graphic images

This commit is contained in:
Denis Molony 2018-07-25 15:48:14 +10:00
parent 4b2b7d72a8
commit 2a79664404
13 changed files with 253 additions and 159 deletions

View File

@ -12,6 +12,40 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
public abstract class HiResImage extends AbstractFile public abstract class HiResImage extends AbstractFile
{ {
// File Type Aux Name
// $06 BIN isGif() - OriginalHiResImage
// $06 BIN isPng() - OriginalHiResImage
// $06 BIN .BMP isBmp() - OriginalHiResImage
// $06 BIN .AUX - DoubleHiResImage
// $06 BIN .PAC - DoubleHiResImage
// $06 BIN .A2FC - DoubleHiResImage
// $06 BIN $2000 eof $4000 - DoubleHiResImage
// $06 BIN $1FFF eof $1FF8/$1FFF/$2000/$4000 - OriginalHiResImage
// $06 BIN $2000 eof $1FF8/$1FFF/$2000/$4000 - OriginalHiResImage
// $06 BIN $4000 eof $1FF8/$1FFF/$2000/$4000 - OriginalHiResImage
// $06 BIN .3200 - ???
// $06 BIN .3201 - ???
// $08 PICT <$4000 Apple II Graphics File - ???
// $08 PICT $4000 Packed Hi-Res file - ???
// $08 PICT $4001 Packed Double Hi-Res file - ???
// $C0 PNT $0000 Paintworks Packed Super Hi-Res - SHRPictureFile2 *
// * $C0 PNT $0001 Packed IIGS Super Hi-Res Image (xx) - SHRPictureFile2
// * $C0 PNT $0002 IIGS Super Hi-Res Picture File (APF) - SHRPictureFile
// $C0 PNT $0003 Packed IIGS QuickDraw II PICT File - SHRPictureFile2 *
// $C0 PNT $0004 Packed Super Hi-Res 3200 (Brooks) (yy) - SHRPictureFile2 *
// $C0 PNT $8001
// $C0 PNT $8005
// $C0 PNT $8006
// * $C1 PIC $0000 IIGS Super Hi-Res Image (xx) - SHRPictureFile2
// $C1 PIC $0001 IIGS QuickDraw II PICT File - SHRPictureFile2 *
// * $C1 PIC $0002 Super Hi-Res 3200 (Brooks) (yy) - SHRPictureFile2
// $C1 PIC $8001
// $C1 PIC $8002
// $C1 PIC $8003
protected static PaletteFactory paletteFactory = new PaletteFactory (); protected static PaletteFactory paletteFactory = new PaletteFactory ();
private static final byte[] pngHeader = private static final byte[] pngHeader =
@ -215,18 +249,18 @@ public abstract class HiResImage extends AbstractFile
switch (type) switch (type)
{ {
case 0: case 0: // copy next 1-64 bytes as is
while (count-- != 0) while (count-- != 0)
newBuf[newPtr++] = buffer[ptr++]; newBuf[newPtr++] = buffer[ptr++];
break; break;
case 1: case 1: // repeat next byte 3/5/6/7 times
byte b = buffer[ptr++]; byte b = buffer[ptr++];
while (count-- != 0) while (count-- != 0)
newBuf[newPtr++] = b; newBuf[newPtr++] = b;
break; break;
case 2: case 2: // repeat next 4 bytes (count) times
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
fourBuf[i] = buffer[ptr++]; fourBuf[i] = buffer[ptr++];
while (count-- != 0) while (count-- != 0)
@ -234,7 +268,7 @@ public abstract class HiResImage extends AbstractFile
newBuf[newPtr++] = fourBuf[i]; newBuf[newPtr++] = fourBuf[i];
break; break;
case 3: case 3: // repeat next byte (4*count) times
b = buffer[ptr++]; b = buffer[ptr++];
count *= 4; count *= 4;
while (count-- != 0) while (count-- != 0)

View File

@ -7,14 +7,14 @@ import java.util.List;
import com.bytezone.diskbrowser.utilities.HexFormatter; import com.bytezone.diskbrowser.utilities.HexFormatter;
public class SHRPictureFile extends HiResImage public class SHRPictureFile1 extends HiResImage
{ {
private final List<Block> blocks = new ArrayList<Block> (); private final List<Block> blocks = new ArrayList<Block> ();
private Main mainBlock; private Main mainBlock;
private Multipal multipalBlock; private Multipal multipalBlock;
// 0xC0 aux = 2 // 0xC0 aux = 2 - Apple IIGS Super Hi-Res Picture File
public SHRPictureFile (String name, byte[] buffer, int fileType, int auxType, int eof) public SHRPictureFile1 (String name, byte[] buffer, int fileType, int auxType, int eof)
{ {
super (name, buffer, fileType, auxType, eof); super (name, buffer, fileType, auxType, eof);
@ -176,9 +176,9 @@ public class SHRPictureFile extends HiResImage
private class Main extends Block private class Main extends Block
{ {
int masterMode; int masterMode; // 0 = Brooks, 0 = PNT 320 80 = PNT 640
int pixelsPerScanLine; int pixelsPerScanLine; // 320 or 640
int numColorTables; int numColorTables; // 1 = Brooks, 16 = Other
ColorTable[] colorTables; ColorTable[] colorTables;
int numScanLines; int numScanLines;
DirEntry[] scanLineDirectory; DirEntry[] scanLineDirectory;

View File

@ -11,59 +11,88 @@ public class SHRPictureFile2 extends HiResImage
ColorTable[] colorTables; ColorTable[] colorTables;
byte[] scb; // 0xC1 aux=0 byte[] scb; // 0xC1 aux=0
// see Graphics & Animation.2mg
public SHRPictureFile2 (String name, byte[] buffer, int fileType, int auxType, int eof) public SHRPictureFile2 (String name, byte[] buffer, int fileType, int auxType, int eof)
{ {
super (name, buffer, fileType, auxType, eof); super (name, buffer, fileType, auxType, eof);
if (fileType == ProdosConstants.FILE_TYPE_PNT) // 0xC0 switch (fileType)
{ {
if (auxType == 0) case ProdosConstants.FILE_TYPE_PNT:
{ switch (auxType)
System.out.println ("0xC0 aux 0 not written");
}
else if (auxType == 1) // Eagle/PackBytes
{
// this unpacks directly to the screen locations
System.out.println ("0xC0 aux 1 not written");
}
else
System.out.println ("C0 unknown aux " + auxType);
}
else if (fileType == ProdosConstants.FILE_TYPE_PIC) // 0xC1
{
if (auxType > 2)
{
System.out.printf ("Changing aux from %04X to 0 in %s%n", auxType, name);
auxType = 0;
}
if (auxType == 0) // 32,768
{
scb = new byte[200];
System.arraycopy (buffer, 32000, scb, 0, scb.length);
colorTables = new ColorTable[16];
for (int i = 0; i < colorTables.length; i++)
colorTables[i] = new ColorTable (i, buffer, 32256 + i * 32);
}
else if (auxType == 1)
{
System.out.println ("0xC1 aux 1 not written");
}
else if (auxType == 2) // Brooks 38,400
{
colorTables = new ColorTable[200];
for (int i = 0; i < colorTables.length; i++)
{ {
colorTables[i] = new ColorTable (i, buffer, 32000 + i * 32); case 0:
colorTables[i].reverse (); System.out.printf (
"%s: PNT aux 0 (Paintworks Packed SHR Image) not written yet%n", name);
break;
case 1: // Eagle/PackBytes - unpacks to PIC/$00
this.buffer = unpackBytes (buffer);
scb = new byte[200];
System.arraycopy (this.buffer, 32000, scb, 0, scb.length);
colorTables = new ColorTable[16];
for (int i = 0; i < colorTables.length; i++)
colorTables[i] = new ColorTable (i, this.buffer, 32256 + i * 32);
break;
case 2: // handled in SHRPictureFile1
break;
case 3:
System.out.printf ("%s: PNT aux 3 (Packed IIGS SHR Image) not written yet%n",
name);
break;
case 4:
System.out.printf (
"%s: PNT aux 4 (Packed SHR Brooks Image) not written yet%n", name);
break;
default:
System.out.printf ("%s: PNT unknown aux: %04X%n", name, auxType);
} }
} break;
else
System.out.println ("C1 unknown aux " + auxType); case ProdosConstants.FILE_TYPE_PIC:
if (auxType > 2)
{
System.out.printf ("%s: PIC changing aux from %04X to 0%n", name, auxType);
auxType = 0;
}
switch (auxType)
{
case 0: // 32,768
scb = new byte[200];
System.arraycopy (buffer, 32000, scb, 0, scb.length);
colorTables = new ColorTable[16];
for (int i = 0; i < colorTables.length; i++)
colorTables[i] = new ColorTable (i, buffer, 32256 + i * 32);
break;
case 1:
System.out.printf ("%s: PIC aux 1 not written yet%n", name);
break;
case 2: // Brooks 38,400
colorTables = new ColorTable[200];
for (int i = 0; i < colorTables.length; i++)
{
colorTables[i] = new ColorTable (i, buffer, 32000 + i * 32);
colorTables[i].reverse ();
}
break;
default:
System.out.println ("PIC unknown aux " + auxType);
}
break;
default:
System.out.println ("unknown filetype " + fileType);
} }
else
System.out.println ("unknown filetype " + fileType);
if (colorTables != null) if (colorTables != null)
createImage (); createImage ();

View File

@ -41,6 +41,8 @@ public class ShapeTable extends AbstractFile
for (int i = 0; i < totalShapes; i++) for (int i = 0; i < totalShapes; i++)
{ {
Shape shape = new Shape (buffer, i); Shape shape = new Shape (buffer, i);
if (!shape.valid)
return;
shapes.add (shape); shapes.add (shape);
minRow = Math.min (minRow, shape.minRow); minRow = Math.min (minRow, shape.minRow);
@ -87,8 +89,6 @@ public class ShapeTable extends AbstractFile
text.append (String.format ("File Name : %s%n", name)); text.append (String.format ("File Name : %s%n", name));
text.append (String.format ("File size : %,d%n", buffer.length)); text.append (String.format ("File size : %,d%n", buffer.length));
text.append (String.format ("Total shapes : %d%n", shapes.size ())); text.append (String.format ("Total shapes : %d%n", shapes.size ()));
// text.append (String.format ("Smallest : %d%n", minSize));
// text.append (String.format ("Largest : %d%n", maxSize));
text.append (String.format ("Max dimensions : %d x %d%n%n", maxWidth, maxHeight)); text.append (String.format ("Max dimensions : %d x %d%n%n", maxWidth, maxHeight));
for (Shape shape : shapes) for (Shape shape : shapes)
@ -139,12 +139,11 @@ public class ShapeTable extends AbstractFile
int actualLength; int actualLength;
int minRow, maxRow; int minRow, maxRow;
int minCol, maxCol; int minCol, maxCol;
// int endRow, endCol;
int startRow = SIZE / 2; int startRow = SIZE / 2;
int startCol = SIZE / 2; int startCol = SIZE / 2;
int[][] grid = new int[SIZE][SIZE]; int[][] grid = new int[SIZE][SIZE];
int[][] displayGrid; int[][] displayGrid;
// int height, width; boolean valid;
private BufferedImage image; private BufferedImage image;
@ -174,7 +173,8 @@ public class ShapeTable extends AbstractFile
// rightmost 3 bits // rightmost 3 bits
if (v3 >= 4) if (v3 >= 4)
plot (grid, row, col); if (!plot (grid, row, col))
return;
if (v3 == 0 || v3 == 4) if (v3 == 0 || v3 == 4)
row--; row--;
@ -187,7 +187,8 @@ public class ShapeTable extends AbstractFile
// middle 3 bits // middle 3 bits
if (v2 >= 4) if (v2 >= 4)
plot (grid, row, col); if (!plot (grid, row, col))
return;
// cannot move up without plotting if v1 is zero // cannot move up without plotting if v1 is zero
if ((v2 == 0 && v1 != 0) || v2 == 4) if ((v2 == 0 && v1 != 0) || v2 == 4)
@ -240,12 +241,7 @@ public class ShapeTable extends AbstractFile
maxCol = Math.max (maxCol, col); maxCol = Math.max (maxCol, col);
} }
} }
valid = true;
// height = maxRow - minRow + 1;
// width = maxCol - minCol + 1;
// System.out.printf ("%4d %4d %4d %4d %4d%n",
// index, minRow, maxRow, minCol,
// maxCol);
} }
void convertGrid (int offsetRows, int offsetColumns, int rows, int columns) void convertGrid (int offsetRows, int offsetColumns, int rows, int columns)
@ -275,11 +271,18 @@ public class ShapeTable extends AbstractFile
// endCol -= offsetColumns; // endCol -= offsetColumns;
} }
private void plot (int[][] grid, int row, int col) private boolean plot (int[][] grid, int row, int col)
{ {
if (row < 0 || row >= SIZE || col < 0 || col >= SIZE)
{
System.out.printf ("Shape table out of range: %d, %d%n", row, col);
return false;
}
grid[row][col] = 1; // plot grid[row][col] = 1; // plot
grid[0][col]++; // increment total column dots grid[0][col]++; // increment total column dots
grid[row][0]++; // increment total row dots grid[row][0]++; // increment total row dots
return true;
} }
public void drawText (StringBuilder text) public void drawText (StringBuilder text)

View File

@ -484,9 +484,6 @@ public class AppleDisk implements Disk
@Override @Override
public boolean isValidAddress (int block) public boolean isValidAddress (int block)
{ {
// if (block < 0 || block >= this.blocks)
// return false;
// return true;
return block >= 0 && block < this.blocks; return block >= 0 && block < this.blocks;
} }

View File

@ -42,12 +42,12 @@ public interface Disk extends Iterable<DiskAddress>
public void writeSector (DiskAddress da, byte[] buffer); public void writeSector (DiskAddress da, byte[] buffer);
public boolean isSectorEmpty (DiskAddress da);
public boolean isSectorEmpty (int block); public boolean isSectorEmpty (int block);
public boolean isSectorEmpty (int track, int sector); public boolean isSectorEmpty (int track, int sector);
public boolean isSectorEmpty (DiskAddress da);
public boolean isValidAddress (int block); public boolean isValidAddress (int block);
public boolean isValidAddress (int track, int sector); public boolean isValidAddress (int track, int sector);

View File

@ -53,6 +53,9 @@ public class DuplicateSwingWorker extends SwingWorker<Void, RootFolderData>
if (rootFolderData.progressPanel.cancelled) if (rootFolderData.progressPanel.cancelled)
return; return;
if (file.isHidden ())
continue;
if (file.isDirectory ()) if (file.isDirectory ())
{ {
if (file.getName ().equalsIgnoreCase ("emulators")) if (file.getName ().equalsIgnoreCase ("emulators"))

View File

@ -60,10 +60,14 @@ public class TreeBuilder
Arrays.sort (files, fileComparator); Arrays.sort (files, fileComparator);
for (File file : files) for (File file : files)
{
if (file.isHidden ())
continue;
if (file.isDirectory ()) if (file.isDirectory ())
parentNode.add (createNode (file, true)); parentNode.add (createNode (file, true));
else if (Utility.validFileType (file.getName ()) && file.length () > 0) else if (Utility.validFileType (file.getName ()) && file.length () > 0)
parentNode.add (createNode (file, false)); parentNode.add (createNode (file, false));
}
} }
private DefaultMutableTreeNode createNode (File file, boolean allowsChildren) private DefaultMutableTreeNode createNode (File file, boolean allowsChildren)

View File

@ -115,19 +115,19 @@ class FileEntry extends CatalogEntry implements ProdosConstants
switch (storageType) switch (storageType)
{ {
case SEEDLING: case SEEDLING:
if (disk.isValidAddress (keyPtr)) if (isValid (keyPtr))
blocks.add (keyPtr); blocks.add (keyPtr);
break; break;
case SAPLING: case SAPLING:
if (disk.isValidAddress (keyPtr)) if (isValid (keyPtr))
blocks.addAll (readIndex (keyPtr)); blocks.addAll (readIndex (keyPtr));
break; break;
case TREE: case TREE:
if (disk.isValidAddress (keyPtr)) if (isValid (keyPtr))
for (Integer indexBlock : readMasterIndex (keyPtr)) for (Integer indexBlock : readMasterIndex (keyPtr))
if (disk.isValidAddress (indexBlock)) if (isValid (indexBlock))
blocks.addAll (readIndex (indexBlock)); blocks.addAll (readIndex (indexBlock));
break; break;
} }
@ -164,7 +164,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
{ {
int blockNo = (buffer[i] & 0xFF) | ((buffer[i + 0x100] & 0xFF) << 8); int blockNo = (buffer[i] & 0xFF) | ((buffer[i + 0x100] & 0xFF) << 8);
blocks.add (disk.isValidAddress (blockNo) ? blockNo : 0); blocks.add (isValid (blockNo) ? blockNo : 0);
} }
} }
@ -187,12 +187,24 @@ class FileEntry extends CatalogEntry implements ProdosConstants
for (int i = 0; i <= highest; i++) for (int i = 0; i <= highest; i++)
{ {
int blockNo = (buffer[i] & 0xFF) | ((buffer[i + 256] & 0xFF) << 8); int blockNo = (buffer[i] & 0xFF) | ((buffer[i + 256] & 0xFF) << 8);
blocks.add (disk.isValidAddress (blockNo) ? blockNo : 0); blocks.add (isValid (blockNo) ? blockNo : 0);
} }
return blocks; return blocks;
} }
private boolean isValid (int blockNo)
{
if (true)
{
if (!disk.isValidAddress (blockNo))
System.out.println ("--Invalid Address: " + blockNo);
if (parentDisk.isSectorFree (blockNo))
System.out.println ("--Free block: " + blockNo);
}
return disk.isValidAddress (blockNo) && !parentDisk.isSectorFree (blockNo);
}
@Override @Override
public DataSource getDataSource () public DataSource getDataSource ()
{ {
@ -208,7 +220,6 @@ class FileEntry extends CatalogEntry implements ProdosConstants
if (fileType == FILE_TYPE_TEXT && auxType > 0) // random access file if (fileType == FILE_TYPE_TEXT && auxType > 0) // random access file
return getRandomAccessTextFile (); return getRandomAccessTextFile ();
// byte[] buffer = isGSOSFile () ? getGEOSBuffer () : getBuffer ();
byte[] buffer = getBuffer (); byte[] buffer = getBuffer ();
byte[] exactBuffer = getExactBuffer (buffer); byte[] exactBuffer = getExactBuffer (buffer);
@ -223,16 +234,18 @@ class FileEntry extends CatalogEntry implements ProdosConstants
case FILE_TYPE_USER_DEFINED_1: case FILE_TYPE_USER_DEFINED_1:
// if (name.endsWith (".S")) // if (name.endsWith (".S"))
// file = new MerlinSource (name, exactBuffer, auxType, endOfFile); // file = new MerlinSource (name, exactBuffer, auxType, endOfFile);
if (ShapeTable.isShapeTable (exactBuffer)) if (SimpleText.isHTML (exactBuffer))
file = new ShapeTable (name, exactBuffer);
else if (SimpleText.isHTML (exactBuffer))
file = new SimpleText (name, exactBuffer); file = new SimpleText (name, exactBuffer);
else if (HiResImage.isGif (exactBuffer) || HiResImage.isPng (exactBuffer)) else if (HiResImage.isGif (exactBuffer) || HiResImage.isPng (exactBuffer))
file = new OriginalHiResImage (name, exactBuffer, auxType); file = new OriginalHiResImage (name, exactBuffer, auxType);
else if (name.endsWith (".BMP") && HiResImage.isBmp (exactBuffer)) else if (name.endsWith (".BMP") && HiResImage.isBmp (exactBuffer))
file = new OriginalHiResImage (name, exactBuffer, auxType); file = new OriginalHiResImage (name, exactBuffer, auxType);
else if (name.endsWith (".3200") || name.endsWith (".3201")) // unknown image file
file = new AssemblerProgram (name, exactBuffer, auxType);
else if (name.endsWith (".FNT") && FontFile.isFont (exactBuffer)) else if (name.endsWith (".FNT") && FontFile.isFont (exactBuffer))
file = new FontFile (name, exactBuffer); file = new FontFile (name, exactBuffer);
else if (ShapeTable.isShapeTable (exactBuffer))
file = new ShapeTable (name, exactBuffer);
else if (link != null) else if (link != null)
{ {
if (name.endsWith (".AUX")) if (name.endsWith (".AUX"))
@ -243,9 +256,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
else if (name.endsWith (".PAC") || name.endsWith (".A2FC") else if (name.endsWith (".PAC") || name.endsWith (".A2FC")
|| (endOfFile == 0x4000 && auxType == 0x2000)) || (endOfFile == 0x4000 && auxType == 0x2000))
file = new DoubleHiResImage (name, exactBuffer); file = new DoubleHiResImage (name, exactBuffer);
else if ((endOfFile == 0x1FF8 || endOfFile == 0x1FFF || endOfFile == 0x2000 else if (oneOf (endOfFile, 0x1FF8, 0x1FFF, 0x2000, 0x4000)
|| endOfFile == 0x4000) && oneOf (auxType, 0x1FFF, 0x2000, 0x4000))
&& (auxType == 0x1FFF || auxType == 0x2000 || auxType == 0x4000))
file = new OriginalHiResImage (name, exactBuffer, auxType); file = new OriginalHiResImage (name, exactBuffer, auxType);
else if (endOfFile == 38400 && name.startsWith ("LVL.")) else if (endOfFile == 38400 && name.startsWith ("LVL."))
file = new LodeRunner (name, exactBuffer); file = new LodeRunner (name, exactBuffer);
@ -328,7 +340,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
case FILE_TYPE_PNT: case FILE_TYPE_PNT:
if (auxType == 2) if (auxType == 2)
file = new SHRPictureFile (name, exactBuffer, fileType, auxType, endOfFile); file = new SHRPictureFile1 (name, exactBuffer, fileType, auxType, endOfFile);
else else
file = new SHRPictureFile2 (name, exactBuffer, fileType, auxType, endOfFile); file = new SHRPictureFile2 (name, exactBuffer, fileType, auxType, endOfFile);
break; break;
@ -337,6 +349,11 @@ class FileEntry extends CatalogEntry implements ProdosConstants
file = new SHRPictureFile2 (name, exactBuffer, fileType, auxType, endOfFile); file = new SHRPictureFile2 (name, exactBuffer, fileType, auxType, endOfFile);
break; break;
case FILE_TYPE_PICT:
System.out.println ("*** PICT : " + name);
file = new DefaultAppleFile (name, exactBuffer);
break;
case FILE_TYPE_FONT: case FILE_TYPE_FONT:
file = new QuickDrawFont (name, exactBuffer, fileType, auxType); file = new QuickDrawFont (name, exactBuffer, fileType, auxType);
break; break;
@ -352,6 +369,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
case FILE_TYPE_FINDER: case FILE_TYPE_FINDER:
case FILE_TYPE_PASCAL_VOLUME: case FILE_TYPE_PASCAL_VOLUME:
case FILE_TYPE_GEO: case FILE_TYPE_GEO:
case FILE_TYPE_LDF:
file = new DefaultAppleFile (name, exactBuffer); file = new DefaultAppleFile (name, exactBuffer);
break; break;
@ -368,16 +386,19 @@ class FileEntry extends CatalogEntry implements ProdosConstants
return file; return file;
} }
private boolean oneOf (int val, int... values)
{
for (int value : values)
if (val == value)
return true;
return false;
}
private byte[] getExactBuffer (byte[] buffer) private byte[] getExactBuffer (byte[] buffer)
{ {
// if (buffer.length < endOfFile && fileType != FILE_TYPE_DIRECTORY)
// System.out.printf ("Buffer (%,d) shorter than EOF (%,d) in %s %02X%n",
// buffer.length, endOfFile, name, fileType);
byte[] exactBuffer; byte[] exactBuffer;
if (buffer.length < endOfFile) if (buffer.length < endOfFile)
{ {
// exactBuffer = new byte[buffer.length];
exactBuffer = new byte[endOfFile]; exactBuffer = new byte[endOfFile];
System.arraycopy (buffer, 0, exactBuffer, 0, buffer.length); System.arraycopy (buffer, 0, exactBuffer, 0, buffer.length);
} }
@ -502,63 +523,63 @@ class FileEntry extends CatalogEntry implements ProdosConstants
} }
// should be removed // should be removed
private byte[] getGEOSBuffer () // private byte[] getGEOSBuffer ()
{ // {
switch (storageType) // switch (storageType)
{ // {
case SEEDLING: // case SEEDLING:
System.out.println ("Seedling GEOS file : " + name); // not sure if possible // System.out.println ("Seedling GEOS file : " + name); // not sure if possible
return disk.readSectors (dataBlocks); // return disk.readSectors (dataBlocks);
case SAPLING: // case SAPLING:
return getIndexFile (keyPtr); // return getIndexFile (keyPtr);
case TREE: // case TREE:
return getMasterIndexFile (keyPtr); // return getMasterIndexFile (keyPtr);
default: // default:
System.out.println ("Unknown storage type for GEOS file : " + storageType); // System.out.println ("Unknown storage type for GEOS file : " + storageType);
return new byte[512]; // return new byte[512];
} // }
} // }
// should be removed // should be removed
private byte[] getMasterIndexFile (int keyPtr) // private byte[] getMasterIndexFile (int keyPtr)
{ // {
byte[] buffer = disk.readSector (keyPtr); // byte[] buffer = disk.readSector (keyPtr);
int length = HexFormatter.intValue (buffer[0xFF], buffer[0x1FF]); // int length = HexFormatter.intValue (buffer[0xFF], buffer[0x1FF]);
byte[] fileBuffer = new byte[length]; // byte[] fileBuffer = new byte[length];
int ptr = 0; // int ptr = 0;
for (int i = 0; i < 0x80; i++) // for (int i = 0; i < 0x80; i++)
{ // {
int block = HexFormatter.intValue (buffer[i], buffer[i + 256]); // int block = HexFormatter.intValue (buffer[i], buffer[i + 256]);
if (block == 0) // if (block == 0)
break; // break;
if (block == 0xFFFF) // should this insert 131,072 zeroes? // if (block == 0xFFFF) // should this insert 131,072 zeroes?
continue; // continue;
byte[] temp = getIndexFile (block); // byte[] temp = getIndexFile (block);
System.arraycopy (temp, 0, fileBuffer, ptr, temp.length); // System.arraycopy (temp, 0, fileBuffer, ptr, temp.length);
ptr += temp.length; // ptr += temp.length;
} // }
return fileBuffer; // return fileBuffer;
} // }
// should be removed // should be removed
private byte[] getIndexFile (int keyPtr) // private byte[] getIndexFile (int keyPtr)
{ // {
byte[] buffer = disk.readSector (keyPtr); // byte[] buffer = disk.readSector (keyPtr);
int length = HexFormatter.intValue (buffer[0xFF], buffer[0x1FF]); // int length = HexFormatter.intValue (buffer[0xFF], buffer[0x1FF]);
byte[] fileBuffer = new byte[length]; // byte[] fileBuffer = new byte[length];
for (int i = 0; i < 0x80; i++) // for (int i = 0; i < 0x80; i++)
{ // {
int block = HexFormatter.intValue (buffer[i], buffer[i + 256]); // int block = HexFormatter.intValue (buffer[i], buffer[i + 256]);
if (block == 0) // if (block == 0)
break; // break;
if (block == 0xFFFF) // should this insert 512 zeroes? // if (block == 0xFFFF) // should this insert 512 zeroes?
continue; // continue;
byte[] temp = disk.readSector (block); // byte[] temp = disk.readSector (block);
System.arraycopy (temp, 0, fileBuffer, i * 512, length > 512 ? 512 : length); // System.arraycopy (temp, 0, fileBuffer, i * 512, length > 512 ? 512 : length);
length -= 512; // length -= 512;
} // }
return fileBuffer; // return fileBuffer;
} // }
private int readIndexBlock (int indexBlock, List<DiskAddress> addresses, private int readIndexBlock (int indexBlock, List<DiskAddress> addresses,
List<TextBuffer> buffers, int logicalBlock) List<TextBuffer> buffers, int logicalBlock)
@ -609,6 +630,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
return false; return false;
} }
// called from ProdosDisk.processDirectoryBlock
void link (FileEntry fileEntry) void link (FileEntry fileEntry)
{ {
this.link = fileEntry; this.link = fileEntry;

View File

@ -8,13 +8,11 @@ import com.bytezone.diskbrowser.disk.DiskAddress;
class ProdosBitMapSector extends AbstractSector class ProdosBitMapSector extends AbstractSector
{ {
// private final DiskAddress da;
private final ProdosDisk parent; private final ProdosDisk parent;
ProdosBitMapSector (ProdosDisk parent, Disk disk, byte[] buffer, DiskAddress da) ProdosBitMapSector (ProdosDisk parent, Disk disk, byte[] buffer, DiskAddress da)
{ {
super (disk, buffer, da); super (disk, buffer, da);
// this.da = da;
this.parent = parent; this.parent = parent;
} }

View File

@ -17,6 +17,7 @@ public interface ProdosConstants
// int FILE_TYPE_FORKED_FILE = 0xB3; // S16 // int FILE_TYPE_FORKED_FILE = 0xB3; // S16
int FILE_TYPE_IIGS_APPLICATION = 0xB3; int FILE_TYPE_IIGS_APPLICATION = 0xB3;
int FILE_TYPE_IIGS_DEVICE_DRIVER = 0xBB; int FILE_TYPE_IIGS_DEVICE_DRIVER = 0xBB;
int FILE_TYPE_LDF = 0xBC;
int FILE_TYPE_GSOS_FILE_SYSTEM_TRANSLATOR = 0xBD; int FILE_TYPE_GSOS_FILE_SYSTEM_TRANSLATOR = 0xBD;
int FILE_TYPE_PNT = 0xC0; int FILE_TYPE_PNT = 0xC0;
int FILE_TYPE_PIC = 0xC1; int FILE_TYPE_PIC = 0xC1;

View File

@ -169,6 +169,11 @@ public class ProdosDisk extends AbstractFormattedDisk
} }
} }
public boolean isReservedAddress (int blockNo)
{
return false;
}
public static boolean isCorrectFormat (AppleDisk disk) public static boolean isCorrectFormat (AppleDisk disk)
{ {
disk.setInterleave (1); disk.setInterleave (1);

View File

@ -329,23 +329,21 @@ public class HexFormatter
public static int unsignedShort (byte[] buffer, int ptr) public static int unsignedShort (byte[] buffer, int ptr)
{ {
// int val = 0; if (ptr >= buffer.length)
// for (int i = 1; i >= 0; i--) {
// { System.out.println ("index out of range: " + ptr);
// val <<= 8; return 0;
// val += buffer[ptr + i] & 0xFF; }
// }
// return val;
return (buffer[ptr] & 0xFF) | ((buffer[ptr + 1] & 0xFF) << 8); return (buffer[ptr] & 0xFF) | ((buffer[ptr + 1] & 0xFF) << 8);
} }
// public static int signedShort (byte[] buffer, int ptr)
// {
// return (short) (((buffer[ptr] & 0xFF) << 8) | (buffer[ptr + 1] & 0xFF));
// }
public static int signedShort (byte[] buffer, int ptr) public static int signedShort (byte[] buffer, int ptr)
{ {
if (ptr >= buffer.length)
{
System.out.println ("index out of range: " + ptr);
return 0;
}
return (short) ((buffer[ptr] & 0xFF) | ((buffer[ptr + 1] & 0xFF) << 8)); return (short) ((buffer[ptr] & 0xFF) | ((buffer[ptr + 1] & 0xFF) << 8));
} }