| 139 | } |
| 140 | |
| 141 | void decodeSectorRecord() override |
| 142 | { |
| 143 | uint64_t id = toBytes(readRawBits(64)).reader().read_be64(); |
| 144 | unsigned recordSize, payloadSize, headerSize; |
| 145 | |
| 146 | if (id == MFM_ID) |
| 147 | { |
| 148 | recordSize = NORTHSTAR_ENCODED_SECTOR_SIZE_DD; |
| 149 | payloadSize = NORTHSTAR_PAYLOAD_SIZE_DD; |
| 150 | headerSize = NORTHSTAR_HEADER_SIZE_DD; |
| 151 | } |
| 152 | else |
| 153 | { |
| 154 | recordSize = NORTHSTAR_ENCODED_SECTOR_SIZE_SD; |
| 155 | payloadSize = NORTHSTAR_PAYLOAD_SIZE_SD; |
| 156 | headerSize = NORTHSTAR_HEADER_SIZE_SD; |
| 157 | } |
| 158 | |
| 159 | auto rawbits = readRawBits(recordSize * 16); |
| 160 | auto bytes = decodeFmMfm(rawbits).slice(0, recordSize); |
| 161 | ByteReader br(bytes); |
| 162 | |
| 163 | _sector->logicalHead = _ltl->logicalHead; |
| 164 | _sector->logicalSector = _hardSectorId; |
| 165 | _sector->logicalCylinder = _ltl->logicalCylinder; |
| 166 | |
| 167 | if (headerSize == NORTHSTAR_HEADER_SIZE_DD) |
| 168 | { |
| 169 | br.read_8(); /* MFM second Sync char, usually 0xFB */ |
| 170 | } |
| 171 | |
| 172 | _sector->data = br.read(payloadSize); |
| 173 | uint8_t wantChecksum = br.read_8(); |
| 174 | uint8_t gotChecksum = |
| 175 | northstarChecksum(bytes.slice(headerSize - 1, payloadSize)); |
| 176 | _sector->status = |
| 177 | (wantChecksum == gotChecksum) ? Sector::OK : Sector::BAD_CHECKSUM; |
| 178 | } |
| 179 | |
| 180 | private: |
| 181 | const NorthstarDecoderProto& _config; |
nothing calls this directly
no test coverage detected