Skip to content

Commit

Permalink
fixed isValidCatalogSector() check
Browse files Browse the repository at this point in the history
  • Loading branch information
dmolony committed Apr 10, 2020
1 parent 0a01db6 commit e1811f8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 38 deletions.
6 changes: 4 additions & 2 deletions src/com/bytezone/diskbrowser/dos/CatalogEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ private boolean isValidCatalogSector (DiskAddress da)

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;
}
Expand Down
57 changes: 21 additions & 36 deletions src/com/bytezone/diskbrowser/dos/DosDisk.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,50 +269,35 @@ public void setOriginalPath (Path path)
public static boolean isCorrectFormat (AppleDisk disk)
// ---------------------------------------------------------------------------------//
{
if (debug)
System.out.println ("Checking interleave 0");
disk.setInterleave (0);

int catalogBlocks0 = checkFormat (disk);
if (catalogBlocks0 > 3)
if (false)
{
disk.setInterleave (2);
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)
int[] cb = new int[3];
for (int interleave = 0; interleave < 3; interleave++)
{
disk.setInterleave (0);
return true;
}

if (catalogBlocks1 > 0)
{
disk.setInterleave (1);
return true;
if (debug)
System.out.printf ("Checking interleave %d%n", interleave);
disk.setInterleave (interleave);
cb[interleave] = checkFormat (disk);
if (cb[interleave] > 3)
return true;
}

if (catalogBlocks2 > 0)
{
disk.setInterleave (2);
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;
}
Expand Down

0 comments on commit e1811f8

Please sign in to comment.