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) if (val == 0xE5)
break; break;
if (val > 31) // && val != 0xE5) if (val > 31)
return false; return false;
for (int j = 1; j <= 8; j++) for (int j = 1; j <= 8; j++)
@ -259,11 +259,11 @@ public class CPMDisk extends AbstractFormattedDisk
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override // @Override
public String toString () // public String toString ()
// ---------------------------------------------------------------------------------// // // ---------------------------------------------------------------------------------//
{ // {
StringBuffer text = new StringBuffer ("CPM disk"); // StringBuffer text = new StringBuffer ("CPM disk");
return text.toString (); // return text.toString ();
} // }
} }

View File

@ -394,7 +394,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
public DataSource getFormattedSector (DiskAddress da) public DataSource getFormattedSector (DiskAddress da)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
if (da.getBlockNo () == 0 && bootSector != null) if (da.isZero () && bootSector != null)
return bootSector; return bootSector;
SectorType sectorType = sectorTypes[da.getBlockNo ()]; SectorType sectorType = sectorTypes[da.getBlockNo ()];
@ -564,6 +564,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (); 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 ("Block size..... %d%n", disk.getBlockSize ()));
text.append (String.format ("Interleave..... %d", disk.getInterleave ())); text.append (String.format ("Interleave..... %d", disk.getInterleave ()));
return text.toString (); return text.toString ();

View File

