This commit is contained in:
Denis Molony 2016-02-28 18:17:58 +11:00
parent 7603a89c3a
commit 087ad914b4
10 changed files with 117 additions and 121 deletions

View File

@ -4,16 +4,16 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
abstract class DirectoryHeader extends CatalogEntry
{
int entryLength;
int entriesPerBlock;
int fileCount;
final int entryLength;
final int entriesPerBlock;
final int fileCount;
public DirectoryHeader (ProdosDisk parentDisk, byte[] entryBuffer)
{
super (parentDisk, entryBuffer);
public DirectoryHeader (ProdosDisk parentDisk, byte[] entryBuffer)
{
super (parentDisk, entryBuffer);
entryLength = HexFormatter.intValue (entryBuffer[31]);
entriesPerBlock = HexFormatter.intValue (entryBuffer[32]);
fileCount = HexFormatter.intValue (entryBuffer[33], entryBuffer[34]);
}
entryLength = HexFormatter.intValue (entryBuffer[31]);
entriesPerBlock = HexFormatter.intValue (entryBuffer[32]);
fileCount = HexFormatter.intValue (entryBuffer[33], entryBuffer[34]);
}
}

View File

@ -77,8 +77,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
case TYPE_GSOS_EXTENDED_FILE:
parentDisk.setSectorType (keyPtr, fDisk.extendedKeySector);
indexBlocks.add (disk.getDiskAddress (keyPtr));
byte[] buffer2 = disk.readSector (keyPtr);
// data fork and resource fork
byte[] buffer2 = disk.readSector (keyPtr); // data fork and resource fork
for (int i = 0; i < 512; i += 256)
{
int storageType = buffer2[i] & 0x0F;
@ -536,6 +536,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
return sectors;
}
@Override
public boolean contains (DiskAddress da)
{
if (da.equals (masterIndexBlock))

View File

@ -8,8 +8,8 @@ import com.bytezone.diskbrowser.disk.DiskAddress;
class ProdosBitMapSector extends AbstractSector
{
DiskAddress da;
ProdosDisk parent;
private final DiskAddress da;
private final ProdosDisk parent;
ProdosBitMapSector (ProdosDisk parent, Disk disk, byte[] buffer, DiskAddress da)
{
@ -26,8 +26,6 @@ class ProdosBitMapSector extends AbstractSector
// check range of bits for current block - so far I don't have a disk that needs
// more than a single block
int relativeBlock = da.getBlock () - parent.vdh.bitMapBlock;
// System.out.println ("rel " + relativeBlock);
// System.out.println ("width : " + grid.width);
int startBit = relativeBlock * 4096;
int endBit = startBit + 4096;
if (startBit >= grid.width * grid.height)
@ -55,7 +53,7 @@ class ProdosBitMapSector extends AbstractSector
int endRow = startRow + (512 / width);
int block = startBit;
int byteNo = 0;
// System.out.printf ("Start %d, end %d%n", startRow, endRow);
// System.out.printf ("Start %d, end %d%n", startRow, endRow);
for (int row = startRow; row < endRow; row++)
{
StringBuilder details = new StringBuilder ();

View File

@ -33,32 +33,31 @@ interface ProdosConstants
int TYPE_SEEDLING = 1;
int TYPE_FREE = 0;
String[] fileTypes = { "NON", "BAD", "PCD", "PTX", "TXT", "PDA", "BIN", "FNT", "FOT", "BA3",
"DA3", "WPF", "SOS", "$0D", "$0E", "DIR", "RPD", "RPI", "AFD", "AFM",
"AFR", "SCL", "PFS", "$17", "$18", "ADB", "AWP", "ASP", "$1C", "$1D",
"$1E", "$1F", "TDM", "$21", "$22", "$23", "$24", "$25", "$26", "$27",
"$28", "$29", "8SC", "8OB", "8IC", "8LD", "P8C", "$2F", "$30", "$31",
"$32", "$33", "$34", "$35", "$36", "$37", "$38", "$39", "$3A", "$3B",
"$3C", "$3D", "$3E", "$3F", "DIC", "OCR", "FTD", "$43", "$44", "$45",
"$46", "$47", "$48", "$49", "$4A", "$4B", "$4C", "$4D", "$4E", "$4F",
"GWP", "GSS", "GDB", "DRW", "GDP", "HMD", "EDU", "STN", "HLP", "COM",
"CFG", "ANM", "MUM", "ENT", "DVU", "FIN", "$60", "$61", "$62", "$63",
"$64", "$65", "$66", "$67", "$68", "$69", "$6A", "BIO", "$6C", "TDR",
"PRE", "HDV", "$70", "$71", "$72", "$73", "$74", "$75", "$76", "$77",
"$78", "$79", "$7A", "$7B", "$7C", "$7D", "$7E", "$7F", "GES", "GEA",
"GEO", "GED", "GEF", "GEP", "GEI", "GEX", "$88", "GEV", "$8A", "GEC",
"GEK", "GEW", "$8E", "$8F", "$90", "$91", "$92", "$93", "$94", "$95",
"$96", "$97", "$98", "$99", "$9A", "$9B", "$9C", "$9D", "$9E", "$9F",
"WP ", "$A1", "$A2", "$A3", "$A4", "$A5", "$A6", "$A7", "$A8", "$A9",
"$AA", "GSB", "TDF", "BDF", "$AE", "$AF", "SRC", "OBJ", "LIB", "S16",
"RTL", "EXE", "PIF", "TIF", "NDA", "CDA", "TOL", "DVR", "LDF", "FST",
"$BE", "DOC", "PNT", "PIC", "ANI", "PAL", "$C4", "OOG", "SCR", "CDV",
"FON", "FND", "ICN", "$CB", "$CC", "$CD", "$CE", "$CF", "$D0", "$D1",
"$D2", "$D3", "$D4", "MUS", "INS", "MDI", "SND", "$D9", "$DA", "DBM",
"$DC", "DDD", "$DE", "$DF", "LBR", "$E1", "ATK", "$E3", "$E4", "$E5",
"$E6", "$E7", "$E8", "$E9", "$EA", "$EB", "$EC", "$ED", "R16", "PAS",
"CMD", "$F1", "$F2", "$F3", "$F4", "$F5", "$F6", "$F7", "$F8", "OS ",
"INT", "IVR", "BAS", "VAR", "REL", "SYS" };
String[] fileTypes =
{ "NON", "BAD", "PCD", "PTX", "TXT", "PDA", "BIN", "FNT", "FOT", "BA3", "DA3",
"WPF", "SOS", "$0D", "$0E", "DIR", "RPD", "RPI", "AFD", "AFM", "AFR", "SCL",
"PFS", "$17", "$18", "ADB", "AWP", "ASP", "$1C", "$1D", "$1E", "$1F", "TDM",
"$21", "$22", "$23", "$24", "$25", "$26", "$27", "$28", "$29", "8SC", "8OB",
"8IC", "8LD", "P8C", "$2F", "$30", "$31", "$32", "$33", "$34", "$35", "$36",
"$37", "$38", "$39", "$3A", "$3B", "$3C", "$3D", "$3E", "$3F", "DIC", "OCR",
"FTD", "$43", "$44", "$45", "$46", "$47", "$48", "$49", "$4A", "$4B", "$4C",
"$4D", "$4E", "$4F", "GWP", "GSS", "GDB", "DRW", "GDP", "HMD", "EDU", "STN",
"HLP", "COM", "CFG", "ANM", "MUM", "ENT", "DVU", "FIN", "$60", "$61", "$62",
"$63", "$64", "$65", "$66", "$67", "$68", "$69", "$6A", "BIO", "$6C", "TDR",
"PRE", "HDV", "$70", "$71", "$72", "$73", "$74", "$75", "$76", "$77", "$78",
"$79", "$7A", "$7B", "$7C", "$7D", "$7E", "$7F", "GES", "GEA", "GEO", "GED",
"GEF", "GEP", "GEI", "GEX", "$88", "GEV", "$8A", "GEC", "GEK", "GEW", "$8E",
"$8F", "$90", "$91", "$92", "$93", "$94", "$95", "$96", "$97", "$98", "$99",
"$9A", "$9B", "$9C", "$9D", "$9E", "$9F", "WP ", "$A1", "$A2", "$A3", "$A4",
"$A5", "$A6", "$A7", "$A8", "$A9", "$AA", "GSB", "TDF", "BDF", "$AE", "$AF",
"SRC", "OBJ", "LIB", "S16", "RTL", "EXE", "PIF", "TIF", "NDA", "CDA", "TOL",
"DVR", "LDF", "FST", "$BE", "DOC", "PNT", "PIC", "ANI", "PAL", "$C4", "OOG",
"SCR", "CDV", "FON", "FND", "ICN", "$CB", "$CC", "$CD", "$CE", "$CF", "$D0",
"$D1", "$D2", "$D3", "$D4", "MUS", "INS", "MDI", "SND", "$D9", "$DA", "DBM",
"$DC", "DDD", "$DE", "$DF", "LBR", "$E1", "ATK", "$E3", "$E4", "$E5", "$E6",
"$E7", "$E8", "$E9", "$EA", "$EB", "$EC", "$ED", "R16", "PAS", "CMD", "$F1",
"$F2", "$F3", "$F4", "$F5", "$F6", "$F7", "$F8", "OS ", "INT", "IVR", "BAS",
"VAR", "REL", "SYS" };
int ENTRY_SIZE = 39;
int ENTRIES_PER_BLOCK = 13;

View File

@ -12,16 +12,16 @@ class ProdosDirectory extends AbstractFile
private static final String newLine = String.format ("%n");
private static final String newLine2 = newLine + newLine;
// private final Disk parent;
private final FormattedDisk parentFD;
private final int totalBlocks;
private final int freeBlocks;
private final int usedBlocks;
public ProdosDirectory (FormattedDisk parent, String name, byte[] buffer, int totalBlocks,
int freeBlocks, int usedBlocks)
public ProdosDirectory (FormattedDisk parent, String name, byte[] buffer,
int totalBlocks, int freeBlocks, int usedBlocks)
{
super (name, buffer);
this.parentFD = parent;
this.totalBlocks = totalBlocks;
this.freeBlocks = freeBlocks;
@ -37,7 +37,8 @@ class ProdosDirectory extends AbstractFile
{
int storageType = (buffer[i] & 0xF0) >> 4;
if (storageType == 0)
continue; // break??
continue; // break??
int nameLength = buffer[i] & 0x0F;
String filename = HexFormatter.getString (buffer, i + 1, nameLength);
String subType = "";
@ -49,8 +50,9 @@ class ProdosDirectory extends AbstractFile
case ProdosConstants.TYPE_SUBDIRECTORY_HEADER:
text.append ("/" + filename + newLine2);
text.append (" NAME TYPE BLOCKS "
+ "MODIFIED CREATED ENDFILE SUBTYPE" + newLine2);
+ "MODIFIED CREATED ENDFILE SUBTYPE" + newLine2);
break;
case ProdosConstants.TYPE_FREE:
case ProdosConstants.TYPE_SEEDLING:
case ProdosConstants.TYPE_SAPLING:
@ -62,16 +64,17 @@ class ProdosDirectory extends AbstractFile
int blocks = HexFormatter.intValue (buffer[i + 19], buffer[i + 20]);
GregorianCalendar created = HexFormatter.getAppleDate (buffer, i + 24);
String dateC =
created == null ? NO_DATE : ProdosDisk.sdf.format (created.getTime ())
.toUpperCase ();
String timeC = created == null ? "" : ProdosDisk.stf.format (created.getTime ());
String dateC = created == null ? NO_DATE
: ProdosDisk.sdf.format (created.getTime ()).toUpperCase ();
String timeC =
created == null ? "" : ProdosDisk.stf.format (created.getTime ());
GregorianCalendar modified = HexFormatter.getAppleDate (buffer, i + 33);
String dateM =
modified == null ? NO_DATE : ProdosDisk.sdf.format (modified.getTime ())
.toUpperCase ();
String timeM = modified == null ? "" : ProdosDisk.stf.format (modified.getTime ());
int eof = HexFormatter.intValue (buffer[i + 21], buffer[i + 22], buffer[i + 23]);
String dateM = modified == null ? NO_DATE
: ProdosDisk.sdf.format (modified.getTime ()).toUpperCase ();
String timeM =
modified == null ? "" : ProdosDisk.stf.format (modified.getTime ());
int eof =
HexFormatter.intValue (buffer[i + 21], buffer[i + 22], buffer[i + 23]);
int fileType = HexFormatter.intValue (buffer[i + 16]);
locked = (buffer[i + 30] & 0xE0) == 0xE0 ? " " : "*";
@ -94,17 +97,18 @@ class ProdosDirectory extends AbstractFile
subType = "";
}
text.append (String.format ("%s%-15s %3s %5d %9s %5s %9s %5s %8d %7s%n", locked,
filename, ProdosConstants.fileTypes[type], blocks,
dateM, timeM, dateC, timeC, eof, subType));
text.append (String.format ("%s%-15s %3s %5d %9s %5s %9s %5s %8d %7s%n",
locked, filename, ProdosConstants.fileTypes[type],
blocks, dateM, timeM, dateC, timeC, eof, subType));
break;
default:
text.append (" <Unknown strage type : " + storageType + newLine);
}
}
text.append (String
.format ("%nBLOCKS FREE:%5d BLOCKS USED:%5d TOTAL BLOCKS:%5d%n", freeBlocks,
usedBlocks, totalBlocks));
text.append (String.format (
"%nBLOCKS FREE:%5d BLOCKS USED:%5d TOTAL BLOCKS:%5d%n",
freeBlocks, usedBlocks, totalBlocks));
return text.toString ();
}

View File

@ -16,8 +16,12 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
public class ProdosDisk extends AbstractFormattedDisk
{
protected static final DateFormat df = DateFormat.getInstance ();
protected static final SimpleDateFormat sdf = new SimpleDateFormat ("d-MMM-yy");
protected static final SimpleDateFormat stf = new SimpleDateFormat ("H:mm");
final SectorType dosSector = new SectorType ("Bootstrap Loader", Color.lightGray);
final SectorType catalogSector = new SectorType ("Catalog", new Color (0, 200, 0)); // green
final SectorType catalogSector = new SectorType ("Catalog", new Color (0, 200, 0));
final SectorType volumeMapSector = new SectorType ("Volume Map", Color.blue);
final SectorType subcatalogSector = new SectorType ("Subcatalog", Color.magenta);
final SectorType masterIndexSector = new SectorType ("Master Index", Color.orange);
@ -26,12 +30,9 @@ public class ProdosDisk extends AbstractFormattedDisk
final SectorType extendedKeySector = new SectorType ("Extended key", Color.gray);
private final List<DirectoryHeader> headerEntries = new ArrayList<DirectoryHeader> ();
VolumeDirectoryHeader vdh = null;
private static final boolean debug = false;
protected VolumeDirectoryHeader vdh;
static final DateFormat df = DateFormat.getInstance ();
static final SimpleDateFormat sdf = new SimpleDateFormat ("d-MMM-yy");
static final SimpleDateFormat stf = new SimpleDateFormat ("H:mm");
private static final boolean debug = false;
public ProdosDisk (Disk disk)
{
@ -106,7 +107,7 @@ public class ProdosDisk extends AbstractFormattedDisk
sectorTypes[block] = currentSectorType;
for (int i = 0; i < vdh.totalBitMapBlocks; i++)
sectorTypes[vdh.bitMapBlock + i] = volumeMapSector;
parentNode.setUserObject (vdh); // populate the empty volume node
parentNode.setUserObject (vdh); // populate the empty volume node
break;
case ProdosConstants.TYPE_SUBDIRECTORY_HEADER:
@ -122,7 +123,7 @@ public class ProdosDisk extends AbstractFormattedDisk
DefaultMutableTreeNode directoryNode = new DefaultMutableTreeNode (ce);
directoryNode.setAllowsChildren (true);
parentNode.add (directoryNode);
processDirectoryBlock (ce.keyPtr, ce, directoryNode); // Recursion !!
processDirectoryBlock (ce.keyPtr, ce, directoryNode); // Recursion !!
break;
case ProdosConstants.TYPE_SEEDLING:
@ -239,15 +240,6 @@ public class ProdosDisk extends AbstractFormattedDisk
return super.getFormattedSector (da);
}
// @Override
// public String getSectorFilename (DiskAddress da)
// {
// for (AppleFileSource fe : fileEntries)
// if (((FileEntry) fe).contains (da))
// return ((FileEntry) fe).getUniqueName ();
// return null;
// }
@Override
public List<DiskAddress> getFileSectors (int fileNo)
{

View File

@ -5,7 +5,6 @@ import com.bytezone.diskbrowser.disk.Disk;
class ProdosExtendedKeySector extends AbstractSector
{
public ProdosExtendedKeySector (Disk disk, byte[] buffer)
{
super (disk, buffer);

View File

@ -6,7 +6,7 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
class ProdosIndexSector extends AbstractSector
{
String name;
private final String name;
ProdosIndexSector (String name, Disk disk, byte[] buffer)
{
@ -21,10 +21,12 @@ class ProdosIndexSector extends AbstractSector
for (int i = 0; i < 256; i++)
{
text.append (String.format ("%02X %02X %02X", i, buffer[i], buffer[i + 256]));
text.append (String.format ("%02X %02X %02X", i, buffer[i],
buffer[i + 256]));
if (buffer[i] != 0 || buffer[i + 256] != 0)
text.append (String.format (" %s%n",
"block " + HexFormatter.intValue (buffer[i], buffer[i + 256])));
text.append (String
.format (" %s%n",
"block " + HexFormatter.intValue (buffer[i], buffer[i + 256])));
else
text.append ("\n");
}

View File

@ -8,36 +8,38 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
class SubDirectoryHeader extends DirectoryHeader
{
int parentPointer;
int parentSequence;
int parentSize;
private final int parentPointer;
private final int parentSequence;
private final int parentSize;
public SubDirectoryHeader (ProdosDisk parentDisk, byte[] entryBuffer, FileEntry parent)
{
super (parentDisk, entryBuffer);
this.parentDirectory = parent.parentDirectory;
public SubDirectoryHeader (ProdosDisk parentDisk, byte[] entryBuffer, FileEntry parent)
{
super (parentDisk, entryBuffer);
this.parentDirectory = parent.parentDirectory;
parentPointer = HexFormatter.intValue (entryBuffer[35], entryBuffer[36]);
parentSequence = HexFormatter.intValue (entryBuffer[37]);
parentSize = HexFormatter.intValue (entryBuffer[38]);
}
parentPointer = HexFormatter.intValue (entryBuffer[35], entryBuffer[36]);
parentSequence = HexFormatter.intValue (entryBuffer[37]);
parentSize = HexFormatter.intValue (entryBuffer[38]);
}
@Override
public String toString ()
{
String locked = (access == 0x01) ? "*" : " ";
return String.format (" %s%-40s %15s", locked, "/" + name, ProdosDisk.df.format (created
.getTime ()));
}
@Override
public String toString ()
{
String locked = (access == 0x01) ? "*" : " ";
return String.format (" %s%-40s %15s", locked, "/" + name,
ProdosDisk.df.format (created.getTime ()));
}
public DataSource getDataSource ()
{
// should this return a directory listing?
return null;
}
@Override
public DataSource getDataSource ()
{
// should this return a directory listing?
return null;
}
public List<DiskAddress> getSectors ()
{
return null;
}
@Override
public List<DiskAddress> getSectors ()
{
return null;
}
}

View File

@ -13,11 +13,11 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
*/
class VolumeDirectoryHeader extends DirectoryHeader
{
int bitMapBlock;
int totalBlocks;
int freeBlocks;
int usedBlocks;
int totalBitMapBlocks;
protected final int bitMapBlock;
protected int totalBlocks;
protected int freeBlocks;
protected int usedBlocks;
protected int totalBitMapBlocks;
public VolumeDirectoryHeader (ProdosDisk parentDisk, byte[] entryBuffer)
{
@ -57,10 +57,9 @@ class VolumeDirectoryHeader extends DirectoryHeader
block = 0;
// nb dual-dos disk needs to use totalBlocks obtained from disk
// int max1 = (totalBlocks - 1) / 8 + 1; // bytes required for sector map
// nb disk may be truncated, so use actual number of blocks
// nb1 dual-dos disk needs to use totalBlocks obtained from disk
// int max1 = (totalBlocks - 1) / 8 + 1; // bytes required for sector map
// nb2 hard disk may be truncated, so use actual number of blocks
// int max2 = (disk.getTotalBlocks () - 1) / 8 + 1; // bytes required for sector map
int max = (Math.min (totalBlocks, disk.getTotalBlocks ()) - 1) / 8 + 1;