diff --git a/Processors/68000/68000.hpp b/Processors/68000/68000.hpp index 61bfa2ede..5e525ecc6 100644 --- a/Processors/68000/68000.hpp +++ b/Processors/68000/68000.hpp @@ -451,6 +451,13 @@ template cla halt_ = halt; } + /// @returns The current phase of the E clock; this will be a number of + /// half-cycles between 0 and 19 inclusive, indicating how far the 68000 + /// is into the current E cycle. + HalfCycles get_e_clock_phase() { + return e_clock_phase_; + } + private: T &bus_handler_; }; diff --git a/Processors/68000/Implementation/68000Implementation.hpp b/Processors/68000/Implementation/68000Implementation.hpp index 92fc359b6..87f0aba13 100644 --- a/Processors/68000/Implementation/68000Implementation.hpp +++ b/Processors/68000/Implementation/68000Implementation.hpp @@ -139,7 +139,9 @@ template void Proces // Extend length by: (i) distance to next E low, plus (ii) difference between // current length and a whole E cycle. cycle_copy.length = HalfCycles(20); // i.e. one E cycle in length. - cycle_copy.length += (e_clock_phase_ + cycles_run_for) % 10; + cycle_copy.length += (e_clock_phase_ + cycles_run_for) % 20; + + // TODO: verify logic above; I'm not persuaded. cycles_run_for += cycle_copy.length + @@ -2191,7 +2193,7 @@ template void Proces #undef destination_address bus_handler_.flush(); - e_clock_phase_ = (e_clock_phase_ + cycles_run_for) % 10; + e_clock_phase_ = (e_clock_phase_ + cycles_run_for) % 20; half_cycles_left_to_run_ = remaining_duration - cycles_run_for; }