mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-29 11:49:29 +00:00
minor bug fixes
This commit is contained in:
parent
96c49fc61d
commit
7e499e208f
@ -5,12 +5,14 @@ import java.util.List;
|
||||
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class BasicProgramGS extends BasicProgram
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static String[] //
|
||||
tokens = { "AUTO", "DEL", "EDI", "HLIST ", // 0x80 - 0x83
|
||||
"LIST", "RENUM", "BREAK ", "FN ", // 0x84 - 0x87
|
||||
"PROC ", "GOSUB", " GOTO ", "FOR ", // 0x88 - 0x8B
|
||||
tokens = { "AUTO", "DEL", "EDI", "HLIST ", // 0x80 - 0x83
|
||||
"LIST", "RENUM", "BREAK ", "FN ", // 0x84 - 0x87
|
||||
"PROC ", "GOSUB", " GOTO ", "FOR ", // 0x88 - 0x8B
|
||||
" THEN ", "ELSE ", "NEXT ", "OFF ", // 0x8C - 0x8F
|
||||
"ON ", "INPUT ", "OUTPUT ", "TEXT ", // 0x90 - 0x93
|
||||
"TIMER ", "EXCEPTION ", "CAT ", " 97 ", // 0x94 - 0x97
|
||||
@ -79,10 +81,15 @@ public class BasicProgramGS extends BasicProgram
|
||||
|
||||
private final List<SourceLine> sourceLines = new ArrayList<> ();
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public BasicProgramGS (String name, byte[] buffer)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (name, buffer);
|
||||
|
||||
// need to validate these files - seem to sometimes contain palette files
|
||||
// 0132 816-Paint.po
|
||||
|
||||
int ptr = 5;
|
||||
while (ptr < buffer.length)
|
||||
{
|
||||
@ -97,8 +104,10 @@ public class BasicProgramGS extends BasicProgram
|
||||
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
public String getText ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
for (SourceLine sourceLine : sourceLines)
|
||||
@ -106,7 +115,9 @@ public class BasicProgramGS extends BasicProgram
|
||||
return text.toString ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private class SourceLine
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int lineNumber;
|
||||
int length;
|
||||
|
@ -6,17 +6,13 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
public class FinderData extends AbstractFile
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
int totFiles;
|
||||
int version = buffer[0];
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public FinderData (String name, byte[] buffer)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (name, buffer);
|
||||
|
||||
int xx = buffer[40] & 0xFF;
|
||||
if (xx == 0x2A)
|
||||
totFiles = buffer[34] & 0xFF; // not always
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@ -28,32 +24,47 @@ public class FinderData extends AbstractFile
|
||||
|
||||
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");
|
||||
|
||||
int ptr = 42;
|
||||
for (int i = 0; i < totFiles; i++)
|
||||
if (version == 1)
|
||||
{
|
||||
String line = HexFormatter.getHexString (buffer, ptr, 8);
|
||||
text.append (line + " ");
|
||||
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 + " ");
|
||||
|
||||
ptr += 8;
|
||||
String name = HexFormatter.getPascalString (buffer, ptr);
|
||||
// text.append (name + "\n");
|
||||
text.append (String.format ("%-20s ", name));
|
||||
String name = HexFormatter.getPascalString (buffer, ptr + 6);
|
||||
text.append (name + "\n");
|
||||
|
||||
ptr += name.length () + 1;
|
||||
text.append (String.format ("%02X%n", buffer[ptr++]));
|
||||
ptr += 22;
|
||||
}
|
||||
}
|
||||
else if (version == 2)
|
||||
{
|
||||
int totFiles = buffer[34];
|
||||
int ptr = 42;
|
||||
text.append (HexFormatter.format (buffer, 0, ptr));
|
||||
text.append ("\n\n");
|
||||
|
||||
for (int i = 0; i < totFiles; i++)
|
||||
{
|
||||
String line = HexFormatter.getHexString (buffer, ptr, 8);
|
||||
text.append (line + " ");
|
||||
|
||||
ptr += 8;
|
||||
String name = HexFormatter.getPascalString (buffer, ptr);
|
||||
text.append (String.format ("%-20s ", name));
|
||||
|
||||
ptr += name.length () + 1;
|
||||
text.append (String.format ("%02X%n", buffer[ptr++]));
|
||||
}
|
||||
}
|
||||
|
||||
// if (text.length () > 0)
|
||||
// text.deleteCharAt (text.length () - 1);
|
||||
if (text.length () > 0)
|
||||
text.deleteCharAt (text.length () - 1);
|
||||
|
||||
return text.toString ();
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public abstract class HiResImage extends AbstractFile
|
||||
// $06 BIN .3200 SHRPictureFile2
|
||||
// $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 $4001 Packed Double Hi-Res file ???
|
||||
// $08 FOT $8066 Fadden Hi-res FaddenHiResImage
|
||||
@ -239,6 +239,7 @@ public abstract class HiResImage extends AbstractFile
|
||||
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
|
||||
* standard Apple II graphics file in one of several modes. After determining that
|
||||
|
@ -1,166 +1,184 @@
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBuffer;
|
||||
|
||||
public class OriginalHiResImage extends HiResImage
|
||||
{
|
||||
private static final int WHITE = 0xFFFFFF;
|
||||
private static final int BLACK = 0x000000;
|
||||
private static final int[][] paletteTable = { { 9, 6 }, { 12, 3 } };
|
||||
|
||||
private static boolean matchColourBits = false;
|
||||
|
||||
private final int[] line = new int[280];
|
||||
private final int[] colourBits = new int[280];
|
||||
|
||||
public OriginalHiResImage (String name, byte[] buffer, int loadAddress)
|
||||
{
|
||||
super (name, buffer, loadAddress);
|
||||
|
||||
createImage ();
|
||||
}
|
||||
|
||||
public OriginalHiResImage (String name, byte[] buffer, int loadAddress,
|
||||
boolean scrunched)
|
||||
{
|
||||
super (name, buffer, loadAddress, scrunched);
|
||||
|
||||
createImage ();
|
||||
}
|
||||
|
||||
public OriginalHiResImage (String name, byte[] buffer, int fileType, int auxType,
|
||||
int eof)
|
||||
{
|
||||
super (name, buffer, fileType, auxType, eof);
|
||||
|
||||
// will call createImage () itself
|
||||
}
|
||||
|
||||
// https://github.com/Michaelangel007/apple2_hgr_font_tutorial
|
||||
// hgr[ y ] = 0x2000 + (y/64)*0x28 + (y%8)*0x400 + ((y/8)&7)*0x80;
|
||||
// or... Y = aabbbccc
|
||||
// address = BASE + aa * 0x28 + bb * 0x80 + ccc * 0x0400 + X
|
||||
|
||||
@Override
|
||||
protected void createMonochromeImage ()
|
||||
{
|
||||
int rows = buffer.length <= 8192 ? 192 : 384;
|
||||
image = new BufferedImage (280, rows, BufferedImage.TYPE_BYTE_GRAY);
|
||||
DataBuffer dataBuffer = image.getRaster ().getDataBuffer ();
|
||||
int element = 0;
|
||||
|
||||
for (int page = 0; page < rows / 192; page++)
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 8; j++)
|
||||
for (int k = 0; k < 8; k++)
|
||||
{
|
||||
int base = page * 0x2000 + i * 0x28 + j * 0x80 + k * 0x400;
|
||||
int max = Math.min (base + 40, buffer.length);
|
||||
for (int ptr = base; ptr < max; ptr++)
|
||||
{
|
||||
int value = buffer[ptr] & 0x7F;
|
||||
for (int px = 0; px < 7; px++)
|
||||
{
|
||||
int val = (value >> px) & 0x01;
|
||||
dataBuffer.setElem (element++, val == 0 ? 0 : 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createColourImage ()
|
||||
{
|
||||
paletteIndex = paletteFactory.getCurrentPaletteIndex ();
|
||||
int rows = buffer.length <= 8192 ? 192 : 384;
|
||||
image = new BufferedImage (280, rows, BufferedImage.TYPE_INT_RGB);
|
||||
DataBuffer dataBuffer = image.getRaster ().getDataBuffer ();
|
||||
int element = 0;
|
||||
|
||||
for (int page = 0; page < rows / 192; page++)
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 8; j++)
|
||||
for (int k = 0; k < 8; k++)
|
||||
{
|
||||
fillLine (page * 0x2000 + i * 0x28 + j * 0x80 + k * 0x400);
|
||||
for (int pixel : line)
|
||||
dataBuffer.setElem (element++, pixel);
|
||||
}
|
||||
}
|
||||
|
||||
private void fillLine (int base)
|
||||
{
|
||||
Palette palette = paletteFactory.getCurrentPalette ();
|
||||
int[] colours = palette.getColours ();
|
||||
|
||||
int max = Math.min (base + 40, buffer.length);
|
||||
int linePtr = 0;
|
||||
assert colourBits != null;
|
||||
|
||||
for (int ptr = base; ptr < max; ptr++)
|
||||
{
|
||||
int colourBit = (buffer[ptr] & 0x80) >> 7;
|
||||
int value = buffer[ptr] & 0x7F;
|
||||
|
||||
for (int px = 0; px < 7; px++)
|
||||
{
|
||||
colourBits[linePtr] = colourBit; // store the colour bit
|
||||
int val = (value >> px) & 0x01; // get the next pixel to draw
|
||||
int column = (ptr + px) % 2; // is it in an odd or even column?
|
||||
line[linePtr++] = val == 0 ? 0 : // black pixel
|
||||
colours[paletteTable[colourBit][column]]; // coloured pixel - use lookup table
|
||||
}
|
||||
}
|
||||
|
||||
// convert consecutive ON pixels to white
|
||||
for (int x = 1; x < line.length; x++) // skip first pixel, refer back
|
||||
{
|
||||
if (matchColourBits && colourBits[x - 1] != colourBits[x])
|
||||
continue; // only modify values with matching colour bits
|
||||
|
||||
int px0 = line[x - 1];
|
||||
int px1 = line[x];
|
||||
if (px0 != BLACK && px1 != BLACK)
|
||||
line[x - 1] = line[x] = WHITE;
|
||||
}
|
||||
|
||||
// optionally do physics
|
||||
if (colourQuirks)
|
||||
applyColourQuirks ();
|
||||
}
|
||||
|
||||
private boolean isColoured (int pixel)
|
||||
{
|
||||
return pixel != BLACK && pixel != WHITE;
|
||||
}
|
||||
|
||||
private void applyColourQuirks ()
|
||||
{
|
||||
for (int x = 3; x < line.length; x++) // skip first three pixels, refer back
|
||||
{
|
||||
if (matchColourBits && colourBits[x - 2] != colourBits[x - 1])
|
||||
continue; // only modify values with matching colour bits
|
||||
|
||||
int px0 = line[x - 3];
|
||||
int px1 = line[x - 2];
|
||||
int px2 = line[x - 1];
|
||||
int px3 = line[x];
|
||||
|
||||
if (px1 == BLACK)
|
||||
{
|
||||
if (px3 == BLACK && px0 == px2 && isColoured (px0)) // V-B-V-B
|
||||
line[x - 2] = px0; // --> V-V-V-B
|
||||
else if (px3 == WHITE && px2 == WHITE && isColoured (px0)) // V-B-W-W
|
||||
line[x - 2] = px0; // --> V-V-W-W
|
||||
}
|
||||
else if (px2 == BLACK)
|
||||
{
|
||||
if (px0 == BLACK && px1 == px3 && isColoured (px3)) // B-G-B-G
|
||||
line[x - 1] = px3; // --> B-G-G-G
|
||||
else if (px0 == WHITE && px1 == WHITE && isColoured (px3)) // W-W-B-G
|
||||
line[x - 1] = px3; // --> W-W-G-G
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.bytezone.diskbrowser.applefile;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBuffer;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class OriginalHiResImage extends HiResImage
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private static final int WHITE = 0xFFFFFF;
|
||||
private static final int BLACK = 0x000000;
|
||||
private static final int[][] paletteTable = { { 9, 6 }, { 12, 3 } };
|
||||
|
||||
private static boolean matchColourBits = false;
|
||||
|
||||
private final int[] line = new int[280];
|
||||
private final int[] colourBits = new int[280];
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public OriginalHiResImage (String name, byte[] buffer, int loadAddress)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (name, buffer, loadAddress);
|
||||
|
||||
createImage ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public OriginalHiResImage (String name, byte[] buffer, int loadAddress,
|
||||
boolean scrunched)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (name, buffer, loadAddress, scrunched);
|
||||
|
||||
createImage ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public OriginalHiResImage (String name, byte[] buffer, int fileType, int auxType,
|
||||
int eof)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
super (name, buffer, fileType, auxType, eof);
|
||||
|
||||
// will call createImage () itself
|
||||
}
|
||||
|
||||
// https://github.com/Michaelangel007/apple2_hgr_font_tutorial
|
||||
// hgr[ y ] = 0x2000 + (y/64)*0x28 + (y%8)*0x400 + ((y/8)&7)*0x80;
|
||||
// or... Y = aabbbccc
|
||||
// address = BASE + aa * 0x28 + bb * 0x80 + ccc * 0x0400 + X
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
protected void createMonochromeImage ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int rows = buffer.length <= 8192 ? 192 : 384;
|
||||
image = new BufferedImage (280, rows, BufferedImage.TYPE_BYTE_GRAY);
|
||||
DataBuffer dataBuffer = image.getRaster ().getDataBuffer ();
|
||||
int element = 0;
|
||||
|
||||
for (int page = 0; page < rows / 192; page++)
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 8; j++)
|
||||
for (int k = 0; k < 8; k++)
|
||||
{
|
||||
int base = page * 0x2000 + i * 0x28 + j * 0x80 + k * 0x400;
|
||||
int max = Math.min (base + 40, buffer.length);
|
||||
for (int ptr = base; ptr < max; ptr++)
|
||||
{
|
||||
int value = buffer[ptr] & 0x7F;
|
||||
for (int px = 0; px < 7; px++)
|
||||
{
|
||||
int val = (value >> px) & 0x01;
|
||||
dataBuffer.setElem (element++, val == 0 ? 0 : 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
@Override
|
||||
protected void createColourImage ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
paletteIndex = paletteFactory.getCurrentPaletteIndex ();
|
||||
int rows = buffer.length <= 8192 ? 192 : 384;
|
||||
image = new BufferedImage (280, rows, BufferedImage.TYPE_INT_RGB);
|
||||
DataBuffer dataBuffer = image.getRaster ().getDataBuffer ();
|
||||
int element = 0;
|
||||
|
||||
for (int page = 0; page < rows / 192; page++)
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 8; j++)
|
||||
for (int k = 0; k < 8; k++)
|
||||
{
|
||||
fillLine (page * 0x2000 + i * 0x28 + j * 0x80 + k * 0x400);
|
||||
for (int pixel : line)
|
||||
dataBuffer.setElem (element++, pixel);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void fillLine (int base)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
Palette palette = paletteFactory.getCurrentPalette ();
|
||||
int[] colours = palette.getColours ();
|
||||
|
||||
int max = Math.min (base + 40, buffer.length);
|
||||
int linePtr = 0;
|
||||
assert colourBits != null;
|
||||
|
||||
for (int ptr = base; ptr < max; ptr++)
|
||||
{
|
||||
int colourBit = (buffer[ptr] & 0x80) >> 7;
|
||||
int value = buffer[ptr] & 0x7F;
|
||||
|
||||
for (int px = 0; px < 7; px++)
|
||||
{
|
||||
colourBits[linePtr] = colourBit; // store the colour bit
|
||||
int val = (value >> px) & 0x01; // get the next pixel to draw
|
||||
int column = (ptr + px) % 2; // is it in an odd or even column?
|
||||
line[linePtr++] = val == 0 ? 0 : // black pixel
|
||||
colours[paletteTable[colourBit][column]]; // coloured pixel - use lookup table
|
||||
}
|
||||
}
|
||||
|
||||
// convert consecutive ON pixels to white
|
||||
for (int x = 1; x < line.length; x++) // skip first pixel, refer back
|
||||
{
|
||||
if (matchColourBits && colourBits[x - 1] != colourBits[x])
|
||||
continue; // only modify values with matching colour bits
|
||||
|
||||
int px0 = line[x - 1];
|
||||
int px1 = line[x];
|
||||
if (px0 != BLACK && px1 != BLACK)
|
||||
line[x - 1] = line[x] = WHITE;
|
||||
}
|
||||
|
||||
// optionally do physics
|
||||
if (colourQuirks)
|
||||
applyColourQuirks ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private boolean isColoured (int pixel)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
return pixel != BLACK && pixel != WHITE;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
private void applyColourQuirks ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
for (int x = 3; x < line.length; x++) // skip first three pixels, refer back
|
||||
{
|
||||
if (matchColourBits && colourBits[x - 2] != colourBits[x - 1])
|
||||
continue; // only modify values with matching colour bits
|
||||
|
||||
int px0 = line[x - 3];
|
||||
int px1 = line[x - 2];
|
||||
int px2 = line[x - 1];
|
||||
int px3 = line[x];
|
||||
|
||||
if (px1 == BLACK)
|
||||
{
|
||||
if (px3 == BLACK && px0 == px2 && isColoured (px0)) // V-B-V-B
|
||||
line[x - 2] = px0; // --> V-V-V-B
|
||||
else if (px3 == WHITE && px2 == WHITE && isColoured (px0)) // V-B-W-W
|
||||
line[x - 2] = px0; // --> V-V-W-W
|
||||
}
|
||||
else if (px2 == BLACK)
|
||||
{
|
||||
if (px0 == BLACK && px1 == px3 && isColoured (px3)) // B-G-B-G
|
||||
line[x - 1] = px3; // --> B-G-G-G
|
||||
else if (px0 == WHITE && px1 == WHITE && isColoured (px3)) // W-W-B-G
|
||||
line[x - 1] = px3; // --> W-W-G-G
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -50,11 +50,11 @@ public class DiskFactory
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
FormattedDisk disk = create (path);
|
||||
if (disk.getDisk ().getInterleave () > 0)
|
||||
{
|
||||
System.out.println (disk);
|
||||
System.out.println ();
|
||||
}
|
||||
// if (disk.getDisk ().getInterleave () > 0)
|
||||
// {
|
||||
// System.out.println (disk);
|
||||
// System.out.println ();
|
||||
// }
|
||||
return disk;
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,8 @@ abstract class AbstractCatalogEntry implements AppleFileSource
|
||||
|
||||
name = getName ("", entryBuffer);
|
||||
reportedSize = HexFormatter.unsignedShort (entryBuffer, 33);
|
||||
if (reportedSize == 0)
|
||||
System.out.printf ("%s size 0%n", name);
|
||||
// if (reportedSize == 0)
|
||||
// System.out.printf ("%s size 0%n", name);
|
||||
|
||||
int type = entryBuffer[2] & 0x7F;
|
||||
locked = (entryBuffer[2] & 0x80) != 0;
|
||||
|
@ -307,7 +307,7 @@ public class DosDisk extends AbstractFormattedDisk
|
||||
}
|
||||
}
|
||||
|
||||
if (best == 0)
|
||||
if (best <= 1)
|
||||
return false;
|
||||
|
||||
disk.setInterleave (il);
|
||||
@ -354,6 +354,14 @@ public class DosDisk extends AbstractFormattedDisk
|
||||
// if (buffer[1] != 0x11) // first catalog track
|
||||
// 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)
|
||||
System.out.printf ("Sectors per track: %02X%n", buffer[53]);
|
||||
|
||||
@ -374,9 +382,10 @@ public class DosDisk extends AbstractFormattedDisk
|
||||
int version = buffer[3] & 0xFF;
|
||||
if (debug)
|
||||
System.out.printf ("Version: %02X%n", buffer[3]);
|
||||
if (version > 0x43 && version != 0xFF)
|
||||
if (version == 0 || (version > 0x43 && version != 0xFF))
|
||||
{
|
||||
System.out.printf ("Bad version : %02X%n", version);
|
||||
if (debug)
|
||||
System.out.printf ("Bad version : %02X%n", version);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ class DosVTOCSector extends AbstractSector
|
||||
maxTracks = buffer[52] & 0xFF;
|
||||
maxSectors = buffer[53] & 0xFF;
|
||||
sectorSize = HexFormatter.intValue (buffer[54], buffer[55]);
|
||||
|
||||
flagSectors2 ();
|
||||
}
|
||||
|
||||
@ -72,7 +73,16 @@ class DosVTOCSector extends AbstractSector
|
||||
addTextAndDecimal (text, buffer, 48, 1, "Last allocated track");
|
||||
addText (text, buffer, 49, 1, "Direction to look when allocating the next file");
|
||||
addText (text, buffer, 50, 2, "Not used");
|
||||
|
||||
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, 54, 2, "Bytes per sector");
|
||||
|
||||
@ -176,7 +186,7 @@ class DosVTOCSector extends AbstractSector
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int firstSector = 0x38;
|
||||
int max = maxTracks * 4 + firstSector;
|
||||
int max = disk.getTotalTracks () * 4 + firstSector;
|
||||
for (int i = firstSector; i < max; i += 4)
|
||||
{
|
||||
int track = (i - firstSector) / 4;
|
||||
|
@ -326,6 +326,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
// see gs basic disk, one of the four pictures looks ok
|
||||
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
|
||||
{
|
||||
file = new AssemblerProgram (name, exactBuffer, auxType);
|
||||
@ -352,7 +354,11 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
break;
|
||||
|
||||
case FILE_TYPE_GS_BASIC:
|
||||
file = new BasicProgramGS (name, exactBuffer);
|
||||
// 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);
|
||||
else
|
||||
file = new DefaultAppleFile (name, exactBuffer);
|
||||
break;
|
||||
|
||||
case FILE_TYPE_INTEGER_BASIC:
|
||||
@ -427,10 +433,28 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
case FILE_TYPE_FOT:
|
||||
if (auxType == HiResImage.FADDEN_AUX)
|
||||
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
|
||||
{
|
||||
System.out.println ("Unwritten FOT: " + name);
|
||||
file = new DefaultAppleFile (name, exactBuffer);
|
||||
// file =
|
||||
// new OriginalHiResImage (name, exactBuffer, fileType, auxType, endOfFile);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -337,14 +337,14 @@ public class HexFormatter
|
||||
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)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
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)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
Loading…
Reference in New Issue
Block a user