mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-29 11:49:29 +00:00
method header lines
This commit is contained in:
parent
4788f4bca4
commit
04557bab39
@ -4,17 +4,23 @@ import com.bytezone.diskbrowser.disk.AbstractSector;
|
|||||||
import com.bytezone.diskbrowser.disk.Disk;
|
import com.bytezone.diskbrowser.disk.Disk;
|
||||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||||
|
|
||||||
public class CPMCatalogSector extends AbstractSector
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class CPMCatalogSector extends AbstractSector
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static int CATALOG_ENTRY_SIZE = 32;
|
private static int CATALOG_ENTRY_SIZE = 32;
|
||||||
|
|
||||||
public CPMCatalogSector (Disk disk, byte[] buffer, DiskAddress diskAddress)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
CPMCatalogSector (Disk disk, byte[] buffer, DiskAddress diskAddress)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (disk, buffer, diskAddress);
|
super (disk, buffer, diskAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String createText ()
|
public String createText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder text = getHeader ("Catalog Sector");
|
StringBuilder text = getHeader ("Catalog Sector");
|
||||||
|
|
||||||
|
@ -6,10 +6,17 @@ import java.util.List;
|
|||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
||||||
import com.bytezone.diskbrowser.disk.*;
|
import com.bytezone.diskbrowser.disk.AbstractFormattedDisk;
|
||||||
|
import com.bytezone.diskbrowser.disk.AppleDisk;
|
||||||
|
import com.bytezone.diskbrowser.disk.DefaultAppleFileSource;
|
||||||
|
import com.bytezone.diskbrowser.disk.Disk;
|
||||||
|
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||||
|
import com.bytezone.diskbrowser.disk.SectorType;
|
||||||
import com.bytezone.diskbrowser.gui.DataSource;
|
import com.bytezone.diskbrowser.gui.DataSource;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class CPMDisk extends AbstractFormattedDisk
|
public class CPMDisk extends AbstractFormattedDisk
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final Color green = new Color (0, 200, 0);
|
private final Color green = new Color (0, 200, 0);
|
||||||
|
|
||||||
@ -27,7 +34,9 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||||||
// // http://www.seasip.info/Cpm/format31.html
|
// // http://www.seasip.info/Cpm/format31.html
|
||||||
private final DefaultMutableTreeNode volumeNode;
|
private final DefaultMutableTreeNode volumeNode;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public CPMDisk (Disk disk)
|
public CPMDisk (Disk disk)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (disk);
|
super (disk);
|
||||||
|
|
||||||
@ -109,7 +118,9 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||||||
makeNodeVisible (volumeNode.getFirstLeaf ());
|
makeNodeVisible (volumeNode.getFirstLeaf ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private SectorType getSectorType (String type)
|
private SectorType getSectorType (String type)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if ("COM".equals (type))
|
if ("COM".equals (type))
|
||||||
return comSector;
|
return comSector;
|
||||||
@ -129,15 +140,19 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||||||
return otherSector;
|
return otherSector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public List<DiskAddress> getFileSectors (int fileNo)
|
public List<DiskAddress> getFileSectors (int fileNo)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (fileEntries.size () > 0 && fileEntries.size () > fileNo)
|
if (fileEntries.size () > 0 && fileEntries.size () > fileNo)
|
||||||
return fileEntries.get (fileNo).getSectors ();
|
return fileEntries.get (fileNo).getSectors ();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private DirectoryEntry findParent (DirectoryEntry child)
|
private DirectoryEntry findParent (DirectoryEntry child)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
for (AppleFileSource entry : fileEntries)
|
for (AppleFileSource entry : fileEntries)
|
||||||
if (((DirectoryEntry) entry).matches (child))
|
if (((DirectoryEntry) entry).matches (child))
|
||||||
@ -146,8 +161,10 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public DataSource getFormattedSector (DiskAddress da)
|
public DataSource getFormattedSector (DiskAddress da)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
SectorType type = sectorTypes[da.getBlock ()];
|
SectorType type = sectorTypes[da.getBlock ()];
|
||||||
byte[] buffer = disk.readSector (da);
|
byte[] buffer = disk.readSector (da);
|
||||||
@ -158,8 +175,10 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||||||
return super.getFormattedSector (da);
|
return super.getFormattedSector (da);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public AppleFileSource getCatalog ()
|
public AppleFileSource getCatalog ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
String newLine = String.format ("%n");
|
String newLine = String.format ("%n");
|
||||||
String line =
|
String line =
|
||||||
@ -182,7 +201,9 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||||||
return new DefaultAppleFileSource ("CPM Disk ", text.toString (), this);
|
return new DefaultAppleFileSource ("CPM Disk ", text.toString (), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public static boolean isCorrectFormat (AppleDisk disk)
|
public static boolean isCorrectFormat (AppleDisk disk)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
disk.setInterleave (3);
|
disk.setInterleave (3);
|
||||||
|
|
||||||
@ -227,7 +248,9 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private static boolean bufferContainsAll (byte[] buffer, byte value)
|
private static boolean bufferContainsAll (byte[] buffer, byte value)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
for (byte b : buffer)
|
for (byte b : buffer)
|
||||||
if (b != value)
|
if (b != value)
|
||||||
@ -235,8 +258,10 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@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 ();
|
||||||
|
@ -14,7 +14,9 @@ import com.bytezone.diskbrowser.gui.DataSource;
|
|||||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
|
|
||||||
// File Control Block (FCB)
|
// File Control Block (FCB)
|
||||||
public class DirectoryEntry implements AppleFileSource
|
// -----------------------------------------------------------------------------------//
|
||||||
|
class DirectoryEntry implements AppleFileSource
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final Disk disk;
|
private final Disk disk;
|
||||||
private final CPMDisk parent;
|
private final CPMDisk parent;
|
||||||
@ -34,7 +36,9 @@ public class DirectoryEntry implements AppleFileSource
|
|||||||
private final boolean readOnly;
|
private final boolean readOnly;
|
||||||
private final boolean systemFile;
|
private final boolean systemFile;
|
||||||
|
|
||||||
public DirectoryEntry (CPMDisk parent, byte[] buffer, int offset)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
DirectoryEntry (CPMDisk parent, byte[] buffer, int offset)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
disk = parent.getDisk ();
|
disk = parent.getDisk ();
|
||||||
@ -75,18 +79,24 @@ public class DirectoryEntry implements AppleFileSource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType ()
|
// ---------------------------------------------------------------------------------//
|
||||||
|
String getType ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matches (DirectoryEntry directoryEntry)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
boolean matches (DirectoryEntry directoryEntry)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return userNumber == directoryEntry.userNumber && name.equals (directoryEntry.name)
|
return userNumber == directoryEntry.userNumber && name.equals (directoryEntry.name)
|
||||||
&& type.equals (directoryEntry.type);
|
&& type.equals (directoryEntry.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add (DirectoryEntry entry)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
void add (DirectoryEntry entry)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
entries.add (entry);
|
entries.add (entry);
|
||||||
|
|
||||||
@ -102,8 +112,10 @@ public class DirectoryEntry implements AppleFileSource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean contains (DiskAddress da)
|
public boolean contains (DiskAddress da)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
for (DiskAddress sector : blocks)
|
for (DiskAddress sector : blocks)
|
||||||
if (sector.matches (da))
|
if (sector.matches (da))
|
||||||
@ -111,7 +123,9 @@ public class DirectoryEntry implements AppleFileSource
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String line ()
|
// ---------------------------------------------------------------------------------//
|
||||||
|
String line ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
String bytes = HexFormatter.getHexString (blockList, 0, 16);
|
String bytes = HexFormatter.getHexString (blockList, 0, 16);
|
||||||
bytes = bytes.replaceAll ("00", " ");
|
bytes = bytes.replaceAll ("00", " ");
|
||||||
@ -131,7 +145,9 @@ public class DirectoryEntry implements AppleFileSource
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toDetailedString ()
|
// ---------------------------------------------------------------------------------//
|
||||||
|
String toDetailedString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
@ -156,14 +172,18 @@ public class DirectoryEntry implements AppleFileSource
|
|||||||
return text.toString ();
|
return text.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getUniqueName ()
|
public String getUniqueName ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return name + "." + type;
|
return name + "." + type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public DataSource getDataSource ()
|
public DataSource getDataSource ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (appleFile != null)
|
if (appleFile != null)
|
||||||
return appleFile;
|
return appleFile;
|
||||||
@ -208,20 +228,26 @@ public class DirectoryEntry implements AppleFileSource
|
|||||||
return appleFile;
|
return appleFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public List<DiskAddress> getSectors ()
|
public List<DiskAddress> getSectors ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return blocks;
|
return blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public FormattedDisk getFormattedDisk ()
|
public FormattedDisk getFormattedDisk ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return name + "." + type;
|
return name + "." + type;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,9 @@ import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
|||||||
import com.bytezone.diskbrowser.applefile.BootSector;
|
import com.bytezone.diskbrowser.applefile.BootSector;
|
||||||
import com.bytezone.diskbrowser.gui.DataSource;
|
import com.bytezone.diskbrowser.gui.DataSource;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public abstract class AbstractFormattedDisk implements FormattedDisk
|
public abstract class AbstractFormattedDisk implements FormattedDisk
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
protected Disk disk;
|
protected Disk disk;
|
||||||
protected FormattedDisk parent; // used by Dual-dos disks
|
protected FormattedDisk parent; // used by Dual-dos disks
|
||||||
@ -49,7 +51,9 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
protected BitSet freeBlocks;
|
protected BitSet freeBlocks;
|
||||||
protected BitSet usedBlocks; // still to be populated - currently using stillAvailable ()
|
protected BitSet usedBlocks; // still to be populated - currently using stillAvailable ()
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public AbstractFormattedDisk (Disk disk)
|
public AbstractFormattedDisk (Disk disk)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.disk = disk;
|
this.disk = disk;
|
||||||
freeBlocks = new BitSet (disk.getTotalBlocks ());
|
freeBlocks = new BitSet (disk.getTotalBlocks ());
|
||||||
@ -94,13 +98,17 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
protected void setEmptyByte (byte value)
|
protected void setEmptyByte (byte value)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
getDisk ().setEmptyByte (value);
|
getDisk ().setEmptyByte (value);
|
||||||
setSectorTypes ();
|
setSectorTypes ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void setSectorTypes ()
|
private void setSectorTypes ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
sectorTypes = new SectorType[disk.getTotalBlocks ()];
|
sectorTypes = new SectorType[disk.getTotalBlocks ()];
|
||||||
|
|
||||||
@ -110,7 +118,9 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
setGridLayout ();
|
setGridLayout ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void setGridLayout ()
|
private void setGridLayout ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
int totalBlocks = disk.getTotalBlocks ();
|
int totalBlocks = disk.getTotalBlocks ();
|
||||||
|
|
||||||
@ -156,32 +166,42 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public Dimension getGridLayout ()
|
public Dimension getGridLayout ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return gridLayout;
|
return gridLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public Disk getDisk ()
|
public Disk getDisk ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return disk;
|
return disk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public FormattedDisk getParent ()
|
public FormattedDisk getParent ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void setParent (FormattedDisk disk)
|
public void setParent (FormattedDisk disk)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
parent = disk;
|
parent = disk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void setOriginalPath (Path path)
|
public void setOriginalPath (Path path)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.originalPath = path;
|
this.originalPath = path;
|
||||||
|
|
||||||
@ -191,14 +211,18 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
new DefaultAppleFileSource (getName (), disk.toString (), this));
|
new DefaultAppleFileSource (getName (), disk.toString (), this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public Path getOriginalPath ()
|
public Path getOriginalPath ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return originalPath;
|
return originalPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getAbsolutePath ()
|
public String getAbsolutePath ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (originalPath != null)
|
if (originalPath != null)
|
||||||
return originalPath.toString ();
|
return originalPath.toString ();
|
||||||
@ -206,8 +230,10 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
return disk.getFile ().getAbsolutePath ();
|
return disk.getFile ().getAbsolutePath ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getDisplayPath ()
|
public String getDisplayPath ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (originalPath != null)
|
if (originalPath != null)
|
||||||
return originalPath.toString ();
|
return originalPath.toString ();
|
||||||
@ -220,14 +246,18 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
return disk.getFile ().getAbsolutePath ();
|
return disk.getFile ().getAbsolutePath ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean isTempDisk ()
|
public boolean isTempDisk ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return originalPath != null;
|
return originalPath != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getName ()
|
public String getName ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (originalPath != null)
|
if (originalPath != null)
|
||||||
{
|
{
|
||||||
@ -238,20 +268,26 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
return disk.getFile ().getName ();
|
return disk.getFile ().getName ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void writeFile (AbstractFile file)
|
public void writeFile (AbstractFile file)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
System.out.println ("not implemented yet");
|
System.out.println ("not implemented yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public List<AppleFileSource> getCatalogList ()
|
public List<AppleFileSource> getCatalogList ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return fileEntries;
|
return fileEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public AppleFileSource getFile (String uniqueName)
|
public AppleFileSource getFile (String uniqueName)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
for (AppleFileSource afs : fileEntries)
|
for (AppleFileSource afs : fileEntries)
|
||||||
if (afs.getUniqueName ().equals (uniqueName))
|
if (afs.getUniqueName ().equals (uniqueName))
|
||||||
@ -259,24 +295,32 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public JTree getCatalogTree ()
|
public JTree getCatalogTree ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return catalogTree;
|
return catalogTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DefaultMutableTreeNode getCatalogTreeRoot ()
|
public DefaultMutableTreeNode getCatalogTreeRoot ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return (DefaultMutableTreeNode) catalogTree.getModel ().getRoot ();
|
return (DefaultMutableTreeNode) catalogTree.getModel ().getRoot ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void makeNodeVisible (DefaultMutableTreeNode node)
|
public void makeNodeVisible (DefaultMutableTreeNode node)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
catalogTree.makeVisible (
|
catalogTree.makeVisible (
|
||||||
new TreePath (((DefaultTreeModel) catalogTree.getModel ()).getPathToRoot (node)));
|
new TreePath (((DefaultTreeModel) catalogTree.getModel ()).getPathToRoot (node)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
protected DefaultMutableTreeNode findNode (DefaultMutableTreeNode node, String name)
|
protected DefaultMutableTreeNode findNode (DefaultMutableTreeNode node, String name)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
Enumeration<TreeNode> children = node.breadthFirstEnumeration ();
|
Enumeration<TreeNode> children = node.breadthFirstEnumeration ();
|
||||||
if (children != null)
|
if (children != null)
|
||||||
@ -292,36 +336,47 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These routines just hand back the information that was created above, and
|
* These routines just hand back the information that was created above, and
|
||||||
* added to by the subclass.
|
* added to by the subclass.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SectorType getSectorType (int block)
|
public SectorType getSectorType (int block)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return getSectorType (disk.getDiskAddress (block));
|
return getSectorType (disk.getDiskAddress (block));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public SectorType getSectorType (int track, int sector)
|
public SectorType getSectorType (int track, int sector)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return getSectorType (disk.getDiskAddress (track, sector));
|
return getSectorType (disk.getDiskAddress (track, sector));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public SectorType getSectorType (DiskAddress da)
|
public SectorType getSectorType (DiskAddress da)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return sectorTypes[da.getBlock ()];
|
return sectorTypes[da.getBlock ()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public List<SectorType> getSectorTypeList ()
|
public List<SectorType> getSectorTypeList ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return sectorTypesList;
|
return sectorTypesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void setSectorType (int block, SectorType type)
|
public void setSectorType (int block, SectorType type)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (block < sectorTypes.length)
|
if (block < sectorTypes.length)
|
||||||
sectorTypes[block] = type;
|
sectorTypes[block] = type;
|
||||||
@ -330,8 +385,10 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Override this so that the correct sector type can be displayed
|
// Override this so that the correct sector type can be displayed
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public DataSource getFormattedSector (DiskAddress da)
|
public DataSource getFormattedSector (DiskAddress da)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (da.getBlock () == 0 && bootSector != null)
|
if (da.getBlock () == 0 && bootSector != null)
|
||||||
return bootSector;
|
return bootSector;
|
||||||
@ -354,14 +411,18 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
/*
|
/*
|
||||||
* Override this with something useful
|
* Override this with something useful
|
||||||
*/
|
*/
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public AppleFileSource getCatalog ()
|
public AppleFileSource getCatalog ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return new DefaultAppleFileSource (disk.toString (), this);
|
return new DefaultAppleFileSource (disk.toString (), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getSectorFilename (DiskAddress da)
|
public String getSectorFilename (DiskAddress da)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
for (AppleFileSource entry : fileEntries)
|
for (AppleFileSource entry : fileEntries)
|
||||||
if (entry.contains (da))
|
if (entry.contains (da))
|
||||||
@ -370,28 +431,36 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int clearOrphans ()
|
public int clearOrphans ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
System.out.println ("Not implemented yet");
|
System.out.println ("Not implemented yet");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean isSectorFree (DiskAddress da)
|
public boolean isSectorFree (DiskAddress da)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return freeBlocks.get (da.getBlock ());
|
return freeBlocks.get (da.getBlock ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean isSectorFree (int blockNo)
|
public boolean isSectorFree (int blockNo)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return freeBlocks.get (blockNo);
|
return freeBlocks.get (blockNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// representation of the Free Sector Table
|
// representation of the Free Sector Table
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void setSectorFree (int block, boolean free)
|
public void setSectorFree (int block, boolean free)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (block < 0 || block >= freeBlocks.size ())
|
if (block < 0 || block >= freeBlocks.size ())
|
||||||
{
|
{
|
||||||
@ -404,20 +473,26 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check that the sector hasn't already been flagged as part of the disk structure
|
// Check that the sector hasn't already been flagged as part of the disk structure
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean stillAvailable (DiskAddress da)
|
public boolean stillAvailable (DiskAddress da)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return stillAvailable (da.getBlock ());
|
return stillAvailable (da.getBlock ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean stillAvailable (int blockNo)
|
public boolean stillAvailable (int blockNo)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return sectorTypes[blockNo] == usedSector || sectorTypes[blockNo] == emptySector;
|
return sectorTypes[blockNo] == usedSector || sectorTypes[blockNo] == emptySector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void verify ()
|
public void verify ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
System.out.println ("Sectors to clean :");
|
System.out.println ("Sectors to clean :");
|
||||||
for (int i = 0, max = disk.getTotalBlocks (); i < max; i++)
|
for (int i = 0, max = disk.getTotalBlocks (); i < max; i++)
|
||||||
@ -436,30 +511,40 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||||||
}
|
}
|
||||||
|
|
||||||
// VTOC flags sector as free, but it is in use by a file
|
// VTOC flags sector as free, but it is in use by a file
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int falsePositiveBlocks ()
|
public int falsePositiveBlocks ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return falsePositives;
|
return falsePositives;
|
||||||
}
|
}
|
||||||
|
|
||||||
// VTOC flags sector as in use, but no file is using it (and not in the DOS tracks)
|
// VTOC flags sector as in use, but no file is using it (and not in the DOS tracks)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int falseNegativeBlocks ()
|
public int falseNegativeBlocks ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return falseNegatives;
|
return falseNegatives;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void addActionListener (ActionListener actionListener)
|
public void addActionListener (ActionListener actionListener)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
actionListenerList = AWTEventMulticaster.add (actionListenerList, actionListener);
|
actionListenerList = AWTEventMulticaster.add (actionListenerList, actionListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void removeActionListener (ActionListener actionListener)
|
public void removeActionListener (ActionListener actionListener)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
actionListenerList = AWTEventMulticaster.remove (actionListenerList, actionListener);
|
actionListenerList = AWTEventMulticaster.remove (actionListenerList, actionListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void notifyListeners (String text)
|
public void notifyListeners (String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (actionListenerList != null)
|
if (actionListenerList != null)
|
||||||
actionListenerList
|
actionListenerList
|
||||||
|
@ -9,7 +9,9 @@ import com.bytezone.diskbrowser.applefile.AssemblerProgram;
|
|||||||
import com.bytezone.diskbrowser.gui.DataSource;
|
import com.bytezone.diskbrowser.gui.DataSource;
|
||||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public abstract class AbstractSector implements DataSource
|
public abstract class AbstractSector implements DataSource
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static String newLine = String.format ("%n");
|
private static String newLine = String.format ("%n");
|
||||||
private static String newLine2 = newLine + newLine;
|
private static String newLine2 = newLine + newLine;
|
||||||
@ -17,55 +19,69 @@ public abstract class AbstractSector implements DataSource
|
|||||||
final public byte[] buffer;
|
final public byte[] buffer;
|
||||||
protected Disk disk;
|
protected Disk disk;
|
||||||
protected DiskAddress diskAddress;
|
protected DiskAddress diskAddress;
|
||||||
// private List<DiskAddress> diskAddressList;
|
|
||||||
AssemblerProgram assembler;
|
AssemblerProgram assembler;
|
||||||
String description;
|
String description;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public AbstractSector (Disk disk, byte[] buffer, DiskAddress diskAddress)
|
public AbstractSector (Disk disk, byte[] buffer, DiskAddress diskAddress)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.buffer = buffer;
|
this.buffer = buffer;
|
||||||
this.disk = disk;
|
this.disk = disk;
|
||||||
this.diskAddress = diskAddress;
|
this.diskAddress = diskAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractSector (Disk disk, byte[] buffer)//, List<DiskAddress> diskAddressList)
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public AbstractSector (Disk disk, byte[] buffer)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.buffer = buffer;
|
this.buffer = buffer;
|
||||||
this.disk = disk;
|
this.disk = disk;
|
||||||
// this.diskAddressList = diskAddressList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getAssembler ()
|
public String getAssembler ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (assembler == null)
|
if (assembler == null)
|
||||||
assembler = new AssemblerProgram ("noname", buffer, 0);
|
assembler = new AssemblerProgram ("noname", buffer, 0);
|
||||||
return assembler.getText ();
|
return assembler.getText ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getHexDump ()
|
public String getHexDump ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return HexFormatter.format (buffer, 0, buffer.length);
|
return HexFormatter.format (buffer, 0, buffer.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public BufferedImage getImage ()
|
public BufferedImage getImage ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getText ()
|
public String getText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (description == null)
|
if (description == null)
|
||||||
description = createText ();
|
description = createText ();
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public abstract String createText ();
|
public abstract String createText ();
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
protected StringBuilder getHeader (String title)
|
protected StringBuilder getHeader (String title)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
@ -76,15 +92,19 @@ public abstract class AbstractSector implements DataSource
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public JComponent getComponent ()
|
public JComponent getComponent ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
JPanel panel = new JPanel ();
|
JPanel panel = new JPanel ();
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
protected void addText (StringBuilder text, byte[] buffer, int offset, int size,
|
protected void addText (StringBuilder text, byte[] buffer, int offset, int size,
|
||||||
String desc)
|
String desc)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if ((offset + size - 1) > buffer.length)
|
if ((offset + size - 1) > buffer.length)
|
||||||
return;
|
return;
|
||||||
@ -113,8 +133,10 @@ public abstract class AbstractSector implements DataSource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
protected void addTextAndDecimal (StringBuilder text, byte[] b, int offset, int size,
|
protected void addTextAndDecimal (StringBuilder text, byte[] b, int offset, int size,
|
||||||
String desc)
|
String desc)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (size == 1)
|
if (size == 1)
|
||||||
desc += " (" + (b[offset] & 0xFF) + ")";
|
desc += " (" + (b[offset] & 0xFF) + ")";
|
||||||
@ -124,6 +146,7 @@ public abstract class AbstractSector implements DataSource
|
|||||||
else if (size == 3)
|
else if (size == 3)
|
||||||
desc += String.format (" (%,d)", ((b[offset + 2] & 0xFF) * 65536)
|
desc += String.format (" (%,d)", ((b[offset + 2] & 0xFF) * 65536)
|
||||||
+ ((b[offset + 1] & 0xFF) * 256) + (b[offset] & 0xFF));
|
+ ((b[offset + 1] & 0xFF) * 256) + (b[offset] & 0xFF));
|
||||||
|
|
||||||
addText (text, b, offset, size, desc);
|
addText (text, b, offset, size, desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,7 +21,9 @@ import com.bytezone.diskbrowser.nib.WozFile;
|
|||||||
import com.bytezone.diskbrowser.utilities.FileFormatException;
|
import com.bytezone.diskbrowser.utilities.FileFormatException;
|
||||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class AppleDisk implements Disk
|
public class AppleDisk implements Disk
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static final int MAX_INTERLEAVE = 3;
|
private static final int MAX_INTERLEAVE = 3;
|
||||||
private static final int SECTOR_SIZE = 256;
|
private static final int SECTOR_SIZE = 256;
|
||||||
@ -86,13 +88,17 @@ public class AppleDisk implements Disk
|
|||||||
|
|
||||||
private final boolean debug = false;
|
private final boolean debug = false;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public AppleDisk (File file, int tracks, int sectors) throws FileFormatException
|
public AppleDisk (File file, int tracks, int sectors) throws FileFormatException
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this (file, tracks, sectors, 0);
|
this (file, tracks, sectors, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public AppleDisk (File file, int tracks, int sectors, int skip)
|
public AppleDisk (File file, int tracks, int sectors, int skip)
|
||||||
throws FileFormatException
|
throws FileFormatException
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert (file.exists ()) : "No such path :" + file.getAbsolutePath ();
|
assert (file.exists ()) : "No such path :" + file.getAbsolutePath ();
|
||||||
assert (!file.isDirectory ()) : "File is directory :" + file.getAbsolutePath ();
|
assert (!file.isDirectory ()) : "File is directory :" + file.getAbsolutePath ();
|
||||||
@ -233,7 +239,9 @@ public class AppleDisk implements Disk
|
|||||||
checkSectorsForData ();
|
checkSectorsForData ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public AppleDisk (V2dFile disk, int tracks, int sectors)
|
public AppleDisk (V2dFile disk, int tracks, int sectors)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.tracks = tracks;
|
this.tracks = tracks;
|
||||||
this.sectors = sectors;
|
this.sectors = sectors;
|
||||||
@ -248,7 +256,9 @@ public class AppleDisk implements Disk
|
|||||||
checkSectorsForData ();
|
checkSectorsForData ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public AppleDisk (NibFile disk) // not used yet
|
public AppleDisk (NibFile disk) // not used yet
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
tracks = 35;
|
tracks = 35;
|
||||||
trackSize = 4096;
|
trackSize = 4096;
|
||||||
@ -256,7 +266,9 @@ public class AppleDisk implements Disk
|
|||||||
diskBuffer = disk.getDiskBuffer ();
|
diskBuffer = disk.getDiskBuffer ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public AppleDisk (WozFile wozFile, int tracks, int sectors)
|
public AppleDisk (WozFile wozFile, int tracks, int sectors)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.wozFile = wozFile;
|
this.wozFile = wozFile;
|
||||||
this.tracks = tracks;
|
this.tracks = tracks;
|
||||||
@ -281,7 +293,9 @@ public class AppleDisk implements Disk
|
|||||||
checkSectorsForData ();
|
checkSectorsForData ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private byte[] getPrefix (File path)
|
private byte[] getPrefix (File path)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[64];
|
byte[] buffer = new byte[64];
|
||||||
try
|
try
|
||||||
@ -299,7 +313,9 @@ public class AppleDisk implements Disk
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void checkSectorsForData ()
|
private void checkSectorsForData ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (true)
|
if (true)
|
||||||
{
|
{
|
||||||
@ -322,7 +338,9 @@ public class AppleDisk implements Disk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void checkSectorsFaster ()
|
private void checkSectorsFaster ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
// force blockList to be rebuilt with the correct number/size of blocks
|
// force blockList to be rebuilt with the correct number/size of blocks
|
||||||
blockList = null;
|
blockList = null;
|
||||||
@ -343,7 +361,9 @@ public class AppleDisk implements Disk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private boolean check (int diskOffset)
|
private boolean check (int diskOffset)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
for (int i = diskOffset, max = diskOffset + SECTOR_SIZE; i < max; i++)
|
for (int i = diskOffset, max = diskOffset + SECTOR_SIZE; i < max; i++)
|
||||||
if (diskBuffer[i] != emptyByte)
|
if (diskBuffer[i] != emptyByte)
|
||||||
@ -355,50 +375,66 @@ public class AppleDisk implements Disk
|
|||||||
* Routines that implement the Disk interface
|
* Routines that implement the Disk interface
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int getSectorsPerTrack ()
|
public int getSectorsPerTrack ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return trackSize / sectorSize;
|
return trackSize / sectorSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int getTrackSize ()
|
public int getTrackSize ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return trackSize;
|
return trackSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int getBlockSize ()
|
public int getBlockSize ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return sectorSize;
|
return sectorSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int getTotalBlocks ()
|
public int getTotalBlocks ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return blocks;
|
return blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int getTotalTracks ()
|
public int getTotalTracks ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return tracks;
|
return tracks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean isSectorEmpty (DiskAddress da)
|
public boolean isSectorEmpty (DiskAddress da)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return !hasData[da.getBlock ()];
|
return !hasData[da.getBlock ()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean isSectorEmpty (int block)
|
public boolean isSectorEmpty (int block)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return !hasData[block];
|
return !hasData[block];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean isSectorEmpty (int track, int sector)
|
public boolean isSectorEmpty (int track, int sector)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return !hasData[getDiskAddress (track, sector).getBlock ()];
|
return !hasData[getDiskAddress (track, sector).getBlock ()];
|
||||||
}
|
}
|
||||||
@ -421,14 +457,18 @@ public class AppleDisk implements Disk
|
|||||||
// return isMissing[getDiskAddress (track, sector).getBlock ()];
|
// return isMissing[getDiskAddress (track, sector).getBlock ()];
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public File getFile ()
|
public File getFile ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public byte[] readSector (DiskAddress da)
|
public byte[] readSector (DiskAddress da)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[sectorSize];
|
byte[] buffer = new byte[sectorSize];
|
||||||
if (da == null)
|
if (da == null)
|
||||||
@ -438,8 +478,10 @@ public class AppleDisk implements Disk
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public byte[] readSectors (List<DiskAddress> daList)
|
public byte[] readSectors (List<DiskAddress> daList)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[daList.size () * sectorSize];
|
byte[] buffer = new byte[daList.size () * sectorSize];
|
||||||
int ptr = 0;
|
int ptr = 0;
|
||||||
@ -453,26 +495,34 @@ public class AppleDisk implements Disk
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public byte[] readSector (int track, int sector)
|
public byte[] readSector (int track, int sector)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return readSector (getDiskAddress (track, sector));
|
return readSector (getDiskAddress (track, sector));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public byte[] readSector (int block)
|
public byte[] readSector (int block)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return readSector (getDiskAddress (block));
|
return readSector (getDiskAddress (block));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void writeSector (DiskAddress da, byte[] buffer)
|
public void writeSector (DiskAddress da, byte[] buffer)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
writeBuffer (da, buffer);
|
writeBuffer (da, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void setInterleave (int interleave)
|
public void setInterleave (int interleave)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert (interleave >= 0 && interleave <= MAX_INTERLEAVE) : "Invalid interleave";
|
assert (interleave >= 0 && interleave <= MAX_INTERLEAVE) : "Invalid interleave";
|
||||||
this.interleave = interleave;
|
this.interleave = interleave;
|
||||||
@ -481,14 +531,18 @@ public class AppleDisk implements Disk
|
|||||||
notifyListeners ("Interleave changed");
|
notifyListeners ("Interleave changed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int getInterleave ()
|
public int getInterleave ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return interleave;
|
return interleave;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void setBlockSize (int size)
|
public void setBlockSize (int size)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert (size == SECTOR_SIZE || size == BLOCK_SIZE) : "Invalid sector size : " + size;
|
assert (size == SECTOR_SIZE || size == BLOCK_SIZE) : "Invalid sector size : " + size;
|
||||||
if (sectorSize == size)
|
if (sectorSize == size)
|
||||||
@ -505,8 +559,10 @@ public class AppleDisk implements Disk
|
|||||||
notifyListeners ("Sector size changed");
|
notifyListeners ("Sector size changed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public DiskAddress getDiskAddress (int track, int sector)
|
public DiskAddress getDiskAddress (int track, int sector)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (!isValidAddress (track, sector))
|
if (!isValidAddress (track, sector))
|
||||||
{
|
{
|
||||||
@ -517,8 +573,10 @@ public class AppleDisk implements Disk
|
|||||||
return new AppleDiskAddress (this, track, sector);
|
return new AppleDiskAddress (this, track, sector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public DiskAddress getDiskAddress (int block)
|
public DiskAddress getDiskAddress (int block)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (!isValidAddress (block))
|
if (!isValidAddress (block))
|
||||||
{
|
{
|
||||||
@ -530,8 +588,10 @@ public class AppleDisk implements Disk
|
|||||||
return new AppleDiskAddress (this, block);
|
return new AppleDiskAddress (this, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public List<DiskAddress> getDiskAddressList (int... blocks)
|
public List<DiskAddress> getDiskAddressList (int... blocks)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
List<DiskAddress> addressList = new ArrayList<> ();
|
List<DiskAddress> addressList = new ArrayList<> ();
|
||||||
|
|
||||||
@ -543,14 +603,18 @@ public class AppleDisk implements Disk
|
|||||||
return addressList;
|
return addressList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean isValidAddress (int block)
|
public boolean isValidAddress (int block)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return block >= 0 && block < this.blocks;
|
return block >= 0 && block < this.blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean isValidAddress (int track, int sector)
|
public boolean isValidAddress (int track, int sector)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
track &= 0x3F;
|
track &= 0x3F;
|
||||||
sector &= 0x1F;
|
sector &= 0x1F;
|
||||||
@ -563,8 +627,10 @@ public class AppleDisk implements Disk
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean isValidAddress (DiskAddress da)
|
public boolean isValidAddress (DiskAddress da)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return da != null && isValidAddress (da.getTrack (), da.getSector ());
|
return da != null && isValidAddress (da.getTrack (), da.getSector ());
|
||||||
}
|
}
|
||||||
@ -573,7 +639,9 @@ public class AppleDisk implements Disk
|
|||||||
* This is the only method that transfers data from the disk buffer to an output buffer.
|
* This is the only method that transfers data from the disk buffer to an output buffer.
|
||||||
* It handles sectors of 256 or 512 bytes, and both linear and interleaved sectors.
|
* It handles sectors of 256 or 512 bytes, and both linear and interleaved sectors.
|
||||||
*/
|
*/
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void readBuffer (DiskAddress da, byte[] buffer, int bufferOffset)
|
private void readBuffer (DiskAddress da, byte[] buffer, int bufferOffset)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert da.getDisk () == this : "Disk address not applicable to this disk";
|
assert da.getDisk () == this : "Disk address not applicable to this disk";
|
||||||
assert sectorSize == SECTOR_SIZE
|
assert sectorSize == SECTOR_SIZE
|
||||||
@ -597,7 +665,9 @@ public class AppleDisk implements Disk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void writeBuffer (DiskAddress da, byte[] buffer)
|
private void writeBuffer (DiskAddress da, byte[] buffer)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert da.getDisk () == this : "Disk address not applicable to this disk";
|
assert da.getDisk () == this : "Disk address not applicable to this disk";
|
||||||
assert sectorSize == SECTOR_SIZE
|
assert sectorSize == SECTOR_SIZE
|
||||||
@ -620,7 +690,9 @@ public class AppleDisk implements Disk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private int getBufferOffset (DiskAddress da)
|
private int getBufferOffset (DiskAddress da)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert sectorSize == SECTOR_SIZE;
|
assert sectorSize == SECTOR_SIZE;
|
||||||
|
|
||||||
@ -628,7 +700,9 @@ public class AppleDisk implements Disk
|
|||||||
+ interleaveSector[interleave][da.getSector ()] * SECTOR_SIZE;
|
+ interleaveSector[interleave][da.getSector ()] * SECTOR_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private int getBufferOffset (DiskAddress da, int seq)
|
private int getBufferOffset (DiskAddress da, int seq)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
assert sectorSize == BLOCK_SIZE;
|
assert sectorSize == BLOCK_SIZE;
|
||||||
|
|
||||||
@ -638,32 +712,42 @@ public class AppleDisk implements Disk
|
|||||||
+ interleaveSector[interleave][da.getSector () * 2 + seq] * SECTOR_SIZE;
|
+ interleaveSector[interleave][da.getSector () * 2 + seq] * SECTOR_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void addActionListener (ActionListener actionListener)
|
public void addActionListener (ActionListener actionListener)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
actionListenerList = AWTEventMulticaster.add (actionListenerList, actionListener);
|
actionListenerList = AWTEventMulticaster.add (actionListenerList, actionListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void removeActionListener (ActionListener actionListener)
|
public void removeActionListener (ActionListener actionListener)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
actionListenerList = AWTEventMulticaster.remove (actionListenerList, actionListener);
|
actionListenerList = AWTEventMulticaster.remove (actionListenerList, actionListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void notifyListeners (String text)
|
public void notifyListeners (String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (actionListenerList != null)
|
if (actionListenerList != null)
|
||||||
actionListenerList
|
actionListenerList
|
||||||
.actionPerformed (new ActionEvent (this, ActionEvent.ACTION_PERFORMED, text));
|
.actionPerformed (new ActionEvent (this, ActionEvent.ACTION_PERFORMED, text));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public AppleFileSource getDetails ()
|
public AppleFileSource getDetails ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return new DefaultAppleFileSource (toString (), file.getName (), null);
|
return new DefaultAppleFileSource (toString (), file.getName (), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
@ -691,8 +775,10 @@ public class AppleDisk implements Disk
|
|||||||
return text.toString ();
|
return text.toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public Iterator<DiskAddress> iterator ()
|
public Iterator<DiskAddress> iterator ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (blockList == null)
|
if (blockList == null)
|
||||||
{
|
{
|
||||||
@ -704,8 +790,10 @@ public class AppleDisk implements Disk
|
|||||||
return blockList.iterator ();
|
return blockList.iterator ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public long getBootChecksum ()
|
public long getBootChecksum ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
byte[] buffer = readSector (0, 0);
|
byte[] buffer = readSector (0, 0);
|
||||||
Checksum checksum = new CRC32 ();
|
Checksum checksum = new CRC32 ();
|
||||||
@ -713,8 +801,10 @@ public class AppleDisk implements Disk
|
|||||||
return checksum.getValue ();
|
return checksum.getValue ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public void setEmptyByte (byte value)
|
public void setEmptyByte (byte value)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
emptyByte = value;
|
emptyByte = value;
|
||||||
checkSectorsForData ();
|
checkSectorsForData ();
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.bytezone.diskbrowser.disk;
|
package com.bytezone.diskbrowser.disk;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class AppleDiskAddress implements DiskAddress
|
public class AppleDiskAddress implements DiskAddress
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private final int block;
|
private final int block;
|
||||||
private final int track;
|
private final int track;
|
||||||
@ -9,7 +11,9 @@ public class AppleDiskAddress implements DiskAddress
|
|||||||
|
|
||||||
private boolean zeroFlag;
|
private boolean zeroFlag;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public AppleDiskAddress (Disk owner, int block)
|
public AppleDiskAddress (Disk owner, int block)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.block = block;
|
this.block = block;
|
||||||
@ -26,7 +30,9 @@ public class AppleDiskAddress implements DiskAddress
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public AppleDiskAddress (Disk owner, int track, int sector)
|
public AppleDiskAddress (Disk owner, int track, int sector)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
zeroFlag = (track & 0x40) != 0;
|
zeroFlag = (track & 0x40) != 0;
|
||||||
@ -35,51 +41,67 @@ public class AppleDiskAddress implements DiskAddress
|
|||||||
this.block = this.track * owner.getSectorsPerTrack () + this.sector;
|
this.block = this.track * owner.getSectorsPerTrack () + this.sector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public boolean zeroFlag ()
|
public boolean zeroFlag ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return zeroFlag;
|
return zeroFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int compareTo (DiskAddress that)
|
public int compareTo (DiskAddress that)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return this.block - that.getBlock ();
|
return this.block - that.getBlock ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean matches (DiskAddress that)
|
public boolean matches (DiskAddress that)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (that == null)
|
if (that == null)
|
||||||
return false;
|
return false;
|
||||||
return this.block == that.getBlock ();
|
return this.block == that.getBlock ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int getBlock ()
|
public int getBlock ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int getSector ()
|
public int getSector ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return sector;
|
return sector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public int getTrack ()
|
public int getTrack ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return track;
|
return track;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public Disk getDisk ()
|
public Disk getDisk ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return String.format ("[Block=%3d, Track=%2d, Sector=%2d, Zero=%s]", block, track,
|
return String.format ("[Block=%3d, Track=%2d, Sector=%2d, Zero=%s]", block, track,
|
||||||
sector, zeroFlag);
|
sector, zeroFlag);
|
||||||
|
@ -5,14 +5,18 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.bytezone.diskbrowser.gui.DataSource;
|
import com.bytezone.diskbrowser.gui.DataSource;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class DataDisk extends AbstractFormattedDisk
|
public class DataDisk extends AbstractFormattedDisk
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
// static final byte[] dos = { 0x01, (byte) 0xA5, 0x27, (byte) 0xC9, 0x09 };
|
// static final byte[] dos = { 0x01, (byte) 0xA5, 0x27, (byte) 0xC9, 0x09 };
|
||||||
|
|
||||||
// this should somehow tie in with the checksum from DiskFactory to determine
|
// this should somehow tie in with the checksum from DiskFactory to determine
|
||||||
// whether it has a bootloader
|
// whether it has a bootloader
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DataDisk (AppleDisk disk)
|
public DataDisk (AppleDisk disk)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (disk);
|
super (disk);
|
||||||
|
|
||||||
@ -33,20 +37,26 @@ public class DataDisk extends AbstractFormattedDisk
|
|||||||
}
|
}
|
||||||
|
|
||||||
// no files on data disks
|
// no files on data disks
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public List<DiskAddress> getFileSectors (int fileNo)
|
public List<DiskAddress> getFileSectors (int fileNo)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return new ArrayList<> ();
|
return new ArrayList<> ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// no files on data disks
|
// no files on data disks
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DataSource getFile (int fileNo)
|
public DataSource getFile (int fileNo)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return disk.toString ();
|
return disk.toString ();
|
||||||
}
|
}
|
||||||
|
@ -10,32 +10,42 @@ import com.bytezone.diskbrowser.gui.DataSource;
|
|||||||
* and Volume nodes in the tree to show some text in the centre panel, use a
|
* and Volume nodes in the tree to show some text in the centre panel, use a
|
||||||
* DefaultAppleFileSource which returns a DefaultDataSource (just some text).
|
* DefaultAppleFileSource which returns a DefaultDataSource (just some text).
|
||||||
*/
|
*/
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class DefaultAppleFileSource implements AppleFileSource
|
public class DefaultAppleFileSource implements AppleFileSource
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
final String title;
|
final String title;
|
||||||
final DataSource file;
|
final DataSource file;
|
||||||
final FormattedDisk owner;
|
final FormattedDisk owner;
|
||||||
List<DiskAddress> blocks;
|
List<DiskAddress> blocks;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DefaultAppleFileSource (String text, FormattedDisk owner)
|
public DefaultAppleFileSource (String text, FormattedDisk owner)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this ("", text, owner);
|
this ("", text, owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DefaultAppleFileSource (String title, String text, FormattedDisk owner)
|
public DefaultAppleFileSource (String title, String text, FormattedDisk owner)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this (title, new DefaultDataSource (text), owner);
|
this (title, new DefaultDataSource (text), owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DefaultAppleFileSource (String title, DataSource file, FormattedDisk owner)
|
public DefaultAppleFileSource (String title, DataSource file, FormattedDisk owner)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.file = file;
|
this.file = file;
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DefaultAppleFileSource (String title, DataSource file, FormattedDisk owner,
|
public DefaultAppleFileSource (String title, DataSource file, FormattedDisk owner,
|
||||||
List<DiskAddress> blocks)
|
List<DiskAddress> blocks)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this (title, file, owner);
|
this (title, file, owner);
|
||||||
this.blocks = blocks;
|
this.blocks = blocks;
|
||||||
@ -43,27 +53,35 @@ public class DefaultAppleFileSource implements AppleFileSource
|
|||||||
((DefaultDataSource) file).buffer = owner.getDisk ().readSectors (blocks);
|
((DefaultDataSource) file).buffer = owner.getDisk ().readSectors (blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void setSectors (List<DiskAddress> blocks)
|
public void setSectors (List<DiskAddress> blocks)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.blocks = blocks;
|
this.blocks = blocks;
|
||||||
if (file instanceof DefaultDataSource)
|
if (file instanceof DefaultDataSource)
|
||||||
((DefaultDataSource) file).buffer = owner.getDisk ().readSectors (blocks);
|
((DefaultDataSource) file).buffer = owner.getDisk ().readSectors (blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public DataSource getDataSource ()
|
public DataSource getDataSource ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public FormattedDisk getFormattedDisk ()
|
public FormattedDisk getFormattedDisk ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public List<DiskAddress> getSectors ()
|
public List<DiskAddress> getSectors ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return blocks;
|
return blocks;
|
||||||
}
|
}
|
||||||
@ -71,8 +89,10 @@ public class DefaultAppleFileSource implements AppleFileSource
|
|||||||
/*
|
/*
|
||||||
* See similar routine in CatalogPanel.DiskNode
|
* See similar routine in CatalogPanel.DiskNode
|
||||||
*/
|
*/
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
final int MAX_NAME_LENGTH = 40;
|
final int MAX_NAME_LENGTH = 40;
|
||||||
final int SUFFIX_LENGTH = 12;
|
final int SUFFIX_LENGTH = 12;
|
||||||
@ -84,14 +104,18 @@ public class DefaultAppleFileSource implements AppleFileSource
|
|||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getUniqueName ()
|
public String getUniqueName ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean contains (DiskAddress diskAddress)
|
public boolean contains (DiskAddress diskAddress)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
for (DiskAddress da : blocks)
|
for (DiskAddress da : blocks)
|
||||||
if (da.matches (diskAddress))
|
if (da.matches (diskAddress))
|
||||||
|
@ -8,39 +8,58 @@ import javax.swing.JPanel;
|
|||||||
import com.bytezone.diskbrowser.gui.DataSource;
|
import com.bytezone.diskbrowser.gui.DataSource;
|
||||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class DefaultDataSource implements DataSource
|
public class DefaultDataSource implements DataSource
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public String text;
|
public String text;
|
||||||
byte[] buffer;
|
byte[] buffer;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DefaultDataSource (String text)
|
public DefaultDataSource (String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.text = text;
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
public String getAssembler ()
|
public String getAssembler ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
public String getHexDump ()
|
public String getHexDump ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (buffer != null)
|
if (buffer != null)
|
||||||
return HexFormatter.format (buffer, 0, buffer.length);
|
return HexFormatter.format (buffer, 0, buffer.length);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
public BufferedImage getImage ()
|
public BufferedImage getImage ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
public String getText ()
|
public String getText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
public JComponent getComponent ()
|
public JComponent getComponent ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
System.out.println ("In DefaultDataSource.getComponent()");
|
System.out.println ("In DefaultDataSource.getComponent()");
|
||||||
JPanel panel = new JPanel ();
|
JPanel panel = new JPanel ();
|
||||||
|
@ -2,24 +2,32 @@ package com.bytezone.diskbrowser.disk;
|
|||||||
|
|
||||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class DefaultSector extends AbstractSector
|
public class DefaultSector extends AbstractSector
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DefaultSector (String name, Disk disk, byte[] buffer, DiskAddress diskAddress)
|
public DefaultSector (String name, Disk disk, byte[] buffer, DiskAddress diskAddress)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (disk, buffer, diskAddress);
|
super (disk, buffer, diskAddress);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String createText ()
|
public String createText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return name + "\n\n" + HexFormatter.format (buffer, 0, buffer.length);
|
return name + "\n\n" + HexFormatter.format (buffer, 0, buffer.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,9 @@ import java.awt.event.ActionListener;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public interface Disk extends Iterable<DiskAddress>
|
public interface Disk extends Iterable<DiskAddress>
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public long getBootChecksum ();
|
public long getBootChecksum ();
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.bytezone.diskbrowser.disk;
|
package com.bytezone.diskbrowser.disk;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public interface DiskAddress extends Comparable<DiskAddress>
|
public interface DiskAddress extends Comparable<DiskAddress>
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public int getBlock ();
|
public int getBlock ();
|
||||||
|
|
||||||
|
@ -26,20 +26,28 @@ import com.bytezone.diskbrowser.utilities.Utility;
|
|||||||
import com.bytezone.diskbrowser.wizardry.Wizardry4BootDisk;
|
import com.bytezone.diskbrowser.wizardry.Wizardry4BootDisk;
|
||||||
import com.bytezone.diskbrowser.wizardry.WizardryScenarioDisk;
|
import com.bytezone.diskbrowser.wizardry.WizardryScenarioDisk;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class DiskFactory
|
public class DiskFactory
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
private static boolean debug = false;
|
private static boolean debug = false;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private DiskFactory ()
|
private DiskFactory ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public static FormattedDisk createDisk (File file)
|
public static FormattedDisk createDisk (File file)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return createDisk (file.getAbsolutePath ());
|
return createDisk (file.getAbsolutePath ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public static FormattedDisk createDisk (String path)
|
public static FormattedDisk createDisk (String path)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
System.out.println ("\nFactory : " + path);
|
System.out.println ("\nFactory : " + path);
|
||||||
@ -488,7 +496,9 @@ public class DiskFactory
|
|||||||
return disk;
|
return disk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private static DosDisk checkDos (AppleDisk disk)
|
private static DosDisk checkDos (AppleDisk disk)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
System.out.println ("Checking DOS disk");
|
System.out.println ("Checking DOS disk");
|
||||||
@ -511,7 +521,9 @@ public class DiskFactory
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private static ProdosDisk checkProdos (AppleDisk disk)
|
private static ProdosDisk checkProdos (AppleDisk disk)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
System.out.println ("Checking Prodos disk");
|
System.out.println ("Checking Prodos disk");
|
||||||
@ -533,7 +545,9 @@ public class DiskFactory
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private static DosDisk checkUnidos (AppleDisk disk, int side)
|
private static DosDisk checkUnidos (AppleDisk disk, int side)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
System.out.println ("Checking UniDOS disk");
|
System.out.println ("Checking UniDOS disk");
|
||||||
@ -556,7 +570,9 @@ public class DiskFactory
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private static FormattedDisk checkHardDisk (File file)
|
private static FormattedDisk checkHardDisk (File file)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -643,7 +659,9 @@ public class DiskFactory
|
|||||||
must all be zero.
|
must all be zero.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private static FormattedDisk check2mgDisk (File file)
|
private static FormattedDisk check2mgDisk (File file)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
System.out.println ("Checking 2mg disk");
|
System.out.println ("Checking 2mg disk");
|
||||||
@ -666,7 +684,9 @@ public class DiskFactory
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private static FormattedDisk checkPascalDisk (AppleDisk disk)
|
private static FormattedDisk checkPascalDisk (AppleDisk disk)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
System.out.println ("Checking Pascal disk");
|
System.out.println ("Checking Pascal disk");
|
||||||
@ -722,7 +742,9 @@ public class DiskFactory
|
|||||||
return pascalDisk;
|
return pascalDisk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private static boolean collectDataDisks (String fileName, int dotPos, AppleDisk[] disks)
|
private static boolean collectDataDisks (String fileName, int dotPos, AppleDisk[] disks)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
char c = fileName.charAt (dotPos - 1);
|
char c = fileName.charAt (dotPos - 1);
|
||||||
String suffix = fileName.substring (dotPos + 1);
|
String suffix = fileName.substring (dotPos + 1);
|
||||||
@ -744,7 +766,9 @@ public class DiskFactory
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private static InfocomDisk checkInfocomDisk (AppleDisk disk)
|
private static InfocomDisk checkInfocomDisk (AppleDisk disk)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
System.out.println ("Checking Infocom disk");
|
System.out.println ("Checking Infocom disk");
|
||||||
@ -762,7 +786,9 @@ public class DiskFactory
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private static CPMDisk checkCPMDisk (AppleDisk disk)
|
private static CPMDisk checkCPMDisk (AppleDisk disk)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
System.out.println ("Checking CPM disk");
|
System.out.println ("Checking CPM disk");
|
||||||
@ -775,9 +801,4 @@ public class DiskFactory
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkMissingSectors (AppleDisk disk, WozFile wozFile)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -10,7 +10,9 @@ 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;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public interface FormattedDisk
|
public interface FormattedDisk
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
// Methods to be implemented by the implementer
|
// Methods to be implemented by the implementer
|
||||||
public DataSource getFormattedSector (DiskAddress da);
|
public DataSource getFormattedSector (DiskAddress da);
|
||||||
|
@ -4,12 +4,16 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class SectorList extends AbstractFile
|
public class SectorList extends AbstractFile
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
List<DiskAddress> sectors;
|
List<DiskAddress> sectors;
|
||||||
FormattedDisk formattedDisk;
|
FormattedDisk formattedDisk;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public SectorList (FormattedDisk formattedDisk, List<DiskAddress> sectors)
|
public SectorList (FormattedDisk formattedDisk, List<DiskAddress> sectors)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super ("noname", null);
|
super ("noname", null);
|
||||||
|
|
||||||
@ -30,8 +34,10 @@ public class SectorList extends AbstractFile
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String getText ()
|
public String getText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
StringBuilder text = new StringBuilder ("Block Sector Type Owner\n");
|
StringBuilder text = new StringBuilder ("Block Sector Type Owner\n");
|
||||||
text.append (
|
text.append (
|
||||||
|
@ -3,12 +3,16 @@ package com.bytezone.diskbrowser.disk;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class SectorListConverter
|
public class SectorListConverter
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public final List<DiskAddress> sectors;
|
public final List<DiskAddress> sectors;
|
||||||
public final String sectorText;
|
public final String sectorText;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public SectorListConverter (String text, Disk disk)
|
public SectorListConverter (String text, Disk disk)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
sectors = new ArrayList<> ();
|
sectors = new ArrayList<> ();
|
||||||
sectorText = text;
|
sectorText = text;
|
||||||
@ -29,7 +33,9 @@ public class SectorListConverter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public SectorListConverter (List<DiskAddress> sectors)
|
public SectorListConverter (List<DiskAddress> sectors)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.sectors = sectors;
|
this.sectors = sectors;
|
||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
@ -55,7 +61,9 @@ public class SectorListConverter
|
|||||||
sectorText = text.deleteCharAt (text.length () - 1).toString ();
|
sectorText = text.deleteCharAt (text.length () - 1).toString ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
private void addToText (StringBuilder text, int firstBlock, int runLength)
|
private void addToText (StringBuilder text, int firstBlock, int runLength)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
if (runLength == 0)
|
if (runLength == 0)
|
||||||
text.append (firstBlock + ";");
|
text.append (firstBlock + ";");
|
||||||
|
@ -2,19 +2,25 @@ package com.bytezone.diskbrowser.disk;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class SectorType
|
public class SectorType
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
public final String name;
|
public final String name;
|
||||||
public final Color colour;
|
public final Color colour;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public SectorType (String name, Color colour)
|
public SectorType (String name, Color colour)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.colour = colour;
|
this.colour = colour;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return String.format ("[SectorType : %s, %s]", name, colour);
|
return String.format ("[SectorType : %s, %s]", name, colour);
|
||||||
}
|
}
|
||||||
|
@ -3,17 +3,23 @@ package com.bytezone.diskbrowser.disk;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
public class UnknownDisk extends AbstractFormattedDisk
|
public class UnknownDisk extends AbstractFormattedDisk
|
||||||
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
// could arrange for the blocks to appear as a question mark
|
// could arrange for the blocks to appear as a question mark
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public UnknownDisk (AppleDisk disk)
|
public UnknownDisk (AppleDisk disk)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (disk);
|
super (disk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public List<DiskAddress> getFileSectors (int fileNo)
|
public List<DiskAddress> getFileSectors (int fileNo)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return new ArrayList<> ();
|
return new ArrayList<> ();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user