findbugs
This commit is contained in:
parent
48b95db89b
commit
8fd7bd1a29
|
@ -10,9 +10,9 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
|||
|
||||
public abstract class AbstractFile implements DataSource
|
||||
{
|
||||
public String name;
|
||||
protected String name;
|
||||
public byte[] buffer;
|
||||
AssemblerProgram assembler;
|
||||
protected AssemblerProgram assembler;
|
||||
protected BufferedImage image;
|
||||
|
||||
public AbstractFile (String name, byte[] buffer)
|
||||
|
@ -27,6 +27,11 @@ public abstract class AbstractFile implements DataSource
|
|||
return "Name : " + name + "\n\nNo text description";
|
||||
}
|
||||
|
||||
public String getName ()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssembler ()
|
||||
{
|
||||
|
|
|
@ -7,143 +7,146 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
|||
|
||||
public class SimpleText2 extends AbstractFile
|
||||
{
|
||||
List<Integer> lineStarts = new ArrayList<Integer> ();
|
||||
int loadAddress;
|
||||
boolean showByte = false;
|
||||
List<Integer> lineStarts = new ArrayList<Integer> ();
|
||||
int loadAddress;
|
||||
boolean showByte = false;
|
||||
|
||||
public SimpleText2 (String name, byte[] buffer, int loadAddress)
|
||||
{
|
||||
super (name, buffer);
|
||||
this.loadAddress = loadAddress;
|
||||
public SimpleText2 (String name, byte[] buffer, int loadAddress)
|
||||
{
|
||||
super (name, buffer);
|
||||
this.loadAddress = loadAddress;
|
||||
|
||||
// store a pointer to each new line
|
||||
int ptr = 0;
|
||||
while (buffer[ptr] != -1)
|
||||
{
|
||||
int length = buffer[ptr] & 0xFF;
|
||||
lineStarts.add (ptr);
|
||||
ptr += length + 1;
|
||||
}
|
||||
}
|
||||
// store a pointer to each new line
|
||||
int ptr = 0;
|
||||
while (buffer[ptr] != -1)
|
||||
{
|
||||
int length = buffer[ptr] & 0xFF;
|
||||
lineStarts.add (ptr);
|
||||
ptr += length + 1;
|
||||
}
|
||||
}
|
||||
|
||||
public String getText ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
@Override
|
||||
public String getText ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
text.append ("Name : " + name + "\n");
|
||||
text.append (String.format ("Length : $%04X (%d)%n", buffer.length, buffer.length));
|
||||
text.append (String.format ("Load at : $%04X%n%n", loadAddress));
|
||||
text.append ("Name : " + name + "\n");
|
||||
text.append (String.format ("Length : $%04X (%d)%n", buffer.length, buffer.length));
|
||||
text.append (String.format ("Load at : $%04X%n%n", loadAddress));
|
||||
|
||||
for (Integer i : lineStarts)
|
||||
text.append (String.format ("%05X %s%n", i, getLine (i)));
|
||||
return text.toString ();
|
||||
}
|
||||
for (Integer i : lineStarts)
|
||||
text.append (String.format ("%05X %s%n", i, getLine (i)));
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
public String getHexDump ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
@Override
|
||||
public String getHexDump ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
for (Integer i : lineStarts)
|
||||
text.append (HexFormatter.formatNoHeader (buffer, i, (buffer[i] & 0xFF) + 1) + "\n");
|
||||
text.append (HexFormatter.formatNoHeader (buffer, buffer.length - 2, 2) + "\n");
|
||||
for (Integer i : lineStarts)
|
||||
text.append (HexFormatter.formatNoHeader (buffer, i, (buffer[i] & 0xFF) + 1)
|
||||
+ "\n");
|
||||
text.append (HexFormatter.formatNoHeader (buffer, buffer.length - 2, 2) + "\n");
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
// convert buffer to text, ignore line-break at the end
|
||||
private String getLine (int ptr)
|
||||
{
|
||||
StringBuilder line = new StringBuilder ();
|
||||
int length = buffer[ptr] & 0xFF;
|
||||
while (--length > 0)
|
||||
{
|
||||
int val = buffer[++ptr] & 0xFF;
|
||||
if (val == 0xBB)
|
||||
{
|
||||
while (line.length () < 35)
|
||||
line.append (' ');
|
||||
line.append (';');
|
||||
}
|
||||
else if (val >= 0x80)
|
||||
{
|
||||
while (line.length () < 10)
|
||||
line.append (' ');
|
||||
if (val == 0xDC)
|
||||
line.append (String.format ("EQU", val));
|
||||
else if (val == 0xD0)
|
||||
line.append (String.format ("STA", val));
|
||||
else if (val == 0xD2)
|
||||
line.append (String.format ("STY", val));
|
||||
else if (val == 0xD4)
|
||||
line.append (String.format ("LSR", val));
|
||||
else if (val == 0xD5)
|
||||
line.append (String.format ("ROR", val));
|
||||
else if (val == 0xD7)
|
||||
line.append (String.format ("ASL", val));
|
||||
else if (val == 0xD9)
|
||||
line.append (String.format ("EQ ", val));
|
||||
else if (val == 0xDB)
|
||||
line.append (String.format ("TGT", val));
|
||||
else if (val == 0xDA)
|
||||
line.append (String.format ("ORG", val));
|
||||
else if (val == 0xB1)
|
||||
line.append (String.format ("TYA", val));
|
||||
else if (val == 0xC1)
|
||||
line.append (String.format ("AND", val));
|
||||
else if (val == 0xC4)
|
||||
line.append (String.format ("CMP", val));
|
||||
else if (val == 0xC8)
|
||||
line.append (String.format ("EOR", val));
|
||||
else if (val == 0xCA)
|
||||
line.append (String.format ("JMP", val));
|
||||
else if (val == 0xCB)
|
||||
line.append (String.format ("JSR", val));
|
||||
else if (val == 0xCD)
|
||||
line.append (String.format ("LDA", val));
|
||||
else if (val == 0xCE)
|
||||
line.append (String.format ("LDX", val));
|
||||
else if (val == 0xCF)
|
||||
line.append (String.format ("LDY", val));
|
||||
else if (val == 0xA1)
|
||||
line.append (String.format ("PHA", val));
|
||||
else if (val == 0xA2)
|
||||
line.append (String.format ("PLA", val));
|
||||
else if (val == 0xA5)
|
||||
line.append (String.format ("RTS", val));
|
||||
else if (val == 0xA9)
|
||||
line.append (String.format ("SEC", val));
|
||||
else if (val == 0xAD)
|
||||
line.append (String.format ("TAY", val));
|
||||
else if (val == 0x82)
|
||||
line.append (String.format ("BMI", val));
|
||||
else if (val == 0x84)
|
||||
line.append (String.format ("BCS", val));
|
||||
else if (val == 0x85)
|
||||
line.append (String.format ("BPL", val));
|
||||
else if (val == 0x86)
|
||||
line.append (String.format ("BNE", val));
|
||||
else if (val == 0x87)
|
||||
line.append (String.format ("BEQ", val));
|
||||
else if (val == 0x99)
|
||||
line.append (String.format ("CLC", val));
|
||||
else if (val == 0x9C)
|
||||
line.append (String.format ("DEX", val));
|
||||
else if (val == 0x9F)
|
||||
line.append (String.format ("INY", val));
|
||||
else
|
||||
line.append (String.format (".%02X.", val));
|
||||
// convert buffer to text, ignore line-break at the end
|
||||
private String getLine (int ptr)
|
||||
{
|
||||
StringBuilder line = new StringBuilder ();
|
||||
int length = buffer[ptr] & 0xFF;
|
||||
while (--length > 0)
|
||||
{
|
||||
int val = buffer[++ptr] & 0xFF;
|
||||
if (val == 0xBB)
|
||||
{
|
||||
while (line.length () < 35)
|
||||
line.append (' ');
|
||||
line.append (';');
|
||||
}
|
||||
else if (val >= 0x80)
|
||||
{
|
||||
while (line.length () < 10)
|
||||
line.append (' ');
|
||||
if (val == 0xDC)
|
||||
line.append (String.format ("EQU %02X", val));
|
||||
else if (val == 0xD0)
|
||||
line.append (String.format ("STA %02X", val));
|
||||
else if (val == 0xD2)
|
||||
line.append (String.format ("STY %02X", val));
|
||||
else if (val == 0xD4)
|
||||
line.append (String.format ("LSR %02X", val));
|
||||
else if (val == 0xD5)
|
||||
line.append (String.format ("ROR %02X", val));
|
||||
else if (val == 0xD7)
|
||||
line.append (String.format ("ASL %02X", val));
|
||||
else if (val == 0xD9)
|
||||
line.append (String.format ("EQ %02X", val));
|
||||
else if (val == 0xDB)
|
||||
line.append (String.format ("TGT %02X", val));
|
||||
else if (val == 0xDA)
|
||||
line.append (String.format ("ORG %02X", val));
|
||||
else if (val == 0xB1)
|
||||
line.append (String.format ("TYA %02X", val));
|
||||
else if (val == 0xC1)
|
||||
line.append (String.format ("AND %02X", val));
|
||||
else if (val == 0xC4)
|
||||
line.append (String.format ("CMP %02X", val));
|
||||
else if (val == 0xC8)
|
||||
line.append (String.format ("EOR %02X", val));
|
||||
else if (val == 0xCA)
|
||||
line.append (String.format ("JMP %02X", val));
|
||||
else if (val == 0xCB)
|
||||
line.append (String.format ("JSR %02X", val));
|
||||
else if (val == 0xCD)
|
||||
line.append (String.format ("LDA %02X", val));
|
||||
else if (val == 0xCE)
|
||||
line.append (String.format ("LDX %02X", val));
|
||||
else if (val == 0xCF)
|
||||
line.append (String.format ("LDY %02X", val));
|
||||
else if (val == 0xA1)
|
||||
line.append (String.format ("PHA %02X", val));
|
||||
else if (val == 0xA2)
|
||||
line.append (String.format ("PLA %02X", val));
|
||||
else if (val == 0xA5)
|
||||
line.append (String.format ("RTS %02X", val));
|
||||
else if (val == 0xA9)
|
||||
line.append (String.format ("SEC %02X", val));
|
||||
else if (val == 0xAD)
|
||||
line.append (String.format ("TAY %02X", val));
|
||||
else if (val == 0x82)
|
||||
line.append (String.format ("BMI %02X", val));
|
||||
else if (val == 0x84)
|
||||
line.append (String.format ("BCS %02X", val));
|
||||
else if (val == 0x85)
|
||||
line.append (String.format ("BPL %02X", val));
|
||||
else if (val == 0x86)
|
||||
line.append (String.format ("BNE %02X", val));
|
||||
else if (val == 0x87)
|
||||
line.append (String.format ("BEQ %02X", val));
|
||||
else if (val == 0x99)
|
||||
line.append (String.format ("CLC %02X", val));
|
||||
else if (val == 0x9C)
|
||||
line.append (String.format ("DEX %02X", val));
|
||||
else if (val == 0x9F)
|
||||
line.append (String.format ("INY %02X", val));
|
||||
else
|
||||
line.append (String.format (".%02X.", val));
|
||||
|
||||
line.append (' ');
|
||||
++ptr;
|
||||
if (buffer[ptr] < 0x20 && showByte)
|
||||
{
|
||||
val = buffer[ptr] & 0xFF;
|
||||
line.append (String.format (".%02X. ", val));
|
||||
}
|
||||
}
|
||||
else
|
||||
line.append ((char) val);
|
||||
}
|
||||
return line.toString ();
|
||||
}
|
||||
line.append (' ');
|
||||
++ptr;
|
||||
if (buffer[ptr] < 0x20 && showByte)
|
||||
{
|
||||
val = buffer[ptr] & 0xFF;
|
||||
line.append (String.format (".%02X. ", val));
|
||||
}
|
||||
}
|
||||
else
|
||||
line.append ((char) val);
|
||||
}
|
||||
return line.toString ();
|
||||
}
|
||||
}
|
|
@ -38,7 +38,7 @@ public class VisicalcFile extends AbstractFile
|
|||
debug = value;
|
||||
}
|
||||
|
||||
public void setDebug (boolean value)
|
||||
public static void setDebug (boolean value)
|
||||
{
|
||||
debug = value;
|
||||
}
|
||||
|
|
|
@ -11,51 +11,54 @@ import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
|||
|
||||
public class TextDiskCreator extends AbstractDiskCreator
|
||||
{
|
||||
public void createDisk ()
|
||||
{
|
||||
File f = new File ("D:\\DiskDetails.txt");
|
||||
FileWriter out = null;
|
||||
@Override
|
||||
public void createDisk ()
|
||||
{
|
||||
File f = new File ("D:\\DiskDetails.txt");
|
||||
FileWriter out = null;
|
||||
|
||||
try
|
||||
{
|
||||
out = new FileWriter (f);
|
||||
printDisk (out);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace ();
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
out.close ();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace ();
|
||||
}
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
out = new FileWriter (f);
|
||||
printDisk (out);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace ();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (out != null)
|
||||
try
|
||||
{
|
||||
out.close ();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void printDisk (FileWriter out) throws IOException
|
||||
{
|
||||
Enumeration<DefaultMutableTreeNode> children = getEnumeration ();
|
||||
private void printDisk (FileWriter out) throws IOException
|
||||
{
|
||||
Enumeration<DefaultMutableTreeNode> children = getEnumeration ();
|
||||
|
||||
if (children == null)
|
||||
return;
|
||||
if (children == null)
|
||||
return;
|
||||
|
||||
while (children.hasMoreElements ())
|
||||
{
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) children.nextElement ();
|
||||
AppleFileSource afs = (AppleFileSource) node.getUserObject ();
|
||||
out.write (afs.getDataSource ().getText () + String.format ("%n"));
|
||||
}
|
||||
while (children.hasMoreElements ())
|
||||
{
|
||||
DefaultMutableTreeNode node = children.nextElement ();
|
||||
AppleFileSource afs = (AppleFileSource) node.getUserObject ();
|
||||
out.write (afs.getDataSource ().getText () + String.format ("%n"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public String getMenuText ()
|
||||
{
|
||||
return "create text disk";
|
||||
}
|
||||
@Override
|
||||
public String getMenuText ()
|
||||
{
|
||||
return "create text disk";
|
||||
}
|
||||
}
|
|
@ -114,7 +114,7 @@ public class DirectoryEntry implements AppleFileSource
|
|||
|
||||
public String line ()
|
||||
{
|
||||
int blocks = ((rc & 0xF0) >> 3) + (((rc & 0x0F) + 7) / 8);
|
||||
// int blocks = ((rc & 0xF0) >> 3) + (((rc & 0x0F) + 7) / 8);
|
||||
String bytes = HexFormatter.getHexString (blockList, 0, 16);
|
||||
bytes = bytes.replaceAll ("00", " ");
|
||||
|
||||
|
|
|
@ -192,7 +192,11 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
|
|||
public String getName ()
|
||||
{
|
||||
if (originalPath != null)
|
||||
return originalPath.getFileName ().toString ();
|
||||
{
|
||||
Path path = originalPath.getFileName ();
|
||||
if (path != null)
|
||||
return path.toString ();
|
||||
}
|
||||
return disk.getFile ().getName ();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@ package com.bytezone.diskbrowser.disk;
|
|||
|
||||
public interface DiskAddress extends Comparable<DiskAddress>
|
||||
{
|
||||
public int getBlock ();
|
||||
public int getBlock ();
|
||||
|
||||
public int getTrack ();
|
||||
public int getTrack ();
|
||||
|
||||
public int getSector ();
|
||||
public int getSector ();
|
||||
|
||||
public Disk getDisk ();
|
||||
public Disk getDisk ();
|
||||
}
|
|
@ -170,58 +170,58 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
|
||||
case Binary: // binary file
|
||||
case Relocatable: // relocatable binary file
|
||||
if (buffer.length == 0)
|
||||
appleFile = new AssemblerProgram (name, buffer, 0);
|
||||
// if (buffer.length == 0)
|
||||
// appleFile = new AssemblerProgram (name, buffer, 0);
|
||||
// else
|
||||
// {
|
||||
int loadAddress = HexFormatter.intValue (buffer[0], buffer[1]);
|
||||
reportedLength = HexFormatter.intValue (buffer[2], buffer[3]);
|
||||
if (reportedLength == 0)
|
||||
{
|
||||
System.out.println (name.trim () + " reported length : 0 - reverting to "
|
||||
+ (buffer.length - 4));
|
||||
reportedLength = buffer.length - 4;
|
||||
}
|
||||
|
||||
// buffer is a multiple of the block size, so it usually needs to be reduced
|
||||
if ((reportedLength + 4) <= buffer.length)
|
||||
{
|
||||
exactBuffer = new byte[reportedLength];
|
||||
// extraBuffer = new byte[buffer.length - reportedLength - 4];
|
||||
// System.arraycopy (buffer, reportedLength + 4, extraBuffer, 0,
|
||||
// extraBuffer.length);
|
||||
}
|
||||
else
|
||||
exactBuffer = new byte[buffer.length - 4]; // reported length is too long
|
||||
|
||||
System.arraycopy (buffer, 4, exactBuffer, 0, exactBuffer.length);
|
||||
|
||||
if (ShapeTable.isShapeTable (exactBuffer))
|
||||
appleFile = new ShapeTable (name, exactBuffer);
|
||||
else if (HiResImage.isGif (exactBuffer))
|
||||
appleFile = new HiResImage (name, exactBuffer);
|
||||
else if (loadAddress == 0x2000 || loadAddress == 0x4000)
|
||||
{
|
||||
if ((reportedLength > 0x1F00 && reportedLength <= 0x4000)
|
||||
|| ((name.equals ("FLY LOGO") && reportedLength == 0x14FA)))
|
||||
appleFile = new HiResImage (name, exactBuffer);
|
||||
// else if
|
||||
// appleFile = new HiResImage (name, unscrunch (exactBuffer));
|
||||
else
|
||||
appleFile = new AssemblerProgram (name, exactBuffer, loadAddress);
|
||||
}
|
||||
else if (name.endsWith (".S"))
|
||||
appleFile = new MerlinSource (name, exactBuffer);
|
||||
else
|
||||
{
|
||||
int loadAddress = HexFormatter.intValue (buffer[0], buffer[1]);
|
||||
reportedLength = HexFormatter.intValue (buffer[2], buffer[3]);
|
||||
if (reportedLength == 0)
|
||||
{
|
||||
System.out.println (name.trim () + " reported length : 0 - reverting to "
|
||||
+ (buffer.length - 4));
|
||||
reportedLength = buffer.length - 4;
|
||||
}
|
||||
|
||||
// buffer is a multiple of the block size, so it usually needs to be reduced
|
||||
if ((reportedLength + 4) <= buffer.length)
|
||||
{
|
||||
exactBuffer = new byte[reportedLength];
|
||||
// extraBuffer = new byte[buffer.length - reportedLength - 4];
|
||||
// System.arraycopy (buffer, reportedLength + 4, extraBuffer, 0,
|
||||
// extraBuffer.length);
|
||||
}
|
||||
else
|
||||
exactBuffer = new byte[buffer.length - 4]; // reported length is too long
|
||||
|
||||
System.arraycopy (buffer, 4, exactBuffer, 0, exactBuffer.length);
|
||||
|
||||
if (ShapeTable.isShapeTable (exactBuffer))
|
||||
appleFile = new ShapeTable (name, exactBuffer);
|
||||
else if (HiResImage.isGif (exactBuffer))
|
||||
appleFile = new HiResImage (name, exactBuffer);
|
||||
else if (loadAddress == 0x2000 || loadAddress == 0x4000)
|
||||
{
|
||||
if ((reportedLength > 0x1F00 && reportedLength <= 0x4000)
|
||||
|| ((name.equals ("FLY LOGO") && reportedLength == 0x14FA)))
|
||||
appleFile = new HiResImage (name, exactBuffer);
|
||||
// else if
|
||||
// appleFile = new HiResImage (name, unscrunch (exactBuffer));
|
||||
else
|
||||
appleFile = new AssemblerProgram (name, exactBuffer, loadAddress);
|
||||
}
|
||||
else if (name.endsWith (".S"))
|
||||
appleFile = new MerlinSource (name, exactBuffer);
|
||||
else
|
||||
{
|
||||
appleFile = new AssemblerProgram (name, exactBuffer, loadAddress);
|
||||
// System.out.printf ("%d %d%n", exactBuffer.length, reportedLength);
|
||||
if ((exactBuffer.length + 4) < buffer.length)
|
||||
((AssemblerProgram) appleFile)
|
||||
.setExtraBuffer (buffer, exactBuffer.length + 4,
|
||||
buffer.length - (exactBuffer.length + 4));
|
||||
}
|
||||
appleFile = new AssemblerProgram (name, exactBuffer, loadAddress);
|
||||
// System.out.printf ("%d %d%n", exactBuffer.length, reportedLength);
|
||||
if ((exactBuffer.length + 4) < buffer.length)
|
||||
((AssemblerProgram) appleFile)
|
||||
.setExtraBuffer (buffer, exactBuffer.length + 4,
|
||||
buffer.length - (exactBuffer.length + 4));
|
||||
}
|
||||
// }
|
||||
break;
|
||||
|
||||
case SS: // what is this?
|
||||
|
@ -235,7 +235,7 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
|||
break;
|
||||
|
||||
case BB: // what is this?
|
||||
int loadAddress = HexFormatter.intValue (buffer[0], buffer[1]);
|
||||
loadAddress = HexFormatter.intValue (buffer[0], buffer[1]);
|
||||
reportedLength = HexFormatter.intValue (buffer[2], buffer[3]);
|
||||
exactBuffer = new byte[reportedLength];
|
||||
System.arraycopy (buffer, 4, exactBuffer, 0, reportedLength);
|
||||
|
|
|
@ -23,10 +23,11 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
|||
{
|
||||
super (windowTitle);
|
||||
|
||||
State state = new State (prefs);
|
||||
|
||||
if (false)
|
||||
{
|
||||
State state = new State (prefs);
|
||||
state.clear ();
|
||||
}
|
||||
|
||||
JToolBar toolBar = new JToolBar ("Toolbar", JToolBar.HORIZONTAL);
|
||||
MenuHandler menuHandler = new MenuHandler (prefs);
|
||||
|
|
|
@ -4,14 +4,7 @@ import java.awt.image.BufferedImage;
|
|||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.*;
|
||||
import java.util.zip.CRC32;
|
||||
import java.util.zip.Checksum;
|
||||
|
||||
|
@ -49,8 +42,8 @@ public class TreeBuilder
|
|||
|
||||
public TreeBuilder (File folder)
|
||||
{
|
||||
assert(folder.exists ());
|
||||
assert(folder.isDirectory ());
|
||||
assert (folder.exists ());
|
||||
assert (folder.isDirectory ());
|
||||
|
||||
long start = System.currentTimeMillis ();
|
||||
|
||||
|
@ -299,20 +292,24 @@ public class TreeBuilder
|
|||
+ " Date Size Type\n");
|
||||
text.append ("- ----------------------------------------"
|
||||
+ " ----------- -------------- ---------\n");
|
||||
for (File f : file.listFiles ())
|
||||
{
|
||||
String name = f.getName ();
|
||||
if (name.startsWith ("."))
|
||||
continue;
|
||||
|
||||
Date d = new Date (f.lastModified ());
|
||||
int pos = name.lastIndexOf ('.');
|
||||
String type = pos > 0 && !f.isDirectory () ? name.substring (pos) : "";
|
||||
String size = f.isDirectory () ? "" : String.format ("%,14d", f.length ());
|
||||
text.append (String.format ("%s %-40.40s %s %-14s %s%n",
|
||||
f.isDirectory () ? "D" : " ", name, sdf.format (d),
|
||||
size, type));
|
||||
}
|
||||
File[] files = file.listFiles ();
|
||||
if (files != null)
|
||||
for (File f : file.listFiles ())
|
||||
{
|
||||
String name = f.getName ();
|
||||
if (name.startsWith ("."))
|
||||
continue;
|
||||
|
||||
Date d = new Date (f.lastModified ());
|
||||
int pos = name.lastIndexOf ('.');
|
||||
String type = pos > 0 && !f.isDirectory () ? name.substring (pos) : "";
|
||||
String size = f.isDirectory () ? "" : String.format ("%,14d", f.length ());
|
||||
text.append (String.format ("%s %-40.40s %s %-14s %s%n",
|
||||
f.isDirectory () ? "D" : " ", name, sdf.format (d),
|
||||
size, type));
|
||||
}
|
||||
|
||||
if (text.length () > 0)
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
return text.toString ();
|
||||
|
|
|
@ -11,75 +11,75 @@ import com.bytezone.diskbrowser.disk.FormattedDisk;
|
|||
|
||||
class AttributeManager extends AbstractFile
|
||||
{
|
||||
List<Statistic> list = new ArrayList<Statistic> ();
|
||||
Header header;
|
||||
List<Statistic> list = new ArrayList<Statistic> ();
|
||||
Header header;
|
||||
|
||||
public AttributeManager (String name, byte[] buffer, Header header)
|
||||
{
|
||||
super (name, buffer);
|
||||
this.header = header;
|
||||
public AttributeManager (String name, byte[] buffer, Header header)
|
||||
{
|
||||
super (name, buffer);
|
||||
this.header = header;
|
||||
|
||||
for (int attrNo = 0; attrNo < 32; attrNo++)
|
||||
list.add (new Statistic (attrNo));
|
||||
}
|
||||
for (int attrNo = 0; attrNo < 32; attrNo++)
|
||||
list.add (new Statistic (attrNo));
|
||||
}
|
||||
|
||||
public void addNodes (DefaultMutableTreeNode node, FormattedDisk disk)
|
||||
{
|
||||
node.setAllowsChildren (true);
|
||||
public void addNodes (DefaultMutableTreeNode node, FormattedDisk disk)
|
||||
{
|
||||
node.setAllowsChildren (true);
|
||||
|
||||
int count = 0;
|
||||
for (Statistic stat : list)
|
||||
{
|
||||
DefaultMutableTreeNode child =
|
||||
new DefaultMutableTreeNode (new DefaultAppleFileSource (("Attribute " + count++), stat
|
||||
.getText (), disk));
|
||||
node.add (child);
|
||||
child.setAllowsChildren (false);
|
||||
}
|
||||
}
|
||||
int count = 0;
|
||||
for (Statistic stat : list)
|
||||
{
|
||||
DefaultMutableTreeNode child = new DefaultMutableTreeNode (
|
||||
new DefaultAppleFileSource (("Attribute " + count++), stat.getText (), disk));
|
||||
node.add (child);
|
||||
child.setAllowsChildren (false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ("Attribute Frequency\n");
|
||||
text.append ("--------- ---------\n");
|
||||
@Override
|
||||
public String getText ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ("Attribute Frequency\n");
|
||||
text.append ("--------- ---------\n");
|
||||
|
||||
for (Statistic stat : list)
|
||||
text.append (String.format ("%s%n", stat));
|
||||
if (text.length () > 0)
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
return text.toString ();
|
||||
}
|
||||
for (Statistic stat : list)
|
||||
text.append (String.format ("%s%n", stat));
|
||||
if (text.length () > 0)
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
private class Statistic
|
||||
{
|
||||
int id;
|
||||
List<ZObject> list = new ArrayList<ZObject> ();
|
||||
private class Statistic
|
||||
{
|
||||
int id;
|
||||
List<ZObject> list = new ArrayList<ZObject> ();
|
||||
|
||||
public Statistic (int id)
|
||||
{
|
||||
this.id = id;
|
||||
for (ZObject o : header.objectManager)
|
||||
if (o.attributes.get (id))
|
||||
list.add (o);
|
||||
}
|
||||
public Statistic (int id)
|
||||
{
|
||||
this.id = id;
|
||||
for (ZObject o : header.objectManager)
|
||||
if (o.attributes.get (id))
|
||||
list.add (o);
|
||||
}
|
||||
|
||||
String getText ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ("Objects with attribute " + id + " set:\n\n");
|
||||
for (ZObject o : list)
|
||||
{
|
||||
text.append (String.format ("%3d %-28s%n", o.id, o.name));
|
||||
}
|
||||
if (text.length () > 0)
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
return text.toString ();
|
||||
}
|
||||
String getText ()
|
||||
{
|
||||
StringBuilder text =
|
||||
new StringBuilder ("Objects with attribute " + id + " set:\n\n");
|
||||
for (ZObject o : list)
|
||||
{
|
||||
text.append (String.format ("%3d %-28s%n", o.id, 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 ());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
return String.format (" %2d %3d", id, list.size ());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,155 +13,158 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
|||
|
||||
class CodeManager extends AbstractFile
|
||||
{
|
||||
Header header;
|
||||
int codeSize;
|
||||
Map<Integer, Routine> routines = new TreeMap<Integer, Routine> ();
|
||||
Header header;
|
||||
int codeSize;
|
||||
Map<Integer, Routine> routines = new TreeMap<Integer, Routine> ();
|
||||
|
||||
public CodeManager (Header header)
|
||||
{
|
||||
super ("Code", header.buffer);
|
||||
this.header = header;
|
||||
}
|
||||
public CodeManager (Header header)
|
||||
{
|
||||
super ("Code", header.buffer);
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
public void addNodes (DefaultMutableTreeNode root, FormattedDisk disk)
|
||||
{
|
||||
root.setAllowsChildren (true);
|
||||
public void addNodes (DefaultMutableTreeNode root, FormattedDisk disk)
|
||||
{
|
||||
root.setAllowsChildren (true);
|
||||
|
||||
codeSize = header.stringPointer - header.highMemory; // should be set by now - do this better!
|
||||
codeSize = header.stringPointer - header.highMemory; // should be set by now - do this better!
|
||||
|
||||
int count = 0;
|
||||
for (Routine routine : routines.values ())
|
||||
{
|
||||
DefaultMutableTreeNode node =
|
||||
new DefaultMutableTreeNode (new DefaultAppleFileSource (String.format ("%3d %s (%04X)",
|
||||
++count, routine.name, routine.startPtr / 2), routine, disk));
|
||||
node.setAllowsChildren (false);
|
||||
root.add (node);
|
||||
}
|
||||
}
|
||||
int count = 0;
|
||||
for (Routine routine : routines.values ())
|
||||
{
|
||||
DefaultMutableTreeNode node =
|
||||
new DefaultMutableTreeNode (new DefaultAppleFileSource (
|
||||
String.format ("%3d %s (%04X)", ++count, routine.getName (),
|
||||
routine.startPtr / 2),
|
||||
routine, disk));
|
||||
node.setAllowsChildren (false);
|
||||
root.add (node);
|
||||
}
|
||||
}
|
||||
|
||||
public void addMissingRoutines ()
|
||||
{
|
||||
System.out.printf ("%nWalking the code block%n%n");
|
||||
int total = 0;
|
||||
int ptr = header.highMemory;
|
||||
while (ptr < header.stringPointer)
|
||||
{
|
||||
if (ptr % 2 == 1) // routine must start on a word boundary
|
||||
ptr++;
|
||||
public void addMissingRoutines ()
|
||||
{
|
||||
System.out.printf ("%nWalking the code block%n%n");
|
||||
int total = 0;
|
||||
int ptr = header.highMemory;
|
||||
|
||||
if (containsRoutineAt (ptr))
|
||||
{
|
||||
ptr += getRoutine (ptr).length;
|
||||
continue;
|
||||
}
|
||||
while (ptr < header.stringPointer)
|
||||
{
|
||||
if (ptr >= 0 && ptr % 2 == 1) // routine must start on a word boundary
|
||||
ptr++;
|
||||
|
||||
Routine routine = addRoutine (ptr, 0);
|
||||
if (routine == null)
|
||||
{
|
||||
System.out.printf ("Invalid routine found : %05X%n", ptr);
|
||||
ptr = findNextRoutine (ptr + 1);
|
||||
System.out.printf ("skipping to %05X%n", ptr);
|
||||
if (ptr == 0)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
total++;
|
||||
ptr += routine.length;
|
||||
}
|
||||
}
|
||||
System.out.printf ("%n%d new routines found by walking the code block%n%n", total);
|
||||
}
|
||||
if (containsRoutineAt (ptr))
|
||||
{
|
||||
ptr += getRoutine (ptr).length;
|
||||
continue;
|
||||
}
|
||||
|
||||
private int findNextRoutine (int address)
|
||||
{
|
||||
for (Routine routine : routines.values ())
|
||||
if (routine.startPtr > address)
|
||||
return routine.startPtr;
|
||||
return 0;
|
||||
}
|
||||
Routine routine = addRoutine (ptr, 0);
|
||||
if (routine == null)
|
||||
{
|
||||
System.out.printf ("Invalid routine found : %05X%n", ptr);
|
||||
ptr = findNextRoutine (ptr + 1);
|
||||
System.out.printf ("skipping to %05X%n", ptr);
|
||||
if (ptr == 0)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
total++;
|
||||
ptr += routine.length;
|
||||
}
|
||||
}
|
||||
System.out.printf ("%n%d new routines found by walking the code block%n%n", total);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
int count = 0;
|
||||
int nextAddress = header.highMemory;
|
||||
text.append (" # Address Size Lines Strings Called Calls Gap Pack\n");
|
||||
text.append ("--- ------- ---- ----- ------- ------ ----- --- ----\n");
|
||||
for (Routine r : routines.values ())
|
||||
{
|
||||
int gap = r.startPtr - nextAddress;
|
||||
text.append (String.format (
|
||||
"%3d %05X %5d %3d %2d %3d %3d %4d %04X%n", ++count,
|
||||
r.startPtr, r.length, r.instructions.size (), r.strings, r.calledBy.size (), r.calls
|
||||
.size (), gap, r.startPtr / 2));
|
||||
private int findNextRoutine (int address)
|
||||
{
|
||||
for (Routine routine : routines.values ())
|
||||
if (routine.startPtr > address)
|
||||
return routine.startPtr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
nextAddress = r.startPtr + r.length;
|
||||
}
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
return text.toString ();
|
||||
}
|
||||
@Override
|
||||
public String getText ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
int count = 0;
|
||||
int nextAddress = header.highMemory;
|
||||
text.append (" # Address Size Lines Strings Called Calls Gap Pack\n");
|
||||
text.append ("--- ------- ---- ----- ------- ------ ----- --- ----\n");
|
||||
for (Routine r : routines.values ())
|
||||
{
|
||||
int gap = r.startPtr - nextAddress;
|
||||
text.append (String
|
||||
.format ("%3d %05X %5d %3d %2d %3d %3d %4d %04X%n",
|
||||
++count, r.startPtr, r.length, r.instructions.size (), r.strings,
|
||||
r.calledBy.size (), r.calls.size (), gap, r.startPtr / 2));
|
||||
|
||||
public boolean containsRoutineAt (int address)
|
||||
{
|
||||
return (routines.containsKey (address));
|
||||
}
|
||||
nextAddress = r.startPtr + r.length;
|
||||
}
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
public void addCodeRoutines ()
|
||||
{
|
||||
List<Integer> routines = header.objectManager.getCodeRoutines ();
|
||||
System.out.println ("Adding " + routines.size () + " code routines");
|
||||
for (Integer address : routines)
|
||||
addRoutine (address, 0);
|
||||
}
|
||||
public boolean containsRoutineAt (int address)
|
||||
{
|
||||
return (routines.containsKey (address));
|
||||
}
|
||||
|
||||
public void addActionRoutines ()
|
||||
{
|
||||
List<Integer> routines = header.grammar.getActionRoutines ();
|
||||
System.out.println ("Adding " + routines.size () + " action routines");
|
||||
for (Integer address : routines)
|
||||
addRoutine (address, 0);
|
||||
}
|
||||
public void addCodeRoutines ()
|
||||
{
|
||||
List<Integer> routines = header.objectManager.getCodeRoutines ();
|
||||
System.out.println ("Adding " + routines.size () + " code routines");
|
||||
for (Integer address : routines)
|
||||
addRoutine (address, 0);
|
||||
}
|
||||
|
||||
public Routine addRoutine (int address, int caller)
|
||||
{
|
||||
if (address == 0) // stack-based call
|
||||
return null;
|
||||
if (address > header.fileLength)
|
||||
return null;
|
||||
public void addActionRoutines ()
|
||||
{
|
||||
List<Integer> routines = header.grammar.getActionRoutines ();
|
||||
System.out.println ("Adding " + routines.size () + " action routines");
|
||||
for (Integer address : routines)
|
||||
addRoutine (address, 0);
|
||||
}
|
||||
|
||||
// check whether we already have this routine
|
||||
if (routines.containsKey (address))
|
||||
{
|
||||
Routine routine = routines.get (address);
|
||||
routine.addCaller (caller);
|
||||
return routine;
|
||||
}
|
||||
public Routine addRoutine (int address, int caller)
|
||||
{
|
||||
if (address == 0) // stack-based call
|
||||
return null;
|
||||
if (address > header.fileLength)
|
||||
return null;
|
||||
|
||||
// try to create a new Routine
|
||||
Routine r = new Routine (address, header, caller);
|
||||
if (r.length == 0) // invalid routine
|
||||
return null;
|
||||
// check whether we already have this routine
|
||||
if (routines.containsKey (address))
|
||||
{
|
||||
Routine routine = routines.get (address);
|
||||
routine.addCaller (caller);
|
||||
return routine;
|
||||
}
|
||||
|
||||
// recursively add all routines called by this one
|
||||
routines.put (address, r);
|
||||
for (int ptr : r.calls)
|
||||
addRoutine (ptr, address);
|
||||
// try to create a new Routine
|
||||
Routine r = new Routine (address, header, caller);
|
||||
if (r.length == 0) // invalid routine
|
||||
return null;
|
||||
|
||||
return r;
|
||||
}
|
||||
// recursively add all routines called by this one
|
||||
routines.put (address, r);
|
||||
for (int ptr : r.calls)
|
||||
addRoutine (ptr, address);
|
||||
|
||||
public Routine getRoutine (int address)
|
||||
{
|
||||
return routines.get (address);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHexDump ()
|
||||
{
|
||||
// this depends on codeSize being set after the strings have been processed
|
||||
return HexFormatter.format (buffer, header.highMemory, codeSize);
|
||||
}
|
||||
public 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);
|
||||
}
|
||||
}
|
|
@ -128,9 +128,13 @@ public class InfocomDisk extends AbstractFormattedDisk
|
|||
break;
|
||||
}
|
||||
}
|
||||
int ptr = 255;
|
||||
while (buffer[ptr--] == 0)
|
||||
fileSize--;
|
||||
|
||||
if (buffer != null)
|
||||
{
|
||||
int ptr = 255;
|
||||
while (buffer[ptr--] == 0)
|
||||
fileSize--;
|
||||
}
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class ObjectManager extends InfocomAbstractFile implements Iterable<ZObject>
|
|||
FormattedDisk disk)
|
||||
{
|
||||
DefaultMutableTreeNode child = new DefaultMutableTreeNode (
|
||||
new DefaultAppleFileSource (object.name, object, disk));
|
||||
new DefaultAppleFileSource (object.getName (), object, disk));
|
||||
parentNode.add (child);
|
||||
if (object.sibling > 0)
|
||||
buildObjectTree (header.objectManager.list.get (object.sibling - 1), parentNode,
|
||||
|
|
|
@ -11,82 +11,85 @@ import com.bytezone.diskbrowser.disk.FormattedDisk;
|
|||
|
||||
class PropertyManager extends AbstractFile
|
||||
{
|
||||
List<Statistic> list = new ArrayList<Statistic> ();
|
||||
Header header;
|
||||
List<Statistic> list = new ArrayList<Statistic> ();
|
||||
Header header;
|
||||
|
||||
public PropertyManager (String name, byte[] buffer, Header header)
|
||||
{
|
||||
super (name, buffer);
|
||||
this.header = header;
|
||||
public PropertyManager (String name, byte[] buffer, Header header)
|
||||
{
|
||||
super (name, buffer);
|
||||
this.header = header;
|
||||
|
||||
for (int propertyNo = 1; propertyNo <= 31; propertyNo++)
|
||||
{
|
||||
Statistic statistic = new Statistic (propertyNo);
|
||||
list.add (statistic);
|
||||
}
|
||||
}
|
||||
for (int propertyNo = 1; propertyNo <= 31; propertyNo++)
|
||||
{
|
||||
Statistic statistic = new Statistic (propertyNo);
|
||||
list.add (statistic);
|
||||
}
|
||||
}
|
||||
|
||||
public void addNodes (DefaultMutableTreeNode node, FormattedDisk disk)
|
||||
{
|
||||
node.setAllowsChildren (true);
|
||||
public void addNodes (DefaultMutableTreeNode node, FormattedDisk disk)
|
||||
{
|
||||
node.setAllowsChildren (true);
|
||||
|
||||
for (Statistic stat : list)
|
||||
if (stat.list.size () > 0)
|
||||
{
|
||||
String title = "Property " + header.propertyNames[stat.id].trim ();
|
||||
DefaultMutableTreeNode child =
|
||||
new DefaultMutableTreeNode (new DefaultAppleFileSource (title, stat.getText (), disk));
|
||||
node.add (child);
|
||||
child.setAllowsChildren (false);
|
||||
}
|
||||
}
|
||||
for (Statistic stat : list)
|
||||
if (stat.list.size () > 0)
|
||||
{
|
||||
String title = "Property " + header.propertyNames[stat.id].trim ();
|
||||
DefaultMutableTreeNode child = new DefaultMutableTreeNode (
|
||||
new DefaultAppleFileSource (title, stat.getText (), disk));
|
||||
node.add (child);
|
||||
child.setAllowsChildren (false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ("Property Type Frequency\n");
|
||||
text.append ("-------- ----- ---------\n");
|
||||
@Override
|
||||
public String getText ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ("Property Type Frequency\n");
|
||||
text.append ("-------- ----- ---------\n");
|
||||
|
||||
for (Statistic stat : list)
|
||||
text.append (String.format ("%s%n", stat));
|
||||
if (text.length () > 0)
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
return text.toString ();
|
||||
}
|
||||
for (Statistic stat : list)
|
||||
text.append (String.format ("%s%n", stat));
|
||||
if (text.length () > 0)
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
private class Statistic
|
||||
{
|
||||
int id;
|
||||
List<ZObject> list = new ArrayList<ZObject> ();
|
||||
private class Statistic
|
||||
{
|
||||
int id;
|
||||
List<ZObject> list = new ArrayList<ZObject> ();
|
||||
|
||||
public Statistic (int id)
|
||||
{
|
||||
this.id = id;
|
||||
for (ZObject o : header.objectManager)
|
||||
{
|
||||
ZObject.Property p = o.getProperty (id);
|
||||
if (p != null)
|
||||
list.add (o);
|
||||
}
|
||||
}
|
||||
public Statistic (int id)
|
||||
{
|
||||
this.id = id;
|
||||
for (ZObject o : header.objectManager)
|
||||
{
|
||||
ZObject.Property p = o.getProperty (id);
|
||||
if (p != null)
|
||||
list.add (o);
|
||||
}
|
||||
}
|
||||
|
||||
String getText ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ("Objects with property " + id + " set:\n\n");
|
||||
for (ZObject o : list)
|
||||
{
|
||||
ZObject.Property p = o.getProperty (id);
|
||||
text.append (String.format ("%3d %-29s%s%n", o.id, o.name, p.toString ().substring (7)));
|
||||
}
|
||||
if (text.length () > 0)
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
return text.toString ();
|
||||
}
|
||||
String getText ()
|
||||
{
|
||||
StringBuilder text =
|
||||
new StringBuilder ("Objects with property " + id + " set:\n\n");
|
||||
for (ZObject o : list)
|
||||
{
|
||||
ZObject.Property p = o.getProperty (id);
|
||||
text.append (String.format ("%3d %-29s%s%n", o.id, o.getName (),
|
||||
p.toString ().substring (7)));
|
||||
}
|
||||
if (text.length () > 0)
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
return String.format (" %2d %-6s %3d", id, header.propertyNames[id], list.size ());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
return String.format (" %2d %-6s %3d", id, header.propertyNames[id],
|
||||
list.size ());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -60,12 +60,12 @@ class PascalCodeObject implements AppleFileSource
|
|||
@Override
|
||||
public String getUniqueName ()
|
||||
{
|
||||
return segment.name; // this should be fileName/segmentName
|
||||
return segment.getName (); // this should be fileName/segmentName
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
return segment.name;
|
||||
return segment.getName ();
|
||||
}
|
||||
}
|
|
@ -5,12 +5,12 @@ class Pi extends Function
|
|||
Pi (Sheet parent, String text)
|
||||
{
|
||||
super (parent, text);
|
||||
value = Math.PI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value calculate ()
|
||||
{
|
||||
value = 3.1415926536;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -283,7 +283,7 @@ class Character extends AbstractFile
|
|||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
return String.format ("%s%-15s (%d)", equipped ? "*" : " ", item.name,
|
||||
return String.format ("%s%-15s (%d)", equipped ? "*" : " ", item.getName (),
|
||||
item.getCost ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,314 +9,316 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
|||
|
||||
class MazeCell
|
||||
{
|
||||
static Dimension cellSize = new Dimension (22, 22); // size in pixels
|
||||
static Dimension cellSize = new Dimension (22, 22); // size in pixels
|
||||
|
||||
boolean northWall;
|
||||
boolean southWall;
|
||||
boolean eastWall;
|
||||
boolean westWall;
|
||||
boolean northWall;
|
||||
boolean southWall;
|
||||
boolean eastWall;
|
||||
boolean westWall;
|
||||
|
||||
boolean northDoor;
|
||||
boolean southDoor;
|
||||
boolean eastDoor;
|
||||
boolean westDoor;
|
||||
boolean northDoor;
|
||||
boolean southDoor;
|
||||
boolean eastDoor;
|
||||
boolean westDoor;
|
||||
|
||||
boolean darkness;
|
||||
boolean darkness;
|
||||
|
||||
boolean stairs;
|
||||
boolean pit;
|
||||
boolean spinner;
|
||||
boolean chute;
|
||||
boolean elevator;
|
||||
boolean monsterLair;
|
||||
boolean rock;
|
||||
boolean teleport;
|
||||
boolean spellsBlocked;
|
||||
boolean stairs;
|
||||
boolean pit;
|
||||
boolean spinner;
|
||||
boolean chute;
|
||||
boolean elevator;
|
||||
boolean monsterLair;
|
||||
boolean rock;
|
||||
boolean teleport;
|
||||
boolean spellsBlocked;
|
||||
|
||||
int elevatorFrom;
|
||||
int elevatorTo;
|
||||
int elevatorFrom;
|
||||
int elevatorTo;
|
||||
|
||||
int messageType;
|
||||
int monsterID = -1;
|
||||
int itemID;
|
||||
int messageType;
|
||||
int monsterID = -1;
|
||||
int itemID;
|
||||
|
||||
int unknown;
|
||||
int unknown;
|
||||
|
||||
MazeAddress address;
|
||||
MazeAddress addressTo; // if teleport/stairs/chute
|
||||
public Message message;
|
||||
public List<Monster> monsters;
|
||||
public Item itemRequired;
|
||||
public Item itemObtained;
|
||||
MazeAddress address;
|
||||
MazeAddress addressTo; // if teleport/stairs/chute
|
||||
public Message message;
|
||||
public List<Monster> monsters;
|
||||
public Item itemRequired;
|
||||
public Item itemObtained;
|
||||
|
||||
public MazeCell (MazeAddress address)
|
||||
{
|
||||
this.address = address;
|
||||
}
|
||||
public MazeCell (MazeAddress address)
|
||||
{
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public void draw (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.setColor (Color.WHITE);
|
||||
public void draw (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.setColor (Color.WHITE);
|
||||
|
||||
if (westWall)
|
||||
drawWest (g, x, y);
|
||||
if (eastWall)
|
||||
drawEast (g, x, y);
|
||||
if (northWall)
|
||||
drawNorth (g, x, y);
|
||||
if (southWall)
|
||||
drawSouth (g, x, y);
|
||||
if (westWall)
|
||||
drawWest (g, x, y);
|
||||
if (eastWall)
|
||||
drawEast (g, x, y);
|
||||
if (northWall)
|
||||
drawNorth (g, x, y);
|
||||
if (southWall)
|
||||
drawSouth (g, x, y);
|
||||
|
||||
g.setColor (Color.RED);
|
||||
g.setColor (Color.RED);
|
||||
|
||||
if (westDoor)
|
||||
drawWest (g, x, y);
|
||||
if (eastDoor)
|
||||
drawEast (g, x, y);
|
||||
if (northDoor)
|
||||
drawNorth (g, x, y);
|
||||
if (southDoor)
|
||||
drawSouth (g, x, y);
|
||||
if (westDoor)
|
||||
drawWest (g, x, y);
|
||||
if (eastDoor)
|
||||
drawEast (g, x, y);
|
||||
if (northDoor)
|
||||
drawNorth (g, x, y);
|
||||
if (southDoor)
|
||||
drawSouth (g, x, y);
|
||||
|
||||
g.setColor (Color.GREEN);
|
||||
g.setColor (Color.GREEN);
|
||||
|
||||
if (westDoor && westWall)
|
||||
drawWest (g, x, y);
|
||||
if (eastDoor && eastWall)
|
||||
drawEast (g, x, y);
|
||||
if (northDoor && northWall)
|
||||
drawNorth (g, x, y);
|
||||
if (southDoor && southWall)
|
||||
drawSouth (g, x, y);
|
||||
if (westDoor && westWall)
|
||||
drawWest (g, x, y);
|
||||
if (eastDoor && eastWall)
|
||||
drawEast (g, x, y);
|
||||
if (northDoor && northWall)
|
||||
drawNorth (g, x, y);
|
||||
if (southDoor && southWall)
|
||||
drawSouth (g, x, y);
|
||||
|
||||
g.setColor (Color.WHITE);
|
||||
g.setColor (Color.WHITE);
|
||||
|
||||
if (monsterLair)
|
||||
drawMonsterLair (g, x, y);
|
||||
if (monsterLair)
|
||||
drawMonsterLair (g, x, y);
|
||||
|
||||
if (stairs)
|
||||
if (address.level < addressTo.level)
|
||||
drawStairsDown (g, x, y);
|
||||
else
|
||||
drawStairsUp (g, x, y);
|
||||
else if (message != null)
|
||||
drawChar (g, x, y, "M", Color.RED);
|
||||
else if (pit)
|
||||
drawPit (g, x, y);
|
||||
else if (chute)
|
||||
drawChute (g, x, y);
|
||||
else if (spinner)
|
||||
g.drawString ("S", x + 8, y + 16);
|
||||
else if (teleport)
|
||||
drawTeleport (g, x, y);
|
||||
else if (darkness)
|
||||
drawDarkness (g, x, y);
|
||||
else if (rock)
|
||||
drawRock (g, x, y);
|
||||
else if (elevator)
|
||||
drawElevator (g, x, y, (elevatorTo - elevatorFrom + 1) / 2);
|
||||
else if (monsterID >= 0)
|
||||
drawMonster (g, x, y);
|
||||
else if (spellsBlocked)
|
||||
drawSpellsBlocked (g, x, y);
|
||||
else if (unknown != 0)
|
||||
drawChar (g, x, y, HexFormatter.format1 (unknown), Color.GRAY);
|
||||
}
|
||||
if (stairs)
|
||||
if (address.level < addressTo.level)
|
||||
drawStairsDown (g, x, y);
|
||||
else
|
||||
drawStairsUp (g, x, y);
|
||||
else if (message != null)
|
||||
drawChar (g, x, y, "M", Color.RED);
|
||||
else if (pit)
|
||||
drawPit (g, x, y);
|
||||
else if (chute)
|
||||
drawChute (g, x, y);
|
||||
else if (spinner)
|
||||
g.drawString ("S", x + 8, y + 16);
|
||||
else if (teleport)
|
||||
drawTeleport (g, x, y);
|
||||
else if (darkness)
|
||||
drawDarkness (g, x, y);
|
||||
else if (rock)
|
||||
drawRock (g, x, y);
|
||||
else if (elevator)
|
||||
drawElevator (g, x, y, (elevatorTo - elevatorFrom + 1) / 2);
|
||||
else if (monsterID >= 0)
|
||||
drawMonster (g, x, y);
|
||||
else if (spellsBlocked)
|
||||
drawSpellsBlocked (g, x, y);
|
||||
else if (unknown != 0)
|
||||
drawChar (g, x, y, HexFormatter.format1 (unknown), Color.GRAY);
|
||||
}
|
||||
|
||||
public void drawWest (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawLine (x + 1, y + 1, x + 1, y + cellSize.height - 1);
|
||||
}
|
||||
public void drawWest (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawLine (x + 1, y + 1, x + 1, y + cellSize.height - 1);
|
||||
}
|
||||
|
||||
private void drawEast (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawLine (x + cellSize.width - 1, y + 1, x + cellSize.width - 1, y + cellSize.height - 1);
|
||||
}
|
||||
private void drawEast (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawLine (x + cellSize.width - 1, y + 1, x + cellSize.width - 1,
|
||||
y + cellSize.height - 1);
|
||||
}
|
||||
|
||||
private void drawNorth (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawLine (x + 1, y + 1, x + cellSize.width - 1, y + 1);
|
||||
}
|
||||
private void drawNorth (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawLine (x + 1, y + 1, x + cellSize.width - 1, y + 1);
|
||||
}
|
||||
|
||||
private void drawSouth (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawLine (x + 1, y + cellSize.height - 1, x + cellSize.width - 1, y + cellSize.height - 1);
|
||||
}
|
||||
private void drawSouth (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawLine (x + 1, y + cellSize.height - 1, x + cellSize.width - 1,
|
||||
y + cellSize.height - 1);
|
||||
}
|
||||
|
||||
public void drawStairsUp (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawLine (x + 6, y + 18, x + 6, y + 14);
|
||||
g.drawLine (x + 6, y + 14, x + 10, y + 14);
|
||||
g.drawLine (x + 10, y + 14, x + 10, y + 10);
|
||||
g.drawLine (x + 10, y + 10, x + 14, y + 10);
|
||||
g.drawLine (x + 14, y + 10, x + 14, y + 6);
|
||||
g.drawLine (x + 14, y + 6, x + 18, y + 6);
|
||||
}
|
||||
public void drawStairsUp (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawLine (x + 6, y + 18, x + 6, y + 14);
|
||||
g.drawLine (x + 6, y + 14, x + 10, y + 14);
|
||||
g.drawLine (x + 10, y + 14, x + 10, y + 10);
|
||||
g.drawLine (x + 10, y + 10, x + 14, y + 10);
|
||||
g.drawLine (x + 14, y + 10, x + 14, y + 6);
|
||||
g.drawLine (x + 14, y + 6, x + 18, y + 6);
|
||||
}
|
||||
|
||||
public void drawStairsDown (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawLine (x + 4, y + 7, x + 8, y + 7);
|
||||
g.drawLine (x + 8, y + 7, x + 8, y + 11);
|
||||
g.drawLine (x + 8, y + 11, x + 12, y + 11);
|
||||
g.drawLine (x + 12, y + 11, x + 12, y + 15);
|
||||
g.drawLine (x + 12, y + 15, x + 16, y + 15);
|
||||
g.drawLine (x + 16, y + 15, x + 16, y + 19);
|
||||
}
|
||||
public void drawStairsDown (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawLine (x + 4, y + 7, x + 8, y + 7);
|
||||
g.drawLine (x + 8, y + 7, x + 8, y + 11);
|
||||
g.drawLine (x + 8, y + 11, x + 12, y + 11);
|
||||
g.drawLine (x + 12, y + 11, x + 12, y + 15);
|
||||
g.drawLine (x + 12, y + 15, x + 16, y + 15);
|
||||
g.drawLine (x + 16, y + 15, x + 16, y + 19);
|
||||
}
|
||||
|
||||
public void drawPit (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawLine (x + 5, y + 14, x + 5, y + 19);
|
||||
g.drawLine (x + 5, y + 19, x + 17, y + 19);
|
||||
g.drawLine (x + 17, y + 14, x + 17, y + 19);
|
||||
}
|
||||
public void drawPit (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawLine (x + 5, y + 14, x + 5, y + 19);
|
||||
g.drawLine (x + 5, y + 19, x + 17, y + 19);
|
||||
g.drawLine (x + 17, y + 14, x + 17, y + 19);
|
||||
}
|
||||
|
||||
public void drawChute (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawLine (x + 6, y + 6, x + 10, y + 6);
|
||||
g.drawLine (x + 10, y + 6, x + 18, y + 18);
|
||||
}
|
||||
public void drawChute (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawLine (x + 6, y + 6, x + 10, y + 6);
|
||||
g.drawLine (x + 10, y + 6, x + 18, y + 18);
|
||||
}
|
||||
|
||||
public void drawElevator (Graphics2D g, int x, int y, int rows)
|
||||
{
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
g.drawOval (x + 7, y + i * 5 + 5, 2, 2);
|
||||
g.drawOval (x + 14, y + i * 5 + 5, 2, 2);
|
||||
}
|
||||
}
|
||||
public void drawElevator (Graphics2D g, int x, int y, int rows)
|
||||
{
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
g.drawOval (x + 7, y + i * 5 + 5, 2, 2);
|
||||
g.drawOval (x + 14, y + i * 5 + 5, 2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawMonsterLair (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.setColor (Color.YELLOW);
|
||||
g.fillOval (x + 4, y + 4, 2, 2);
|
||||
g.setColor (Color.WHITE);
|
||||
}
|
||||
public void drawMonsterLair (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.setColor (Color.YELLOW);
|
||||
g.fillOval (x + 4, y + 4, 2, 2);
|
||||
g.setColor (Color.WHITE);
|
||||
}
|
||||
|
||||
public void drawTeleport (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.setColor (Color.GREEN);
|
||||
g.fillOval (x + 8, y + 8, 8, 8);
|
||||
g.setColor (Color.WHITE);
|
||||
}
|
||||
public void drawTeleport (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.setColor (Color.GREEN);
|
||||
g.fillOval (x + 8, y + 8, 8, 8);
|
||||
g.setColor (Color.WHITE);
|
||||
}
|
||||
|
||||
public void drawSpellsBlocked (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.setColor (Color.YELLOW);
|
||||
g.fillOval (x + 8, y + 8, 8, 8);
|
||||
g.setColor (Color.WHITE);
|
||||
}
|
||||
public void drawSpellsBlocked (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.setColor (Color.YELLOW);
|
||||
g.fillOval (x + 8, y + 8, 8, 8);
|
||||
g.setColor (Color.WHITE);
|
||||
}
|
||||
|
||||
public void drawMonster (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.setColor (Color.RED);
|
||||
g.fillOval (x + 8, y + 8, 8, 8);
|
||||
g.setColor (Color.WHITE);
|
||||
}
|
||||
public void drawMonster (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.setColor (Color.RED);
|
||||
g.fillOval (x + 8, y + 8, 8, 8);
|
||||
g.setColor (Color.WHITE);
|
||||
}
|
||||
|
||||
public void drawDarkness (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.setColor (Color.gray);
|
||||
for (int h = 0; h < 15; h += 7)
|
||||
for (int offset = 0; offset < 15; offset += 7)
|
||||
g.drawOval (x + offset + 4, y + h + 4, 1, 1);
|
||||
g.setColor (Color.white);
|
||||
}
|
||||
public void drawDarkness (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.setColor (Color.gray);
|
||||
for (int h = 0; h < 15; h += 7)
|
||||
for (int offset = 0; offset < 15; offset += 7)
|
||||
g.drawOval (x + offset + 4, y + h + 4, 1, 1);
|
||||
g.setColor (Color.white);
|
||||
}
|
||||
|
||||
public void drawRock (Graphics2D g, int x, int y)
|
||||
{
|
||||
for (int h = 0; h < 15; h += 7)
|
||||
for (int offset = 0; offset < 15; offset += 7)
|
||||
g.drawOval (x + offset + 4, y + h + 4, 1, 1);
|
||||
}
|
||||
public void drawRock (Graphics2D g, int x, int y)
|
||||
{
|
||||
for (int h = 0; h < 15; h += 7)
|
||||
for (int offset = 0; offset < 15; offset += 7)
|
||||
g.drawOval (x + offset + 4, y + h + 4, 1, 1);
|
||||
}
|
||||
|
||||
public void drawChar (Graphics2D g, int x, int y, String c, Color colour)
|
||||
{
|
||||
g.setColor (colour);
|
||||
g.fillRect (x + 7, y + 6, 11, 11);
|
||||
g.setColor (Color.WHITE);
|
||||
g.drawString (c, x + 8, y + 16);
|
||||
}
|
||||
public void drawChar (Graphics2D g, int x, int y, String c, Color colour)
|
||||
{
|
||||
g.setColor (colour);
|
||||
g.fillRect (x + 7, y + 6, 11, 11);
|
||||
g.setColor (Color.WHITE);
|
||||
g.drawString (c, x + 8, y + 16);
|
||||
}
|
||||
|
||||
public void drawHotDogStand (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawRect (x + 5, y + 11, 12, 6);
|
||||
g.drawOval (x + 6, y + 18, 3, 3);
|
||||
g.drawOval (x + 13, y + 18, 3, 3);
|
||||
g.drawLine (x + 8, y + 6, x + 8, y + 10);
|
||||
g.drawLine (x + 14, y + 6, x + 14, y + 10);
|
||||
g.drawLine (x + 5, y + 5, x + 17, y + 5);
|
||||
}
|
||||
public void drawHotDogStand (Graphics2D g, int x, int y)
|
||||
{
|
||||
g.drawRect (x + 5, y + 11, 12, 6);
|
||||
g.drawOval (x + 6, y + 18, 3, 3);
|
||||
g.drawOval (x + 13, y + 18, 3, 3);
|
||||
g.drawLine (x + 8, y + 6, x + 8, y + 10);
|
||||
g.drawLine (x + 14, y + 6, x + 14, y + 10);
|
||||
g.drawLine (x + 5, y + 5, x + 17, y + 5);
|
||||
}
|
||||
|
||||
public String getTooltipText ()
|
||||
{
|
||||
StringBuilder sign = new StringBuilder ("<html><pre>");
|
||||
sign.append (" <b>");
|
||||
sign.append (address.row + "N ");
|
||||
sign.append (address.column + "E</b> <br>");
|
||||
public String getTooltipText ()
|
||||
{
|
||||
StringBuilder sign = new StringBuilder ("<html><pre>");
|
||||
sign.append (" <b>");
|
||||
sign.append (address.row + "N ");
|
||||
sign.append (address.column + "E</b> <br>");
|
||||
|
||||
if (message != null)
|
||||
sign.append (message.toHTMLString ());
|
||||
if (message != null)
|
||||
sign.append (message.toHTMLString ());
|
||||
|
||||
if (elevator)
|
||||
sign.append (" Elevator: L" + elevatorFrom + "-L" + elevatorTo + " ");
|
||||
if (stairs)
|
||||
{
|
||||
sign.append (" Stairs to ");
|
||||
if (addressTo.level == 0)
|
||||
sign.append ("castle ");
|
||||
else
|
||||
{
|
||||
sign.append ("level " + addressTo.level + " ");
|
||||
}
|
||||
}
|
||||
if (teleport)
|
||||
{
|
||||
sign.append (" Teleport to ");
|
||||
if (addressTo.level == 0)
|
||||
sign.append ("castle ");
|
||||
else
|
||||
{
|
||||
sign.append ("L" + addressTo.level + " " + addressTo.row + "N " + addressTo.column
|
||||
+ "E ");
|
||||
}
|
||||
}
|
||||
if (pit)
|
||||
sign.append (" Pit");
|
||||
if (spinner)
|
||||
sign.append (" Spinner ");
|
||||
if (chute)
|
||||
sign.append (" Chute");
|
||||
if (darkness)
|
||||
sign.append (" Darkness ");
|
||||
if (rock)
|
||||
sign.append (" Rock ");
|
||||
if (spellsBlocked)
|
||||
sign.append (" Spells fizzle out ");
|
||||
if (monsterID >= 0)
|
||||
if (monsters == null || monsterID >= monsters.size ())
|
||||
sign.append (" Monster ");
|
||||
else
|
||||
{
|
||||
Monster monster = monsters.get (monsterID);
|
||||
sign.append (" <b>" + monster.getRealName () + " </b>");
|
||||
while (monster.partnerOdds == 100)
|
||||
{
|
||||
monster = monsters.get (monster.partnerID);
|
||||
sign.append ("<br> <b>" + monster.getRealName () + " </b>");
|
||||
}
|
||||
}
|
||||
if (itemRequired != null)
|
||||
{
|
||||
sign.append (" <b>Requires: ");
|
||||
sign.append (itemRequired.name + " </b>");
|
||||
}
|
||||
if (elevator)
|
||||
sign.append (" Elevator: L" + elevatorFrom + "-L" + elevatorTo + " ");
|
||||
if (stairs)
|
||||
{
|
||||
sign.append (" Stairs to ");
|
||||
if (addressTo.level == 0)
|
||||
sign.append ("castle ");
|
||||
else
|
||||
{
|
||||
sign.append ("level " + addressTo.level + " ");
|
||||
}
|
||||
}
|
||||
if (teleport)
|
||||
{
|
||||
sign.append (" Teleport to ");
|
||||
if (addressTo.level == 0)
|
||||
sign.append ("castle ");
|
||||
else
|
||||
{
|
||||
sign.append ("L" + addressTo.level + " " + addressTo.row + "N " + addressTo.column
|
||||
+ "E ");
|
||||
}
|
||||
}
|
||||
if (pit)
|
||||
sign.append (" Pit");
|
||||
if (spinner)
|
||||
sign.append (" Spinner ");
|
||||
if (chute)
|
||||
sign.append (" Chute");
|
||||
if (darkness)
|
||||
sign.append (" Darkness ");
|
||||
if (rock)
|
||||
sign.append (" Rock ");
|
||||
if (spellsBlocked)
|
||||
sign.append (" Spells fizzle out ");
|
||||
if (monsterID >= 0)
|
||||
if (monsters == null || monsterID >= monsters.size ())
|
||||
sign.append (" Monster ");
|
||||
else
|
||||
{
|
||||
Monster monster = monsters.get (monsterID);
|
||||
sign.append (" <b>" + monster.getRealName () + " </b>");
|
||||
while (monster.partnerOdds == 100)
|
||||
{
|
||||
monster = monsters.get (monster.partnerID);
|
||||
sign.append ("<br> <b>" + monster.getRealName () + " </b>");
|
||||
}
|
||||
}
|
||||
if (itemRequired != null)
|
||||
{
|
||||
sign.append (" <b>Requires: ");
|
||||
sign.append (itemRequired.getName () + " </b>");
|
||||
}
|
||||
|
||||
if (itemObtained != null)
|
||||
{
|
||||
sign.append (" <b>Obtain: ");
|
||||
sign.append (itemObtained.name + " </b>");
|
||||
}
|
||||
sign.append ("</pre></html>");
|
||||
return sign.toString ();
|
||||
}
|
||||
if (itemObtained != null)
|
||||
{
|
||||
sign.append (" <b>Obtain: ");
|
||||
sign.append (itemObtained.getName () + " </b>");
|
||||
}
|
||||
sign.append ("</pre></html>");
|
||||
return sign.toString ();
|
||||
}
|
||||
}
|
|
@ -7,135 +7,136 @@ import com.bytezone.diskbrowser.applefile.AbstractFile;
|
|||
|
||||
class Reward extends AbstractFile
|
||||
{
|
||||
static String[] types = { "gold", "item" };
|
||||
static final int SEGMENT_LENGTH = 18;
|
||||
int id;
|
||||
int totalElements;
|
||||
List<RewardElement> elements;
|
||||
List<Item> items;
|
||||
List<Monster> goldMonsters = new ArrayList<Monster> ();
|
||||
List<Monster> chestMonsters = new ArrayList<Monster> ();
|
||||
static String[] types = { "gold", "item" };
|
||||
static final int SEGMENT_LENGTH = 18;
|
||||
int id;
|
||||
int totalElements;
|
||||
List<RewardElement> elements;
|
||||
List<Item> items;
|
||||
List<Monster> goldMonsters = new ArrayList<Monster> ();
|
||||
List<Monster> chestMonsters = new ArrayList<Monster> ();
|
||||
|
||||
public Reward (String name, byte[] buffer, int id, List<Item> items)
|
||||
{
|
||||
super (name, buffer);
|
||||
this.id = id;
|
||||
this.items = items;
|
||||
totalElements = buffer[4];
|
||||
elements = new ArrayList<RewardElement> (totalElements);
|
||||
public Reward (String name, byte[] buffer, int id, List<Item> items)
|
||||
{
|
||||
super (name, buffer);
|
||||
this.id = id;
|
||||
this.items = items;
|
||||
totalElements = buffer[4];
|
||||
elements = new ArrayList<RewardElement> (totalElements);
|
||||
|
||||
for (int i = 0; i < totalElements; i++)
|
||||
{
|
||||
byte[] buffer2 = new byte[SEGMENT_LENGTH];
|
||||
System.arraycopy (buffer, i * SEGMENT_LENGTH, buffer2, 0, SEGMENT_LENGTH);
|
||||
elements.add (new RewardElement (buffer2));
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < totalElements; i++)
|
||||
{
|
||||
byte[] buffer2 = new byte[SEGMENT_LENGTH];
|
||||
System.arraycopy (buffer, i * SEGMENT_LENGTH, buffer2, 0, SEGMENT_LENGTH);
|
||||
elements.add (new RewardElement (buffer2));
|
||||
}
|
||||
}
|
||||
|
||||
public void addMonster (Monster monster, int location)
|
||||
{
|
||||
if (location == 0)
|
||||
goldMonsters.add (monster);
|
||||
else
|
||||
chestMonsters.add (monster);
|
||||
}
|
||||
public void addMonster (Monster monster, int location)
|
||||
{
|
||||
if (location == 0)
|
||||
goldMonsters.add (monster);
|
||||
else
|
||||
chestMonsters.add (monster);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText ()
|
||||
{
|
||||
return getText (true);
|
||||
}
|
||||
@Override
|
||||
public String getText ()
|
||||
{
|
||||
return getText (true);
|
||||
}
|
||||
|
||||
public String getText (boolean showLinks)
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
for (RewardElement re : elements)
|
||||
text.append (re.getDetail () + "\n");
|
||||
public String getText (boolean showLinks)
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
for (RewardElement re : elements)
|
||||
text.append (re.getDetail () + "\n");
|
||||
|
||||
if (showLinks)
|
||||
{
|
||||
if (goldMonsters.size () > 0)
|
||||
{
|
||||
text.append ("Without chest:\n\n");
|
||||
for (Monster m : goldMonsters)
|
||||
text.append (" " + m + "\n");
|
||||
text.append ("\n");
|
||||
}
|
||||
if (chestMonsters.size () > 0)
|
||||
{
|
||||
text.append ("With chest:\n\n");
|
||||
for (Monster m : chestMonsters)
|
||||
text.append (" " + m + "\n");
|
||||
}
|
||||
}
|
||||
return text.toString ();
|
||||
}
|
||||
if (showLinks)
|
||||
{
|
||||
if (goldMonsters.size () > 0)
|
||||
{
|
||||
text.append ("Without chest:\n\n");
|
||||
for (Monster m : goldMonsters)
|
||||
text.append (" " + m + "\n");
|
||||
text.append ("\n");
|
||||
}
|
||||
if (chestMonsters.size () > 0)
|
||||
{
|
||||
text.append ("With chest:\n\n");
|
||||
for (Monster m : chestMonsters)
|
||||
text.append (" " + m + "\n");
|
||||
}
|
||||
}
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
public String getDump ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
int seq = 0;
|
||||
for (RewardElement re : elements)
|
||||
{
|
||||
text.append (seq++ == 0 ? String.format ("%02X : ", id) : " ");
|
||||
text.append (re + "\n");
|
||||
}
|
||||
public String getDump ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
int seq = 0;
|
||||
for (RewardElement re : elements)
|
||||
{
|
||||
text.append (seq++ == 0 ? String.format ("%02X : ", id) : " ");
|
||||
text.append (re + "\n");
|
||||
}
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
private class RewardElement
|
||||
{
|
||||
int type;
|
||||
int odds;
|
||||
byte[] buffer;
|
||||
private class RewardElement
|
||||
{
|
||||
int type;
|
||||
int odds;
|
||||
byte[] buffer;
|
||||
|
||||
public RewardElement (byte[] buffer)
|
||||
{
|
||||
this.buffer = buffer;
|
||||
type = buffer[8];
|
||||
odds = buffer[6];
|
||||
}
|
||||
public RewardElement (byte[] buffer)
|
||||
{
|
||||
this.buffer = buffer;
|
||||
type = buffer[8];
|
||||
odds = buffer[6];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
for (int i = 0; i < SEGMENT_LENGTH; i += 2)
|
||||
text.append (String.format ("%3d ", buffer[i] & 0xFF));
|
||||
return text.toString ();
|
||||
}
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
for (int i = 0; i < SEGMENT_LENGTH; i += 2)
|
||||
text.append (String.format ("%3d ", buffer[i] & 0xFF));
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
public String getDetail ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
text.append ("Odds ............ " + odds + "%\n");
|
||||
public String getDetail ()
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
text.append ("Odds ............ " + odds + "%\n");
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
text.append ("Gold ............ " + buffer[10] + "d" + buffer[12] + "\n");
|
||||
break;
|
||||
case 1:
|
||||
int lo = buffer[10] & 0xFF;
|
||||
int qty = buffer[16] & 0xFF;
|
||||
boolean title = true;
|
||||
String[] lineItem = new String[4];
|
||||
for (int i = lo, max = lo + qty; i <= max; i += lineItem.length)
|
||||
{
|
||||
String lineTitle = title ? "Items ..........." : "";
|
||||
title = false;
|
||||
for (int j = 0; j < lineItem.length; j++)
|
||||
lineItem[j] = i + j <= max ? items.get (i + j).name : "";
|
||||
text.append (String.format ("%-17s %-16s %-16s %-16s %-16s%n", lineTitle, lineItem[0],
|
||||
lineItem[1], lineItem[2], lineItem[3]));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
System.out.println ("Unknown reward type " + type);
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
text.append ("Gold ............ " + buffer[10] + "d" + buffer[12] + "\n");
|
||||
break;
|
||||
case 1:
|
||||
int lo = buffer[10] & 0xFF;
|
||||
int qty = buffer[16] & 0xFF;
|
||||
boolean title = true;
|
||||
String[] lineItem = new String[4];
|
||||
for (int i = lo, max = lo + qty; i <= max; i += lineItem.length)
|
||||
{
|
||||
String lineTitle = title ? "Items ..........." : "";
|
||||
title = false;
|
||||
for (int j = 0; j < lineItem.length; j++)
|
||||
lineItem[j] = i + j <= max ? items.get (i + j).getName () : "";
|
||||
text.append (String.format ("%-17s %-16s %-16s %-16s %-16s%n", lineTitle,
|
||||
lineItem[0], lineItem[1], lineItem[2],
|
||||
lineItem[3]));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
System.out.println ("Unknown reward type " + type);
|
||||
}
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
}
|
||||
return text.toString ();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,7 +9,11 @@ import javax.swing.tree.DefaultTreeModel;
|
|||
|
||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
||||
import com.bytezone.diskbrowser.disk.*;
|
||||
import com.bytezone.diskbrowser.disk.DefaultAppleFileSource;
|
||||
import com.bytezone.diskbrowser.disk.DefaultDataSource;
|
||||
import com.bytezone.diskbrowser.disk.Disk;
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.disk.SectorType;
|
||||
import com.bytezone.diskbrowser.gui.DataSource;
|
||||
import com.bytezone.diskbrowser.pascal.PascalDisk;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
@ -93,7 +97,8 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||
extractMonsters (linkNode ("Monsters", "Monsters string", dataNode), sectors);
|
||||
extractCharacters (linkNode ("Characters", "Characters string", dataNode), sectors);
|
||||
extractImages (linkNode ("Images", "Images string", dataNode), sectors);
|
||||
extractExperienceLevels (linkNode ("Experience", "Experience string", dataNode), sectors);
|
||||
extractExperienceLevels (linkNode ("Experience", "Experience string", dataNode),
|
||||
sectors);
|
||||
// node = linkNode ("Spells", "Spells string", dataNode);
|
||||
node = null;
|
||||
extractSpells (node, sectors);
|
||||
|
@ -112,7 +117,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||
}
|
||||
|
||||
private DefaultMutableTreeNode linkNode (String name, String text,
|
||||
DefaultMutableTreeNode parent)
|
||||
DefaultMutableTreeNode parent)
|
||||
{
|
||||
DefaultAppleFileSource afs = new DefaultAppleFileSource (name, text, this);
|
||||
DefaultMutableTreeNode node = new DefaultMutableTreeNode (afs);
|
||||
|
@ -133,7 +138,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||
{
|
||||
String text = HexFormatter.getPascalString (buffer, ptr);
|
||||
if (!text.equals ("SCENARIO.DATA") && !text.equals ("SCENARIO.MESGS")
|
||||
&& !text.equals ("WIZARDRY.CODE"))
|
||||
&& !text.equals ("WIZARDRY.CODE"))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -189,8 +194,8 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||
dds.text = text.toString ();
|
||||
}
|
||||
|
||||
private int addReward (byte[] buffer, List<DiskAddress> blocks, DefaultMutableTreeNode node,
|
||||
int seq)
|
||||
private int addReward (byte[] buffer, List<DiskAddress> blocks,
|
||||
DefaultMutableTreeNode node, int seq)
|
||||
{
|
||||
int recLen = 168;
|
||||
for (int ptr = 0; ptr < 1008; ptr += recLen)
|
||||
|
@ -224,9 +229,9 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||
|
||||
StringBuilder text = new StringBuilder ();
|
||||
text.append ("Name Age Align Race Type "
|
||||
+ "HP St In Pi Vi Ag Lu Status\n");
|
||||
+ "HP St In Pi Vi Ag Lu Status\n");
|
||||
text.append ("------------- ---- -------- -------- ---------- "
|
||||
+ "-- -- -- -- -- -- -- ------\n");
|
||||
+ "-- -- -- -- -- -- -- ------\n");
|
||||
for (Character ch : characters)
|
||||
{
|
||||
Statistics stats = ch.getStatistics ();
|
||||
|
@ -237,7 +242,8 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||
text.append (String.format (" %2d %2d %2d %2d %2d %2d", att.strength,
|
||||
att.intelligence, att.piety, att.vitality, att.agility,
|
||||
att.luck));
|
||||
text.append (String.format (" %5s %s%n", stats.status, ch.isOut () ? "* OUT *" : ""));
|
||||
text.append (String.format (" %5s %s%n", stats.status,
|
||||
ch.isOut () ? "* OUT *" : ""));
|
||||
}
|
||||
|
||||
DefaultAppleFileSource afs = (DefaultAppleFileSource) node.getUserObject ();
|
||||
|
@ -247,7 +253,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||
}
|
||||
|
||||
private void addCharacters (byte[] buffer, List<DiskAddress> blocks,
|
||||
DefaultMutableTreeNode node)
|
||||
DefaultMutableTreeNode node)
|
||||
{
|
||||
int recLen = 208;
|
||||
for (int ptr = 0; ptr < 832; ptr += recLen)
|
||||
|
@ -300,7 +306,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||
}
|
||||
|
||||
private void addMonsters (byte[] buffer, List<DiskAddress> blocks,
|
||||
DefaultMutableTreeNode node)
|
||||
DefaultMutableTreeNode node)
|
||||
{
|
||||
int recLen = 158;
|
||||
for (int ptr = 0; ptr < 948; ptr += recLen)
|
||||
|
@ -352,7 +358,8 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||
dds.text = text.toString ();
|
||||
}
|
||||
|
||||
private void addItems (byte[] buffer, List<DiskAddress> blocks, DefaultMutableTreeNode node)
|
||||
private void addItems (byte[] buffer, List<DiskAddress> blocks,
|
||||
DefaultMutableTreeNode node)
|
||||
{
|
||||
int recLen = 78;
|
||||
for (int ptr = 0; ptr < 1014; ptr += recLen)
|
||||
|
@ -493,7 +500,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||
|
||||
StringBuilder text = new StringBuilder ();
|
||||
for (MazeLevel level : levels)
|
||||
text.append (level.name + "\n");
|
||||
text.append (level.getName () + "\n");
|
||||
|
||||
DefaultAppleFileSource afs = (DefaultAppleFileSource) node.getUserObject ();
|
||||
afs.setSectors (nodeSectors);
|
||||
|
@ -524,16 +531,15 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||
break;
|
||||
}
|
||||
|
||||
AbstractImage mi =
|
||||
scenarioHeader.scenarioID < 3 ? new Image (name, buffer) : new ImageV2 (name,
|
||||
exactBuffer);
|
||||
AbstractImage mi = scenarioHeader.scenarioID < 3 ? new Image (name, buffer)
|
||||
: new ImageV2 (name, exactBuffer);
|
||||
images.add (mi);
|
||||
addToNode (mi, node, da, imageSector);
|
||||
}
|
||||
|
||||
StringBuilder text = new StringBuilder ();
|
||||
for (AbstractImage image : images)
|
||||
text.append (image.name + "\n");
|
||||
text.append (image.getName () + "\n");
|
||||
|
||||
DefaultAppleFileSource afs = (DefaultAppleFileSource) node.getUserObject ();
|
||||
afs.setSectors (nodeSectors);
|
||||
|
@ -541,8 +547,8 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||
dds.text = text.toString ();
|
||||
}
|
||||
|
||||
private void
|
||||
extractExperienceLevels (DefaultMutableTreeNode node, List<DiskAddress> sectors)
|
||||
private void extractExperienceLevels (DefaultMutableTreeNode node,
|
||||
List<DiskAddress> sectors)
|
||||
{
|
||||
List<DiskAddress> nodeSectors = new ArrayList<DiskAddress> ();
|
||||
ScenarioData sd = scenarioHeader.data.get (Header.EXPERIENCE_AREA);
|
||||
|
@ -573,7 +579,7 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||
}
|
||||
|
||||
private void addToNode (AbstractFile af, DefaultMutableTreeNode node, DiskAddress block,
|
||||
SectorType type)
|
||||
SectorType type)
|
||||
{
|
||||
ArrayList<DiskAddress> blocks = new ArrayList<DiskAddress> (1);
|
||||
blocks.add (block);
|
||||
|
@ -581,15 +587,17 @@ public class WizardryScenarioDisk extends PascalDisk
|
|||
}
|
||||
|
||||
private void addToNode (AbstractFile af, DefaultMutableTreeNode node,
|
||||
List<DiskAddress> blocks, SectorType type)
|
||||
List<DiskAddress> blocks, SectorType type)
|
||||
{
|
||||
DefaultAppleFileSource dafs = new DefaultAppleFileSource (af.name, af, this, blocks);
|
||||
DefaultAppleFileSource dafs =
|
||||
new DefaultAppleFileSource (af.getName (), af, this, blocks);
|
||||
DefaultMutableTreeNode childNode = new DefaultMutableTreeNode (dafs);
|
||||
node.add (childNode);
|
||||
childNode.setAllowsChildren (false);
|
||||
}
|
||||
|
||||
private List<DiskAddress> getTwoBlocks (ScenarioData sd, int i, List<DiskAddress> sectors)
|
||||
private List<DiskAddress> getTwoBlocks (ScenarioData sd, int i,
|
||||
List<DiskAddress> sectors)
|
||||
{
|
||||
ArrayList<DiskAddress> blocks = new ArrayList<DiskAddress> (2);
|
||||
blocks.add (sectors.get (sd.dataOffset + i * 2));
|
||||
|
|
Loading…
Reference in New Issue