Skip to content

Commit 3c54a66

Browse files
authored
Merge pull request #157 from davidgiven/amigacorruption
Fix some issues causing corruption when reading Amiga disks
2 parents 5be7249 + 1fd6545 commit 3c54a66

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

arch/amiga/decoder.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ AbstractDecoder::RecordType AmigaDecoder::advanceToNextRecord()
3232
void AmigaDecoder::decodeSectorRecord()
3333
{
3434
const auto& rawbits = readRawBits(AMIGA_RECORD_SIZE*16);
35+
if (rawbits.size() < (AMIGA_RECORD_SIZE*16))
36+
return;
3537
const auto& rawbytes = toBytes(rawbits).slice(0, AMIGA_RECORD_SIZE*2);
3638
const auto& bytes = decodeFmMfm(rawbits).slice(0, AMIGA_RECORD_SIZE);
3739

lib/reader.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,13 @@ void readDiskCommand(AbstractDecoder& decoder)
261261
if (dumpSectors)
262262
{
263263
std::cout << "\nDecoded sectors follow:\n\n";
264-
for (auto& i : readSectors)
264+
for (auto& sector : track->sectors)
265265
{
266-
auto& sector = i.second;
267-
std::cout << fmt::format("{}.{:02}.{:02}: I+{:.2f}us with {:.2f}us clock\n",
268-
sector->logicalTrack, sector->logicalSide, sector->logicalSector,
269-
sector->position.ns() / 1000.0, sector->clock / 1000.0);
270-
hexdump(std::cout, sector->data);
266+
std::cout << fmt::format("{}.{:02}.{:02}: I+{:.2f}us with {:.2f}us clock: status {}\n",
267+
sector.logicalTrack, sector.logicalSide, sector.logicalSector,
268+
sector.position.ns() / 1000.0, sector.clock / 1000.0,
269+
sector.status);
270+
hexdump(std::cout, sector.data);
271271
std::cout << std::endl;
272272
}
273273
}

0 commit comments

Comments
 (0)