mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-02-20 04:29:02 +00:00
tidying
This commit is contained in:
parent
c64c7aea64
commit
696393799a
@ -23,7 +23,6 @@ public class AssemblerProgram extends AbstractFile
|
|||||||
|
|
||||||
private byte[] extraBuffer = new byte[0];
|
private byte[] extraBuffer = new byte[0];
|
||||||
|
|
||||||
// private TreeMap<Integer, String> strings;
|
|
||||||
private List<Integer> entryPoints;
|
private List<Integer> entryPoints;
|
||||||
private List<StringLocation> stringLocations;
|
private List<StringLocation> stringLocations;
|
||||||
|
|
||||||
@ -249,13 +248,10 @@ public class AssemblerProgram extends AbstractFile
|
|||||||
StringBuilder text = new StringBuilder ("\n\nPossible strings:\n\n");
|
StringBuilder text = new StringBuilder ("\n\nPossible strings:\n\n");
|
||||||
for (StringLocation stringLocation : stringLocations)
|
for (StringLocation stringLocation : stringLocations)
|
||||||
{
|
{
|
||||||
if (stringLocation.zeroTerminated)
|
int address = stringLocation.offset + loadAddress;
|
||||||
text.append (String.format ("%s %04X - %04X %s %s %n",
|
text.append (String.format ("%s %04X - %04X %s %n",
|
||||||
entryPoints.contains (stringLocation.offset + loadAddress) ? "*" : " ",
|
entryPoints.contains (stringLocation.offset + loadAddress) ? "*" : " ", address,
|
||||||
stringLocation.offset, stringLocation.offset + stringLocation.length,
|
address + stringLocation.length, stringLocation));
|
||||||
stringLocation.toStatisticsString (), stringLocation));
|
|
||||||
else
|
|
||||||
System.out.println (stringLocation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text.length () > 0)
|
if (text.length () > 0)
|
||||||
@ -270,15 +266,16 @@ public class AssemblerProgram extends AbstractFile
|
|||||||
stringLocations = new ArrayList<> ();
|
stringLocations = new ArrayList<> ();
|
||||||
|
|
||||||
int start = 0;
|
int start = 0;
|
||||||
|
int max = buffer.length - 2;
|
||||||
for (int ptr = 0; ptr < buffer.length; ptr++)
|
for (int ptr = 0; ptr < buffer.length; ptr++)
|
||||||
{
|
{
|
||||||
if ((buffer[ptr] == (byte) 0xBD // LDA Absolute,X
|
if ((buffer[ptr] == (byte) 0xBD // LDA Absolute,X
|
||||||
|| buffer[ptr] == (byte) 0xB9 // LDA Absolute,Y
|
|| buffer[ptr] == (byte) 0xB9 // LDA Absolute,Y
|
||||||
|| buffer[ptr] == (byte) 0xAD) // LDA Absolute
|
|| buffer[ptr] == (byte) 0xAD) // LDA Absolute
|
||||||
&& (ptr + 2 < buffer.length))
|
&& (ptr < max))
|
||||||
{
|
{
|
||||||
int address = Utility.getWord (buffer, ptr + 1);
|
int address = Utility.getWord (buffer, ptr + 1);
|
||||||
if (address > loadAddress && address < loadAddress + buffer.length)
|
if (address >= loadAddress && address < loadAddress + buffer.length)
|
||||||
entryPoints.add (address);
|
entryPoints.add (address);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,6 +352,7 @@ public class AssemblerProgram extends AbstractFile
|
|||||||
int offset;
|
int offset;
|
||||||
int length;
|
int length;
|
||||||
boolean zeroTerminated;
|
boolean zeroTerminated;
|
||||||
|
boolean lowTerminated;
|
||||||
boolean hasLengthByte;
|
boolean hasLengthByte;
|
||||||
int digits;
|
int digits;
|
||||||
int letters;
|
int letters;
|
||||||
@ -367,7 +365,10 @@ public class AssemblerProgram extends AbstractFile
|
|||||||
offset = first;
|
offset = first;
|
||||||
length = last - offset + 1;
|
length = last - offset + 1;
|
||||||
|
|
||||||
zeroTerminated = ++last < buffer.length && buffer[last] == 0;
|
int end = last + 1;
|
||||||
|
|
||||||
|
zeroTerminated = end < buffer.length && buffer[end] == 0;
|
||||||
|
lowTerminated = end < buffer.length && buffer[end] >= 32 && buffer[end] < 127;
|
||||||
hasLengthByte = first > 0 && (buffer[first] & 0xFF) == length;
|
hasLengthByte = first > 0 && (buffer[first] & 0xFF) == length;
|
||||||
|
|
||||||
for (int i = offset; i < offset + length; i++)
|
for (int i = offset; i < offset + length; i++)
|
||||||
@ -419,6 +420,8 @@ public class AssemblerProgram extends AbstractFile
|
|||||||
else
|
else
|
||||||
text.append ((char) val);
|
text.append ((char) val);
|
||||||
}
|
}
|
||||||
|
if (lowTerminated)
|
||||||
|
text.append ((char) buffer[offset + length]);
|
||||||
|
|
||||||
return text.toString ();
|
return text.toString ();
|
||||||
}
|
}
|
||||||
|
@ -13,25 +13,6 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
|||||||
|
|
||||||
public class IconFile extends AbstractFile implements ProdosConstants
|
public class IconFile extends AbstractFile implements ProdosConstants
|
||||||
{
|
{
|
||||||
private static Palette palette = //
|
|
||||||
new Palette ("Virtual II", new int[] { 0x000000, // 0 black
|
|
||||||
0xDD0033, // 1 magenta
|
|
||||||
0x885500, // 2 brown (8)
|
|
||||||
0xFF6600, // 3 orange (9)
|
|
||||||
0x007722, // 4 dark green
|
|
||||||
0x555555, // 5 grey1
|
|
||||||
0x11DD00, // 6 light green (C)
|
|
||||||
0xFFFF00, // 7 yellow (D)
|
|
||||||
0x000099, // 8 dark blue (2)
|
|
||||||
0xDD22DD, // 9 purple (3)
|
|
||||||
0xAAAAAA, // A grey2
|
|
||||||
0xFF9988, // B pink
|
|
||||||
0x2222FF, // C med blue (6)
|
|
||||||
0x66AAFF, // D light blue (7)
|
|
||||||
0x44FF99, // E aqua
|
|
||||||
0xFFFFFF // F white
|
|
||||||
});
|
|
||||||
|
|
||||||
private final int iBlkNext;
|
private final int iBlkNext;
|
||||||
private final int iBlkID;
|
private final int iBlkID;
|
||||||
private final int iBlkPath;
|
private final int iBlkPath;
|
||||||
@ -53,10 +34,11 @@ public class IconFile extends AbstractFile implements ProdosConstants
|
|||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
int dataLen = HexFormatter.unsignedShort (buffer, ptr);
|
int dataLen = HexFormatter.unsignedShort (buffer, ptr);
|
||||||
|
|
||||||
if (dataLen == 0 || (dataLen + ptr) > buffer.length)
|
if (dataLen == 0 || (dataLen + ptr) > buffer.length)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
Icon icon = new Icon (buffer, ptr);
|
Icon icon = new Icon (buffer, ptr);
|
||||||
|
if (icon.smallImage != null) // didn't have an exception
|
||||||
icons.add (icon);
|
icons.add (icon);
|
||||||
ptr += dataLen;
|
ptr += dataLen;
|
||||||
}
|
}
|
||||||
@ -77,8 +59,10 @@ public class IconFile extends AbstractFile implements ProdosConstants
|
|||||||
int columns = Math.min (icons.size (), 4);
|
int columns = Math.min (icons.size (), 4);
|
||||||
int rows = (icons.size () - 1) / columns + 1;
|
int rows = (icons.size () - 1) / columns + 1;
|
||||||
|
|
||||||
image = new BufferedImage (columns * maxWidth + 2 * base + (columns - 1) * gap,
|
image = new BufferedImage ( //
|
||||||
rows * maxHeight + 2 * base + (rows - 1) * gap, BufferedImage.TYPE_INT_RGB);
|
columns * maxWidth + 2 * base + (columns - 1) * gap, //
|
||||||
|
rows * maxHeight + 2 * base + (rows - 1) * gap, //
|
||||||
|
BufferedImage.TYPE_INT_RGB);
|
||||||
|
|
||||||
Graphics2D graphics = image.createGraphics ();
|
Graphics2D graphics = image.createGraphics ();
|
||||||
graphics.setBackground (Color.WHITE);
|
graphics.setBackground (Color.WHITE);
|
||||||
@ -100,6 +84,7 @@ public class IconFile extends AbstractFile implements ProdosConstants
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
g2d.dispose ();
|
g2d.dispose ();
|
||||||
|
graphics.dispose ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -212,7 +197,7 @@ public class IconFile extends AbstractFile implements ProdosConstants
|
|||||||
System.out.println ();
|
System.out.println ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iconType != 0 && iconType != 0x8000)
|
if (iconType != 0 && iconType != 0x8000 && iconType != 0xFFFF && iconType != 0x00FF)
|
||||||
throw new InvalidImageException (String.format ("Bad icon type: %04X", iconType));
|
throw new InvalidImageException (String.format ("Bad icon type: %04X", iconType));
|
||||||
|
|
||||||
iconImage = new byte[iconSize];
|
iconImage = new byte[iconSize];
|
||||||
@ -223,7 +208,7 @@ public class IconFile extends AbstractFile implements ProdosConstants
|
|||||||
System.arraycopy (buffer, ptr + 8, iconImage, 0, iconSize);
|
System.arraycopy (buffer, ptr + 8, iconImage, 0, iconSize);
|
||||||
System.arraycopy (buffer, ptr + 8 + iconSize, iconMask, 0, iconSize);
|
System.arraycopy (buffer, ptr + 8 + iconSize, iconMask, 0, iconSize);
|
||||||
|
|
||||||
int[] colours = palette.getColours ();
|
int[] colours = HiResImage.getPaletteFactory ().get (0).getColours ();
|
||||||
|
|
||||||
image = new BufferedImage (iconWidth, iconHeight, BufferedImage.TYPE_INT_RGB);
|
image = new BufferedImage (iconWidth, iconHeight, BufferedImage.TYPE_INT_RGB);
|
||||||
|
|
||||||
|
@ -155,7 +155,8 @@ public class AppleDisk implements Disk
|
|||||||
}
|
}
|
||||||
else if (suffix.equalsIgnoreCase ("HDV"))
|
else if (suffix.equalsIgnoreCase ("HDV"))
|
||||||
{
|
{
|
||||||
this.blocks = (int) file.length () / 4096 * 8; // reduce blocks to a multiple of 8
|
// this.blocks = (int) file.length () / 4096 * 8; // reduce blocks to a multiple of 8
|
||||||
|
this.blocks = tracks * sectors;
|
||||||
this.sectorSize = 512;
|
this.sectorSize = 512;
|
||||||
this.trackSize = sectors * sectorSize;
|
this.trackSize = sectors * sectorSize;
|
||||||
}
|
}
|
||||||
@ -193,7 +194,6 @@ public class AppleDisk implements Disk
|
|||||||
|
|
||||||
diskBuffer = new byte[blocks * sectorSize];
|
diskBuffer = new byte[blocks * sectorSize];
|
||||||
hasData = new boolean[blocks];
|
hasData = new boolean[blocks];
|
||||||
// isMissing = new boolean[blocks];
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -415,6 +415,9 @@ public class AppleDisk implements Disk
|
|||||||
public byte[] readSector (DiskAddress da)
|
public byte[] readSector (DiskAddress da)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[sectorSize];
|
byte[] buffer = new byte[sectorSize];
|
||||||
|
if (da == null)
|
||||||
|
System.out.println ("Disk address is null");
|
||||||
|
else
|
||||||
readBuffer (da, buffer, 0);
|
readBuffer (da, buffer, 0);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,16 @@ public class AppleDiskAddress implements DiskAddress
|
|||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.block = block;
|
this.block = block;
|
||||||
int sectorsPerTrack = owner.getSectorsPerTrack ();
|
int sectorsPerTrack = owner.getSectorsPerTrack ();
|
||||||
this.track = block / sectorsPerTrack;
|
if (sectorsPerTrack == 0)
|
||||||
this.sector = block % sectorsPerTrack;
|
{
|
||||||
|
track = 0;
|
||||||
|
sector = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
track = block / sectorsPerTrack;
|
||||||
|
sector = block % sectorsPerTrack;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AppleDiskAddress (Disk owner, int track, int sector)
|
public AppleDiskAddress (Disk owner, int track, int sector)
|
||||||
|
@ -236,10 +236,8 @@ public class DiskFactory
|
|||||||
System.out.println ("Checking woz");
|
System.out.println ("Checking woz");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// WozFileOld wozDisk = new WozFileOld (file);
|
|
||||||
WozFile wozFile = new WozFile (file);
|
WozFile wozFile = new WozFile (file);
|
||||||
if (debug)
|
|
||||||
System.out.println (" Woz read");
|
|
||||||
if (wozFile.getSectorsPerTrack () == 13)
|
if (wozFile.getSectorsPerTrack () == 13)
|
||||||
{
|
{
|
||||||
AppleDisk appleDisk = new AppleDisk (wozFile, 35, 13);
|
AppleDisk appleDisk = new AppleDisk (wozFile, 35, 13);
|
||||||
@ -526,8 +524,14 @@ public class DiskFactory
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// truncate the file if necessary
|
// extend the file if necessary
|
||||||
AppleDisk disk = new AppleDisk (file, (int) file.length () / 4096, 8);
|
int tracks = (int) (file.length () - 1) / 4096 + 1;
|
||||||
|
if (tracks * 4096 != file.length ())
|
||||||
|
{
|
||||||
|
System.out.println ("*** extended ***"); // System Addons.hdv
|
||||||
|
// System.out.println (tracks);
|
||||||
|
}
|
||||||
|
AppleDisk disk = new AppleDisk (file, tracks, 8);
|
||||||
if (ProdosDisk.isCorrectFormat (disk))
|
if (ProdosDisk.isCorrectFormat (disk))
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
|
@ -235,6 +235,7 @@ public class DosDisk extends AbstractFormattedDisk
|
|||||||
{
|
{
|
||||||
disk.setInterleave (0);
|
disk.setInterleave (0);
|
||||||
int catalogBlocks = checkFormat (disk);
|
int catalogBlocks = checkFormat (disk);
|
||||||
|
|
||||||
if (catalogBlocks > 3)
|
if (catalogBlocks > 3)
|
||||||
return true;
|
return true;
|
||||||
disk.setInterleave (1);
|
disk.setInterleave (1);
|
||||||
@ -243,19 +244,22 @@ public class DosDisk extends AbstractFormattedDisk
|
|||||||
if (cb2 > 3)
|
if (cb2 > 3)
|
||||||
return true;
|
return true;
|
||||||
disk.setInterleave (2);
|
disk.setInterleave (2);
|
||||||
if (false)
|
if (true)
|
||||||
{
|
{
|
||||||
int cb3 = checkFormat (disk);
|
int cb3 = checkFormat (disk);
|
||||||
if (cb3 > 3)
|
if (cb3 > 3)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (catalogBlocks > 0)
|
if (catalogBlocks > 0)
|
||||||
{
|
{
|
||||||
disk.setInterleave (1);
|
disk.setInterleave (1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cb2 > 0)
|
if (cb2 > 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +297,7 @@ public class DosDisk extends AbstractFormattedDisk
|
|||||||
// if (buffer[1] != 0x11) // first catalog track
|
// if (buffer[1] != 0x11) // first catalog track
|
||||||
// return 0;
|
// return 0;
|
||||||
|
|
||||||
if (buffer[53] != 16 && buffer[53] != 13) // tracks per sector
|
if (buffer[53] != 16 && buffer[53] != 13) // sectors per track
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -325,7 +329,7 @@ public class DosDisk extends AbstractFormattedDisk
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (!disk.isValidAddress (da))
|
if (!disk.isValidAddress (da))
|
||||||
break;
|
return 0;
|
||||||
|
|
||||||
if (catalogAddresses.contains (da))
|
if (catalogAddresses.contains (da))
|
||||||
{
|
{
|
||||||
@ -336,8 +340,8 @@ public class DosDisk extends AbstractFormattedDisk
|
|||||||
buffer = disk.readSector (da);
|
buffer = disk.readSector (da);
|
||||||
if (!disk.isValidAddress (buffer[1], buffer[2]))
|
if (!disk.isValidAddress (buffer[1], buffer[2]))
|
||||||
{
|
{
|
||||||
System.out.printf ("Invalid address : %02X / %02X%n", buffer[1], buffer[2]);
|
// System.out.printf ("Invalid address : %02X / %02X%n", buffer[1], buffer[2]);
|
||||||
break;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
catalogAddresses.add (da);
|
catalogAddresses.add (da);
|
||||||
|
@ -54,6 +54,11 @@ class ObjectManager extends InfocomAbstractFile implements Iterable<ZObject>
|
|||||||
|
|
||||||
ZObject getObject (int index)
|
ZObject getObject (int index)
|
||||||
{
|
{
|
||||||
|
if (index < 0 || index >= list.size ())
|
||||||
|
{
|
||||||
|
System.out.printf ("Invalid index: %d / %d%n", index, list.size ());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return list.get (index);
|
return list.get (index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,10 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
|||||||
int block = keyPtr;
|
int block = keyPtr;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
dataBlocks.add (disk.getDiskAddress (block));
|
DiskAddress diskAddress = disk.getDiskAddress (block);
|
||||||
|
if (diskAddress == null)
|
||||||
|
break;
|
||||||
|
dataBlocks.add (diskAddress);
|
||||||
byte[] buffer = disk.readSector (block);
|
byte[] buffer = disk.readSector (block);
|
||||||
block = HexFormatter.unsignedShort (buffer, 2);
|
block = HexFormatter.unsignedShort (buffer, 2);
|
||||||
} while (block > 0);
|
} while (block > 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user