From fead524eb567bdeddbcb7729babcf01af0f543ac Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 29 Jul 2016 18:52:50 -0400 Subject: [PATCH] Attempted to give the PLL a litte extra leeway, and fixed `PCMTrack` length test. --- Storage/Disk/DiskDrive.cpp | 7 +++++-- Storage/Disk/PCMTrack.cpp | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Storage/Disk/DiskDrive.cpp b/Storage/Disk/DiskDrive.cpp index ee5f5b298..7d49dd7f0 100644 --- a/Storage/Disk/DiskDrive.cpp +++ b/Storage/Disk/DiskDrive.cpp @@ -11,11 +11,11 @@ using namespace Storage; DiskDrive::DiskDrive(unsigned int clock_rate, unsigned int revolutions_per_minute) : - _clock_rate(clock_rate), + _clock_rate(clock_rate * 16), _revolutions_per_minute(revolutions_per_minute), _head_position(0), - TimedEventLoop(clock_rate) + TimedEventLoop(clock_rate * 16) {} void DiskDrive::set_expected_bit_length(Time bit_length) @@ -63,6 +63,8 @@ void DiskDrive::run_for_cycles(int number_of_cycles) if(has_disk()) { _cycles_since_index_hole += (unsigned int)number_of_cycles; + + number_of_cycles *= 16; _pll->run_for_cycles(number_of_cycles); TimedEventLoop::run_for_cycles(number_of_cycles); } @@ -100,6 +102,7 @@ void DiskDrive::process_next_event() case Track::Event::IndexHole: _cycles_since_index_hole = 0; process_index_hole(); + printf("\n"); break; } get_next_event(); diff --git a/Storage/Disk/PCMTrack.cpp b/Storage/Disk/PCMTrack.cpp index 77550870f..9716a0511 100644 --- a/Storage/Disk/PCMTrack.cpp +++ b/Storage/Disk/PCMTrack.cpp @@ -33,7 +33,7 @@ PCMTrack::Event PCMTrack::get_next_event() { unsigned int clock_multiplier = _track_clock_rate / _segments[_segment_pointer].length_of_a_bit.clock_rate; const uint8_t *segment_data = _segments[_segment_pointer].data.get(); - while(_bit_pointer < _segments[_segment_pointer].length_of_a_bit.length) + while(_bit_pointer < _segments[_segment_pointer].number_of_bits) { // for timing simplicity, bits are modelled as happening at the end of their window // TODO: should I account for the converse bit ordering? Or can I assume MSB first? @@ -66,7 +66,7 @@ void PCMTrack::fix_length() _track_clock_rate = NumberTheory::least_common_multiple(_track_clock_rate, _segments[c].length_of_a_bit.clock_rate); } - // therby determine the total length, storing it to next_event as the track-total divisor + // thereby determine the total length, storing it to next_event as the track-total divisor _next_event.length.clock_rate = 0; for(size_t c = 0; c < _segments.size(); c++) {