From 4fec625b1904942a00dec2059b572d297f15ad51 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 12 Jun 2016 10:38:21 -0400 Subject: [PATCH] Minor cleaning, implemented `clearAllKeys`. --- Machines/Vic-20/Vic20.hpp | 18 ++++++++---------- .../Mac/Clock Signal/Wrappers/CSVic20.mm | 13 ++++++++----- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Machines/Vic-20/Vic20.hpp b/Machines/Vic-20/Vic20.hpp index 3d62adc20..47dcb71df 100644 --- a/Machines/Vic-20/Vic20.hpp +++ b/Machines/Vic-20/Vic20.hpp @@ -51,15 +51,13 @@ class KeyboardVIA: public MOS::MOS6522 { public: void set_key_state(Key key, bool isPressed) { if(isPressed) - { _columns[key & 7] &= ~(key >> 3); -// printf("!!!\n"); - } else - { _columns[key & 7] |= (key >> 3); -// printf("???\n"); - } + } + + void clear_all_keys() { + memset(_columns, 0xff, sizeof(_columns)); } // to satisfy MOS::MOS6522 @@ -71,8 +69,6 @@ class KeyboardVIA: public MOS::MOS6522 { if(!(_activation_mask&(1 << c))) result &= _columns[c]; } -// if(_activation_mask) -// printf("%02x => %02x\n", _activation_mask, result); return result; } @@ -82,10 +78,11 @@ class KeyboardVIA: public MOS::MOS6522 { void set_port_output(int port, uint8_t value) { if(port) _activation_mask = value; -// printf("<- %02x\n", port, value); } - KeyboardVIA() : _columns{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} {} + KeyboardVIA() { + clear_all_keys(); + } private: uint8_t _columns[8]; uint8_t _activation_mask; @@ -99,6 +96,7 @@ class Machine: public CPU6502::Processor, public CRTMachine::Machine, p void set_rom(ROMSlot slot, size_t length, const uint8_t *data); void add_prg(size_t length, const uint8_t *data); void set_key_state(Key key, bool isPressed) { _keyboardVIA->set_key_state(key, isPressed); } + void clear_all_keys() { _keyboardVIA->clear_all_keys(); } // to satisfy CPU6502::Processor unsigned int perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value); diff --git a/OSBindings/Mac/Clock Signal/Wrappers/CSVic20.mm b/OSBindings/Mac/Clock Signal/Wrappers/CSVic20.mm index ebcdfbfeb..cd5a0c18f 100644 --- a/OSBindings/Mac/Clock Signal/Wrappers/CSVic20.mm +++ b/OSBindings/Mac/Clock Signal/Wrappers/CSVic20.mm @@ -86,6 +86,11 @@ @(VK_DownArrow): @(Vic20::Key::KeyDown), }; + // Not yet mapped: + // KeyHome + // KeyPlus + // KeyGBP + @synchronized(self) { switch(key) { @@ -108,12 +113,10 @@ } } -// Not yet mapped: -// KeyHome -// KeyPlus -// KeyGBP - - (void)clearAllKeys { + @synchronized(self) { + _vic20.clear_all_keys(); + } } @end