Add Micropolis encoder

Has not been tested on a Micropolis machine.
This commit is contained in:
Eric Anderson
2021-01-10 15:18:00 -08:00
parent f6f6db913e
commit 8b71c0d737
6 changed files with 126 additions and 7 deletions

View File

@@ -23,7 +23,7 @@ AbstractDecoder::RecordType MicropolisDecoder::advanceToNextRecord()
}
/* Adds all bytes, with carry. */
static uint8_t checksum(const Bytes& bytes) {
uint8_t micropolisChecksum(const Bytes& bytes) {
ByteReader br(bytes);
uint16_t sum = 0;
while (!br.eof()) {
@@ -54,7 +54,7 @@ void MicropolisDecoder::decodeSectorRecord()
br.read(10); /* OS data or padding */
_sector->data = br.read(256);
uint8_t wantChecksum = br.read_8();
uint8_t gotChecksum = checksum(bytes.slice(1, 2+266));
uint8_t gotChecksum = micropolisChecksum(bytes.slice(1, 2+266));
br.read(5); /* 4 byte ECC and ECC-present flag */
_sector->status = (wantChecksum == gotChecksum) ? Sector::OK : Sector::BAD_CHECKSUM;