From 271de23ee6e8cb79a9b5872c55a0a3b890955a48 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 11 Jun 2016 12:26:19 -0400 Subject: [PATCH] Ran on in and introduced a bunch more keys, hopefully to help to diagnose. --- Machines/Vic-20/Vic20.hpp | 30 ++++++++++++--- .../Mac/Clock Signal/Wrappers/CSVic20.mm | 37 +++++++++++++++++++ 2 files changed, 62 insertions(+), 5 deletions(-) diff --git a/Machines/Vic-20/Vic20.hpp b/Machines/Vic-20/Vic20.hpp index 7fa8dbdc6..816a10392 100644 --- a/Machines/Vic-20/Vic20.hpp +++ b/Machines/Vic-20/Vic20.hpp @@ -26,7 +26,22 @@ enum ROMSlot { #define key(line, mask) (((mask) << 3) | (line)) enum Key: uint16_t { - Key2 = key(7, 0x80), Key4 = key(7, 0x40) + Key2 = key(7, 0x01), Key4 = key(7, 0x02), Key6 = key(7, 0x04), Key8 = key(7, 0x08), + Key0 = key(7, 0x10), KeyDash = key(7, 0x20), KeyHome = key(7, 0x40), KeyF7 = key(7, 0x80), + KeyQ = key(6, 0x01), KeyE = key(6, 0x02), KeyT = key(6, 0x04), KeyU = key(6, 0x08), + KeyO = key(6, 0x10), KeyAt = key(6, 0x20), KeyUp = key(6, 0x40), KeyF5 = key(6, 0x80), + KeyCBM = key(5, 0x01), KeyS = key(5, 0x02), KeyF = key(5, 0x04), KeyH = key(5, 0x08), + KeyK = key(5, 0x10), KeyColon = key(5, 0x20), KeyEquals = key(5, 0x40), KeyF3 = key(5, 0x80), + KeySpace = key(4, 0x01), KeyZ = key(4, 0x02), KeyC = key(4, 0x04), KeyB = key(4, 0x08), + KeyM = key(4, 0x10), KeyFullStop = key(4, 0x20), KeyRShift = key(4, 0x40), KeyF1 = key(4, 0x80), + KeyRunStop = key(3, 0x01), KeyLShift = key(3, 0x02), KeyX = key(3, 0x04), KeyV = key(3, 0x08), + KeyN = key(3, 0x10), KeyComma = key(3, 0x20), KeySlash = key(3, 0x40), KeyDown = key(3, 0x80), + KeyControl = key(2, 0x01), KeyA = key(2, 0x02), KeyD = key(2, 0x04), KeyG = key(2, 0x08), + KeyJ = key(2, 0x10), KeyL = key(2, 0x20), KeySemicolon = key(2, 0x40), KeyRight = key(2, 0x80), + KeyLeft = key(1, 0x01), KeyW = key(1, 0x02), KeyR = key(1, 0x04), KeyY = key(1, 0x08), + KeyI = key(1, 0x10), KeyP = key(1, 0x20), KeyAsterisk = key(1, 0x40), KeyReturn = key(1, 0x80), + 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), KeyDel = key(0, 0x80), }; class UserPortVIA: public MOS::MOS6522 { @@ -36,9 +51,9 @@ class KeyboardVIA: public MOS::MOS6522 { public: void set_key_state(Key key, bool isPressed) { if(isPressed) - _columns[key & 0x07] &= ~(key >> 3); + _columns[key & 7] &= ~(key >> 3); else - _columns[key & 0x07] |= (key >> 3); + _columns[key & 7] |= (key >> 3); } // to satisfy MOS::MOS6522 @@ -47,8 +62,11 @@ class KeyboardVIA: public MOS::MOS6522 { uint8_t result = 0xff; for(int c = 0; c < 8; c++) { - if(!(_activation_mask&(1 << c))) result &= _columns[c]; + if(!(_activation_mask&(1 << c))) + result &= _columns[c]; } +// if(_activation_mask) +// printf("%02x => %02x\n", _activation_mask, result); return result; } @@ -56,7 +74,9 @@ class KeyboardVIA: public MOS::MOS6522 { } void set_port_output(int port, uint8_t value) { - if(port) _activation_mask = value; + if(port) + _activation_mask = value; +// printf("%d <= %02x\n", port, value); } KeyboardVIA() : _columns{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} {} diff --git a/OSBindings/Mac/Clock Signal/Wrappers/CSVic20.mm b/OSBindings/Mac/Clock Signal/Wrappers/CSVic20.mm index cd9209d60..250145a7e 100644 --- a/OSBindings/Mac/Clock Signal/Wrappers/CSVic20.mm +++ b/OSBindings/Mac/Clock Signal/Wrappers/CSVic20.mm @@ -42,8 +42,45 @@ @synchronized(self) { switch(key) { + case VK_ANSI_1: _vic20.set_key_state(Vic20::Key::Key1, isPressed); break; case VK_ANSI_2: _vic20.set_key_state(Vic20::Key::Key2, isPressed); break; + case VK_ANSI_3: _vic20.set_key_state(Vic20::Key::Key3, isPressed); break; case VK_ANSI_4: _vic20.set_key_state(Vic20::Key::Key4, isPressed); break; + case VK_ANSI_5: _vic20.set_key_state(Vic20::Key::Key5, isPressed); break; + case VK_ANSI_6: _vic20.set_key_state(Vic20::Key::Key6, isPressed); break; + case VK_ANSI_7: _vic20.set_key_state(Vic20::Key::Key7, isPressed); break; + case VK_ANSI_8: _vic20.set_key_state(Vic20::Key::Key8, isPressed); break; + case VK_ANSI_9: _vic20.set_key_state(Vic20::Key::Key9, isPressed); break; + case VK_ANSI_0: _vic20.set_key_state(Vic20::Key::Key0, isPressed); break; + + case VK_ANSI_Q: _vic20.set_key_state(Vic20::Key::KeyQ, isPressed); break; + case VK_ANSI_W: _vic20.set_key_state(Vic20::Key::KeyW, isPressed); break; + case VK_ANSI_E: _vic20.set_key_state(Vic20::Key::KeyE, isPressed); break; + case VK_ANSI_R: _vic20.set_key_state(Vic20::Key::KeyR, isPressed); break; + case VK_ANSI_T: _vic20.set_key_state(Vic20::Key::KeyT, isPressed); break; + case VK_ANSI_Y: _vic20.set_key_state(Vic20::Key::KeyY, isPressed); break; + case VK_ANSI_U: _vic20.set_key_state(Vic20::Key::KeyU, isPressed); break; + case VK_ANSI_I: _vic20.set_key_state(Vic20::Key::KeyI, isPressed); break; + case VK_ANSI_O: _vic20.set_key_state(Vic20::Key::KeyO, isPressed); break; + case VK_ANSI_P: _vic20.set_key_state(Vic20::Key::KeyP, isPressed); break; + + case VK_ANSI_A: _vic20.set_key_state(Vic20::Key::KeyA, isPressed); break; + case VK_ANSI_S: _vic20.set_key_state(Vic20::Key::KeyS, isPressed); break; + case VK_ANSI_D: _vic20.set_key_state(Vic20::Key::KeyD, isPressed); break; + case VK_ANSI_F: _vic20.set_key_state(Vic20::Key::KeyF, isPressed); break; + case VK_ANSI_G: _vic20.set_key_state(Vic20::Key::KeyG, isPressed); break; + case VK_ANSI_H: _vic20.set_key_state(Vic20::Key::KeyH, isPressed); break; + case VK_ANSI_J: _vic20.set_key_state(Vic20::Key::KeyI, isPressed); break; + case VK_ANSI_K: _vic20.set_key_state(Vic20::Key::KeyO, isPressed); break; + case VK_ANSI_L: _vic20.set_key_state(Vic20::Key::KeyP, isPressed); break; + + case VK_ANSI_Z: _vic20.set_key_state(Vic20::Key::KeyZ, isPressed); break; + case VK_ANSI_X: _vic20.set_key_state(Vic20::Key::KeyX, isPressed); break; + case VK_ANSI_C: _vic20.set_key_state(Vic20::Key::KeyC, isPressed); break; + case VK_ANSI_V: _vic20.set_key_state(Vic20::Key::KeyV, isPressed); break; + case VK_ANSI_B: _vic20.set_key_state(Vic20::Key::KeyB, isPressed); break; + case VK_ANSI_N: _vic20.set_key_state(Vic20::Key::KeyN, isPressed); break; + case VK_ANSI_M: _vic20.set_key_state(Vic20::Key::KeyM, isPressed); break; } } }