method header lines
This commit is contained in:
parent
ed872ce87e
commit
5b640cbb1c
|
@ -3,7 +3,9 @@ package com.bytezone.diskbrowser.infocom;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class Abbreviations extends InfocomAbstractFile
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
List<ZString> list;
|
||||
Header header;
|
||||
|
@ -12,7 +14,9 @@ class Abbreviations extends InfocomAbstractFile
|
|||
int tablePtr;
|
||||
int tableSize;
|
||||
|
||||
public Abbreviations (Header header)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
Abbreviations (Header header)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Abbreviations", header.buffer);
|
||||
this.header = header;
|
||||
|
@ -27,7 +31,9 @@ class Abbreviations extends InfocomAbstractFile
|
|||
hexBlocks.add (new HexBlock (tablePtr, tableSize, "Abbreviations table:"));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void populate ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
list = new ArrayList<> ();
|
||||
|
||||
|
@ -35,7 +41,9 @@ class Abbreviations extends InfocomAbstractFile
|
|||
list.add (new ZString (header, header.getWord (i) * 2));
|
||||
}
|
||||
|
||||
public String getAbbreviation (int abbreviationNumber)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
String getAbbreviation (int abbreviationNumber)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (list == null)
|
||||
populate ();
|
||||
|
@ -43,8 +51,10 @@ class Abbreviations extends InfocomAbstractFile
|
|||
return list.get (abbreviationNumber).value;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (list == null)
|
||||
populate ();
|
||||
|
@ -54,8 +64,8 @@ class Abbreviations extends InfocomAbstractFile
|
|||
// text.append (String.format ("Data address....%04X %d%n", dataPtr, dataPtr));
|
||||
// text.append (String.format ("Data size.......%04X %d%n", dataSize, dataSize));
|
||||
// text.append (String.format ("Table address...%04X %d%n", tablePtr, tablePtr));
|
||||
// text.append (String.format ("Table size......%04X %d (%d words)%n%n", tableSize, tableSize,
|
||||
// (tableSize / 2)));
|
||||
// text.append (String.format ("Table size......%04X %d (%d words)%n%n",
|
||||
// tableSize, tableSize, (tableSize / 2)));
|
||||
|
||||
int count = 0;
|
||||
for (ZString word : list)
|
||||
|
|
|
@ -9,12 +9,16 @@ import com.bytezone.diskbrowser.applefile.AbstractFile;
|
|||
import com.bytezone.diskbrowser.disk.DefaultAppleFileSource;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class AttributeManager extends AbstractFile
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
List<Statistic> list = new ArrayList<> ();
|
||||
Header header;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public AttributeManager (String name, byte[] buffer, Header header)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (name, buffer);
|
||||
this.header = header;
|
||||
|
@ -23,7 +27,9 @@ class AttributeManager extends AbstractFile
|
|||
list.add (new Statistic (attrNo));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addNodes (DefaultMutableTreeNode node, FormattedDisk disk)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
node.setAllowsChildren (true);
|
||||
|
||||
|
@ -37,8 +43,10 @@ class AttributeManager extends AbstractFile
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ("Attribute Frequency\n");
|
||||
text.append ("--------- ---------\n");
|
||||
|
@ -50,7 +58,9 @@ class AttributeManager extends AbstractFile
|
|||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private class Statistic
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int id;
|
||||
List<ZObject> list = new ArrayList<> ();
|
||||
|
|
|
@ -15,19 +15,25 @@ import com.bytezone.diskbrowser.infocom.Grammar.Sentence;
|
|||
import com.bytezone.diskbrowser.infocom.Grammar.SentenceGroup;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class CodeManager extends AbstractFile
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final Header header;
|
||||
private int codeSize;
|
||||
private final Map<Integer, Routine> routines = new TreeMap<> ();
|
||||
|
||||
public CodeManager (Header header)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
CodeManager (Header header)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Code", header.buffer);
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void addNodes (DefaultMutableTreeNode root, InfocomDisk disk)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
root.setAllowsChildren (true);
|
||||
|
||||
|
@ -48,7 +54,9 @@ class CodeManager extends AbstractFile
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private List<DiskAddress> getSectors (Routine routine, Disk disk)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int blockNo = routine.startPtr / 256 + 48;
|
||||
int size = routine.length;
|
||||
|
@ -62,7 +70,9 @@ class CodeManager extends AbstractFile
|
|||
return blocks;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void addRoutines (int programCounter)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
addRoutine (programCounter - 1, -1);
|
||||
addActionRoutines (); // obtained from Grammar
|
||||
|
@ -111,19 +121,25 @@ class CodeManager extends AbstractFile
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private int checkAlignment (int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (ptr % 2 == 1) // routine must start on a word boundary
|
||||
++ptr;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void addGlobalRoutines ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void addMissingRoutines ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
System.out.printf ("%nWalking the code block%n%n");
|
||||
int total = routines.size ();
|
||||
|
@ -158,7 +174,9 @@ class CodeManager extends AbstractFile
|
|||
routines.size () - total);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private int findNextRoutine (int address)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (Routine routine : routines.values ())
|
||||
if (routine.startPtr > address)
|
||||
|
@ -166,8 +184,10 @@ class CodeManager extends AbstractFile
|
|||
return 0;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
int count = 0;
|
||||
|
@ -188,7 +208,9 @@ class CodeManager extends AbstractFile
|
|||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void addCodeRoutines ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
List<Integer> routines = header.objectManager.getCodeRoutines ();
|
||||
System.out.println ("Adding " + routines.size () + " code routines");
|
||||
|
@ -196,7 +218,9 @@ class CodeManager extends AbstractFile
|
|||
addRoutine (address, 0);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void addActionRoutines ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int total = routines.size ();
|
||||
|
||||
|
@ -211,7 +235,9 @@ class CodeManager extends AbstractFile
|
|||
System.out.printf ("Added %d action routines%n", routines.size () - total);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
Routine addRoutine (int address, int caller)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (address == 0) // stack-based call
|
||||
return null;
|
||||
|
@ -240,13 +266,17 @@ class CodeManager extends AbstractFile
|
|||
return routine;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
Routine getRoutine (int address)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return routines.get (address);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getHexDump ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
// this depends on codeSize being set after the strings have been processed
|
||||
return HexFormatter.format (buffer, header.highMemory, codeSize);
|
||||
|
|
|
@ -8,7 +8,9 @@ import java.util.TreeMap;
|
|||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class Dictionary extends AbstractFile
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final Map<Integer, ZString> dictionary;
|
||||
private final int totalEntries;
|
||||
|
@ -19,7 +21,9 @@ class Dictionary extends AbstractFile
|
|||
|
||||
Map<Integer, List<WordEntry>> synonymList = new TreeMap<> ();
|
||||
|
||||
public Dictionary (Header header)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
Dictionary (Header header)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Dictionary", header.buffer);
|
||||
|
||||
|
@ -129,19 +133,25 @@ class Dictionary extends AbstractFile
|
|||
// 1F n, north
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public boolean containsWordAt (int address)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return dictionary.containsKey (address);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public String wordAt (int address)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (dictionary.containsKey (address))
|
||||
return dictionary.get (address).value;
|
||||
return "dictionary can't find word @ " + address;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public List<String> getVerbs (int value)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
List<String> words = new ArrayList<> ();
|
||||
int ptr = dictionaryPtr + totalSeparators + 4;
|
||||
|
@ -160,7 +170,9 @@ class Dictionary extends AbstractFile
|
|||
return words;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public List<String> getPrepositions (int value)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
List<String> words = new ArrayList<> ();
|
||||
int ptr = dictionaryPtr + totalSeparators + 4;
|
||||
|
@ -179,16 +191,20 @@ class Dictionary extends AbstractFile
|
|||
return words;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getHexDump ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
text.append (HexFormatter.format (buffer, dictionaryPtr, dictionarySize));
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
|
@ -287,7 +303,9 @@ class Dictionary extends AbstractFile
|
|||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private class WordEntry implements Comparable<WordEntry>
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
ZString word;
|
||||
int seq;
|
||||
|
|
|
@ -5,7 +5,9 @@ import java.util.List;
|
|||
|
||||
import com.bytezone.diskbrowser.infocom.Instruction.Operand;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class Globals extends InfocomAbstractFile
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static final int TOTAL_GLOBALS = 240;
|
||||
private final Header header;
|
||||
|
@ -13,7 +15,9 @@ class Globals extends InfocomAbstractFile
|
|||
private final int arrayPtr, arraySize;
|
||||
private final List<List<Routine>> globalRoutines;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
Globals (Header header)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Globals", header.buffer);
|
||||
this.header = header;
|
||||
|
@ -32,15 +36,19 @@ class Globals extends InfocomAbstractFile
|
|||
globalRoutines.add (new ArrayList<> ());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
void addRoutine (Routine routine, Operand operand)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
List<Routine> list = globalRoutines.get (operand.value - 16);
|
||||
if (!list.contains (routine))
|
||||
list.add (routine);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ("GLB Value Routines\n");
|
||||
for (int i = 0; i < TOTAL_GLOBALS; i++)
|
||||
|
|
|
@ -32,7 +32,7 @@ class Header extends InfocomAbstractFile
|
|||
final StringManager stringManager;
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public Header (String name, byte[] buffer, Disk disk)
|
||||
Header (String name, byte[] buffer, Disk disk)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (name, buffer);
|
||||
|
|
|
@ -7,13 +7,13 @@ import com.bytezone.diskbrowser.applefile.AbstractFile;
|
|||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class InfocomAbstractFile extends AbstractFile
|
||||
class InfocomAbstractFile extends AbstractFile
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
protected List<HexBlock> hexBlocks = new ArrayList<> ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public InfocomAbstractFile (String name, byte[] buffer)
|
||||
InfocomAbstractFile (String name, byte[] buffer)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (name, buffer);
|
||||
|
|
|
@ -24,7 +24,9 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
|||
// https://inform-fiction.org/zmachine/standards/
|
||||
// https://github.com/historicalsource?tab=repositories
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class InfocomDisk extends AbstractFormattedDisk
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static final int BLOCK_SIZE = 256;
|
||||
private static final boolean TYPE_NODE = true;
|
||||
|
@ -44,7 +46,9 @@ public class InfocomDisk extends AbstractFormattedDisk
|
|||
SectorType globalsSector = new SectorType ("Globals", Color.darkGray);
|
||||
SectorType grammarSector = new SectorType ("Grammar", Color.gray);
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public InfocomDisk (Disk disk)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (disk);
|
||||
|
||||
|
@ -111,7 +115,9 @@ public class InfocomDisk extends AbstractFormattedDisk
|
|||
setSectorTypes (header.stringPointer, header.fileLength, stringsSector, stringsNode);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
protected void setInfocomSectorTypes ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
sectorTypesList.add (bootSector);
|
||||
sectorTypesList.add (headerSector);
|
||||
|
@ -129,8 +135,10 @@ public class InfocomDisk extends AbstractFormattedDisk
|
|||
sectorTypes[track * 16 + sector] = bootSector;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void setSectorTypes (int sectorFrom, int sectorTo, SectorType type,
|
||||
DefaultMutableTreeNode node)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
DefaultAppleFileSource dafs = (DefaultAppleFileSource) node.getUserObject ();
|
||||
List<DiskAddress> blocks = new ArrayList<> ();
|
||||
|
@ -147,7 +155,9 @@ public class InfocomDisk extends AbstractFormattedDisk
|
|||
dafs.setSectors (blocks);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private int getFileSize ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
byte[] buffer = null;
|
||||
int startBlock = getWord (4) / 256 + 48;
|
||||
|
@ -172,7 +182,9 @@ public class InfocomDisk extends AbstractFormattedDisk
|
|||
return fileSize;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private byte[] getBuffer (int fileSize)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (fileSize == 0)
|
||||
fileSize = getFileSize ();
|
||||
|
@ -193,8 +205,10 @@ public class InfocomDisk extends AbstractFormattedDisk
|
|||
return data;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private DefaultMutableTreeNode addToTree (DefaultMutableTreeNode root, String title,
|
||||
DataSource af, boolean allowsChildren)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
DefaultAppleFileSource dafs = new DefaultAppleFileSource (title, af, this);
|
||||
|
||||
|
@ -205,25 +219,33 @@ public class InfocomDisk extends AbstractFormattedDisk
|
|||
return node;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public List<DiskAddress> getFileSectors (int fileNo)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public AppleFileSource getCatalog ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return new DefaultAppleFileSource (header.getText (), this);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static boolean isCorrectFormat (AppleDisk disk)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
disk.setInterleave (2);
|
||||
return checkFormat (disk);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static boolean checkFormat (AppleDisk disk)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
byte[] buffer = disk.readSector (3, 0);
|
||||
|
||||
|
@ -276,12 +298,16 @@ public class InfocomDisk extends AbstractFormattedDisk
|
|||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private int getWord (int offset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return (((data[offset] << 8) & 0xFF00) | ((data[offset + 1]) & 0xFF));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void createStoryFile (String fileName)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
File f = new File (fileName);
|
||||
try
|
||||
|
|
|
@ -5,7 +5,9 @@ import java.util.List;
|
|||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class Instruction
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
static int version = 3;
|
||||
|
||||
|
@ -40,7 +42,9 @@ class Instruction
|
|||
"scan_table", "not", "call_vn", "call_vn2", "tokenise", "encode_text",
|
||||
"copy_table", "print_table", "check_arg" };
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
Instruction (byte[] buffer, int ptr, Header header)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
this.buffer = buffer;
|
||||
this.startPtr = ptr;
|
||||
|
@ -71,54 +75,74 @@ class Instruction
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
int length ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return opcode.length ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
boolean isReturn ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return opcode.isReturn;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
boolean isPrint ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return opcode.string != null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
boolean isCall ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return opcode.isCall;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
boolean isJump ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
// could use jumpTarget != 0
|
||||
return (opcode instanceof Opcode1OP && opcode.opcodeNumber == 12);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
boolean isBranch ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return opcode.branch != null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
boolean isStore ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return opcode.store != null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
int target ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return isBranch () ? opcode.branch.target : isJump () ? opcode.jumpTarget : 0;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
String dump ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return String.format ("%05X : %s", startPtr,
|
||||
HexFormatter.getHexString (buffer, startPtr, opcode.length ()));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
String getHex ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int max = opcode.length ();
|
||||
String extra = "";
|
||||
|
@ -132,13 +156,17 @@ class Instruction
|
|||
return String.format ("%05X : %-26s%2s", startPtr, hex, extra);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return opcode.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
abstract class Opcode
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int opcodeNumber;
|
||||
int opcodeLength;
|
||||
|
@ -268,7 +296,9 @@ class Instruction
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class Opcode0OP extends Opcode
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
Opcode0OP (byte[] buffer, int ptr)
|
||||
{
|
||||
|
@ -296,7 +326,9 @@ class Instruction
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class Opcode1OP extends Opcode
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
Opcode1OP (byte[] buffer, int ptr)
|
||||
{
|
||||
|
@ -325,7 +357,9 @@ class Instruction
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
abstract class Opcode2OP extends Opcode
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
Opcode2OP ()
|
||||
{
|
||||
|
@ -348,7 +382,9 @@ class Instruction
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class Opcode2OPLong extends Opcode2OP
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
Opcode2OPLong (byte[] buffer, int ptr)
|
||||
{
|
||||
|
@ -371,7 +407,9 @@ class Instruction
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class Opcode2OPVar extends Opcode2OP
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
Opcode2OPVar (byte[] buffer, int ptr)
|
||||
{
|
||||
|
@ -382,7 +420,9 @@ class Instruction
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class OpcodeVar extends Opcode
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
OpcodeVar (byte[] buffer, int ptr)
|
||||
{
|
||||
|
@ -413,7 +453,9 @@ class Instruction
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
abstract class Operand
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int length;
|
||||
int value;
|
||||
|
@ -448,7 +490,9 @@ class Instruction
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class OperandWord extends Operand
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
OperandWord (int value)
|
||||
{
|
||||
|
@ -458,7 +502,9 @@ class Instruction
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class OperandByte extends Operand
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
OperandByte (byte value)
|
||||
{
|
||||
|
@ -468,7 +514,9 @@ class Instruction
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class OperandVariable extends Operand
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
OperandVariable (byte value)
|
||||
{
|
||||
|
@ -484,7 +532,9 @@ class Instruction
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class ArgumentBranch extends Operand
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
private int target;
|
||||
private boolean branchOnTrue;
|
||||
|
@ -524,7 +574,9 @@ class Instruction
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class ArgumentString extends Operand
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
private ZString text;
|
||||
private int startPtr;
|
||||
|
|
|
@ -6,14 +6,18 @@ import java.util.List;
|
|||
|
||||
import com.bytezone.diskbrowser.infocom.ZObject.Property;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class ObjectAnalyser
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
Header header;
|
||||
ObjectManager parent;
|
||||
List<Statistics> list = new ArrayList<Statistics> ();
|
||||
List<Integer> routines = new ArrayList<Integer> ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public ObjectAnalyser (Header header, ObjectManager parent)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
this.header = header;
|
||||
this.parent = parent;
|
||||
|
@ -31,7 +35,9 @@ class ObjectAnalyser
|
|||
checkThreeByteProperties ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void setStringPointer ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
PropertyTester pt = new PropertyTester (parent.getObjects ());
|
||||
pt.addTest (new LengthTwoCondition ());
|
||||
|
@ -58,7 +64,9 @@ class ObjectAnalyser
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void createPropertyLinks ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int sCount = 0;
|
||||
int rCount = 0;
|
||||
|
@ -85,7 +93,9 @@ class ObjectAnalyser
|
|||
System.out.println ("Routines found : " + totRoutines);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void checkThreeByteProperties ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
System.out.printf ("Checking %d objects%n", parent.getObjects ().size ());
|
||||
for (ZObject object : parent.getObjects ())
|
||||
|
@ -106,7 +116,9 @@ class ObjectAnalyser
|
|||
}
|
||||
|
||||
// find the property with only dictionary entries
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void setDictionary ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
PropertyTester pt = new PropertyTester (parent.getObjects ());
|
||||
pt.addTest (new LengthEvenCondition ());
|
||||
|
@ -118,7 +130,9 @@ class ObjectAnalyser
|
|||
header.propertyNames[i] = "DICT"; // SYNONYM
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class Statistics implements Comparable<Statistics>
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int propertyNumber;
|
||||
int lo;
|
||||
|
@ -153,7 +167,9 @@ class ObjectAnalyser
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class LengthTwoCondition extends Condition
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
@Override
|
||||
boolean test (Property property)
|
||||
|
@ -162,7 +178,9 @@ class ObjectAnalyser
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class LengthThreeCondition extends Condition
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
@Override
|
||||
boolean test (Property property)
|
||||
|
@ -171,7 +189,9 @@ class ObjectAnalyser
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class LengthEvenCondition extends Condition
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
@Override
|
||||
boolean test (Property property)
|
||||
|
@ -180,7 +200,9 @@ class ObjectAnalyser
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class HighMemoryCondition extends Condition
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int lo, hi;
|
||||
Statistics[] statistics = new Statistics[32]; // note there is no property #0
|
||||
|
@ -202,7 +224,9 @@ class ObjectAnalyser
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class ValidDictionaryCondition extends Condition
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
@Override
|
||||
boolean test (Property property)
|
||||
|
|
|
@ -10,9 +10,10 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
|||
import com.bytezone.diskbrowser.disk.DefaultAppleFileSource;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class ObjectManager extends InfocomAbstractFile implements Iterable<ZObject>
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
// private final Header header;
|
||||
private final List<ZObject> list;
|
||||
private List<ZObject> sortedList;
|
||||
private final int defaultsPtr, defaultsSize;
|
||||
|
@ -20,10 +21,11 @@ class ObjectManager extends InfocomAbstractFile implements Iterable<ZObject>
|
|||
private final int propertyPtr, propertySize;
|
||||
private final ObjectAnalyser analyser;
|
||||
|
||||
public ObjectManager (Header header)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
ObjectManager (Header header)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super ("Objects", header.buffer);
|
||||
// this.header = header;
|
||||
|
||||
defaultsPtr = header.objectTableOffset;
|
||||
defaultsSize = 62; // 31 words
|
||||
|
@ -47,12 +49,16 @@ class ObjectManager extends InfocomAbstractFile implements Iterable<ZObject>
|
|||
hexBlocks.add (new HexBlock (propertyPtr, propertySize, "Properties:"));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
List<ZObject> getObjects ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return list;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
ZObject getObject (int index)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (index < 0 || index >= list.size ())
|
||||
{
|
||||
|
@ -62,7 +68,9 @@ class ObjectManager extends InfocomAbstractFile implements Iterable<ZObject>
|
|||
return list.get (index);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addNodes (DefaultMutableTreeNode root, FormattedDisk disk)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
root.setAllowsChildren (true);
|
||||
|
||||
|
@ -71,8 +79,10 @@ class ObjectManager extends InfocomAbstractFile implements Iterable<ZObject>
|
|||
buildObjectTree (zo, root, disk);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void buildObjectTree (ZObject object, DefaultMutableTreeNode parentNode,
|
||||
FormattedDisk disk)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
DefaultMutableTreeNode child = new DefaultMutableTreeNode (
|
||||
new DefaultAppleFileSource (object.getName (), object, disk));
|
||||
|
@ -85,16 +95,18 @@ class ObjectManager extends InfocomAbstractFile implements Iterable<ZObject>
|
|||
child.setAllowsChildren (false);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public List<Integer> getCodeRoutines ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return analyser.routines;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
// String header1 = "ID Attributes Pr Sb Ch Prop Title\n-- -----------"
|
||||
// + " -- -- -- ----- -----------------------------\n";
|
||||
String underline = " ----------------------------------------";
|
||||
String titles[] =
|
||||
{ "ID ", "Title ",
|
||||
|
@ -109,11 +121,7 @@ class ObjectManager extends InfocomAbstractFile implements Iterable<ZObject>
|
|||
sortedList = new ArrayList<> (list);
|
||||
Collections.sort (sortedList);
|
||||
|
||||
// int objectNumber = 0;
|
||||
for (ZObject zo : list)
|
||||
// if (false)
|
||||
// text.append (String.format ("%02X %s%n", ++objectNumber, zo));
|
||||
// else
|
||||
text.append (String.format ("%02X %s%n", zo.getId (), zo.getDescription (list)));
|
||||
|
||||
text.append ("\n\n");
|
||||
|
@ -125,8 +133,10 @@ class ObjectManager extends InfocomAbstractFile implements Iterable<ZObject>
|
|||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public Iterator<ZObject> iterator ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return list.iterator ();
|
||||
}
|
||||
|
|
|
@ -9,12 +9,16 @@ import com.bytezone.diskbrowser.applefile.AbstractFile;
|
|||
import com.bytezone.diskbrowser.disk.DefaultAppleFileSource;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class PropertyManager extends AbstractFile
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
List<Statistic> list = new ArrayList<> ();
|
||||
Header header;
|
||||
|
||||
public PropertyManager (String name, byte[] buffer, Header header)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
PropertyManager (String name, byte[] buffer, Header header)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (name, buffer);
|
||||
this.header = header;
|
||||
|
@ -26,7 +30,9 @@ class PropertyManager extends AbstractFile
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addNodes (DefaultMutableTreeNode node, FormattedDisk disk)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
node.setAllowsChildren (true);
|
||||
|
||||
|
@ -41,8 +47,10 @@ class PropertyManager extends AbstractFile
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ("Property Type Frequency\n");
|
||||
text.append ("-------- ----- ---------\n");
|
||||
|
@ -54,7 +62,9 @@ class PropertyManager extends AbstractFile
|
|||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private class Statistic
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int id;
|
||||
List<ZObject> list = new ArrayList<> ();
|
||||
|
|
|
@ -6,23 +6,31 @@ import java.util.List;
|
|||
|
||||
import com.bytezone.diskbrowser.infocom.ZObject.Property;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class PropertyTester implements Iterable<Integer>
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
List<ZObject> objects;
|
||||
List<Condition> conditions = new ArrayList<> ();
|
||||
List<Integer> matchedProperties;
|
||||
|
||||
public PropertyTester (List<ZObject> objects)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
PropertyTester (List<ZObject> objects)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
this.objects = objects;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addTest (Condition test)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
conditions.add (test);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void doTests ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
boolean[] propFail = new boolean[32];
|
||||
int[] propTestCount = new int[32];
|
||||
|
@ -47,19 +55,25 @@ class PropertyTester implements Iterable<Integer>
|
|||
matchedProperties.add (i);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public Iterator<Integer> iterator ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return matchedProperties.iterator ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public int totalSuccessfulProperties ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return matchedProperties.size ();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
abstract class Condition
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
abstract boolean test (Property property);
|
||||
}
|
|
@ -8,8 +8,10 @@ import com.bytezone.diskbrowser.infocom.Instruction.Operand;
|
|||
import com.bytezone.diskbrowser.infocom.Instruction.OperandType;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class Routine extends InfocomAbstractFile
|
||||
implements Iterable<Instruction>, Comparable<Routine>
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
int startPtr, length, strings, locals;
|
||||
|
||||
|
@ -20,7 +22,9 @@ class Routine extends InfocomAbstractFile
|
|||
List<Integer> actions = new ArrayList<> (); // not used yet
|
||||
List<Integer> targets = new ArrayList<> ();
|
||||
|
||||
public Routine (int ptr, Header header, int caller)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
Routine (int ptr, Header header, int caller)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (String.format ("Routine %05X", ptr), header.buffer);
|
||||
|
||||
|
@ -104,7 +108,9 @@ class Routine extends InfocomAbstractFile
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
String dump ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
text.append (String.format ("%05X : %s", startPtr,
|
||||
|
@ -118,13 +124,17 @@ class Routine extends InfocomAbstractFile
|
|||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
boolean isValid ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return startPtr > 0;
|
||||
}
|
||||
|
||||
// test whether the routine contains any instructions pointing to this address
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private boolean isTarget (int ptr)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (Instruction ins : instructions)
|
||||
{
|
||||
|
@ -137,13 +147,17 @@ class Routine extends InfocomAbstractFile
|
|||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public void addCaller (int caller)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
calledBy.add (caller);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
|
@ -193,14 +207,18 @@ class Routine extends InfocomAbstractFile
|
|||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return String.format ("[Start: %05X, Len: %4d, Strings: %2d, Locals: %2d]", startPtr,
|
||||
length, strings, locals);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class Parameter
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int value;
|
||||
int sequence;
|
||||
|
|
|
@ -6,12 +6,16 @@ import java.util.TreeMap;
|
|||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class StringManager extends AbstractFile
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
Header header;
|
||||
Map<Integer, ZString> strings = new TreeMap<Integer, ZString> ();
|
||||
|
||||
public StringManager (String name, byte[] buffer, Header header)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
StringManager (String name, byte[] buffer, Header header)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (name, buffer);
|
||||
this.header = header;
|
||||
|
@ -28,20 +32,26 @@ class StringManager extends AbstractFile
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public boolean containsStringAt (int address)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return strings.containsKey (address);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public String stringAt (int address)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
if (strings.containsKey (address))
|
||||
return strings.get (address).value;
|
||||
return "String not found at : " + address;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
int count = 0;
|
||||
|
@ -61,8 +71,10 @@ class StringManager extends AbstractFile
|
|||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getHexDump ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int size = header.fileLength - header.stringPointer;
|
||||
return HexFormatter.format (buffer, header.stringPointer, size);
|
||||
|
|
|
@ -7,7 +7,9 @@ import java.util.List;
|
|||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class ZObject extends AbstractFile implements Comparable<ZObject>
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
static final int HEADER_SIZE = 9;
|
||||
|
||||
|
@ -22,7 +24,9 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
|
|||
final List<Property> properties = new ArrayList<> ();
|
||||
final BitSet attributes = new BitSet (32);
|
||||
|
||||
public ZObject (String name, byte[] buffer, int offset, int id, Header header)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
ZObject (String name, byte[] buffer, int offset, int id, Header header)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (name, buffer);
|
||||
|
||||
|
@ -66,13 +70,17 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
|
|||
propertyTableLength = ptr - propertyTablePtr;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
int getId ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
|
@ -96,8 +104,10 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
|
|||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getHexDump ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ("Header :\n\n");
|
||||
text.append (HexFormatter.formatNoHeader (buffer, startPtr, HEADER_SIZE));
|
||||
|
@ -107,7 +117,9 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
|
|||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
Property getProperty (int id)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (Property p : properties)
|
||||
if (p.propertyNumber == id)
|
||||
|
@ -115,13 +127,17 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
|
|||
return null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return HexFormatter.getHexString (buffer, startPtr, HEADER_SIZE) + " " + name;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public String getDescription (List<ZObject> list)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder (String.format (" %-40s", getName ()));
|
||||
|
||||
|
@ -140,7 +156,9 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
|
|||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
class Property
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int propertyNumber;
|
||||
int ptr;
|
||||
|
@ -270,8 +288,10 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public int compareTo (ZObject o)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return this.name.compareTo (o.name);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.bytezone.diskbrowser.infocom;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class ZString
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static String[] letters =
|
||||
{ " abcdefghijklmnopqrstuvwxyz", " ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
|
@ -10,7 +12,9 @@ class ZString
|
|||
int startPtr;
|
||||
int length;
|
||||
|
||||
public ZString (Header header, int offset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
ZString (Header header, int offset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
ZStringBuilder text = new ZStringBuilder ();
|
||||
this.header = header;
|
||||
|
@ -42,13 +46,17 @@ class ZString
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String toString ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private class ZStringBuilder
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int alphabet;
|
||||
boolean shift;
|
||||
|
|
Loading…
Reference in New Issue