diff --git a/src/com/bytezone/diskbrowser/applefile/DoubleHiResImage.java b/src/com/bytezone/diskbrowser/applefile/DoubleHiResImage.java index 0fcd92f..e7de067 100644 --- a/src/com/bytezone/diskbrowser/applefile/DoubleHiResImage.java +++ b/src/com/bytezone/diskbrowser/applefile/DoubleHiResImage.java @@ -25,7 +25,7 @@ public class DoubleHiResImage extends HiResImage { super (name, buffer); - assert name.endsWith (".PAC") || name.endsWith ("A2FC"); + // assert name.endsWith (".PAC") || name.endsWith ("A2FC"); if (name.endsWith (".PAC")) { @@ -35,17 +35,17 @@ public class DoubleHiResImage extends HiResImage auxBuffer = doubleScrunch.memory[0]; this.buffer = doubleScrunch.memory[1]; } - else if (name.endsWith (".A2FC")) + else //if (name.endsWith (".A2FC") || auxType == 0x2000) { auxBuffer = new byte[0x2000]; this.buffer = new byte[0x2000]; System.arraycopy (buffer, 0, auxBuffer, 0, 0x2000); System.arraycopy (buffer, 0x2000, this.buffer, 0, 0x2000); } - else - { - auxBuffer = null; - } + // else + // { + // auxBuffer = null; + // } createImage (); } diff --git a/src/com/bytezone/diskbrowser/applefile/OriginalHiResImage.java b/src/com/bytezone/diskbrowser/applefile/OriginalHiResImage.java index 6398581..b6b7850 100755 --- a/src/com/bytezone/diskbrowser/applefile/OriginalHiResImage.java +++ b/src/com/bytezone/diskbrowser/applefile/OriginalHiResImage.java @@ -107,7 +107,6 @@ public class OriginalHiResImage extends HiResImage 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 - // palette[colourBit][column]; // coloured pixel - use lookup table colours[paletteTable[colourBit][column]]; // coloured pixel - use lookup table } } diff --git a/src/com/bytezone/diskbrowser/disk/AppleDisk.java b/src/com/bytezone/diskbrowser/disk/AppleDisk.java index ec258b4..87923e9 100755 --- a/src/com/bytezone/diskbrowser/disk/AppleDisk.java +++ b/src/com/bytezone/diskbrowser/disk/AppleDisk.java @@ -503,7 +503,7 @@ public class AppleDisk implements Disk @Override public boolean isValidAddress (DiskAddress da) { - return isValidAddress (da.getTrack (), da.getSector ()); + return da != null && isValidAddress (da.getTrack (), da.getSector ()); } /* diff --git a/src/com/bytezone/diskbrowser/disk/DiskFactory.java b/src/com/bytezone/diskbrowser/disk/DiskFactory.java index e35ba2f..bdcf2d9 100755 --- a/src/com/bytezone/diskbrowser/disk/DiskFactory.java +++ b/src/com/bytezone/diskbrowser/disk/DiskFactory.java @@ -229,14 +229,22 @@ public class DiskFactory if (suffix.equals ("woz")) { - WozDisk wozDisk = new WozDisk (file); - AppleDisk appleDisk256 = new AppleDisk (wozDisk, 35, 16); - disk = checkDos (appleDisk256); - if (disk == null) - disk = checkProdos (new AppleDisk (wozDisk, 35, 8)); - if (disk == null) - disk = new DataDisk (appleDisk256); - return disk; + try + { + WozDisk wozDisk = new WozDisk (file); + AppleDisk appleDisk256 = new AppleDisk (wozDisk, 35, 16); + disk = checkDos (appleDisk256); + if (disk == null) + disk = checkProdos (new AppleDisk (wozDisk, 35, 8)); + if (disk == null) + disk = new DataDisk (appleDisk256); + return disk; + } + catch (Exception e) + { + System.out.println (e); + return null; + } } if (suffix.equals ("v2d")) diff --git a/src/com/bytezone/diskbrowser/disk/SectorList.java b/src/com/bytezone/diskbrowser/disk/SectorList.java index 93f9dc2..7b104f5 100755 --- a/src/com/bytezone/diskbrowser/disk/SectorList.java +++ b/src/com/bytezone/diskbrowser/disk/SectorList.java @@ -22,6 +22,8 @@ public class SectorList extends AbstractFile for (DiskAddress da : sectors) { + if (!disk.isValidAddress (da)) + break; byte[] tempBuffer = disk.readSector (da); System.arraycopy (tempBuffer, 0, buffer, ptr, disk.getBlockSize ()); ptr += disk.getBlockSize (); diff --git a/src/com/bytezone/diskbrowser/disk/WozDisk.java b/src/com/bytezone/diskbrowser/disk/WozDisk.java index a0c8cf9..c6c3040 100644 --- a/src/com/bytezone/diskbrowser/disk/WozDisk.java +++ b/src/com/bytezone/diskbrowser/disk/WozDisk.java @@ -24,20 +24,22 @@ class WozDisk // constructor // ---------------------------------------------------------------------------------// - public WozDisk (File file) + public WozDisk (File file) throws Exception { this.file = file; Nibblizer nibbler = new Nibblizer (); byte[] buffer = readFile (); - assert matches (header, buffer); + if (!matches (header, buffer)) + throw new Exception ("Header error"); int cs1 = readInt (buffer, 8, 4); int cs2 = Utility.crc32 (buffer, 12, 256 - 12 + 35 * TRK_SIZE); if (cs1 != cs2) { - System.out.printf ("Checksum: %08X%n", cs1); - System.out.printf ("Calculat: %08X%n", cs2); + System.out.printf ("Checksum : %08X%n", cs1); + System.out.printf ("Calculated: %08X%n", cs2); + throw new Exception ("Checksum error"); } int ptr = 12; diff --git a/src/com/bytezone/diskbrowser/prodos/FileEntry.java b/src/com/bytezone/diskbrowser/prodos/FileEntry.java index 10ccb7b..d121cec 100755 --- a/src/com/bytezone/diskbrowser/prodos/FileEntry.java +++ b/src/com/bytezone/diskbrowser/prodos/FileEntry.java @@ -293,7 +293,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants else file = new DoubleHiResImage (name, exactBuffer, link.getBuffer ()); } - else if (name.endsWith (".PAC") || name.endsWith (".A2FC")) + else if (name.endsWith (".PAC") || name.endsWith (".A2FC") + || (endOfFile == 0x4000 && auxType == 0x2000)) file = new DoubleHiResImage (name, exactBuffer); else if ((endOfFile == 0x1FF8 || endOfFile == 0x1FFF || endOfFile == 0x2000 || endOfFile == 0x4000)