From 98f5d0cdb70cfc6253f53d5ba5519947d220234c Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 28 Feb 2024 21:36:55 -0500 Subject: [PATCH] Propagate reset to the auxiliary switches. --- Machines/Apple/AppleII/AppleII.cpp | 12 ++++++++---- Machines/Apple/AppleII/AuxiliaryMemorySwitches.hpp | 12 ++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Machines/Apple/AppleII/AppleII.cpp b/Machines/Apple/AppleII/AppleII.cpp index b322e8960..f8fc8305f 100644 --- a/Machines/Apple/AppleII/AppleII.cpp +++ b/Machines/Apple/AppleII/AppleII.cpp @@ -362,7 +362,7 @@ template // MARK: - Keyboard and typing. struct Keyboard: public Inputs::Keyboard { - Keyboard(Processor *m6502) : m6502_(m6502) {} + Keyboard(Processor &m6502, AuxiliaryMemorySwitches &switches) : m6502_(m6502), auxiliary_switches_(switches) {} void reset_all_keys() final { open_apple_is_pressed = @@ -454,7 +454,10 @@ template // Accept a bunch non-symbolic other keys, as // reset, in the hope that the user can find // at least one usable key. - m6502_->set_reset_line(is_pressed); + m6502_.set_reset_line(is_pressed); + if(!is_pressed) { + auxiliary_switches_.reset(); + } return true; default: @@ -556,7 +559,8 @@ template std::unique_ptr string_serialiser_; // 6502 connection, for applying the reset button. - Processor *const m6502_; + Processor &m6502_; + AuxiliaryMemorySwitches &auxiliary_switches_; }; Keyboard keyboard_; @@ -574,7 +578,7 @@ template speaker_(lowpass_source()), language_card_(*this), auxiliary_switches_(*this), - keyboard_(&m6502_) { + keyboard_(m6502_, auxiliary_switches_) { // This is where things get slightly convoluted: establish the machine as having a clock rate // equal to the number of cycles of work the 6502 will actually achieve. Which is less than diff --git a/Machines/Apple/AppleII/AuxiliaryMemorySwitches.hpp b/Machines/Apple/AppleII/AuxiliaryMemorySwitches.hpp index 9c2e760ff..f4abba555 100644 --- a/Machines/Apple/AppleII/AuxiliaryMemorySwitches.hpp +++ b/Machines/Apple/AppleII/AuxiliaryMemorySwitches.hpp @@ -90,6 +90,10 @@ template class AuxiliaryMemorySwitches { bool alternative_zero_page = false; bool video_page_2 = false; bool high_resolution = false; + + void reset() { + *this = SwitchState(); + } }; AuxiliaryMemorySwitches(Machine &machine) : machine_(machine) {} @@ -208,6 +212,14 @@ template class AuxiliaryMemorySwitches { return switches_; } + void reset() { + switches_.reset(); + + set_main_paging(); + set_zero_page_paging(); + set_card_paging(); + } + private: Machine &machine_; SwitchState switches_;