This commit is contained in:
Denis Molony 2019-08-01 17:31:49 +10:00
parent cb6d56cd55
commit 3785b29449
10 changed files with 77 additions and 73 deletions

View File

@ -414,12 +414,8 @@ public class BasicProgram extends AbstractFile
private void addHeader (StringBuilder pgm)
{
pgm.append ("Name : " + name + "\n");
pgm.append ("Length : $" + HexFormatter.format4 (buffer.length));
pgm.append (" (" + buffer.length + ")\n");
int programLoadAddress = getLoadAddress ();
pgm.append ("Load at : $" + HexFormatter.format4 (programLoadAddress));
pgm.append (" (" + programLoadAddress + ")\n\n");
pgm.append (String.format ("Length : $%04X (%<,d)%n", buffer.length));
pgm.append (String.format ("Load at : $%04X (%<,d)%n%n", getLoadAddress ()));
}
private int getLoadAddress ()

View File

@ -28,8 +28,7 @@ public class IntegerBasicProgram extends AbstractFile
{
StringBuilder pgm = new StringBuilder ();
pgm.append ("Name : " + name + "\n");
pgm.append ("Length : $" + HexFormatter.format4 (buffer.length) + " ("
+ buffer.length + ")\n\n");
pgm.append (String.format ("Length : $%04X (%<,d)%n%n", buffer.length));
int ptr = 0;
boolean looksLikeAssembler = checkForAssembler (); // this can probably go

View File

@ -18,7 +18,6 @@ import com.bytezone.diskbrowser.applefile.AppleFileSource;
import com.bytezone.diskbrowser.nib.NibFile;
import com.bytezone.diskbrowser.nib.V2dFile;
import com.bytezone.diskbrowser.nib.WozFile;
import com.bytezone.diskbrowser.nib.WozFile.Sector;
import com.bytezone.diskbrowser.nib.WozFileOld;
import com.bytezone.diskbrowser.utilities.FileFormatException;
import com.bytezone.diskbrowser.utilities.HexFormatter;
@ -78,7 +77,7 @@ public class AppleDisk implements Disk
// DFB 06,04,02,15 ;12->06,13->04,14->02,15->15
private boolean[] hasData;
private boolean[] isMissing;
// private boolean[] isMissing;
private byte emptyByte = 0;
private ActionListener actionListenerList;
@ -196,7 +195,7 @@ public class AppleDisk implements Disk
diskBuffer = new byte[blocks * sectorSize];
hasData = new boolean[blocks];
isMissing = new boolean[blocks];
// isMissing = new boolean[blocks];
if (debug)
{
@ -232,7 +231,7 @@ public class AppleDisk implements Disk
sectorSize = trackSize / sectors;
blocks = tracks * sectors;
hasData = new boolean[blocks];
isMissing = new boolean[blocks];
// isMissing = new boolean[blocks];
checkSectorsForData ();
}
@ -265,7 +264,7 @@ public class AppleDisk implements Disk
blocks = tracks * sectors;
hasData = new boolean[blocks];
isMissing = new boolean[blocks];
// isMissing = new boolean[blocks];
checkSectorsForData ();
}
@ -290,12 +289,12 @@ public class AppleDisk implements Disk
blocks = tracks * sectors;
hasData = new boolean[blocks];
isMissing = new boolean[blocks];
// isMissing = new boolean[blocks];
checkSectorsForData ();
for (Sector sector : wozFile.getBadSectors ())
isMissing[sector.trackNo * sectors + sector.sectorNo] = true;
// for (Sector sector : wozFile.getBadSectors ())
// isMissing[sector.trackNo * sectors + sector.sectorNo] = true;
}
private byte[] getPrefix (File path)
@ -420,23 +419,23 @@ public class AppleDisk implements Disk
return !hasData[getDiskAddress (track, sector).getBlock ()];
}
@Override
public boolean isSectorMissing (DiskAddress da)
{
return isMissing[da.getBlock ()];
}
@Override
public boolean isSectorMissing (int block)
{
return isMissing[block];
}
@Override
public boolean isSectorMissing (int track, int sector)
{
return isMissing[getDiskAddress (track, sector).getBlock ()];
}
// @Override
// public boolean isSectorMissing (DiskAddress da)
// {
// return isMissing[da.getBlock ()];
// }
//
// @Override
// public boolean isSectorMissing (int block)
// {
// return isMissing[block];
// }
//
// @Override
// public boolean isSectorMissing (int track, int sector)
// {
// return isMissing[getDiskAddress (track, sector).getBlock ()];
// }
@Override
public File getFile ()

View File

