mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-06-26 17:29:50 +00:00
Woz2 changes
This commit is contained in:
parent
220a2f1cf9
commit
01b481339e
|
@ -113,7 +113,6 @@ public class DirectoryEntry implements AppleFileSource
|
||||||
|
|
||||||
public String line ()
|
public String line ()
|
||||||
{
|
{
|
||||||
// int blocks = ((rc & 0xF0) >> 3) + (((rc & 0x0F) + 7) / 8);
|
|
||||||
String bytes = HexFormatter.getHexString (blockList, 0, 16);
|
String bytes = HexFormatter.getHexString (blockList, 0, 16);
|
||||||
bytes = bytes.replaceAll ("00", " ");
|
bytes = bytes.replaceAll ("00", " ");
|
||||||
|
|
||||||
|
|
|
@ -254,8 +254,8 @@ public class DiskFactory
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// System.out.println (e);
|
System.out.println (e);
|
||||||
e.printStackTrace ();
|
// e.printStackTrace ();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,9 +98,12 @@ class MC3470
|
||||||
{
|
{
|
||||||
++zeroBits;
|
++zeroBits;
|
||||||
if (zeroBits > 2)
|
if (zeroBits > 2)
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
System.out.printf (zeroBits + " consecutive zeroes @ %d/%d %s%n",
|
System.out.printf (zeroBits + " consecutive zeroes @ %d/%d %s%n",
|
||||||
diskSectors.size (), dataPtr, currentState);
|
diskSectors.size (), dataPtr, currentState);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((value & 0x80) != 0) // value is not valid until the hi-bit is set
|
if ((value & 0x80) != 0) // value is not valid until the hi-bit is set
|
||||||
{
|
{
|
||||||
|
@ -132,6 +135,7 @@ class MC3470
|
||||||
{
|
{
|
||||||
inPtr = offset;
|
inPtr = offset;
|
||||||
restarted = true;
|
restarted = true;
|
||||||
|
if (debug)
|
||||||
System.out.println ("wrapping around");
|
System.out.println ("wrapping around");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@ public class WozFile
|
||||||
|
|
||||||
private final boolean debug = false;
|
private final boolean debug = false;
|
||||||
private int diskType; // 5.25 or 3.5
|
private int diskType; // 5.25 or 3.5
|
||||||
|
private int wozVersion;
|
||||||
|
private int bootSectorFormat;
|
||||||
|
|
||||||
public final File file;
|
public final File file;
|
||||||
byte[] diskBuffer;
|
byte[] diskBuffer;
|
||||||
|
@ -41,7 +43,15 @@ public class WozFile
|
||||||
byte[] buffer = readFile ();
|
byte[] buffer = readFile ();
|
||||||
boolean valid = false;
|
boolean valid = false;
|
||||||
|
|
||||||
if (!matches (WOZ1_FILE_HEADER, buffer))
|
if (matches (WOZ1_FILE_HEADER, buffer))
|
||||||
|
{
|
||||||
|
wozVersion = 1;
|
||||||
|
}
|
||||||
|
else if (matches (WOZ2_FILE_HEADER, buffer))
|
||||||
|
{
|
||||||
|
wozVersion = 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
System.out.println (HexFormatter.format (buffer, 0, 20));
|
System.out.println (HexFormatter.format (buffer, 0, 20));
|
||||||
throw new DiskNibbleException ("Header error");
|
throw new DiskNibbleException ("Header error");
|
||||||
|
@ -64,19 +74,45 @@ public class WozFile
|
||||||
int chunkSize = readInt (buffer, ptr, 4);
|
int chunkSize = readInt (buffer, ptr, 4);
|
||||||
ptr += 4;
|
ptr += 4;
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
System.out.printf ("Offset : %06X%n", ptr - 8);
|
||||||
|
System.out.printf ("Chunk ID : %s%n", chunkId);
|
||||||
|
System.out.printf ("Chunk size: %,d%n", chunkSize);
|
||||||
|
}
|
||||||
|
|
||||||
if ("INFO".equals (chunkId))
|
if ("INFO".equals (chunkId))
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
|
System.out.println ();
|
||||||
System.out.printf ("Version ........... %02X%n", buffer[ptr]);
|
System.out.printf ("Version ........... %02X%n", buffer[ptr]);
|
||||||
System.out.printf ("Disk type ......... %02X%n", buffer[ptr + 1]);
|
System.out.printf ("Disk type ......... %02X%n", buffer[ptr + 1]);
|
||||||
System.out.printf ("Write protected ... %02X%n", buffer[ptr + 2]);
|
System.out.printf ("Write protected ... %02X%n", buffer[ptr + 2]);
|
||||||
System.out.printf ("Synchronised ...... %02X%n", buffer[ptr + 3]);
|
System.out.printf ("Synchronised ...... %02X%n", buffer[ptr + 3]);
|
||||||
System.out.printf ("Cleaned ........... %02X%n", buffer[ptr + 4]);
|
System.out.printf ("Cleaned ........... %02X%n", buffer[ptr + 4]);
|
||||||
System.out.printf ("Creator ........... %s%n%n",
|
System.out.printf ("Creator ........... %s%n",
|
||||||
new String (buffer, ptr + 5, 32));
|
new String (buffer, ptr + 5, 32).trim ());
|
||||||
|
|
||||||
|
if (wozVersion > 1)
|
||||||
|
{
|
||||||
|
System.out.printf ("Disk sides ........ %02X%n", buffer[ptr + 37]);
|
||||||
|
System.out.printf ("Boot format ....... %02X%n", buffer[ptr + 38]);
|
||||||
|
System.out.printf ("Optimal timing .... %02X%n", buffer[ptr + 39]);
|
||||||
|
System.out.printf ("Compatible flags .. %04X%n",
|
||||||
|
readInt (buffer, ptr + 40, 2));
|
||||||
|
System.out.printf ("Minimum RAM ....... %04X%n",
|
||||||
|
readInt (buffer, ptr + 42, 2));
|
||||||
|
System.out.printf ("Largest track ..... %04X%n",
|
||||||
|
readInt (buffer, ptr + 44, 2));
|
||||||
}
|
}
|
||||||
|
System.out.println ();
|
||||||
|
}
|
||||||
|
|
||||||
diskType = buffer[ptr + 1] & 0xFF;
|
diskType = buffer[ptr + 1] & 0xFF;
|
||||||
|
if (wozVersion > 1)
|
||||||
|
bootSectorFormat = buffer[ptr + 38] & 0xFF;
|
||||||
|
|
||||||
ptr += INFO_SIZE;
|
ptr += INFO_SIZE;
|
||||||
}
|
}
|
||||||
else if ("TMAP".equals (chunkId))
|
else if ("TMAP".equals (chunkId))
|
||||||
|
@ -98,10 +134,13 @@ public class WozFile
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
System.out.println ("***************************************");
|
System.out.println ("***********************************************");
|
||||||
System.out.printf ("* Disk ......... %s%n", file.getName ());
|
System.out.printf ("* Disk ......... %s%n", file.getName ());
|
||||||
System.out.println ("***************************************");
|
System.out.println ("***********************************************");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wozVersion == 1)
|
||||||
|
{
|
||||||
int tracks = chunkSize / TRK_SIZE;
|
int tracks = chunkSize / TRK_SIZE;
|
||||||
|
|
||||||
for (int trackNo = 0; trackNo < tracks; trackNo++)
|
for (int trackNo = 0; trackNo < tracks; trackNo++)
|
||||||
|
@ -111,11 +150,12 @@ public class WozFile
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
System.out.println ("******************************");
|
System.out.println ("***************************************");
|
||||||
System.out.printf ("* Track ......... %,6d *%n", trackNo);
|
System.out.printf ("* Track ......... %,6d of %,6d *%n", trackNo,
|
||||||
|
tracks);
|
||||||
System.out.printf ("* Bytes used .... %,6d *%n", bytesUsed);
|
System.out.printf ("* Bytes used .... %,6d *%n", bytesUsed);
|
||||||
System.out.printf ("* Bit count .... %,6d *%n", bitCount);
|
System.out.printf ("* Bit count .... %,6d *%n", bitCount);
|
||||||
System.out.println ("******************************");
|
System.out.println ("***************************************");
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -141,7 +181,6 @@ public class WozFile
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// e.printStackTrace ();
|
|
||||||
System.out.println (e);
|
System.out.println (e);
|
||||||
break read;
|
break read;
|
||||||
}
|
}
|
||||||
|
@ -149,6 +188,40 @@ public class WozFile
|
||||||
ptr += TRK_SIZE;
|
ptr += TRK_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
diskBuffer = new byte[(bootSectorFormat == 2 ? 13 : 16) * 35 * 256];
|
||||||
|
|
||||||
|
for (int trackNo = 0; trackNo < 160; trackNo++)
|
||||||
|
{
|
||||||
|
int p = 256 + trackNo * 8;
|
||||||
|
int startingBlock = readInt (buffer, p, 2);
|
||||||
|
int blockCount = readInt (buffer, p + 2, 2);
|
||||||
|
int bitCount = readInt (buffer, p + 4, 4);
|
||||||
|
|
||||||
|
if (startingBlock == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
System.out.printf ("%3d %3d %6d%n", startingBlock, blockCount, bitCount);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// nibbleTracks.add (mc3470.getNibbleTrack (buffer, ptr, bytesUsed, bitCount));
|
||||||
|
List<RawDiskSector> diskSectors = mc3470.readTrack (buffer,
|
||||||
|
startingBlock * 512, blockCount * 512, bitCount);
|
||||||
|
|
||||||
|
mc3470.storeSectors (diskSectors, diskBuffer);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
System.out.println (e);
|
||||||
|
break read;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ptr += chunkSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if ("META".equals (chunkId))
|
else if ("META".equals (chunkId))
|
||||||
{
|
{
|
||||||
// System.out.printf ("[%s] %08X%n", chunkId, chunkSize);
|
// System.out.printf ("[%s] %08X%n", chunkId, chunkSize);
|
||||||
|
@ -162,8 +235,8 @@ public class WozFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!valid)
|
// if (!valid)
|
||||||
readNibbleTracks (buffer);
|
// readNibbleTracks (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@ -182,7 +255,6 @@ public class WozFile
|
||||||
NibbleTrack nibbleTrack = mc3470.getNibbleTrack (buffer, ptr, bytesUsed, bitCount);
|
NibbleTrack nibbleTrack = mc3470.getNibbleTrack (buffer, ptr, bytesUsed, bitCount);
|
||||||
nibbleTracks.add (nibbleTrack);
|
nibbleTracks.add (nibbleTrack);
|
||||||
}
|
}
|
||||||
// System.out.println (HexFormatter.format (nibbleTracks.get (2).buffer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
Loading…
Reference in New Issue
Block a user