@ -113,6 +113,7 @@ public class AppleDisk implements Disk
if ("2mg".equalsIgnoreCase (suffix) || "2IMG".equals (prefix)) if ("2mg".equalsIgnoreCase (suffix) || "2IMG".equals (prefix))
{ {
// System.out.println ("checking 2mg");
if ("2IMG".equals (prefix)) if ("2IMG".equals (prefix))
{ {
Prefix2mg prefix2mg = new Prefix2mg (buffer); Prefix2mg prefix2mg = new Prefix2mg (buffer);

View File

@ -66,6 +66,14 @@ public class AppleDiskAddress implements DiskAddress
return this.block == that.getBlockNo (); return this.block == that.getBlockNo ();
} }
// ---------------------------------------------------------------------------------//
@Override
public boolean isZero ()
// ---------------------------------------------------------------------------------//
{
return block == 0;
}
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public int getBlockNo () public int getBlockNo ()

View File

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

View File

@ -1,350 +1,354 @@
package com.bytezone.diskbrowser.disk; package com.bytezone.diskbrowser.disk;
import java.awt.Dimension; import java.awt.Dimension;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List; import java.util.List;
import javax.swing.JTree; import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultTreeModel;
import com.bytezone.diskbrowser.applefile.AbstractFile; import com.bytezone.diskbrowser.applefile.AbstractFile;
import com.bytezone.diskbrowser.applefile.AppleFileSource; import com.bytezone.diskbrowser.applefile.AppleFileSource;
import com.bytezone.diskbrowser.gui.DataSource; import com.bytezone.diskbrowser.gui.DataSource;
// Apple Assembly Lines disks are dual-dos // Apple Assembly Lines disks are dual-dos
// Should be renamed MultiVolumeDisk (and allow >2 volumes) // Should be renamed MultiVolumeDisk (and allow >2 volumes)
// -----------------------------------------------------------------------------------// // -----------------------------------------------------------------------------------//
public class DualDosDisk implements FormattedDisk public class DualDosDisk implements FormattedDisk
// -----------------------------------------------------------------------------------// // -----------------------------------------------------------------------------------//
{ {
private final FormattedDisk[] disks = new FormattedDisk[2]; private final FormattedDisk[] disks = new FormattedDisk[2];
private int currentDisk; private int currentDisk;
private final JTree tree; private final JTree tree;
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
public DualDosDisk (FormattedDisk disk0, FormattedDisk disk1) public DualDosDisk (FormattedDisk disk0, FormattedDisk disk1)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
assert disk0 != disk1; assert disk0 != disk1;
String diskName = disk0.getDisk ().getFile ().getName (); String diskName = disk0.getDisk ().getFile ().getName ();
String text = "This disk contains files from DOS and another OS\n\n" String text = "This disk contains files from DOS and another OS\n\n"
+ disk0.getDisk () + "\n\n" + disk1.getDisk (); + disk0.getDisk () + "\n\n" + disk1.getDisk ();
DefaultAppleFileSource dafs = new DefaultAppleFileSource (diskName, text, this); DefaultAppleFileSource dafs = new DefaultAppleFileSource (diskName, text, this);
DefaultMutableTreeNode root = new DefaultMutableTreeNode (dafs); DefaultMutableTreeNode root = new DefaultMutableTreeNode (dafs);
DefaultTreeModel treeModel = new DefaultTreeModel (root); DefaultTreeModel treeModel = new DefaultTreeModel (root);
tree = new JTree (treeModel); tree = new JTree (treeModel);
// allow empty nodes to appear as folders // allow empty nodes to appear as folders
treeModel.setAsksAllowsChildren (true); treeModel.setAsksAllowsChildren (true);
disks[0] = disk0; disks[0] = disk0;
disks[1] = disk1; disks[1] = disk1;
disk0.setParent (this); disk0.setParent (this);
disk1.setParent (this); disk1.setParent (this);
DefaultMutableTreeNode root0 = DefaultMutableTreeNode root0 =
(DefaultMutableTreeNode) disk0.getCatalogTree ().getModel ().getRoot (); (DefaultMutableTreeNode) disk0.getCatalogTree ().getModel ().getRoot ();
DefaultMutableTreeNode root1 = DefaultMutableTreeNode root1 =
(DefaultMutableTreeNode) disk1.getCatalogTree ().getModel ().getRoot (); (DefaultMutableTreeNode) disk1.getCatalogTree ().getModel ().getRoot ();
root.add ((DefaultMutableTreeNode) root0.getChildAt (0)); root.add ((DefaultMutableTreeNode) root0.getChildAt (0));
root.add ((DefaultMutableTreeNode) root1.getChildAt (0)); root.add ((DefaultMutableTreeNode) root1.getChildAt (0));
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public JTree getCatalogTree () public JTree getCatalogTree ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return tree; return tree;
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public List<DiskAddress> getFileSectors (int fileNo) public List<DiskAddress> getFileSectors (int fileNo)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return disks[currentDisk].getFileSectors (fileNo); return disks[currentDisk].getFileSectors (fileNo);
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public List<AppleFileSource> getCatalogList () public List<AppleFileSource> getCatalogList ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return disks[currentDisk].getCatalogList (); return disks[currentDisk].getCatalogList ();
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public DataSource getFormattedSector (DiskAddress da) public DataSource getFormattedSector (DiskAddress da)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return disks[currentDisk].getFormattedSector (da); return disks[currentDisk].getFormattedSector (da);
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public SectorType getSectorType (DiskAddress da) public SectorType getSectorType (DiskAddress da)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return disks[currentDisk].getSectorType (da); return disks[currentDisk].getSectorType (da);
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public SectorType getSectorType (int track, int sector) public SectorType getSectorType (int track, int sector)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return disks[currentDisk].getSectorType (track, sector); return disks[currentDisk].getSectorType (track, sector);
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public SectorType getSectorType (int block) public SectorType getSectorType (int block)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return disks[currentDisk].getSectorType (block); return disks[currentDisk].getSectorType (block);
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public List<SectorType> getSectorTypeList () public List<SectorType> getSectorTypeList ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return disks[currentDisk].getSectorTypeList (); return disks[currentDisk].getSectorTypeList ();
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public Disk getDisk () public Disk getDisk ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return disks[currentDisk].getDisk (); return disks[currentDisk].getDisk ();
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
public void setCurrentDisk (FormattedDisk fd) public void setCurrentDisk (FormattedDisk fd)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
if (disks[0] == fd) if (disks[0] == fd)
currentDisk = 0; currentDisk = 0;
else if (disks[1] == fd) else if (disks[1] == fd)
currentDisk = 1; currentDisk = 1;
else else
System.out.println ("Disk not found: " + fd); {
} // 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 void setCurrentDiskNo (int n)
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
public int getCurrentDiskNo () currentDisk = n;
// ---------------------------------------------------------------------------------// }
{
return currentDisk; // ---------------------------------------------------------------------------------//
} public int getCurrentDiskNo ()
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
public FormattedDisk getCurrentDisk () return currentDisk;
// ---------------------------------------------------------------------------------// }
{
return disks[currentDisk]; // ---------------------------------------------------------------------------------//
} public FormattedDisk getCurrentDisk ()
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override return disks[currentDisk];
public void writeFile (AbstractFile file) }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
disks[currentDisk].writeFile (file); @Override
} public void writeFile (AbstractFile file)
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override disks[currentDisk].writeFile (file);
public AppleFileSource getCatalog () }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
return new DefaultAppleFileSource ("text", @Override
disks[0].getCatalog ().getDataSource ().getText () + "\n\n" public AppleFileSource getCatalog ()
+ disks[1].getCatalog ().getDataSource ().getText (), // ---------------------------------------------------------------------------------//
this); {
} return new DefaultAppleFileSource ("text",
disks[0].getCatalog ().getDataSource ().getText () + "\n\n"
// ---------------------------------------------------------------------------------// + disks[1].getCatalog ().getDataSource ().getText (),
@Override this);
public AppleFileSource getFile (String uniqueName) }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
return disks[currentDisk].getFile (uniqueName); @Override
} public AppleFileSource getFile (String uniqueName)
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override return disks[currentDisk].getFile (uniqueName);
public int clearOrphans () }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
return disks[currentDisk].clearOrphans (); @Override
} public int clearOrphans ()
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override return disks[currentDisk].clearOrphans ();
public boolean isSectorFree (DiskAddress da) }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
return disks[currentDisk].isSectorFree (da); @Override
} public boolean isSectorFree (DiskAddress da)
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override return disks[currentDisk].isSectorFree (da);
public void verify () }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
disks[currentDisk].verify (); @Override
} public void verify ()
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override disks[currentDisk].verify ();
public boolean stillAvailable (DiskAddress da) }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
return disks[currentDisk].stillAvailable (da); @Override
} public boolean stillAvailable (DiskAddress da)
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override return disks[currentDisk].stillAvailable (da);
public void setSectorType (int block, SectorType type) }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
disks[currentDisk].setSectorType (block, type); @Override
} public void setSectorType (int block, SectorType type)
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override disks[currentDisk].setSectorType (block, type);
public void setSectorFree (int block, boolean free) }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
disks[currentDisk].setSectorFree (block, free); @Override
} public void setSectorFree (int block, boolean free)
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override disks[currentDisk].setSectorFree (block, free);
public int falseNegativeBlocks () }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
return disks[currentDisk].falseNegativeBlocks (); @Override
} public int falseNegativeBlocks ()
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override return disks[currentDisk].falseNegativeBlocks ();
public int falsePositiveBlocks () }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
return disks[currentDisk].falsePositiveBlocks (); @Override
} public int falsePositiveBlocks ()
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override return disks[currentDisk].falsePositiveBlocks ();
public Dimension getGridLayout () }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
return disks[currentDisk].getGridLayout (); @Override
} public Dimension getGridLayout ()
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override return disks[currentDisk].getGridLayout ();
public boolean isSectorFree (int block) }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
return disks[currentDisk].isSectorFree (block); @Override
} public boolean isSectorFree (int block)
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override return disks[currentDisk].isSectorFree (block);
public boolean stillAvailable (int block) }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
return disks[currentDisk].stillAvailable (block); @Override
} public boolean stillAvailable (int block)
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override return disks[currentDisk].stillAvailable (block);
public void setOriginalPath (Path path) }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
disks[currentDisk].setOriginalPath (path); @Override
} public void setOriginalPath (Path path)
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override disks[currentDisk].setOriginalPath (path);
public String getAbsolutePath () }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
return disks[currentDisk].getAbsolutePath (); @Override
} public String getAbsolutePath ()
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override return disks[currentDisk].getAbsolutePath ();
public String getDisplayPath () }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
return disks[currentDisk].getDisplayPath (); @Override
} public String getDisplayPath ()
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override return disks[currentDisk].getDisplayPath ();
public FormattedDisk getParent () }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
return disks[currentDisk].getParent (); @Override
} public FormattedDisk getParent ()
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override return disks[currentDisk].getParent ();
public void setParent (FormattedDisk disk) }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
disks[currentDisk].setParent (disk); @Override
} public void setParent (FormattedDisk disk)
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override disks[currentDisk].setParent (disk);
public String getSectorFilename (DiskAddress da) }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
return disks[currentDisk].getSectorFilename (da); @Override
} public String getSectorFilename (DiskAddress da)
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override return disks[currentDisk].getSectorFilename (da);
public String getName () }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
return disks[currentDisk].getName (); @Override
} public String getName ()
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override return disks[currentDisk].getName ();
public boolean isTempDisk () }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
return disks[currentDisk].isTempDisk (); @Override
} public boolean isTempDisk ()
// ---------------------------------------------------------------------------------//
// ---------------------------------------------------------------------------------// {
@Override return disks[currentDisk].isTempDisk ();
public Path getOriginalPath () }
// ---------------------------------------------------------------------------------//
{ // ---------------------------------------------------------------------------------//
return disks[currentDisk].getOriginalPath (); @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) 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 (reportedSize > 0 && disk.isValidAddress (entryBuffer[0], entryBuffer[1]))
if (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]); DiskAddress da = disk.getDiskAddress (entryBuffer[0], entryBuffer[1]);
// Loop through all TS-list sectors // 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)) if (dosDisk.stillAvailable (da))
{ {
@ -70,7 +70,7 @@ class CatalogEntry extends AbstractCatalogEntry
i, sectorBuffer[i], sectorBuffer[i + 1], name.trim ()); i, sectorBuffer[i], sectorBuffer[i + 1], name.trim ());
break loop; break loop;
} }
if (da.getBlockNo () == 0 && !((AppleDiskAddress) da).zeroFlag ()) if (da.isZero () && !((AppleDiskAddress) da).zeroFlag ())
{ {
if (fileType != FileType.Text) if (fileType != FileType.Text)
break; break;
@ -151,7 +151,8 @@ class CatalogEntry extends AbstractCatalogEntry
return false; return false;
if (buffer[3] != 0 || buffer[4] != 0) // not supposed to be used if (buffer[3] != 0 || buffer[4] != 0) // not supposed to be used
// Diags2E.dsk stores its own sector address here // 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 false;
return true; return true;
@ -175,9 +176,9 @@ class CatalogEntry extends AbstractCatalogEntry
if (dataSectors.size () == 0) if (dataSectors.size () == 0)
message += "No data "; 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", 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 ()); tsSectors.size (), (dataSectors.size () - textFileGaps), message.trim ());
if (actualSize == 0) if (actualSize == 0)
text = text.substring (0, 50); text = text.substring (0, 50);

View File

@ -51,7 +51,7 @@ class DeletedCatalogEntry extends AbstractCatalogEntry
} }
// Loop through all TS-list sectors // 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)) if (!dosDisk.stillAvailable (da))
{ {
@ -67,10 +67,10 @@ class DeletedCatalogEntry extends AbstractCatalogEntry
da = getValidAddress (sectorBuffer, i); da = getValidAddress (sectorBuffer, i);
if (da == null) if (da == null)
break loop; break loop;
if (da.getBlockNo () > 0 && debug) if (!da.isZero () && debug)
System.out.println (da); System.out.println (da);
if (da.getBlockNo () > 0 || ((AppleDiskAddress) da).zeroFlag ()) if (!da.isZero () || ((AppleDiskAddress) da).zeroFlag ())
{ {
if (!dosDisk.stillAvailable (da)) if (!dosDisk.stillAvailable (da))
{ {

View File

@ -132,7 +132,7 @@ public class DosDisk extends AbstractFormattedDisk
da = disk.getDiskAddress (track, sector); da = disk.getDiskAddress (track, sector);
} while (da.getBlockNo () != 0); } while (!da.isZero ());
// same loop, but now all the catalog sectors are properly flagged // same loop, but now all the catalog sectors are properly flagged
da = disk.getDiskAddress (catalogStart.getBlockNo ()); da = disk.getDiskAddress (catalogStart.getBlockNo ());
@ -149,15 +149,15 @@ public class DosDisk extends AbstractFormattedDisk
if (sectorBuffer[ptr] == 0) // empty slot, no more catalog entries if (sectorBuffer[ptr] == 0) // empty slot, no more catalog entries
continue; continue;
byte[] entry = new byte[ENTRY_SIZE]; byte[] entryBuffer = new byte[ENTRY_SIZE];
System.arraycopy (sectorBuffer, ptr, entry, 0, ENTRY_SIZE); System.arraycopy (sectorBuffer, ptr, entryBuffer, 0, ENTRY_SIZE);
int track = entry[0] & 0xFF; int track = entryBuffer[0] & 0xFF;
boolean deletedFlag = (entry[0] & 0x80) != 0; boolean deletedFlag = (entryBuffer[0] & 0x80) != 0;
if (deletedFlag) // deleted file if (deletedFlag) // deleted file
{ {
DeletedCatalogEntry deletedCatalogEntry = DeletedCatalogEntry deletedCatalogEntry =
new DeletedCatalogEntry (this, da, entry, dosVTOCSector.dosVersion); new DeletedCatalogEntry (this, da, entryBuffer, dosVTOCSector.dosVersion);
deletedFileEntries.add (deletedCatalogEntry); deletedFileEntries.add (deletedCatalogEntry);
DefaultMutableTreeNode node = new DefaultMutableTreeNode (deletedCatalogEntry); DefaultMutableTreeNode node = new DefaultMutableTreeNode (deletedCatalogEntry);
node.setAllowsChildren (false); node.setAllowsChildren (false);
@ -165,7 +165,7 @@ public class DosDisk extends AbstractFormattedDisk
} }
else else
{ {
CatalogEntry catalogEntry = new CatalogEntry (this, da, entry); CatalogEntry catalogEntry = new CatalogEntry (this, da, entryBuffer);
fileEntries.add (catalogEntry); fileEntries.add (catalogEntry);
DefaultMutableTreeNode node = new DefaultMutableTreeNode (catalogEntry); DefaultMutableTreeNode node = new DefaultMutableTreeNode (catalogEntry);
node.setAllowsChildren (false); node.setAllowsChildren (false);
@ -186,7 +186,7 @@ public class DosDisk extends AbstractFormattedDisk
da = disk.getDiskAddress (sectorBuffer[1], sectorBuffer[2]); da = disk.getDiskAddress (sectorBuffer[1], sectorBuffer[2]);
} while (da.getBlockNo () != 0); } while (!da.isZero ());
// link double hi-res files // link double hi-res files
for (AppleFileSource fe : fileEntries) for (AppleFileSource fe : fileEntries)
@ -426,7 +426,7 @@ public class DosDisk extends AbstractFormattedDisk
da = disk.getDiskAddress (buffer[1], buffer[2]); da = disk.getDiskAddress (buffer[1], buffer[2]);
} while (da.getBlockNo () != 0); } while (!da.isZero ());
if (debug) if (debug)
System.out.printf ("Catalog blocks: %d%n", catalogAddresses.size ()); System.out.printf ("Catalog blocks: %d%n", catalogAddresses.size ());
@ -469,7 +469,7 @@ public class DosDisk extends AbstractFormattedDisk
SectorType type = sectorTypes[da.getBlockNo ()]; SectorType type = sectorTypes[da.getBlockNo ()];
if (type == vtocSector) if (type == vtocSector)
return dosVTOCSector; return dosVTOCSector;
if (da.getBlockNo () == 0) if (da.isZero ())
return bootSector; return bootSector;
byte[] buffer = disk.readBlock (da); 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.QuickDrawFont;
import com.bytezone.diskbrowser.applefile.SHRPictureFile1; import com.bytezone.diskbrowser.applefile.SHRPictureFile1;
import com.bytezone.diskbrowser.applefile.SHRPictureFile2; import com.bytezone.diskbrowser.applefile.SHRPictureFile2;
import com.bytezone.diskbrowser.applefile.Selector;
import com.bytezone.diskbrowser.applefile.ShapeTable; import com.bytezone.diskbrowser.applefile.ShapeTable;
import com.bytezone.diskbrowser.applefile.SimpleText; import com.bytezone.diskbrowser.applefile.SimpleText;
import com.bytezone.diskbrowser.applefile.StoredVariables; import com.bytezone.diskbrowser.applefile.StoredVariables;
@ -268,12 +269,17 @@ class FileEntry extends CatalogEntry implements ProdosConstants
{ {
switch (fileType) switch (fileType)
{ {
case FILE_TYPE_USER_DEFINED_1: // OVL case FILE_TYPE_OVL:
if (endOfFile == 0x2000 && auxType == 0) if (endOfFile == 0x2000 && auxType == 0)
{ {
file = new OriginalHiResImage (name, exactBuffer, auxType); file = new OriginalHiResImage (name, exactBuffer, auxType);
break; break;
} }
else if (endOfFile == 0x800 && "SELECTOR.LIST".equals (name))
{
file = new Selector (name, exactBuffer);
break;
}
// drop through // drop through
case FILE_TYPE_BINARY: case FILE_TYPE_BINARY:
case FILE_TYPE_RELOCATABLE: case FILE_TYPE_RELOCATABLE:

View File

@ -34,7 +34,7 @@ public interface ProdosConstants
static int FILE_TYPE_ICN = 0xCA; static int FILE_TYPE_ICN = 0xCA;
static int FILE_TYPE_APPLETALK = 0xE2; static int FILE_TYPE_APPLETALK = 0xE2;
static int FILE_TYPE_PASCAL_VOLUME = 0xEF; 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_BAT = 0xF5;
static int FILE_TYPE_INTEGER_BASIC = 0xFA; static int FILE_TYPE_INTEGER_BASIC = 0xFA;
static int FILE_TYPE_INTEGER_BASIC_VARS = 0xFB; static int FILE_TYPE_INTEGER_BASIC_VARS = 0xFB;

View File

@ -152,12 +152,12 @@ public class ProdosDisk extends AbstractFormattedDisk
break; break;
case ProdosConstants.SUBDIRECTORY: case ProdosConstants.SUBDIRECTORY:
FileEntry ce = new FileEntry (this, entry, localHeader, block); FileEntry fileEntry = new FileEntry (this, entry, localHeader, block);
fileEntries.add (ce); fileEntries.add (fileEntry);
DefaultMutableTreeNode directoryNode = new DefaultMutableTreeNode (ce); DefaultMutableTreeNode directoryNode = new DefaultMutableTreeNode (fileEntry);
directoryNode.setAllowsChildren (true); directoryNode.setAllowsChildren (true);
parentNode.add (directoryNode); parentNode.add (directoryNode);
processDirectoryBlock (ce.keyPtr, ce, directoryNode); // Recursion !! processDirectoryBlock (fileEntry.keyPtr, fileEntry, directoryNode); // Recursion!!
break; break;
case ProdosConstants.SEEDLING: case ProdosConstants.SEEDLING:
@ -165,9 +165,9 @@ public class ProdosDisk extends AbstractFormattedDisk
case ProdosConstants.TREE: case ProdosConstants.TREE:
case ProdosConstants.PASCAL_ON_PROFILE: case ProdosConstants.PASCAL_ON_PROFILE:
case ProdosConstants.GSOS_EXTENDED_FILE: case ProdosConstants.GSOS_EXTENDED_FILE:
FileEntry fe = new FileEntry (this, entry, localHeader, block); fileEntry = new FileEntry (this, entry, localHeader, block);
fileEntries.add (fe); fileEntries.add (fileEntry);
DefaultMutableTreeNode node = new DefaultMutableTreeNode (fe); DefaultMutableTreeNode node = new DefaultMutableTreeNode (fileEntry);
node.setAllowsChildren (false); node.setAllowsChildren (false);
parentNode.add (node); parentNode.add (node);
break; break;
@ -271,7 +271,7 @@ public class ProdosDisk extends AbstractFormattedDisk
public DataSource getFormattedSector (DiskAddress da) public DataSource getFormattedSector (DiskAddress da)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
if (da.getBlockNo () == 0) if (da.isZero ())
return bootSector; return bootSector;
byte[] buffer = disk.readBlock (da); byte[] buffer = disk.readBlock (da);