diff --git a/src/com/bytezone/diskbrowser/disk/AbstractFormattedDisk.java b/src/com/bytezone/diskbrowser/disk/AbstractFormattedDisk.java index ef0f607..ff3c7ed 100755 --- a/src/com/bytezone/diskbrowser/disk/AbstractFormattedDisk.java +++ b/src/com/bytezone/diskbrowser/disk/AbstractFormattedDisk.java @@ -31,8 +31,8 @@ public abstract class AbstractFormattedDisk implements FormattedDisk protected JTree catalogTree; protected Path originalPath; - protected List sectorTypesList = new ArrayList (); - protected List fileEntries = new ArrayList (); + protected List sectorTypesList = new ArrayList<> (); + protected List fileEntries = new ArrayList<> (); public SectorType[] sectorTypes; @@ -113,6 +113,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk private void setGridLayout () { int totalBlocks = disk.getTotalBlocks (); + switch (totalBlocks) { case 280: @@ -132,7 +133,10 @@ public abstract class AbstractFormattedDisk implements FormattedDisk break; case 1600: - gridLayout = new Dimension (16, 100); + if (disk.getSectorsPerTrack () == 32) + gridLayout = new Dimension (32, 50); + else + gridLayout = new Dimension (16, 100); break; case 2048: diff --git a/src/com/bytezone/diskbrowser/disk/AppleDisk.java b/src/com/bytezone/diskbrowser/disk/AppleDisk.java index 494976b..8745d5d 100755 --- a/src/com/bytezone/diskbrowser/disk/AppleDisk.java +++ b/src/com/bytezone/diskbrowser/disk/AppleDisk.java @@ -39,7 +39,8 @@ public class AppleDisk implements Disk private int interleave = 0; private static int[][] interleaveSector = // - { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, // None + { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }, // None { 0, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15 }, // Prodos/Pascal { 0, 13, 11, 9, 7, 5, 3, 1, 14, 12, 10, 8, 6, 4, 2, 15 }, // Infocom { 0, 6, 12, 3, 9, 15, 14, 5, 11, 2, 8, 7, 13, 4, 10, 1 } }; // CPM @@ -83,7 +84,7 @@ public class AppleDisk implements Disk private WozFile wozFile; - private final boolean debug = false; + private final boolean debug = true; public AppleDisk (File file, int tracks, int sectors) throws FileFormatException { @@ -170,6 +171,12 @@ public class AppleDisk implements Disk this.sectorSize = 512; this.trackSize = sectors * sectorSize; } + else if (file.length () == 819200 && tracks == 50 && sectors == 32) // unidisk + { + this.blocks = tracks * sectors; + this.sectorSize = 256; + this.trackSize = sectors * sectorSize; + } else { this.blocks = tracks * sectors; @@ -316,12 +323,12 @@ public class AppleDisk implements Disk for (DiskAddress da : this) // uses blockList.iterator { - if (sectorSize == SECTOR_SIZE) + if (sectorSize == SECTOR_SIZE) // 256 byte sectors { int diskOffset = getBufferOffset (da); hasData[da.getBlock ()] = check (diskOffset); } - else + else // 512 byte blocks { int diskOffset1 = getBufferOffset (da, 0); int diskOffset2 = getBufferOffset (da, 1); diff --git a/src/com/bytezone/diskbrowser/disk/DiskFactory.java b/src/com/bytezone/diskbrowser/disk/DiskFactory.java index b55d042..a377e7e 100755 --- a/src/com/bytezone/diskbrowser/disk/DiskFactory.java +++ b/src/com/bytezone/diskbrowser/disk/DiskFactory.java @@ -201,6 +201,16 @@ public class DiskFactory return disk; } + if (file.length () == 819200) + { + if (debug) + System.out.println ("UniDos ?"); + // 2 x 400k disk images + AppleDisk appleDisk = new AppleDisk (file, 50, 32); + disk = checkUnidos (appleDisk); + return disk == null ? new DataDisk (appleDisk) : disk; + } + if (debug) System.out.println (" Checking po or dsk hard drive: " + file.length ()); @@ -520,6 +530,29 @@ public class DiskFactory return null; } + private static DosDisk checkUnidos (AppleDisk disk) + { + if (debug) + System.out.println ("Checking UniDOS disk"); + + try + { + if (DosDisk.isCorrectFormat (disk)) + { + if (debug) + System.out.println (" --> UniDOS"); + return new DosDisk (disk); + } + } + catch (Exception e) + { + e.printStackTrace (); + } + if (debug) + System.out.println (" not a UniDOS disk"); + return null; + } + private static FormattedDisk checkHardDisk (File file) { if (debug) diff --git a/src/com/bytezone/diskbrowser/dos/DosDisk.java b/src/com/bytezone/diskbrowser/dos/DosDisk.java index 2a0d42c..1e27af1 100755 --- a/src/com/bytezone/diskbrowser/dos/DosDisk.java +++ b/src/com/bytezone/diskbrowser/dos/DosDisk.java @@ -235,30 +235,34 @@ public class DosDisk extends AbstractFormattedDisk { disk.setInterleave (0); int catalogBlocks = checkFormat (disk); + System.out.printf ("Catalog blocks: %d%n", catalogBlocks); if (catalogBlocks > 3) return true; - disk.setInterleave (1); - int cb2 = checkFormat (disk); - // if (cb2 > catalogBlocks) - if (cb2 > 3) - return true; - disk.setInterleave (2); - if (true) - { - int cb3 = checkFormat (disk); - if (cb3 > 3) - return true; - } - if (catalogBlocks > 0) + if (disk.getSectorsPerTrack () <= 16) { disk.setInterleave (1); - return true; - } + int cb2 = checkFormat (disk); + if (cb2 > 3) + return true; + disk.setInterleave (2); + if (true) + { + int cb3 = checkFormat (disk); + if (cb3 > 3) + return true; + } - if (cb2 > 0) - return true; + if (catalogBlocks > 0) + { + disk.setInterleave (1); + return true; + } + + if (cb2 > 0) + return true; + } return false; } @@ -297,7 +301,7 @@ public class DosDisk extends AbstractFormattedDisk // if (buffer[1] != 0x11) // first catalog track // return 0; - if (buffer[53] != 16 && buffer[53] != 13) // sectors per track + if (buffer[53] != 16 && buffer[53] != 13 && buffer[53] != 32) // sectors per track { return 0; } @@ -322,9 +326,8 @@ public class DosDisk extends AbstractFormattedDisk private static int countCatalogBlocks (AppleDisk disk, byte[] buffer) { DiskAddress catalogStart = disk.getDiskAddress (buffer[1], buffer[2]); - // int catalogBlocks = 0; DiskAddress da = disk.getDiskAddress (catalogStart.getBlock ()); - List catalogAddresses = new ArrayList (); + List catalogAddresses = new ArrayList<> (); do { @@ -339,10 +342,7 @@ public class DosDisk extends AbstractFormattedDisk buffer = disk.readSector (da); if (!disk.isValidAddress (buffer[1], buffer[2])) - { - // System.out.printf ("Invalid address : %02X / %02X%n", buffer[1], buffer[2]); return 0; - } catalogAddresses.add (da);