# The SIO bus, disk drives and the cassette The computers reach their disk drives, cassette recorder, printers and modems through the Serial I/O bus. This is the subject the 5200 never needed, and the one that decides how much of the library boots: of the 36 local No-Intro images, 7 are disk images (3 ATR, 3 ATX, 1 SCP flux) ([census.md](census.md)). ## The bus ([AHRM] 9.1) | Line | Computer side | Peripheral side | | --- | --- | --- | | DATA OUT | POKEY serial output | peripherals listen | | DATA IN | POKEY serial input (SERIN, and SKSTAT bit 4 directly) | one peripheral at a time sends | | COMMAND | PIA CB2, active low | starts a command frame | | MOTOR | PIA CA2, active low | cassette motor | | PROCEED, INTERRUPT | PIA CA1, CB1 | rarely used (1030 modem) | | CLOCK IN/OUT, AUDIO IN | POKEY clock pins; the audio mix | synchronous devices; cassette audio | Frames are 8N1, normally 19,200 baud. A command is: COMMAND low, 750 µs-1.6 ms, a five-byte frame (device ID, command, two auxiliary bytes, an 8-bit end-around-carry checksum), 650-950 µs, COMMAND high; then ACK ($41) or NAK ($4E) within 16 ms; for a write, the computer's data frame and a second ACK; then Complete ($43) or Error ($45) after at least 250 µs; for a read, the data frame (sent even after an error), possibly back to back with the C/E byte ([AHRM] 9.1, Figure 18 and its timing table). Device IDs: $31-$3F disks, $40-$45 printers, $50-$53 the 850's serial ports, $5F the cassette as a virtual OS device ([AHRM] Table 29). The OS side is [OSM] (SIO, CIO, the device handlers) and [XLA] (the XL changes). **The board needs pokey-python's serial shift registers** for any of this ([reuse.md](reuse.md)): the computer sends through SEROUT and receives through SERIN, with the serial-output-complete and input-busy flags and the clock modes. ## Disk drives | Drive | CPU | Controller | Other chips | Firmware (SHA-1 in [firmware.md](firmware.md)) | | --- | --- | --- | --- | --- | | 810 (1980) | 6507 at 0.5 MHz, no interrupts | WD FD1771, single density, inverted data bus | 6532 RIOT (timer as index pulse, stepper phases), 6810 RAM (128 bytes) | revisions B, C (in MAME's set), E | | 1050 (1983) | 6507 at 1 MHz | WD2793/2797 (FM and MFM: "enhanced density") | 6532 RIOT, 6810 RAM | revisions E, H, J, K, L (H-L in MAME's set) | Facts from [AHRM] 10.9-10.10 and 10.15-10.16 (memory maps Tables 60 and 68), [FSM-810], [FSM-1050] (the 1050 manual has no text layer yet, U15). Drive behaviour that software sees is mostly timing: transmit delays by firmware (Table 50), step rates (51), sector layout and interleave (52-53), rotational timing, FDC status for bad sectors (54-56); copy protection depends on it, which is why the No-Intro set holds ATX images (they record sector timing and duplicates) and one SCP flux capture. Two ways to put a drive on the bus (decision D4): 1. **A disk device at the SIO protocol level** in this board (transaction level): it answers command frames from an image, with the per-firmware timings above and the rotational position kept in machine cycles. Enough for ATR/XFD and, with timing records, ATX. This is what most emulators do and what Acid800's `pokey_serdirect` needs (a real D1: answering a bad request with NAK). 2. **The drive as its own board** (`atari810-python`, `atari1050-python`), plugged into the SIO socket: a 6507 on 6502-python, the RIOT, the FDC, the drive's own ROM by SHA-1, a disk surface model fed by ATX or flux. Cycle level, its own clock and domain, and the only way to honour SCP flux images or custom drive code (Happy, US Doubler). MAME 0.285 models both drives this way (`atari810.cpp`, `atari1050.cpp`, BSD-3), a detector and a source of facts. **Recommend 1 first, 2 as later boards**: the SIO socket is the same for both, so a drive board replaces the protocol device without touching the computer; option 2 brings two second-consumer questions (RIOT from a2600-python, a WD279x shared with msx-python). ## Image formats | Format | Seen locally | What it holds | Description to use | | --- | --- | --- | --- | | ATR | 3 (92,176 bytes: 720 sectors of 128) | a 16-byte header (magic $0296, size in paragraphs, sector size) and sectors | a permissive or factual description is still to be chosen (U10); the header layout the census reads is OBSERVED in these files | | ATX | 3 | VAPI's timed sector format ("AT8X"): sector timing, duplicates, weak bits | the VAPI format notes (ijor); terms to check (U10) | | SCP | 1 (11 MB, Trailblazer) | SuperCard Pro flux capture | the SCP format document (public); only useful with option 2 | | XFD, DCM, PRO | none locally | raw sectors; DiskComm; APE's protected format | later | | CAS | none locally | cassette chunks ("FUJI", baud, data) | U9 | | XEX | none locally (Acid800's standalone tests are XEX) | DOS binary load file ($FFFF header, segments, INITAD/RUNAD) | [OSM]/DOS documentation | A raw cartridge named `.atx` in the No-Intro set (Centipede (Europe), C5) shows why the loader must look at contents, not names. ## Cassette (410, 1010) The recorder is a dumb device: the motor line (PIA CA2) starts it, its data reach POKEY's serial input as FSK tones (5,327 Hz for 1, 3,995 Hz for 0) decoded by the recorder, at 600 baud for the OS (POKEY divisor $05CC; [AHRM] 5.6 and appendix C), and its audio track goes into the audio mix ([AHRM] 9.17, appendix C; [FSM-410], no text layer yet; [OSM] cassette handler). The OS reads tape through SIO with DDEVIC $5F intercepted. Proposed: a tape socket fed from a CAS file (decoded bits with their timing), at milestone 6; raw audio (WAV) decoding as a later frontend tool, since the demodulator choice is ours (appendix C lists several) and not the hardware's. ## XEX without a disk Acid800's standalone tests are XEX files. Real machines load them through a DOS or a loader on a disk; emulators commonly synthesise a tiny boot disk. Proposed: the test harness loads an XEX through a generated boot disk on the SIO protocol device (milestone 3), and before that (milestones 1-2) through a labelled host loader that writes the segments and calls INITAD/RUNAD the way DOS 2 does, recorded as a harness, not hardware.