added attribute names to infocom objects

This commit is contained in:
Denis Molony 2025-01-21 14:41:46 +10:00
parent dafc29c60e
commit c88b616164
4 changed files with 47 additions and 20 deletions

View File

@ -139,8 +139,9 @@ class DirectoryEntry implements AppleFileSource
char ro = readOnly ? '*' : ' ';
char sf = systemFile ? '*' : ' ';
String text = String.format ("%3d %-8s %-3s %s %s %02X %02X %02X %02X %s",
userNumber, name, type, ro, sf, extent, s2, s1, recordsUsed, bytes);
String text =
String.format ("%3d %-8s %-3s %s %s %02X %02X %02X %02X %s",
userNumber, name, type, ro, sf, extent, s2, s1, recordsUsed, bytes);
for (DirectoryEntry entry : entries)
text = text + "\n" + entry.line ();
@ -217,13 +218,15 @@ class DirectoryEntry implements AppleFileSource
else if ("DVR".equals (type))
appleFile = new DefaultAppleFile (name, exactBuffer, "DVR File");
else if ("ASM".equals (type) || "DOC".equals (type) || "COB".equals (type)
|| "HLP".equals (type) || "TXT".equals (type) || "LET".equals (type) || "ALX".equals (type)
|| "SRC".equals (type) || "H".equals (type) || exactBuffer[len - 1] == 0x1A)
|| "HLP".equals (type) || "TXT".equals (type) || "LET".equals (type)
|| "ALX".equals (type) || "SRC".equals (type) || "H".equals (type)
|| exactBuffer[len - 1] == 0x1A)
appleFile = new CPMTextFile (name, exactBuffer);
else if ("BAS".equals (type))
appleFile = new CPMBasicFile (name, exactBuffer);
else
appleFile = new DefaultAppleFile (name, exactBuffer, "CPM File : " + name + "." + type);
appleFile =
new DefaultAppleFile (name, exactBuffer, "CPM File : " + name + "." + type);
return appleFile;
}

View File

@ -37,7 +37,8 @@ class AttributeManager extends AbstractFile
for (Statistic stat : list)
{
DefaultMutableTreeNode child = new DefaultMutableTreeNode (
new DefaultAppleFileSource (("Attribute " + count++), stat.getText (), disk));
new DefaultAppleFileSource ((ZObject.attrName[count]), stat.getText (), disk));
count++;
node.add (child);
child.setAllowsChildren (false);
}
@ -48,8 +49,8 @@ class AttributeManager extends AbstractFile
public String getText ()
// ---------------------------------------------------------------------------------//
{
StringBuilder text = new StringBuilder ("Attribute Frequency\n");
text.append ("--------- ---------\n");
StringBuilder text = new StringBuilder ("Attribute Freq\n");
text.append ("----------- ----\n");
for (Statistic stat : list)
text.append (String.format ("%s%n", stat));
@ -63,33 +64,35 @@ class AttributeManager extends AbstractFile
// ---------------------------------------------------------------------------------//
{
int id;
List<ZObject> list = new ArrayList<> ();
List<ZObject> objects = new ArrayList<> ();
public Statistic (int id)
{
this.id = id;
for (ZObject o : header.objectManager)
if (o.attributes.get (id))
list.add (o);
for (ZObject object : header.objectManager)
if (object.attributes.get (id))
objects.add (object);
}
String getText ()
{
StringBuilder text =
new StringBuilder ("Objects with attribute " + id + " set:\n\n");
for (ZObject o : list)
StringBuilder text = new StringBuilder (
"Objects with attribute " + ZObject.attrName[id] + " set:\n\n");
for (ZObject o : objects)
{
text.append (String.format ("%3d %-28s%n", o.getId (), o.getName ()));
}
if (text.length () > 0)
text.deleteCharAt (text.length () - 1);
return text.toString ();
}
@Override
public String toString ()
{
return String.format (" %2d %3d", id, list.size ());
return String.format ("%-12s %3d", ZObject.attrName[id], objects.size ());
}
}
}

View File

@ -23,6 +23,8 @@ import com.bytezone.diskbrowser.utilities.Utility;
// https://mud.co.uk/richard/htflpism.htm
// https://inform-fiction.org/zmachine/standards/
// https://github.com/historicalsource?tab=repositories
// https://medium.com/swlh/zork-the-great-inner-workings-b68012952bdc
// https://github.com/ZoBoRf/ZILCH-How-to
// -----------------------------------------------------------------------------------//
public class InfocomDisk extends AbstractFormattedDisk
@ -216,6 +218,7 @@ public class InfocomDisk extends AbstractFormattedDisk
DefaultMutableTreeNode node = new DefaultMutableTreeNode (dafs);
node.setAllowsChildren (allowsChildren);
root.add (node);
return node;
}

View File

@ -12,6 +12,10 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
// -----------------------------------------------------------------------------------//
{
static final int HEADER_SIZE = 9;
static final String[] attrName = { "0", "1", "2", "TOUCH", "WATER", "MAZE", "LAND",
"INVISIBLE", "SEARCH", "OUTSIDE", "SURFACE", "OPEN", "TRANSPARENT", "TRYTAKE",
"NODESC", "TURN", "READ", "TAKE", "18", "CONTAINER", "ON", "FOOD", "DRINK", "DOOR",
"CLIMB", "FLAME", "BURN", "VEHICLE", "TOOL", "WEAPON", "CHARACTER", "LIGHT" };
private final Header header;
private final int id;
@ -57,7 +61,7 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
propertyTablePtr = header.getWord (offset + 7);
int ptr = propertyTablePtr;
int nameLength = header.getByte (ptr) * 2;
setName (nameLength == 0 ? "<<" + id + ">>" : new ZString (header, ++ptr).value);
setName (nameLength == 0 ? "Object " + id : new ZString (header, ++ptr).value);
ptr += nameLength;
// read each property
@ -94,9 +98,23 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
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");
text.append ("Attrs : ");
if (!attributes.isEmpty ())
{
for (int i = 0; i < 32; i++)
{
if (attributes.get (i))
text.append (attrName[i] + ", ");
}
if (text.charAt (text.length () - 2) == ',')
text.deleteCharAt (text.length () - 2);
text.append (" " + attributes.toString () + " ");
}
text.append ("\n\n");
for (Property prop : properties)
text.append (prop + "\n");