diff --git a/src/com/bytezone/diskbrowser/applefile/BasicProgram.java b/src/com/bytezone/diskbrowser/applefile/BasicProgram.java index aca3452..60d21c1 100644 --- a/src/com/bytezone/diskbrowser/applefile/BasicProgram.java +++ b/src/com/bytezone/diskbrowser/applefile/BasicProgram.java @@ -159,7 +159,7 @@ public class BasicProgram extends AbstractFile else text.append (lineText); - // Check for a wrappable PRINT statement + // Check for a wrappable PRINT statement // (see FROM MACHINE LANGUAGE TO BASIC on DOSToolkit2eB.dsk) if (wrapPrintAt > 0 && (subline.is (TOKEN_PRINT) || subline.is (TOKEN_INPUT)) && countChars (text, ASCII_QUOTE) == 2 // just start and end quotes @@ -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 () diff --git a/src/com/bytezone/diskbrowser/applefile/IntegerBasicProgram.java b/src/com/bytezone/diskbrowser/applefile/IntegerBasicProgram.java index 130c753..b78cd8a 100755 --- a/src/com/bytezone/diskbrowser/applefile/IntegerBasicProgram.java +++ b/src/com/bytezone/diskbrowser/applefile/IntegerBasicProgram.java @@ -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 @@ -260,20 +259,20 @@ INPUT comands - change comma to semi-colon remove all DIM of a string variable (not needed) change string variables to use MID$ - i.e. A$(1,1)(in INT) is MID$(A$,1,1)(in AS basic) change GOTO or GOSUB with a variable to ON GOTO -change IF statements to ON GOTO where possible and convert to multiple lines. -All statements that follow an IF on the same line are executed whether the statement +change IF statements to ON GOTO where possible and convert to multiple lines. +All statements that follow an IF on the same line are executed whether the statement is true or not. change MOD function to X=Y-(INT(Y/Z)*Z) change "#" to "<>" change TAB to HTAB change RND(X) to INT(RND(1)*X) -relocate ML programs and change CALL'S and POKE'S. Since INT programs go from +relocate ML programs and change CALL'S and POKE'S. Since INT programs go from HIMEM down, binary code is usually in low memory. These few are not necessary but make for compact code. change CALL -384 to INVERSE change CALL -380 to NORMAL -change CALL -936 to HOME +change CALL -936 to HOME */ } \ No newline at end of file diff --git a/src/com/bytezone/diskbrowser/disk/AppleDisk.java b/src/com/bytezone/diskbrowser/disk/AppleDisk.java index 423c29a..7af8c59 100755 --- a/src/com/bytezone/diskbrowser/disk/AppleDisk.java +++ b/src/com/bytezone/diskbrowser/disk/AppleDisk.java @@ -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 () diff --git a/src/com/bytezone/diskbrowser/disk/Disk.java b/src/com/bytezone/diskbrowser/disk/Disk.java index c65243d..13f4ba7 100755 --- a/src/com/bytezone/diskbrowser/disk/Disk.java +++ b/src/com/bytezone/diskbrowser/disk/Disk.java @@ -48,11 +48,11 @@ public interface Disk extends Iterable 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); diff --git a/src/com/bytezone/diskbrowser/dos/AbstractCatalogEntry.java b/src/com/bytezone/diskbrowser/dos/AbstractCatalogEntry.java index bc85e39..bbfbfa3 100644 --- a/src/com/bytezone/diskbrowser/dos/AbstractCatalogEntry.java +++ b/src/com/bytezone/diskbrowser/dos/AbstractCatalogEntry.java @@ -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) diff --git a/src/com/bytezone/diskbrowser/gui/DiskLayoutImage.java b/src/com/bytezone/diskbrowser/gui/DiskLayoutImage.java index 75a95b0..498033b 100644 --- a/src/com/bytezone/diskbrowser/gui/DiskLayoutImage.java +++ b/src/com/bytezone/diskbrowser/gui/DiskLayoutImage.java @@ -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) diff --git a/src/com/bytezone/diskbrowser/nib/MC3470.java b/src/com/bytezone/diskbrowser/nib/MC3470.java index 8a60a0b..7405250 100644 --- a/src/com/bytezone/diskbrowser/nib/MC3470.java +++ b/src/com/bytezone/diskbrowser/nib/MC3470.java @@ -69,6 +69,7 @@ class MC3470 List readTrack (byte[] buffer, int offset, int bytesUsed, int bitCount) throws DiskNibbleException { + assert false : "Not used"; int totalBits = 0; int totalBytes = 0; diff --git a/src/com/bytezone/diskbrowser/nib/NibbleTrack.java b/src/com/bytezone/diskbrowser/nib/NibbleTrack.java index c9d1a5f..0d7f30b 100644 --- a/src/com/bytezone/diskbrowser/nib/NibbleTrack.java +++ b/src/com/bytezone/diskbrowser/nib/NibbleTrack.java @@ -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); diff --git a/src/com/bytezone/diskbrowser/nib/RawDiskSector.java b/src/com/bytezone/diskbrowser/nib/RawDiskSector.java index 608325e..ebe259f 100644 --- a/src/com/bytezone/diskbrowser/nib/RawDiskSector.java +++ b/src/com/bytezone/diskbrowser/nib/RawDiskSector.java @@ -9,6 +9,7 @@ public class RawDiskSector RawDiskSector (DiskAddressField addressField) { + assert false : "Not used"; this.addressField = addressField; } diff --git a/src/com/bytezone/diskbrowser/nib/WozFile.java b/src/com/bytezone/diskbrowser/nib/WozFile.java index fe95a53..227f266 100644 --- a/src/com/bytezone/diskbrowser/nib/WozFile.java +++ b/src/com/bytezone/diskbrowser/nib/WozFile.java @@ -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 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); } // ---------------------------------------------------------------------------------//