display encounter bits

This commit is contained in:
Denis Molony 2016-09-01 14:01:47 +10:00
parent 4da09cdca5
commit c573e86f2b
3 changed files with 200 additions and 18 deletions

View File

@ -109,18 +109,78 @@ public class MazeGridV5 extends AbstractFile
StringBuilder text = new StringBuilder (super.getHexDump ());
text.append ("\n\n");
text.append (HexFormatter.format (buffer, 0x550, 0x80));
int offset = 0x220;
for (int i = 0; i < 16; i++)
{
text.append (String.format ("%05X : ", offset + i * 4));
for (int j = 0; j < 4; j++)
{
text.append (HexFormatter.getHexString (buffer, offset + j * 64 + i * 4, 4));
text.append (" ");
}
text.append ("\n");
}
text.append ("\n");
for (int i = 0; i < 128; i += 2)
offset = 0x320;
for (int i = 0; i < 15; i++)
{
int msg = Utility.getWord (buffer, 0x550 + i);
if (msg >= 15000)
text.append (Utility.toHex (buffer, offset + i * 10, 10));
text.append ("\n");
}
text.append ("\n");
offset = 0x400;
for (int i = 0; i < 5; i++)
{
text.append (Utility.toHex (buffer, offset + i * 64, 64));
text.append ("\n\n");
}
text.append ("\n");
for (int i = 0; i < 176; i += 2)
{
int msg = Utility.getWord (buffer, 0x540 + i);
text.append (String.format ("%05X %04X %04X", 0x540 + i, i / 2, msg));
if (msg >= 700)
{
List<String> messages = messageBlock.getMessageLines (msg);
text.append (String.format ("%n%4d %04X %s%n", i, msg, messages.get (0)));
for (int j = 1; j < messages.size (); j++)
text.append (String.format (" %s%n", messages.get (j)));
if (messages.size () > 0)
text.append (String.format (" %s%n", messages.get (0)));
else
text.append (String.format (" Message not found: %04X%n", msg));
}
else
text.append ("\n");
}
text.append ("\n");
offset = 0x5F0;
for (int i = 0; i < 7; i++)
{
text.append (Utility.toHex (buffer, offset + i * 64, 64));
text.append ("\n\n");
}
if (false)
{
for (int i = 0; i < 176; i += 2)
{
int msg = Utility.getWord (buffer, 0x540 + i);
if (msg >= 15000)
{
List<String> messages = messageBlock.getMessageLines (msg);
if (messages.size () > 0)
text.append (
String.format ("%n%4d %02X %04X %s%n", i, i, msg, messages.get (0)));
else
text.append (String.format ("Message not found: %04X%n", msg));
for (int j = 1; j < messages.size (); j++)
text.append (String.format (" %s%n", messages.get (j)));
}
}
}

View File

