diff --git a/src/com/bytezone/diskbrowser/applefile/ProdosDirectory.java b/src/com/bytezone/diskbrowser/applefile/ProdosDirectory.java index 3eee24b..6a28844 100755 --- a/src/com/bytezone/diskbrowser/applefile/ProdosDirectory.java +++ b/src/com/bytezone/diskbrowser/applefile/ProdosDirectory.java @@ -148,9 +148,10 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants subType = ""; } - text.append (String.format ("%s%-15s %3s %5d %9s %5s %9s %5s %8d %7s%n", - locked, filename, ProdosConstants.fileTypes[type], blocks, dateM, timeM, - dateC, timeC, eof, subType)); + String forkFlag = storageType == 5 ? "+" : " "; + text.append (String.format ("%s%-15s %3s%s %5d %9s %5s %9s %5s %8d %7s%n", + locked, filename, ProdosConstants.fileTypes[type], forkFlag, blocks, dateM, + timeM, dateC, timeC, eof, subType)); break; default: diff --git a/src/com/bytezone/diskbrowser/disk/AppleDisk.java b/src/com/bytezone/diskbrowser/disk/AppleDisk.java index 207c5f7..3bede4a 100755 --- a/src/com/bytezone/diskbrowser/disk/AppleDisk.java +++ b/src/com/bytezone/diskbrowser/disk/AppleDisk.java @@ -121,8 +121,8 @@ public class AppleDisk implements Disk if (debug) System.out.println (prefix2mg); - if (prefix2mg.diskData > 0) - this.blocks = prefix2mg.diskData / 4096 * 8; // reduce blocks to a multiple of 8 + if (prefix2mg.length > 0) + this.blocks = prefix2mg.length / 4096 * 8; // reduce blocks to a multiple of 8 this.sectorSize = 512; this.trackSize = 8 * sectorSize; diff --git a/src/com/bytezone/diskbrowser/disk/DiskFactory.java b/src/com/bytezone/diskbrowser/disk/DiskFactory.java index 4f074f4..1abb82f 100755 --- a/src/com/bytezone/diskbrowser/disk/DiskFactory.java +++ b/src/com/bytezone/diskbrowser/disk/DiskFactory.java @@ -175,6 +175,7 @@ public class DiskFactory } catch (Exception e) { + // e.printStackTrace (); System.out.println (e.getMessage ()); System.out.printf ("Error unpacking: %s%n", file.getAbsolutePath ()); return null; diff --git a/src/com/bytezone/diskbrowser/disk/Prefix2mg.java b/src/com/bytezone/diskbrowser/disk/Prefix2mg.java index 6671d9e..c55ddd3 100644 --- a/src/com/bytezone/diskbrowser/disk/Prefix2mg.java +++ b/src/com/bytezone/diskbrowser/disk/Prefix2mg.java @@ -7,13 +7,22 @@ import com.bytezone.diskbrowser.utilities.Utility; public class Prefix2mg // -----------------------------------------------------------------------------------// { + String[] creators = { "!nfc", "B2TR", "CTKG", "CdrP", "ShIm", "WOOF", "XGS!" }; + String[] images = { "Dos3.3", "Prodos", "Nibbized" }; + String prefix; String creator; int headerSize; int version; - byte format; - int diskData; + int format; + int flags; + int length; int blocks; + int offset; + int commentOffset; + int commentLength; + int creatorOffset; + int creatorLength; // ---------------------------------------------------------------------------------// public Prefix2mg (byte[] buffer) @@ -21,14 +30,20 @@ public class Prefix2mg { prefix = new String (buffer, 0, 4); creator = new String (buffer, 4, 4); - headerSize = Utility.getWord (buffer, 8); - version = Utility.getWord (buffer, 10); - format = buffer[12]; - - diskData = Utility.getLong (buffer, 28); - blocks = Utility.intValue (buffer[20], buffer[21]); // 1600 + headerSize = Utility.getWord (buffer, 0x08); + version = Utility.getWord (buffer, 0x0A); + format = Utility.getLong (buffer, 0x0C); + flags = Utility.getLong (buffer, 0x10); + blocks = Utility.getLong (buffer, 0x14); // 1600 + offset = Utility.getLong (buffer, 0x18); + length = Utility.getLong (buffer, 0x1C); + commentOffset = Utility.getLong (buffer, 0x20); + commentLength = Utility.getLong (buffer, 0x24); + creatorOffset = Utility.getLong (buffer, 0x28); + creatorLength = Utility.getLong (buffer, 0x2C); // see /Asimov disks/images/gs/os/prodos16/ProDOS 16v1_3.2mg + System.out.println (this); } // ---------------------------------------------------------------------------------// @@ -38,14 +53,19 @@ public class Prefix2mg { StringBuilder text = new StringBuilder (); - text.append (String.format ("Prefix : %s%n", prefix)); - text.append (String.format ("Creator : %s%n", creator)); - text.append (String.format ("Header : %d%n", headerSize)); - text.append (String.format ("Version : %d%n", version)); - text.append (String.format ("Format : %02X%n", format)); - - text.append (String.format ("Data size : %08X (%<,d)%n", diskData)); - text.append (String.format ("Blocks : %,d%n", blocks)); + text.append (String.format ("Prefix : %s%n", prefix)); + text.append (String.format ("Creator : %s%n", creator)); + text.append (String.format ("Header : %d%n", headerSize)); + text.append (String.format ("Version : %d%n", version)); + text.append (String.format ("Format : %02X%n", format)); + text.append (String.format ("Flags : %,d%n", flags)); + text.append (String.format ("Blocks : %,d%n", blocks)); + text.append (String.format ("Offset : %,d%n", offset)); + text.append (String.format ("Length : %08X (%<,d)%n", length)); + text.append (String.format ("Comment Offset : %,d%n", commentOffset)); + text.append (String.format ("Comment Length : %08X (%<,d)%n", commentLength)); + text.append (String.format ("Creator Offset : %,d%n", creatorOffset)); + text.append (String.format ("Creator Length : %08X (%<,d)", creatorLength)); return text.toString (); } diff --git a/src/com/bytezone/diskbrowser/gui/FontFrame.java b/src/com/bytezone/diskbrowser/gui/FontFrame.java index 69bf34e..05d18b5 100644 --- a/src/com/bytezone/diskbrowser/gui/FontFrame.java +++ b/src/com/bytezone/diskbrowser/gui/FontFrame.java @@ -130,14 +130,17 @@ public class FontFrame extends JFrame { String fonts[] = GraphicsEnvironment.getLocalGraphicsEnvironment ().getAvailableFontFamilyNames (); + // for (String font : fonts) + // System.out.println (font); String pf[] = - { "Andale Mono", "Anonymous Pro", "Anonymous Pro Minus", "Apple2Forever", - "Apple2Forever80", "Consolas", "Bitstream Vera Sans Mono", "Consolas", - "Courier", "Courier New", "DejaVu Sans Mono", "Envy Code R", "Inconsolata", - "Input Mono", "Input Mono Narrow", "Iosevka", "Lucida Sans Typewriter", - "Luculent", "Menlo", "Monaco", "monofur", "Monospaced", "Nimbus Mono L", - "PCMyungjo", "PR Number 3", "Pragmata", "Print Char 21", "ProFont", "ProFontX", - "Proggy", "PT Mono", "Source Code Pro", "Ubuntu Mono" }; + { "Andale Mono", "Anonymous Pro", "Anonymous Pro Minus", "Apple II Display Pro", + "Apple II Pro", "Apple2Forever", "Apple2Forever80", "Bitstream Vera Sans Mono", + "Consolas", "Courier", "Courier New", "DejaVu Sans Mono", "Envy Code R", + "Inconsolata", "Input Mono", "Input Mono Narrow", "Iosevka", + "Lucida Sans Typewriter", "Luculent", "Menlo", "Monaco", "monofur", + "Monospaced", "Nimbus Mono L", "PCMyungjo", "PR Number 3", "Pragmata", + "Print Char 21", "ProFont", "ProFontX", "Proggy", "PT Mono", "Source Code Pro", + "Ubuntu Mono" }; DefaultListModel lm = (DefaultListModel) fontList.getModel (); diff --git a/src/com/bytezone/diskbrowser/prodos/write/FileWriter.java b/src/com/bytezone/diskbrowser/prodos/write/FileWriter.java index 0c53745..ab64066 100644 --- a/src/com/bytezone/diskbrowser/prodos/write/FileWriter.java +++ b/src/com/bytezone/diskbrowser/prodos/write/FileWriter.java @@ -30,23 +30,23 @@ public class FileWriter void writeFile (byte[] dataBuffer, int eof) throws DiskFullException // ---------------------------------------------------------------------------------// { - this.eof = eof; + this.eof = Math.min (eof, dataBuffer.length); int dataPtr = 0; - int remaining = eof; + int remaining = this.eof; - while (dataPtr < eof) + while (dataPtr < this.eof) { int actualBlockNo = allocateNextBlock (); map (dataPtr / BLOCK_SIZE, actualBlockNo); int bufferPtr = actualBlockNo * BLOCK_SIZE; - int tfr = Math.min (remaining, BLOCK_SIZE); + int transfer = Math.min (remaining, BLOCK_SIZE); - System.arraycopy (dataBuffer, dataPtr, disk.getBuffer (), bufferPtr, tfr); + System.arraycopy (dataBuffer, dataPtr, disk.getBuffer (), bufferPtr, transfer); - dataPtr += BLOCK_SIZE; - remaining -= BLOCK_SIZE; + dataPtr += transfer; + remaining -= transfer; } writeIndices (); @@ -103,13 +103,13 @@ public class FileWriter switch (storageType) { case TREE: - actualBlockNo = - masterIndexBlock.get (logicalBlockNo / 256).get (logicalBlockNo % 256); + actualBlockNo = masterIndexBlock.get (logicalBlockNo / 0x100) + .getPosition (logicalBlockNo % 0x100); break; case SAPLING: - if (logicalBlockNo < 256) - actualBlockNo = indexBlock.get (logicalBlockNo); + if (logicalBlockNo < 0x100) + actualBlockNo = indexBlock.getPosition (logicalBlockNo); break; case SEEDLING: @@ -141,7 +141,7 @@ public class FileWriter private void map (int logicalBlockNo, int actualBlockNo) throws DiskFullException // ---------------------------------------------------------------------------------// { - if (logicalBlockNo > 255) // potential TREE + if (logicalBlockNo >= 0x100) // potential TREE { if (storageType != TREE) { @@ -204,7 +204,7 @@ public class FileWriter } } else - System.out.println ("Error"); + System.out.println ("Error: " + logicalBlockNo); } // ---------------------------------------------------------------------------------// diff --git a/src/com/bytezone/diskbrowser/prodos/write/IndexBlock.java b/src/com/bytezone/diskbrowser/prodos/write/IndexBlock.java index 11fab31..ebbbcae 100644 --- a/src/com/bytezone/diskbrowser/prodos/write/IndexBlock.java +++ b/src/com/bytezone/diskbrowser/prodos/write/IndexBlock.java @@ -28,7 +28,7 @@ public class IndexBlock } // ---------------------------------------------------------------------------------// - int get (int position) + int getPosition (int position) // ---------------------------------------------------------------------------------// { return blocks[position]; diff --git a/src/com/bytezone/diskbrowser/prodos/write/ProdosDisk.java b/src/com/bytezone/diskbrowser/prodos/write/ProdosDisk.java index 8c1eee8..5400353 100644 --- a/src/com/bytezone/diskbrowser/prodos/write/ProdosDisk.java +++ b/src/com/bytezone/diskbrowser/prodos/write/ProdosDisk.java @@ -222,8 +222,7 @@ public class ProdosDisk fileEntry.keyPointer = blockNo; // extended key block fileEntry.storageType = 0x05; // extended fileEntry.blocksUsed += fileWriter.blocksUsed + 1; - - // fileEntry.eof ?? + fileEntry.eof = BLOCK_SIZE; fileEntry.write (); extendedKeyBlock.write (); diff --git a/src/com/bytezone/diskbrowser/utilities/MasterHeader.java b/src/com/bytezone/diskbrowser/utilities/MasterHeader.java index df6dc27..a758cd6 100644 --- a/src/com/bytezone/diskbrowser/utilities/MasterHeader.java +++ b/src/com/bytezone/diskbrowser/utilities/MasterHeader.java @@ -29,6 +29,13 @@ class MasterHeader { if (Utility.isMagic (buffer, ptr, NuFile)) break; + if (Utility.isMagic (buffer, 0x2000, NuFile)) + { + System.out.println ("found it"); + ptr = 0x2000; + bin2 = true; + break; + } if (isBin2 (buffer, ptr)) {