bug fixes

This commit is contained in:
Denis Molony 2020-04-10 20:10:53 +10:00
parent e1811f8fbe
commit ed137b5731
5 changed files with 116 additions and 88 deletions

View File

@ -14,7 +14,7 @@ public interface ApplesoftConstants
"COLOR=", "POP ", "VTAB ", "HIMEM:", // 0xA0
"LOMEM:", "ONERR ", "RESUME", "RECALL ", // 0xA4 - 0xA7
"STORE ", "SPEED=", "LET ", "GOTO ", // 0xA8
"RUN ", "IF ", "RESTORE ", "& ", // 0xAC
"RUN ", "IF ", "RESTORE ", "&", // 0xAC
"GOSUB ", "RETURN ", "REM ", "STOP ", // 0xB0
"ON ", "WAIT ", "LOAD ", "SAVE ", // 0xB4
"DEF", "POKE ", "PRINT ", "CONT", // 0xB8

View File

@ -30,7 +30,7 @@ import com.bytezone.diskbrowser.wizardry.WizardryScenarioDisk;
public class DiskFactory
// -----------------------------------------------------------------------------------//
{
private static boolean debug = false;
private static boolean debug = true;
// ---------------------------------------------------------------------------------//
private DiskFactory ()
@ -199,7 +199,9 @@ public class DiskFactory
return new DataDisk (appleDisk);
}
if (((suffix.equals ("po") || suffix.equals ("dsk")) && file.length () > 143360))
// Toolkit.do = 143488
if (((suffix.equals ("po") || suffix.equals ("dsk") || suffix.equals ("do"))
&& file.length () > 143360))
{
if (file.length () < 143500) // slightly bigger than a floppy
{
@ -359,7 +361,7 @@ public class DiskFactory
System.out.println (" empty sector checksum : " + checksum);
}
else if (checksum == 3176296590L //
|| checksum == 108825457L //
|| checksum == 108825457L // ARCBOOT.DSK (looping)
|| checksum == 1439356606L //
|| checksum == 1550012074L //
|| checksum == 1614602459L //

View File

@ -42,7 +42,7 @@ public class DosDisk extends AbstractFormattedDisk
protected List<AppleFileSource> deletedFileEntries = new ArrayList<> ();
private static boolean debug = false;
private static boolean debug = true;
enum FileType
{
@ -82,9 +82,11 @@ public class DosDisk extends AbstractFormattedDisk
DiskAddress catalogStart = disk.getDiskAddress (sectorBuffer[1], sectorBuffer[2]);
if (dosVTOCSector.sectorSize != disk.getBlockSize ())
System.out.println ("Invalid sector size : " + dosVTOCSector.sectorSize);
System.out.printf ("%s - invalid sector size : %d%n", disk.getFile ().getName (),
dosVTOCSector.sectorSize);
if (dosVTOCSector.maxSectors != disk.getSectorsPerTrack ())
System.out.println ("Invalid sectors per track : " + dosVTOCSector.maxSectors);
System.out.printf ("%s - invalid sectors per track : %d%n",
disk.getFile ().getName (), dosVTOCSector.maxSectors);
// sectorTypes[CATALOG_TRACK * dosVTOCSector.maxSectors] = vtocSector;
@ -269,9 +271,9 @@ public class DosDisk extends AbstractFormattedDisk
public static boolean isCorrectFormat (AppleDisk disk)
// ---------------------------------------------------------------------------------//
{
if (false)
if (false) // testing
{
disk.setInterleave (2);
disk.setInterleave (1);
return true;
}
@ -279,27 +281,31 @@ public class DosDisk extends AbstractFormattedDisk
return false;
int[] cb = new int[3];
int best = 0;
int il = -1;
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)
if (cb[interleave] >= 15)
return true;
}
for (int max = 2; max > 0; max--)
for (int interleave = 0; interleave < 3; interleave++)
if (cb[interleave] > best)
{
if (cb[interleave] >= max)
{
disk.setInterleave (interleave);
return true;
best = cb[interleave];
il = interleave;
}
}
if (best == 0)
return false;
disk.setInterleave (il);
return true;
}
// ---------------------------------------------------------------------------------//
@ -347,6 +353,7 @@ public class DosDisk extends AbstractFormattedDisk
if (buffer[53] != 16 && buffer[53] != 13 && buffer[53] != 32) // sectors per track
{
if (debug)
System.out.printf ("Bad sectors per track : %02X%n", buffer[53]);
return 0;
}
@ -394,8 +401,9 @@ public class DosDisk extends AbstractFormattedDisk
return 0;
}
if (catalogAddresses.contains (da))
if (isDuplicate (catalogAddresses, da))
{
if (debug)
System.out.println ("Catalog looping");
return 0;
}
@ -419,6 +427,16 @@ public class DosDisk extends AbstractFormattedDisk
return catalogAddresses.size ();
}
// ---------------------------------------------------------------------------------//
private static boolean isDuplicate (List<DiskAddress> catalogAddresses, DiskAddress da)
// ---------------------------------------------------------------------------------//
{
for (DiskAddress diskAddress : catalogAddresses)
if (diskAddress.getBlock () == da.getBlock ())
return true;
return false;
}
// ---------------------------------------------------------------------------------//
@Override
public String toString ()

View File

@ -69,7 +69,15 @@ class DosTSListSector extends AbstractSector
StringBuilder text = getHeader ("TS List Sector : " + name);
addText (text, buffer, 0, 1, "Not used");
addText (text, buffer, 1, 2, "Next TS list track/sector" + msg);
if ((buffer[3] != 0 || buffer[4] != 0) // not supposed to be used
// Diags2E.dsk stores its own sector address here
&& (diskAddress.getTrack () == (buffer[3] & 0xFF)
&& diskAddress.getSector () == (buffer[4] & 0xFF)))
addText (text, buffer, 3, 2, "Self-reference");
else
addText (text, buffer, 3, 2, "Not used");
addTextAndDecimal (text, buffer, 5, 2, "Sector base number");
addText (text, buffer, 7, 4, "Not used");
addText (text, buffer, 11, 1, "Not used");

View File

@ -259,7 +259,7 @@ public class InfocomDisk extends AbstractFormattedDisk
int abbreviationsTable = HexFormatter.intValue (buffer[25], buffer[24]);
int fileLength = HexFormatter.intValue (buffer[27], buffer[26]);
if (true)
if (false)
{
System.out.printf ("Version %,6d%n", version);
System.out.printf ("Abbreviations %,6d%n", abbreviationsTable);