From adf22d88945dcba9b3031d7a521cc4ab3975b367 Mon Sep 17 00:00:00 2001 From: Denis Molony Date: Fri, 27 Jan 2017 18:11:00 +1100 Subject: [PATCH] tidying --- .../diskbrowser/applefile/HiResImage.java | 7 ++++++ .../applefile/SHRPictureFile2.java | 24 ++++++++++++------- .../bytezone/diskbrowser/gui/DataPanel.java | 2 +- .../bytezone/diskbrowser/gui/MenuHandler.java | 4 ++-- .../diskbrowser/prodos/FileEntry.java | 15 ++++++------ 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/com/bytezone/diskbrowser/applefile/HiResImage.java b/src/com/bytezone/diskbrowser/applefile/HiResImage.java index 387b174..6c4eab9 100644 --- a/src/com/bytezone/diskbrowser/applefile/HiResImage.java +++ b/src/com/bytezone/diskbrowser/applefile/HiResImage.java @@ -143,6 +143,8 @@ public abstract class HiResImage extends AbstractFile auxText = "Packed Hi-Res File"; else if (auxType == 0x4001) auxText = "Packed Double Hi-Res File"; + else + auxText = "Unknown aux: " + auxType; break; case ProdosConstants.FILE_TYPE_PNT: // 0xC0 @@ -154,6 +156,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 + auxText = "Unknown aux: " + auxType; break; case ProdosConstants.FILE_TYPE_PIC: // 0xC1 @@ -163,6 +167,8 @@ public abstract class HiResImage extends AbstractFile auxText = "QuickDraw PICT File"; else if (auxType == 2) auxText = "Super Hi-Res 3200 color image"; + else + auxText = "Unknown aux: " + auxType; } if (!auxText.isEmpty ()) @@ -454,6 +460,7 @@ public abstract class HiResImage extends AbstractFile int red = ((value >> 8) & 0x0f) * 17; int green = ((value >> 4) & 0x0f) * 17; int blue = (value & 0x0f) * 17; + color = new Color (red, green, blue); } diff --git a/src/com/bytezone/diskbrowser/applefile/SHRPictureFile2.java b/src/com/bytezone/diskbrowser/applefile/SHRPictureFile2.java index 43faf30..d4560ec 100644 --- a/src/com/bytezone/diskbrowser/applefile/SHRPictureFile2.java +++ b/src/com/bytezone/diskbrowser/applefile/SHRPictureFile2.java @@ -26,10 +26,16 @@ public class SHRPictureFile2 extends HiResImage System.out.println ("0xC0 aux 1 not written"); } else - System.out.println ("unknown aux " + auxType); + 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) { scb = new byte[200]; @@ -53,12 +59,13 @@ public class SHRPictureFile2 extends HiResImage } } else - System.out.println ("unknown aux " + auxType); + System.out.println ("C1 unknown aux " + auxType); } else System.out.println ("unknown filetype " + fileType); - createImage (); + if (colorTables != null) + createImage (); } @Override @@ -110,11 +117,12 @@ public class SHRPictureFile2 extends HiResImage text.append ("\n"); } - for (ColorTable colorTable : colorTables) - { - text.append (colorTable); - text.append ("\n\n"); - } + if (colorTables != null) + for (ColorTable colorTable : colorTables) + { + text.append (colorTable); + text.append ("\n\n"); + } text.deleteCharAt (text.length () - 1); text.deleteCharAt (text.length () - 1); diff --git a/src/com/bytezone/diskbrowser/gui/DataPanel.java b/src/com/bytezone/diskbrowser/gui/DataPanel.java index ba04063..5c54876 100755 --- a/src/com/bytezone/diskbrowser/gui/DataPanel.java +++ b/src/com/bytezone/diskbrowser/gui/DataPanel.java @@ -54,7 +54,7 @@ class DataPanel extends JTabbedPane formattedText = new JTextArea (10, TEXT_WIDTH); formattedPane = setPanel (formattedText, "Formatted"); - formattedText.setLineWrap (menuHandler.lineWrapItem.isSelected ()); + formattedText.setLineWrap (prefs.getBoolean (MenuHandler.PREFS_LINE_WRAP, true)); formattedText.setText ("Please use the 'File->Set HOME folder...' command to " + "\ntell DiskBrowser where your Apple disks are located." + "\n\nTo see the contents of a disk in more detail, double-click" diff --git a/src/com/bytezone/diskbrowser/gui/MenuHandler.java b/src/com/bytezone/diskbrowser/gui/MenuHandler.java index 3fa1c19..aede15f 100755 --- a/src/com/bytezone/diskbrowser/gui/MenuHandler.java +++ b/src/com/bytezone/diskbrowser/gui/MenuHandler.java @@ -24,13 +24,13 @@ import com.bytezone.diskbrowser.disk.FormattedDisk; public class MenuHandler implements DiskSelectionListener, FileSelectionListener, QuitListener { - private static final String PREFS_LINE_WRAP = "line wrap"; + static final String PREFS_LINE_WRAP = "line wrap"; private static final String PREFS_SHOW_CATALOG = "show catalog"; private static final String PREFS_SHOW_LAYOUT = "show layout"; private static final String PREFS_SHOW_FREE_SECTORS = "show free sectors"; private static final String PREFS_COLOUR_QUIRKS = "colour quirks"; private static final String PREFS_MONOCHROME = "monochrome"; - private static final String PREFS_DEBUGGING = "debugging"; + // private static final String PREFS_DEBUGGING = "debugging"; private static final String PREFS_PALETTE = "palette"; FormattedDisk currentDisk; diff --git a/src/com/bytezone/diskbrowser/prodos/FileEntry.java b/src/com/bytezone/diskbrowser/prodos/FileEntry.java index 206faef..27b907d 100755 --- a/src/com/bytezone/diskbrowser/prodos/FileEntry.java +++ b/src/com/bytezone/diskbrowser/prodos/FileEntry.java @@ -137,7 +137,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants private void traverseMasterIndex (int keyPtr) { - byte[] buffer = disk.readSector (keyPtr); // master index + byte[] buffer = disk.readSector (keyPtr); // master index // find the last used index block // get the file size from the catalog and only check those blocks int highestBlock = 0; @@ -189,7 +189,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants break; if (block == 0) - dataBlocks.add (null); // allow for sparse image files + dataBlocks.add (null); // allow for sparse image files else { parentDisk.setSectorType (block, parentDisk.dataSector); @@ -200,8 +200,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants private void traverseGEOSMasterIndex (int keyPtr) { - byte[] buffer = disk.readSector (keyPtr); // master index - // int length = HexFormatter.intValue (buffer[0xFF], buffer[0x1FF]); + byte[] buffer = disk.readSector (keyPtr); // master index for (int i = 0; i < 0x80; i++) { int block = HexFormatter.intValue (buffer[i], buffer[i + 256]); @@ -218,7 +217,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants parentDisk.setSectorType (keyPtr, parentDisk.indexSector); indexBlocks.add (disk.getDiskAddress (keyPtr)); byte[] buffer = disk.readSector (keyPtr); - // int length = HexFormatter.intValue (buffer[0xFF], buffer[0x1FF]); + for (int i = 0; i < 0x80; i++) { int block = HexFormatter.intValue (buffer[i], buffer[i + 256]); @@ -589,13 +588,15 @@ class FileEntry extends CatalogEntry implements ProdosConstants @Override public boolean contains (DiskAddress da) { + if (da == null) + return false; if (da.equals (masterIndexBlock)) return true; for (DiskAddress block : indexBlocks) - if (block.matches (da)) + if (da.matches (block)) return true; for (DiskAddress block : dataBlocks) - if (block.matches (da)) + if (da.matches (block)) return true; return false; }