From c4e45200589d7ec92441fa130cb14c98a84926da Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 1 Mar 2022 11:27:48 -0600 Subject: [PATCH] apple2 decoder: explain the progression of sector status values --- arch/apple2/decoder.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/apple2/decoder.cc b/arch/apple2/decoder.cc index f046e6c8..644c0493 100644 --- a/arch/apple2/decoder.cc +++ b/arch/apple2/decoder.cc @@ -90,6 +90,9 @@ public: _sector->logicalTrack = combine(br.read_be16()); _sector->logicalSector = 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)) _sector->status = Sector::DATA_MISSING; /* unintuitive but correct */ } @@ -106,6 +109,9 @@ public: unsigned recordLength = APPLE2_ENCODED_SECTOR_LENGTH + 2; 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->data = decode_crazy_data(&bytes[0], _sector->status); }