diff --git a/src/com/bytezone/diskbrowser/wizardry/MazeGridV5.java b/src/com/bytezone/diskbrowser/wizardry/MazeGridV5.java index 5258259..f4927dd 100644 --- a/src/com/bytezone/diskbrowser/wizardry/MazeGridV5.java +++ b/src/com/bytezone/diskbrowser/wizardry/MazeGridV5.java @@ -88,41 +88,17 @@ public class MazeGridV5 extends AbstractFile int offset = gridNo * 16 + column * 2 + row / 4; int value; - if (false) - { - value = HexFormatter.intValue (buffer[offset]); - value >>>= (row % 4) * 2; - cell.westWall = ((value & 1) == 1); - value >>>= 1; - cell.westDoor = ((value & 1) == 1); - } + value = HexFormatter.intValue (buffer[offset + 0]); + value >>>= (row % 4) * 2; + cell.eastWall = ((value & 1) == 1); + value >>>= 1; + cell.eastDoor = ((value & 1) == 1); - if (false) - { - value = HexFormatter.intValue (buffer[offset + 256]); - value >>>= (row % 4) * 2; - cell.southWall = ((value & 1) == 1); - value >>>= 1; - cell.southDoor = ((value & 1) == 1); - } - - if (true) - { - value = HexFormatter.intValue (buffer[offset + 0]); - value >>>= (row % 4) * 2; - cell.eastWall = ((value & 1) == 1); - value >>>= 1; - cell.eastDoor = ((value & 1) == 1); - } - - if (true) - { - value = HexFormatter.intValue (buffer[offset + 256]); - value >>>= (row % 4) * 2; - cell.northWall = ((value & 1) == 1); - value >>>= 1; - cell.northDoor = ((value & 1) == 1); - } + value = HexFormatter.intValue (buffer[offset + 256]); + value >>>= (row % 4) * 2; + cell.northWall = ((value & 1) == 1); + value >>>= 1; + cell.northDoor = ((value & 1) == 1); return cell; } @@ -134,15 +110,17 @@ public class MazeGridV5 extends AbstractFile text.append ("\n\n"); text.append (HexFormatter.format (buffer, 0x550, 0x80)); - text.append ("\n\n"); + text.append ("\n"); for (int i = 0; i < 128; i += 2) { int msg = Utility.getWord (buffer, 0x550 + i); if (msg >= 15000) { - String message = messageBlock.getMessageText (msg); - text.append (String.format ("%4d %04X %s%n", i, msg, message)); + List 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))); } } diff --git a/src/com/bytezone/diskbrowser/wizardry/MessageBlock.java b/src/com/bytezone/diskbrowser/wizardry/MessageBlock.java index eb1b4b3..fe3e43a 100644 --- a/src/com/bytezone/diskbrowser/wizardry/MessageBlock.java +++ b/src/com/bytezone/diskbrowser/wizardry/MessageBlock.java @@ -41,12 +41,38 @@ public class MessageBlock extends AbstractFile implements Iterable messageNo) - return messageDataBlocks.get (i - 1).getText (messageNo); + if (messageDataBlock.lastMessageNo >= messageNo) + return messageDataBlock.getText (messageNo); } return null; } + public List getMessageLines (int messageNo) + { + List lines = new ArrayList (); + + for (MessageDataBlock messageDataBlock : messageDataBlocks) + { + if (messageNo > messageDataBlock.lastMessageNo) + continue; + if (messageNo < messageDataBlock.firstMessageNo) + break; + + while (true) + { + String message = messageDataBlock.getText (messageNo); + if (message != null) + { + lines.add (message); + ++messageNo; + } + else + break; + } + } + return lines; + } + public byte[] getMessage (int messageNo) { for (int i = 0; i < messageDataBlocks.size (); i++) diff --git a/src/com/bytezone/diskbrowser/wizardry/MessageDataBlock.java b/src/com/bytezone/diskbrowser/wizardry/MessageDataBlock.java index 372f1d2..04cbec2 100644 --- a/src/com/bytezone/diskbrowser/wizardry/MessageDataBlock.java +++ b/src/com/bytezone/diskbrowser/wizardry/MessageDataBlock.java @@ -9,6 +9,7 @@ import com.bytezone.diskbrowser.applefile.AbstractFile; public class MessageDataBlock extends AbstractFile { final int firstMessageNo; + final int lastMessageNo; private final int groupCount; private final List messages = new ArrayList (); @@ -65,7 +66,13 @@ public class MessageDataBlock extends AbstractFile } if (currentMessageNo > firstMessageNo) - this.name += " - " + (currentMessageNo - 1); + { + lastMessageNo = currentMessageNo - 1; + // this.name += " - " + (currentMessageNo - 1); + } + else + lastMessageNo = firstMessageNo; + this.name += " - " + lastMessageNo; } byte[] getMessage (int messageNo) @@ -89,7 +96,7 @@ public class MessageDataBlock extends AbstractFile System.arraycopy (buffer, message.offset, returnMessage, 0, message.length); return huffman.decodeMessage (returnMessage); } - return "*** not found ***"; + return null; } @Override diff --git a/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java b/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java index a62ec22..20bbd63 100644 --- a/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java +++ b/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java @@ -167,13 +167,15 @@ public class Wizardry4BootDisk extends PascalDisk DefaultMutableTreeNode mazeNode = linkNode ("Maze", "Level 5 mazes", scenarioNode); + int blockSize = 0x39A; int base = 0x1800; for (int i = 0; i < 8; i++) { int offset = base + i * 0x400; - byte[] data = new byte[2048]; - System.arraycopy (buffer, offset, data, 0, 1024); - System.arraycopy (buffer, offset + 8192, data, 1024, 1024); + // 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); MazeGridV5 grid = new MazeGridV5 ("Maze level " + (i + 1), data, messageBlock); List mazeBlocks = new ArrayList ();