diff --git a/src/com/bytezone/diskbrowser/cpm/CPMDisk.java b/src/com/bytezone/diskbrowser/cpm/CPMDisk.java index fe83f4c..fbdcbd4 100644 --- a/src/com/bytezone/diskbrowser/cpm/CPMDisk.java +++ b/src/com/bytezone/diskbrowser/cpm/CPMDisk.java @@ -21,7 +21,7 @@ public class CPMDisk extends AbstractFormattedDisk public final SectorType basSector = new SectorType ("BAS", Color.gray); public final SectorType asmSector = new SectorType ("ASM", Color.orange); public final SectorType ovrSector = new SectorType ("OVR", Color.magenta); - public final SectorType macSector = new SectorType ("Green", Color.green); + public final SectorType macSector = new SectorType ("MAC", Color.green); private int version; // http://www.seasip.info/Cpm/format22.html diff --git a/src/com/bytezone/diskbrowser/disk/AppleDisk.java b/src/com/bytezone/diskbrowser/disk/AppleDisk.java index 6a5081b..97df5d1 100755 --- a/src/com/bytezone/diskbrowser/disk/AppleDisk.java +++ b/src/com/bytezone/diskbrowser/disk/AppleDisk.java @@ -146,12 +146,6 @@ public class AppleDisk implements Disk System.out.println (); } - // if (sectorSize != 256 && sectorSize != 512) - // { - // System.out.println ("Invalid sector size : " + sectorSize); - // new Exception ().printStackTrace (); - // } - if (sectorSize != 256 && sectorSize != 512) throw new FileFormatException ("Invalid sector size : " + sectorSize); diff --git a/src/com/bytezone/diskbrowser/disk/DiskFactory.java b/src/com/bytezone/diskbrowser/disk/DiskFactory.java index 76853e1..37ab700 100755 --- a/src/com/bytezone/diskbrowser/disk/DiskFactory.java +++ b/src/com/bytezone/diskbrowser/disk/DiskFactory.java @@ -124,6 +124,9 @@ public class DiskFactory if (((suffix.equals ("po") || suffix.equals ("dsk")) && file.length () > 143360)) { + if (debug) + System.out.println ("Checking po or dsk hard drive: " + file.length ()); + disk = checkHardDisk (file); if (disk != null) { @@ -131,11 +134,22 @@ public class DiskFactory disk.setOriginalPath (p); return disk; } - else + + if (debug) + System.out.println ("Creating a data disk from bad length"); + try { AppleDisk appleDisk = new AppleDisk (file, (int) file.length () / 4096, 8); + if (debug) + System.out.println ("created"); return new DataDisk (appleDisk); } + catch (FileFormatException e) + { + if (debug) + System.out.println ("Creating AppleDisk failed"); + return null; + } } long length = file.length (); @@ -296,20 +310,17 @@ public class DiskFactory if ((file.length () % 512) != 0) { if (debug) - System.out.printf ("file length not divisible by 512 : %,d%n", file.length ()); - // return null; + System.out.printf ("file length not divisible by 512 : %,d%n%n", file.length ()); + return null; } // assumes a track is 4096 bytes - // if ((file.length () % 4096) != 0) - // { - // if (debug) - // { - // System.out.printf ("file length not divisible by 4096 : %d%n%n", file.length ()); - // int usableLength = (int) (file.length () / 4096); - // } - // return null; - // } + if ((file.length () % 4096) != 0) + { + if (debug) + System.out.printf ("file length not divisible by 4096 : %d%n%n", file.length ()); + return null; + } try { diff --git a/src/com/bytezone/diskbrowser/disk/DualDosDisk.java b/src/com/bytezone/diskbrowser/disk/DualDosDisk.java index 6e135c9..689bde6 100755 --- a/src/com/bytezone/diskbrowser/disk/DualDosDisk.java +++ b/src/com/bytezone/diskbrowser/disk/DualDosDisk.java @@ -25,11 +25,10 @@ public class DualDosDisk implements FormattedDisk, FileSelectionListener public DualDosDisk (FormattedDisk disk0, FormattedDisk disk1) { String diskName = disk0.getDisk ().getFile ().getName (); - String text = - "This disk contains both DOS and Prodos files. Isn't that clever?\n\n" - + disk0.getDisk () + "\n" + disk1.getDisk (); + String text = "This disk contains both DOS and Prodos files. Isn't that clever?\n\n" + + disk0.getDisk () + "\n" + disk1.getDisk (); DefaultMutableTreeNode root = - new DefaultMutableTreeNode (new DefaultAppleFileSource (diskName, text, this)); + new DefaultMutableTreeNode (new DefaultAppleFileSource (diskName, text, this)); DefaultTreeModel treeModel = new DefaultTreeModel (root); tree = new JTree (treeModel); treeModel.setAsksAllowsChildren (true); // allows empty nodes to appear as folders @@ -40,9 +39,9 @@ public class DualDosDisk implements FormattedDisk, FileSelectionListener disk1.setParent (this); DefaultMutableTreeNode root0 = - (DefaultMutableTreeNode) disk0.getCatalogTree ().getModel ().getRoot (); + (DefaultMutableTreeNode) disk0.getCatalogTree ().getModel ().getRoot (); DefaultMutableTreeNode root1 = - (DefaultMutableTreeNode) disk1.getCatalogTree ().getModel ().getRoot (); + (DefaultMutableTreeNode) disk1.getCatalogTree ().getModel ().getRoot (); root.add ((DefaultMutableTreeNode) root0.getChildAt (0)); root.add ((DefaultMutableTreeNode) root1.getChildAt (0)); @@ -112,14 +111,14 @@ public class DualDosDisk implements FormattedDisk, FileSelectionListener else if (disks[1] == fd && currentDisk != 1) currentDisk = 1; - System.out.println ("AFS : " + afs); - System.out.println ("1. Setting current disk to : " + currentDisk); + // System.out.println ("AFS : " + afs); + // System.out.println ("1. Setting current disk to : " + currentDisk); } public void setCurrentDiskNo (int n) { currentDisk = n; - System.out.println ("2. Setting current disk to : " + currentDisk); + // System.out.println ("2. Setting current disk to : " + currentDisk); } public int getCurrentDiskNo () @@ -141,9 +140,10 @@ public class DualDosDisk implements FormattedDisk, FileSelectionListener @Override public AppleFileSource getCatalog () { - return new DefaultAppleFileSource ("text", disks[0].getCatalog ().getDataSource () - .getText () - + "\n\n" + disks[1].getCatalog ().getDataSource ().getText (), this); + return new DefaultAppleFileSource ("text", + disks[0].getCatalog ().getDataSource ().getText () + "\n\n" + + disks[1].getCatalog ().getDataSource ().getText (), + this); } @Override @@ -151,7 +151,7 @@ public class DualDosDisk implements FormattedDisk, FileSelectionListener { if (true) return disks[currentDisk].getFile (uniqueName); - System.out.println ("Searching for : " + uniqueName); + // System.out.println ("Searching for : " + uniqueName); for (int i = 0; i < 2; i++) { AppleFileSource afs = disks[i].getFile (uniqueName); diff --git a/src/com/bytezone/diskbrowser/infocom/InfocomDisk.java b/src/com/bytezone/diskbrowser/infocom/InfocomDisk.java index 459b321..015396c 100755 --- a/src/com/bytezone/diskbrowser/infocom/InfocomDisk.java +++ b/src/com/bytezone/diskbrowser/infocom/InfocomDisk.java @@ -41,8 +41,8 @@ public class InfocomDisk extends AbstractFormattedDisk setInfocomSectorTypes (); - data = disk.readSector (3, 0); // read first sector to get file size - data = getBuffer (getWord (26) * 2); // read entire file into data buffer + data = disk.readSector (3, 0); // read first sector to get file size + data = getBuffer (getWord (26) * 2); // read entire file into data buffer if (false) createStoryFile ("Zork1.sf"); @@ -138,7 +138,6 @@ public class InfocomDisk extends AbstractFormattedDisk { if (fileSize == 0) fileSize = getFileSize (); - // System.out.println ("File size : " + fileSize); data = new byte[fileSize]; for (int track = 3, ptr = 0; track < 35; track++)