Allow invalid DOS file types

This commit is contained in:
Denis Molony 2020-07-13 14:32:08 +10:00
parent f78dce5d05
commit 06f1ecd891
7 changed files with 94 additions and 14 deletions

View File

@ -140,7 +140,7 @@ public class AppleDisk implements Disk
this.trackSize = sectors * sectorSize;
}
}
else if ("img".equals (suffix))
else if ("img".equals (suffix) || "dimg".equals (suffix))
{
PrefixDiskCopy prefixDiskCopy = new PrefixDiskCopy (buffer);

View File

@ -212,7 +212,7 @@ public class DiskFactory
return new DataDisk (appleDisk);
}
if (suffix.equals ("img"))
if (suffix.equals ("img") || suffix.equals ("dimg"))
{
disk = checkDiskCopyDisk (file);
if (disk != null)
@ -372,7 +372,8 @@ public class DiskFactory
if (true)
{
long checksum = appleDisk256.getBootChecksum ();
// long checksum = appleDisk256.getBootChecksum ();
long checksum = 0;
if (checksum == 227968344L) // empty boot sector
{
@ -380,7 +381,7 @@ public class DiskFactory
if (debug)
System.out.println (" empty sector checksum : " + checksum);
}
else if (checksum == 3176296590L //
else if (checksum == 3176296590L // HIGHRTXT.DSK
|| checksum == 108825457L // ARCBOOT.DSK (looping)
|| checksum == 1439356606L //
|| checksum == 1550012074L //
@ -396,7 +397,7 @@ public class DiskFactory
if (debug)
System.out.println (" known DOS checksum : " + checksum);
disk = checkDos (appleDisk256);
disk2 = checkProdos (appleDisk512); // no need for this
// disk2 = checkProdos (appleDisk512); // no need for this
if (disk2 != null && disk != null) // should be impossible
{
if (debug)

View File

@ -3,6 +3,7 @@ package com.bytezone.diskbrowser.disk;
import com.bytezone.diskbrowser.utilities.HexFormatter;
import com.bytezone.diskbrowser.utilities.Utility;
// https://www.discferret.com/wiki/Apple_DiskCopy_4.2
// -----------------------------------------------------------------------------------//
public class PrefixDiskCopy
// -----------------------------------------------------------------------------------//

View File

@ -70,18 +70,21 @@ abstract class AbstractCatalogEntry implements AppleFileSource
fileType = FileType.IntegerBasic;
else if ((type == 0x02))
fileType = FileType.ApplesoftBasic;
else if ((type == 0x04))
else if ((type < 0x08))
fileType = FileType.Binary;
else if ((type == 0x08))
else if ((type < 0x10))
fileType = FileType.SS;
else if ((type == 0x10))
else if ((type < 0x20))
fileType = FileType.Relocatable;
else if ((type == 0x20))
else if ((type < 0x40))
fileType = FileType.AA;
else if ((type == 0x40)) // Lisa
fileType = FileType.BB;
// else if ((type == 0x40)) // Lisa
else
System.out.println ("Unknown file type : " + type);
fileType = FileType.BB;
// else
// {
// System.out.println ("Unknown file type : " + type);
// }
if (dosDisk.getVersion () >= 0x41)
lastModified = Utility.getDateTime (entryBuffer, 0x1B);
@ -129,6 +132,10 @@ abstract class AbstractCatalogEntry implements AppleFileSource
protected String getFileType ()
// ---------------------------------------------------------------------------------//
{
if (fileType == null)
{
return "?";
}
switch (fileType)
{
case Text:

View File

@ -0,0 +1,65 @@
package com.bytezone.diskbrowser.dosmaster;
import com.bytezone.diskbrowser.utilities.Utility;
// -----------------------------------------------------------------------------------//
public class DosMasterDisk
// -----------------------------------------------------------------------------------//
{
// ---------------------------------------------------------------------------------//
public static boolean isDos33 (byte[] buffer)
// ---------------------------------------------------------------------------------//
{
int slots = 3 * 16 + 8;
int v0 = slots + 8;
int size = v0 + 16;
int vsiz = size + 8;
// int adrs = vsiz + 8;
System.out.println (
"Slots v0 size vsiz d d0 slot ptr st sz v num");
StringBuilder text = new StringBuilder ();
for (int d = 0; d < 8; d++)
{
int d0 = d / 2 * 2;
int s = buffer[slots + d] & 0xFF;
if (s == 0)
continue;
System.out.printf (" %02X %02X %02X %02X %02X %02X %02X", slots,
v0, size, vsiz, d, d0, s);
int dr = 0;
if (s > 127)
{
s -= 128;
dr = 1;
}
text.append (String.format ("Slot %d, Drive %d has", s / 16, dr + 1));
int ptr = v0 + 2 * d0 + 2 * dr;
int st = Utility.unsignedShort (buffer, ptr);
int sz = Utility.unsignedShort (buffer, vsiz + d0);
int v = Utility.unsignedShort (buffer, size + d0);
if (st > v)
st -= 16 * 4096;
int num = (v - st) / sz - 1;
text.append (String.format (" %d volumes of %d sectors%n", num, sz * 2));
System.out.printf (" %02X %04X %04X %04X %04X%n", ptr, st, sz, v,
num);
}
System.out.println ();
System.out.println (text.toString ());
return false;
}
}

View File

@ -39,6 +39,7 @@ import com.bytezone.diskbrowser.appleworks.AppleworksADBFile;
import com.bytezone.diskbrowser.appleworks.AppleworksSSFile;
import com.bytezone.diskbrowser.appleworks.AppleworksWPFile;
import com.bytezone.diskbrowser.disk.DiskAddress;
import com.bytezone.diskbrowser.dosmaster.DosMasterDisk;
import com.bytezone.diskbrowser.gui.DataSource;
import com.bytezone.diskbrowser.utilities.HexFormatter;
import com.bytezone.diskbrowser.utilities.Utility;
@ -356,6 +357,11 @@ class FileEntry extends CatalogEntry implements ProdosConstants
}
// else if (name.endsWith (".PIC")) // 0091 X-BASIC../../XBASIC.PIC
// file = new SHRPictureFile2 (name, exactBuffer, fileType, auxType, endOfFile);
else if (name.equals ("DOS.3.3") && endOfFile == 0x2800
&& DosMasterDisk.isDos33 (exactBuffer))
{
}
else
{
file = new AssemblerProgram (name, exactBuffer, auxType);

View File

@ -17,8 +17,8 @@ import java.util.zip.Checksum;
public class Utility
// -----------------------------------------------------------------------------------//
{
public static final List<String> suffixes =
Arrays.asList ("po", "dsk", "do", "hdv", "2mg", "v2d", "d13", "sdk", "woz", "img");
public static final List<String> suffixes = Arrays.asList ("po", "dsk", "do", "hdv",
"2mg", "v2d", "d13", "sdk", "woz", "img", "dimg");
// ---------------------------------------------------------------------------------//
public static boolean test (Graphics2D g)