mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-25 16:34:00 +00:00
wizardry 4 changes
This commit is contained in:
parent
e911fae830
commit
3062189ee8
@ -6,6 +6,7 @@ import java.util.List;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.FileFormatException;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
public class PascalCode extends AbstractFile
|
||||
implements PascalConstants, Iterable<PascalSegment>
|
||||
@ -25,25 +26,31 @@ public class PascalCode extends AbstractFile
|
||||
{
|
||||
super (name, buffer);
|
||||
int nonameCounter = 0;
|
||||
if (false)
|
||||
{
|
||||
System.out.println (name);
|
||||
byte[] key = new byte[] { 0x38, 0x00, 0x0C, 0x1C };
|
||||
Utility.find (buffer, key);
|
||||
}
|
||||
|
||||
// Build segment list (up to 16 segments)
|
||||
// Create segment list (up to 16 segments)
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
codeName = HexFormatter.getString (buffer, 0x40 + i * 8, 8).trim ();
|
||||
if (codeName.length () == 0)
|
||||
codeName = "<NULL" + nonameCounter++ + ">";
|
||||
int size = HexFormatter.intValue (buffer[i * 4 + 2], buffer[i * 4 + 3]);
|
||||
System.out.printf ("%s %s %d %n", HexFormatter.getHexString (buffer, i * 4, 4),
|
||||
codeName, size);
|
||||
// System.out.printf ("%s %s %d %n", HexFormatter.getHexString (buffer, i * 4, 4),
|
||||
// codeName, size);
|
||||
if (size > 0)
|
||||
{
|
||||
if (codeName.length () == 0)
|
||||
codeName = "<NULL" + nonameCounter++ + ">";
|
||||
try
|
||||
{
|
||||
segments.add (new PascalSegment (codeName, buffer, i));
|
||||
}
|
||||
catch (FileFormatException e)
|
||||
{
|
||||
System.out.println ("Bad segment");
|
||||
System.out.printf ("Bad segment: %d%n", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -334,4 +334,20 @@ public class PascalCodeStatement implements PascalConstants
|
||||
return String.format ("%04X", addressTo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* from Wizardry info 1.txt
|
||||
|
||||
LDC instruction
|
||||
---------------
|
||||
Earlier today I noticed the LDC pcode instruction seems to display
|
||||
differently at times. Then I realized that it is operating with WORD
|
||||
values and needs to have them aligned on an even BYTE boundary. For
|
||||
example:
|
||||
|
||||
5004 B3 02 8C 3F CD CC
|
||||
LDC. PUSH 02 WORDS
|
||||
|
||||
5017 B3 02 (02)8C 3F CD CC
|
||||
LDC. PUSH 02 WORDS
|
||||
*/
|
@ -38,7 +38,7 @@ public class PascalProcedure
|
||||
if (valid)
|
||||
{
|
||||
procedureNo = buffer[procOffset] & 0xFF;
|
||||
procLevel = buffer[procOffset + 1];
|
||||
procLevel = buffer[procOffset + 1] & 0xFF;
|
||||
codeStart = HexFormatter.intValue (buffer[procOffset - 2], buffer[procOffset - 1]);
|
||||
codeEnd = HexFormatter.intValue (buffer[procOffset - 4], buffer[procOffset - 3]);
|
||||
parmSize = HexFormatter.intValue (buffer[procOffset - 6], buffer[procOffset - 5]);
|
||||
|
@ -31,12 +31,14 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
||||
this.slot = seq;
|
||||
this.blockNo = HexFormatter.intValue (fullBuffer[seq * 4], fullBuffer[seq * 4 + 1]);
|
||||
this.size = HexFormatter.intValue (fullBuffer[seq * 4 + 2], fullBuffer[seq * 4 + 3]);
|
||||
this.segmentNoHeader = fullBuffer[0x100 + seq * 2];
|
||||
|
||||
segKind = HexFormatter.intValue (fullBuffer[0xC0 + seq * 2],
|
||||
fullBuffer[0xC0 + seq * 2 + 1]);
|
||||
|
||||
textAddress = HexFormatter.intValue (fullBuffer[0xE0 + seq * 2],
|
||||
fullBuffer[0xE0 + seq * 2 + 1]);
|
||||
|
||||
this.segmentNoHeader = fullBuffer[0x100 + seq * 2] & 0xFF;
|
||||
int flags = fullBuffer[0x101 + seq * 2] & 0xFF;
|
||||
machineType = flags & 0x0F;
|
||||
version = (flags & 0xD0) >> 5;
|
||||
@ -64,8 +66,8 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.printf ("Error in blocksize %,d > %,d for pascal disk%n", offset,
|
||||
fullBuffer.length);
|
||||
// System.out.printf ("Error in blocksize %,d > %,d for pascal disk%n", offset,
|
||||
// fullBuffer.length);
|
||||
throw new FileFormatException ("Error in PascalSegment");
|
||||
}
|
||||
}
|
||||
@ -81,7 +83,7 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
||||
public String toText ()
|
||||
{
|
||||
return String
|
||||
.format (" %2d %02X %04X %,6d %-8s %-15s %3d %3d %d %d %d %d",
|
||||
.format (" %2d %02X %04X %,6d %-8s %-15s %3d %02X %d %d %d %d",
|
||||
slot, blockNo, size, size, name, SegmentKind[segKind], textAddress,
|
||||
segmentNoHeader, machineType, version, intrinsSegs1, intrinsSegs2);
|
||||
}
|
||||
@ -96,13 +98,13 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
||||
String title = "Segment - " + name;
|
||||
text.append (title + "\n"
|
||||
+ "===============================".substring (0, title.length ()) + "\n\n");
|
||||
String warning =
|
||||
segmentNoBody == segmentNoHeader ? "" : " (" + segmentNoHeader + " in header)";
|
||||
String warning = segmentNoBody == segmentNoHeader ? ""
|
||||
: String.format (" (%02X in header)", segmentNoHeader);
|
||||
text.append (String.format ("Address........ %02X%n", blockNo));
|
||||
text.append (String.format ("Length......... %04X%n", buffer.length));
|
||||
text.append (String.format ("Machine type... %d%n", machineType));
|
||||
text.append (String.format ("Version........ %d%n", version));
|
||||
text.append (String.format ("Segment........ %d%s%n", segmentNoBody, warning));
|
||||
text.append (String.format ("Segment........ %02X%s%n", segmentNoBody, warning));
|
||||
text.append (String.format ("Total procs.... %d%n", procedures.size ()));
|
||||
|
||||
text.append ("\nProcedure Dictionary\n====================\n\n");
|
||||
@ -118,17 +120,15 @@ public class PascalSegment extends AbstractFile implements PascalConstants
|
||||
if (procedure.valid)
|
||||
{
|
||||
int address = size - procedure.slot * 2 - 2;
|
||||
text.append (String.format (
|
||||
" %2d %04X %3d %04X %04X %04X "
|
||||
+ "%04X (%04X - %04X = %04X)%n",
|
||||
procedure.procedureNo, procedure.offset,
|
||||
procedure.procLevel, procedure.codeStart,
|
||||
procedure.codeEnd, procedure.parmSize,
|
||||
procedure.dataSize, address, procedure.offset,
|
||||
procedure.procOffset));
|
||||
text.append (String
|
||||
.format (" %3d %04X %3d %04X %04X %04X %04X (%04X - %04X = %04X)%n",
|
||||
procedure.procedureNo, procedure.offset, procedure.procLevel,
|
||||
procedure.codeStart, procedure.codeEnd, procedure.parmSize,
|
||||
procedure.dataSize, address, procedure.offset,
|
||||
procedure.procOffset));
|
||||
}
|
||||
else
|
||||
text.append (String.format (" %2d %04X%n", procedure.slot, procedure.offset));
|
||||
text.append (String.format (" %3d %04X%n", procedure.slot, procedure.offset));
|
||||
}
|
||||
|
||||
text.append ("\nStrings\n=======\n");
|
||||
|
@ -100,8 +100,8 @@ public class Relocator extends AbstractFile
|
||||
@Override
|
||||
public String toString ()
|
||||
{
|
||||
return String.format (" %04X %04X %04X", logicalBlock, physicalBlock,
|
||||
segmentLength);
|
||||
return String.format (" %04X %04X %04X %04X", logicalBlock,
|
||||
physicalBlock, segmentLength, (physicalBlock - 0x46));
|
||||
}
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@ import com.bytezone.diskbrowser.wizardry.WizardryScenarioDisk;
|
||||
|
||||
public class DiskFactory
|
||||
{
|
||||
private static boolean debug = true;
|
||||
private static boolean debug = false;
|
||||
|
||||
private DiskFactory ()
|
||||
{
|
||||
|
@ -160,7 +160,7 @@ public class DiskBrowser extends JFrame implements DiskSelectionListener, QuitLi
|
||||
@Override
|
||||
public void quit (Preferences preferences)
|
||||
{
|
||||
windowSaver = new WindowSaver (prefs, this, "DiskBrowser");
|
||||
// windowSaver = new WindowSaver (prefs, this, "DiskBrowser");
|
||||
windowSaver.saveWindow ();
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,8 @@ public class WindowSaver
|
||||
prefs.putInt (key + "Y", frame.getY ());
|
||||
prefs.putInt (key + "Height", frame.getHeight ());
|
||||
prefs.putInt (key + "Width", frame.getWidth ());
|
||||
System.out.printf ("Saving x:%d, y:%d, w:%d, h:%d%n", frame.getX (), frame.getY (),
|
||||
frame.getWidth (), frame.getHeight ());
|
||||
// System.out.printf ("Saving x:%d, y:%d, w:%d, h:%d%n", frame.getX (), frame.getY (),
|
||||
// frame.getWidth (), frame.getHeight ());
|
||||
}
|
||||
|
||||
public boolean restoreWindow ()
|
||||
@ -42,17 +42,17 @@ public class WindowSaver
|
||||
frame.setLocation (100, 100);
|
||||
frame.setSize (1000, 600);
|
||||
frame.setLocationRelativeTo (null); // centre
|
||||
System.out.printf ("Creating x:%d, y:%d, w:%d, h:%d%n", x, y, width, height);
|
||||
// System.out.printf ("Creating x:%d, y:%d, w:%d, h:%d%n", x, y, width, height);
|
||||
return false;
|
||||
}
|
||||
|
||||
System.out.printf ("w:%d, sw:%f%n", width, screen.getWidth ());
|
||||
// System.out.printf ("w:%d, sw:%f%n", width, screen.getWidth ());
|
||||
if (width > screen.getWidth () - 15)
|
||||
width = (int) (screen.getWidth () - 15);
|
||||
|
||||
frame.setSize (width, height);
|
||||
frame.setLocation (x, y);
|
||||
System.out.printf ("Restoring x:%d, y:%d, w:%d, h:%d%n", x, y, width, height);
|
||||
// System.out.printf ("Restoring x:%d, y:%d, w:%d, h:%d%n", x, y, width, height);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ abstract class CatalogEntry implements AppleFileSource
|
||||
{
|
||||
if (i >= 280)
|
||||
{
|
||||
System.out.printf ("CatalogEntry: block >= 280%n");
|
||||
System.out.printf ("CatalogEntry: block %04X >= 280%n", i);
|
||||
break;
|
||||
}
|
||||
blocks.add (disk.getDiskAddress (i));
|
||||
|
@ -54,9 +54,9 @@ class PascalCatalogSector extends AbstractSector
|
||||
addTextAndDecimal (text, buffer, ptr + 2, 2, "File's last block");
|
||||
int type = buffer[ptr + 4] & 0x0F;
|
||||
if (type < fileTypes.length)
|
||||
addText (text, buffer, ptr + 4, 2, "File type : " + fileTypes[type]);
|
||||
addText (text, buffer, ptr + 4, 1, "File type : " + fileTypes[type]);
|
||||
int wildcard = buffer[ptr + 4] & 0xC0;
|
||||
addText (text, buffer, ptr + 4, 2, "Wildcard : " + wildcard);
|
||||
addText (text, buffer, ptr + 5, 1, "Wildcard : " + wildcard);
|
||||
name = HexFormatter.getPascalString (buffer, ptr + 6);
|
||||
addText (text, buffer, ptr + 6, 4, "");
|
||||
addText (text, buffer, ptr + 10, 4, "");
|
||||
|
@ -132,12 +132,12 @@ public class PascalDisk extends AbstractFormattedDisk
|
||||
disk.setInterleave (1); // should only ever be Prodos
|
||||
if (checkFormat (disk, debug))
|
||||
return true;
|
||||
|
||||
disk.setInterleave (0);
|
||||
if (checkFormat (disk, debug))
|
||||
return true;
|
||||
disk.setInterleave (3);
|
||||
return checkFormat (disk, debug);
|
||||
return false;
|
||||
// disk.setInterleave (0);
|
||||
// if (checkFormat (disk, debug))
|
||||
// return true;
|
||||
// disk.setInterleave (3);
|
||||
// return checkFormat (disk, debug);
|
||||
}
|
||||
|
||||
public static boolean checkFormat (AppleDisk disk, boolean debug)
|
||||
|
@ -25,4 +25,36 @@ public class Utility
|
||||
return g.getFontRenderContext ().getTransform ()
|
||||
.equals (AffineTransform.getScaleInstance (2.0, 2.0));
|
||||
}
|
||||
|
||||
public static void find (byte[] buffer, byte[] key)
|
||||
{
|
||||
System.out.println ("*********** searching ************");
|
||||
// System.out.println (HexFormatter.format (buffer));
|
||||
for (int i = 0; i < buffer.length; i++)
|
||||
{
|
||||
// System.out.printf ("%02X %02X%n", buffer[i], key[0]);
|
||||
if (buffer[i] == key[0])
|
||||
{
|
||||
// System.out.println ("**** checking first ****");
|
||||
if (matches (buffer, i, key))
|
||||
System.out.printf ("Matches at %04X%n", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean matches (byte[] buffer, int offset, byte[] key)
|
||||
{
|
||||
int ptr = 0;
|
||||
while (offset < buffer.length && ptr < key.length)
|
||||
{
|
||||
if (buffer[offset++] != key[ptr++])
|
||||
{
|
||||
// System.out.printf ("%04X: %02X != %02X%n", offset, buffer[offset], key[ptr]);
|
||||
return false;
|
||||
}
|
||||
// System.out.printf ("%04X: %02X == %02X%n", offset, buffer[offset - 1],
|
||||
// key[ptr - 1]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user