From f25e591d1a904b2bc8432ff2fd49ed8434a6a802 Mon Sep 17 00:00:00 2001 From: Denis Molony Date: Sat, 28 Jul 2018 22:00:02 +1000 Subject: [PATCH] graphics changes --- .../diskbrowser/applefile/HiResImage.java | 41 ++++++++++++----- .../applefile/SHRPictureFile1.java | 21 ++++++++- .../applefile/SHRPictureFile2.java | 14 +++++- .../bytezone/diskbrowser/gui/DataPanel.java | 6 +-- .../diskbrowser/gui/DebuggingAction.java | 3 +- .../bytezone/diskbrowser/gui/MenuHandler.java | 38 +++++++-------- .../diskbrowser/prodos/FileEntry.java | 10 +++- .../diskbrowser/prodos/ProdosConstants.java | 2 + .../diskbrowser/prodos/ProdosDirectory.java | 16 +++++-- .../diskbrowser/prodos/ProdosDisk.java | 46 +++++++++---------- 10 files changed, 132 insertions(+), 65 deletions(-) diff --git a/src/com/bytezone/diskbrowser/applefile/HiResImage.java b/src/com/bytezone/diskbrowser/applefile/HiResImage.java index 4292d67..eb48e3f 100644 --- a/src/com/bytezone/diskbrowser/applefile/HiResImage.java +++ b/src/com/bytezone/diskbrowser/applefile/HiResImage.java @@ -34,17 +34,20 @@ public abstract class HiResImage extends AbstractFile // * $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 + // $C0 PNT $0004 Packed Super Hi-Res 3200 (Brooks) (yy) .3201? - SHRPictureFile2 * + // $C0 PNT $8001 GTv background picture + // $C0 PNT $8005 DreamGraphix document + // $C0 PNT $8006 GIF // * $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 + // * $C1 PIC $0002 Super Hi-Res 3200 (Brooks) (yy) .3200? - SHRPictureFile2 + // $C1 PIC $8001 Allison raw image + // $C1 PIC $8002 Thunderscan + // $C1 PIC $8003 DreamGraphix + + // $C2 ANI Paintworks animation + // $C3 PAL Paintworks palette protected static PaletteFactory paletteFactory = new PaletteFactory (); @@ -190,6 +193,8 @@ public abstract class HiResImage extends AbstractFile auxText = "Super Hi-Res Image (Apple Preferred)"; else if (auxType == 3) auxText = "Packed QuickDraw II PICT File"; + else if (auxType == 4) + auxText = "Packed Super Hi-Res 3200 color image"; else auxText = "Unknown aux: " + auxType; break; @@ -235,10 +240,26 @@ public abstract class HiResImage extends AbstractFile // Super Hi-res IIGS protected byte[] unpackBytes (byte[] buffer) + { + for (int i = 1; i <= 4; i++) + try + { + byte[] newBuf = new byte[32768 * i]; // keep guessing + unpack (buffer, newBuf); + return newBuf; + } + catch (ArrayIndexOutOfBoundsException e) + { + + } + + return new byte[0]; + } + + private void unpack (byte[] buffer, byte[] newBuf) throws ArrayIndexOutOfBoundsException { // routine found here - http://kpreid.livejournal.com/4319.html - byte[] newBuf = new byte[32768]; // this might be wrong byte[] fourBuf = new byte[4]; int ptr = 0, newPtr = 0; @@ -276,8 +297,6 @@ public abstract class HiResImage extends AbstractFile break; } } - - return newBuf; } // Super Hi-res IIGS diff --git a/src/com/bytezone/diskbrowser/applefile/SHRPictureFile1.java b/src/com/bytezone/diskbrowser/applefile/SHRPictureFile1.java index 01b4a57..863482d 100644 --- a/src/com/bytezone/diskbrowser/applefile/SHRPictureFile1.java +++ b/src/com/bytezone/diskbrowser/applefile/SHRPictureFile1.java @@ -41,9 +41,28 @@ public class SHRPictureFile1 extends HiResImage blocks.add (multipalBlock); break; + case "PALETTES": + System.out.println ("PALETTES not written"); + blocks.add (new Block (kind, data)); + break; + + case "MASK": + System.out.println ("MASK not written"); + blocks.add (new Block (kind, data)); + break; + + case "PATS": + System.out.println ("PATS not written"); + blocks.add (new Block (kind, data)); + break; + + case "SCIB": + System.out.println ("SCIB not written"); + blocks.add (new Block (kind, data)); + break; + // case "SuperConvert": // case "EOA ": // DeluxePaint - // case "PATS": // case "Platinum Paint": // blocks.add (new Block (kind, data)); // break; diff --git a/src/com/bytezone/diskbrowser/applefile/SHRPictureFile2.java b/src/com/bytezone/diskbrowser/applefile/SHRPictureFile2.java index 0113d06..139cee6 100644 --- a/src/com/bytezone/diskbrowser/applefile/SHRPictureFile2.java +++ b/src/com/bytezone/diskbrowser/applefile/SHRPictureFile2.java @@ -25,6 +25,17 @@ public class SHRPictureFile2 extends HiResImage case 0: System.out.printf ( "%s: PNT aux 0 (Paintworks Packed SHR Image) not written yet%n", name); + int background = HexFormatter.intValue (buffer[0x20], buffer[0x21]); + + byte[] palette = new byte[32]; + byte[] patterns = new byte[512]; + byte[] data = new byte[buffer.length - 0x222]; + + System.arraycopy (buffer, 0x00, palette, 0, palette.length); + System.arraycopy (buffer, 0x22, patterns, 0, patterns.length); + System.arraycopy (buffer, 0x0222, data, 0, data.length); + + this.buffer = unpackBytes (data); break; case 1: // packed version of PIC/$00 @@ -52,7 +63,7 @@ public class SHRPictureFile2 extends HiResImage colorTables = new ColorTable[200]; for (int i = 0; i < colorTables.length; i++) { - colorTables[i] = new ColorTable (i, buffer, 32000 + i * 32); + colorTables[i] = new ColorTable (i, this.buffer, 32000 + i * 32); colorTables[i].reverse (); } break; @@ -173,6 +184,7 @@ public class SHRPictureFile2 extends HiResImage text.append ("\nScreen lines\n\n"); for (int i = 0; i < 200; i++) { + text.append (String.format ("Line: %02X %<3d%n", i)); text.append (HexFormatter.format (buffer, i * 160, 160)); text.append ("\n\n"); } diff --git a/src/com/bytezone/diskbrowser/gui/DataPanel.java b/src/com/bytezone/diskbrowser/gui/DataPanel.java index b490d79..611f157 100755 --- a/src/com/bytezone/diskbrowser/gui/DataPanel.java +++ b/src/com/bytezone/diskbrowser/gui/DataPanel.java @@ -36,7 +36,7 @@ class DataPanel extends JTabbedPane JTextArea formattedText; ImagePanel imagePanel; // internal class - boolean debug; + boolean debugMode; boolean imageVisible = false; @@ -182,7 +182,7 @@ class DataPanel extends JTabbedPane public void setDebug (boolean value) { - debug = value; + debugMode = value; if (currentDataSource instanceof VisicalcFile) { @@ -271,7 +271,7 @@ class DataPanel extends JTabbedPane } BufferedImage image = dataSource.getImage (); - if (image == null || debug) + if (image == null || debugMode) removeImage (); else { diff --git a/src/com/bytezone/diskbrowser/gui/DebuggingAction.java b/src/com/bytezone/diskbrowser/gui/DebuggingAction.java index 3f254e4..460b47d 100644 --- a/src/com/bytezone/diskbrowser/gui/DebuggingAction.java +++ b/src/com/bytezone/diskbrowser/gui/DebuggingAction.java @@ -15,8 +15,7 @@ public class DebuggingAction extends AbstractAction { super ("Debugging"); putValue (Action.SHORT_DESCRIPTION, "Show debugging information"); - putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("ctrl D")); - // putValue (Action.MNEMONIC_KEY, KeyEvent.VK_D); + putValue (Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke ("meta D")); this.owner = owner; } diff --git a/src/com/bytezone/diskbrowser/gui/MenuHandler.java b/src/com/bytezone/diskbrowser/gui/MenuHandler.java index 4e415b3..43e598f 100755 --- a/src/com/bytezone/diskbrowser/gui/MenuHandler.java +++ b/src/com/bytezone/diskbrowser/gui/MenuHandler.java @@ -39,32 +39,32 @@ public class MenuHandler JMenu helpMenu = new JMenu ("Help"); // File menu items - JMenuItem rootItem = new JMenuItem ("Set root folder..."); - JMenuItem refreshTreeItem = new JMenuItem ("Refresh current tree"); + final JMenuItem rootItem = new JMenuItem ("Set root folder..."); + final JMenuItem refreshTreeItem = new JMenuItem ("Refresh current tree"); JMenuItem executeDiskItem; - JMenuItem printItem = new JMenuItem ("Print output panel..."); - JMenuItem closeTabItem = new JMenuItem (); - JMenuItem duplicateItem = new JMenuItem (); - FontAction fontAction; + final JMenuItem printItem = new JMenuItem ("Print output panel..."); + final JMenuItem closeTabItem = new JMenuItem (); + final JMenuItem duplicateItem = new JMenuItem (); + final FontAction fontAction; // Format menu items final JMenuItem lineWrapItem = new JCheckBoxMenuItem ("Line wrap"); final JMenuItem showLayoutItem = new JCheckBoxMenuItem ("Show layout panel"); - JMenuItem showCatalogItem = new JCheckBoxMenuItem ("Show catalog panel"); - JMenuItem showFreeSectorsItem = new JCheckBoxMenuItem ("Show free sectors"); + final JMenuItem showCatalogItem = new JCheckBoxMenuItem ("Show catalog panel"); + final JMenuItem showFreeSectorsItem = new JCheckBoxMenuItem ("Show free sectors"); - JMenuItem sector256Item = new JRadioButtonMenuItem ("256 byte sectors"); - JMenuItem sector512Item = new JRadioButtonMenuItem ("512 byte blocks"); - JMenuItem interleave0Item = new JRadioButtonMenuItem (new InterleaveAction (0)); - JMenuItem interleave1Item = new JRadioButtonMenuItem (new InterleaveAction (1)); - JMenuItem interleave2Item = new JRadioButtonMenuItem (new InterleaveAction (2)); - JMenuItem interleave3Item = new JRadioButtonMenuItem (new InterleaveAction (3)); + final JMenuItem sector256Item = new JRadioButtonMenuItem ("256 byte sectors"); + final JMenuItem sector512Item = new JRadioButtonMenuItem ("512 byte blocks"); + final JMenuItem interleave0Item = new JRadioButtonMenuItem (new InterleaveAction (0)); + final JMenuItem interleave1Item = new JRadioButtonMenuItem (new InterleaveAction (1)); + final JMenuItem interleave2Item = new JRadioButtonMenuItem (new InterleaveAction (2)); + final JMenuItem interleave3Item = new JRadioButtonMenuItem (new InterleaveAction (3)); - JMenuItem colourQuirksItem = new JCheckBoxMenuItem ("Colour quirks"); - JMenuItem monochromeItem = new JCheckBoxMenuItem ("Monochrome"); - JMenuItem debuggingItem = new JCheckBoxMenuItem ("Debugging"); - JMenuItem nextPaletteItem = new JMenuItem ("Next Palette"); - JMenuItem prevPaletteItem = new JMenuItem ("Previous Palette"); + final JMenuItem colourQuirksItem = new JCheckBoxMenuItem ("Colour quirks"); + final JMenuItem monochromeItem = new JCheckBoxMenuItem ("Monochrome"); + final JMenuItem debuggingItem = new JCheckBoxMenuItem ("Debugging"); + final JMenuItem nextPaletteItem = new JMenuItem ("Next Palette"); + final JMenuItem prevPaletteItem = new JMenuItem ("Previous Palette"); ButtonGroup paletteGroup = new ButtonGroup (); diff --git a/src/com/bytezone/diskbrowser/prodos/FileEntry.java b/src/com/bytezone/diskbrowser/prodos/FileEntry.java index 803f932..c99b3aa 100755 --- a/src/com/bytezone/diskbrowser/prodos/FileEntry.java +++ b/src/com/bytezone/diskbrowser/prodos/FileEntry.java @@ -240,8 +240,12 @@ class FileEntry extends CatalogEntry implements ProdosConstants file = new OriginalHiResImage (name, exactBuffer, auxType); else if (name.endsWith (".BMP") && HiResImage.isBmp (exactBuffer)) 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 (".3200")) // $C1/02 + // file = new AssemblerProgram (name, exactBuffer, auxType); + file = new SHRPictureFile2 (name, exactBuffer, 0xC1, 0x02, endOfFile); + else if (name.endsWith (".3201")) // $C0/04 + file = new DefaultAppleFile (name, exactBuffer); + // file = new SHRPictureFile2 (name, exactBuffer, 0xC0, 0x04, endOfFile); else if (name.endsWith (".FNT") && FontFile.isFont (exactBuffer)) file = new FontFile (name, exactBuffer); else if (ShapeTable.isShapeTable (exactBuffer)) @@ -370,6 +374,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants case FILE_TYPE_PASCAL_VOLUME: case FILE_TYPE_GEO: case FILE_TYPE_LDF: + case FILE_TYPE_ANI: + case FILE_TYPE_PAL: file = new DefaultAppleFile (name, exactBuffer); break; diff --git a/src/com/bytezone/diskbrowser/prodos/ProdosConstants.java b/src/com/bytezone/diskbrowser/prodos/ProdosConstants.java index da8613b..0b90d5c 100755 --- a/src/com/bytezone/diskbrowser/prodos/ProdosConstants.java +++ b/src/com/bytezone/diskbrowser/prodos/ProdosConstants.java @@ -21,6 +21,8 @@ public interface ProdosConstants int FILE_TYPE_GSOS_FILE_SYSTEM_TRANSLATOR = 0xBD; int FILE_TYPE_PNT = 0xC0; int FILE_TYPE_PIC = 0xC1; + int FILE_TYPE_ANI = 0xC2; + int FILE_TYPE_PAL = 0xC3; int FILE_TYPE_FONT = 0xC8; int FILE_TYPE_FINDER = 0xC9; int FILE_TYPE_ICN = 0xCA; diff --git a/src/com/bytezone/diskbrowser/prodos/ProdosDirectory.java b/src/com/bytezone/diskbrowser/prodos/ProdosDirectory.java index 263a9ab..e7e4d6f 100755 --- a/src/com/bytezone/diskbrowser/prodos/ProdosDirectory.java +++ b/src/com/bytezone/diskbrowser/prodos/ProdosDirectory.java @@ -6,7 +6,7 @@ import com.bytezone.diskbrowser.applefile.AbstractFile; import com.bytezone.diskbrowser.disk.FormattedDisk; import com.bytezone.diskbrowser.utilities.HexFormatter; -class ProdosDirectory extends AbstractFile +class ProdosDirectory extends AbstractFile implements ProdosConstants { private static final String NO_DATE = ""; private static final String newLine = String.format ("%n"); @@ -79,14 +79,24 @@ class ProdosDirectory extends AbstractFile switch (fileType) { - case 4: // Text file + case FILE_TYPE_TEXT: int aux = HexFormatter.intValue (buffer[i + 31], buffer[i + 32]); subType = String.format ("R=%5d", aux); break; - case 6: // BIN file + case FILE_TYPE_BINARY: + case FILE_TYPE_PNT: + case FILE_TYPE_PIC: aux = HexFormatter.intValue (buffer[i + 31], buffer[i + 32]); subType = String.format ("A=$%4X", aux); + if (fileType == FILE_TYPE_PNT && aux == 0) + System.out.printf ("found $C0/00 %s%n", name); + if (fileType == FILE_TYPE_PNT && aux == 3) + System.out.printf ("found $C0/03 %s%n", name); + if (fileType == FILE_TYPE_PNT && aux == 4) + System.out.printf ("found $C0/04 %s%n", name); + if (fileType == FILE_TYPE_PIC && aux == 1) + System.out.printf ("found $C1/01 %s%n", name); break; case 0x1A: // AWP file diff --git a/src/com/bytezone/diskbrowser/prodos/ProdosDisk.java b/src/com/bytezone/diskbrowser/prodos/ProdosDisk.java index d0f4df5..618777a 100755 --- a/src/com/bytezone/diskbrowser/prodos/ProdosDisk.java +++ b/src/com/bytezone/diskbrowser/prodos/ProdosDisk.java @@ -219,29 +219,6 @@ public class ProdosDisk extends AbstractFormattedDisk this); } - @Override - public String toString () - { - StringBuffer text = new StringBuffer (); - String newLine = String.format ("%n"); - - VolumeDirectoryHeader volumeDirectory = (VolumeDirectoryHeader) headerEntries.get (0); - String timeC = volumeDirectory.created == null ? "" - : df.format (volumeDirectory.created.getTime ()); - text.append ("Volume name : " + volumeDirectory.name + newLine); - text.append ("Creation date : " + timeC + newLine); - text.append ("ProDOS version : " + volumeDirectory.version + newLine); - text.append ("Min ProDOS version : " + volumeDirectory.minVersion + newLine); - text.append ("Access rights : " + volumeDirectory.access + newLine); - text.append ("Entry length : " + volumeDirectory.entryLength + newLine); - text.append ("Entries per block : " + volumeDirectory.entriesPerBlock + newLine); - text.append ("File count : " + volumeDirectory.fileCount + newLine); - text.append ("Bitmap block : " + volumeDirectory.bitMapBlock + newLine); - text.append ("Total blocks : " + volumeDirectory.totalBlocks + newLine); - - return text.toString (); - } - @Override public DataSource getFormattedSector (DiskAddress da) { @@ -275,4 +252,27 @@ public class ProdosDisk extends AbstractFormattedDisk return ((VolumeDirectoryHeader) headerEntries.get (0)).getSectors (); return fileEntries.get (fileNo - 1).getSectors (); } + + @Override + public String toString () + { + StringBuffer text = new StringBuffer (); + String newLine = String.format ("%n"); + + VolumeDirectoryHeader volumeDirectory = (VolumeDirectoryHeader) headerEntries.get (0); + String timeC = volumeDirectory.created == null ? "" + : df.format (volumeDirectory.created.getTime ()); + text.append ("Volume name : " + volumeDirectory.name + newLine); + text.append ("Creation date : " + timeC + newLine); + text.append ("ProDOS version : " + volumeDirectory.version + newLine); + text.append ("Min ProDOS version : " + volumeDirectory.minVersion + newLine); + text.append ("Access rights : " + volumeDirectory.access + newLine); + text.append ("Entry length : " + volumeDirectory.entryLength + newLine); + text.append ("Entries per block : " + volumeDirectory.entriesPerBlock + newLine); + text.append ("File count : " + volumeDirectory.fileCount + newLine); + text.append ("Bitmap block : " + volumeDirectory.bitMapBlock + newLine); + text.append ("Total blocks : " + volumeDirectory.totalBlocks + newLine); + + return text.toString (); + } } \ No newline at end of file