1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-25 18:30:07 +00:00

Merge pull request #1333 from TomHarte/DeferredSwitches

Apple II: Apply deferred video actions before getting vapour value.
This commit is contained in:
Thomas Harte 2024-02-16 10:08:23 -05:00 committed by GitHub
commit a758112084
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 21 additions and 7 deletions

View File

@ -73,6 +73,11 @@ template <typename TimeUnit> class DeferredQueue {
} }
} }
/// @returns @c true if no actions are enqueued; @c false otherwise.
bool empty() const {
return pending_actions_.empty();
}
private: private:
// The list of deferred actions. // The list of deferred actions.
struct DeferredAction { struct DeferredAction {

View File

@ -13,7 +13,7 @@
using namespace Apple::ADB; using namespace Apple::ADB;
namespace { namespace {
Log::Logger<Log::Source::ADBDevice> logger; [[maybe_unused]] Log::Logger<Log::Source::ADBDevice> logger;
} }
ReactiveDevice::ReactiveDevice(Apple::ADB::Bus &bus, uint8_t adb_device_id) : ReactiveDevice::ReactiveDevice(Apple::ADB::Bus &bus, uint8_t adb_device_id) :

View File

@ -742,6 +742,11 @@ template <Analyser::Static::AppleII::Target::Model model, bool has_mockingboard>
// actor, but this will actually be the result most of the time so it's not // actor, but this will actually be the result most of the time so it's not
// too terrible. // too terrible.
if(isReadOperation(operation) && address != 0xc000) { if(isReadOperation(operation) && address != 0xc000) {
// Ensure any enqueued video changes are applied before grabbing the
// vapour value.
if(video_.has_deferred_actions()) {
update_video();
}
*value = video_.get_last_read_value(cycles_since_video_update_); *value = video_.get_last_read_value(cycles_since_video_update_);
} }
@ -826,19 +831,19 @@ template <Analyser::Static::AppleII::Target::Model model, bool has_mockingboard>
case 0xc000: case 0xc000:
case 0xc001: case 0xc001:
update_video(); update_video();
video_.set_80_store(!!(address&1)); video_.set_80_store(address&1);
break; break;
case 0xc00c: case 0xc00c:
case 0xc00d: case 0xc00d:
update_video(); update_video();
video_.set_80_columns(!!(address&1)); video_.set_80_columns(address&1);
break; break;
case 0xc00e: case 0xc00e:
case 0xc00f: case 0xc00f:
update_video(); update_video();
video_.set_alternative_character_set(!!(address&1)); video_.set_alternative_character_set(address&1);
break; break;
} }
} }
@ -851,7 +856,7 @@ template <Analyser::Static::AppleII::Target::Model model, bool has_mockingboard>
case 0xc050: case 0xc050:
case 0xc051: case 0xc051:
update_video(); update_video();
video_.set_text(!!(address&1)); video_.set_text(address&1);
break; break;
case 0xc052: update_video(); video_.set_mixed(false); break; case 0xc052: update_video(); video_.set_mixed(false); break;
case 0xc053: update_video(); video_.set_mixed(true); break; case 0xc053: update_video(); video_.set_mixed(true); break;

View File

@ -10,7 +10,6 @@
#include "../../../Outputs/CRT/CRT.hpp" #include "../../../Outputs/CRT/CRT.hpp"
#include "../../../ClockReceiver/ClockReceiver.hpp" #include "../../../ClockReceiver/ClockReceiver.hpp"
#include "../../../ClockReceiver/DeferredQueue.hpp"
#include "VideoSwitches.hpp" #include "VideoSwitches.hpp"
@ -124,7 +123,8 @@ template <class BusHandler, bool is_iie> class Video: public VideoBase {
bus_handler_(bus_handler) {} 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) { uint8_t get_last_read_value(Cycles offset) {
// Rules of generation: // Rules of generation:

View File

@ -247,6 +247,10 @@ template <typename TimeUnit> class VideoSwitches {
} }
} }
bool has_deferred_actions() const {
return !deferrer_.empty();
}
protected: protected:
GraphicsMode graphics_mode(int row) const { GraphicsMode graphics_mode(int row) const {
if( if(