mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-25 16:34:00 +00:00
zork source code released
This commit is contained in:
parent
161c57b974
commit
8764dd0db8
@ -17,6 +17,7 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
// https://mud.co.uk/richard/htflpism.htm
|
||||
// https://inform-fiction.org/zmachine/standards/
|
||||
// https://github.com/historicalsource?tab=repositories
|
||||
|
||||
public class InfocomDisk extends AbstractFormattedDisk
|
||||
{
|
||||
|
@ -79,10 +79,14 @@ class ObjectManager extends InfocomAbstractFile implements Iterable<ZObject>
|
||||
{
|
||||
String header1 = "ID Attributes Pr Sb Ch Prop Title\n-- -----------"
|
||||
+ " -- -- -- ----- -----------------------------\n";
|
||||
String underline = " --------------------------";
|
||||
String header2 = "ID Title Parent Sibling"
|
||||
+ " Child Attributes Prop\n" + "-- "
|
||||
+ underline + underline + underline + underline + " ----------- -----" + "\n";
|
||||
String underline = " ----------------------------------------";
|
||||
String titles[] =
|
||||
{ "ID ", "Title ",
|
||||
"Parent ",
|
||||
"Sibling ",
|
||||
"Child ", "Attributes Prop\n" };
|
||||
String header2 = titles[0] + titles[1] + titles[2] + titles[3] + titles[4] + titles[5]
|
||||
+ "-- " + underline + underline + underline + underline + " ----------- -----\n";
|
||||
StringBuilder text = new StringBuilder (header2);
|
||||
|
||||
int objectNumber = 0;
|
||||
|
@ -77,7 +77,7 @@ class PropertyManager extends AbstractFile
|
||||
for (ZObject o : list)
|
||||
{
|
||||
ZObject.Property p = o.getProperty (id);
|
||||
text.append (String.format ("%3d %-29s%s%n", o.id, o.getName (),
|
||||
text.append (String.format ("%02X %-29s%s%n", o.id, o.getName (),
|
||||
p.toString ().substring (7)));
|
||||
}
|
||||
if (text.length () > 0)
|
||||
|
@ -35,7 +35,7 @@ class ZObject extends AbstractFile
|
||||
byte b = buffer[offset + i];
|
||||
for (int j = 0; j < 8; j++)
|
||||
{
|
||||
if ((b & 0x80) == 0x80)
|
||||
if ((b & 0x80) != 0)
|
||||
attributes.set (bitIndex);
|
||||
b <<= 1;
|
||||
++bitIndex;
|
||||
@ -69,18 +69,19 @@ class ZObject extends AbstractFile
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
text.append (String.format ("ID : %3d %s%n%nAttributes : ", id, name));
|
||||
text.append (HexFormatter.getHexString (buffer, startPtr, 4));
|
||||
text.append (" " + attributes.toString ());
|
||||
text.append (String.format ("ID : %02X (%<3d) %s%n%n", id, name));
|
||||
|
||||
String obj1 = parent == 0 ? "" : header.objectManager.list.get (parent - 1).name;
|
||||
String obj2 = sibling == 0 ? "" : header.objectManager.list.get (sibling - 1).name;
|
||||
String obj3 = child == 0 ? "" : header.objectManager.list.get (child - 1).name;
|
||||
|
||||
text.append (
|
||||
String.format ("%n%nParent : %02X (%3d) %s%n", parent, parent, obj1));
|
||||
text.append (String.format ("Sibling : %02X (%3d) %s%n", sibling, sibling, obj2));
|
||||
text.append (String.format ("Child : %02X (%3d) %s%n%n", child, child, obj3));
|
||||
text.append (String.format ("Parent : %02X (%<3d) %s%n", parent, obj1));
|
||||
text.append (String.format ("Sibling : %02X (%<3d) %s%n", sibling, obj2));
|
||||
text.append (String.format ("Child : %02X (%<3d) %s%n%n", child, obj3));
|
||||
|
||||
text.append ("Attributes : ");
|
||||
text.append (HexFormatter.getHexString (buffer, startPtr, 4));
|
||||
text.append (" " + attributes.toString () + "\n\n");
|
||||
|
||||
for (Property prop : properties)
|
||||
text.append (prop + "\n");
|
||||
@ -115,13 +116,13 @@ class ZObject extends AbstractFile
|
||||
|
||||
public String getDescription (List<ZObject> list)
|
||||
{
|
||||
StringBuilder text = new StringBuilder (String.format (" %-26s", getName ()));
|
||||
StringBuilder text = new StringBuilder (String.format (" %-40s", getName ()));
|
||||
|
||||
for (int i = 4; i < 7; i++)
|
||||
{
|
||||
int index = buffer[startPtr + i] & 0xFF;
|
||||
String name = index > 0 ? list.get (index - 1).getName () : "";
|
||||
text.append (String.format (" %-26s", name));
|
||||
text.append (String.format (" %-40s", name));
|
||||
}
|
||||
|
||||
text.append (" ");
|
||||
@ -176,9 +177,10 @@ class ZObject extends AbstractFile
|
||||
case 2:
|
||||
text.append ("\"" + header.stringManager.stringAt (offset) + "\"");
|
||||
break;
|
||||
case 3:
|
||||
case 3: // executable routine
|
||||
int address = header.getWord (ptr + 1) * 2;
|
||||
text.append (String.format ("R:%05X", address));
|
||||
appendRoutine (text, address);
|
||||
break;
|
||||
case 4:
|
||||
address = header.getWord (ptr + 3) * 2;
|
||||
@ -202,13 +204,7 @@ class ZObject extends AbstractFile
|
||||
else if (propertyType.startsWith ("CODE"))
|
||||
{
|
||||
if (offset > 0) // cretin contains 00 00
|
||||
{
|
||||
Routine r = header.codeManager.getRoutine (offset);
|
||||
if (r != null)
|
||||
text.append ("\n\n" + r.getText ());
|
||||
else // this can happen if the property is mislabelled as code
|
||||
text.append ("\n\n****** null routine\n");
|
||||
}
|
||||
appendRoutine (text, offset);
|
||||
}
|
||||
else if (propertyType.startsWith ("STR"))
|
||||
{
|
||||
@ -218,5 +214,14 @@ class ZObject extends AbstractFile
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
private void appendRoutine (StringBuilder text, int offset)
|
||||
{
|
||||
Routine r = header.codeManager.getRoutine (offset);
|
||||
if (r != null)
|
||||
text.append ("\n\n" + r.getText ());
|
||||
else // this can happen if the property is mislabelled as code
|
||||
text.append ("\n\n****** null routine\n");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user