mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-29 11:49:29 +00:00
set code sectors
This commit is contained in:
parent
6be994c2a3
commit
bff1e8de2d
@ -1,5 +1,6 @@
|
||||
package com.bytezone.diskbrowser.infocom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
@ -8,7 +9,8 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
||||
|
||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.disk.DefaultAppleFileSource;
|
||||
import com.bytezone.diskbrowser.disk.FormattedDisk;
|
||||
import com.bytezone.diskbrowser.disk.Disk;
|
||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
class CodeManager extends AbstractFile
|
||||
@ -23,25 +25,41 @@ class CodeManager extends AbstractFile
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
public void addNodes (DefaultMutableTreeNode root, FormattedDisk disk)
|
||||
void addNodes (DefaultMutableTreeNode root, InfocomDisk disk)
|
||||
{
|
||||
root.setAllowsChildren (true);
|
||||
|
||||
codeSize = header.stringPointer - header.highMemory; // should be set by now - do this better!
|
||||
// should be set by now - do this better!
|
||||
codeSize = header.stringPointer - header.highMemory;
|
||||
|
||||
int count = 0;
|
||||
for (Routine routine : routines.values ())
|
||||
{
|
||||
DefaultMutableTreeNode node =
|
||||
new DefaultMutableTreeNode (new DefaultAppleFileSource (
|
||||
String.format ("%3d %s (%04X)", ++count, routine.getName (),
|
||||
routine.startPtr / 2),
|
||||
routine, disk));
|
||||
String name = String.format ("%3d %s (%04X)", ++count, routine.getName (),
|
||||
routine.startPtr / 2);
|
||||
DefaultAppleFileSource dafs = new DefaultAppleFileSource (name, routine, disk);
|
||||
dafs.setSectors (getSectors (routine, disk.getDisk ()));
|
||||
|
||||
DefaultMutableTreeNode node = new DefaultMutableTreeNode (dafs);
|
||||
node.setAllowsChildren (false);
|
||||
root.add (node);
|
||||
}
|
||||
}
|
||||
|
||||
private List<DiskAddress> getSectors (Routine routine, Disk disk)
|
||||
{
|
||||
int blockNo = routine.startPtr / 256 + 48;
|
||||
int size = routine.length;
|
||||
List<DiskAddress> blocks = new ArrayList<DiskAddress> ();
|
||||
|
||||
while (size > 0)
|
||||
{
|
||||
blocks.add (disk.getDiskAddress (blockNo++));
|
||||
size -= 256;
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
public void addMissingRoutines ()
|
||||
{
|
||||
System.out.printf ("%nWalking the code block%n%n");
|
||||
|
@ -2,11 +2,14 @@ package com.bytezone.diskbrowser.infocom;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.bytezone.diskbrowser.disk.Disk;
|
||||
|
||||
class Header extends InfocomAbstractFile
|
||||
{
|
||||
final String[] propertyNames = new String[32];
|
||||
|
||||
private final File file;
|
||||
private final Disk disk;
|
||||
int version;
|
||||
int highMemory;
|
||||
int programCounter;
|
||||
@ -27,10 +30,11 @@ class Header extends InfocomAbstractFile
|
||||
Globals globals;
|
||||
Grammar grammar;
|
||||
|
||||
public Header (String name, byte[] buffer, File file)
|
||||
public Header (String name, byte[] buffer, Disk disk)
|
||||
{
|
||||
super (name, buffer);
|
||||
this.file = file;
|
||||
this.disk = disk;
|
||||
this.file = disk.getFile ();
|
||||
|
||||
version = getByte (0);
|
||||
highMemory = getWord (4);
|
||||
|
@ -58,7 +58,7 @@ public class InfocomDisk extends AbstractFormattedDisk
|
||||
DefaultMutableTreeNode dictionaryNode = null;
|
||||
DefaultMutableTreeNode stringsNode = null;
|
||||
|
||||
header = new Header ("Header", data, disk.getFile ());
|
||||
header = new Header ("Header", data, disk);
|
||||
|
||||
headerNode = addToTree (root, "Header", header, TYPE_LEAF);
|
||||
DefaultAppleFileSource dafs = (DefaultAppleFileSource) headerNode.getUserObject ();
|
||||
|
Loading…
Reference in New Issue
Block a user