From f3fe711542d0cbf50dc236af21280313796ee2ea Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 27 May 2018 23:55:04 -0400 Subject: [PATCH] Attempts to reduce FDC costs. --- Machines/AmstradCPC/AmstradCPC.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Machines/AmstradCPC/AmstradCPC.cpp b/Machines/AmstradCPC/AmstradCPC.cpp index e5557533a..c484b7add 100644 --- a/Machines/AmstradCPC/AmstradCPC.cpp +++ b/Machines/AmstradCPC/AmstradCPC.cpp @@ -746,7 +746,7 @@ class ConcreteMachine: ay_.run_for(cycle.length); // Clock the FDC, if connected, using a lazy scale by two - if(has_fdc_ && !fdc_is_sleeping_) fdc_.run_for(Cycles(cycle.length.as_int())); + time_since_fdc_update_ += cycle.length; // Update typing activity if(typer_) typer_->run_for(cycle.length); @@ -793,11 +793,13 @@ class ConcreteMachine: // Check for an FDC access if(has_fdc_ && (address & 0x580) == 0x100) { + flush_fdc(); fdc_.set_register(address & 1, *cycle.value); } // Check for a disk motor access if(has_fdc_ && !(address & 0x580)) { + flush_fdc(); fdc_.set_motor_on(!!(*cycle.value)); } break; @@ -812,6 +814,7 @@ class ConcreteMachine: // Check for an FDC access if(has_fdc_ && (address & 0x580) == 0x100) { + flush_fdc(); *cycle.value &= fdc_.get_register(address & 1); } @@ -855,6 +858,7 @@ class ConcreteMachine: // Just flush the AY. ay_.update(); ay_.flush(); + flush_fdc(); } /// A CRTMachine function; indicates that outputs should be created now. @@ -967,6 +971,7 @@ class ConcreteMachine: void set_component_prefers_clocking(ClockingHint::Source *component, ClockingHint::Preference clocking) override final { fdc_is_sleeping_ = fdc_.preferred_clocking() == ClockingHint::Preference::None; tape_player_is_sleeping_ = tape_player_.preferred_clocking() == ClockingHint::Preference::None; + printf("FDC: %s, tape %s\n", fdc_is_sleeping_ ? "sleeping" : "regular", tape_player_is_sleeping_ ? "sleeping" : "regular"); } // MARK: - Keyboard @@ -1060,6 +1065,14 @@ class ConcreteMachine: Intel::i8255::i8255 i8255_; FDC fdc_; + HalfCycles time_since_fdc_update_; + void flush_fdc() { + // Clock the FDC, if connected, using a lazy scale by two + if(has_fdc_ && !fdc_is_sleeping_) { + fdc_.run_for(Cycles(time_since_fdc_update_.as_int())); + } + time_since_fdc_update_ = HalfCycles(0); + } InterruptTimer interrupt_timer_; Storage::Tape::BinaryTapePlayer tape_player_;