From fadd3bc6fc7506651bbe8a988a8fa1cc261cefb7 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 15 Feb 2024 13:57:11 -0500 Subject: [PATCH 1/4] Eliminate 'unused' error. --- Machines/Apple/ADB/ReactiveDevice.cpp | 2 +- .../xcshareddata/xcschemes/Clock Signal.xcscheme | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Machines/Apple/ADB/ReactiveDevice.cpp b/Machines/Apple/ADB/ReactiveDevice.cpp index 1ba80f462..04579459c 100644 --- a/Machines/Apple/ADB/ReactiveDevice.cpp +++ b/Machines/Apple/ADB/ReactiveDevice.cpp @@ -13,7 +13,7 @@ using namespace Apple::ADB; namespace { -Log::Logger logger; +[[maybe_unused]] Log::Logger logger; } ReactiveDevice::ReactiveDevice(Apple::ADB::Bus &bus, uint8_t adb_device_id) : diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme index 474fa352e..19b54b90e 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme +++ b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme @@ -62,7 +62,7 @@ Date: Fri, 16 Feb 2024 08:56:01 -0500 Subject: [PATCH 2/4] Apply applicable deferred actions before lookahead. --- ClockReceiver/DeferredQueue.hpp | 5 +++++ Machines/Apple/AppleII/AppleII.cpp | 5 ++++- Machines/Apple/AppleII/Video.hpp | 1 - Machines/Apple/AppleII/VideoSwitches.hpp | 4 ++++ .../xcshareddata/xcschemes/Clock Signal.xcscheme | 2 +- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ClockReceiver/DeferredQueue.hpp b/ClockReceiver/DeferredQueue.hpp index 5dfbfd0ea..c639ea411 100644 --- a/ClockReceiver/DeferredQueue.hpp +++ b/ClockReceiver/DeferredQueue.hpp @@ -73,6 +73,11 @@ template class DeferredQueue { } } + /// @returns @c true if no actions are enqueued; @c false otherwise. + bool empty() const { + return pending_actions_.empty(); + } + private: // The list of deferred actions. struct DeferredAction { diff --git a/Machines/Apple/AppleII/AppleII.cpp b/Machines/Apple/AppleII/AppleII.cpp index 210e592be..c56a3d4a1 100644 --- a/Machines/Apple/AppleII/AppleII.cpp +++ b/Machines/Apple/AppleII/AppleII.cpp @@ -742,6 +742,9 @@ template // actor, but this will actually be the result most of the time so it's not // too terrible. if(isReadOperation(operation) && address != 0xc000) { + if(video_.has_deferred_actions()) { + update_video(); + } *value = video_.get_last_read_value(cycles_since_video_update_); } @@ -851,7 +854,7 @@ template case 0xc050: case 0xc051: update_video(); - video_.set_text(!!(address&1)); + video_.set_text(address&1); break; case 0xc052: update_video(); video_.set_mixed(false); break; case 0xc053: update_video(); video_.set_mixed(true); break; diff --git a/Machines/Apple/AppleII/Video.hpp b/Machines/Apple/AppleII/Video.hpp index 26e230b1d..ce0814a3b 100644 --- a/Machines/Apple/AppleII/Video.hpp +++ b/Machines/Apple/AppleII/Video.hpp @@ -10,7 +10,6 @@ #include "../../../Outputs/CRT/CRT.hpp" #include "../../../ClockReceiver/ClockReceiver.hpp" -#include "../../../ClockReceiver/DeferredQueue.hpp" #include "VideoSwitches.hpp" diff --git a/Machines/Apple/AppleII/VideoSwitches.hpp b/Machines/Apple/AppleII/VideoSwitches.hpp index 159cd0491..6763d642b 100644 --- a/Machines/Apple/AppleII/VideoSwitches.hpp +++ b/Machines/Apple/AppleII/VideoSwitches.hpp @@ -247,6 +247,10 @@ template class VideoSwitches { } } + bool has_deferred_actions() const { + return !deferrer_.empty(); + } + protected: GraphicsMode graphics_mode(int row) const { if( diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme index 19b54b90e..474fa352e 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme +++ b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme @@ -62,7 +62,7 @@ Date: Fri, 16 Feb 2024 08:57:43 -0500 Subject: [PATCH 3/4] Remove further !!s. --- Machines/Apple/AppleII/AppleII.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Machines/Apple/AppleII/AppleII.cpp b/Machines/Apple/AppleII/AppleII.cpp index c56a3d4a1..795f1e50a 100644 --- a/Machines/Apple/AppleII/AppleII.cpp +++ b/Machines/Apple/AppleII/AppleII.cpp @@ -829,19 +829,19 @@ template case 0xc000: case 0xc001: update_video(); - video_.set_80_store(!!(address&1)); + video_.set_80_store(address&1); break; case 0xc00c: case 0xc00d: update_video(); - video_.set_80_columns(!!(address&1)); + video_.set_80_columns(address&1); break; case 0xc00e: case 0xc00f: update_video(); - video_.set_alternative_character_set(!!(address&1)); + video_.set_alternative_character_set(address&1); break; } } From e8036127fe825b51d9acc65b5e65e91e8034c1af Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 16 Feb 2024 09:19:22 -0500 Subject: [PATCH 4/4] Add some commentary. --- Machines/Apple/AppleII/AppleII.cpp | 2 ++ Machines/Apple/AppleII/Video.hpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Machines/Apple/AppleII/AppleII.cpp b/Machines/Apple/AppleII/AppleII.cpp index 795f1e50a..4ca222a3d 100644 --- a/Machines/Apple/AppleII/AppleII.cpp +++ b/Machines/Apple/AppleII/AppleII.cpp @@ -742,6 +742,8 @@ template // actor, but this will actually be the result most of the time so it's not // too terrible. if(isReadOperation(operation) && address != 0xc000) { + // Ensure any enqueued video changes are applied before grabbing the + // vapour value. if(video_.has_deferred_actions()) { update_video(); } diff --git a/Machines/Apple/AppleII/Video.hpp b/Machines/Apple/AppleII/Video.hpp index ce0814a3b..fe6ce1504 100644 --- a/Machines/Apple/AppleII/Video.hpp +++ b/Machines/Apple/AppleII/Video.hpp @@ -123,7 +123,8 @@ template class Video: public VideoBase { bus_handler_(bus_handler) {} /*! - Obtains the last value the video read prior to time now+offset. + Obtains the last value the video read prior to time now+offset, according to the *current* + video mode, i.e. not allowing for any changes still enqueued. */ uint8_t get_last_read_value(Cycles offset) { // Rules of generation: