apple2
====
## Prodos, Appledos, and CP/M
<!-- This file is automatically generated. Do not edit. -->

Apple II disks are nominally fairly sensible 40-track, single-sided, 256
bytes-per-sector jobs. However, they come in two varieties: DOS 3.3/ProDOS and
above, and pre-DOS 3.3. They use different GCR encoding systems, dubbed
6-and-2 and 5-and-3, and are mutually incompatible (although in some rare
cases you can mix 6-and-2 and 5-and-3 sectors on the same disk).

The difference is in the drive controller; the 6-and-2 controller is capable
of a more efficient encoding, and can fit 16 sectors on a track, storing
140kB on a disk. The 5-and-3 controller can only fit 13, with a mere 114kB.

Both formats use GCR (in different varieties) in a nice, simple grid of
sectors, unlike the Macintosh. Like the Macintosh, there's a crazy encoding
scheme applied to the data before it goes down on disk to speed up
checksumming.

In addition, a lot of the behaviour of the drive was handled in software.
This means that Apple II disks can do all kinds of weird things, including
having spiral tracks! Copy protection for the Apple II was even madder than
on other systems.

FluxEngine can only read well-behaved 6-and-2 disks. It doesn't even try to
handle the weird stuff.

Apple DOS also applies logical sector remapping on top of the physical sector
numbering on the disk, and this _varies_ depending on what the disk is for.
FluxEngine can remap the sectors from physical to logical using modifiers.  If
you don't specify a remapping modifier, you get the sectors in the order they
appear on the disk.

If you don't want an image in physical sector order, specify one of the
filesystem ordering options. These also select the appropriate file system;
FluxEngine has read-only support for all of these.

In addition, some third-party systems use 80-track double sides drives, with
the same underlying disk format. The complication here is that the AppleDOS
filesystem only supports up to 50 tracks, so it needs tweaking to support
larger disks. It treats the second side of the disk as a completely different
volume.

## Options

  - Format variants:
      - `140`: 140kB 5.25" 35-track SS
      - `640`: 640kB 5.25" 80-track DS
  - Filesystem and sector skew:
      - `nofs`: use physical CHS sector order and no file system
      - `appledos`: use AppleDOS soft sector skew and file system
      - `prodos`: use ProDOS soft sector skew and filesystem
      - `cpm`: use CP/M soft sector skew and filesystem
  - `side1`: for AppleDOS file system access, read the volume on side 1 of a disk

## Examples

To read:

  - `fluxengine read apple2 --140 -s drive:0 -o apple2.img`
  - `fluxengine read apple2 --640 -s drive:0 -o apple2.img`

To write:

  - `fluxengine write apple2 --140 -d drive:0 -i apple2.img`
  - `fluxengine write apple2 --640 -d drive:0 -i apple2.img`

## References

  - [Beneath Apple DOS](https://fabiensanglard.net/fd_proxy/prince_of_persia/Beneath%20Apple%20DOS.pdf)

  - [MAME's ap2_dsk.cpp file](https://github.com/mamedev/mame/blob/4263a71e64377db11392c458b580c5ae83556bc7/src/lib/formats/ap2_dsk.cpp)

