1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-30 22:29:56 +00:00

Fixes the more obvious issues with GCR encoding: byte order, top bit selection.

This commit is contained in:
Thomas Harte 2019-06-16 17:17:24 -04:00
parent 745a5ab749
commit 5c8aacdc17
2 changed files with 13 additions and 13 deletions

View File

@ -125,7 +125,7 @@
0x8f, 0xb8, 0x9b, 0x5a, 0xb2, 0x64, 0x8d, 0xbe, 0xe3, 0xa4, 0x82, 0x44, 0xac, 0x1d, 0xae, 0x80,
0x54, 0xac, 0x14, 0x0e, 0x63, 0x9a, 0x17, 0x4f, 0x1b, 0xf2, 0x02, 0x85, 0x34, 0x93, 0xab, 0x0e,
0x09, 0x64, 0x18, 0x6e, 0x66, 0xd5, 0x32, 0x6f, 0xc2, 0x1e, 0x69, 0x75, 0x80, 0x4d, 0x9e, 0x92,
0x5a, 0xee, 0xc1, 0x29, 0x41, 0xae, 0x47, 0xbd, 0x3b, 0x13, 0x46, 0xa1, // 0x00,
0x5a, 0xee, 0xc1, 0x29, 0x41, 0xae, 0x47, 0xbd, 0x3b, 0x13, 0x46, 0xa1,
};
const auto data = Storage::Encodings::AppleGCR::Macintosh::data(source_data);
const auto expected = Storage::Disk::PCMSegment(expected_data);

View File

@ -284,24 +284,24 @@ Storage::Disk::PCMSegment AppleGCR::Macintosh::data(const uint8_t *source) {
// Having mutated those three bytes according to the current checksum,
// and the checksum according to those bytes, run them through the
// GCR conversion table.
output[3 + c*4 + 0] = six_and_two_mapping[values[0] & 0x3f];
output[3 + c*4 + 1] = six_and_two_mapping[values[1] & 0x3f];
output[3 + c*4 + 2] = six_and_two_mapping[values[2] & 0x3f];
output[3 + c*4 + 3] = six_and_two_mapping[
output[3 + c*4 + 1] = six_and_two_mapping[values[0] & 0x3f];
output[3 + c*4 + 2] = six_and_two_mapping[values[1] & 0x3f];
output[3 + c*4 + 3] = six_and_two_mapping[values[2] & 0x3f];
output[3 + c*4 + 0] = six_and_two_mapping[
((values[0] >> 2) & 0x30) |
((values[1] >> 2) & 0x0c) |
((values[2] >> 2) & 0x03)
((values[1] >> 4) & 0x0c) |
((values[2] >> 6) & 0x03)
];
}
// Also write the checksum.
output[703] = six_and_two_mapping[checksum[0] & 0x3f];
output[704] = six_and_two_mapping[checksum[1] & 0x3f];
output[705] = six_and_two_mapping[checksum[2] & 0x3f];
output[706] = six_and_two_mapping[
output[704] = six_and_two_mapping[checksum[0] & 0x3f];
output[705] = six_and_two_mapping[checksum[1] & 0x3f];
output[706] = six_and_two_mapping[checksum[2] & 0x3f];
output[703] = six_and_two_mapping[
((checksum[0] >> 2) & 0x30) |
((checksum[1] >> 2) & 0x0c) |
((checksum[2] >> 2) & 0x03)
((checksum[1] >> 4) & 0x0c) |
((checksum[2] >> 6) & 0x03)
];
// Write epilogue.