fixed isValidCatalogSector() check

This commit is contained in:
Denis Molony 2020-04-10 10:47:42 +10:00
parent 0a01db617f
commit e1811f8fbe
2 changed files with 29 additions and 42 deletions

View File

@ -148,8 +148,10 @@ class CatalogEntry extends AbstractCatalogEntry
if (!da.getDisk ().isValidAddress (buffer[1], buffer[2]))
return false;
if (buffer[4] != 0)
return false;
if (buffer[3] != 0 || buffer[4] != 0) // not supposed to be used
// Diags2E.dsk stores its own sector address here
if (da.getTrack () != (buffer[3] & 0xFF) && da.getSector () != (buffer[4] & 0xFF))
return false;
return true;
}

View File

@ -269,51 +269,36 @@ public class DosDisk extends AbstractFormattedDisk
public static boolean isCorrectFormat (AppleDisk disk)
// ---------------------------------------------------------------------------------//
{
if (debug)
System.out.println ("Checking interleave 0");
disk.setInterleave (0);
int catalogBlocks0 = checkFormat (disk);
if (catalogBlocks0 > 3)
return true;
if (disk.getSectorsPerTrack () > 16)
return false;
if (debug)
System.out.println ("Checking interleave 1");
disk.setInterleave (1);
int catalogBlocks1 = checkFormat (disk);
if (catalogBlocks1 > 3)
return true;
if (debug)
System.out.println ("Checking interleave 2");
disk.setInterleave (2);
int catalogBlocks2 = checkFormat (disk);
if (catalogBlocks2 > 3)
return true;
if (catalogBlocks0 > 0)
{
disk.setInterleave (0);
return true;
}
if (catalogBlocks1 > 0)
{
disk.setInterleave (1);
return true;
}
if (catalogBlocks2 > 0)
if (false)
{
disk.setInterleave (2);
return true;
}
if (disk.getSectorsPerTrack () > 16)
return false;
int[] cb = new int[3];
for (int interleave = 0; interleave < 3; interleave++)
{
if (debug)
System.out.printf ("Checking interleave %d%n", interleave);
disk.setInterleave (interleave);
cb[interleave] = checkFormat (disk);
if (cb[interleave] > 3)
return true;
}
for (int max = 2; max > 0; max--)
for (int interleave = 0; interleave < 3; interleave++)
{
if (cb[interleave] >= max)
{
disk.setInterleave (interleave);
return true;
}
}
return false;
}