diff --git a/lib/ac-api/src/main/java/com/webcodepro/applecommander/storage/os/rdos/RdosFormatDisk.java b/lib/ac-api/src/main/java/com/webcodepro/applecommander/storage/os/rdos/RdosFormatDisk.java index a1bd45a..8c9a03b 100644 --- a/lib/ac-api/src/main/java/com/webcodepro/applecommander/storage/os/rdos/RdosFormatDisk.java +++ b/lib/ac-api/src/main/java/com/webcodepro/applecommander/storage/os/rdos/RdosFormatDisk.java @@ -67,15 +67,38 @@ public class RdosFormatDisk extends FormattedDisk { */ public static final int ENTRY_LENGTH = 0x20; /** - * Specifies the number of blocks on the disk. + * Specifies the number of tracks on the disk. * RDOS apparantly only worked on 5.25" disks. */ - public static final int BLOCKS_ON_DISK = 455; + public static final int TRACKS_ON_DISK = 35; + /** + * Number of sectors used by catalog. + * FIXME: some sources say 10, others say 11. RDOS 3.3 may support 16. + */ + public static final int CATALOG_SECTORS = 10; /** * The known filetypes for a RDOS disk. */ public static final String[] filetypes = { "B", "A", "T" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + /** + * 13 sectors for RDOS 2.1/3.2, native sectoring (16) for RDOS 3.3 + */ + private int SectorsPerTrack() { + if (getImageOrder() instanceof ProdosOrder) { + return getImageOrder().getSectorsPerTrack(); + } else { + return 13; + } + } + + /** + * 455 blocks for RDOS 2.1/3.2, 560 for RDOS 3.3 + */ + private int BlocksOnDisk() { + return TRACKS_ON_DISK * SectorsPerTrack(); + } + /** * Use this inner interface for managing the disk usage data. * This off-loads format-specific implementation to the implementing class. @@ -94,13 +117,13 @@ public class RdosFormatDisk extends FormattedDisk { private int location = -1; private BitSet bitmap = null; public boolean hasNext() { - return location == -1 || location < BLOCKS_ON_DISK - 1; + return location == -1 || location < BlocksOnDisk() - 1; } public void next() { if (bitmap == null) { - bitmap = new BitSet(BLOCKS_ON_DISK); + bitmap = new BitSet(BlocksOnDisk()); // mark all blocks as unused - for (int b=0; b16 sector conversion */ + byte[] block = readRdosBlock(4); + return AppleUtil.getString(block, 0xe0, 0x20); + } else { + /* Use the name of the OS (catalog entry zero) */ byte[] block = readSector(1, 0x0); return AppleUtil.getString(block, 0x0, 0x18); } - byte[] block = readRdosBlock(4); - return AppleUtil.getString(block, 0xe0, 0x20); } /** @@ -206,8 +222,8 @@ public class RdosFormatDisk extends FormattedDisk { */ public List getFiles() { List files = new ArrayList<>(); - for (int b=13; b<23; b++) { - byte[] data = readRdosBlock(b); + for (int b=0; b getDiskInformation() { List list = super.getDiskInformation(); - list.add(new DiskInformation(textBundle.get("TotalBlocks"), BLOCKS_ON_DISK)); //$NON-NLS-1$ + list.add(new DiskInformation(textBundle.get("TotalBlocks"), BlocksOnDisk())); //$NON-NLS-1$ list.add(new DiskInformation(textBundle.get("FreeBlocks"), getFreeBlocks())); //$NON-NLS-1$ list.add(new DiskInformation(textBundle.get("UsedBlocks"), getUsedBlocks())); //$NON-NLS-1$ return list; @@ -418,12 +435,7 @@ public class RdosFormatDisk extends FormattedDisk { byte[] fileData = new byte[rdosEntry.getSizeInBlocks() * SECTOR_SIZE]; int offset = 0; for (int blockOffset = 0; blockOffset < rdosEntry.getSizeInBlocks(); blockOffset++) { - byte[] blockData; - if (getImageOrder() instanceof ProdosOrder) { - blockData = readBlock(startingBlock + blockOffset); - } else { - blockData = readRdosBlock(startingBlock + blockOffset); - } + byte[] blockData = readRdosBlock(startingBlock + blockOffset); System.arraycopy(blockData, 0, fileData, offset, blockData.length); offset+= blockData.length; }