fixed some infocom bugs

This commit is contained in:
Denis Molony 2020-12-20 11:34:42 +10:00
parent e7c4423ebf
commit 0b13adbee9
9 changed files with 29 additions and 28 deletions

View File

@ -12,7 +12,7 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
public abstract class AbstractFile implements DataSource
// -----------------------------------------------------------------------------------//
{
static boolean debug;
static boolean showDebugText;
protected String name;
public byte[] buffer;
@ -40,14 +40,14 @@ public abstract class AbstractFile implements DataSource
public static void setDefaultDebug (boolean value)
// ---------------------------------------------------------------------------------//
{
debug = value;
showDebugText = value;
}
// ---------------------------------------------------------------------------------//
public static void setDebug (boolean value)
// ---------------------------------------------------------------------------------//
{
debug = value;
showDebugText = value;
}
// ---------------------------------------------------------------------------------//

View File

@ -60,7 +60,7 @@ public class ApplesoftBasicProgram extends BasicProgram
public String getText ()
// ---------------------------------------------------------------------------------//
{
return debug ? getHexText () : getProgramText ();
return showDebugText ? getHexText () : getProgramText ();
}
// ---------------------------------------------------------------------------------//

View File

@ -26,7 +26,7 @@ public class VisicalcFile extends AbstractFile
StringBuilder text = new StringBuilder ();
text.append ("Visicalc : " + name + "\n\n");
text.append (sheet.getTextDisplay (debug));
text.append (sheet.getTextDisplay (showDebugText));
return text.toString ();
}

View File

@ -262,25 +262,10 @@ public class DataPanel extends JTabbedPane
AbstractFile.setDebug (value);
setText (formattedText, currentDataSource.getText ());
// if (currentDataSource instanceof VisicalcFile)
// {
// VisicalcFile visicalcFile = (VisicalcFile) currentDataSource;
// VisicalcFile.setDebug (value);
// setText (formattedText, visicalcFile.getText ());
// }
// else if (currentDataSource instanceof ApplesoftBasicProgram)
// {
// ApplesoftBasicProgram basicProgram = (ApplesoftBasicProgram) currentDataSource;
// ApplesoftBasicProgram.setDebug (value);
// setText (formattedText, basicProgram.getText ());
// }
// // should implement an interface for this
// else
if (currentDataSource instanceof HiResImage
|| currentDataSource instanceof QuickDrawFont)
{
setDataSource (currentDataSource); // toggles text/image
}
}
// ---------------------------------------------------------------------------------//
@ -359,6 +344,9 @@ public class DataPanel extends JTabbedPane
hexTextValid = false;
formattedTextValid = false;
break;
default:
System.out.println ("Unexpected Tab #" + getSelectedIndex ());
}
BufferedImage image = dataSource.getImage ();

View File

@ -151,7 +151,10 @@ class CodeManager extends AbstractFile
if (routines.containsKey (ptr))
{
ptr += getRoutine (ptr).length;
int length = getRoutine (ptr).length;
if (length == 0)
break;
ptr += length;
continue;
}

View File

@ -65,8 +65,13 @@ class Dictionary extends AbstractFile
int b1 = buffer[ptr + 5] & 0xFF;
int b2 = buffer[ptr + 6] & 0xFF;
int property = b2 == 0 ? b1 : b2;
property &= 0x1F;
String propertyName = header.getPropertyName (property);
System.out.printf ("%02X %s%n", property, string.value);
// if (property >= header.propertyNames.length)
// System.out.println ("Illegal property");
// else
if (propertyName == null || propertyName.length () > string.value.length ())
header.propertyNames[property] = string.value;
}
@ -80,7 +85,7 @@ class Dictionary extends AbstractFile
header.propertyNames[i] = i + "";
// testing (only works in Zork 1)
if (true)
if (false)
{
if (header.propertyNames[4].equals ("4"))
header.propertyNames[4] = "PSEUDO";

View File

@ -87,6 +87,8 @@ class Header extends InfocomAbstractFile
String getPropertyName (int id)
// ---------------------------------------------------------------------------------//
{
if (id >= propertyNames.length)
return "Bad id : " + id;
return propertyNames[id];
}

View File

@ -54,7 +54,7 @@ public class InfocomDisk extends AbstractFormattedDisk
setInfocomSectorTypes ();
data = disk.readBlock (3, 0); // read first sector to get file size
data = disk.readBlock (3, 0); // read first sector to get file size
data = getBuffer (getWord (26) * 2); // read entire file into data buffer
if (false)

View File

@ -199,10 +199,13 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
if (propertyNumber >= 19) // directions
{
ZObject object = getObject ();
String objectName = object == null ? "no object" : object.name;
switch (length)
{
case 1: // UEXIT - unconditional exit
text.append (getObject ().name);
text.append (objectName);
break;
case 2:
text.append ("\"" + header.stringManager.stringAt (offset) + "\"");
@ -213,15 +216,15 @@ class ZObject extends AbstractFile implements Comparable<ZObject>
appendRoutine (text, address);
break;
case 4:
text.append (String.format ("%s : IF G%02X ELSE ", getObject ().name,
text.append (String.format ("%s : IF G%02X ELSE ", objectName,
header.getByte (ptr + 2)));
address = header.getWord (ptr + 3) * 2;
if (address > 0)
text.append ("\"" + header.stringManager.stringAt (address) + "\"");
break;
case 5:
text.append (String.format ("%s : IF G%02X ", getObject ().name,
header.getByte (ptr + 2)));
text.append (
String.format ("%s : IF G%02X ", objectName, header.getByte (ptr + 2)));
break;
default:
break;