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");
|
||||||
|
|
||||||
|
@ -36,7 +42,7 @@ public class CPMCatalogSector extends AbstractSector
|
||||||
typeBuffer[2] = buffer[i + 11];
|
typeBuffer[2] = buffer[i + 11];
|
||||||
type = new String (typeBuffer).trim ();
|
type = new String (typeBuffer).trim ();
|
||||||
extra = String.format (" (%s%s)", readOnly ? "read only" : "",
|
extra = String.format (" (%s%s)", readOnly ? "read only" : "",
|
||||||
systemFile ? "system file" : "");
|
systemFile ? "system file" : "");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,129 +1,152 @@
|
||||||
package com.bytezone.diskbrowser.disk;
|
package com.bytezone.diskbrowser.disk;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.AssemblerProgram;
|
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 newLine2 = newLine + newLine;
|
{
|
||||||
|
private static String newLine = String.format ("%n");
|
||||||
final public byte[] buffer;
|
private static String newLine2 = newLine + newLine;
|
||||||
protected Disk disk;
|
|
||||||
protected DiskAddress diskAddress;
|
final public byte[] buffer;
|
||||||
// private List<DiskAddress> diskAddressList;
|
protected Disk disk;
|
||||||
AssemblerProgram assembler;
|
protected DiskAddress diskAddress;
|
||||||
String description;
|
AssemblerProgram assembler;
|
||||||
|
String description;
|
||||||
public AbstractSector (Disk disk, byte[] buffer, DiskAddress diskAddress)
|
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
this.buffer = buffer;
|
public AbstractSector (Disk disk, byte[] buffer, DiskAddress diskAddress)
|
||||||
this.disk = disk;
|
// ---------------------------------------------------------------------------------//
|
||||||
this.diskAddress = diskAddress;
|
{
|
||||||
}
|
this.buffer = buffer;
|
||||||
|
this.disk = disk;
|
||||||
public AbstractSector (Disk disk, byte[] buffer)//, List<DiskAddress> diskAddressList)
|
this.diskAddress = diskAddress;
|
||||||
{
|
}
|
||||||
this.buffer = buffer;
|
|
||||||
this.disk = disk;
|
// ---------------------------------------------------------------------------------//
|
||||||
// this.diskAddressList = diskAddressList;
|
public AbstractSector (Disk disk, byte[] buffer)
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
@Override
|
this.buffer = buffer;
|
||||||
public String getAssembler ()
|
this.disk = disk;
|
||||||
{
|
}
|
||||||
if (assembler == null)
|
|
||||||
assembler = new AssemblerProgram ("noname", buffer, 0);
|
// ---------------------------------------------------------------------------------//
|
||||||
return assembler.getText ();
|
@Override
|
||||||
}
|
public String getAssembler ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
{
|
||||||
public String getHexDump ()
|
if (assembler == null)
|
||||||
{
|
assembler = new AssemblerProgram ("noname", buffer, 0);
|
||||||
return HexFormatter.format (buffer, 0, buffer.length);
|
return assembler.getText ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// ---------------------------------------------------------------------------------//
|
||||||
public BufferedImage getImage ()
|
@Override
|
||||||
{
|
public String getHexDump ()
|
||||||
return null;
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
{
|
||||||
|
return HexFormatter.format (buffer, 0, buffer.length);
|
||||||
@Override
|
}
|
||||||
public String getText ()
|
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
if (description == null)
|
@Override
|
||||||
description = createText ();
|
public BufferedImage getImage ()
|
||||||
return description;
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
{
|
||||||
|
return null;
|
||||||
public abstract String createText ();
|
}
|
||||||
|
|
||||||
protected StringBuilder getHeader (String title)
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
@Override
|
||||||
StringBuilder text = new StringBuilder ();
|
public String getText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
text.append (title + newLine2);
|
{
|
||||||
text.append ("Offset Value Description" + newLine);
|
if (description == null)
|
||||||
text.append ("======= =========== "
|
description = createText ();
|
||||||
+ "===============================================================" + newLine);
|
return description;
|
||||||
return text;
|
}
|
||||||
}
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
public abstract String createText ();
|
||||||
public JComponent getComponent ()
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
|
||||||
JPanel panel = new JPanel ();
|
// ---------------------------------------------------------------------------------//
|
||||||
return panel;
|
protected StringBuilder getHeader (String title)
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
protected void addText (StringBuilder text, byte[] buffer, int offset, int size,
|
StringBuilder text = new StringBuilder ();
|
||||||
String desc)
|
|
||||||
{
|
text.append (title + newLine2);
|
||||||
if ((offset + size - 1) > buffer.length)
|
text.append ("Offset Value Description" + newLine);
|
||||||
return;
|
text.append ("======= =========== "
|
||||||
|
+ "===============================================================" + newLine);
|
||||||
switch (size)
|
return text;
|
||||||
{
|
}
|
||||||
case 1:
|
|
||||||
text.append (String.format ("%03X %02X %s%n", offset,
|
// ---------------------------------------------------------------------------------//
|
||||||
buffer[offset], desc));
|
@Override
|
||||||
break;
|
public JComponent getComponent ()
|
||||||
case 2:
|
// ---------------------------------------------------------------------------------//
|
||||||
text.append (String.format ("%03X-%03X %02X %02X %s%n", offset,
|
{
|
||||||
offset + 1, buffer[offset], buffer[offset + 1], desc));
|
JPanel panel = new JPanel ();
|
||||||
break;
|
return panel;
|
||||||
case 3:
|
}
|
||||||
text.append (String.format ("%03X-%03X %02X %02X %02X %s%n", offset,
|
|
||||||
offset + 2, buffer[offset], buffer[offset + 1], buffer[offset + 2], desc));
|
// ---------------------------------------------------------------------------------//
|
||||||
break;
|
protected void addText (StringBuilder text, byte[] buffer, int offset, int size,
|
||||||
case 4:
|
String desc)
|
||||||
text.append (String.format ("%03X-%03X %02X %02X %02X %02X %s%n", offset,
|
// ---------------------------------------------------------------------------------//
|
||||||
offset + 3, buffer[offset], buffer[offset + 1], buffer[offset + 2],
|
{
|
||||||
buffer[offset + 3], desc));
|
if ((offset + size - 1) > buffer.length)
|
||||||
break;
|
return;
|
||||||
default:
|
|
||||||
System.out.println ("Invalid length : " + size);
|
switch (size)
|
||||||
}
|
{
|
||||||
}
|
case 1:
|
||||||
|
text.append (String.format ("%03X %02X %s%n", offset,
|
||||||
protected void addTextAndDecimal (StringBuilder text, byte[] b, int offset, int size,
|
buffer[offset], desc));
|
||||||
String desc)
|
break;
|
||||||
{
|
case 2:
|
||||||
if (size == 1)
|
text.append (String.format ("%03X-%03X %02X %02X %s%n", offset,
|
||||||
desc += " (" + (b[offset] & 0xFF) + ")";
|
offset + 1, buffer[offset], buffer[offset + 1], desc));
|
||||||
else if (size == 2)
|
break;
|
||||||
desc +=
|
case 3:
|
||||||
String.format (" (%,d)", ((b[offset + 1] & 0xFF) * 256 + (b[offset] & 0xFF)));
|
text.append (String.format ("%03X-%03X %02X %02X %02X %s%n", offset,
|
||||||
else if (size == 3)
|
offset + 2, buffer[offset], buffer[offset + 1], buffer[offset + 2], desc));
|
||||||
desc += String.format (" (%,d)", ((b[offset + 2] & 0xFF) * 65536)
|
break;
|
||||||
+ ((b[offset + 1] & 0xFF) * 256) + (b[offset] & 0xFF));
|
case 4:
|
||||||
addText (text, b, offset, size, desc);
|
text.append (String.format ("%03X-%03X %02X %02X %02X %02X %s%n", offset,
|
||||||
}
|
offset + 3, buffer[offset], buffer[offset + 1], buffer[offset + 2],
|
||||||
|
buffer[offset + 3], desc));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
System.out.println ("Invalid length : " + size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
protected void addTextAndDecimal (StringBuilder text, byte[] b, int offset, int size,
|
||||||
|
String desc)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
if (size == 1)
|
||||||
|
desc += " (" + (b[offset] & 0xFF) + ")";
|
||||||
|
else if (size == 2)
|
||||||
|
desc +=
|
||||||
|
String.format (" (%,d)", ((b[offset + 1] & 0xFF) * 256 + (b[offset] & 0xFF)));
|
||||||
|
else if (size == 3)
|
||||||
|
desc += String.format (" (%,d)", ((b[offset + 2] & 0xFF) * 65536)
|
||||||
|
+ ((b[offset + 1] & 0xFF) * 256) + (b[offset] & 0xFF));
|
||||||
|
|
||||||
|
addText (text, b, offset, size, desc);
|
||||||
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,87 +1,109 @@
|
||||||
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 track;
|
{
|
||||||
private final int sector;
|
private final int block;
|
||||||
public final Disk owner;
|
private final int track;
|
||||||
|
private final int sector;
|
||||||
private boolean zeroFlag;
|
public final Disk owner;
|
||||||
|
|
||||||
public AppleDiskAddress (Disk owner, int block)
|
private boolean zeroFlag;
|
||||||
{
|
|
||||||
this.owner = owner;
|
// ---------------------------------------------------------------------------------//
|
||||||
this.block = block;
|
public AppleDiskAddress (Disk owner, int block)
|
||||||
int sectorsPerTrack = owner.getSectorsPerTrack ();
|
// ---------------------------------------------------------------------------------//
|
||||||
if (sectorsPerTrack == 0)
|
{
|
||||||
{
|
this.owner = owner;
|
||||||
track = 0;
|
this.block = block;
|
||||||
sector = 0;
|
int sectorsPerTrack = owner.getSectorsPerTrack ();
|
||||||
}
|
if (sectorsPerTrack == 0)
|
||||||
else
|
{
|
||||||
{
|
track = 0;
|
||||||
track = block / sectorsPerTrack;
|
sector = 0;
|
||||||
sector = block % sectorsPerTrack;
|
}
|
||||||
}
|
else
|
||||||
}
|
{
|
||||||
|
track = block / sectorsPerTrack;
|
||||||
public AppleDiskAddress (Disk owner, int track, int sector)
|
sector = block % sectorsPerTrack;
|
||||||
{
|
}
|
||||||
this.owner = owner;
|
}
|
||||||
zeroFlag = (track & 0x40) != 0;
|
|
||||||
this.track = track & 0x3F;
|
// ---------------------------------------------------------------------------------//
|
||||||
this.sector = sector & 0x1F;
|
public AppleDiskAddress (Disk owner, int track, int sector)
|
||||||
this.block = this.track * owner.getSectorsPerTrack () + this.sector;
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
{
|
||||||
|
this.owner = owner;
|
||||||
public boolean zeroFlag ()
|
zeroFlag = (track & 0x40) != 0;
|
||||||
{
|
this.track = track & 0x3F;
|
||||||
return zeroFlag;
|
this.sector = sector & 0x1F;
|
||||||
}
|
this.block = this.track * owner.getSectorsPerTrack () + this.sector;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public int compareTo (DiskAddress that)
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
public boolean zeroFlag ()
|
||||||
return this.block - that.getBlock ();
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
{
|
||||||
|
return zeroFlag;
|
||||||
@Override
|
}
|
||||||
public boolean matches (DiskAddress that)
|
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
if (that == null)
|
@Override
|
||||||
return false;
|
public int compareTo (DiskAddress that)
|
||||||
return this.block == that.getBlock ();
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
{
|
||||||
|
return this.block - that.getBlock ();
|
||||||
@Override
|
}
|
||||||
public int getBlock ()
|
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
return block;
|
@Override
|
||||||
}
|
public boolean matches (DiskAddress that)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
{
|
||||||
public int getSector ()
|
if (that == null)
|
||||||
{
|
return false;
|
||||||
return sector;
|
return this.block == that.getBlock ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// ---------------------------------------------------------------------------------//
|
||||||
public int getTrack ()
|
@Override
|
||||||
{
|
public int getBlock ()
|
||||||
return track;
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
{
|
||||||
|
return block;
|
||||||
@Override
|
}
|
||||||
public Disk getDisk ()
|
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
return owner;
|
@Override
|
||||||
}
|
public int getSector ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
{
|
||||||
public String toString ()
|
return sector;
|
||||||
{
|
}
|
||||||
return String.format ("[Block=%3d, Track=%2d, Sector=%2d, Zero=%s]", block, track,
|
|
||||||
sector, zeroFlag);
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
@Override
|
||||||
|
public int getTrack ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return track;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public Disk getDisk ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return String.format ("[Block=%3d, Track=%2d, Sector=%2d, Zero=%s]", block, track,
|
||||||
|
sector, zeroFlag);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,53 +1,63 @@
|
||||||
package com.bytezone.diskbrowser.disk;
|
package com.bytezone.diskbrowser.disk;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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 };
|
// -----------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
// this should somehow tie in with the checksum from DiskFactory to determine
|
// static final byte[] dos = { 0x01, (byte) 0xA5, 0x27, (byte) 0xC9, 0x09 };
|
||||||
// whether it has a bootloader
|
|
||||||
|
// this should somehow tie in with the checksum from DiskFactory to determine
|
||||||
public DataDisk (AppleDisk disk)
|
// whether it has a bootloader
|
||||||
{
|
|
||||||
super (disk);
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public DataDisk (AppleDisk disk)
|
||||||
// byte[] buffer = disk.readSector (0, 0); // Boot sector
|
// ---------------------------------------------------------------------------------//
|
||||||
// boolean ok = true;
|
{
|
||||||
// for (int i = 0; i < dos.length; i++)
|
super (disk);
|
||||||
// if (buffer[i] != dos[i])
|
|
||||||
// {
|
// byte[] buffer = disk.readSector (0, 0); // Boot sector
|
||||||
// ok = false;
|
// boolean ok = true;
|
||||||
// break;
|
// for (int i = 0; i < dos.length; i++)
|
||||||
// }
|
// if (buffer[i] != dos[i])
|
||||||
// if (buffer[0] == 0x01)
|
// {
|
||||||
// {
|
// ok = false;
|
||||||
// bootSector = new BootSector (disk, buffer, "DOS");
|
// break;
|
||||||
// sectorTypesList.add (dosSector);
|
// }
|
||||||
// sectorTypes[0] = dosSector;
|
// if (buffer[0] == 0x01)
|
||||||
// }
|
// {
|
||||||
}
|
// bootSector = new BootSector (disk, buffer, "DOS");
|
||||||
|
// sectorTypesList.add (dosSector);
|
||||||
// no files on data disks
|
// sectorTypes[0] = dosSector;
|
||||||
@Override
|
// }
|
||||||
public List<DiskAddress> getFileSectors (int fileNo)
|
}
|
||||||
{
|
|
||||||
return new ArrayList<> ();
|
// no files on data disks
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
// no files on data disks
|
public List<DiskAddress> getFileSectors (int fileNo)
|
||||||
public DataSource getFile (int fileNo)
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return null;
|
return new ArrayList<> ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// no files on data disks
|
||||||
public String toString ()
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
public DataSource getFile (int fileNo)
|
||||||
return disk.toString ();
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return disk.toString ();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,101 +1,125 @@
|
||||||
package com.bytezone.diskbrowser.disk;
|
package com.bytezone.diskbrowser.disk;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
||||||
import com.bytezone.diskbrowser.gui.DataSource;
|
import com.bytezone.diskbrowser.gui.DataSource;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Most AppleFileSource objects are CatalogEntry types. In order to allow Disk
|
* Most AppleFileSource objects are CatalogEntry types. In order to allow Disk
|
||||||
* 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 DataSource file;
|
{
|
||||||
final FormattedDisk owner;
|
final String title;
|
||||||
List<DiskAddress> blocks;
|
final DataSource file;
|
||||||
|
final FormattedDisk owner;
|
||||||
public DefaultAppleFileSource (String text, FormattedDisk owner)
|
List<DiskAddress> blocks;
|
||||||
{
|
|
||||||
this ("", text, owner);
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
public DefaultAppleFileSource (String text, FormattedDisk owner)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DefaultAppleFileSource (String title, String text, FormattedDisk owner)
|
{
|
||||||
{
|
this ("", text, owner);
|
||||||
this (title, new DefaultDataSource (text), owner);
|
}
|
||||||
}
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DefaultAppleFileSource (String title, DataSource file, FormattedDisk owner)
|
public DefaultAppleFileSource (String title, String text, FormattedDisk owner)
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
this.title = title;
|
{
|
||||||
this.file = file;
|
this (title, new DefaultDataSource (text), owner);
|
||||||
this.owner = owner;
|
}
|
||||||
}
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public DefaultAppleFileSource (String title, DataSource file, FormattedDisk owner,
|
public DefaultAppleFileSource (String title, DataSource file, FormattedDisk owner)
|
||||||
List<DiskAddress> blocks)
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
this (title, file, owner);
|
this.title = title;
|
||||||
this.blocks = blocks;
|
this.file = file;
|
||||||
if (file instanceof DefaultDataSource)
|
this.owner = owner;
|
||||||
((DefaultDataSource) file).buffer = owner.getDisk ().readSectors (blocks);
|
}
|
||||||
}
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public void setSectors (List<DiskAddress> blocks)
|
public DefaultAppleFileSource (String title, DataSource file, FormattedDisk owner,
|
||||||
{
|
List<DiskAddress> blocks)
|
||||||
this.blocks = blocks;
|
// ---------------------------------------------------------------------------------//
|
||||||
if (file instanceof DefaultDataSource)
|
{
|
||||||
((DefaultDataSource) file).buffer = owner.getDisk ().readSectors (blocks);
|
this (title, file, owner);
|
||||||
}
|
this.blocks = blocks;
|
||||||
|
if (file instanceof DefaultDataSource)
|
||||||
@Override
|
((DefaultDataSource) file).buffer = owner.getDisk ().readSectors (blocks);
|
||||||
public DataSource getDataSource ()
|
}
|
||||||
{
|
|
||||||
return file;
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
public void setSectors (List<DiskAddress> blocks)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
{
|
||||||
public FormattedDisk getFormattedDisk ()
|
this.blocks = blocks;
|
||||||
{
|
if (file instanceof DefaultDataSource)
|
||||||
return owner;
|
((DefaultDataSource) file).buffer = owner.getDisk ().readSectors (blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// ---------------------------------------------------------------------------------//
|
||||||
public List<DiskAddress> getSectors ()
|
@Override
|
||||||
{
|
public DataSource getDataSource ()
|
||||||
return blocks;
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
{
|
||||||
|
return file;
|
||||||
/*
|
}
|
||||||
* See similar routine in CatalogPanel.DiskNode
|
|
||||||
*/
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public FormattedDisk getFormattedDisk ()
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
final int MAX_NAME_LENGTH = 40;
|
{
|
||||||
final int SUFFIX_LENGTH = 12;
|
return owner;
|
||||||
final int PREFIX_LENGTH = MAX_NAME_LENGTH - SUFFIX_LENGTH - 3;
|
}
|
||||||
|
|
||||||
if (title.length () > MAX_NAME_LENGTH)
|
// ---------------------------------------------------------------------------------//
|
||||||
return title.substring (0, PREFIX_LENGTH) + "..."
|
@Override
|
||||||
+ title.substring (title.length () - SUFFIX_LENGTH);
|
public List<DiskAddress> getSectors ()
|
||||||
return title;
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
{
|
||||||
|
return blocks;
|
||||||
@Override
|
}
|
||||||
public String getUniqueName ()
|
|
||||||
{
|
/*
|
||||||
return title;
|
* See similar routine in CatalogPanel.DiskNode
|
||||||
}
|
*/
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
@Override
|
@Override
|
||||||
public boolean contains (DiskAddress diskAddress)
|
public String toString ()
|
||||||
{
|
// ---------------------------------------------------------------------------------//
|
||||||
for (DiskAddress da : blocks)
|
{
|
||||||
if (da.matches (diskAddress))
|
final int MAX_NAME_LENGTH = 40;
|
||||||
return true;
|
final int SUFFIX_LENGTH = 12;
|
||||||
return false;
|
final int PREFIX_LENGTH = MAX_NAME_LENGTH - SUFFIX_LENGTH - 3;
|
||||||
}
|
|
||||||
|
if (title.length () > MAX_NAME_LENGTH)
|
||||||
|
return title.substring (0, PREFIX_LENGTH) + "..."
|
||||||
|
+ title.substring (title.length () - SUFFIX_LENGTH);
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public String getUniqueName ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public boolean contains (DiskAddress diskAddress)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
for (DiskAddress da : blocks)
|
||||||
|
if (da.matches (diskAddress))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,49 +1,68 @@
|
||||||
package com.bytezone.diskbrowser.disk;
|
package com.bytezone.diskbrowser.disk;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JPanel;
|
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;
|
// -----------------------------------------------------------------------------------//
|
||||||
byte[] buffer;
|
{
|
||||||
|
public String text;
|
||||||
public DefaultDataSource (String text)
|
byte[] buffer;
|
||||||
{
|
|
||||||
this.text = text;
|
// ---------------------------------------------------------------------------------//
|
||||||
}
|
public DefaultDataSource (String text)
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public String getAssembler ()
|
{
|
||||||
{
|
this.text = text;
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
public String getHexDump ()
|
@Override
|
||||||
{
|
public String getAssembler ()
|
||||||
if (buffer != null)
|
// ---------------------------------------------------------------------------------//
|
||||||
return HexFormatter.format (buffer, 0, buffer.length);
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BufferedImage getImage ()
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
@Override
|
||||||
return null;
|
public String getHexDump ()
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
public String getText ()
|
if (buffer != null)
|
||||||
{
|
return HexFormatter.format (buffer, 0, buffer.length);
|
||||||
return text;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JComponent getComponent ()
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
@Override
|
||||||
System.out.println ("In DefaultDataSource.getComponent()");
|
public BufferedImage getImage ()
|
||||||
JPanel panel = new JPanel ();
|
// ---------------------------------------------------------------------------------//
|
||||||
return panel;
|
{
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public String getText ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public JComponent getComponent ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
System.out.println ("In DefaultDataSource.getComponent()");
|
||||||
|
JPanel panel = new JPanel ();
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,26 +1,34 @@
|
||||||
package com.bytezone.diskbrowser.disk;
|
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;
|
// -----------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
public DefaultSector (String name, Disk disk, byte[] buffer, DiskAddress diskAddress)
|
String name;
|
||||||
{
|
|
||||||
super (disk, buffer, diskAddress);
|
// ---------------------------------------------------------------------------------//
|
||||||
this.name = name;
|
public DefaultSector (String name, Disk disk, byte[] buffer, DiskAddress diskAddress)
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
@Override
|
super (disk, buffer, diskAddress);
|
||||||
public String createText ()
|
this.name = name;
|
||||||
{
|
}
|
||||||
return name + "\n\n" + HexFormatter.format (buffer, 0, buffer.length);
|
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
@Override
|
public String createText ()
|
||||||
public String toString ()
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
return name;
|
return name + "\n\n" + HexFormatter.format (buffer, 0, buffer.length);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,62 +1,64 @@
|
||||||
package com.bytezone.diskbrowser.disk;
|
package com.bytezone.diskbrowser.disk;
|
||||||
|
|
||||||
import java.awt.event.ActionListener;
|
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 void setEmptyByte (byte value);
|
public long getBootChecksum ();
|
||||||
|
|
||||||
public int getTotalBlocks (); // blocks per disk - usually 560 or 280
|
public void setEmptyByte (byte value);
|
||||||
|
|
||||||
public int getTotalTracks (); // usually 35
|
public int getTotalBlocks (); // blocks per disk - usually 560 or 280
|
||||||
|
|
||||||
public int getBlockSize (); // bytes per block - 256 or 512
|
public int getTotalTracks (); // usually 35
|
||||||
|
|
||||||
public void setBlockSize (int blockSize);
|
public int getBlockSize (); // bytes per block - 256 or 512
|
||||||
|
|
||||||
public int getTrackSize (); // bytes per track - 4096
|
public void setBlockSize (int blockSize);
|
||||||
|
|
||||||
public int getSectorsPerTrack (); // 8 or 16
|
public int getTrackSize (); // bytes per track - 4096
|
||||||
|
|
||||||
public void setInterleave (int interleave);
|
public int getSectorsPerTrack (); // 8 or 16
|
||||||
|
|
||||||
public int getInterleave ();
|
public void setInterleave (int interleave);
|
||||||
|
|
||||||
public DiskAddress getDiskAddress (int block);
|
public int getInterleave ();
|
||||||
|
|
||||||
public List<DiskAddress> getDiskAddressList (int... blocks);
|
public DiskAddress getDiskAddress (int block);
|
||||||
|
|
||||||
public DiskAddress getDiskAddress (int track, int sector);
|
public List<DiskAddress> getDiskAddressList (int... blocks);
|
||||||
|
|
||||||
public byte[] readSector (int block);
|
public DiskAddress getDiskAddress (int track, int sector);
|
||||||
|
|
||||||
public byte[] readSector (int track, int sector);
|
public byte[] readSector (int block);
|
||||||
|
|
||||||
public byte[] readSector (DiskAddress da);
|
public byte[] readSector (int track, int sector);
|
||||||
|
|
||||||
public byte[] readSectors (List<DiskAddress> daList);
|
public byte[] readSector (DiskAddress da);
|
||||||
|
|
||||||
public void writeSector (DiskAddress da, byte[] buffer);
|
public byte[] readSectors (List<DiskAddress> daList);
|
||||||
|
|
||||||
public boolean isSectorEmpty (int block);
|
public void writeSector (DiskAddress da, byte[] buffer);
|
||||||
|
|
||||||
public boolean isSectorEmpty (int track, int sector);
|
public boolean isSectorEmpty (int block);
|
||||||
|
|
||||||
public boolean isSectorEmpty (DiskAddress da);
|
public boolean isSectorEmpty (int track, int sector);
|
||||||
|
|
||||||
public boolean isValidAddress (int block);
|
public boolean isSectorEmpty (DiskAddress da);
|
||||||
|
|
||||||
public boolean isValidAddress (int track, int sector);
|
public boolean isValidAddress (int block);
|
||||||
|
|
||||||
public boolean isValidAddress (DiskAddress da);
|
public boolean isValidAddress (int track, int sector);
|
||||||
|
|
||||||
public File getFile ();
|
public boolean isValidAddress (DiskAddress da);
|
||||||
|
|
||||||
public void addActionListener (ActionListener listener);
|
public File getFile ();
|
||||||
|
|
||||||
public void removeActionListener (ActionListener listener);
|
public void addActionListener (ActionListener listener);
|
||||||
|
|
||||||
|
public void removeActionListener (ActionListener listener);
|
||||||
}
|
}
|
|
@ -1,14 +1,16 @@
|
||||||
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 getTrack ();
|
public int getBlock ();
|
||||||
|
|
||||||
public int getSector ();
|
public int getTrack ();
|
||||||
|
|
||||||
public Disk getDisk ();
|
public int getSector ();
|
||||||
|
|
||||||
public boolean matches (DiskAddress other);
|
public Disk getDisk ();
|
||||||
|
|
||||||
|
public boolean matches (DiskAddress other);
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,85 +1,87 @@
|
||||||
package com.bytezone.diskbrowser.disk;
|
package com.bytezone.diskbrowser.disk;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.JTree;
|
import javax.swing.JTree;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||||
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
||||||
import com.bytezone.diskbrowser.gui.DataSource;
|
import com.bytezone.diskbrowser.gui.DataSource;
|
||||||
|
|
||||||
public interface FormattedDisk
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
public interface FormattedDisk
|
||||||
// Methods to be implemented by the implementer
|
// -----------------------------------------------------------------------------------//
|
||||||
public DataSource getFormattedSector (DiskAddress da);
|
{
|
||||||
|
// Methods to be implemented by the implementer
|
||||||
public List<DiskAddress> getFileSectors (int fileNo);
|
public DataSource getFormattedSector (DiskAddress da);
|
||||||
|
|
||||||
// Methods implemented by AbstractFormattedDisk
|
public List<DiskAddress> getFileSectors (int fileNo);
|
||||||
public JTree getCatalogTree (); // each node is an AppleFileSource
|
|
||||||
|
// Methods implemented by AbstractFormattedDisk
|
||||||
public List<AppleFileSource> getCatalogList ();
|
public JTree getCatalogTree (); // each node is an AppleFileSource
|
||||||
|
|
||||||
public void writeFile (AbstractFile file);
|
public List<AppleFileSource> getCatalogList ();
|
||||||
|
|
||||||
public SectorType getSectorType (int track, int sector);
|
public void writeFile (AbstractFile file);
|
||||||
|
|
||||||
public SectorType getSectorType (int block);
|
public SectorType getSectorType (int track, int sector);
|
||||||
|
|
||||||
public SectorType getSectorType (DiskAddress da);
|
public SectorType getSectorType (int block);
|
||||||
|
|
||||||
public void setSectorType (int block, SectorType type);
|
public SectorType getSectorType (DiskAddress da);
|
||||||
|
|
||||||
public String getSectorFilename (DiskAddress da);
|
public void setSectorType (int block, SectorType type);
|
||||||
|
|
||||||
public List<SectorType> getSectorTypeList ();
|
public String getSectorFilename (DiskAddress da);
|
||||||
|
|
||||||
public Disk getDisk ();
|
public List<SectorType> getSectorTypeList ();
|
||||||
|
|
||||||
public FormattedDisk getParent ();
|
public Disk getDisk ();
|
||||||
|
|
||||||
public void setParent (FormattedDisk disk);
|
public FormattedDisk getParent ();
|
||||||
|
|
||||||
public AppleFileSource getCatalog ();
|
public void setParent (FormattedDisk disk);
|
||||||
|
|
||||||
public AppleFileSource getFile (String uniqueName);
|
public AppleFileSource getCatalog ();
|
||||||
|
|
||||||
public int clearOrphans ();
|
public AppleFileSource getFile (String uniqueName);
|
||||||
|
|
||||||
public void setSectorFree (int block, boolean free);
|
public int clearOrphans ();
|
||||||
|
|
||||||
public boolean isSectorFree (DiskAddress da);
|
public void setSectorFree (int block, boolean free);
|
||||||
|
|
||||||
public boolean isSectorFree (int block);
|
public boolean isSectorFree (DiskAddress da);
|
||||||
|
|
||||||
public void verify ();
|
public boolean isSectorFree (int block);
|
||||||
|
|
||||||
public boolean stillAvailable (DiskAddress da);
|
public void verify ();
|
||||||
|
|
||||||
public boolean stillAvailable (int block);
|
public boolean stillAvailable (DiskAddress da);
|
||||||
|
|
||||||
public Dimension getGridLayout ();
|
public boolean stillAvailable (int block);
|
||||||
|
|
||||||
public String getAbsolutePath ();
|
public Dimension getGridLayout ();
|
||||||
|
|
||||||
public String getDisplayPath ();
|
public String getAbsolutePath ();
|
||||||
|
|
||||||
public void setOriginalPath (Path path);
|
public String getDisplayPath ();
|
||||||
|
|
||||||
public Path getOriginalPath ();
|
public void setOriginalPath (Path path);
|
||||||
|
|
||||||
public boolean isTempDisk ();
|
public Path getOriginalPath ();
|
||||||
|
|
||||||
// VTOC flags sector as free, but it is in use by a file
|
public boolean isTempDisk ();
|
||||||
public int falsePositiveBlocks ();
|
|
||||||
|
// VTOC flags sector as free, but it is in use by a file
|
||||||
// VTOC flags sector as in use, but no file is using it
|
public int falsePositiveBlocks ();
|
||||||
public int falseNegativeBlocks ();
|
|
||||||
|
// VTOC flags sector as in use, but no file is using it
|
||||||
public String getName ();
|
public int falseNegativeBlocks ();
|
||||||
}
|
|
||||||
|
public String getName ();
|
||||||
// getFileTypeList ()
|
}
|
||||||
|
|
||||||
|
// getFileTypeList ()
|
||||||
// getFiles (FileType type)
|
// getFiles (FileType type)
|
|
@ -1,52 +1,58 @@
|
||||||
package com.bytezone.diskbrowser.disk;
|
package com.bytezone.diskbrowser.disk;
|
||||||
|
|
||||||
import java.util.List;
|
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;
|
// -----------------------------------------------------------------------------------//
|
||||||
FormattedDisk formattedDisk;
|
{
|
||||||
|
List<DiskAddress> sectors;
|
||||||
public SectorList (FormattedDisk formattedDisk, List<DiskAddress> sectors)
|
FormattedDisk formattedDisk;
|
||||||
{
|
|
||||||
super ("noname", null);
|
// ---------------------------------------------------------------------------------//
|
||||||
|
public SectorList (FormattedDisk formattedDisk, List<DiskAddress> sectors)
|
||||||
this.sectors = sectors;
|
// ---------------------------------------------------------------------------------//
|
||||||
this.formattedDisk = formattedDisk;
|
{
|
||||||
|
super ("noname", null);
|
||||||
Disk disk = formattedDisk.getDisk ();
|
|
||||||
int ptr = 0;
|
this.sectors = sectors;
|
||||||
buffer = new byte[sectors.size () * disk.getBlockSize ()];
|
this.formattedDisk = formattedDisk;
|
||||||
|
|
||||||
for (DiskAddress da : sectors)
|
Disk disk = formattedDisk.getDisk ();
|
||||||
{
|
int ptr = 0;
|
||||||
if (!disk.isValidAddress (da))
|
buffer = new byte[sectors.size () * disk.getBlockSize ()];
|
||||||
break;
|
|
||||||
byte[] tempBuffer = disk.readSector (da);
|
for (DiskAddress da : sectors)
|
||||||
System.arraycopy (tempBuffer, 0, buffer, ptr, disk.getBlockSize ());
|
{
|
||||||
ptr += disk.getBlockSize ();
|
if (!disk.isValidAddress (da))
|
||||||
}
|
break;
|
||||||
}
|
byte[] tempBuffer = disk.readSector (da);
|
||||||
|
System.arraycopy (tempBuffer, 0, buffer, ptr, disk.getBlockSize ());
|
||||||
@Override
|
ptr += disk.getBlockSize ();
|
||||||
public String getText ()
|
}
|
||||||
{
|
}
|
||||||
StringBuilder text = new StringBuilder ("Block Sector Type Owner\n");
|
|
||||||
text.append (
|
// ---------------------------------------------------------------------------------//
|
||||||
"----- ------------------ ---------------------------------------------\n");
|
@Override
|
||||||
|
public String getText ()
|
||||||
for (DiskAddress da : sectors)
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
SectorType sectorType = formattedDisk.getSectorType (da);
|
StringBuilder text = new StringBuilder ("Block Sector Type Owner\n");
|
||||||
String owner = formattedDisk.getSectorFilename (da);
|
text.append (
|
||||||
if (owner == null)
|
"----- ------------------ ---------------------------------------------\n");
|
||||||
owner = "";
|
|
||||||
text.append (
|
for (DiskAddress da : sectors)
|
||||||
String.format (" %04X %-18s %s%n", da.getBlock (), sectorType.name, owner));
|
{
|
||||||
}
|
SectorType sectorType = formattedDisk.getSectorType (da);
|
||||||
|
String owner = formattedDisk.getSectorFilename (da);
|
||||||
return text.toString ();
|
if (owner == null)
|
||||||
}
|
owner = "";
|
||||||
|
text.append (
|
||||||
|
String.format (" %04X %-18s %s%n", da.getBlock (), sectorType.name, owner));
|
||||||
|
}
|
||||||
|
|
||||||
|
return text.toString ();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -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 + ";");
|
||||||
|
|
|
@ -1,21 +1,27 @@
|
||||||
package com.bytezone.diskbrowser.disk;
|
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 Color colour;
|
{
|
||||||
|
public final String name;
|
||||||
public SectorType (String name, Color colour)
|
public final Color colour;
|
||||||
{
|
|
||||||
this.name = name;
|
// ---------------------------------------------------------------------------------//
|
||||||
this.colour = colour;
|
public SectorType (String name, Color colour)
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
@Override
|
this.name = name;
|
||||||
public String toString ()
|
this.colour = colour;
|
||||||
{
|
}
|
||||||
return String.format ("[SectorType : %s, %s]", name, colour);
|
|
||||||
}
|
// ---------------------------------------------------------------------------------//
|
||||||
|
@Override
|
||||||
|
public String toString ()
|
||||||
|
// ---------------------------------------------------------------------------------//
|
||||||
|
{
|
||||||
|
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