diff --git a/doc/disk-apple2.md b/doc/disk-apple2.md index 351316c1..eae99f4f 100644 --- a/doc/disk-apple2.md +++ b/doc/disk-apple2.md @@ -46,9 +46,9 @@ fluxengine ls appleii140 --appledos -f image.flux In addition, some third-party systems use 80-track double sides drives, with the same underlying disk format. These are supported with the `appleii640` profile. The complication here is that the AppleDOS filesystem only supports up -to 50 tracks, so it needs tweaking to support larger disks. FluxEngine doesn't -understand these tweaks yet but they only become important when writing to -disks, which isn't supported yet. +to 50 tracks, so it needs tweaking to support larger disks. It treats the +second side of the disk as a completely different volume. To access these +files, use `--appledos --side1`. [^1]: CP/M disks use the ProDOS translation for the first three tracks and a different translation for all the tracks thereafter. diff --git a/lib/vfs/appledos.cc b/lib/vfs/appledos.cc index de23cb36..43f40a66 100644 --- a/lib/vfs/appledos.cc +++ b/lib/vfs/appledos.cc @@ -103,7 +103,7 @@ public: ByteWriter bw(bytes); while (tstrack) { - Bytes ts = getLogicalSector(tstrack * 16 + tssector); + Bytes ts = getAppleSector(tstrack * 16 + tssector); ByteReader br(ts); br.seek(0x0c); @@ -114,7 +114,7 @@ public: if (!track) goto done; - bw += getLogicalSector(track * 16 + sector); + bw += getAppleSector(track * 16 + sector); } tstrack = ts[1]; @@ -128,7 +128,7 @@ public: private: void mount() { - _vtoc = getLogicalSector(VTOC_BLOCK); + _vtoc = getAppleSector(VTOC_BLOCK); if ((_vtoc[0x27] != 122) || (_vtoc[0x36] != 0) || (_vtoc[0x37] != 1)) throw BadFilesystemException(); @@ -137,7 +137,7 @@ private: int sector = _vtoc[2]; while (track) { - Bytes dir = getLogicalSector(track * 16 + sector); + Bytes dir = getAppleSector(track * 16 + sector); ByteReader br(dir); br.seek(0x0b); @@ -162,6 +162,12 @@ private: throw FileNotFoundException(); } + Bytes getAppleSector(uint32_t number, uint32_t count = 1) + { + return getLogicalSector( + number + _config.filesystem_offset_sectors(), count); + } + private: const AppledosProto& _config; Bytes _vtoc; diff --git a/lib/vfs/vfs.proto b/lib/vfs/vfs.proto index 7c86d7b8..aa45e814 100644 --- a/lib/vfs/vfs.proto +++ b/lib/vfs/vfs.proto @@ -59,7 +59,12 @@ message CbmfsProto message ProdosProto {} -message AppledosProto {} +message AppledosProto { + optional uint32 filesystem_offset_sectors = 1 [ + default = 0, + (help) = "offset the entire offset up the disk this many sectors" + ]; +} message Smaky6FsProto {} diff --git a/src/formats/appleii640.textpb b/src/formats/appleii640.textpb index af33f777..58044bec 100644 --- a/src/formats/appleii640.textpb +++ b/src/formats/appleii640.textpb @@ -24,17 +24,19 @@ layout { } } -decoder { - apple2 { - side_one_track_offset: 80 - } -} - -encoder { - apple2 { - side_one_track_offset: 80 - } -} - tpi: 96 +option { + name: "side1" + comment: "reads the volume on side 1 of a disk" + message: "accessing volume on side 1" + + config { + filesystem { + appledos { + filesystem_offset_sectors: 0x500 + } + } + } +} +