Skip to content

Commit

Permalink
tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
dmolony committed Jun 13, 2024
1 parent 2bc330e commit 706c644
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 77 deletions.
10 changes: 6 additions & 4 deletions src/com/bytezone/diskbrowser/applefile/PascalProcedure.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class PascalProcedure
byte[] buffer;
int procOffset;
int offset;
int slot;
int procNo;
boolean valid;

// only valid procedures have these fields
Expand All @@ -30,12 +30,13 @@ public class PascalProcedure
int jumpTable = -8;

// ---------------------------------------------------------------------------------//
public PascalProcedure (byte[] buffer, int slot)
public PascalProcedure (byte[] buffer, int procNo)
// ---------------------------------------------------------------------------------//
{
this.buffer = buffer;
this.slot = slot;
int p = buffer.length - 2 - slot * 2;
this.procNo = procNo;

int p = buffer.length - 2 - procNo * 2;
offset = Utility.getShort (buffer, p);
procOffset = p - offset;
valid = procOffset > 0;
Expand All @@ -57,6 +58,7 @@ private void decode ()
{
if (statements.size () > 0 || assembler != null)
return;

int ptr = procOffset - codeStart - 2;
int max = procOffset + jumpTable;

Expand Down
84 changes: 11 additions & 73 deletions src/com/bytezone/diskbrowser/applefile/PascalSegment.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class PascalSegment extends AbstractFile implements PascalConstants
final int segmentNoHeader;
private int segmentNoBody;
// private final int blockOffset;
// private final Relocator relocator;
boolean debug = false;

public int blockNo;
Expand All @@ -41,7 +40,6 @@ public PascalSegment (String name, byte[] fullBuffer, int seq, int blockOffset)

this.slot = seq;
// this.blockOffset = blockOffset;
// this.relocator = relocator;

this.blockNo = Utility.getShort (fullBuffer, seq * 4);
this.size = Utility.getShort (fullBuffer, seq * 4 + 2);
Expand All @@ -68,24 +66,6 @@ public PascalSegment (String name, byte[] fullBuffer, int seq, int blockOffset)

int offset = blockNo * 512;

// if (relocator != null)
// {
// // if (segmentNoHeader > 1)
// // {
// int sizeInBlocks = (size - 1) / BLOCK_SIZE + 1;
// int targetBlock = blockNo + blockOffset;
// addresses = relocator.getMultiDiskAddress (name, targetBlock, sizeInBlocks);
// if (addresses.size () > 0)
// {
// MultiDiskAddress multiDiskAddress = addresses.get (0);
// if (multiDiskAddress.diskNumber == 1)
// offset = (multiDiskAddress.physicalBlockNumber - blockOffset) * BLOCK_SIZE;
// else
// offset = -1;
// }
// // }
// }

if (offset < 0)
{
buffer = new byte[0];
Expand All @@ -110,11 +90,6 @@ else if (segmentNoBody != segmentNoHeader)
}
}

// void setMultiDiskAddresses (List<MultiDiskAddress> addresses)
// {
// this.addresses = addresses;
// }

// ---------------------------------------------------------------------------------//
private void buildProcedureList ()
// ---------------------------------------------------------------------------------//
Expand All @@ -132,10 +107,9 @@ public String toText ()
int sizeInBlocks = (size - 1) / BLOCK_SIZE + 1;

return String.format (
" %2d %02X %02X %04X %-8s %-15s%3d " + "%02X %d %d %d %d %s",
slot, blockNo, sizeInBlocks, size, name, SegmentKind[segKind], textAddress,
segmentNoHeader, machineType, version, intrinsSegs1, intrinsSegs2,
getMultiDiskAddresses ());
" %2d %02X %02X %04X %-8s %-15s%3d " + "%02X %d %d %d %d", slot,
blockNo, sizeInBlocks, size, name, SegmentKind[segKind], textAddress,
segmentNoHeader, machineType, version, intrinsSegs1, intrinsSegs2);
}

// ---------------------------------------------------------------------------------//
Expand All @@ -152,14 +126,13 @@ public String getText ()
+ "===============================".substring (0, title.length ()) + "\n\n");
String warning = segmentNoBody == segmentNoHeader ? ""
: String.format (" (%02X in routine)", segmentNoBody);
text.append (String.format ("Address........ %02X%n", blockNo));
// if (addresses != null)
text.append (String.format ("Multi disk .... %s%n", getMultiDiskAddresses ()));
text.append (
String.format ("Segment........ %02X%s%n", segmentNoHeader, warning));
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));
text.append (String.format ("Version........ %d%n", version));
text.append (String.format ("Segment........ %02X%s%n", segmentNoHeader, warning));
text.append (String.format ("Total procs.... %d%n", procedures.size ()));
text.append (String.format ("Machine type... %d%n", machineType));
text.append (String.format ("Version........ %d%n", version));
text.append (String.format ("Total procs.... %2d%n", procedures.size ()));

text.append ("\nProcedure Dictionary\n====================\n\n");

Expand All @@ -174,15 +147,15 @@ public String getText ()
{
if (procedure.valid)
{
int address = size - procedure.slot * 2 - 2;
int address = size - procedure.procNo * 2 - 2;
text.append (String.format (
" %3d %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 (" %3d %04X%n", procedure.slot, procedure.offset));
text.append (String.format (" %3d %04X%n", procedure.procNo, procedure.offset));
}

text.append ("\nStrings\n=======\n");
Expand All @@ -200,39 +173,4 @@ public String getText ()

return text.toString ();
}

// ---------------------------------------------------------------------------------//
private String getMultiDiskAddresses ()
// ---------------------------------------------------------------------------------//
{
String multiDiskAddressText = "";
// int sizeInBlocks = (size - 1) / BLOCK_SIZE + 1;

// if (segmentNoHeader == 1) // main segment
// {
// multiDiskAddressText = String.format ("1:%03X", (blockNo + blockOffset));
// }
// else
// if (relocator != null)
// {
// int targetBlock = blockNo + blockOffset;
// List<MultiDiskAddress> addresses =
// relocator.getMultiDiskAddress (name, targetBlock, sizeInBlocks);
// if (addresses.isEmpty ())
// multiDiskAddressText = ".";
// else
// {
// StringBuilder locations = new StringBuilder ();
// for (MultiDiskAddress multiDiskAddress : addresses)
// locations.append (multiDiskAddress.toString () + ", ");
// if (locations.length () > 2)
// {
// locations.deleteCharAt (locations.length () - 1);
// locations.deleteCharAt (locations.length () - 1);
// }
// multiDiskAddressText = locations.toString ();
// }
// }
return multiDiskAddressText;
}
}

0 comments on commit 706c644

Please sign in to comment.