@ -54,9 +54,12 @@ class MazeLevel extends AbstractFile
text.append ("\nIndex\n\n");
text.append (
String.format ("%04X: %s%n%n", 760, HexFormatter.getHexString (buffer, 760, 8)));
String.format ("%04X: %s%n", 760, HexFormatter.getHexString (buffer, 760, 8)));
text.append (" 0 1 2 3 4 5 6 7 8 9 A B C D E F\n");
text.append ("\nTable\n\n");
text.append (HexFormatter.format (buffer, 768, 96));
text.append ("\n\n 0 1 2 3 4 5 6 7 8 9 A B C D E F\n");
text.append (String.format ("%04X: ", 760));
for (int i = 0; i < 8; i++)
{
@ -71,7 +74,7 @@ class MazeLevel extends AbstractFile
List<MazeAddress> messageList = new ArrayList<MazeAddress> ();
List<MazeAddress> monsterList = new ArrayList<MazeAddress> ();
text.append ("\n\nTable Index Contains \n");
text.append ("\n\nValue Index Contains Table\n");
for (int j = 0; j < 16; j++)
{
String extraText = "";
@ -113,18 +116,18 @@ class MazeLevel extends AbstractFile
extraText += monsters.get (address.column).realName;
}
text.append (String.format (" %X %X %-15s %04X %04X %04X %s%n", j,
text.append (String.format (" %X --> %X %-15s %04X %04X %04X %s%n", j,
cellFlag, extra, address.level, address.row, address.column, extraText));
}
text.append ("\nRest\n\n");
text.append ("\n\nRest\n\n");
text.append (HexFormatter.format (buffer, 864, buffer.length - 864));
text.append ("\n");
for (MazeAddress address : messageList)
{
Message message = getMessage (address.row);
text.append (String.format ("%nMessage: %04X%n", address.row));
text.append (String.format ("%nMessage: %04X (%d)%n", address.row, address.row));
text.append (message.getText ());
text.append ("\n");
}
@ -152,8 +155,28 @@ class MazeLevel extends AbstractFile
{
text.append ("\n\n");
for (int i = 0; i < 20; i++)
text.append (String.format (" Col %2d: %s%n", i,
{
text.append (String.format (" Col %2d: %s ", i,
HexFormatter.getHexString (buffer, ptr + i * 4, 4)));
StringBuilder bitString = new StringBuilder ();
for (int j = 2; j >= 0; j--)
{
byte b = buffer[ptr + i * 4 + j];
String s = ("0000000" + Integer.toBinaryString (0xFF & b))
.replaceAll (".*(.{8})$", "$1");
bitString.append (s);
// text.append (s);
// text.append (" ");
}
String bitsReversed = bitString.reverse ().toString ();
bitsReversed = bitsReversed.replace ("1", " 1");
bitsReversed = bitsReversed.replace ("0", " ");
text.append (bitsReversed.substring (0, 40));
text.append (" : ");
text.append (bitsReversed.substring (40));
text.append ("\n");
}
}
private void addExtras (StringBuilder text, int ptr)

View File

@ -13,6 +13,7 @@ import com.bytezone.diskbrowser.disk.Disk;
import com.bytezone.diskbrowser.disk.DiskAddress;
import com.bytezone.diskbrowser.pascal.FileEntry;
import com.bytezone.diskbrowser.pascal.PascalDisk;
import com.bytezone.diskbrowser.utilities.HexFormatter;
import com.bytezone.diskbrowser.utilities.Utility;
import com.bytezone.diskbrowser.wizardry.Header.ScenarioData;
@ -104,6 +105,9 @@ public class Wizardry4BootDisk extends PascalDisk
fileEntry.setFile (null);
scenarioNode.setAllowsChildren (true);
linkMazeLevels5 (scenarioNode, fileEntry);
linkBlock1 (scenarioNode, fileEntry);
linkOracle (scenarioNode, fileEntry);
linkBlock2 (scenarioNode, fileEntry);
}
}
@ -166,21 +170,116 @@ public class Wizardry4BootDisk extends PascalDisk
List<DiskAddress> blocks = fileEntry.getSectors ();
DefaultMutableTreeNode mazeNode = linkNode ("Maze", "Level 5 mazes", scenarioNode);
List<DiskAddress> allMazeBlocks = new ArrayList<DiskAddress> ();
int blockSize = 0x39A;
int dataSize = 0x39A;
int base = 0x1800;
for (int i = 0; i < 8; i++)
{
int offset = base + i * 0x400;
// byte[] data = new byte[2048];
byte[] data = new byte[0x800];
System.arraycopy (buffer, offset, data, 0, blockSize);
System.arraycopy (buffer, offset + 0x2000, data, 0x400, blockSize);
System.arraycopy (buffer, offset, data, 0, dataSize);
System.arraycopy (buffer, offset + 0x2000, data, 0x400, dataSize);
MazeGridV5 grid = new MazeGridV5 ("Maze level " + (i + 1), data, messageBlock);
List<DiskAddress> mazeBlocks = new ArrayList<DiskAddress> ();
for (int j = 0; j < 4; j++)
mazeBlocks.add (blocks.get (12 + i * 4 + j));
allMazeBlocks.addAll (mazeBlocks);
addToNode (grid, mazeNode, mazeBlocks);
}
DefaultAppleFileSource afs = (DefaultAppleFileSource) mazeNode.getUserObject ();
afs.setSectors (allMazeBlocks);
}
private void linkBlock1 (DefaultMutableTreeNode scenarioNode, FileEntry fileEntry)
{
byte[] buffer = fileEntry.getDataSource ().buffer;
List<DiskAddress> blocks = fileEntry.getSectors ();
StringBuilder text = new StringBuilder ();
List<DiskAddress> allBlocks = new ArrayList<DiskAddress> ();
for (int i = 0; i < 23; i++)
{
allBlocks.add (blocks.get (44 + i));
}
int offset = 0x5800;
int length = 66;
for (int i = 0; i < 179; i++)
{
text.append (String.format ("%04X : %s%n", (offset + i * length),
HexFormatter.getHexString (buffer, offset + i * length, length)));
}
DefaultMutableTreeNode oracleNode =
linkNode ("Block1", text.toString (), scenarioNode);
oracleNode.setAllowsChildren (false);
DefaultAppleFileSource afs = (DefaultAppleFileSource) oracleNode.getUserObject ();
afs.setSectors (allBlocks);
}
private void linkBlock2 (DefaultMutableTreeNode scenarioNode, FileEntry fileEntry)
{
byte[] buffer = fileEntry.getDataSource ().buffer;
List<DiskAddress> blocks = fileEntry.getSectors ();
StringBuilder text = new StringBuilder ();
List<DiskAddress> allBlocks = new ArrayList<DiskAddress> ();
for (int i = 0; i < 19; i++)
{
allBlocks.add (blocks.get (87 + i));
}
int offset = 0xAE00;
int length = 60;
for (int i = 0; i < 150; i++)
{
text.append (String.format ("%04X : %s%n", (offset + i * length),
HexFormatter.getHexString (buffer, offset + i * length, length)));
}
DefaultMutableTreeNode oracleNode =
linkNode ("Block2", text.toString (), scenarioNode);
oracleNode.setAllowsChildren (false);
DefaultAppleFileSource afs = (DefaultAppleFileSource) oracleNode.getUserObject ();
afs.setSectors (allBlocks);
}
private void linkOracle (DefaultMutableTreeNode scenarioNode, FileEntry fileEntry)
{
byte[] buffer = fileEntry.getDataSource ().buffer;
List<DiskAddress> blocks = fileEntry.getSectors ();
StringBuilder text = new StringBuilder ();
for (int i = 0; i < 320; i++)
{
// System.out.println (HexFormatter.format (buffer, 0x08600 + i * 32, 32));
int offset = 0x08600 + i * 32 + 18;
int key = HexFormatter.getWord (buffer, offset);
if (key > 0)
text.append (String.format ("%04X %04X * %s%n", offset, key,
messageBlock.getMessageText (key)));
key = HexFormatter.getWord (buffer, offset + 8);
if (key > 0)
text.append (String.format ("%04X %04X %s%n", offset + 8, key,
messageBlock.getMessageText (key)));
}
List<DiskAddress> allOracleBlocks = new ArrayList<DiskAddress> ();
for (int i = 0; i < 20; i++)
{
allOracleBlocks.add (blocks.get (67 + i));
}
DefaultMutableTreeNode oracleNode =
linkNode ("Oracle", text.toString (), scenarioNode);
oracleNode.setAllowsChildren (false);
DefaultAppleFileSource afs = (DefaultAppleFileSource) oracleNode.getUserObject ();
afs.setSectors (allOracleBlocks);
}
private void linkMonsterImages4 (DefaultMutableTreeNode monstersNode,