From 45b169f341aca39f728bc49a2b4a851388197033 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 5 Nov 2016 15:28:03 -0400 Subject: [PATCH] Made a few mapping fixes, clarified where the default reset code lives, ensured the Oric and Vic clear their keys when the typer ends. --- Machines/Commodore/Vic-20/Typer.cpp | 30 ++++++++++++++--------------- Machines/Commodore/Vic-20/Vic20.cpp | 3 +++ Machines/Commodore/Vic-20/Vic20.hpp | 2 +- Machines/Electron/Typer.cpp | 2 +- Machines/Oric/Oric.cpp | 6 +++++- Machines/Typer.cpp | 5 ----- Machines/Typer.hpp | 3 ++- 7 files changed, 27 insertions(+), 24 deletions(-) diff --git a/Machines/Commodore/Vic-20/Typer.cpp b/Machines/Commodore/Vic-20/Typer.cpp index efcfbca00..9cf018e4f 100644 --- a/Machines/Commodore/Vic-20/Typer.cpp +++ b/Machines/Commodore/Vic-20/Typer.cpp @@ -46,21 +46,21 @@ uint16_t *Commodore::Vic20::Machine::sequence_for_character(Utility::Typer *type /* : */ KEYS(KeyColon), /* ; */ KEYS(KeySemicolon), /* < */ SHIFT(KeyComma), /* = */ KEYS(KeyEquals), /* > */ SHIFT(KeyFullStop), /* ? */ SHIFT(KeySlash), - /* @ */ KEYS(KeyAt), /* A */ SHIFT(KeyA), - /* B */ SHIFT(KeyB), /* C */ SHIFT(KeyC), - /* D */ SHIFT(KeyD), /* E */ SHIFT(KeyE), - /* F */ SHIFT(KeyF), /* G */ SHIFT(KeyG), - /* H */ SHIFT(KeyH), /* I */ SHIFT(KeyI), - /* J */ SHIFT(KeyJ), /* K */ SHIFT(KeyK), - /* L */ SHIFT(KeyL), /* M */ SHIFT(KeyM), - /* N */ SHIFT(KeyN), /* O */ SHIFT(KeyO), - /* P */ SHIFT(KeyP), /* Q */ SHIFT(KeyQ), - /* R */ SHIFT(KeyR), /* S */ SHIFT(KeyS), - /* T */ SHIFT(KeyT), /* U */ SHIFT(KeyU), - /* V */ SHIFT(KeyV), /* W */ SHIFT(KeyW), - /* X */ SHIFT(KeyX), /* Y */ SHIFT(KeyY), - /* Z */ SHIFT(KeyZ), /* [ */ SHIFT(KeyColon), - /* \ */ X, /* ] */ SHIFT(KeyFullStop), + /* @ */ KEYS(KeyAt), /* A */ KEYS(KeyA), + /* B */ KEYS(KeyB), /* C */ KEYS(KeyC), + /* D */ KEYS(KeyD), /* E */ KEYS(KeyE), + /* F */ KEYS(KeyF), /* G */ KEYS(KeyG), + /* H */ KEYS(KeyH), /* I */ KEYS(KeyI), + /* J */ KEYS(KeyJ), /* K */ KEYS(KeyK), + /* L */ KEYS(KeyL), /* M */ KEYS(KeyM), + /* N */ KEYS(KeyN), /* O */ KEYS(KeyO), + /* P */ KEYS(KeyP), /* Q */ KEYS(KeyQ), + /* R */ KEYS(KeyR), /* S */ KEYS(KeyS), + /* T */ KEYS(KeyT), /* U */ KEYS(KeyU), + /* V */ KEYS(KeyV), /* W */ KEYS(KeyW), + /* X */ KEYS(KeyX), /* Y */ KEYS(KeyY), + /* Z */ KEYS(KeyZ), /* [ */ SHIFT(KeyColon), + /* \ */ X, /* ] */ SHIFT(KeySemicolon), /* ^ */ X, /* _ */ X, /* ` */ X, /* a */ KEYS(KeyA), /* b */ KEYS(KeyB), /* c */ KEYS(KeyC), diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index 8b803c752..48617d124 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -162,7 +162,10 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin if(_typer && operation == CPU6502::BusOperation::ReadOpcode && address == 0xEB1E) { if(!_typer->type_next_character()) + { + clear_all_keys(); _typer.reset(); + } } _tape.run_for_cycles(1); if(_c1540) _c1540->run_for_cycles(1); diff --git a/Machines/Commodore/Vic-20/Vic20.hpp b/Machines/Commodore/Vic-20/Vic20.hpp index 0c0b1b187..61d3c62e7 100644 --- a/Machines/Commodore/Vic-20/Vic20.hpp +++ b/Machines/Commodore/Vic-20/Vic20.hpp @@ -64,7 +64,7 @@ enum Key: uint16_t { Key1 = key(0, 0x01), Key3 = key(0, 0x02), Key5 = key(0, 0x04), Key7 = key(0, 0x08), Key9 = key(0, 0x10), KeyPlus = key(0, 0x20), KeyGBP = key(0, 0x40), KeyDelete = key(0, 0x80), - TerminateSequence = 0, NotMapped = 0xffff + TerminateSequence = 0xffff, NotMapped = 0xfffe }; enum JoystickInput { diff --git a/Machines/Electron/Typer.cpp b/Machines/Electron/Typer.cpp index 6a01c77dc..31bc92f3e 100644 --- a/Machines/Electron/Typer.cpp +++ b/Machines/Electron/Typer.cpp @@ -15,7 +15,7 @@ int Electron::Machine::get_typer_delay() int Electron::Machine::get_typer_frequency() { - return 625*128; // accept a new character every frame + return 625*128*2; // accept a new character every two frames } uint16_t *Electron::Machine::sequence_for_character(Utility::Typer *typer, char character) diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index ac7c4a1e4..64f53df89 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -81,7 +81,11 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin if(_typer && operation == CPU6502::BusOperation::ReadOpcode && address == 0xF495) { - if(!_typer->type_next_character()) _typer.reset(); + if(!_typer->type_next_character()) + { + clear_all_keys(); + _typer.reset(); + } } _via.run_for_cycles(1); diff --git a/Machines/Typer.cpp b/Machines/Typer.cpp index ac074240e..43a527b0d 100644 --- a/Machines/Typer.cpp +++ b/Machines/Typer.cpp @@ -89,11 +89,6 @@ bool Typer::Delegate::typer_set_next_character(Utility::Typer *typer, char chara return false; } -void Typer::Delegate::typer_reset(Typer *typer) -{ - clear_all_keys(); -} - uint16_t *Typer::Delegate::sequence_for_character(Typer *typer, char character) { return nullptr; diff --git a/Machines/Typer.hpp b/Machines/Typer.hpp index e6b172e15..4a5958414 100644 --- a/Machines/Typer.hpp +++ b/Machines/Typer.hpp @@ -19,7 +19,7 @@ class Typer { class Delegate: public KeyboardMachine::Machine { public: virtual bool typer_set_next_character(Typer *typer, char character, int phase); - virtual void typer_reset(Typer *typer); + virtual void typer_reset(Typer *typer) = 0; virtual uint16_t *sequence_for_character(Typer *typer, char character); @@ -52,6 +52,7 @@ class TypeRecipient: public Typer::Delegate { void typer_reset(Typer *typer) { + clear_all_keys(); _typer.reset(); }