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