diff --git a/src/com/bytezone/diskbrowser/applefile/AbstractFile.java b/src/com/bytezone/diskbrowser/applefile/AbstractFile.java index d480595..47e92c3 100755 --- a/src/com/bytezone/diskbrowser/applefile/AbstractFile.java +++ b/src/com/bytezone/diskbrowser/applefile/AbstractFile.java @@ -50,10 +50,10 @@ public abstract class AbstractFile implements DataSource if (buffer == null || buffer.length == 0) return "No buffer"; - if (buffer.length <= 99999) + if (buffer.length <= 999999) return HexFormatter.format (buffer, 0, buffer.length); - return HexFormatter.format (buffer, 0, 99999); + return HexFormatter.format (buffer, 0, 999999); } @Override diff --git a/src/com/bytezone/diskbrowser/disk/AbstractFormattedDisk.java b/src/com/bytezone/diskbrowser/disk/AbstractFormattedDisk.java index 2e9f68f..4215f39 100755 --- a/src/com/bytezone/diskbrowser/disk/AbstractFormattedDisk.java +++ b/src/com/bytezone/diskbrowser/disk/AbstractFormattedDisk.java @@ -257,7 +257,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk return childNode; } } - System.out.println ("Node not found : " + name); + // System.out.println ("Node not found : " + name); return null; } diff --git a/src/com/bytezone/diskbrowser/gui/AbstractTab.java b/src/com/bytezone/diskbrowser/gui/AbstractTab.java index 28abc3e..959eae2 100755 --- a/src/com/bytezone/diskbrowser/gui/AbstractTab.java +++ b/src/com/bytezone/diskbrowser/gui/AbstractTab.java @@ -135,8 +135,7 @@ abstract class AbstractTab extends JPanel implements Tab { TreePath tp = getPathToNode (showNode); tree.setSelectionPath (tp); - if (!tree.isVisible (tp)) - tree.scrollPathToVisible (tp); + tree.scrollPathToVisible (tp); tree.requestFocusInWindow (); } diff --git a/src/com/bytezone/diskbrowser/gui/FileSystemTab.java b/src/com/bytezone/diskbrowser/gui/FileSystemTab.java index efa9460..5e1de1b 100755 --- a/src/com/bytezone/diskbrowser/gui/FileSystemTab.java +++ b/src/com/bytezone/diskbrowser/gui/FileSystemTab.java @@ -33,7 +33,7 @@ class FileSystemTab extends AbstractTab Map> duplicateDisks; public FileSystemTab (File folder, DiskAndFileSelector selector, RedoHandler navMan, - Font font, DiskSelectedEvent diskEvent) // throws NoDisksFoundException + Font font, DiskSelectedEvent diskEvent) // throws NoDisksFoundException { super (navMan, selector, font); this.rootFolder = folder; @@ -76,13 +76,13 @@ class FileSystemTab extends AbstractTab } for (File file : tb.dosMap.get (key)) System.out.printf (" %s%n", - file.getAbsolutePath ().substring (beginIndex)); + file.getAbsolutePath ().substring (beginIndex)); } } } public FileSystemTab (File folder, DiskAndFileSelector selector, RedoHandler navMan, - Font font) + Font font) // throws NoDisksFoundException { this (folder, selector, navMan, font, null); // default to first available disk @@ -177,7 +177,7 @@ class FileSystemTab extends AbstractTab return childNode; if (fn2.file.isDirectory () && absolutePath.startsWith (path) - && absolutePath.charAt (path.length ()) == '/') + && absolutePath.charAt (path.length ()) == '/') { DefaultMutableTreeNode node2 = search (childNode, absolutePath); if (node2 != null) @@ -231,11 +231,12 @@ class FileSystemTab extends AbstractTab public void treeWillExpand (TreeExpansionEvent e) throws ExpandVetoException { TreePath path = e.getPath (); - DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent (); + DefaultMutableTreeNode node = + (DefaultMutableTreeNode) path.getLastPathComponent (); FileNode fn = (FileNode) node.getUserObject (); if (node.getChildCount () == 0) fn.readFiles (); } }); } -} +} \ No newline at end of file diff --git a/src/com/bytezone/diskbrowser/wizardry/MazeLevel.java b/src/com/bytezone/diskbrowser/wizardry/MazeLevel.java index 919f2d5..9913a62 100755 --- a/src/com/bytezone/diskbrowser/wizardry/MazeLevel.java +++ b/src/com/bytezone/diskbrowser/wizardry/MazeLevel.java @@ -112,23 +112,29 @@ class MazeLevel extends AbstractFile cell.stairs = true; cell.addressTo = getAddress (b); break; + case 2: cell.pit = true; break; + case 3: cell.chute = true; cell.addressTo = getAddress (b); break; + case 4: cell.spinner = true; break; + case 5: cell.darkness = true; break; + case 6: cell.teleport = true; cell.addressTo = getAddress (b); break; + case 8: cell.elevator = true; cell.elevatorTo = @@ -136,23 +142,28 @@ class MazeLevel extends AbstractFile cell.elevatorFrom = HexFormatter.intValue (buffer[832 + b * 2], buffer[833 + b * 2]); break; + case 9: cell.rock = true; break; + case 10: cell.spellsBlocked = true; break; + case 11: int messageNum = HexFormatter.intValue (buffer[800 + b * 2], buffer[801 + b * 2]); if (messages != null) + { for (Message m : messages) if (m.match (messageNum)) { cell.message = m; break; } - if (cell.message == null) - System.out.println ("message not found : " + messageNum); + if (cell.message == null) + System.out.println ("message not found : " + messageNum); + } cell.messageType = HexFormatter.intValue (buffer[832 + b * 2], buffer[833 + b * 2]); @@ -190,10 +201,12 @@ class MazeLevel extends AbstractFile } } break; + case 12: cell.monsterID = HexFormatter.intValue (buffer[832 + b * 2], buffer[833 + b * 2]); cell.monsters = monsters; break; + default: cell.unknown = d; break; diff --git a/src/com/bytezone/diskbrowser/wizardry/MessageBlock.java b/src/com/bytezone/diskbrowser/wizardry/MessageBlock.java index 3040b74..b5f42c4 100644 --- a/src/com/bytezone/diskbrowser/wizardry/MessageBlock.java +++ b/src/com/bytezone/diskbrowser/wizardry/MessageBlock.java @@ -27,7 +27,7 @@ public class MessageBlock implements Iterable byte[] data = new byte[512]; System.arraycopy (buffer, i * 512, data, 0, data.length); MessageDataBlock messageDataBlock = new MessageDataBlock ( - "Block " + i + " Msg " + firstMessageNo, data, firstMessageNo, huffman); + " Message " + firstMessageNo, data, firstMessageNo, huffman); messageDataBlocks.add (messageDataBlock); } } diff --git a/src/com/bytezone/diskbrowser/wizardry/MessageDataBlock.java b/src/com/bytezone/diskbrowser/wizardry/MessageDataBlock.java index 2fce987..cb3bece 100644 --- a/src/com/bytezone/diskbrowser/wizardry/MessageDataBlock.java +++ b/src/com/bytezone/diskbrowser/wizardry/MessageDataBlock.java @@ -19,6 +19,7 @@ public class MessageDataBlock extends AbstractFile Huffman huffman) { super (name, buffer); + this.firstMessageNo = firstMessageNo; this.huffman = huffman; @@ -62,6 +63,9 @@ public class MessageDataBlock extends AbstractFile currentMessageNo += skip; } } + + if (currentMessageNo > firstMessageNo) + this.name += " - " + (currentMessageNo - 1); } byte[] getMessage (int messageNo) @@ -79,12 +83,15 @@ public class MessageDataBlock extends AbstractFile @Override public String getText () { + if (messages.size () == 0) + return "No Messages"; + if (huffman == null) return toString (); StringBuilder text = new StringBuilder (); - text.append ("\n"); int lastMessageNo = messages.get (0).msgNo - 1; + for (Message message : messages) { if (message.msgNo != lastMessageNo + 1) diff --git a/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java b/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java index afbb468..795b405 100644 --- a/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java +++ b/src/com/bytezone/diskbrowser/wizardry/Wizardry4BootDisk.java @@ -19,16 +19,17 @@ import com.bytezone.diskbrowser.wizardry.Header.ScenarioData; public class Wizardry4BootDisk extends PascalDisk { public Header scenarioHeader; - List disks = new ArrayList (); + private final List disks = new ArrayList (); private Relocator relocator; private MessageBlock messageBlock; private Huffman huffman; + private final int version; public Wizardry4BootDisk (AppleDisk[] dataDisks) { super (dataDisks[0]); - // this.dataDisks = dataDisks; + version = dataDisks.length == 6 ? 4 : dataDisks.length == 10 ? 5 : 0; DefaultTreeModel model = (DefaultTreeModel) catalogTree.getModel (); DefaultMutableTreeNode currentRoot = (DefaultMutableTreeNode) model.getRoot (); @@ -53,25 +54,37 @@ public class Wizardry4BootDisk extends PascalDisk fileEntry.getDataSource (); } - DefaultMutableTreeNode scenarioNode = findNode (currentRoot, "SCENARIO.DATA"); - fileEntry = (FileEntry) scenarioNode.getUserObject (); - if (fileEntry != null) + if (version == 4) { - fileEntry.setFile (null); + DefaultMutableTreeNode scenarioNode = findNode (currentRoot, "SCENARIO.DATA"); - scenarioNode.setAllowsChildren (true); - scenarioHeader = new Header (scenarioNode, this); - linkMazeLevels (scenarioNode, fileEntry); + if (scenarioNode != null) + { + fileEntry = (FileEntry) scenarioNode.getUserObject (); + if (fileEntry != null) + { + fileEntry.setFile (null); + scenarioNode.setAllowsChildren (true); + scenarioHeader = new Header (scenarioNode, this); + linkMazeLevels4 (scenarioNode, fileEntry); + } + } + } + else if (version == 5) + { + DefaultMutableTreeNode scenarioNode = findNode (currentRoot, "DRAGON.DATA"); } - DefaultMutableTreeNode monstersNode = findNode (currentRoot, "200.MONSTERS"); - fileEntry = (FileEntry) monstersNode.getUserObject (); - if (fileEntry != null) + if (version == 4) { - fileEntry.setFile (null); - - monstersNode.setAllowsChildren (true); - linkMonsterImages (monstersNode, fileEntry); + DefaultMutableTreeNode monstersNode = findNode (currentRoot, "200.MONSTERS"); + fileEntry = (FileEntry) monstersNode.getUserObject (); + if (fileEntry != null) + { + fileEntry.setFile (null); + monstersNode.setAllowsChildren (true); + linkMonsterImages4 (monstersNode, fileEntry); + } } DefaultMutableTreeNode huffNode = findNode (currentRoot, "ASCII.HUFF"); @@ -91,15 +104,19 @@ public class Wizardry4BootDisk extends PascalDisk { messageBlock = new MessageBlock (fileEntry.getDataSource ().buffer, huffman); messagesNode.setAllowsChildren (true); + List blocks = fileEntry.getSectors (); + + int count = 0; for (MessageDataBlock mdb : messageBlock) { List messageBlocks = new ArrayList (); + messageBlocks.add (blocks.get (count++)); addToNode (mdb, messagesNode, messageBlocks); } } } - private void linkMazeLevels (DefaultMutableTreeNode scenarioNode, FileEntry fileEntry) + private void linkMazeLevels4 (DefaultMutableTreeNode scenarioNode, FileEntry fileEntry) { ScenarioData mazeData = scenarioHeader.data.get (Header.MAZE_AREA); @@ -110,18 +127,21 @@ public class Wizardry4BootDisk extends PascalDisk for (int i = 0; i < 15; i++) { byte[] level = new byte[896]; - System.arraycopy (buffer, mazeData.dataOffset * 512 + i * 1024, level, 0, - level.length); + int offset = mazeData.dataOffset * 512 + i * 1024; + if (offset + level.length < buffer.length) + { + System.arraycopy (buffer, offset, level, 0, level.length); - List mazeBlocks = new ArrayList (); - int ptr = mazeData.dataOffset + i * 2; - mazeBlocks.add (blocks.get (ptr)); - mazeBlocks.add (blocks.get (ptr + 1)); - addToNode (new MazeLevel (level, i), mazeNode, mazeBlocks); + List mazeBlocks = new ArrayList (); + int ptr = mazeData.dataOffset + i * 2; + mazeBlocks.add (blocks.get (ptr)); + mazeBlocks.add (blocks.get (ptr + 1)); + addToNode (new MazeLevel (level, i), mazeNode, mazeBlocks); + } } } - private void linkMonsterImages (DefaultMutableTreeNode monstersNode, + private void linkMonsterImages4 (DefaultMutableTreeNode monstersNode, FileEntry fileEntry) { byte[] pictureBuffer = fileEntry.getDataSource ().buffer; @@ -149,8 +169,8 @@ public class Wizardry4BootDisk extends PascalDisk DefaultAppleFileSource dafs = new DefaultAppleFileSource (af.getName (), af, this, blocks); DefaultMutableTreeNode childNode = new DefaultMutableTreeNode (dafs); - node.add (childNode); childNode.setAllowsChildren (false); + node.add (childNode); } private DefaultMutableTreeNode linkNode (String name, String text, diff --git a/src/com/bytezone/diskbrowser/wizardry/WizardryScenarioDisk.java b/src/com/bytezone/diskbrowser/wizardry/WizardryScenarioDisk.java index 1797902..9b2f7f7 100755 --- a/src/com/bytezone/diskbrowser/wizardry/WizardryScenarioDisk.java +++ b/src/com/bytezone/diskbrowser/wizardry/WizardryScenarioDisk.java @@ -84,8 +84,8 @@ public class WizardryScenarioDisk extends PascalDisk // Process SCENARIO.MESGS (requires scenario) AppleFileSource afs = (AppleFileSource) msgNode.getUserObject (); - DefaultMutableTreeNode node = linkNode ("Messages", "Messages string", msgNode); - extractMessages (node, afs.getSectors ()); + // DefaultMutableTreeNode node = linkNode ("Messages", "Messages string", msgNode); + extractMessages (msgNode, afs.getSectors ()); // makeNodeVisible (node); // Process SCENARIO.DATA (requires scenario and messages) @@ -100,7 +100,7 @@ public class WizardryScenarioDisk extends PascalDisk extractExperienceLevels (linkNode ("Experience", "Experience string", dataNode), sectors); // node = linkNode ("Spells", "Spells string", dataNode); - node = null; + DefaultMutableTreeNode node = null; extractSpells (node, sectors); extractLevels (linkNode ("Maze", "Levels string", dataNode), sectors); // Make the Spells node (and its siblings) visible @@ -467,9 +467,6 @@ public class WizardryScenarioDisk extends PascalDisk totalLines = 0; } } - - DefaultAppleFileSource afs = (DefaultAppleFileSource) node.getUserObject (); - afs.setSectors (sectors); } private void extractLevels (DefaultMutableTreeNode node, List sectors)