From 98f5d0cdb70cfc6253f53d5ba5519947d220234c Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 28 Feb 2024 21:36:55 -0500 Subject: [PATCH 1/2] 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_; From 0f691766eedcd096611c6564836bd9d932a84957 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 28 Feb 2024 22:13:22 -0500 Subject: [PATCH 2/2] Double flash rate. --- Machines/Apple/AppleII/VideoSwitches.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Machines/Apple/AppleII/VideoSwitches.hpp b/Machines/Apple/AppleII/VideoSwitches.hpp index 6763d642b..39a714caa 100644 --- a/Machines/Apple/AppleII/VideoSwitches.hpp +++ b/Machines/Apple/AppleII/VideoSwitches.hpp @@ -310,7 +310,14 @@ template class VideoSwitches { bool annunciator_3 = false; } external_, internal_; - int flash_length = 8406; + // 8406 lines covers a complete on-off cycle, i.e. because the Apple II has a line + // rate of around 15734.26 lines/second, flashing has a frequency of roughly + // 15734.26 / 8406, or roughly 1.83Hz. + // + // Internally that's modelled by a counter that goes to **twice** the value of the + // constant specified below. Hence the divide by two. + static constexpr int flash_length = 8406 / 2; + int flash_ = 0; uint8_t flash_mask() const { return uint8_t((flash_ / flash_length) * 0xff);