mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-25 16:34:00 +00:00
Wiz4 first stage complete
This commit is contained in:
parent
6ad21060b3
commit
9104389d22
@ -22,7 +22,7 @@ public class PascalCode extends AbstractFile
|
|||||||
PascalConstants.mnemonics[i], PascalConstants.descriptions[i]);
|
PascalConstants.mnemonics[i], PascalConstants.descriptions[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PascalCode (String name, byte[] buffer, int blockOffset, Relocator relocator)
|
public PascalCode (String name, byte[] buffer, int blockOffset)
|
||||||
{
|
{
|
||||||
super (name, buffer);
|
super (name, buffer);
|
||||||
|
|
||||||
@ -31,8 +31,8 @@ public class PascalCode extends AbstractFile
|
|||||||
throw new FileFormatException ("Error in PascalSegment");
|
throw new FileFormatException ("Error in PascalSegment");
|
||||||
// this.blockOffset = blockOffset;
|
// this.blockOffset = blockOffset;
|
||||||
// this.relocator = relocator;
|
// this.relocator = relocator;
|
||||||
if (relocator != null)
|
// if (relocator != null)
|
||||||
relocator.getMultiDiskAddress ("SEG-DIC", blockOffset, 1);
|
// relocator.getMultiDiskAddress ("SEG-DIC", blockOffset, 1);
|
||||||
|
|
||||||
int nonameCounter = 0;
|
int nonameCounter = 0;
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ public class PascalCode extends AbstractFile
|
|||||||
{
|
{
|
||||||
// this could throw an exception
|
// this could throw an exception
|
||||||
PascalSegment pascalSegment =
|
PascalSegment pascalSegment =
|
||||||
new PascalSegment (codeName, buffer, i, blockOffset, relocator);
|
new PascalSegment (codeName, buffer, i, blockOffset);
|
||||||
segments.add (pascalSegment);
|
segments.add (pascalSegment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public class PascalProcedure
|
|||||||
// System.out.printf ("ptr:%d, max:%d, buf:%d %n", ptr, max, buffer.length);
|
// System.out.printf ("ptr:%d, max:%d, buf:%d %n", ptr, max, buffer.length);
|
||||||
if (ptr >= buffer.length || ptr < 0)
|
if (ptr >= buffer.length || ptr < 0)
|
||||||
{
|
{
|
||||||
System.out.println ("Ptr outside buffer");
|
System.out.printf ("Ptr outside buffer: %d %d%n", ptr, buffer.length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PascalCodeStatement cs = new PascalCodeStatement (buffer, ptr, procOffset);
|
PascalCodeStatement cs = new PascalCodeStatement (buffer, ptr, procOffset);
|
||||||
|
@ -13,7 +13,7 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
|||||||
final int segmentNoHeader;
|
final int segmentNoHeader;
|
||||||
private int segmentNoBody;
|
private int segmentNoBody;
|
||||||
private final int blockOffset;
|
private final int blockOffset;
|
||||||
private final Relocator relocator;
|
// private final Relocator relocator;
|
||||||
|
|
||||||
public int blockNo;
|
public int blockNo;
|
||||||
// public int newBlockNo;
|
// public int newBlockNo;
|
||||||
@ -30,14 +30,13 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
|||||||
private List<PascalProcedure> procedures;
|
private List<PascalProcedure> procedures;
|
||||||
private List<MultiDiskAddress> addresses;
|
private List<MultiDiskAddress> addresses;
|
||||||
|
|
||||||
public PascalSegment (String name, byte[] fullBuffer, int seq, int blockOffset,
|
public PascalSegment (String name, byte[] fullBuffer, int seq, int blockOffset)
|
||||||
Relocator relocator)
|
|
||||||
{
|
{
|
||||||
super (name, fullBuffer); // sets this.buffer to the full buffer temporarily
|
super (name, fullBuffer); // sets this.buffer to the full buffer temporarily
|
||||||
|
|
||||||
this.slot = seq;
|
this.slot = seq;
|
||||||
this.blockOffset = blockOffset;
|
this.blockOffset = blockOffset;
|
||||||
this.relocator = relocator;
|
// this.relocator = relocator;
|
||||||
|
|
||||||
this.blockNo = HexFormatter.intValue (fullBuffer[seq * 4], fullBuffer[seq * 4 + 1]);
|
this.blockNo = HexFormatter.intValue (fullBuffer[seq * 4], fullBuffer[seq * 4 + 1]);
|
||||||
this.size = HexFormatter.intValue (fullBuffer[seq * 4 + 2], fullBuffer[seq * 4 + 3]);
|
this.size = HexFormatter.intValue (fullBuffer[seq * 4 + 2], fullBuffer[seq * 4 + 3]);
|
||||||
@ -68,23 +67,23 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
|||||||
|
|
||||||
int offset = blockNo * 512;
|
int offset = blockNo * 512;
|
||||||
|
|
||||||
if (relocator != null)
|
// if (relocator != null)
|
||||||
{
|
// {
|
||||||
// if (segmentNoHeader > 1)
|
// // if (segmentNoHeader > 1)
|
||||||
// {
|
// // {
|
||||||
int sizeInBlocks = (size - 1) / BLOCK_SIZE + 1;
|
// int sizeInBlocks = (size - 1) / BLOCK_SIZE + 1;
|
||||||
int targetBlock = blockNo + blockOffset;
|
// int targetBlock = blockNo + blockOffset;
|
||||||
addresses = relocator.getMultiDiskAddress (name, targetBlock, sizeInBlocks);
|
// addresses = relocator.getMultiDiskAddress (name, targetBlock, sizeInBlocks);
|
||||||
if (addresses.size () > 0)
|
// if (addresses.size () > 0)
|
||||||
{
|
// {
|
||||||
MultiDiskAddress multiDiskAddress = addresses.get (0);
|
// MultiDiskAddress multiDiskAddress = addresses.get (0);
|
||||||
if (multiDiskAddress.diskNumber == 1)
|
// if (multiDiskAddress.diskNumber == 1)
|
||||||
offset = (multiDiskAddress.physicalBlockNumber - blockOffset) * BLOCK_SIZE;
|
// offset = (multiDiskAddress.physicalBlockNumber - blockOffset) * BLOCK_SIZE;
|
||||||
else
|
// else
|
||||||
offset = -1;
|
// offset = -1;
|
||||||
}
|
// }
|
||||||
// }
|
// // }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (offset < 0)
|
if (offset < 0)
|
||||||
{
|
{
|
||||||
@ -204,26 +203,26 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
|||||||
// multiDiskAddressText = String.format ("1:%03X", (blockNo + blockOffset));
|
// multiDiskAddressText = String.format ("1:%03X", (blockNo + blockOffset));
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
if (relocator != null)
|
// if (relocator != null)
|
||||||
{
|
// {
|
||||||
int targetBlock = blockNo + blockOffset;
|
// int targetBlock = blockNo + blockOffset;
|
||||||
List<MultiDiskAddress> addresses =
|
// List<MultiDiskAddress> addresses =
|
||||||
relocator.getMultiDiskAddress (name, targetBlock, sizeInBlocks);
|
// relocator.getMultiDiskAddress (name, targetBlock, sizeInBlocks);
|
||||||
if (addresses.isEmpty ())
|
// if (addresses.isEmpty ())
|
||||||
multiDiskAddressText = ".";
|
// multiDiskAddressText = ".";
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
StringBuilder locations = new StringBuilder ();
|
// StringBuilder locations = new StringBuilder ();
|
||||||
for (MultiDiskAddress multiDiskAddress : addresses)
|
// for (MultiDiskAddress multiDiskAddress : addresses)
|
||||||
locations.append (multiDiskAddress.toString () + ", ");
|
// locations.append (multiDiskAddress.toString () + ", ");
|
||||||
if (locations.length () > 2)
|
// if (locations.length () > 2)
|
||||||
{
|
// {
|
||||||
locations.deleteCharAt (locations.length () - 1);
|
// locations.deleteCharAt (locations.length () - 1);
|
||||||
locations.deleteCharAt (locations.length () - 1);
|
// locations.deleteCharAt (locations.length () - 1);
|
||||||
}
|
// }
|
||||||
multiDiskAddressText = locations.toString ();
|
// multiDiskAddressText = locations.toString ();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return multiDiskAddressText;
|
return multiDiskAddressText;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.bytezone.diskbrowser.disk.AppleDisk;
|
||||||
import com.bytezone.diskbrowser.disk.Disk;
|
import com.bytezone.diskbrowser.disk.Disk;
|
||||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
import com.bytezone.diskbrowser.disk.DiskAddress;
|
||||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
@ -151,6 +152,24 @@ public class Relocator extends AbstractFile
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void createNewBuffer (Disk[] dataDisks)
|
||||||
|
{
|
||||||
|
AppleDisk master = (AppleDisk) dataDisks[0];
|
||||||
|
|
||||||
|
for (int logicalBlock = 0; logicalBlock < diskBlocks.length; logicalBlock++)
|
||||||
|
{
|
||||||
|
int physicalBlock = diskOffsets2[logicalBlock];
|
||||||
|
int diskNo = diskBlocks[logicalBlock];
|
||||||
|
if (diskNo > 0)
|
||||||
|
{
|
||||||
|
Disk disk = dataDisks[diskNo];
|
||||||
|
byte[] temp = disk.readSector (physicalBlock);
|
||||||
|
DiskAddress da = master.getDiskAddress (logicalBlock);
|
||||||
|
master.writeSector (da, temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText ()
|
public String getText ()
|
||||||
{
|
{
|
||||||
@ -165,23 +184,26 @@ public class Relocator extends AbstractFile
|
|||||||
text.append ("\n");
|
text.append ("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int previousDiskNumber = 0;
|
if (false)
|
||||||
for (MultiDiskAddress multiDiskAddress : addresses)
|
|
||||||
{
|
{
|
||||||
if (multiDiskAddress.diskNumber != previousDiskNumber)
|
int previousDiskNumber = 0;
|
||||||
|
for (MultiDiskAddress multiDiskAddress : addresses)
|
||||||
{
|
{
|
||||||
previousDiskNumber = multiDiskAddress.diskNumber;
|
if (multiDiskAddress.diskNumber != previousDiskNumber)
|
||||||
text.append ("\n");
|
{
|
||||||
text.append ("Disk Logical Physical Size Name\n");
|
previousDiskNumber = multiDiskAddress.diskNumber;
|
||||||
text.append ("---- ------- -------- ---- -------------\n");
|
text.append ("\n");
|
||||||
|
text.append ("Disk Logical Physical Size Name\n");
|
||||||
|
text.append ("---- ------- -------- ---- -------------\n");
|
||||||
|
}
|
||||||
|
text.append (String.format (" %d %03X %03X %03X %s%n",
|
||||||
|
multiDiskAddress.diskNumber, multiDiskAddress.logicalBlockNumber,
|
||||||
|
multiDiskAddress.physicalBlockNumber, multiDiskAddress.totalBlocks,
|
||||||
|
multiDiskAddress.name));
|
||||||
}
|
}
|
||||||
text.append (String.format (" %d %03X %03X %03X %s%n",
|
|
||||||
multiDiskAddress.diskNumber, multiDiskAddress.logicalBlockNumber,
|
|
||||||
multiDiskAddress.physicalBlockNumber, multiDiskAddress.totalBlocks,
|
|
||||||
multiDiskAddress.name));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
text.append ("\n\n Logical Size Disk Physical");
|
text.append ("\n Logical Size Disk Physical");
|
||||||
text.append ("\n--------- ---- ---- ---------\n");
|
text.append ("\n--------- ---- ---- ---------\n");
|
||||||
|
|
||||||
int first = 0;
|
int first = 0;
|
||||||
|
@ -381,10 +381,11 @@ public class AppleDisk implements Disk
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int writeSector (DiskAddress da, byte[] buffer)
|
public void writeSector (DiskAddress da, byte[] buffer)
|
||||||
{
|
{
|
||||||
System.out.println ("Not yet implemented");
|
// System.out.println ("Not yet implemented");
|
||||||
return -1;
|
// return -1;
|
||||||
|
writeBuffer (da, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -507,7 +508,7 @@ public class AppleDisk implements Disk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeBuffer (DiskAddress da, byte[] buffer, int bufferOffset)
|
private void writeBuffer (DiskAddress da, byte[] buffer)
|
||||||
{
|
{
|
||||||
assert da.getDisk () == this : "Disk address not applicable to this disk";
|
assert da.getDisk () == this : "Disk address not applicable to this disk";
|
||||||
assert sectorSize == SECTOR_SIZE
|
assert sectorSize == SECTOR_SIZE
|
||||||
@ -518,16 +519,15 @@ public class AppleDisk implements Disk
|
|||||||
if (sectorSize == SECTOR_SIZE)
|
if (sectorSize == SECTOR_SIZE)
|
||||||
{
|
{
|
||||||
int diskOffset = getBufferOffset (da);
|
int diskOffset = getBufferOffset (da);
|
||||||
System.arraycopy (buffer, bufferOffset, diskBuffer, diskOffset, SECTOR_SIZE);
|
System.arraycopy (buffer, 0, diskBuffer, diskOffset, SECTOR_SIZE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int diskOffset = getBufferOffset (da, 0);
|
int diskOffset = getBufferOffset (da, 0);
|
||||||
System.arraycopy (buffer, bufferOffset, diskBuffer, diskOffset, SECTOR_SIZE);
|
System.arraycopy (buffer, 0, diskBuffer, diskOffset, SECTOR_SIZE);
|
||||||
|
|
||||||
diskOffset = getBufferOffset (da, 1);
|
diskOffset = getBufferOffset (da, 1);
|
||||||
System.arraycopy (buffer, bufferOffset + SECTOR_SIZE, diskBuffer, diskOffset,
|
System.arraycopy (buffer, SECTOR_SIZE, diskBuffer, diskOffset, SECTOR_SIZE);
|
||||||
SECTOR_SIZE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public interface Disk extends Iterable<DiskAddress>
|
|||||||
|
|
||||||
public byte[] readSectors (List<DiskAddress> daList);
|
public byte[] readSectors (List<DiskAddress> daList);
|
||||||
|
|
||||||
public int writeSector (DiskAddress da, byte[] buffer);
|
public void writeSector (DiskAddress da, byte[] buffer);
|
||||||
|
|
||||||
public boolean isSectorEmpty (DiskAddress da);
|
public boolean isSectorEmpty (DiskAddress da);
|
||||||
|
|
||||||
|
@ -390,13 +390,15 @@ public class DiskFactory
|
|||||||
|
|
||||||
if (Wizardry4BootDisk.isWizardryIV (disk, debug))
|
if (Wizardry4BootDisk.isWizardryIV (disk, debug))
|
||||||
{
|
{
|
||||||
// collect 4 data disks
|
// collect 4 extra data disks
|
||||||
AppleDisk[] disks = new AppleDisk[5];
|
AppleDisk[] disks = new AppleDisk[6];
|
||||||
AppleDisk d = new AppleDisk (file, 256, 8);
|
|
||||||
d.setInterleave (1);
|
|
||||||
disks[0] = d;
|
|
||||||
|
|
||||||
for (int i = 2; i <= 5; i++)
|
disks[0] = new AppleDisk (file, 256, 8); // will become a PascalDisk
|
||||||
|
disks[1] = new AppleDisk (file, 256, 8); // will remain a DataDisk
|
||||||
|
disks[0].setInterleave (1);
|
||||||
|
disks[1].setInterleave (1);
|
||||||
|
|
||||||
|
for (int i = 2; i < disks.length; i++)
|
||||||
{
|
{
|
||||||
String filename = file.getAbsolutePath ().replace ("1.dsk", i + ".dsk");
|
String filename = file.getAbsolutePath ().replace ("1.dsk", i + ".dsk");
|
||||||
File f = new File (filename);
|
File f = new File (filename);
|
||||||
@ -404,7 +406,7 @@ public class DiskFactory
|
|||||||
{
|
{
|
||||||
AppleDisk dataDisk = new AppleDisk (f, 35, 8);
|
AppleDisk dataDisk = new AppleDisk (f, 35, 8);
|
||||||
dataDisk.setInterleave (1);
|
dataDisk.setInterleave (1);
|
||||||
disks[i - 1] = dataDisk;
|
disks[i] = dataDisk;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,35 +1,26 @@
|
|||||||
package com.bytezone.diskbrowser.pascal;
|
package com.bytezone.diskbrowser.pascal;
|
||||||
|
|
||||||
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.*;
|
import com.bytezone.diskbrowser.applefile.*;
|
||||||
import com.bytezone.diskbrowser.disk.DiskAddress;
|
|
||||||
import com.bytezone.diskbrowser.utilities.FileFormatException;
|
import com.bytezone.diskbrowser.utilities.FileFormatException;
|
||||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||||
|
|
||||||
public class FileEntry extends CatalogEntry
|
public class FileEntry extends CatalogEntry
|
||||||
{
|
{
|
||||||
int bytesUsedInLastBlock;
|
int bytesUsedInLastBlock;
|
||||||
private final Relocator relocator;
|
private DefaultMutableTreeNode node;
|
||||||
|
AbstractFile file;
|
||||||
|
|
||||||
public FileEntry (PascalDisk parent, byte[] buffer, Relocator relocator)
|
public FileEntry (PascalDisk parent, byte[] buffer)
|
||||||
{
|
{
|
||||||
super (parent, buffer);
|
super (parent, buffer);
|
||||||
|
|
||||||
this.relocator = relocator;
|
|
||||||
bytesUsedInLastBlock = HexFormatter.intValue (buffer[22], buffer[23]);
|
bytesUsedInLastBlock = HexFormatter.intValue (buffer[22], buffer[23]);
|
||||||
date = HexFormatter.getPascalDate (buffer, 24);
|
date = HexFormatter.getPascalDate (buffer, 24);
|
||||||
|
|
||||||
if (relocator != null)
|
|
||||||
{
|
|
||||||
int size = lastBlock - firstBlock;
|
|
||||||
// System.out.printf ("%04X %04X %s%n", firstBlock, size, name);
|
|
||||||
relocator.getMultiDiskAddress (name, firstBlock, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = firstBlock; i < lastBlock; i++)
|
for (int i = firstBlock; i < lastBlock; i++)
|
||||||
{
|
{
|
||||||
if (i >= 280)
|
|
||||||
break;
|
|
||||||
|
|
||||||
switch (fileType)
|
switch (fileType)
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
@ -64,14 +55,22 @@ public class FileEntry extends CatalogEntry
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setNode (DefaultMutableTreeNode node)
|
||||||
|
{
|
||||||
|
this.node = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFile (AbstractFile file)
|
||||||
|
{
|
||||||
|
this.file = file;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractFile getDataSource ()
|
public AbstractFile getDataSource ()
|
||||||
{
|
{
|
||||||
if (file != null)
|
if (file != null)
|
||||||
return file;
|
return file;
|
||||||
|
|
||||||
// this needs to use the Relocator to obtain the currect blocks
|
|
||||||
assembleBuffer ();
|
|
||||||
byte[] buffer = getExactBuffer ();
|
byte[] buffer = getExactBuffer ();
|
||||||
|
|
||||||
switch (fileType)
|
switch (fileType)
|
||||||
@ -79,7 +78,16 @@ public class FileEntry extends CatalogEntry
|
|||||||
case 2: // code (6502 or Pascal)
|
case 2: // code (6502 or Pascal)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
file = new PascalCode (name, buffer, firstBlock, relocator);
|
file = new PascalCode (name, buffer, firstBlock);
|
||||||
|
node.removeAllChildren ();
|
||||||
|
|
||||||
|
for (PascalSegment pascalSegment : (PascalCode) file)
|
||||||
|
{
|
||||||
|
DefaultMutableTreeNode segmentNode = new DefaultMutableTreeNode (
|
||||||
|
new PascalCodeObject (parent, pascalSegment, firstBlock));
|
||||||
|
node.add (segmentNode);
|
||||||
|
segmentNode.setAllowsChildren (false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (FileFormatException e)
|
catch (FileFormatException e)
|
||||||
{
|
{
|
||||||
@ -103,8 +111,8 @@ public class FileEntry extends CatalogEntry
|
|||||||
file = new Charset (name, buffer);
|
file = new Charset (name, buffer);
|
||||||
// else if (name.equals ("WT")) // only testing
|
// else if (name.equals ("WT")) // only testing
|
||||||
// file = new WizardryTitle (name, buffer);
|
// file = new WizardryTitle (name, buffer);
|
||||||
else if (name.equals ("SYSTEM.RELOC"))
|
// else if (name.equals ("SYSTEM.RELOC"))
|
||||||
file = new Relocator (name, buffer);
|
// file = new Relocator (name, buffer);
|
||||||
else
|
else
|
||||||
file = new DefaultAppleFile (name, buffer);
|
file = new DefaultAppleFile (name, buffer);
|
||||||
break;
|
break;
|
||||||
@ -119,27 +127,11 @@ public class FileEntry extends CatalogEntry
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] assembleBuffer ()
|
|
||||||
{
|
|
||||||
if (relocator != null)
|
|
||||||
for (DiskAddress da : blocks)
|
|
||||||
{
|
|
||||||
System.out.println (da);
|
|
||||||
if (da.getBlock () < 20)
|
|
||||||
{
|
|
||||||
byte[] buffer = relocator.getLogicalBuffer (da);
|
|
||||||
System.out.println (HexFormatter.format (buffer));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// use Relocator to obtain correct blocks
|
|
||||||
private byte[] getExactBuffer ()
|
private byte[] getExactBuffer ()
|
||||||
{
|
{
|
||||||
byte[] buffer = parent.getDisk ().readSectors (blocks);
|
byte[] buffer = parent.getDisk ().readSectors (blocks);
|
||||||
byte[] exactBuffer;
|
byte[] exactBuffer;
|
||||||
|
// System.out.println (HexFormatter.format (buffer));
|
||||||
|
|
||||||
if (buffer.length > 0 && bytesUsedInLastBlock < 512)
|
if (buffer.length > 0 && bytesUsedInLastBlock < 512)
|
||||||
{
|
{
|
||||||
|
@ -10,8 +10,6 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
|||||||
|
|
||||||
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
import com.bytezone.diskbrowser.applefile.AppleFileSource;
|
||||||
import com.bytezone.diskbrowser.applefile.BootSector;
|
import com.bytezone.diskbrowser.applefile.BootSector;
|
||||||
import com.bytezone.diskbrowser.applefile.PascalCode;
|
|
||||||
import com.bytezone.diskbrowser.applefile.PascalSegment;
|
|
||||||
import com.bytezone.diskbrowser.applefile.Relocator;
|
import com.bytezone.diskbrowser.applefile.Relocator;
|
||||||
import com.bytezone.diskbrowser.disk.*;
|
import com.bytezone.diskbrowser.disk.*;
|
||||||
import com.bytezone.diskbrowser.gui.DataSource;
|
import com.bytezone.diskbrowser.gui.DataSource;
|
||||||
@ -21,11 +19,10 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||||||
{
|
{
|
||||||
static final int CATALOG_ENTRY_SIZE = 26;
|
static final int CATALOG_ENTRY_SIZE = 26;
|
||||||
private final DateFormat df = DateFormat.getDateInstance (DateFormat.SHORT);
|
private final DateFormat df = DateFormat.getDateInstance (DateFormat.SHORT);
|
||||||
private VolumeEntry volumeEntry;
|
private final VolumeEntry volumeEntry;
|
||||||
private PascalCatalogSector diskCatalogSector;
|
private final PascalCatalogSector diskCatalogSector;
|
||||||
|
|
||||||
protected Relocator relocator;
|
protected Relocator relocator;
|
||||||
protected Disk[] dataDisks;
|
|
||||||
|
|
||||||
final String[] fileTypes =
|
final String[] fileTypes =
|
||||||
{ "Volume", "Xdsk", "Code", "Text", "Info", "Data", "Graf", "Foto", "SecureDir" };
|
{ "Volume", "Xdsk", "Code", "Text", "Info", "Data", "Graf", "Foto", "SecureDir" };
|
||||||
@ -39,26 +36,10 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||||||
SectorType grafSector = new SectorType ("Graf", Color.cyan);
|
SectorType grafSector = new SectorType ("Graf", Color.cyan);
|
||||||
SectorType fotoSector = new SectorType ("Foto", Color.gray);
|
SectorType fotoSector = new SectorType ("Foto", Color.gray);
|
||||||
|
|
||||||
public PascalDisk (Disk[] disks)
|
|
||||||
{
|
|
||||||
super (disks[0]);
|
|
||||||
init ();
|
|
||||||
|
|
||||||
dataDisks = disks; // these need to be in place before ...
|
|
||||||
|
|
||||||
// 1. create new disk buffer
|
|
||||||
// 2. copy sectors from 5 data disks to new buffer
|
|
||||||
// 3. replace old disk buffer with new disk buffer
|
|
||||||
}
|
|
||||||
|
|
||||||
public PascalDisk (Disk disk)
|
public PascalDisk (Disk disk)
|
||||||
{
|
{
|
||||||
super (disk);
|
super (disk);
|
||||||
init ();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init ()
|
|
||||||
{
|
|
||||||
sectorTypesList.add (diskBootSector);
|
sectorTypesList.add (diskBootSector);
|
||||||
sectorTypesList.add (catalogSector);
|
sectorTypesList.add (catalogSector);
|
||||||
sectorTypesList.add (dataSector);
|
sectorTypesList.add (dataSector);
|
||||||
@ -117,32 +98,24 @@ public class PascalDisk extends AbstractFormattedDisk
|
|||||||
data = new byte[CATALOG_ENTRY_SIZE];
|
data = new byte[CATALOG_ENTRY_SIZE];
|
||||||
|
|
||||||
System.arraycopy (buffer, ptr, data, 0, CATALOG_ENTRY_SIZE);
|
System.arraycopy (buffer, ptr, data, 0, CATALOG_ENTRY_SIZE);
|
||||||
FileEntry fileEntry = new FileEntry (this, data, relocator);
|
FileEntry fileEntry = new FileEntry (this, data);
|
||||||
fileEntries.add (fileEntry);
|
fileEntries.add (fileEntry);
|
||||||
DefaultMutableTreeNode node = new DefaultMutableTreeNode (fileEntry);
|
DefaultMutableTreeNode node = new DefaultMutableTreeNode (fileEntry);
|
||||||
|
fileEntry.setNode (node);
|
||||||
|
|
||||||
// why is this being called? it creates every file on the disk
|
if (fileEntry.fileType == 2)// && dataSource instanceof PascalCode)
|
||||||
DataSource dataSource = fileEntry.getDataSource (); // reads all buffers
|
|
||||||
|
|
||||||
if (fileEntry.fileType == 5 && dataSource instanceof Relocator)
|
|
||||||
{
|
|
||||||
relocator = (Relocator) dataSource;
|
|
||||||
relocator.setDisks (dataDisks);
|
|
||||||
int size = fileEntry.lastBlock - fileEntry.firstBlock;
|
|
||||||
relocator.getMultiDiskAddress (fileEntry.name, fileEntry.firstBlock, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fileEntry.fileType == 2 && dataSource instanceof PascalCode)
|
|
||||||
{
|
{
|
||||||
node.setAllowsChildren (true);
|
node.setAllowsChildren (true);
|
||||||
PascalCode pascalCode = (PascalCode) dataSource;
|
// this does not trigger correctly when opening the arrow
|
||||||
for (PascalSegment pascalSegment : pascalCode)
|
|
||||||
{
|
// PascalCode pascalCode = (PascalCode) dataSource;
|
||||||
DefaultMutableTreeNode segmentNode = new DefaultMutableTreeNode (
|
// for (PascalSegment pascalSegment : pascalCode)
|
||||||
new PascalCodeObject (this, pascalSegment, fileEntry.firstBlock));
|
// {
|
||||||
node.add (segmentNode);
|
// DefaultMutableTreeNode segmentNode = new DefaultMutableTreeNode (
|
||||||
segmentNode.setAllowsChildren (false);
|
// new PascalCodeObject (this, pascalSegment, fileEntry.firstBlock));
|
||||||
}
|
// node.add (segmentNode);
|
||||||
|
// segmentNode.setAllowsChildren (false);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
node.setAllowsChildren (false);
|
node.setAllowsChildren (false);
|
||||||
|
@ -3,18 +3,40 @@ package com.bytezone.diskbrowser.wizardry;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
|
|
||||||
|
import com.bytezone.diskbrowser.applefile.Relocator;
|
||||||
import com.bytezone.diskbrowser.disk.AppleDisk;
|
import com.bytezone.diskbrowser.disk.AppleDisk;
|
||||||
import com.bytezone.diskbrowser.disk.Disk;
|
import com.bytezone.diskbrowser.disk.Disk;
|
||||||
|
import com.bytezone.diskbrowser.pascal.FileEntry;
|
||||||
import com.bytezone.diskbrowser.pascal.PascalDisk;
|
import com.bytezone.diskbrowser.pascal.PascalDisk;
|
||||||
import com.bytezone.diskbrowser.utilities.Utility;
|
import com.bytezone.diskbrowser.utilities.Utility;
|
||||||
|
|
||||||
public class Wizardry4BootDisk extends PascalDisk
|
public class Wizardry4BootDisk extends PascalDisk
|
||||||
{
|
{
|
||||||
List<AppleDisk> disks = new ArrayList<AppleDisk> ();
|
List<AppleDisk> disks = new ArrayList<AppleDisk> ();
|
||||||
|
protected Disk[] dataDisks;
|
||||||
|
private Relocator relocator;
|
||||||
|
|
||||||
public Wizardry4BootDisk (AppleDisk[] dataDisks)
|
public Wizardry4BootDisk (AppleDisk[] dataDisks)
|
||||||
{
|
{
|
||||||
super (dataDisks);
|
super (dataDisks[0]);
|
||||||
|
|
||||||
|
this.dataDisks = dataDisks;
|
||||||
|
|
||||||
|
DefaultTreeModel model = (DefaultTreeModel) catalogTree.getModel ();
|
||||||
|
DefaultMutableTreeNode currentRoot = (DefaultMutableTreeNode) model.getRoot ();
|
||||||
|
DefaultMutableTreeNode relocNode = findNode (currentRoot, "SYSTEM.RELOC");
|
||||||
|
FileEntry fileEntry = (FileEntry) relocNode.getUserObject ();
|
||||||
|
|
||||||
|
if (fileEntry != null)
|
||||||
|
{
|
||||||
|
relocator =
|
||||||
|
new Relocator (fileEntry.getUniqueName (), fileEntry.getDataSource ().buffer);
|
||||||
|
relocator.createNewBuffer (dataDisks);
|
||||||
|
fileEntry.setFile (relocator);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isWizardryIV (Disk disk, boolean debug)
|
public static boolean isWizardryIV (Disk disk, boolean debug)
|
||||||
|
Loading…
Reference in New Issue
Block a user