Add support for "RDOS 3.3" disk format

Uses 16 sectors, with ProDOS sector ordering.
This commit is contained in:
Bradley Bell 2023-10-14 02:06:46 -07:00
parent 6064b52d41
commit 66cdbe314c
2 changed files with 38 additions and 3 deletions

View File

@ -278,7 +278,7 @@ public class Disk {
rc = 0;
} else {
imageOrder = proDosOrder;
if (knownProDOSOrder || isProdosFormat() || isDosFormat()) {
if (knownProDOSOrder || isProdosFormat() || isDosFormat() || isRdos33Format()) {
rc = 0;
}
}
@ -791,9 +791,20 @@ public class Disk {
if (!is140KbDisk()) return false;
byte[] block = readSector(0, 0x0d);
String id = AppleUtil.getString(block, 0xe0, 4);
return "RDOS".equals(id); //$NON-NLS-1$
return "RDOS".equals(id) || isRdos33Format(); //$NON-NLS-1$
}
/**
* Test the disk format to see if this is a RDOS 33 formatted
* disk.
*/
public boolean isRdos33Format() {
if (!is140KbDisk()) return false;
byte[] block = readSector(1, 0x0);
String id = AppleUtil.getString(block, 0x0, 6);
return "RDOS 3".equals(id); //$NON-NLS-1$
}
/**
* Test the disk format to see if this is a WP formatted
* disk.

View File

@ -30,6 +30,7 @@ import com.webcodepro.applecommander.storage.FileEntry;
import com.webcodepro.applecommander.storage.FormattedDisk;
import com.webcodepro.applecommander.storage.StorageBundle;
import com.webcodepro.applecommander.storage.physical.ImageOrder;
import com.webcodepro.applecommander.storage.physical.ProdosOrder;
import com.webcodepro.applecommander.util.AppleUtil;
import com.webcodepro.applecommander.util.TextBundle;
@ -170,6 +171,24 @@ public class RdosFormatDisk extends FormattedDisk {
writeSector(track, sector, data);
}
/**
* Read the block from the disk image.
*/
public byte[] readBlock(int block) {
int track = block / 16;
int sector = block % 16;
return getImageOrder().readSector(track, sector);
}
/**
* Write the block to the disk image.
*/
public void writeBlock(int block, byte[] data) {
int track = block / 16;
int sector = block % 16;
getImageOrder().writeSector(track, sector, data);
}
/**
* RDOS really does not have a disk name. Fake one.
*/
@ -392,7 +411,12 @@ 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 = readRdosBlock(startingBlock + blockOffset);
byte[] blockData;
if (getImageOrder() instanceof ProdosOrder) {
blockData = readBlock(startingBlock + blockOffset);
} else {
blockData = readRdosBlock(startingBlock + blockOffset);
}
System.arraycopy(blockData, 0, fileData, offset, blockData.length);
offset+= blockData.length;
}