fixed exposure of setSectorTypes()
This commit is contained in:
parent
cd24a6b780
commit
4b989b0ad8
|
@ -8,19 +8,19 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
|||
|
||||
public class PascalSegment extends AbstractFile implements PascalConstants
|
||||
{
|
||||
int segmentNoHeader;
|
||||
int segmentNoBody;
|
||||
private final int segmentNoHeader;
|
||||
private int segmentNoBody;
|
||||
public final int blockNo;
|
||||
public final int size;
|
||||
List<PascalProcedure> procedures;
|
||||
int segKind;
|
||||
int textAddress;
|
||||
int machineType;
|
||||
int version;
|
||||
int intrinsSegs1;
|
||||
int intrinsSegs2;
|
||||
int slot;
|
||||
int totalProcedures;
|
||||
private List<PascalProcedure> procedures;
|
||||
private final int segKind;
|
||||
private final int textAddress;
|
||||
private final int machineType;
|
||||
private final int version;
|
||||
private final int intrinsSegs1;
|
||||
private final int intrinsSegs2;
|
||||
private final int slot;
|
||||
private int totalProcedures;
|
||||
|
||||
public PascalSegment (String name, byte[] fullBuffer, int seq)
|
||||
{
|
||||
|
@ -29,29 +29,28 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
|||
this.blockNo = HexFormatter.intValue (fullBuffer[seq * 4], fullBuffer[seq * 4 + 1]);
|
||||
this.size = HexFormatter.intValue (fullBuffer[seq * 4 + 2], fullBuffer[seq * 4 + 3]);
|
||||
this.segmentNoHeader = fullBuffer[0x100 + seq * 2];
|
||||
segKind =
|
||||
HexFormatter.intValue (fullBuffer[0xC0 + seq * 2], fullBuffer[0xC0 + seq * 2 + 1]);
|
||||
textAddress =
|
||||
HexFormatter.intValue (fullBuffer[0xE0 + seq * 2], fullBuffer[0xE0 + seq * 2 + 1]);
|
||||
segKind = HexFormatter.intValue (fullBuffer[0xC0 + seq * 2],
|
||||
fullBuffer[0xC0 + seq * 2 + 1]);
|
||||
textAddress = HexFormatter.intValue (fullBuffer[0xE0 + seq * 2],
|
||||
fullBuffer[0xE0 + seq * 2 + 1]);
|
||||
int flags = fullBuffer[0x101 + seq * 2] & 0xFF;
|
||||
machineType = flags & 0x0F;
|
||||
version = (flags & 0xD0) >> 5;
|
||||
intrinsSegs1 =
|
||||
HexFormatter.intValue (fullBuffer[0x120 + seq * 4], fullBuffer[0x120 + seq * 4 + 1]);
|
||||
intrinsSegs2 =
|
||||
HexFormatter.intValue (fullBuffer[0x120 + seq * 4 + 2],
|
||||
fullBuffer[0x120 + seq * 4 + 3]);
|
||||
intrinsSegs1 = HexFormatter.intValue (fullBuffer[0x120 + seq * 4],
|
||||
fullBuffer[0x120 + seq * 4 + 1]);
|
||||
intrinsSegs2 = HexFormatter.intValue (fullBuffer[0x120 + seq * 4 + 2],
|
||||
fullBuffer[0x120 + seq * 4 + 3]);
|
||||
|
||||
int offset = blockNo * 512;
|
||||
if (offset < fullBuffer.length)
|
||||
{
|
||||
buffer = new byte[size]; // replaces this.buffer with the segment buffer only
|
||||
buffer = new byte[size]; // replaces this.buffer with the segment buffer only
|
||||
System.arraycopy (fullBuffer, blockNo * 512, buffer, 0, size);
|
||||
totalProcedures = buffer[size - 1] & 0xFF;
|
||||
segmentNoBody = buffer[size - 2] & 0xFF;
|
||||
if (segmentNoBody != segmentNoHeader)
|
||||
System.out.println ("Segment number mismatch : " + segmentNoBody + " / "
|
||||
+ segmentNoHeader);
|
||||
+ segmentNoHeader);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -71,9 +70,9 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
|||
public String toText ()
|
||||
{
|
||||
return String
|
||||
.format (" %2d %02X %04X %,6d %-8s %-15s %3d %3d %d %d %d %d",
|
||||
slot, blockNo, size, size, name, SegmentKind[segKind], textAddress,
|
||||
segmentNoHeader, machineType, version, intrinsSegs1, intrinsSegs2);
|
||||
.format (" %2d %02X %04X %,6d %-8s %-15s %3d %3d %d %d %d %d",
|
||||
slot, blockNo, size, size, name, SegmentKind[segKind], textAddress,
|
||||
segmentNoHeader, machineType, version, intrinsSegs1, intrinsSegs2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -85,9 +84,9 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
|||
StringBuilder text = new StringBuilder ();
|
||||
String title = "Segment - " + name;
|
||||
text.append (title + "\n"
|
||||
+ "===============================".substring (0, title.length ()) + "\n\n");
|
||||
+ "===============================".substring (0, title.length ()) + "\n\n");
|
||||
String warning =
|
||||
segmentNoBody == segmentNoHeader ? "" : " (" + segmentNoHeader + " in header)";
|
||||
segmentNoBody == segmentNoHeader ? "" : " (" + segmentNoHeader + " in header)";
|
||||
text.append (String.format ("Address........ %02X%n", blockNo));
|
||||
text.append (String.format ("Length......... %04X%n", buffer.length));
|
||||
text.append (String.format ("Machine type... %d%n", machineType));
|
||||
|
@ -109,10 +108,11 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
|||
{
|
||||
int address = size - procedure.slot * 2 - 2;
|
||||
text.append (String
|
||||
.format (" %2d %04X %3d %04X %04X %04X %04X (%04X - %04X = %04X)%n",
|
||||
procedure.procedureNo, procedure.offset, procedure.procLevel,
|
||||
procedure.codeStart, procedure.codeEnd, procedure.parmSize,
|
||||
procedure.dataSize, address, procedure.offset, procedure.procOffset));
|
||||
.format (" %2d %04X %3d %04X %04X %04X %04X (%04X - %04X = %04X)%n",
|
||||
procedure.procedureNo, procedure.offset, procedure.procLevel,
|
||||
procedure.codeStart, procedure.codeEnd, procedure.parmSize,
|
||||
procedure.dataSize, address, procedure.offset,
|
||||
procedure.procOffset));
|
||||
}
|
||||
else
|
||||
text.append (String.format (" %2d %04X%n", procedure.slot, procedure.offset));
|
||||
|
@ -123,7 +123,8 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
|||
{
|
||||
List<PascalCodeStatement> strings = pp.extractStrings ();
|
||||
for (PascalCodeStatement cs : strings)
|
||||
text.append (String.format (" %2d %04X %s%n", pp.procedureNo, cs.ptr, cs.text));
|
||||
text.append (String.format (" %2d %04X %s%n", pp.procedureNo, cs.ptr,
|
||||
cs.text));
|
||||
}
|
||||
|
||||
for (PascalProcedure procedure : procedures)
|
||||
|
|
|
@ -39,8 +39,7 @@ public class CPMDisk extends AbstractFormattedDisk
|
|||
sectorTypesList.add (macSector);
|
||||
sectorTypesList.add (otherSector);
|
||||
|
||||
getDisk ().setEmptyByte ((byte) 0xE5);
|
||||
setSectorTypes ();
|
||||
setEmptyByte ((byte) 0xE5);
|
||||
|
||||
byte[] buffer = disk.readSector (0, 8);
|
||||
String text = new String (buffer, 16, 24);
|
||||
|
|
|
@ -93,7 +93,13 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||
});
|
||||
}
|
||||
|
||||
protected void setSectorTypes ()
|
||||
protected void setEmptyByte (byte value)
|
||||
{
|
||||
getDisk ().setEmptyByte ((byte) 0xE5);
|
||||
setSectorTypes ();
|
||||
}
|
||||
|
||||
private void setSectorTypes ()
|
||||
{
|
||||
sectorTypes = new SectorType[disk.getTotalBlocks ()];
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.bytezone.diskbrowser.infocom;
|
||||
|
||||
import static java.lang.System.out;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -22,8 +20,8 @@ public class InfocomDisk extends AbstractFormattedDisk
|
|||
private static final boolean TYPE_NODE = true;
|
||||
private static final boolean TYPE_LEAF = false;
|
||||
private byte[] data;
|
||||
int version;
|
||||
Header header;
|
||||
private int version;
|
||||
private final Header header;
|
||||
|
||||
Color green = new Color (0, 200, 0);
|
||||
|
||||
|
@ -41,7 +39,7 @@ public class InfocomDisk extends AbstractFormattedDisk
|
|||
{
|
||||
super (disk);
|
||||
|
||||
setSectorTypes ();
|
||||
setInfocomSectorTypes ();
|
||||
|
||||
data = disk.readSector (3, 0); // read first sector to get file size
|
||||
data = getBuffer (getWord (26) * 2); // read entire file into data buffer
|
||||
|
@ -85,8 +83,7 @@ public class InfocomDisk extends AbstractFormattedDisk
|
|||
setSectors (header.stringPointer, header.fileLength, stringsSector);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setSectorTypes ()
|
||||
protected void setInfocomSectorTypes ()
|
||||
{
|
||||
sectorTypesList.add (bootSector);
|
||||
sectorTypesList.add (headerSector);
|
||||
|
@ -125,7 +122,7 @@ public class InfocomDisk extends AbstractFormattedDisk
|
|||
{
|
||||
if (da.getBlock () > startBlock && disk.isSectorEmpty (da))
|
||||
{
|
||||
out.println ("Empty : " + da);
|
||||
System.out.println ("Empty : " + da);
|
||||
buffer = disk.readSector (da.getBlock () - 1);
|
||||
fileSize = (da.getBlock () - 48) * disk.getBlockSize ();
|
||||
break;
|
||||
|
@ -141,7 +138,7 @@ public class InfocomDisk extends AbstractFormattedDisk
|
|||
{
|
||||
if (fileSize == 0)
|
||||
fileSize = getFileSize ();
|
||||
System.out.println ("File size : " + fileSize);
|
||||
// System.out.println ("File size : " + fileSize);
|
||||
data = new byte[fileSize];
|
||||
|
||||
for (int track = 3, ptr = 0; track < 35; track++)
|
||||
|
|
|
@ -20,21 +20,27 @@ class FileEntry extends CatalogEntry
|
|||
case 2:
|
||||
parent.sectorTypes[i] = parent.codeSector;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
parent.sectorTypes[i] = parent.textSector;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
parent.sectorTypes[i] = parent.infoSector;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
parent.sectorTypes[i] = parent.dataSector;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
parent.sectorTypes[i] = parent.grafSector;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
parent.sectorTypes[i] = parent.fotoSector;
|
||||
break;
|
||||
|
||||
default:
|
||||
System.out.println ("Unknown pascal file type : " + fileType);
|
||||
parent.sectorTypes[i] = parent.dataSector;
|
||||
|
|
|
@ -76,6 +76,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
sectors.add (da);
|
||||
freeBlocks.set (i, false);
|
||||
}
|
||||
|
||||
buffer = disk.readSectors (sectors);
|
||||
diskCatalogSector = new PascalCatalogSector (disk, buffer); // uses all 4 sectors
|
||||
|
||||
|
@ -94,18 +95,18 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
{
|
||||
int ptr = i * CATALOG_ENTRY_SIZE;
|
||||
data = new byte[CATALOG_ENTRY_SIZE];
|
||||
|
||||
System.arraycopy (buffer, ptr, data, 0, CATALOG_ENTRY_SIZE);
|
||||
FileEntry fe = new FileEntry (this, data);
|
||||
fileEntries.add (fe);
|
||||
DefaultMutableTreeNode node = new DefaultMutableTreeNode (fe);
|
||||
|
||||
if (fe.fileType == 2) // PascalCode
|
||||
if (fe.fileType == 2) // PascalCode
|
||||
{
|
||||
node.setAllowsChildren (true);
|
||||
PascalCode pc = (PascalCode) fe.getDataSource ();
|
||||
for (PascalSegment ps : pc)
|
||||
{
|
||||
// List<DiskAddress> blocks = new ArrayList<DiskAddress> ();
|
||||
DefaultMutableTreeNode segmentNode =
|
||||
new DefaultMutableTreeNode (new PascalCodeObject (this, ps, fe.firstBlock));
|
||||
node.add (segmentNode);
|
||||
|
@ -114,6 +115,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
}
|
||||
else
|
||||
node.setAllowsChildren (false);
|
||||
|
||||
volumeNode.add (node);
|
||||
for (int j = fe.firstBlock; j < fe.lastBlock; j++)
|
||||
freeBlocks.set (j, false);
|
||||
|
@ -138,6 +140,8 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
public static boolean checkFormat (AppleDisk disk, boolean debug)
|
||||
{
|
||||
byte[] buffer = disk.readSector (2);
|
||||
if (debug)
|
||||
System.out.println (HexFormatter.format (buffer));
|
||||
int nameLength = HexFormatter.intValue (buffer[6]);
|
||||
if (nameLength < 1 || nameLength > 7)
|
||||
{
|
||||
|
@ -145,6 +149,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
System.out.println ("bad name length : " + nameLength);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
String name = HexFormatter.getPascalString (buffer, 6);
|
||||
|
@ -154,19 +159,24 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
int from = HexFormatter.intValue (buffer[0], buffer[1]);
|
||||
int to = HexFormatter.intValue (buffer[2], buffer[3]);
|
||||
if (from != 0 || to != 6)
|
||||
return false; // will only work for floppies!
|
||||
{
|
||||
if (debug)
|
||||
System.out.printf ("from: %d, to: %d%n", from, to);
|
||||
return false; // will only work for floppies!
|
||||
}
|
||||
|
||||
List<DiskAddress> addresses = new ArrayList<DiskAddress> ();
|
||||
for (int i = 2; i < to; i++)
|
||||
addresses.add (disk.getDiskAddress (i));
|
||||
buffer = disk.readSectors (addresses);
|
||||
|
||||
int blocks = HexFormatter.intValue (buffer[14], buffer[15]);
|
||||
if (blocks > 280)
|
||||
return false;
|
||||
int files = HexFormatter.intValue (buffer[16], buffer[17]);
|
||||
if (files < 0 || files > 77)
|
||||
{
|
||||
if (debug)
|
||||
System.out.printf ("Files: %d%n", files);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
System.out.println ("Files found : " + files);
|
||||
|
@ -184,6 +194,17 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||
nameLength = HexFormatter.intValue (buffer[ptr + 6]);
|
||||
if (nameLength < 1 || nameLength > 15)
|
||||
return false;
|
||||
if (debug)
|
||||
System.out.printf ("%4d %4d %d %s%n", a, b, c,
|
||||
new String (buffer, ptr + 7, nameLength));
|
||||
}
|
||||
|
||||
int blocks = HexFormatter.intValue (buffer[14], buffer[15]);
|
||||
if (blocks > 280)
|
||||
{
|
||||
if (debug)
|
||||
System.out.printf ("Blocks: %d%n", blocks);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -6,8 +6,8 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
|||
|
||||
class VolumeEntry extends CatalogEntry
|
||||
{
|
||||
int totalFiles;
|
||||
int totalBlocks;
|
||||
final int totalFiles;
|
||||
final int totalBlocks;
|
||||
|
||||
public VolumeEntry (PascalDisk parent, byte[] buffer)
|
||||
{
|
||||
|
@ -17,9 +17,6 @@ class VolumeEntry extends CatalogEntry
|
|||
totalFiles = HexFormatter.intValue (buffer[16], buffer[17]);
|
||||
firstBlock = HexFormatter.intValue (buffer[18], buffer[19]);
|
||||
date = HexFormatter.getPascalDate (buffer, 20);
|
||||
|
||||
// for (int i = firstBlock; i < lastBlock; i++)
|
||||
// sectorType[i] = catalogSector;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue