Tweaking HDV recognition; 5.25" recognition (finding tracks from 35 to 40); and correcting some funny business around PO handling.

This commit is contained in:
Rob Greene
2025-09-06 13:54:03 -05:00
parent 1de20f14ab
commit 48a17e8a93
2 changed files with 13 additions and 18 deletions

View File

@@ -32,7 +32,8 @@ public interface DiskConstants {
int PRODOS_BLOCKS_ON_800KB_DISK = 1600;
int DOS32_SECTORS_ON_115KB_DISK = 455;
int DOS33_SECTORS_ON_140KB_DISK = 560;
int APPLE_140KB_DISK = 143360;
int APPLE_140KB_DISK = 143360; // standard 35 track x 16 sector disk
int APPLE_160KB_DISK = 163840; // largest(?) 5.25" disk of 40 tracks x 16 sectors
int APPLE_13SECTOR_DISK = 116480;
int APPLE_140KB_NIBBLE_DISK = 232960;
int APPLE_400KB_DISK = 409600;

View File

@@ -101,7 +101,7 @@ public interface DiskFactory {
devices.add(new TrackSectorToBlockAdapter(converted, TrackSectorToBlockAdapter.BlockStyle.PRODOS));
}
}
else if (ctx.source.isApproxEQ(DiskConstants.APPLE_140KB_DISK)) {
else if (ctx.source.isApproxBetween(DiskConstants.APPLE_140KB_DISK, DiskConstants.APPLE_160KB_DISK)) {
if (ctx.source.is(Hint.DOS_SECTOR_ORDER) || ctx.source.extensionLike("do")) {
TrackSectorDevice doDevice = new DosOrderedTrackSectorDevice(ctx.source, Hint.DOS_SECTOR_ORDER);
TrackSectorDevice poDevice = SkewedTrackSectorDevice.dosToPascalSkew(doDevice);
@@ -126,7 +126,8 @@ public interface DiskFactory {
return this;
}
public BlockDeviceBuilder includeHDV() {
if (ctx.source.getSize() > DiskConstants.APPLE_800KB_DISK) {
// Anything not a floppy is included -- but if we have a device, assume it was picked up elsewhere...
if (ctx.source.getSize() > DiskConstants.APPLE_140KB_NIBBLE_DISK && devices.isEmpty()) {
devices.add(new ProdosOrderedBlockDevice(ctx.source, BlockDevice.STANDARD_BLOCK_SIZE));
}
return this;
@@ -160,47 +161,40 @@ public interface DiskFactory {
return this;
}
public TrackSectorDeviceBuilder include16Sector(Hint hint) {
assert hint == Hint.DOS_SECTOR_ORDER || hint == Hint.NIBBLE_SECTOR_ORDER;
if (ctx.nibbleTrackReaderWriter != null) {
Optional<TrackSectorDevice> nibble = TrackSectorNibbleDevice.identify(ctx.nibbleTrackReaderWriter);
nibble.ifPresent(device -> {
if (device.getGeometry().sectorsPerTrack() == 16) {
TrackSectorDevice converted = switch (hint) {
case DOS_SECTOR_ORDER -> SkewedTrackSectorDevice.physicalToDosSkew(nibble.get());
case PRODOS_BLOCK_ORDER -> SkewedTrackSectorDevice.physicalToPascalSkew(nibble.get());
case NIBBLE_SECTOR_ORDER -> nibble.get();
default -> throw new RuntimeException("wrong hint type: " + hint);
};
devices.add(converted);
}
});
} else if (ctx.source.isApproxEQ(DiskConstants.APPLE_140KB_DISK)) {
}
else if (ctx.source.isApproxBetween(DiskConstants.APPLE_140KB_DISK, DiskConstants.APPLE_160KB_DISK)) {
TrackSectorDevice doDevice = null;
TrackSectorDevice poDevice = null;
if (ctx.source.is(Hint.DOS_SECTOR_ORDER) || ctx.source.extensionLike("do")) {
doDevice = new DosOrderedTrackSectorDevice(ctx.source, Hint.DOS_SECTOR_ORDER);
}
else if (ctx.source.is(Hint.PRODOS_BLOCK_ORDER) || ctx.source.extensionLike("po")) {
poDevice = new DosOrderedTrackSectorDevice(ctx.source, Hint.PRODOS_BLOCK_ORDER);
BlockDevice blockDevice = new ProdosOrderedBlockDevice(ctx.source, BlockDevice.STANDARD_BLOCK_SIZE);
poDevice = new BlockToTrackSectorAdapter(blockDevice, new ProdosBlockToTrackSectorAdapterStrategy());
}
else {
doDevice = new DosOrderedTrackSectorDevice(ctx.source, Hint.DOS_SECTOR_ORDER);
poDevice = new DosOrderedTrackSectorDevice(ctx.source, Hint.PRODOS_BLOCK_ORDER);
BlockDevice blockDevice = new ProdosOrderedBlockDevice(ctx.source, BlockDevice.STANDARD_BLOCK_SIZE);
poDevice = new BlockToTrackSectorAdapter(blockDevice, new ProdosBlockToTrackSectorAdapterStrategy());
}
switch (hint) {
case DOS_SECTOR_ORDER -> {
if (doDevice != null) {
devices.add(doDevice);
}
if (poDevice != null) {
TrackSectorDevice tmp = SkewedTrackSectorDevice.pascalToPhysicalSkew(poDevice);
devices.add(SkewedTrackSectorDevice.physicalToDosSkew(tmp));
}
}
case PRODOS_BLOCK_ORDER -> {
if (doDevice != null) {
TrackSectorDevice tmp = SkewedTrackSectorDevice.dosToPhysicalSkew(doDevice);
devices.add(SkewedTrackSectorDevice.physicalToPascalSkew(tmp));
}
if (poDevice != null) {
devices.add(poDevice);
}
@@ -210,7 +204,7 @@ public interface DiskFactory {
devices.add(SkewedTrackSectorDevice.dosToPhysicalSkew(doDevice));
}
if (poDevice != null) {
devices.add(SkewedTrackSectorDevice.pascalToPhysicalSkew(poDevice));
devices.add(SkewedTrackSectorDevice.dosToPhysicalSkew(poDevice));
}
}
}