Finder data, 2mg dos disks

This commit is contained in:
Denis Molony 2020-04-08 12:17:08 +10:00
parent b1c5092329
commit fd81d521f1
9 changed files with 75 additions and 32 deletions

View File

@ -6,12 +6,17 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
public class FinderData extends AbstractFile
// -----------------------------------------------------------------------------------//
{
int totFiles;
// ---------------------------------------------------------------------------------//
public FinderData (String name, byte[] buffer)
// ---------------------------------------------------------------------------------//
{
super (name, buffer);
int xx = buffer[40] & 0xFF;
if (xx == 0x2A)
totFiles = buffer[34] & 0xFF; // not always
}
// ---------------------------------------------------------------------------------//
@ -23,24 +28,32 @@ public class FinderData extends AbstractFile
text.append ("Name : " + name + "\n\n");
text.append (HexFormatter.format (buffer, 0, 41));
text.append ("\n\n");
int ptr = 41;
while (ptr < buffer.length - 1)
if (buffer.length < 50)
{
String line = HexFormatter.getHexString (buffer, ptr, 9);
text.append (line + " ");
ptr += 9;
String name = HexFormatter.getPascalString (buffer, ptr);
text.append (name + "\n");
ptr += name.length () + 1;
text.append (HexFormatter.format (buffer));
return text.toString ();
}
if (text.length () > 0)
text.deleteCharAt (text.length () - 1);
text.append (HexFormatter.format (buffer, 0, 42));
text.append ("\n\n");
int ptr = 42;
for (int i = 0; i < totFiles; i++)
{
String line = HexFormatter.getHexString (buffer, ptr, 8);
text.append (line + " ");
ptr += 8;
String name = HexFormatter.getPascalString (buffer, ptr);
// text.append (name + "\n");
text.append (String.format ("%-20s ", name));
ptr += name.length () + 1;
text.append (String.format ("%02X%n", buffer[ptr++]));
}
// if (text.length () > 0)
// text.deleteCharAt (text.length () - 1);
return text.toString ();
}

View File

@ -448,46 +448,48 @@ public abstract class HiResImage extends AbstractFile
}
// ---------------------------------------------------------------------------------//
private void debug (byte[] buffer, int ptr, int length)
String debug (byte[] buffer, int ptr, int length)
// ---------------------------------------------------------------------------------//
{
// int ptr = 0;
int size = 0;
int max = ptr + length;
StringBuffer text = new StringBuffer ();
while (ptr < max)
{
int type = (buffer[ptr] & 0xC0) >>> 6; // 0-3
int count = (buffer[ptr++] & 0x3F) + 1; // 1-64
System.out.printf ("%04X/%04d: %02X (%d,%2d) ", ptr - 1, size, buffer[ptr - 1],
type, count);
text.append (String.format ("%04X/%04d: %02X (%d,%2d) ", ptr - 1, size,
buffer[ptr - 1], type, count));
if (type == 0)
{
System.out.println (HexFormatter.getHexString (buffer, ptr, count));
text.append (
String.format ("%s%n", HexFormatter.getHexString (buffer, ptr, count)));
ptr += count;
size += count;
}
else if (type == 1)
{
System.out.println (HexFormatter.getHexString (buffer, ptr, 1));
text.append (String.format ("%s%n", HexFormatter.getHexString (buffer, ptr, 1)));
ptr++;
size += count;
}
else if (type == 2)
{
System.out.println (HexFormatter.getHexString (buffer, ptr, 4));
text.append (String.format ("%s%n", HexFormatter.getHexString (buffer, ptr, 4)));
ptr += 4;
size += count * 4;
}
else
{
System.out.println (HexFormatter.getHexString (buffer, ptr, 1));
text.append (String.format ("%s%n", HexFormatter.getHexString (buffer, ptr, 1)));
ptr++;
size += count * 4;
}
}
return text.toString ();
}
// ---------------------------------------------------------------------------------//

View File

