mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-01-05 11:29:43 +00:00
method header lines
This commit is contained in:
parent
467f5db110
commit
e4ed878f69
@ -7,22 +7,28 @@ import java.util.List;
|
||||
import com.bytezone.diskbrowser.utilities.FileFormatException;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public class PascalCode extends AbstractFile
|
||||
implements PascalConstants, Iterable<PascalSegment>
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
private final List<PascalSegment> segments = new ArrayList<> (16);
|
||||
private final String comment;
|
||||
// private final int blockOffset;
|
||||
// private final Relocator relocator;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static void print ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (int i = 0; i < 216; i++)
|
||||
System.out.printf ("%3d %d %3s %s%n", i + 128, PascalConstants.mnemonicSize[i],
|
||||
PascalConstants.mnemonics[i], PascalConstants.descriptions[i]);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public PascalCode (String name, byte[] buffer, int blockOffset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (name, buffer);
|
||||
|
||||
@ -55,8 +61,10 @@ public class PascalCode extends AbstractFile
|
||||
comment = HexFormatter.getPascalString (buffer, 0x1B0);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder (getHeader ());
|
||||
|
||||
@ -75,13 +83,17 @@ public class PascalCode extends AbstractFile
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private String getHeader ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return "Name : " + name + "\n\n";
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public Iterator<PascalSegment> iterator ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return segments.iterator ();
|
||||
}
|
||||
|
@ -5,7 +5,9 @@ import java.util.List;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class PascalCodeStatement implements PascalConstants
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static final String[] compValue =
|
||||
{ "invalid", "", "REAL", "", "STR", "", "BOOL", "", "POWR", "", "BYT", "", "WORD" };
|
||||
@ -22,7 +24,9 @@ public class PascalCodeStatement implements PascalConstants
|
||||
boolean jumpTarget;
|
||||
List<Jump> jumps = new ArrayList<> ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public PascalCodeStatement (byte[] buffer, int ptr, int procPtr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
this.ptr = ptr;
|
||||
this.buffer = buffer;
|
||||
@ -223,44 +227,58 @@ public class PascalCodeStatement implements PascalConstants
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private int getWord (byte[] buffer, int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return (buffer[ptr + 1] & 0xFF) * 256 + (buffer[ptr] & 0xFF);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private int getLengthOfB (byte b)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return (b & 0x80) == 0x80 ? 2 : 1;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private int getValueOfB (byte[] buffer, int ptr, int length)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (length == 2)
|
||||
return (buffer[ptr] & 0x7F) * 256 + (buffer[ptr + 1] & 0xFF);
|
||||
return buffer[ptr] & 0xFF;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void setParameters (int p1)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
description = description.replaceFirst (":1", p1 + "");
|
||||
extras = "#" + p1;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void setParameters (int p1, int p2)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
setParameters (p1);
|
||||
extras += ", #" + p2;
|
||||
description = description.replaceFirst (":2", p2 + "");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void setParameters (int p1, int p2, String p3)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
setParameters (p1, p2);
|
||||
description = description.replaceFirst (":3", p3);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
String hex = getHex (buffer, ptr, length > 4 ? 4 : length);
|
||||
StringBuilder text = new StringBuilder ();
|
||||
@ -290,7 +308,9 @@ public class PascalCodeStatement implements PascalConstants
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private String getHex (byte[] buffer, int offset, int length)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if ((offset + length) >= buffer.length)
|
||||
{
|
||||
@ -305,7 +325,9 @@ public class PascalCodeStatement implements PascalConstants
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class Jump
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int addressFrom;
|
||||
int addressTo;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public interface PascalConstants
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
static String[] mnemonics =
|
||||
{ "ABI", "ABR", "ADI", "ADR", "LAND", "DIF", "DVI", "DVR", "CHK", "FLO", "FLT",
|
||||
@ -66,7 +68,8 @@ public interface PascalConstants
|
||||
"Load multiple words - push block of unsigned bytes at *ToS",
|
||||
"Store multiple words - store block of UB at ToS to *ToS-1",
|
||||
"Load Byte - index the byte pointer ToS-1 by integer index ToS and push that byte",
|
||||
"Store Byte - index the byte pointer ToS-2 by integer index ToS-1 and move ToS to that location",
|
||||
"Store Byte - index the byte pointer ToS-2 by integer "
|
||||
+ "index ToS-1 and move ToS to that location",
|
||||
"Index packed array - do complicated stuff with :1 and :2",
|
||||
"Return from base procedure (pass :1 words)",
|
||||
"Call Base Procedure :1 at lex level -1 or 0", "Compare Integer : ToS-1 = ToS",
|
||||
|
@ -1,15 +1,20 @@
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class PascalInfo extends AbstractFile
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public PascalInfo (String name, byte[] buffer)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (name, buffer);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder (getHeader ());
|
||||
|
||||
@ -22,7 +27,9 @@ public class PascalInfo extends AbstractFile
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private String getHeader ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return "Name : " + name + "\n\n";
|
||||
}
|
||||
|
@ -6,7 +6,9 @@ import java.util.List;
|
||||
import com.bytezone.diskbrowser.applefile.PascalCodeStatement.Jump;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class PascalProcedure
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
// all procedures have these fields
|
||||
byte[] buffer;
|
||||
@ -26,7 +28,9 @@ public class PascalProcedure
|
||||
AssemblerProgram assembler;
|
||||
int jumpTable = -8;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public PascalProcedure (byte[] buffer, int slot)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
this.buffer = buffer;
|
||||
this.slot = slot;
|
||||
@ -46,7 +50,9 @@ public class PascalProcedure
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void decode ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (statements.size () > 0 || assembler != null)
|
||||
return;
|
||||
@ -118,7 +124,9 @@ public class PascalProcedure
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public List<PascalCodeStatement> extractStrings ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
decode ();
|
||||
List<PascalCodeStatement> strings = new ArrayList<> ();
|
||||
@ -128,8 +136,10 @@ public class PascalProcedure
|
||||
return strings;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (!valid)
|
||||
return "";
|
||||
|
@ -6,7 +6,9 @@ import java.util.List;
|
||||
import com.bytezone.diskbrowser.utilities.FileFormatException;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class PascalSegment extends AbstractFile implements PascalConstants
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final static int BLOCK_SIZE = 512;
|
||||
final int segmentNoHeader;
|
||||
@ -30,7 +32,9 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
||||
private List<PascalProcedure> procedures;
|
||||
// private List<MultiDiskAddress> addresses;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public PascalSegment (String name, byte[] fullBuffer, int seq, int blockOffset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (name, fullBuffer); // sets this.buffer to the full buffer temporarily
|
||||
|
||||
@ -114,7 +118,9 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
||||
// this.addresses = addresses;
|
||||
// }
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void buildProcedureList ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
procedures = new ArrayList<> (totalProcedures);
|
||||
|
||||
@ -122,7 +128,9 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
||||
procedures.add (new PascalProcedure (buffer, i));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public String toText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int sizeInBlocks = (size - 1) / BLOCK_SIZE + 1;
|
||||
|
||||
@ -133,8 +141,10 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
||||
getMultiDiskAddresses ());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (procedures == null)
|
||||
buildProcedureList ();
|
||||
@ -194,7 +204,9 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private String getMultiDiskAddresses ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
String multiDiskAddressText = "";
|
||||
// int sizeInBlocks = (size - 1) / BLOCK_SIZE + 1;
|
||||
|
@ -1,14 +1,20 @@
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class PascalText extends AbstractFile
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public PascalText (String name, byte[] buffer)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (name, buffer);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder (getHeader ());
|
||||
|
||||
@ -38,12 +44,16 @@ public class PascalText extends AbstractFile
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private String getHeader ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return "Name : " + name + "\n\n";
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private String getLine (int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder line = new StringBuilder ();
|
||||
while (buffer[ptr] != 0x0D)
|
||||
|
@ -5,9 +5,13 @@ import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBuffer;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class PrintShopGraphic extends AbstractFile
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public PrintShopGraphic (String name, byte[] buffer)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (name, buffer);
|
||||
|
||||
@ -27,8 +31,10 @@ public class PrintShopGraphic extends AbstractFile
|
||||
g2d.dispose ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
|
@ -1,15 +1,21 @@
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class SegmentDictionary
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final boolean isValid;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public SegmentDictionary (String name, byte[] buffer)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
isValid = !name.equals ("SYSTEM.INTERP"); // temporary
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public boolean isValid ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return isValid;
|
||||
}
|
||||
|
@ -21,14 +21,18 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
* S2+n last byte = 0
|
||||
*/
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class ShapeTable extends AbstractFile
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final List<Shape> shapes = new ArrayList<> ();
|
||||
private static final int SIZE = 400;
|
||||
int maxWidth = 0;
|
||||
int maxHeight = 0;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public ShapeTable (String name, byte[] buffer)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (name, buffer);
|
||||
|
||||
@ -81,8 +85,10 @@ public class ShapeTable extends AbstractFile
|
||||
g2d.dispose ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
@ -100,7 +106,9 @@ public class ShapeTable extends AbstractFile
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static boolean isShapeTable (byte[] buffer)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (buffer.length == 0)
|
||||
return false;
|
||||
@ -134,7 +142,9 @@ public class ShapeTable extends AbstractFile
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class Shape
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
private final byte[] buffer;
|
||||
private final int index;
|
||||
|
Loading…
Reference in New Issue
Block a user