Clean up the IBM decoder (still not right).

This commit is contained in:
David Given
2019-03-05 20:57:45 +01:00
parent 4d8c43731f
commit 0ae1623afc

View File

@@ -17,9 +17,9 @@ SectorVector AbstractIbmDecoder::decodeToSectors(const RawRecordVector& rawRecor
for (auto& rawrecord : rawRecords)
{
const Bytes& bytes = decodeFmMfm(rawrecord->data);
const Bytes bytes = decodeFmMfm(rawrecord->data);
int headerSize = skipHeaderBytes();
const Bytes& data = bytes.slice(headerSize, bytes.size() - headerSize);
Bytes data = bytes.slice(headerSize, bytes.size() - headerSize);
switch (data[0])
{
@@ -48,13 +48,12 @@ SectorVector AbstractIbmDecoder::decodeToSectors(const RawRecordVector& rawRecor
break;
unsigned size = 1 << (idam.sectorSize + 7);
if (size > (data.size() + IBM_DAM_LEN + 2))
break;
data.resize(IBM_DAM_LEN + size + 2);
const Bytes payload = data.slice(IBM_DAM_LEN, size);
uint16_t crc = crc16(CCITT_POLY, payload);
uint16_t gotCrc = crc16(CCITT_POLY, payload);
uint16_t wantedCrc = data.reader().seek(IBM_DAM_LEN+size).read_be16();
int status = (crc == wantedCrc) ? Sector::OK : Sector::BAD_CHECKSUM;
int status = (gotCrc == wantedCrc) ? Sector::OK : Sector::BAD_CHECKSUM;
int sectorNum = idam.sector - _sectorIdBase;
auto sector = std::unique_ptr<Sector>(