diff --git a/arch/northstar/decoder.cc b/arch/northstar/decoder.cc index 85b4a7b0..98b8c36b 100644 --- a/arch/northstar/decoder.cc +++ b/arch/northstar/decoder.cc @@ -127,9 +127,9 @@ public: void decodeSectorRecord() override { uint64_t id = toBytes(readRawBits(64)).reader().read_be64(); - unsigned recordSize, payloadSize, headerSize; - if (id == SECTOR_TYPE_MFM) { + + if (id == MFM_ID) { recordSize = NORTHSTAR_ENCODED_SECTOR_SIZE_DD; payloadSize = NORTHSTAR_PAYLOAD_SIZE_DD; headerSize = NORTHSTAR_HEADER_SIZE_DD; @@ -143,22 +143,18 @@ public: auto rawbits = readRawBits(recordSize * 16); auto bytes = decodeFmMfm(rawbits).slice(0, recordSize); ByteReader br(bytes); - uint8_t sync_char; _sector->logicalSide = _sector->physicalHead; _sector->logicalSector = _hardSectorId; _sector->logicalTrack = _sector->physicalCylinder; - sync_char = br.read_8(); /* Sync char: 0xFB */ - if (_sectorType == SECTOR_TYPE_MFM) { - sync_char = br.read_8();/* MFM second Sync char, usually 0xFB */ + if (headerSize == NORTHSTAR_HEADER_SIZE_DD) { + br.read_8(); /* MFM second Sync char, usually 0xFB */ } _sector->data = br.read(payloadSize); - uint8_t wantChecksum = br.read_8(); - uint8_t gotChecksum = northstarChecksum(bytes.slice(headerSize, payloadSize)); - + uint8_t gotChecksum = northstarChecksum(bytes.slice(headerSize - 1, payloadSize)); _sector->status = (wantChecksum == gotChecksum) ? Sector::OK : Sector::BAD_CHECKSUM; } @@ -170,7 +166,6 @@ public: private: const NorthstarDecoderProto& _config; - uint8_t _sectorType = SECTOR_TYPE_MFM; uint8_t _hardSectorId; }; diff --git a/arch/northstar/northstar.h b/arch/northstar/northstar.h index c20a084e..2bcfdce3 100644 --- a/arch/northstar/northstar.h +++ b/arch/northstar/northstar.h @@ -22,9 +22,6 @@ #define NORTHSTAR_ENCODED_SECTOR_SIZE_SD (NORTHSTAR_HEADER_SIZE_SD + NORTHSTAR_PAYLOAD_SIZE_SD + NORTHSTAR_CHECKSUM_SIZE) #define NORTHSTAR_ENCODED_SECTOR_SIZE_DD (NORTHSTAR_HEADER_SIZE_DD + NORTHSTAR_PAYLOAD_SIZE_DD + NORTHSTAR_CHECKSUM_SIZE) -#define SECTOR_TYPE_MFM (0) -#define SECTOR_TYPE_FM (1) - class AbstractDecoder; class AbstractEncoder; class EncoderProto;