mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2026-01-22 17:16:11 +00:00
Adding support for D13/D16 disks.
This commit is contained in:
@@ -33,6 +33,7 @@ public interface DiskConstants {
|
||||
int DOS32_SECTORS_ON_115KB_DISK = 455;
|
||||
int DOS33_SECTORS_ON_140KB_DISK = 560;
|
||||
int APPLE_140KB_DISK = 143360;
|
||||
int APPLE_13SECTOR_DISK = 116480;
|
||||
int APPLE_140KB_NIBBLE_DISK = 232960;
|
||||
int APPLE_400KB_DISK = 409600;
|
||||
int APPLE_800KB_DISK = 819200;
|
||||
|
||||
@@ -194,6 +194,9 @@ public interface DiskFactory {
|
||||
devices.add(nibble);
|
||||
}
|
||||
}
|
||||
else if (ctx.source.isApproxEQ(DiskConstants.APPLE_13SECTOR_DISK)) {
|
||||
devices.add(new DosOrderedTrackSectorDevice(ctx.source));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public TrackSectorDeviceBuilder include16Sector(Hint hint) {
|
||||
|
||||
@@ -55,7 +55,8 @@ public class FilenameFilter {
|
||||
static {
|
||||
// Build everything dynamically
|
||||
List<String> templates = List.of(
|
||||
"140kDosImages:do,dsk",
|
||||
"16SectorDosImages:do,d16,dsk",
|
||||
"13SectorDosImages:d13",
|
||||
"140kProdosImages:po",
|
||||
"140kNibbleImages:nib",
|
||||
"800kProdosImages:2mg,2img",
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
package org.applecommander.device;
|
||||
|
||||
import com.webcodepro.applecommander.storage.DiskConstants;
|
||||
import org.applecommander.capability.Capability;
|
||||
import org.applecommander.hint.Hint;
|
||||
import org.applecommander.source.Source;
|
||||
@@ -34,14 +35,24 @@ public class DosOrderedTrackSectorDevice implements TrackSectorDevice {
|
||||
|
||||
public DosOrderedTrackSectorDevice(Source source) {
|
||||
this.source = source;
|
||||
this.geometry = new Geometry(35, 16); // assumed for now?
|
||||
this.geometry = calculateGeometry(source);
|
||||
this.orderHint = null;
|
||||
}
|
||||
public DosOrderedTrackSectorDevice(Source source, Hint orderHint) {
|
||||
this.source = source;
|
||||
this.geometry = new Geometry(35, 16); // assumed for now?
|
||||
this.geometry = calculateGeometry(source);
|
||||
this.orderHint = orderHint;
|
||||
}
|
||||
private static Geometry calculateGeometry(Source source) {
|
||||
if (source.isApproxEQ(DiskConstants.APPLE_13SECTOR_DISK)) {
|
||||
int tracksOnDisk = source.getSize() / (13 * SECTOR_SIZE);
|
||||
return new Geometry(tracksOnDisk, 13);
|
||||
}
|
||||
else {
|
||||
int tracksOnDisk = source.getSize() / (16 * SECTOR_SIZE);
|
||||
return new Geometry(tracksOnDisk, 16);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> get(Class<T> iface) {
|
||||
@@ -65,16 +76,18 @@ public class DosOrderedTrackSectorDevice implements TrackSectorDevice {
|
||||
|
||||
@Override
|
||||
public DataBuffer readSector(int track, int sector) {
|
||||
assert(track < geometry.tracksOnDisk());
|
||||
assert(sector < geometry.sectorsPerTrack());
|
||||
return source.readBytes((track*16+sector)*SECTOR_SIZE, SECTOR_SIZE);
|
||||
return source.readBytes(calculateOffset(track,sector), SECTOR_SIZE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSector(int track, int sector, DataBuffer data) {
|
||||
assert(data.limit() == SECTOR_SIZE);
|
||||
source.writeBytes(calculateOffset(track,sector), data);
|
||||
}
|
||||
|
||||
public int calculateOffset(int track, int sector) {
|
||||
assert(track < geometry.tracksOnDisk());
|
||||
assert(sector < geometry.sectorsPerTrack());
|
||||
assert(data.limit() == SECTOR_SIZE);
|
||||
source.writeBytes((track*16+sector)*SECTOR_SIZE, data);
|
||||
return (track * geometry.sectorsPerTrack() + sector) * SECTOR_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,9 @@ NotAFile='{1}' is not a file.
|
||||
|
||||
# Disk
|
||||
Disk.AllImages=All Emulator Images
|
||||
Disk.140kDosImages=140K DOS Ordered Images (*.do, *.dsk)
|
||||
Disk.140kNibbleImages=140K Nibbilized Images (*.nib)
|
||||
Disk.16SectorDosImages=16-sector DOS Ordered Images (*.do, *.d16, *.dsk)
|
||||
Disk.13SectorDosImages=13-sector DOS Ordered Images (*.d13)
|
||||
Disk.140kNibbleImages=Nibble Images (*.nib)
|
||||
Disk.140kProdosImages=140K ProDOS Ordered Images (*.po)
|
||||
Disk.800kProdosImages=800K ProDOS Ordered Images (*.2mg, *.2img)
|
||||
Disk.WozImages=WOZ 1.x/2.x Images (*.woz)
|
||||
@@ -57,17 +58,6 @@ FormattedDisk.2Img=2IMG
|
||||
FormattedDisk.Unknown=Unknown
|
||||
FormattedDisk.DiskFormat=Disk Format
|
||||
|
||||
# DosOrder
|
||||
DosOrder.OrderName=DOS
|
||||
DosOrder.UnrecognizedFormatError=Unrecognized DOS format\!
|
||||
DosOrder.InvalidSizeError=The track ({0}) and sector ({1}) do not match the disk image size.
|
||||
|
||||
# ProdosOrder
|
||||
ProdosOrder.OrderName=ProDOS
|
||||
|
||||
# NibbleOrder
|
||||
NibbleOrder.InvalidPhysicalSectorError=Unable to locate physical sector {0} on track {1} (\#{2})
|
||||
|
||||
# RdosFormatDisk
|
||||
RdosFormatDisk.Rdos21=RDOS 2.1
|
||||
RdosFormatDisk.Rdos33=RDOS 3.3
|
||||
|
||||
@@ -241,6 +241,13 @@ public class DiskHelperTest {
|
||||
assertCanReadFiles(disks);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOriginal32SystemMasterStd() throws DiskException, IOException {
|
||||
FormattedDisk[] disks = showDirectory(config.getDiskDir() +
|
||||
"/original32sysmasstd.d13");
|
||||
assertCanReadFiles(disks);
|
||||
}
|
||||
|
||||
protected FormattedDisk[] showDirectory(String imageName) throws IOException, DiskException {
|
||||
Source source = Sources.create(imageName).orElseThrow();
|
||||
DiskFactory.Context ctx = Disks.inspect(source);
|
||||
|
||||
BIN
lib/ac-api/src/test/resources/disks/original32sysmasstd.d13
Executable file
BIN
lib/ac-api/src/test/resources/disks/original32sysmasstd.d13
Executable file
Binary file not shown.
Reference in New Issue
Block a user