From 44a56724cb5ce2275712154abff6fba77a59f5f0 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 16 Sep 2017 20:28:24 -0400 Subject: [PATCH] Speeds up byte decoding within sectors for the ahead-of-time MFM parser. --- Storage/Disk/Encodings/MFM.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Storage/Disk/Encodings/MFM.cpp b/Storage/Disk/Encodings/MFM.cpp index 5d7374f5f..ec85a8665 100644 --- a/Storage/Disk/Encodings/MFM.cpp +++ b/Storage/Disk/Encodings/MFM.cpp @@ -221,7 +221,7 @@ std::shared_ptr Storage::Encodings::MFM::GetMFMTrackWithSe 22, 0x4e, 12, (sector_gap_length != DefaultSectorGapLength) ? sector_gap_length : 54, 0xff, - 12500); // unintelligently: double the single-density bytes/rotation (or: 500kps @ 300 rpm) + 12500); // unintelligently: double the single-density bytes/rotation (or: 500kbps @ 300 rpm) } std::unique_ptr Storage::Encodings::MFM::GetMFMEncoder(std::vector &target) { @@ -337,7 +337,15 @@ uint8_t Parser::get_byte_for_shift_value(uint16_t value) { uint8_t Parser::get_next_byte() { bit_count_ = 0; - while(bit_count_ < 16) run_for(Cycles(1)); + // Archetypal MFM is 500,000 bps given that the drive has an RPM of 300. Clock rate was + // specified at 4,000,000. So that's an idealised 8 cycles per bit, Jump ahead 14 + // times that... + run_for(Cycles(14 * 8)); + + // ... and proceed at half-idealised-bit intervals to get the next bit. Then proceed very gingerly indeed. + while(bit_count_ < 15) run_for(Cycles(4)); + while(bit_count_ < 16) run_for(Cycles(2)); + uint8_t byte = get_byte_for_shift_value((uint16_t)shift_register_); crc_generator_.add(byte); return byte;