This commit is contained in:
Denis Molony 2016-08-19 19:57:29 +10:00
parent f6562b9ce2
commit 529d20ca18
9 changed files with 84 additions and 47 deletions

View File

@ -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

View File

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

View File

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

View File

@ -33,7 +33,7 @@ class FileSystemTab extends AbstractTab
Map<String, List<DiskDetails>> 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,7 +231,8 @@ 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 ();

View File

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

View File

@ -27,7 +27,7 @@ public class MessageBlock implements Iterable<MessageDataBlock>
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);
}
}

View File

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

View File

@ -19,16 +19,17 @@ import com.bytezone.diskbrowser.wizardry.Header.ScenarioData;
public class Wizardry4BootDisk extends PascalDisk
{
public Header scenarioHeader;
List<AppleDisk> disks = new ArrayList<AppleDisk> ();
private final List<AppleDisk> disks = new ArrayList<AppleDisk> ();
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<DiskAddress> blocks = fileEntry.getSectors ();
int count = 0;
for (MessageDataBlock mdb : messageBlock)
{
List<DiskAddress> messageBlocks = new ArrayList<DiskAddress> ();
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<DiskAddress> mazeBlocks = new ArrayList<DiskAddress> ();
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<DiskAddress> mazeBlocks = new ArrayList<DiskAddress> ();
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,

View File

@ -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<DiskAddress> sectors)