1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-10 12:29:01 +00:00

Corrected wiring to get advance signals through to Drive event delegates.

This commit is contained in:
Thomas Harte 2017-09-10 20:51:05 -04:00
parent 0622187ddf
commit 8882aa496f
4 changed files with 9 additions and 6 deletions

View File

@ -48,7 +48,7 @@ void Controller::process_event(const Track::Event &event) {
} }
void Controller::advance(const Cycles cycles) { 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() { void Controller::process_write_completed() {

View File

@ -91,6 +91,10 @@ void Drive::set_event_delegate(Storage::Disk::Drive::EventDelegate *delegate) {
event_delegate_ = delegate; event_delegate_ = delegate;
} }
void Drive::advance(const Cycles cycles) {
if(event_delegate_) event_delegate_->advance(cycles);
}
void Drive::run_for(const Cycles cycles) { void Drive::run_for(const Cycles cycles) {
Time zero(0); Time zero(0);
@ -111,9 +115,7 @@ void Drive::run_for(const Cycles cycles) {
cycles_since_index_hole_ += (unsigned int)cycles_to_run_for; cycles_since_index_hole_ += (unsigned int)cycles_to_run_for;
number_of_cycles -= cycles_to_run_for; number_of_cycles -= cycles_to_run_for;
if(is_reading_) { if(!is_reading_) {
if(event_delegate_) event_delegate_->advance(Cycles(cycles_to_run_for));
} else {
if(cycles_until_bits_written_ > zero) { if(cycles_until_bits_written_ > zero) {
Storage::Time cycles_to_run_for_time(cycles_to_run_for); Storage::Time cycles_to_run_for_time(cycles_to_run_for);
if(cycles_until_bits_written_ <= cycles_to_run_for_time) { 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() { void Drive::process_next_event() {
// TODO: ready test here. // 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_); if(event_delegate_) event_delegate_->process_event(current_event_);
get_next_event(Time(0)); get_next_event(Time(0));
} }

View File

@ -146,7 +146,7 @@ class Drive: public Sleeper, public TimedEventLoop {
// If the drive is not currently reading then it is writing. While writing // If the drive is not currently reading then it is writing. While writing
// it can optionally be told to clamp to the index hole. // 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; bool clamp_writing_to_index_hole_ = false;
// If writing is occurring then the drive will be accumulating a write segment, // 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. // TimedEventLoop call-ins and state.
void process_next_event(); void process_next_event();
void get_next_event(const Time &duration_already_passed); void get_next_event(const Time &duration_already_passed);
void advance(const Cycles cycles);
Track::Event current_event_; Track::Event current_event_;
// Helper for track changes. // Helper for track changes.

View File

@ -426,7 +426,6 @@ std::vector<uint8_t> Parser::get_track() {
return result; return result;
} }
std::shared_ptr<Sector> Parser::get_next_sector() { std::shared_ptr<Sector> Parser::get_next_sector() {
std::shared_ptr<Sector> sector(new Sector); std::shared_ptr<Sector> sector(new Sector);
index_count_ = 0; index_count_ = 0;