From 79ef38b123924c7b9745d7fbc7db4952f7ed5445 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 17 Sep 2016 22:02:38 -0400 Subject: [PATCH] Attempted to use the new `get_cycles_until_next_event` method to take some repetition outside of the PLL and drive event loops. --- Storage/Disk/DiskDrive.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Storage/Disk/DiskDrive.cpp b/Storage/Disk/DiskDrive.cpp index 29f9cb4eb..681a9e94d 100644 --- a/Storage/Disk/DiskDrive.cpp +++ b/Storage/Disk/DiskDrive.cpp @@ -85,11 +85,14 @@ void Drive::run_for_cycles(int number_of_cycles) if(has_disk()) { number_of_cycles *= _clock_rate_multiplier; - while(number_of_cycles--) + while(number_of_cycles) { - _cycles_since_index_hole ++; - _pll->run_for_cycles(1); - TimedEventLoop::run_for_cycles(1); + int cycles_until_next_event = (int)get_cycles_until_next_event(); + int cycles_to_run_for = std::min(cycles_until_next_event, number_of_cycles); + _cycles_since_index_hole += (unsigned int)cycles_to_run_for; + number_of_cycles -= cycles_to_run_for; + _pll->run_for_cycles(cycles_to_run_for); + TimedEventLoop::run_for_cycles(cycles_to_run_for); } } }