diff --git a/src/com/bytezone/diskbrowser/applefile/Selector.java b/src/com/bytezone/diskbrowser/applefile/Selector.java new file mode 100644 index 0000000..59f800c --- /dev/null +++ b/src/com/bytezone/diskbrowser/applefile/Selector.java @@ -0,0 +1,111 @@ +package com.bytezone.diskbrowser.applefile; + +import java.util.ArrayList; +import java.util.List; + +// -----------------------------------------------------------------------------------// +public class Selector extends AbstractFile +// -----------------------------------------------------------------------------------// +{ + int numRunListEntries; + int numOtherRunListEntries; + List entries = new ArrayList<> (); + List paths = new ArrayList<> (); + + // ---------------------------------------------------------------------------------// + public Selector (String name, byte[] buffer) + // ---------------------------------------------------------------------------------// + { + super (name, buffer); + + numRunListEntries = buffer[0] & 0xFF; + numOtherRunListEntries = buffer[1] & 0xFF; + + int ptr = 2; + for (int i = 0; i < 24; i++) + { + entries.add (new Entry (buffer, ptr)); + ptr += 16; + } + + ptr = 386; + for (int i = 0; i < 24; i++) + { + paths.add (new Path (buffer, ptr)); + ptr += 64; + } + } + + // ---------------------------------------------------------------------------------// + @Override + public String getText () + // ---------------------------------------------------------------------------------// + { + StringBuilder text = new StringBuilder (); + + text.append ("Name : " + name + "\n"); + text.append (String.format ("Length : $%04X (%<,d)%n%n", buffer.length)); + text.append (String.format ("NumRunListEntries ....... %d%n", buffer[0])); + text.append (String.format ("NumOtherRunListEntries .. %d%n%n", buffer[1])); + text.append ("Name Copy Path\n"); + text.append ("-------------- ---------- ------------------------------------\n"); + + for (int i = 0; i < entries.size (); i++) + { + Entry entry = entries.get (i); + Path path = paths.get (i); + + if (entry.labelLength > 0) + text.append (String.format ("%-14s %-10s %s%n", entry.label, entry.copyText, + path.pathName)); + } + + return text.toString (); + } + + // ---------------------------------------------------------------------------------// + class Entry + // ---------------------------------------------------------------------------------// + { + int labelLength; + String label; + byte copyFlags; + String copyText; + + public Entry (byte[] buffer, int ptr) + { + labelLength = buffer[ptr] & 0xFF; + label = new String (buffer, ptr + 1, labelLength); + copyFlags = buffer[ptr + 15]; + switch (copyFlags & 0xFF) + { + case 0: + copyText = "First boot"; + break; + case 0x80: + copyText = "First use"; + break; + case 0xC0: + copyText = "Never"; + break; + default: + copyText = "Unknown"; + break; + } + } + } + + // ---------------------------------------------------------------------------------// + class Path + // ---------------------------------------------------------------------------------// + { + int length; + String pathName; + + public Path (byte[] buffer, int ptr) + { + length = buffer[ptr] & 0xFF; + pathName = new String (buffer, ptr + 1, length); + } + } +} diff --git a/src/com/bytezone/diskbrowser/cpm/CPMDisk.java b/src/com/bytezone/diskbrowser/cpm/CPMDisk.java index 5c4dadd..2445ef8 100644 --- a/src/com/bytezone/diskbrowser/cpm/CPMDisk.java +++ b/src/com/bytezone/diskbrowser/cpm/CPMDisk.java @@ -233,7 +233,7 @@ public class CPMDisk extends AbstractFormattedDisk if (val == 0xE5) break; - if (val > 31) // && val != 0xE5) + if (val > 31) return false; for (int j = 1; j <= 8; j++) @@ -259,11 +259,11 @@ public class CPMDisk extends AbstractFormattedDisk } // ---------------------------------------------------------------------------------// - @Override - public String toString () - // ---------------------------------------------------------------------------------// - { - StringBuffer text = new StringBuffer ("CPM disk"); - return text.toString (); - } + // @Override + // public String toString () + // // ---------------------------------------------------------------------------------// + // { + // StringBuffer text = new StringBuffer ("CPM disk"); + // return text.toString (); + // } } \ No newline at end of file diff --git a/src/com/bytezone/diskbrowser/disk/AbstractFormattedDisk.java b/src/com/bytezone/diskbrowser/disk/AbstractFormattedDisk.java index 85f6f9f..aa0fed5 100755 --- a/src/com/bytezone/diskbrowser/disk/AbstractFormattedDisk.java +++ b/src/com/bytezone/diskbrowser/disk/AbstractFormattedDisk.java @@ -394,7 +394,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk public DataSource getFormattedSector (DiskAddress da) // ---------------------------------------------------------------------------------// { - if (da.getBlockNo () == 0 && bootSector != null) + if (da.isZero () && bootSector != null) return bootSector; SectorType sectorType = sectorTypes[da.getBlockNo ()]; @@ -564,6 +564,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk // ---------------------------------------------------------------------------------// { StringBuilder text = new StringBuilder (); + text.append (String.format ("Disk name ............. %s%n", getDisplayPath ())); text.append (String.format ("Block size..... %d%n", disk.getBlockSize ())); text.append (String.format ("Interleave..... %d", disk.getInterleave ())); return text.toString (); diff --git a/src/com/bytezone/diskbrowser/disk/AppleDisk.java b/src/com/bytezone/diskbrowser/disk/AppleDisk.java index 2fa96cf..0c772dd 100755 --- a/src/com/bytezone/diskbrowser/disk/AppleDisk.java +++ b/src/com/bytezone/diskbrowser/disk/AppleDisk.java @@ -113,6 +113,7 @@ public class AppleDisk implements Disk if ("2mg".equalsIgnoreCase (suffix) || "2IMG".equals (prefix)) { + // System.out.println ("checking 2mg"); if ("2IMG".equals (prefix)) { Prefix2mg prefix2mg = new Prefix2mg (buffer); diff --git a/src/com/bytezone/diskbrowser/disk/AppleDiskAddress.java b/src/com/bytezone/diskbrowser/disk/AppleDiskAddress.java index 25c74b2..53d797b 100755 --- a/src/com/bytezone/diskbrowser/disk/AppleDiskAddress.java +++ b/src/com/bytezone/diskbrowser/disk/AppleDiskAddress.java @@ -66,6 +66,14 @@ public class AppleDiskAddress implements DiskAddress return this.block == that.getBlockNo (); } + // ---------------------------------------------------------------------------------// + @Override + public boolean isZero () + // ---------------------------------------------------------------------------------// + { + return block == 0; + } + // ---------------------------------------------------------------------------------// @Override public int getBlockNo () diff --git a/src/com/bytezone/diskbrowser/disk/DiskAddress.java b/src/com/bytezone/diskbrowser/disk/DiskAddress.java index eab52df..1f55cba 100755 --- a/src/com/bytezone/diskbrowser/disk/DiskAddress.java +++ b/src/com/bytezone/diskbrowser/disk/DiskAddress.java @@ -10,6 +10,8 @@ public interface DiskAddress extends Comparable public int getSectorNo (); + public boolean isZero (); + public Disk getDisk (); public boolean matches (DiskAddress other); diff --git a/src/com/bytezone/diskbrowser/disk/DualDosDisk.java b/src/com/bytezone/diskbrowser/disk/DualDosDisk.java index 4a3a0d2..de62d69 100755 --- a/src/com/bytezone/diskbrowser/disk/DualDosDisk.java +++ b/src/com/bytezone/diskbrowser/disk/DualDosDisk.java @@ -1,350 +1,354 @@ -package com.bytezone.diskbrowser.disk; - -import java.awt.Dimension; -import java.nio.file.Path; -import java.util.List; - -import javax.swing.JTree; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.DefaultTreeModel; - -import com.bytezone.diskbrowser.applefile.AbstractFile; -import com.bytezone.diskbrowser.applefile.AppleFileSource; -import com.bytezone.diskbrowser.gui.DataSource; - -// Apple Assembly Lines disks are dual-dos -// Should be renamed MultiVolumeDisk (and allow >2 volumes) - -// -----------------------------------------------------------------------------------// -public class DualDosDisk implements FormattedDisk -// -----------------------------------------------------------------------------------// -{ - private final FormattedDisk[] disks = new FormattedDisk[2]; - private int currentDisk; - private final JTree tree; - - // ---------------------------------------------------------------------------------// - public DualDosDisk (FormattedDisk disk0, FormattedDisk disk1) - // ---------------------------------------------------------------------------------// - { - assert disk0 != disk1; - String diskName = disk0.getDisk ().getFile ().getName (); - String text = "This disk contains files from DOS and another OS\n\n" - + disk0.getDisk () + "\n\n" + disk1.getDisk (); - - DefaultAppleFileSource dafs = new DefaultAppleFileSource (diskName, text, this); - DefaultMutableTreeNode root = new DefaultMutableTreeNode (dafs); - - DefaultTreeModel treeModel = new DefaultTreeModel (root); - tree = new JTree (treeModel); - - // allow empty nodes to appear as folders - treeModel.setAsksAllowsChildren (true); - - disks[0] = disk0; - disks[1] = disk1; - - disk0.setParent (this); - disk1.setParent (this); - - DefaultMutableTreeNode root0 = - (DefaultMutableTreeNode) disk0.getCatalogTree ().getModel ().getRoot (); - DefaultMutableTreeNode root1 = - (DefaultMutableTreeNode) disk1.getCatalogTree ().getModel ().getRoot (); - - root.add ((DefaultMutableTreeNode) root0.getChildAt (0)); - root.add ((DefaultMutableTreeNode) root1.getChildAt (0)); - } - - // ---------------------------------------------------------------------------------// - @Override - public JTree getCatalogTree () - // ---------------------------------------------------------------------------------// - { - return tree; - } - - // ---------------------------------------------------------------------------------// - @Override - public List getFileSectors (int fileNo) - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].getFileSectors (fileNo); - } - - // ---------------------------------------------------------------------------------// - @Override - public List getCatalogList () - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].getCatalogList (); - } - - // ---------------------------------------------------------------------------------// - @Override - public DataSource getFormattedSector (DiskAddress da) - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].getFormattedSector (da); - } - - // ---------------------------------------------------------------------------------// - @Override - public SectorType getSectorType (DiskAddress da) - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].getSectorType (da); - } - - // ---------------------------------------------------------------------------------// - @Override - public SectorType getSectorType (int track, int sector) - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].getSectorType (track, sector); - } - - // ---------------------------------------------------------------------------------// - @Override - public SectorType getSectorType (int block) - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].getSectorType (block); - } - - // ---------------------------------------------------------------------------------// - @Override - public List getSectorTypeList () - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].getSectorTypeList (); - } - - // ---------------------------------------------------------------------------------// - @Override - public Disk getDisk () - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].getDisk (); - } - - // ---------------------------------------------------------------------------------// - public void setCurrentDisk (FormattedDisk fd) - // ---------------------------------------------------------------------------------// - { - if (disks[0] == fd) - currentDisk = 0; - else if (disks[1] == fd) - currentDisk = 1; - else - System.out.println ("Disk not found: " + fd); - } - - // ---------------------------------------------------------------------------------// - public void setCurrentDiskNo (int n) - // ---------------------------------------------------------------------------------// - { - currentDisk = n; - } - - // ---------------------------------------------------------------------------------// - public int getCurrentDiskNo () - // ---------------------------------------------------------------------------------// - { - return currentDisk; - } - - // ---------------------------------------------------------------------------------// - public FormattedDisk getCurrentDisk () - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk]; - } - - // ---------------------------------------------------------------------------------// - @Override - public void writeFile (AbstractFile file) - // ---------------------------------------------------------------------------------// - { - disks[currentDisk].writeFile (file); - } - - // ---------------------------------------------------------------------------------// - @Override - public AppleFileSource getCatalog () - // ---------------------------------------------------------------------------------// - { - return new DefaultAppleFileSource ("text", - disks[0].getCatalog ().getDataSource ().getText () + "\n\n" - + disks[1].getCatalog ().getDataSource ().getText (), - this); - } - - // ---------------------------------------------------------------------------------// - @Override - public AppleFileSource getFile (String uniqueName) - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].getFile (uniqueName); - } - - // ---------------------------------------------------------------------------------// - @Override - public int clearOrphans () - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].clearOrphans (); - } - - // ---------------------------------------------------------------------------------// - @Override - public boolean isSectorFree (DiskAddress da) - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].isSectorFree (da); - } - - // ---------------------------------------------------------------------------------// - @Override - public void verify () - // ---------------------------------------------------------------------------------// - { - disks[currentDisk].verify (); - } - - // ---------------------------------------------------------------------------------// - @Override - public boolean stillAvailable (DiskAddress da) - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].stillAvailable (da); - } - - // ---------------------------------------------------------------------------------// - @Override - public void setSectorType (int block, SectorType type) - // ---------------------------------------------------------------------------------// - { - disks[currentDisk].setSectorType (block, type); - } - - // ---------------------------------------------------------------------------------// - @Override - public void setSectorFree (int block, boolean free) - // ---------------------------------------------------------------------------------// - { - disks[currentDisk].setSectorFree (block, free); - } - - // ---------------------------------------------------------------------------------// - @Override - public int falseNegativeBlocks () - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].falseNegativeBlocks (); - } - - // ---------------------------------------------------------------------------------// - @Override - public int falsePositiveBlocks () - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].falsePositiveBlocks (); - } - - // ---------------------------------------------------------------------------------// - @Override - public Dimension getGridLayout () - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].getGridLayout (); - } - - // ---------------------------------------------------------------------------------// - @Override - public boolean isSectorFree (int block) - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].isSectorFree (block); - } - - // ---------------------------------------------------------------------------------// - @Override - public boolean stillAvailable (int block) - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].stillAvailable (block); - } - - // ---------------------------------------------------------------------------------// - @Override - public void setOriginalPath (Path path) - // ---------------------------------------------------------------------------------// - { - disks[currentDisk].setOriginalPath (path); - } - - // ---------------------------------------------------------------------------------// - @Override - public String getAbsolutePath () - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].getAbsolutePath (); - } - - // ---------------------------------------------------------------------------------// - @Override - public String getDisplayPath () - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].getDisplayPath (); - } - - // ---------------------------------------------------------------------------------// - @Override - public FormattedDisk getParent () - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].getParent (); - } - - // ---------------------------------------------------------------------------------// - @Override - public void setParent (FormattedDisk disk) - // ---------------------------------------------------------------------------------// - { - disks[currentDisk].setParent (disk); - } - - // ---------------------------------------------------------------------------------// - @Override - public String getSectorFilename (DiskAddress da) - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].getSectorFilename (da); - } - - // ---------------------------------------------------------------------------------// - @Override - public String getName () - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].getName (); - } - - // ---------------------------------------------------------------------------------// - @Override - public boolean isTempDisk () - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].isTempDisk (); - } - - // ---------------------------------------------------------------------------------// - @Override - public Path getOriginalPath () - // ---------------------------------------------------------------------------------// - { - return disks[currentDisk].getOriginalPath (); - } +package com.bytezone.diskbrowser.disk; + +import java.awt.Dimension; +import java.nio.file.Path; +import java.util.List; + +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; + +import com.bytezone.diskbrowser.applefile.AbstractFile; +import com.bytezone.diskbrowser.applefile.AppleFileSource; +import com.bytezone.diskbrowser.gui.DataSource; + +// Apple Assembly Lines disks are dual-dos +// Should be renamed MultiVolumeDisk (and allow >2 volumes) + +// -----------------------------------------------------------------------------------// +public class DualDosDisk implements FormattedDisk +// -----------------------------------------------------------------------------------// +{ + private final FormattedDisk[] disks = new FormattedDisk[2]; + private int currentDisk; + private final JTree tree; + + // ---------------------------------------------------------------------------------// + public DualDosDisk (FormattedDisk disk0, FormattedDisk disk1) + // ---------------------------------------------------------------------------------// + { + assert disk0 != disk1; + String diskName = disk0.getDisk ().getFile ().getName (); + String text = "This disk contains files from DOS and another OS\n\n" + + disk0.getDisk () + "\n\n" + disk1.getDisk (); + + DefaultAppleFileSource dafs = new DefaultAppleFileSource (diskName, text, this); + DefaultMutableTreeNode root = new DefaultMutableTreeNode (dafs); + + DefaultTreeModel treeModel = new DefaultTreeModel (root); + tree = new JTree (treeModel); + + // allow empty nodes to appear as folders + treeModel.setAsksAllowsChildren (true); + + disks[0] = disk0; + disks[1] = disk1; + + disk0.setParent (this); + disk1.setParent (this); + + DefaultMutableTreeNode root0 = + (DefaultMutableTreeNode) disk0.getCatalogTree ().getModel ().getRoot (); + DefaultMutableTreeNode root1 = + (DefaultMutableTreeNode) disk1.getCatalogTree ().getModel ().getRoot (); + + root.add ((DefaultMutableTreeNode) root0.getChildAt (0)); + root.add ((DefaultMutableTreeNode) root1.getChildAt (0)); + } + + // ---------------------------------------------------------------------------------// + @Override + public JTree getCatalogTree () + // ---------------------------------------------------------------------------------// + { + return tree; + } + + // ---------------------------------------------------------------------------------// + @Override + public List getFileSectors (int fileNo) + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].getFileSectors (fileNo); + } + + // ---------------------------------------------------------------------------------// + @Override + public List getCatalogList () + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].getCatalogList (); + } + + // ---------------------------------------------------------------------------------// + @Override + public DataSource getFormattedSector (DiskAddress da) + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].getFormattedSector (da); + } + + // ---------------------------------------------------------------------------------// + @Override + public SectorType getSectorType (DiskAddress da) + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].getSectorType (da); + } + + // ---------------------------------------------------------------------------------// + @Override + public SectorType getSectorType (int track, int sector) + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].getSectorType (track, sector); + } + + // ---------------------------------------------------------------------------------// + @Override + public SectorType getSectorType (int block) + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].getSectorType (block); + } + + // ---------------------------------------------------------------------------------// + @Override + public List getSectorTypeList () + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].getSectorTypeList (); + } + + // ---------------------------------------------------------------------------------// + @Override + public Disk getDisk () + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].getDisk (); + } + + // ---------------------------------------------------------------------------------// + public void setCurrentDisk (FormattedDisk fd) + // ---------------------------------------------------------------------------------// + { + if (disks[0] == fd) + currentDisk = 0; + else if (disks[1] == fd) + currentDisk = 1; + else + { + // this happens when the top-level folder is selected (i.e. neither disk) + System.out.println ("Disk not found: " + fd); + // Utility.printStackTrace (); + } + } + + // ---------------------------------------------------------------------------------// + public void setCurrentDiskNo (int n) + // ---------------------------------------------------------------------------------// + { + currentDisk = n; + } + + // ---------------------------------------------------------------------------------// + public int getCurrentDiskNo () + // ---------------------------------------------------------------------------------// + { + return currentDisk; + } + + // ---------------------------------------------------------------------------------// + public FormattedDisk getCurrentDisk () + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk]; + } + + // ---------------------------------------------------------------------------------// + @Override + public void writeFile (AbstractFile file) + // ---------------------------------------------------------------------------------// + { + disks[currentDisk].writeFile (file); + } + + // ---------------------------------------------------------------------------------// + @Override + public AppleFileSource getCatalog () + // ---------------------------------------------------------------------------------// + { + return new DefaultAppleFileSource ("text", + disks[0].getCatalog ().getDataSource ().getText () + "\n\n" + + disks[1].getCatalog ().getDataSource ().getText (), + this); + } + + // ---------------------------------------------------------------------------------// + @Override + public AppleFileSource getFile (String uniqueName) + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].getFile (uniqueName); + } + + // ---------------------------------------------------------------------------------// + @Override + public int clearOrphans () + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].clearOrphans (); + } + + // ---------------------------------------------------------------------------------// + @Override + public boolean isSectorFree (DiskAddress da) + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].isSectorFree (da); + } + + // ---------------------------------------------------------------------------------// + @Override + public void verify () + // ---------------------------------------------------------------------------------// + { + disks[currentDisk].verify (); + } + + // ---------------------------------------------------------------------------------// + @Override + public boolean stillAvailable (DiskAddress da) + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].stillAvailable (da); + } + + // ---------------------------------------------------------------------------------// + @Override + public void setSectorType (int block, SectorType type) + // ---------------------------------------------------------------------------------// + { + disks[currentDisk].setSectorType (block, type); + } + + // ---------------------------------------------------------------------------------// + @Override + public void setSectorFree (int block, boolean free) + // ---------------------------------------------------------------------------------// + { + disks[currentDisk].setSectorFree (block, free); + } + + // ---------------------------------------------------------------------------------// + @Override + public int falseNegativeBlocks () + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].falseNegativeBlocks (); + } + + // ---------------------------------------------------------------------------------// + @Override + public int falsePositiveBlocks () + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].falsePositiveBlocks (); + } + + // ---------------------------------------------------------------------------------// + @Override + public Dimension getGridLayout () + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].getGridLayout (); + } + + // ---------------------------------------------------------------------------------// + @Override + public boolean isSectorFree (int block) + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].isSectorFree (block); + } + + // ---------------------------------------------------------------------------------// + @Override + public boolean stillAvailable (int block) + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].stillAvailable (block); + } + + // ---------------------------------------------------------------------------------// + @Override + public void setOriginalPath (Path path) + // ---------------------------------------------------------------------------------// + { + disks[currentDisk].setOriginalPath (path); + } + + // ---------------------------------------------------------------------------------// + @Override + public String getAbsolutePath () + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].getAbsolutePath (); + } + + // ---------------------------------------------------------------------------------// + @Override + public String getDisplayPath () + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].getDisplayPath (); + } + + // ---------------------------------------------------------------------------------// + @Override + public FormattedDisk getParent () + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].getParent (); + } + + // ---------------------------------------------------------------------------------// + @Override + public void setParent (FormattedDisk disk) + // ---------------------------------------------------------------------------------// + { + disks[currentDisk].setParent (disk); + } + + // ---------------------------------------------------------------------------------// + @Override + public String getSectorFilename (DiskAddress da) + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].getSectorFilename (da); + } + + // ---------------------------------------------------------------------------------// + @Override + public String getName () + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].getName (); + } + + // ---------------------------------------------------------------------------------// + @Override + public boolean isTempDisk () + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].isTempDisk (); + } + + // ---------------------------------------------------------------------------------// + @Override + public Path getOriginalPath () + // ---------------------------------------------------------------------------------// + { + return disks[currentDisk].getOriginalPath (); + } } \ No newline at end of file diff --git a/src/com/bytezone/diskbrowser/dos/CatalogEntry.java b/src/com/bytezone/diskbrowser/dos/CatalogEntry.java index 0303173..66bca1b 100644 --- a/src/com/bytezone/diskbrowser/dos/CatalogEntry.java +++ b/src/com/bytezone/diskbrowser/dos/CatalogEntry.java @@ -17,7 +17,7 @@ class CatalogEntry extends AbstractCatalogEntry CatalogEntry (DosDisk dosDisk, DiskAddress catalogSector, byte[] entryBuffer) // ---------------------------------------------------------------------------------// { - super (dosDisk, catalogSector, entryBuffer); // build lists of ts and data sectors + super (dosDisk, catalogSector, entryBuffer); // if (reportedSize > 0 && disk.isValidAddress (entryBuffer[0], entryBuffer[1])) if (disk.isValidAddress (entryBuffer[0], entryBuffer[1])) @@ -26,7 +26,7 @@ class CatalogEntry extends AbstractCatalogEntry DiskAddress da = disk.getDiskAddress (entryBuffer[0], entryBuffer[1]); // Loop through all TS-list sectors - loop: while (da.getBlockNo () > 0 || ((AppleDiskAddress) da).zeroFlag ()) + loop: while (!da.isZero () || ((AppleDiskAddress) da).zeroFlag ()) { if (dosDisk.stillAvailable (da)) { @@ -70,7 +70,7 @@ class CatalogEntry extends AbstractCatalogEntry i, sectorBuffer[i], sectorBuffer[i + 1], name.trim ()); break loop; } - if (da.getBlockNo () == 0 && !((AppleDiskAddress) da).zeroFlag ()) + if (da.isZero () && !((AppleDiskAddress) da).zeroFlag ()) { if (fileType != FileType.Text) break; @@ -151,7 +151,8 @@ class CatalogEntry extends AbstractCatalogEntry return false; if (buffer[3] != 0 || buffer[4] != 0) // not supposed to be used // Diags2E.dsk stores its own sector address here - if (da.getTrackNo () != (buffer[3] & 0xFF) && da.getSectorNo () != (buffer[4] & 0xFF)) + if (da.getTrackNo () != (buffer[3] & 0xFF) + && da.getSectorNo () != (buffer[4] & 0xFF)) return false; return true; @@ -175,9 +176,9 @@ class CatalogEntry extends AbstractCatalogEntry if (dataSectors.size () == 0) message += "No data "; - String catName = catalogName.length () >= 8 ? catalogName.substring (7) : catalogName; + // String catName = catalogName.length () >= 8 ? catalogName.substring (7) : catalogName; String text = String.format ("%1s %1s %03d %-30.30s %-5s %-13s %3d %3d %s", - lockedFlag, getFileType (), actualSize, catName, addressText, lengthText, + lockedFlag, getFileType (), actualSize, catalogName, addressText, lengthText, tsSectors.size (), (dataSectors.size () - textFileGaps), message.trim ()); if (actualSize == 0) text = text.substring (0, 50); diff --git a/src/com/bytezone/diskbrowser/dos/DeletedCatalogEntry.java b/src/com/bytezone/diskbrowser/dos/DeletedCatalogEntry.java index 3330039..f69d4a0 100644 --- a/src/com/bytezone/diskbrowser/dos/DeletedCatalogEntry.java +++ b/src/com/bytezone/diskbrowser/dos/DeletedCatalogEntry.java @@ -51,7 +51,7 @@ class DeletedCatalogEntry extends AbstractCatalogEntry } // Loop through all TS-list sectors - loop: while (da.getBlockNo () > 0 || ((AppleDiskAddress) da).zeroFlag ()) + loop: while (!da.isZero () || ((AppleDiskAddress) da).zeroFlag ()) { if (!dosDisk.stillAvailable (da)) { @@ -67,10 +67,10 @@ class DeletedCatalogEntry extends AbstractCatalogEntry da = getValidAddress (sectorBuffer, i); if (da == null) break loop; - if (da.getBlockNo () > 0 && debug) + if (!da.isZero () && debug) System.out.println (da); - if (da.getBlockNo () > 0 || ((AppleDiskAddress) da).zeroFlag ()) + if (!da.isZero () || ((AppleDiskAddress) da).zeroFlag ()) { if (!dosDisk.stillAvailable (da)) { diff --git a/src/com/bytezone/diskbrowser/dos/DosDisk.java b/src/com/bytezone/diskbrowser/dos/DosDisk.java index e62b5fe..2ab3014 100755 --- a/src/com/bytezone/diskbrowser/dos/DosDisk.java +++ b/src/com/bytezone/diskbrowser/dos/DosDisk.java @@ -132,7 +132,7 @@ public class DosDisk extends AbstractFormattedDisk da = disk.getDiskAddress (track, sector); - } while (da.getBlockNo () != 0); + } while (!da.isZero ()); // same loop, but now all the catalog sectors are properly flagged da = disk.getDiskAddress (catalogStart.getBlockNo ()); @@ -149,15 +149,15 @@ public class DosDisk extends AbstractFormattedDisk if (sectorBuffer[ptr] == 0) // empty slot, no more catalog entries continue; - byte[] entry = new byte[ENTRY_SIZE]; - System.arraycopy (sectorBuffer, ptr, entry, 0, ENTRY_SIZE); - int track = entry[0] & 0xFF; - boolean deletedFlag = (entry[0] & 0x80) != 0; + byte[] entryBuffer = new byte[ENTRY_SIZE]; + System.arraycopy (sectorBuffer, ptr, entryBuffer, 0, ENTRY_SIZE); + int track = entryBuffer[0] & 0xFF; + boolean deletedFlag = (entryBuffer[0] & 0x80) != 0; if (deletedFlag) // deleted file { DeletedCatalogEntry deletedCatalogEntry = - new DeletedCatalogEntry (this, da, entry, dosVTOCSector.dosVersion); + new DeletedCatalogEntry (this, da, entryBuffer, dosVTOCSector.dosVersion); deletedFileEntries.add (deletedCatalogEntry); DefaultMutableTreeNode node = new DefaultMutableTreeNode (deletedCatalogEntry); node.setAllowsChildren (false); @@ -165,7 +165,7 @@ public class DosDisk extends AbstractFormattedDisk } else { - CatalogEntry catalogEntry = new CatalogEntry (this, da, entry); + CatalogEntry catalogEntry = new CatalogEntry (this, da, entryBuffer); fileEntries.add (catalogEntry); DefaultMutableTreeNode node = new DefaultMutableTreeNode (catalogEntry); node.setAllowsChildren (false); @@ -186,7 +186,7 @@ public class DosDisk extends AbstractFormattedDisk da = disk.getDiskAddress (sectorBuffer[1], sectorBuffer[2]); - } while (da.getBlockNo () != 0); + } while (!da.isZero ()); // link double hi-res files for (AppleFileSource fe : fileEntries) @@ -426,7 +426,7 @@ public class DosDisk extends AbstractFormattedDisk da = disk.getDiskAddress (buffer[1], buffer[2]); - } while (da.getBlockNo () != 0); + } while (!da.isZero ()); if (debug) System.out.printf ("Catalog blocks: %d%n", catalogAddresses.size ()); @@ -469,7 +469,7 @@ public class DosDisk extends AbstractFormattedDisk SectorType type = sectorTypes[da.getBlockNo ()]; if (type == vtocSector) return dosVTOCSector; - if (da.getBlockNo () == 0) + if (da.isZero ()) return bootSector; byte[] buffer = disk.readBlock (da); diff --git a/src/com/bytezone/diskbrowser/prodos/FileEntry.java b/src/com/bytezone/diskbrowser/prodos/FileEntry.java index 73bb46a..95f13e6 100755 --- a/src/com/bytezone/diskbrowser/prodos/FileEntry.java +++ b/src/com/bytezone/diskbrowser/prodos/FileEntry.java @@ -26,6 +26,7 @@ import com.bytezone.diskbrowser.applefile.OriginalHiResImage; import com.bytezone.diskbrowser.applefile.QuickDrawFont; import com.bytezone.diskbrowser.applefile.SHRPictureFile1; import com.bytezone.diskbrowser.applefile.SHRPictureFile2; +import com.bytezone.diskbrowser.applefile.Selector; import com.bytezone.diskbrowser.applefile.ShapeTable; import com.bytezone.diskbrowser.applefile.SimpleText; import com.bytezone.diskbrowser.applefile.StoredVariables; @@ -268,12 +269,17 @@ class FileEntry extends CatalogEntry implements ProdosConstants { switch (fileType) { - case FILE_TYPE_USER_DEFINED_1: // OVL + case FILE_TYPE_OVL: if (endOfFile == 0x2000 && auxType == 0) { file = new OriginalHiResImage (name, exactBuffer, auxType); break; } + else if (endOfFile == 0x800 && "SELECTOR.LIST".equals (name)) + { + file = new Selector (name, exactBuffer); + break; + } // drop through case FILE_TYPE_BINARY: case FILE_TYPE_RELOCATABLE: diff --git a/src/com/bytezone/diskbrowser/prodos/ProdosConstants.java b/src/com/bytezone/diskbrowser/prodos/ProdosConstants.java index d94f48a..8012473 100755 --- a/src/com/bytezone/diskbrowser/prodos/ProdosConstants.java +++ b/src/com/bytezone/diskbrowser/prodos/ProdosConstants.java @@ -34,7 +34,7 @@ public interface ProdosConstants static int FILE_TYPE_ICN = 0xCA; static int FILE_TYPE_APPLETALK = 0xE2; static int FILE_TYPE_PASCAL_VOLUME = 0xEF; - static int FILE_TYPE_USER_DEFINED_1 = 0xF1; // OVL + static int FILE_TYPE_OVL = 0xF1; static int FILE_TYPE_BAT = 0xF5; static int FILE_TYPE_INTEGER_BASIC = 0xFA; static int FILE_TYPE_INTEGER_BASIC_VARS = 0xFB; diff --git a/src/com/bytezone/diskbrowser/prodos/ProdosDisk.java b/src/com/bytezone/diskbrowser/prodos/ProdosDisk.java index 9676fd1..5dd267f 100755 --- a/src/com/bytezone/diskbrowser/prodos/ProdosDisk.java +++ b/src/com/bytezone/diskbrowser/prodos/ProdosDisk.java @@ -152,12 +152,12 @@ public class ProdosDisk extends AbstractFormattedDisk break; case ProdosConstants.SUBDIRECTORY: - FileEntry ce = new FileEntry (this, entry, localHeader, block); - fileEntries.add (ce); - DefaultMutableTreeNode directoryNode = new DefaultMutableTreeNode (ce); + FileEntry fileEntry = new FileEntry (this, entry, localHeader, block); + fileEntries.add (fileEntry); + DefaultMutableTreeNode directoryNode = new DefaultMutableTreeNode (fileEntry); directoryNode.setAllowsChildren (true); parentNode.add (directoryNode); - processDirectoryBlock (ce.keyPtr, ce, directoryNode); // Recursion !! + processDirectoryBlock (fileEntry.keyPtr, fileEntry, directoryNode); // Recursion!! break; case ProdosConstants.SEEDLING: @@ -165,9 +165,9 @@ public class ProdosDisk extends AbstractFormattedDisk case ProdosConstants.TREE: case ProdosConstants.PASCAL_ON_PROFILE: case ProdosConstants.GSOS_EXTENDED_FILE: - FileEntry fe = new FileEntry (this, entry, localHeader, block); - fileEntries.add (fe); - DefaultMutableTreeNode node = new DefaultMutableTreeNode (fe); + fileEntry = new FileEntry (this, entry, localHeader, block); + fileEntries.add (fileEntry); + DefaultMutableTreeNode node = new DefaultMutableTreeNode (fileEntry); node.setAllowsChildren (false); parentNode.add (node); break; @@ -271,7 +271,7 @@ public class ProdosDisk extends AbstractFormattedDisk public DataSource getFormattedSector (DiskAddress da) // ---------------------------------------------------------------------------------// { - if (da.getBlockNo () == 0) + if (da.isZero ()) return bootSector; byte[] buffer = disk.readBlock (da);