| 109 | } |
| 110 | |
| 111 | void decodeSectorRecord() override |
| 112 | { |
| 113 | auto rawbits = readRawBits(FB100_RECORD_SIZE * 16); |
| 114 | |
| 115 | const Bytes bytes = decodeFmMfm(rawbits).slice(0, FB100_RECORD_SIZE); |
| 116 | ByteReader br(bytes); |
| 117 | br.seek(1); |
| 118 | const Bytes id = br.read(FB100_ID_SIZE); |
| 119 | uint16_t wantIdCrc = br.read_be16(); |
| 120 | uint16_t gotIdCrc = checksum(id); |
| 121 | const Bytes payload = br.read(FB100_PAYLOAD_SIZE); |
| 122 | uint16_t wantPayloadCrc = br.read_be16(); |
| 123 | uint16_t gotPayloadCrc = checksum(payload); |
| 124 | |
| 125 | if (wantIdCrc != gotIdCrc) |
| 126 | return; |
| 127 | |
| 128 | uint8_t abssector = id[2]; |
| 129 | _sector->logicalCylinder = abssector >> 1; |
| 130 | _sector->logicalHead = 0; |
| 131 | _sector->logicalSector = abssector & 1; |
| 132 | _sector->data.writer().append(id.slice(5, 12)).append(payload); |
| 133 | |
| 134 | _sector->status = (wantPayloadCrc == gotPayloadCrc) |
| 135 | ? Sector::OK |
| 136 | : Sector::BAD_CHECKSUM; |
| 137 | } |
| 138 | }; |
| 139 | |
| 140 | std::unique_ptr<Decoder> createFb100Decoder(const DecoderProto& config) |