@ -141,7 +141,7 @@ public class SHRPictureFile1 extends HiResImage
int lo = dirEntry.mode & 0x00FF; // mode bit if hi == 0
boolean fillMode = (dirEntry.mode & 0x20) != 0;
// assert fillMode == false;
assert fillMode == false;
if (hi != 0)
System.out.println ("hi not zero");
@ -428,6 +428,13 @@ public class SHRPictureFile1 extends HiResImage
text.append ("\n ");
}
text.append ("\n");
if (true)
{
text.append ("\n");
text.append (debug (packedScanLine, 0, packedScanLine.length));
text.append ("\n");
}
}
return text.toString ();

View File

@ -214,6 +214,7 @@ public class AppleDisk implements Disk
}
diskBuffer = new byte[blocks * sectorSize];
hasData = new boolean[blocks];
if (debug)
@ -222,13 +223,13 @@ public class AppleDisk implements Disk
System.out.printf ("Skip size : %,d%n", skip);
}
try
try (BufferedInputStream in = new BufferedInputStream (new FileInputStream (file)))
{
BufferedInputStream in = new BufferedInputStream (new FileInputStream (file));
if (skip > 0)
in.skip (skip);
in.read (diskBuffer);
in.close ();
// in.close ();
}
catch (IOException e)
{
@ -239,6 +240,17 @@ public class AppleDisk implements Disk
checkSectorsForData ();
}
// ---------------------------------------------------------------------------------//
void switchToDos () // experimental
// ---------------------------------------------------------------------------------//
{
sectorSize = 256;
sectors = 16;
blocks = 560;
hasData = new boolean[blocks];
checkSectorsForData ();
}
// ---------------------------------------------------------------------------------//
public AppleDisk (V2dFile disk, int tracks, int sectors)
// ---------------------------------------------------------------------------------//

View File

@ -103,7 +103,7 @@ public class AppleDiskAddress implements DiskAddress
public String toString ()
// ---------------------------------------------------------------------------------//
{
return String.format ("[Block=%3d, Track=%2d, Sector=%2d, Zero=%s]", block, track,
return String.format ("[Block=%02X, Track=%02X, Sector=%02X, Zero=%s]", block, track,
sector, zeroFlag);
}
}

View File

@ -671,7 +671,12 @@ public class DiskFactory
AppleDisk disk = new AppleDisk (file, 0, 0);
if (disk.getTotalBlocks () > 0 && ProdosDisk.isCorrectFormat (disk))
return new ProdosDisk (disk);
// should check for DOS, but AppleDisk assumes 2mg has 512 byte blocks
// switch sector size
disk.switchToDos ();
// System.out.println (disk);
if (disk.getTotalBlocks () > 0 && DosDisk.isCorrectFormat (disk))
return new DosDisk (disk);
}
catch (Exception e)
{

View File

@ -55,9 +55,9 @@ class CatalogEntry extends AbstractCatalogEntry
da = getValidAddress (sectorBuffer, i);
if (da == null)
{
System.out.print ("T/S list in sector " + i);
System.out.printf (" contains an invalid address : %02X, %02X (file %s)%n",
sectorBuffer[i], sectorBuffer[i + 1], name.trim ());
System.out.printf (
"T/S list at offset %02X contains an invalid address : %02X, %02X (file %s)%n",
i, sectorBuffer[i], sectorBuffer[i + 1], name.trim ());
break loop;
}
if (da.getBlock () == 0 && !((AppleDiskAddress) da).zeroFlag ())

View File

@ -358,6 +358,7 @@ public class DosDisk extends AbstractFormattedDisk
System.out.printf ("Bad version : %02X%n", version);
return 0;
}
// System.out.printf ("Catalog blocks: %s%n", countCatalogBlocks (disk, buffer));
return countCatalogBlocks (disk, buffer);
}

View File

@ -61,6 +61,9 @@ class DosTSListSector extends AbstractSector
// ---------------------------------------------------------------------------------//
{
DiskAddress da = disk.getDiskAddress (buffer[1], buffer[2]);
if (da == null)
return String.format ("Invalid address: %02X %02X", buffer[1], buffer[2]);
String msg = da.matches (diskAddress) ? " (circular reference)" : "";
StringBuilder text = getHeader ("TS List Sector : " + name);