From 8882aa496fc0ac4eb79cfeab8558dd4c59fa40c0 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 10 Sep 2017 20:51:05 -0400 Subject: [PATCH] Corrected wiring to get `advance` signals through to Drive event delegates. --- Storage/Disk/DiskController.cpp | 2 +- Storage/Disk/Drive.cpp | 9 ++++++--- Storage/Disk/Drive.hpp | 3 ++- Storage/Disk/Encodings/MFM.cpp | 1 - 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Storage/Disk/DiskController.cpp b/Storage/Disk/DiskController.cpp index 4b2ee7a9e..62a66ee79 100644 --- a/Storage/Disk/DiskController.cpp +++ b/Storage/Disk/DiskController.cpp @@ -48,7 +48,7 @@ void Controller::process_event(const Track::Event &event) { } void Controller::advance(const Cycles cycles) { - pll_->run_for(cycles); + pll_->run_for(Cycles(cycles.as_int() * clock_rate_multiplier_)); } void Controller::process_write_completed() { diff --git a/Storage/Disk/Drive.cpp b/Storage/Disk/Drive.cpp index 6e12dc70f..afa5e4938 100644 --- a/Storage/Disk/Drive.cpp +++ b/Storage/Disk/Drive.cpp @@ -91,6 +91,10 @@ void Drive::set_event_delegate(Storage::Disk::Drive::EventDelegate *delegate) { event_delegate_ = delegate; } +void Drive::advance(const Cycles cycles) { + if(event_delegate_) event_delegate_->advance(cycles); +} + void Drive::run_for(const Cycles cycles) { Time zero(0); @@ -111,9 +115,7 @@ void Drive::run_for(const Cycles cycles) { cycles_since_index_hole_ += (unsigned int)cycles_to_run_for; number_of_cycles -= cycles_to_run_for; - if(is_reading_) { - if(event_delegate_) event_delegate_->advance(Cycles(cycles_to_run_for)); - } else { + if(!is_reading_) { if(cycles_until_bits_written_ > zero) { Storage::Time cycles_to_run_for_time(cycles_to_run_for); if(cycles_until_bits_written_ <= cycles_to_run_for_time) { @@ -152,6 +154,7 @@ void Drive::get_next_event(const Time &duration_already_passed) { void Drive::process_next_event() { // TODO: ready test here. + if(current_event_.type == Track::Event::IndexHole) cycles_since_index_hole_ = 0; if(event_delegate_) event_delegate_->process_event(current_event_); get_next_event(Time(0)); } diff --git a/Storage/Disk/Drive.hpp b/Storage/Disk/Drive.hpp index b11d23fb6..59a25201c 100644 --- a/Storage/Disk/Drive.hpp +++ b/Storage/Disk/Drive.hpp @@ -146,7 +146,7 @@ class Drive: public Sleeper, public TimedEventLoop { // If the drive is not currently reading then it is writing. While writing // it can optionally be told to clamp to the index hole. - bool is_reading_ = false; + bool is_reading_ = true; bool clamp_writing_to_index_hole_ = false; // If writing is occurring then the drive will be accumulating a write segment, @@ -166,6 +166,7 @@ class Drive: public Sleeper, public TimedEventLoop { // TimedEventLoop call-ins and state. void process_next_event(); void get_next_event(const Time &duration_already_passed); + void advance(const Cycles cycles); Track::Event current_event_; // Helper for track changes. diff --git a/Storage/Disk/Encodings/MFM.cpp b/Storage/Disk/Encodings/MFM.cpp index 6a03d5ab2..3c7919db5 100644 --- a/Storage/Disk/Encodings/MFM.cpp +++ b/Storage/Disk/Encodings/MFM.cpp @@ -426,7 +426,6 @@ std::vector Parser::get_track() { return result; } - std::shared_ptr Parser::get_next_sector() { std::shared_ptr sector(new Sector); index_count_ = 0;