added isZero() and Selector

This commit is contained in:
Denis Molony 2020-05-10 21:28:01 +10:00
parent 0b032b13f5
commit 96c49fc61d
13 changed files with 521 additions and 387 deletions

View File

@ -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<Entry> entries = new ArrayList<> ();
List<Path> 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);
}
}
}

View File

@ -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 ();
// }
}

View File

@ -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 ();

View File

@ -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);

View File

@ -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 ()

View File

@ -10,6 +10,8 @@ public interface DiskAddress extends Comparable<DiskAddress>
public int getSectorNo ();
public boolean isZero ();
public Disk getDisk ();
public boolean matches (DiskAddress other);

View File

@ -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<DiskAddress> getFileSectors (int fileNo)
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getFileSectors (fileNo);
}
// ---------------------------------------------------------------------------------//
@Override
public List<AppleFileSource> 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<SectorType> 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<DiskAddress> getFileSectors (int fileNo)
// ---------------------------------------------------------------------------------//
{
return disks[currentDisk].getFileSectors (fileNo);
}
// ---------------------------------------------------------------------------------//
@Override
public List<AppleFileSource> 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<SectorType> 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 ();
}
}

View File

@ -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);

View File

@ -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))
{

View File

@ -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);

View File

@ -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:

View File

@ -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;

View File

@ -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);