From b9177e50d300ff0e13aa00af1c3bc244bf9ff98d Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 4 Mar 2025 09:57:34 -0500 Subject: [PATCH] Commute 'speed' to 'model approximation'. --- Analyser/Static/PCCompatible/Target.hpp | 12 +++++----- Machines/PCCompatible/PCCompatible.cpp | 22 ++++++++++--------- .../StaticAnalyser/CSStaticAnalyser.mm | 4 ++-- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Analyser/Static/PCCompatible/Target.hpp b/Analyser/Static/PCCompatible/Target.hpp index ad94736e2..3a85b15e3 100644 --- a/Analyser/Static/PCCompatible/Target.hpp +++ b/Analyser/Static/PCCompatible/Target.hpp @@ -19,10 +19,10 @@ struct Target: public Analyser::Static::Target, public Reflection::StructImpl; void declare_fields() { AnnounceEnum(VideoAdaptor); - AnnounceEnum(Speed); + AnnounceEnum(ModelApproximation); DeclareField(adaptor); - DeclareField(speed); + DeclareField(model); } }; diff --git a/Machines/PCCompatible/PCCompatible.cpp b/Machines/PCCompatible/PCCompatible.cpp index 6381d88a8..ab0bf5c29 100644 --- a/Machines/PCCompatible/PCCompatible.cpp +++ b/Machines/PCCompatible/PCCompatible.cpp @@ -893,7 +893,7 @@ class ConcreteMachine: context(pit_, dma_, ppi_, pic_, video_, fdc_, rtc_) { // Capture speed. - speed_ = target.speed; + model_ = target.model; // Set up DMA source/target. dma_.set_memory(&context.memory); @@ -938,18 +938,20 @@ class ConcreteMachine: // MARK: - TimedMachine. void run_for(const Cycles duration) override { - switch(speed_) { - case Target::Speed::ApproximatelyOriginal: run_for(duration); break; - case Target::Speed::Fast: run_for(duration); break; + using Model = Target::ModelApproximation; + switch(model_) { + case Model::XT: run_for(duration); break; + case Model::TurboXT: run_for(duration); break; } } - template + template void run_for(const Cycles duration) { const auto pit_ticks = duration.as(); + constexpr bool is_fast = model == Target::ModelApproximation::TurboXT; int ticks; - if constexpr (speed == Target::Speed::Fast) { + if constexpr (is_fast) { ticks = pit_ticks; } else { cpu_divisor_ += pit_ticks; @@ -970,7 +972,7 @@ class ConcreteMachine: // For original speed, the CPU performs instructions at a 1/3rd divider of the PIT clock, // so run the PIT three times per 'tick'. - if constexpr (speed == Target::Speed::ApproximatelyOriginal) { + if constexpr (is_fast) { pit_.run_for(1); ++speaker_.cycles_since_update; pit_.run_for(1); @@ -980,7 +982,7 @@ class ConcreteMachine: // // Advance CRTC at a more approximate rate. // - video_.run_for(speed == Target::Speed::Fast ? Cycles(1) : Cycles(3)); + video_.run_for(is_fast ? Cycles(1) : Cycles(3)); // // Give the keyboard a notification of passing time; it's very approximately clocked, @@ -1014,7 +1016,7 @@ class ConcreteMachine: continue; } - if constexpr (speed == Target::Speed::Fast) { + if constexpr (is_fast) { // There's no divider applied, so this makes for 2*PIT = around 2.4 MIPS. // That's broadly 80286 speed, if MIPS were a valid measure. perform_instruction(); @@ -1198,7 +1200,7 @@ class ConcreteMachine: std::pair> decoded; int cpu_divisor_ = 0; - Target::Speed speed_{}; + Target::ModelApproximation model_{}; }; diff --git a/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm b/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm index a17860b88..eb0097c59 100644 --- a/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm +++ b/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm @@ -302,8 +302,8 @@ case CSPCCompatibleVideoAdaptorCGA: target->adaptor = Target::VideoAdaptor::CGA; break; } switch(speed) { - case CSPCCompatibleSpeedOriginal: target->speed = Target::Speed::ApproximatelyOriginal; break; - case CSPCCompatibleSpeedTurbo: target->speed = Target::Speed::Fast; break; + case CSPCCompatibleSpeedOriginal: target->model = Target::ModelApproximation::XT; break; + case CSPCCompatibleSpeedTurbo: target->model = Target::ModelApproximation::TurboXT; break; } _targets.push_back(std::move(target)); }