Fixed bug with https://csdb.dk/release/?id=11627 directory display.

grue on Lemon found this image that caused an infinite loop when attempting to display the directory.
This commit is contained in:
Stephen White 2018-07-02 18:30:30 +10:00
parent c961e2b5b0
commit e4dc6e54ec

View file

@ -991,6 +991,8 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
if (track != 0) if (track != 0)
{ {
unsigned trackPrev = 0xff;
unsigned sectorPrev = 0xff;
bool complete = false; bool complete = false;
// Blocks 1 through 19 on track 18 contain the file entries. The first two bytes of a block point to the next directory block with file entries. If no more directory blocks follow, these bytes contain $00 and $FF, respectively. // Blocks 1 through 19 on track 18 contain the file entries. The first two bytes of a block point to the next directory block with file entries. If no more directory blocks follow, these bytes contain $00 and $FF, respectively.
while (!complete) while (!complete)
@ -1002,8 +1004,11 @@ void FileBrowser::DisplayDiskInfo(DiskImage* diskImage, const char* filenameForI
unsigned sectorNoNext = buffer[1]; unsigned sectorNoNext = buffer[1];
complete = (track == trackNext) && (sectorNo == sectorNoNext); // Detect looping directory entries (raid over moscow ntsc) complete = (track == trackNext) && (sectorNo == sectorNoNext); // Detect looping directory entries (raid over moscow ntsc)
complete |= (trackNext == trackPrev) && (sectorNoNext == sectorPrev); // Detect looping directory entries (IndustrialBreakdown)
complete |= (trackNext == 00) || (sectorNoNext == 0xff); complete |= (trackNext == 00) || (sectorNoNext == 0xff);
complete |= (trackNext == 18) && (sectorNoNext == 1); complete |= (trackNext == 18) && (sectorNoNext == 1);
trackPrev = track;
sectorPrev = sectorNo;
track = trackNext; track = trackNext;
sectorNo = sectorNoNext; sectorNo = sectorNoNext;