# The floppy drive, MFM and the disk image formats The drive is a separate mechanism with its own time (a rotating disk), wired to Paula (the read/write bit stream), CIA-B (control, the index pulse) and CIA-A (status). It is the board's second domain candidate (domains-and-speed.md). ## The drive's interface (HRM3 pdf259-260, table 8-5; tier 2) | Signal | Where | Behaviour | | --- | --- | --- | | DSKRDY* | CIA-A PA5 | low when the motor is at full speed; "only valid when the motor is ON, at other times configuration information may obscure the meaning": the **drive ID** shift (external drives report a 32-bit ID through this line when selected with the motor off: U25 for the exact protocol) | | DSKTRACK0* | CIA-A PA4 | low over track 0; stepping outward from 0 must be refused | | DSKPROT* | CIA-A PA3 | write protect | | DSKCHANGE* | CIA-A PA2 | goes low when a disk is removed; "remains low until a disk is inserted AND a step pulse is received" (so Kickstart's polling steps the head: the familiar click) | | DSKMOTOR* | CIA-B PB7 | **latched per drive when its select goes active**; "all drive motors turn off after system reset"; wait 500 ms or DSKRDY* after turning on | | DSKSEL3-0* | CIA-B PB6-PB3 | drive select (0 = internal) | | DSKSIDE | CIA-B PB2 | 0 = upper head; stable 100 µs before writing, 1.3 ms after | | DSKDIREC | CIA-B PB1 | 0 = towards the spindle; set before the step, in a separate write | | DSKSTEP* | CIA-B PB0 | a pulse; the next track is reached within 3 ms; 18 ms after reversing; 15 ms settle | | DSKINDEX* | CIA-B FLAG (ICR bit 4) | once a revolution; can raise level 6 | The "within 3 ms" and "15 ms settle" figures are drive specifications, minimums for software. What the board models is the mechanism: a head position (0-79, plus the over-step a real drive allows: U26), a rotating track position in bit cells, the motor's spin-up time to DSKRDY*, and the index pulse. These are FITTED or HYPOTHESIS until measured (no Amiga drive on hand): the Amiga Test Kit's floppy tests print measured RPM and step timings on a real machine, a tier-3 source once readings from real units are in hand (open decision 9). ## Track timing - MFM bit cells of **2 µs** (ADKCON FAST = 1, HRM3 pdf264): 14.19 7M clocks on PAL (2 µs x 7.09379 MHz), 14.32 on NTSC, so not an integer: the drive's clock is its own, and Paula's data separator locks to the stream: **U27**, how Paula samples cells, is a modelling decision; proposal: the drive delivers cells on a 2 µs grid in its own time, converted at the channel). - **300 rpm**: 200 ms a revolution. disk-utilities (tier 3, from flux captures of real disks) uses **100,150 bit cells per track** at 300 rpm, "determined empirically -- larger than expected for 2us bitcell @ 300rpm" (`libdisk/include/private/disk.h`, `DEFAULT_BITS_PER_TRACK`). The nominal 100,000 is the specification's; real tracks are longer because drives spin a little slow or duplicators wrote them that way. - A full track read by DMA covers more than one revolution's worth of words when the length asks for it; Kickstart reads a whole track's worth of raw words (HRM3 pdf19: "over 5600 bytes of data in a single disk revolution" counts only the decoded sector data; trackdisk's DMA length per Kickstart version is U29) and finds sectors by the $4489 sync. ## AmigaDOS track layout (disk-utilities `libdisk/format/amiga/amigados.c`, Unlicense) Eleven back-to-back sectors a track, no index alignment, each: two zero bytes of gap, `$A1 $A1` written as the MFM sync words `$4489 $4489`, then the header (format `$FF`, track 0-159, sector 0-10, sectors to gap), a 16-byte label, header and data checksums, and 512 data bytes, all stored as odd bits then even bits (`0x55555555` masking) so that the blitter can decode a sector in two passes. 160 tracks x 11 x 512 = 901,120 bytes: an ADF. HD disks (A3000/A4000, 22 sectors) are a later row. ## Disk image formats | Format | What it holds | Who reads it | Plan | | --- | --- | --- | --- | | **ADF** | decoded AmigaDOS sectors only (901,120 bytes) | trivial: the board MFM-encodes each track itself | M5: the first format, for test programs | | **IPF** (SPS) | the track as preserved: blocks of sync, data and gap with bit-exact encoding, density changes, weak ("flaky") bits for copy protections; the CAPS/SPS encoder types | SPS's decoder library: **non-commercial, excluded** (sources.md) | M6: our own reader, from the container description in disk-utilities' `ipf.c` (records CAPS, INFO, IMGE, DATA with CRC32s; block types sync/data/gap/raw/flaky; density types noise/uniform/Copylock/Speedlock) plus the files themselves; checked by decoding every library IPF and comparing the AmigaDOS tracks it yields with the sector checksums inside them | | ADZ, DMS | compressed ADF; DMS is a packer with its own format | — | later, if wanted | | SCP, KryoFlux stream | raw flux | disk-utilities converts | not needed for the No-Intro set | **Every disk in the No-Intro library is IPF** (census.md: 5,753 images, no ADF), so the IPF reader is on the critical path to running any game. Copy protections (Copylock's timing, long tracks, weak bits) are exactly what IPF preserves and an ADF loses; the board's drive model must honour the IPF's per-cell density and weak-bit records. What would decide the IPF reader's correctness independently: decoding all 5,753 images without a CRC failure; AmigaDOS tracks whose sector checksums all pass; and, as a detector, the SPS library's decoded tracks (run in a tool repository whose terms allow it, never in this one: open decision 2).