minor bug fixes

This commit is contained in:
Denis Molony 2020-05-15 11:14:01 +10:00
parent 96c49fc61d
commit 7e499e208f
10 changed files with 292 additions and 216 deletions

View File

@ -5,7 +5,9 @@ import java.util.List;
import com.bytezone.diskbrowser.utilities.HexFormatter; import com.bytezone.diskbrowser.utilities.HexFormatter;
// -----------------------------------------------------------------------------------//
public class BasicProgramGS extends BasicProgram public class BasicProgramGS extends BasicProgram
// -----------------------------------------------------------------------------------//
{ {
private static String[] // private static String[] //
tokens = { "AUTO", "DEL", "EDI", "HLIST ", // 0x80 - 0x83 tokens = { "AUTO", "DEL", "EDI", "HLIST ", // 0x80 - 0x83
@ -79,10 +81,15 @@ public class BasicProgramGS extends BasicProgram
private final List<SourceLine> sourceLines = new ArrayList<> (); private final List<SourceLine> sourceLines = new ArrayList<> ();
// ---------------------------------------------------------------------------------//
public BasicProgramGS (String name, byte[] buffer) public BasicProgramGS (String name, byte[] buffer)
// ---------------------------------------------------------------------------------//
{ {
super (name, buffer); super (name, buffer);
// need to validate these files - seem to sometimes contain palette files
// 0132 816-Paint.po
int ptr = 5; int ptr = 5;
while (ptr < buffer.length) while (ptr < buffer.length)
{ {
@ -97,8 +104,10 @@ public class BasicProgramGS extends BasicProgram
} }
// ---------------------------------------------------------------------------------//
@Override @Override
public String getText () public String getText ()
// ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
for (SourceLine sourceLine : sourceLines) for (SourceLine sourceLine : sourceLines)
@ -106,7 +115,9 @@ public class BasicProgramGS extends BasicProgram
return text.toString (); return text.toString ();
} }
// ---------------------------------------------------------------------------------//
private class SourceLine private class SourceLine
// ---------------------------------------------------------------------------------//
{ {
int lineNumber; int lineNumber;
int length; int length;

View File

@ -6,17 +6,13 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
public class FinderData extends AbstractFile public class FinderData extends AbstractFile
// -----------------------------------------------------------------------------------// // -----------------------------------------------------------------------------------//
{ {
int totFiles; int version = buffer[0];
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
public FinderData (String name, byte[] buffer) public FinderData (String name, byte[] buffer)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
super (name, buffer); super (name, buffer);
int xx = buffer[40] & 0xFF;
if (xx == 0x2A)
totFiles = buffer[34] & 0xFF; // not always
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -28,16 +24,31 @@ public class FinderData extends AbstractFile
text.append ("Name : " + name + "\n\n"); text.append ("Name : " + name + "\n\n");
if (buffer.length < 50)
{
text.append (HexFormatter.format (buffer));
return text.toString ();
}
text.append (HexFormatter.format (buffer, 0, 42));
text.append ("\n\n"); text.append ("\n\n");
if (version == 1)
{
int ptr = 16;
text.append (HexFormatter.getHexString (buffer, 0, ptr));
text.append ("\n\n");
while (buffer[ptr] != 0)
{
String line = HexFormatter.getHexString (buffer, ptr, 6);
text.append (line + " ");
String name = HexFormatter.getPascalString (buffer, ptr + 6);
text.append (name + "\n");
ptr += 22;
}
}
else if (version == 2)
{
int totFiles = buffer[34];
int ptr = 42; int ptr = 42;
text.append (HexFormatter.format (buffer, 0, ptr));
text.append ("\n\n");
for (int i = 0; i < totFiles; i++) for (int i = 0; i < totFiles; i++)
{ {
String line = HexFormatter.getHexString (buffer, ptr, 8); String line = HexFormatter.getHexString (buffer, ptr, 8);
@ -45,15 +56,15 @@ public class FinderData extends AbstractFile
ptr += 8; ptr += 8;
String name = HexFormatter.getPascalString (buffer, ptr); String name = HexFormatter.getPascalString (buffer, ptr);
// text.append (name + "\n");
text.append (String.format ("%-20s ", name)); text.append (String.format ("%-20s ", name));
ptr += name.length () + 1; ptr += name.length () + 1;
text.append (String.format ("%02X%n", buffer[ptr++])); text.append (String.format ("%02X%n", buffer[ptr++]));
} }
}
// if (text.length () > 0) if (text.length () > 0)
// text.deleteCharAt (text.length () - 1); text.deleteCharAt (text.length () - 1);
return text.toString (); return text.toString ();
} }

View File

@ -44,7 +44,7 @@ public abstract class HiResImage extends AbstractFile
// $06 BIN .3200 SHRPictureFile2 // $06 BIN .3200 SHRPictureFile2
// $06 BIN .3201 SHRPictureFile2 packed // $06 BIN .3201 SHRPictureFile2 packed
// ---- ---- ------ -------------------------------------- ------------------------ // ---- ---- ------ -------------------------------------- ------------------------
// $08 FOT <$4000 Apple II Graphics File ??? // $08 FOT <$4000 Apple II Graphics File OriginalHiResImage
// $08 FOT $4000 Packed Hi-Res file ??? // $08 FOT $4000 Packed Hi-Res file ???
// $08 FOT $4001 Packed Double Hi-Res file ??? // $08 FOT $4001 Packed Double Hi-Res file ???
// $08 FOT $8066 Fadden Hi-res FaddenHiResImage // $08 FOT $8066 Fadden Hi-res FaddenHiResImage
@ -239,6 +239,7 @@ public abstract class HiResImage extends AbstractFile
monochrome = value; monochrome = value;
} }
// byte +120 is the first screen hole
/*- /*-
* Files of type $08 and any auxiliary type less than or equal to $3FFF contain a * Files of type $08 and any auxiliary type less than or equal to $3FFF contain a
* standard Apple II graphics file in one of several modes. After determining that * standard Apple II graphics file in one of several modes. After determining that

View File

@ -3,7 +3,9 @@ package com.bytezone.diskbrowser.applefile;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer; import java.awt.image.DataBuffer;
// -----------------------------------------------------------------------------------//
public class OriginalHiResImage extends HiResImage public class OriginalHiResImage extends HiResImage
// -----------------------------------------------------------------------------------//
{ {
private static final int WHITE = 0xFFFFFF; private static final int WHITE = 0xFFFFFF;
private static final int BLACK = 0x000000; private static final int BLACK = 0x000000;
@ -14,23 +16,29 @@ public class OriginalHiResImage extends HiResImage
private final int[] line = new int[280]; private final int[] line = new int[280];
private final int[] colourBits = new int[280]; private final int[] colourBits = new int[280];
// ---------------------------------------------------------------------------------//
public OriginalHiResImage (String name, byte[] buffer, int loadAddress) public OriginalHiResImage (String name, byte[] buffer, int loadAddress)
// ---------------------------------------------------------------------------------//
{ {
super (name, buffer, loadAddress); super (name, buffer, loadAddress);
createImage (); createImage ();
} }
// ---------------------------------------------------------------------------------//
public OriginalHiResImage (String name, byte[] buffer, int loadAddress, public OriginalHiResImage (String name, byte[] buffer, int loadAddress,
boolean scrunched) boolean scrunched)
// ---------------------------------------------------------------------------------//
{ {
super (name, buffer, loadAddress, scrunched); super (name, buffer, loadAddress, scrunched);
createImage (); createImage ();
} }
// ---------------------------------------------------------------------------------//
public OriginalHiResImage (String name, byte[] buffer, int fileType, int auxType, public OriginalHiResImage (String name, byte[] buffer, int fileType, int auxType,
int eof) int eof)
// ---------------------------------------------------------------------------------//
{ {
super (name, buffer, fileType, auxType, eof); super (name, buffer, fileType, auxType, eof);
@ -42,8 +50,10 @@ public class OriginalHiResImage extends HiResImage
// or... Y = aabbbccc // or... Y = aabbbccc
// address = BASE + aa * 0x28 + bb * 0x80 + ccc * 0x0400 + X // address = BASE + aa * 0x28 + bb * 0x80 + ccc * 0x0400 + X
// ---------------------------------------------------------------------------------//
@Override @Override
protected void createMonochromeImage () protected void createMonochromeImage ()
// ---------------------------------------------------------------------------------//
{ {
int rows = buffer.length <= 8192 ? 192 : 384; int rows = buffer.length <= 8192 ? 192 : 384;
image = new BufferedImage (280, rows, BufferedImage.TYPE_BYTE_GRAY); image = new BufferedImage (280, rows, BufferedImage.TYPE_BYTE_GRAY);
@ -69,8 +79,10 @@ public class OriginalHiResImage extends HiResImage
} }
} }
// ---------------------------------------------------------------------------------//
@Override @Override
protected void createColourImage () protected void createColourImage ()
// ---------------------------------------------------------------------------------//
{ {
paletteIndex = paletteFactory.getCurrentPaletteIndex (); paletteIndex = paletteFactory.getCurrentPaletteIndex ();
int rows = buffer.length <= 8192 ? 192 : 384; int rows = buffer.length <= 8192 ? 192 : 384;
@ -89,7 +101,9 @@ public class OriginalHiResImage extends HiResImage
} }
} }
// ---------------------------------------------------------------------------------//
private void fillLine (int base) private void fillLine (int base)
// ---------------------------------------------------------------------------------//
{ {
Palette palette = paletteFactory.getCurrentPalette (); Palette palette = paletteFactory.getCurrentPalette ();
int[] colours = palette.getColours (); int[] colours = palette.getColours ();
@ -130,12 +144,16 @@ public class OriginalHiResImage extends HiResImage
applyColourQuirks (); applyColourQuirks ();
} }
// ---------------------------------------------------------------------------------//
private boolean isColoured (int pixel) private boolean isColoured (int pixel)
// ---------------------------------------------------------------------------------//
{ {
return pixel != BLACK && pixel != WHITE; return pixel != BLACK && pixel != WHITE;
} }
// ---------------------------------------------------------------------------------//
private void applyColourQuirks () private void applyColourQuirks ()
// ---------------------------------------------------------------------------------//
{ {
for (int x = 3; x < line.length; x++) // skip first three pixels, refer back for (int x = 3; x < line.length; x++) // skip first three pixels, refer back
{ {

View File

@ -50,11 +50,11 @@ public class DiskFactory
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
FormattedDisk disk = create (path); FormattedDisk disk = create (path);
if (disk.getDisk ().getInterleave () > 0) // if (disk.getDisk ().getInterleave () > 0)
{ // {
System.out.println (disk); // System.out.println (disk);
System.out.println (); // System.out.println ();
} // }
return disk; return disk;
} }

View File

@ -59,8 +59,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
name = getName ("", entryBuffer); name = getName ("", entryBuffer);
reportedSize = HexFormatter.unsignedShort (entryBuffer, 33); reportedSize = HexFormatter.unsignedShort (entryBuffer, 33);
if (reportedSize == 0) // if (reportedSize == 0)
System.out.printf ("%s size 0%n", name); // System.out.printf ("%s size 0%n", name);
int type = entryBuffer[2] & 0x7F; int type = entryBuffer[2] & 0x7F;
locked = (entryBuffer[2] & 0x80) != 0; locked = (entryBuffer[2] & 0x80) != 0;

View File

@ -307,7 +307,7 @@ public class DosDisk extends AbstractFormattedDisk
} }
} }
if (best == 0) if (best <= 1)
return false; return false;
disk.setInterleave (il); disk.setInterleave (il);
@ -354,6 +354,14 @@ public class DosDisk extends AbstractFormattedDisk
// if (buffer[1] != 0x11) // first catalog track // if (buffer[1] != 0x11) // first catalog track
// return 0; // return 0;
// Apple Assembly Language.dsk claims 0x2A tracks per disk
// if (buffer[52] != 35 && buffer[52] != 50)
// {
// if (debug)
// System.out.printf ("Bad tracks per disk : %02X%n", buffer[52]);
// return 0;
// }
if (debug) if (debug)
System.out.printf ("Sectors per track: %02X%n", buffer[53]); System.out.printf ("Sectors per track: %02X%n", buffer[53]);
@ -374,8 +382,9 @@ public class DosDisk extends AbstractFormattedDisk
int version = buffer[3] & 0xFF; int version = buffer[3] & 0xFF;
if (debug) if (debug)
System.out.printf ("Version: %02X%n", buffer[3]); System.out.printf ("Version: %02X%n", buffer[3]);
if (version > 0x43 && version != 0xFF) if (version == 0 || (version > 0x43 && version != 0xFF))
{ {
if (debug)
System.out.printf ("Bad version : %02X%n", version); System.out.printf ("Bad version : %02X%n", version);
return 0; return 0;
} }

View File

@ -37,6 +37,7 @@ class DosVTOCSector extends AbstractSector
maxTracks = buffer[52] & 0xFF; maxTracks = buffer[52] & 0xFF;
maxSectors = buffer[53] & 0xFF; maxSectors = buffer[53] & 0xFF;
sectorSize = HexFormatter.intValue (buffer[54], buffer[55]); sectorSize = HexFormatter.intValue (buffer[54], buffer[55]);
flagSectors2 (); flagSectors2 ();
} }
@ -72,7 +73,16 @@ class DosVTOCSector extends AbstractSector
addTextAndDecimal (text, buffer, 48, 1, "Last allocated track"); addTextAndDecimal (text, buffer, 48, 1, "Last allocated track");
addText (text, buffer, 49, 1, "Direction to look when allocating the next file"); addText (text, buffer, 49, 1, "Direction to look when allocating the next file");
addText (text, buffer, 50, 2, "Not used"); addText (text, buffer, 50, 2, "Not used");
addTextAndDecimal (text, buffer, 52, 1, "Maximum tracks"); addTextAndDecimal (text, buffer, 52, 1, "Maximum tracks");
if (maxTracks != disk.getTotalTracks ())
{
text.deleteCharAt (text.length () - 1);
text.append (String.format (" <-- Should be 0x%02X !!%n",
disk.getTotalTracks ()));
}
addTextAndDecimal (text, buffer, 53, 1, "Maximum sectors"); addTextAndDecimal (text, buffer, 53, 1, "Maximum sectors");
addTextAndDecimal (text, buffer, 54, 2, "Bytes per sector"); addTextAndDecimal (text, buffer, 54, 2, "Bytes per sector");
@ -176,7 +186,7 @@ class DosVTOCSector extends AbstractSector
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
int firstSector = 0x38; int firstSector = 0x38;
int max = maxTracks * 4 + firstSector; int max = disk.getTotalTracks () * 4 + firstSector;
for (int i = firstSector; i < max; i += 4) for (int i = firstSector; i < max; i += 4)
{ {
int track = (i - firstSector) / 4; int track = (i - firstSector) / 4;

View File

@ -326,6 +326,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
// see gs basic disk, one of the four pictures looks ok // see gs basic disk, one of the four pictures looks ok
file = new SHRPictureFile2 (name, exactBuffer, 0xC1, 0, endOfFile); file = new SHRPictureFile2 (name, exactBuffer, 0xC1, 0, endOfFile);
} }
// else if (name.endsWith (".PIC")) // 0091 X-BASIC../../XBASIC.PIC
// file = new SHRPictureFile2 (name, exactBuffer, fileType, auxType, endOfFile);
else else
{ {
file = new AssemblerProgram (name, exactBuffer, auxType); file = new AssemblerProgram (name, exactBuffer, auxType);
@ -352,7 +354,11 @@ class FileEntry extends CatalogEntry implements ProdosConstants
break; break;
case FILE_TYPE_GS_BASIC: case FILE_TYPE_GS_BASIC:
// 0132 816-Paint.po has GSB files that crash because they are palettes
if (buffer[0] == 4 && buffer[1] == 16) // complete guess
file = new BasicProgramGS (name, exactBuffer); file = new BasicProgramGS (name, exactBuffer);
else
file = new DefaultAppleFile (name, exactBuffer);
break; break;
case FILE_TYPE_INTEGER_BASIC: case FILE_TYPE_INTEGER_BASIC:
@ -427,10 +433,28 @@ class FileEntry extends CatalogEntry implements ProdosConstants
case FILE_TYPE_FOT: case FILE_TYPE_FOT:
if (auxType == HiResImage.FADDEN_AUX) if (auxType == HiResImage.FADDEN_AUX)
file = new FaddenHiResImage (name, exactBuffer, fileType, auxType, endOfFile); file = new FaddenHiResImage (name, exactBuffer, fileType, auxType, endOfFile);
else if (auxType < 0x4000)
{
file = new OriginalHiResImage (name, exactBuffer, 0x2000);
System.out.printf ("FOT %02X%n", exactBuffer[121]);
}
else if (auxType == 0x4000)
{
// packed hi-res
System.out.println ("FOT - packed hi res");
file = new DefaultAppleFile (name, exactBuffer);
}
else if (auxType == 0x4001)
{
// packed double hi-res
System.out.println ("FOT - double hi res");
file = new DefaultAppleFile (name, exactBuffer);
}
else else
{ {
System.out.println ("Unwritten FOT: " + name);
file = new DefaultAppleFile (name, exactBuffer); file = new DefaultAppleFile (name, exactBuffer);
// file =
// new OriginalHiResImage (name, exactBuffer, fileType, auxType, endOfFile);
} }
break; break;

View File

@ -337,14 +337,14 @@ public class HexFormatter
public static int intValue (byte b1, byte b2) public static int intValue (byte b1, byte b2)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return (b1 & 0xFF) + (b2 & 0xFF) * 256; return (b1 & 0xFF) | ((b2 & 0xFF) << 8);
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
public static int intValue (byte b1, byte b2, byte b3) public static int intValue (byte b1, byte b2, byte b3)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
return (b1 & 0xFF) + (b2 & 0xFF) * 256 + (b3 & 0xFF) * 65536; return (b1 & 0xFF) | ((b2 & 0xFF) << 8) | ((b3 & 0xFF) << 16);
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -360,14 +360,6 @@ public class HexFormatter
return val; return val;
} }
// ---------------------------------------------------------------------------------//
public static int signedLong (byte[] buffer, int ptr)
// ---------------------------------------------------------------------------------//
{
return (((buffer[ptr] & 0xFF) << 24) | ((buffer[ptr] & 0xFF) << 16)
| ((buffer[ptr] & 0xFF) << 8) | (buffer[ptr + 1] & 0xFF));
}
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
public static int getLongBigEndian (byte[] buffer, int ptr) public static int getLongBigEndian (byte[] buffer, int ptr)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//