mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2026-04-27 02:17:54 +00:00
Some prep work for 3.5" disks to support T/S reads.
This commit is contained in:
1 parent
0aa8dad20d
commit
79bbaf6a3d
2 files changed
+13
-4
No files matched your search
+2
-2
@@ -33,14 +33,14 @@ public class ProdosOrder extends ImageOrder {
|
||||
/**
|
||||
* This table contains the block offset for a particular DOS sector.
|
||||
*/
|
||||
private static final int[] blockInterleave = {
|
||||
public static final int[] blockInterleave = {
|
||||
0, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 7
|
||||
};
|
||||
/**
|
||||
* Defines the location within a block in which the DOS sector resides.
|
||||
* (0 = 0-255 and 1 = 256-511.)
|
||||
*/
|
||||
private static final int[] blockOffsets = {
|
||||
public static final int[] blockOffsets = {
|
||||
0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1
|
||||
};
|
||||
|
||||
|
||||
+11
-2
@@ -16,6 +16,9 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static com.webcodepro.applecommander.storage.physical.NibbleCodec.readSectorFromTrack;
|
||||
import static com.webcodepro.applecommander.storage.physical.NibbleCodec.readSectorFromTrack35;
|
||||
import static com.webcodepro.applecommander.storage.physical.ProdosOrder.blockInterleave;
|
||||
import static com.webcodepro.applecommander.storage.physical.ProdosOrder.blockOffsets;
|
||||
|
||||
public class WozOrder extends ImageOrder {
|
||||
// The magic bytes are read in little-endian order, so they do appear reversed here.
|
||||
@@ -131,7 +134,7 @@ public class WozOrder extends ImageOrder {
|
||||
public byte[] readBlock35(int block) {
|
||||
DosSectorAddress addr = blockToSector35(block);
|
||||
byte[] trackData = readTrackData(addr.track);
|
||||
return readSectorFromTrack(trackData, addr.track, addr.sector, getSectorsPerTrack());
|
||||
return readSectorFromTrack35(trackData, addr.track, addr.sector, getSectorsPerTrack());
|
||||
}
|
||||
|
||||
public DosSectorAddress blockToSector35(int block) {
|
||||
@@ -187,7 +190,13 @@ public class WozOrder extends ImageOrder {
|
||||
}
|
||||
|
||||
public byte[] readSector35(int track, int sector) throws IllegalArgumentException {
|
||||
throw new RuntimeException("WOZ 3.5\" Disk Image does not support reading DOS track and sectors at this time");
|
||||
int block = track * 8 + blockInterleave[sector];
|
||||
byte[] blockData = readBlock(block);
|
||||
int offset = blockOffsets[sector];
|
||||
byte[] sectorData = new byte[Disk.SECTOR_SIZE];
|
||||
System.arraycopy(blockData, offset * Disk.SECTOR_SIZE,
|
||||
sectorData, 0, Disk.SECTOR_SIZE);
|
||||
return sectorData;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user