From 5b35c88be2ce0e923255a6378beebbed8ac651d5 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 28 Apr 2018 15:47:50 -0400 Subject: [PATCH] Corrections: data segments now correctly announce their number of bits, and tracks aren't oversized. --- Storage/Disk/DiskImage/Formats/AppleDSK.cpp | 7 ++++--- Storage/Disk/Encodings/AppleGCR.cpp | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Storage/Disk/DiskImage/Formats/AppleDSK.cpp b/Storage/Disk/DiskImage/Formats/AppleDSK.cpp index 1b11fd490..b32a63876 100644 --- a/Storage/Disk/DiskImage/Formats/AppleDSK.cpp +++ b/Storage/Disk/DiskImage/Formats/AppleDSK.cpp @@ -40,7 +40,6 @@ std::shared_ptr AppleDSK::get_track_at_position(Track::Address address) { // In either case below, the code aims for exactly 50,000 bits per track. if(sectors_per_track_ == 16) { - // Write the sectors. for(uint8_t c = 0; c < 16; ++c) { segments.push_back(Encodings::AppleGCR::six_and_two_sync(10)); @@ -50,9 +49,11 @@ std::shared_ptr AppleDSK::get_track_at_position(Track::Address address) { segments.push_back(Encodings::AppleGCR::six_and_two_sync(10)); } + // Pad if necessary. int encoded_length = (80 + 112 + 80 + 2848 + 80) * sectors_per_track_; - segments.push_back(Encodings::AppleGCR::six_and_two_sync((50000 - encoded_length) >> 3)); - + if(encoded_length < 50000) { + segments.push_back(Encodings::AppleGCR::six_and_two_sync((50000 - encoded_length) >> 3)); + } } else { } diff --git a/Storage/Disk/Encodings/AppleGCR.cpp b/Storage/Disk/Encodings/AppleGCR.cpp index 20d81106b..a7a137b9e 100644 --- a/Storage/Disk/Encodings/AppleGCR.cpp +++ b/Storage/Disk/Encodings/AppleGCR.cpp @@ -135,6 +135,7 @@ Storage::Disk::PCMSegment AppleGCR::six_and_two_data(const uint8_t *source) { Storage::Disk::PCMSegment segment; segment.data.resize(349); + segment.number_of_bits = static_cast(segment.data.size() * 8); // Add the prologue and epilogue. segment.data[0] = header_prologue[0]; @@ -174,7 +175,7 @@ Storage::Disk::PCMSegment AppleGCR::six_and_two_data(const uint8_t *source) { // Map six-bit values up to full bytes. for(std::size_t c = 0; c < 343; ++c) { - segment.data[c] = six_and_two_mapping[segment.data[c]]; + segment.data[3 + c] = six_and_two_mapping[segment.data[3 + c]]; } return segment;