@ -48,11 +48,11 @@ public interface Disk extends Iterable<DiskAddress>
public boolean isSectorEmpty (DiskAddress da);
public boolean isSectorMissing (int block);
// public boolean isSectorMissing (int block);
public boolean isSectorMissing (int track, int sector);
// public boolean isSectorMissing (int track, int sector);
public boolean isSectorMissing (DiskAddress da);
// public boolean isSectorMissing (DiskAddress da);
public boolean isValidAddress (int block);

View File

@ -70,7 +70,7 @@ abstract class AbstractCatalogEntry implements AppleFileSource
// CATALOG command only formats the LO byte - see Beneath Apple DOS pp4-6
String base = String.format ("%s%s %03d ", (locked) ? "*" : " ", getFileType (),
(entryBuffer[33] & 0xFF));
catalogName = getName (base, entryBuffer);
catalogName = getName (base, entryBuffer).replace ("^", "");
}
private String getName (String base, byte[] buffer)

View File

@ -126,15 +126,15 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
DiskAddress da = d.getDiskAddress (blockNo);
boolean free = showFreeSectors && formattedDisk.isSectorFree (da);
boolean selected = selectionHandler.isSelected (da);
boolean missing = d.isSectorMissing (da);
drawBlock ((Graphics2D) g, type, x, y, free, selected, missing);
// boolean missing = d.isSectorMissing (da);
drawBlock ((Graphics2D) g, type, x, y, free, selected);
}
}
}
}
private void drawBlock (Graphics2D g, SectorType type, int x, int y, boolean flagFree,
boolean selected, boolean missing)
boolean selected)
{
g.setColor (type.colour);
g.fillRect (x + 1, y + 1, blockWidth - 1, blockHeight - 1);
@ -150,13 +150,13 @@ class DiskLayoutImage extends DiskPanel implements Scrollable, RedoListener
g.fillOval (x + centerOffset, y + 6, 3, 3);
}
if (missing)
{
g.setColor (Color.black);
g.setStroke (missingStroke);
g.drawLine (x + 5, y + 5, x + 11, y + 11);
g.drawLine (x + 5, y + 11, x + 11, y + 5);
}
// if (missing)
// {
// g.setColor (Color.darkGray);
// g.setStroke (missingStroke);
// g.drawLine (x + 5, y + 5, x + 11, y + 11);
// g.drawLine (x + 5, y + 11, x + 11, y + 5);
// }
}
private Color getContrastColor (SectorType type)

View File

