From c2f6799f0ceb0f0e80267d8d048c667b63f21852 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 19 Oct 2017 22:02:34 -0400 Subject: [PATCH] Implements Vic-20 restore key. --- Machines/Commodore/Vic-20/Vic20.cpp | 19 +++++++++---------- Machines/Commodore/Vic-20/Vic20.hpp | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index 2f6261140..0549514ec 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -119,14 +119,10 @@ class KeyboardVIA: public MOS::MOS6522::IRQDelegatePortHandler { /// Sets whether @c key @c is_pressed. void set_key_state(uint16_t key, bool is_pressed) { - if(key == KeyRestore) { - // TODO: how is restore wired? - } else { - if(is_pressed) - columns_[key & 7] &= ~(key >> 3); - else - columns_[key & 7] |= (key >> 3); - } + if(is_pressed) + columns_[key & 7] &= ~(key >> 3); + else + columns_[key & 7] |= (key >> 3); } /// Sets all keys as unpressed. @@ -375,8 +371,11 @@ class ConcreteMachine: return !media.tapes.empty() || (!media.disks.empty() && c1540_ != nullptr) || !media.cartridges.empty(); } - void set_key_state(uint16_t key, bool isPressed) override final { - keyboard_via_port_handler_->set_key_state(key, isPressed); + void set_key_state(uint16_t key, bool is_pressed) override final { + if(key != KeyRestore) + keyboard_via_port_handler_->set_key_state(key, is_pressed); + else + user_port_via_.set_control_line_input(MOS::MOS6522::Port::A, MOS::MOS6522::Line::One, !is_pressed); } void clear_all_keys() override final { diff --git a/Machines/Commodore/Vic-20/Vic20.hpp b/Machines/Commodore/Vic-20/Vic20.hpp index 829c207f6..10bc09365 100644 --- a/Machines/Commodore/Vic-20/Vic20.hpp +++ b/Machines/Commodore/Vic-20/Vic20.hpp @@ -57,7 +57,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), - KeyRestore = 0xfffe + KeyRestore = 0xfffd #undef key };