changed Maze hex output to debug screen

This commit is contained in:
Denis Molony 2022-03-10 21:06:52 +10:00
parent 2270b1f6db
commit d83ac3afda
3 changed files with 58 additions and 56 deletions

View File

@ -16,14 +16,15 @@ import com.bytezone.diskbrowser.utilities.Utility;
public abstract class HiResImage extends AbstractFile public abstract class HiResImage extends AbstractFile
// -----------------------------------------------------------------------------------// // -----------------------------------------------------------------------------------//
{ {
static final String[] auxTypes = static final String[] auxTypes = { "Paintworks Packed SHR Image", "Packed Super Hi-Res Image",
{ "Paintworks Packed SHR Image", "Packed Super Hi-Res Image", "Super Hi-Res Image (Apple Preferred Format)", "Packed QuickDraw II PICT File",
"Super Hi-Res Image (Apple Preferred Format)", "Packed QuickDraw II PICT File", "Packed Super Hi-Res 3200 color image", "DreamGraphix" };
"Packed Super Hi-Res 3200 color image", "DreamGraphix" };
static final int COLOR_TABLE_SIZE = 32; static final int COLOR_TABLE_SIZE = 32;
static final int COLOR_TABLE_OFFSET_AUX_0 = 32_256; static final int COLOR_TABLE_OFFSET_AUX_0 = 32_256;
static final int COLOR_TABLE_OFFSET_AUX_2 = 32_000; static final int COLOR_TABLE_OFFSET_AUX_2 = 32_000;
public static final int FADDEN_AUX = 0x8066; public static final int FADDEN_AUX = 0x8066;
private byte[] fourBuf = new byte[4]; private byte[] fourBuf = new byte[4];
private ColorTable defaultColorTable320 = new ColorTable (0, 0x00); private ColorTable defaultColorTable320 = new ColorTable (0, 0x00);
private ColorTable defaultColorTable640 = new ColorTable (0, 0x80); private ColorTable defaultColorTable640 = new ColorTable (0, 0x80);
@ -114,8 +115,7 @@ public abstract class HiResImage extends AbstractFile
static PaletteFactory paletteFactory = new PaletteFactory (); static PaletteFactory paletteFactory = new PaletteFactory ();
static final byte[] pngHeader = static final byte[] pngHeader = { (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
{ (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
static boolean colourQuirks; static boolean colourQuirks;
static boolean monochrome; static boolean monochrome;
@ -275,8 +275,8 @@ public abstract class HiResImage extends AbstractFile
{ {
String auxText = ""; String auxText = "";
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
text.append (String.format ("Image File : %s%nFile type : $%02X %s%n", name, text.append (String.format ("Image File : %s%nFile type : $%02X %s%n", name, fileType,
fileType, ProdosConstants.fileTypes[fileType])); ProdosConstants.fileTypes[fileType]));
switch (fileType) switch (fileType)
{ {
@ -393,8 +393,7 @@ public abstract class HiResImage extends AbstractFile
{ {
if (dataBuffer.getSize () < rgbList.length + element) if (dataBuffer.getSize () < rgbList.length + element)
{ {
System.out.printf ("Bollocks: %d %d %d%n", dataBuffer.getSize (), rgbList.length, System.out.printf ("Bollocks: %d %d %d%n", dataBuffer.getSize (), rgbList.length, element);
element);
return element; return element;
} }
@ -463,13 +462,12 @@ public abstract class HiResImage extends AbstractFile
int type = (buffer[ptr] & 0xC0) >>> 6; // 0-3 int type = (buffer[ptr] & 0xC0) >>> 6; // 0-3
int count = (buffer[ptr++] & 0x3F) + 1; // 1-64 int count = (buffer[ptr++] & 0x3F) + 1; // 1-64
text.append (String.format ("%04X/%04d: %02X (%d,%2d) ", ptr - 1, size, text.append (String.format ("%04X/%04d: %02X (%d,%2d) ", ptr - 1, size, buffer[ptr - 1],
buffer[ptr - 1], type, count)); type, count));
if (type == 0) if (type == 0)
{ {
text.append ( text.append (String.format ("%s%n", HexFormatter.getHexString (buffer, ptr, count)));
String.format ("%s%n", HexFormatter.getHexString (buffer, ptr, count)));
ptr += count; ptr += count;
size += count; size += count;
} }
@ -653,8 +651,8 @@ public abstract class HiResImage extends AbstractFile
if (buffer.length < 4) if (buffer.length < 4)
return false; return false;
return buffer[0] == (byte) 0xC1 && buffer[1] == (byte) 0xD0 return buffer[0] == (byte) 0xC1 && buffer[1] == (byte) 0xD0 && buffer[2] == (byte) 0xD0
&& buffer[2] == (byte) 0xD0 && buffer[3] == 0; && buffer[3] == 0;
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//

View File

@ -33,6 +33,7 @@ import com.bytezone.diskbrowser.disk.DiskAddress;
import com.bytezone.diskbrowser.disk.SectorList; import com.bytezone.diskbrowser.disk.SectorList;
import com.bytezone.diskbrowser.gui.FontAction.FontChangeEvent; import com.bytezone.diskbrowser.gui.FontAction.FontChangeEvent;
import com.bytezone.diskbrowser.gui.FontAction.FontChangeListener; import com.bytezone.diskbrowser.gui.FontAction.FontChangeListener;
import com.bytezone.diskbrowser.wizardry.MazeLevel;
// -----------------------------------------------------------------------------------// // -----------------------------------------------------------------------------------//
public class OutputPanel extends JTabbedPane public class OutputPanel extends JTabbedPane
@ -86,8 +87,7 @@ public class OutputPanel extends JTabbedPane
formattedText.setText ("Please use the 'File->Set HOME folder...' command to " formattedText.setText ("Please use the 'File->Set HOME folder...' command to "
+ "\ntell DiskBrowser where your Apple disks are located." + "\ntell DiskBrowser where your Apple disks are located."
+ "\n\nTo see the contents of a disk in more detail, double-click" + "\n\nTo see the contents of a disk in more detail, double-click"
+ "\nthe disk. You will then be able to select individual files to " + "\nthe disk. You will then be able to select individual files to " + "view them.");
+ "view them.");
hexText = new JTextArea (10, TEXT_WIDTH); hexText = new JTextArea (10, TEXT_WIDTH);
setPanel (hexText, "Hex dump"); setPanel (hexText, "Hex dump");
@ -95,9 +95,8 @@ public class OutputPanel extends JTabbedPane
disassemblyText = new JTextArea (10, TEXT_WIDTH); disassemblyText = new JTextArea (10, TEXT_WIDTH);
setPanel (disassemblyText, "Disassembly"); setPanel (disassemblyText, "Disassembly");
imagePane = imagePane = new JScrollPane (imagePanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
new JScrollPane (imagePanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
imagePane.setBorder (null); imagePane.setBorder (null);
@ -272,9 +271,10 @@ public class OutputPanel extends JTabbedPane
AbstractFile.setDebug (value); AbstractFile.setDebug (value);
setText (formattedText, currentDataSource.getText ()); setText (formattedText, currentDataSource.getText ());
if (currentDataSource instanceof HiResImage if (currentDataSource instanceof HiResImage //
|| currentDataSource instanceof MazeLevel // Wizardry
|| currentDataSource instanceof QuickDrawFont) || currentDataSource instanceof QuickDrawFont)
setDataSource (currentDataSource); // toggles text/image setDataSource (currentDataSource); // toggles text/image
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -493,8 +493,7 @@ public class OutputPanel extends JTabbedPane
public void setAssemblerPreferences (AssemblerPreferences assemblerPreferences) public void setAssemblerPreferences (AssemblerPreferences assemblerPreferences)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
if (currentDataSource instanceof AssemblerProgram if (currentDataSource instanceof AssemblerProgram || currentDataSource instanceof BootSector)
|| currentDataSource instanceof BootSector)
setDataSource (currentDataSource); setDataSource (currentDataSource);
} }

View File

@ -12,7 +12,7 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
import com.bytezone.diskbrowser.utilities.Utility; import com.bytezone.diskbrowser.utilities.Utility;
// -----------------------------------------------------------------------------------// // -----------------------------------------------------------------------------------//
class MazeLevel extends AbstractFile public class MazeLevel extends AbstractFile
// -----------------------------------------------------------------------------------// // -----------------------------------------------------------------------------------//
{ {
private static final String[] squareType = private static final String[] squareType =
@ -34,7 +34,7 @@ class MazeLevel extends AbstractFile
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@Override @Override
public String getHexDump () public String getText ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
@ -421,42 +421,47 @@ class MazeLevel extends AbstractFile
int itemID = -1; int itemID = -1;
if (cell.messageType == 2 && items != null) // obtain Item switch (cell.messageType)
{ {
itemID = messageAddress.level; case 2: // obtain Item
cell.itemObtained = items.get (itemID); if (items != null)
{
itemID = messageAddress.level;
cell.itemObtained = items.get (itemID);
}
break;
case 4:
itemID = messageAddress.level;
if (itemID <= 100)
{
cell.monsterID = itemID;
cell.monsters = monsters;
}
else
{
int val = (itemID - 64536) * -1;
// this gives Index error: 20410, Size 104 in Wizardry_III/legacy2.dsk
if (items != null && val < items.size ())
cell.itemObtained = items.get (val); // check this
if (cell.itemObtained == null)
System.out.printf ("Item %d (%d) not found on level %d%n", val, value, level);
}
break;
case 5: // requires Item
if (items != null)
{
itemID = messageAddress.level;
cell.itemRequired = items.get (itemID);
}
break;
} }
if (cell.messageType == 5 && items != null) // requires Item
{
itemID = messageAddress.level;
cell.itemRequired = items.get (itemID);
}
if (cell.messageType == 4)
{
itemID = messageAddress.level;
if (value <= 100)
{
cell.monsterID = value;
cell.monsters = monsters;
}
else
{
int val = (value - 64536) * -1;
System.out.println ("Value : " + val);
// this gives Index error: 20410, Size 104 in Wizardry_III/legacy2.dsk
if (items != null && val < items.size ())
cell.itemObtained = items.get (val); // check this
if (cell.itemObtained == null)
System.out.printf ("Item %d not found%n", val);
}
}
break; break;
case 12: // encounter case 12: // encounter
MazeAddress monsterAddress = getAddress (b); MazeAddress monsterAddress = getAddress (b);
// cell.monsterID = HexFormatter.intValue (buffer[832 + b * 2], buffer[833 + b * 2]);
cell.monsterID = monsterAddress.column; cell.monsterID = monsterAddress.column;
cell.monsters = monsters; cell.monsters = monsters;
break; break;