@ -69,6 +69,7 @@ class MC3470
List<RawDiskSector> readTrack (byte[] buffer, int offset, int bytesUsed, int bitCount)
throws DiskNibbleException
{
assert false : "Not used";
int totalBits = 0;
int totalBytes = 0;

View File

@ -7,6 +7,7 @@ public class NibbleTrack
public NibbleTrack (byte[] buffer, int length, int bitsUsed)
{
assert false : "Not used";
this.bitsUsed = bitsUsed;
this.buffer = new byte[length];
System.arraycopy (buffer, 0, this.buffer, 0, length);

View File

@ -9,6 +9,7 @@ public class RawDiskSector
RawDiskSector (DiskAddressField addressField)
{
assert false : "Not used";
this.addressField = addressField;
}

View File

@ -13,6 +13,7 @@ import com.bytezone.diskbrowser.utilities.Utility;
// -----------------------------------------------------------------------------------//
public class WozFile
//-----------------------------------------------------------------------------------//
{
private static final byte[] address16prologue =
{ (byte) 0xD5, (byte) 0xAA, (byte) 0x96 };
@ -20,6 +21,7 @@ public class WozFile
{ (byte) 0xD5, (byte) 0xAA, (byte) 0xB5 };
private static final byte[] dataPrologue = { (byte) 0xD5, (byte) 0xAA, (byte) 0xAD };
private static final byte[] epilogue = { (byte) 0xDE, (byte) 0xAA, (byte) 0xEB };
// apparently it can be DE AA Ex
private static final int BLOCK_SIZE = 512;
private static final int SECTOR_SIZE = 256;
@ -34,11 +36,13 @@ public class WozFile
public final File file;
private int diskSectors;
private int diskType;
private int wozVersion;
private byte[] addressPrologue;
private final byte[] diskBuffer;
private final boolean debug = false;
private final boolean debug1 = false;
private final boolean debug2 = false;
List<Sector> badSectors = new ArrayList<> ();
// ---------------------------------------------------------------------------------//
@ -68,7 +72,7 @@ public class WozFile
{
String chunkId = new String (buffer, ptr, 4);
int size = val32 (buffer, ptr + 4);
if (debug)
if (debug1)
System.out.printf ("%n%s %,9d%n", chunkId, size);
switch (chunkId)
@ -97,11 +101,12 @@ public class WozFile
diskBuffer = new byte[35 * diskSectors * 256];
int ndx = diskSectors == 13 ? 0 : 1;
for (Track track : tracks)
for (Sector sector : track)
if (sector.dataOffset > 0)
sector.pack (diskReader, diskBuffer, SECTOR_SIZE
* (sector.trackNo * diskSectors + interleave[ndx][sector.sectorNo]));
if (diskType == 1)
for (Track track : tracks)
for (Sector sector : track)
if (sector.dataOffset > 0)
sector.pack (diskReader, diskBuffer, SECTOR_SIZE
* (sector.trackNo * diskSectors + interleave[ndx][sector.sectorNo]));
}
// ---------------------------------------------------------------------------------//
@ -131,13 +136,13 @@ public class WozFile
{
wozVersion = val8 (buffer, ptr + 8);
int diskType = val8 (buffer, ptr + 9);
diskType = val8 (buffer, ptr + 9);
int writeProtected = val8 (buffer, ptr + 10);
int synchronised = val8 (buffer, ptr + 11);
int cleaned = val8 (buffer, ptr + 12);
String creator = new String (buffer, ptr + 13, 32);
if (debug)
if (debug1)
{
String diskTypeText = diskType == 1 ? "5.25" : "3.5";
@ -160,7 +165,7 @@ public class WozFile
setGlobals (bootSectorFormat == 2 ? 13 : 16);
if (debug)
if (debug1)
{
String bootSectorFormatText =
bootSectorFormat == 0 ? "Unknown" : bootSectorFormat == 1 ? "16 sector"
@ -198,7 +203,7 @@ public class WozFile
{
ptr += 8;
if (debug)
if (debug1)
{
String metaData = new String (buffer, ptr, length);
String[] chunks = metaData.split ("\n");
@ -231,7 +236,7 @@ public class WozFile
if (trk.bitCount == 0)
break;
tracks.add (trk);
if (debug)
if (debug2)
System.out.printf ("%n$%02X %s%n", i, trk);
}
catch (DiskNibbleException e)
@ -299,12 +304,14 @@ public class WozFile
String home = "/Users/denismolony/";
String wozBase1 = home + "Dropbox/Examples/woz test images/WOZ 1.0/";
String wozBase2 = home + "Dropbox/Examples/woz test images/WOZ 2.0/";
String wozBase3 = home + "Dropbox/Examples/woz test images/WOZ 2.0/3.5/";
File[] files = { new File (home + "code/python/wozardry-2.0/bill.woz"),
new File (wozBase2 + "DOS 3.3 System Master.woz"),
new File (wozBase1 + "DOS 3.3 System Master.woz") };
new File (wozBase1 + "DOS 3.3 System Master.woz"),
new File (wozBase3 + "Apple IIgs System Disk 1.1.woz") };
try
{
new WozFile (files[2]);
new WozFile (files[3]);
}
catch (Exception e)
{
@ -339,15 +346,15 @@ public class WozFile
this.rawBuffer = rawBuffer;
this.trackNo = trackNo;
if (debug)
System.out.println (HexFormatter.format (rawBuffer, ptr, 512, ptr));
if (debug1)
System.out.println (HexFormatter.format (rawBuffer, ptr, 1024, ptr));
if (wozVersion == 1)
{
bytesUsed = val16 (rawBuffer, ptr + DATA_SIZE);
bitCount = val16 (rawBuffer, ptr + DATA_SIZE + 2);
if (debug)
if (debug1)
System.out.println (
(String.format ("Bytes: %2d, Bits: %,8d%n%n", bytesUsed, bitCount)));
}
@ -357,8 +364,8 @@ public class WozFile
blockCount = val16 (rawBuffer, ptr + 2);
bitCount = val32 (rawBuffer, ptr + 4);
if (debug)
System.out.println ((String.format ("Start: %4d, Blocks: %2d, Bits: %,8d%n%n",
if (debug1)
System.out.println ((String.format ("%nStart: %4d, Blocks: %2d, Bits: %,8d%n",
startingBlock, blockCount, bitCount)));
}
@ -384,7 +391,7 @@ public class WozFile
break;
Sector sector = new Sector (this, offset);
if (sectors.size () > 0)
if (debug1 && sectors.size () > 0)
checkDuplicates (sector);
sectors.add (sector);
@ -399,7 +406,7 @@ public class WozFile
{
for (Sector sector : sectors)
if (sector.isDuplicate (newSector))
System.out.println ("\n*** duplicate ***\n");
System.out.printf ("Duplicate: %s%n", newSector);
}
// ---------------------------------------------------------------------------------//