display maze messages

This commit is contained in:
Denis Molony 2016-08-24 20:17:27 +10:00
parent a6cc3529de
commit 4da09cdca5
4 changed files with 57 additions and 44 deletions

View File

@ -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<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)));
}
}

View File

@ -41,12 +41,38 @@ public class MessageBlock extends AbstractFile implements Iterable<MessageDataBl
for (int i = 0; i < messageDataBlocks.size (); i++)
{
MessageDataBlock messageDataBlock = messageDataBlocks.get (i);
if (messageDataBlock.firstMessageNo > messageNo)
return messageDataBlocks.get (i - 1).getText (messageNo);
if (messageDataBlock.lastMessageNo >= messageNo)
return messageDataBlock.getText (messageNo);
}
return null;
}
public List<String> getMessageLines (int messageNo)
{
List<String> lines = new ArrayList<String> ();
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++)

View File

@ -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<Message> messages = new ArrayList<Message> ();
@ -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

View File

@ -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<DiskAddress> mazeBlocks = new ArrayList<DiskAddress> ();