apple2 decoder: explain the progression of sector status values

This commit is contained in:
Jeff Epler
2022-03-01 11:27:48 -06:00
parent dd49f01499
commit c4e4520058

View File

@@ -90,6 +90,9 @@ public:
_sector->logicalTrack = combine(br.read_be16()); _sector->logicalTrack = combine(br.read_be16());
_sector->logicalSector = combine(br.read_be16()); _sector->logicalSector = combine(br.read_be16());
uint8_t checksum = combine(br.read_be16()); uint8_t checksum = combine(br.read_be16());
// If the checksum is correct, upgrade the sector from MISSING
// to DATA_MISSING in anticipation of its data record
if (checksum == (volume ^ _sector->logicalTrack ^ _sector->logicalSector)) if (checksum == (volume ^ _sector->logicalTrack ^ _sector->logicalSector))
_sector->status = Sector::DATA_MISSING; /* unintuitive but correct */ _sector->status = Sector::DATA_MISSING; /* unintuitive but correct */
} }
@@ -106,6 +109,9 @@ public:
unsigned recordLength = APPLE2_ENCODED_SECTOR_LENGTH + 2; unsigned recordLength = APPLE2_ENCODED_SECTOR_LENGTH + 2;
Bytes bytes = toBytes(readRawBits(recordLength*8)).slice(0, recordLength); Bytes bytes = toBytes(readRawBits(recordLength*8)).slice(0, recordLength);
// Upgrade the sector from MISSING to BAD_CHECKSUM.
// If decode_crazy_data succeeds, it upgrades the sector to
// OK.
_sector->status = Sector::BAD_CHECKSUM; _sector->status = Sector::BAD_CHECKSUM;
_sector->data = decode_crazy_data(&bytes[0], _sector->status); _sector->data = decode_crazy_data(&bytes[0], _sector->status);
} }