From 669e0caff5d0e7b2fe8a3e704a54798a2c31a181 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 19 Aug 2017 22:06:56 -0400 Subject: [PATCH] Ensured the head_unload_delay values are properly seeded, and generalised the quick escape. --- Components/8272/i8272.cpp | 4 +++- Components/8272/i8272.hpp | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Components/8272/i8272.cpp b/Components/8272/i8272.cpp index e6b79f217..5a1958dbb 100644 --- a/Components/8272/i8272.cpp +++ b/Components/8272/i8272.cpp @@ -128,6 +128,7 @@ void i8272::run_for(Cycles cycles) { // check for any head unloads if(head_timers_running_) { + int timers_left = head_timers_running_; for(int c = 0; c < 4; c++) { for(int h = 0; h < 2; h++) { if(drives_[c].head_unload_delay[c] > 0) { @@ -135,10 +136,11 @@ void i8272::run_for(Cycles cycles) { drives_[c].head_unload_delay[c] = 0; drives_[c].head_is_loaded[c] = false; head_timers_running_--; - if(!head_timers_running_) return; } else { drives_[c].head_unload_delay[c] -= cycles.as_int(); } + timers_left--; + if(!timers_left) return; } } } diff --git a/Components/8272/i8272.hpp b/Components/8272/i8272.hpp index 44dc899af..62ff35db9 100644 --- a/Components/8272/i8272.hpp +++ b/Components/8272/i8272.hpp @@ -102,7 +102,8 @@ class i8272: public Storage::Disk::MFMController { Drive() : head_position(0), phase(NotSeeking), drive(new Storage::Disk::Drive), - head_is_loaded{false, false} {}; + head_is_loaded{false, false}, + head_unload_delay{0, 0} {}; } drives_[4]; int drives_seeking_;