From 269a1bbd831621a6100101250b12b13bcea94ffb Mon Sep 17 00:00:00 2001 From: Denis Molony Date: Thu, 6 May 2021 21:30:23 +1000 Subject: [PATCH] show NuFX contents on disk file display --- .../bytezone/diskbrowser/disk/AppleDisk.java | 17 +++++ .../diskbrowser/disk/DefaultDataSource.java | 1 - .../diskbrowser/disk/DiskFactory.java | 18 ++++- .../bytezone/diskbrowser/utilities/NuFX.java | 67 ++++++++----------- 4 files changed, 60 insertions(+), 43 deletions(-) diff --git a/src/com/bytezone/diskbrowser/disk/AppleDisk.java b/src/com/bytezone/diskbrowser/disk/AppleDisk.java index ff4daea..63f67aa 100755 --- a/src/com/bytezone/diskbrowser/disk/AppleDisk.java +++ b/src/com/bytezone/diskbrowser/disk/AppleDisk.java @@ -18,6 +18,7 @@ import com.bytezone.diskbrowser.nib.NibFile; import com.bytezone.diskbrowser.nib.V2dFile; import com.bytezone.diskbrowser.nib.WozFile; import com.bytezone.diskbrowser.utilities.FileFormatException; +import com.bytezone.diskbrowser.utilities.NuFX; // -----------------------------------------------------------------------------------// public class AppleDisk implements Disk @@ -37,6 +38,7 @@ public class AppleDisk implements Disk private final int trackSize; // 4096 public int sectorSize; // 256 or 512 + private NuFX nuFX; private int interleave = 0; private static int[][] interleaveSector = // @@ -232,6 +234,15 @@ public class AppleDisk implements Disk checkSectorsForData (); } + // ---------------------------------------------------------------------------------// + public AppleDisk (File file, int tracks, int sectors, NuFX nufx) + throws FileFormatException + // ---------------------------------------------------------------------------------// + { + this (file, tracks, sectors); + this.nuFX = nufx; + } + // ---------------------------------------------------------------------------------// public AppleDisk (V2dFile disk, int tracks, int sectors) // ---------------------------------------------------------------------------------// @@ -731,6 +742,12 @@ public class AppleDisk implements Disk text.append (wozFile); } + if (nuFX != null) + { + text.append ("\n\n"); + text.append (nuFX); + } + return text.toString (); } diff --git a/src/com/bytezone/diskbrowser/disk/DefaultDataSource.java b/src/com/bytezone/diskbrowser/disk/DefaultDataSource.java index 07e1002..f9af439 100755 --- a/src/com/bytezone/diskbrowser/disk/DefaultDataSource.java +++ b/src/com/bytezone/diskbrowser/disk/DefaultDataSource.java @@ -61,7 +61,6 @@ public class DefaultDataSource implements DataSource public JComponent getComponent () // ---------------------------------------------------------------------------------// { - System.out.println ("In DefaultDataSource.getComponent()"); JPanel panel = new JPanel (); return panel; } diff --git a/src/com/bytezone/diskbrowser/disk/DiskFactory.java b/src/com/bytezone/diskbrowser/disk/DiskFactory.java index a7f8ad3..5fa003c 100755 --- a/src/com/bytezone/diskbrowser/disk/DiskFactory.java +++ b/src/com/bytezone/diskbrowser/disk/DiskFactory.java @@ -35,6 +35,8 @@ public class DiskFactory private static final int DISK_143K = 143360; private static final int DISK_116K = 116480; + private static NuFX nuFX; + // ---------------------------------------------------------------------------------// private DiskFactory () // ---------------------------------------------------------------------------------// @@ -143,7 +145,7 @@ public class DiskFactory System.out.println (" ** sdk/shk/bxy **"); try { - NuFX nuFX = new NuFX (file.toPath ()); + nuFX = new NuFX (file.toPath ()); if (nuFX.getTotalDisks () == 0 && nuFX.getTotalFiles () == 0) return null; @@ -364,7 +366,12 @@ public class DiskFactory } AppleDisk appleDisk256 = new AppleDisk (file, 35, 16); - AppleDisk appleDisk512 = new AppleDisk (file, 35, 8); + AppleDisk appleDisk512; + + if (nuFX == null) + appleDisk512 = new AppleDisk (file, 35, 8); + else + appleDisk512 = new AppleDisk (file, 35, 8, nuFX); if (true) { @@ -634,7 +641,12 @@ public class DiskFactory { System.out.println ("*** extended ***"); // System Addons.hdv } - AppleDisk disk = new AppleDisk (file, tracks, 8); + AppleDisk disk; + if (nuFX == null) + disk = new AppleDisk (file, tracks, 8); + else + disk = new AppleDisk (file, tracks, 8, nuFX); + if (ProdosDisk.isCorrectFormat (disk)) { if (debug) diff --git a/src/com/bytezone/diskbrowser/utilities/NuFX.java b/src/com/bytezone/diskbrowser/utilities/NuFX.java index 30d089a..096ae77 100644 --- a/src/com/bytezone/diskbrowser/utilities/NuFX.java +++ b/src/com/bytezone/diskbrowser/utilities/NuFX.java @@ -78,37 +78,6 @@ public class NuFX if (record.hasDisk ()) ++totalDisks; } - - // printSummary (); - } - - // ---------------------------------------------------------------------------------// - void printSummary () - // ---------------------------------------------------------------------------------// - { - System.out.printf (" %s Created:%s Mod:%s Recs:%5d%n%n", - volumeName.getFileName (), masterHeader.getCreated2 (), - masterHeader.getModified2 (), masterHeader.getTotalRecords ()); - System.out.println (" Name Type Auxtyp Archived" - + " Fmat Size Un-Length"); - System.out.println (UNDERLINE); - - int totalUncompressedSize = 0; - int totalCompressedSize = 0; - - for (Record record : records) - { - System.out.println (record.getLine ()); - totalUncompressedSize += record.getUncompressedSize (); - totalCompressedSize += record.getCompressedSize (); - } - System.out.println (UNDERLINE); - - float pct = 0; - if (totalUncompressedSize > 0) - pct = totalCompressedSize * 100 / totalUncompressedSize; - System.out.printf (" Uncomp:%7d Comp:%7d %%of orig:%3.0f%%%n%n", - totalUncompressedSize, totalCompressedSize, pct); } // ---------------------------------------------------------------------------------// @@ -274,12 +243,35 @@ public class NuFX public String toString () // ---------------------------------------------------------------------------------// { - for (Record record : records) - for (Thread thread : record.threads) - if (thread.hasDisk ()) - return thread.toString (); + StringBuilder text = new StringBuilder (); - return "no disk"; + text.append (String.format (" %s Created:%s Mod:%s Recs:%5d%n%n", + volumeName.getFileName (), masterHeader.getCreated2 (), + masterHeader.getModified2 (), masterHeader.getTotalRecords ())); + + text.append (" Name Type Auxtyp Archived" + + " Fmat Size Un-Length\n"); + + text.append (String.format ("%s%n", UNDERLINE)); + + int totalUncompressedSize = 0; + int totalCompressedSize = 0; + + for (Record record : records) + { + text.append (String.format ("%s%n", record.getLine ())); + totalUncompressedSize += record.getUncompressedSize (); + totalCompressedSize += record.getCompressedSize (); + } + text.append (String.format ("%s%n", UNDERLINE)); + + float pct = 0; + if (totalUncompressedSize > 0) + pct = totalCompressedSize * 100 / totalUncompressedSize; + text.append (String.format (" Uncomp:%7d Comp:%7d %%of orig:%3.0f%%%n%n", + totalUncompressedSize, totalCompressedSize, pct)); + + return text.toString (); } // ---------------------------------------------------------------------------------// @@ -343,9 +335,6 @@ public class NuFX private String getVolumeName () // -------------------------------------------------------------------------------// { - // if (true) - // return volumeName; - if (rootContainsFiles) return volumeName;