# Disk: the FD1793 and WD2797 cartridges Sources: Tandy's Disk Interface service manual, cat. 26-3022 (DSM, OCR), the FD179X-02 data sheet (WD, May 1980, OCR) and application notes, LOM's FF40-FF4B reference, the MAME observation runs ([mame-oracle.md](mame-oracle.md)). DOC unless tagged. ## Tandy's disk interface (26-3022) - A cartridge holding an 8K Disk BASIC ROM at C000, an 8-bit control latch, a WD1793 clocked at 1 MHz (a 4 MHz crystal divided by 4), a WD1691 and WD2143 for double-density data separation and write precompensation; up to four drives of 35 tracks (DSM "System description", "Clock generation"). - Register map (DSM figure 2): | Address | Use | | --- | --- | | FF40 (write) | control latch: bit 0-2 drive select 1-3, bit 3 motor on, bit 4 precompensation, bit 5 double density enable, bit 6 drive select 4, bit 7 wait (HALT) enable | | FF48 | command (write) / status (read) | | FF49 | track | | FF4A | sector | | FF4B | data | LOM adds that FF41-FF47 are copies of the latch (partial decoding) and FF50-FF5F serve other disks (community). - **HALT and NMI** (DSM "Computer interface"): DRQ gated with the wait-enable bit drives the CPU's HALT, so during a sector transfer the CPU is halted until each byte is ready and runs one load/store per DRQ; INTRQ gated with the double-density bit drives NMI, and the NMI at the end of the command clears the wait-enable bit and breaks the CPU out of its transfer loop. This is the board's only bus-level cross-device coupling besides the SAM: the 6809's HALT (dead cycles before and after, m6809-python's U list) and NMI timing decide whether a transfer works, so the FDC must be stepped against the CPU's cycles at least while a command runs. - OBSERVED (MAME `coco` with the default disk cartridge): Disk BASIC writes FF40 = 00 (everything off) and FF48 = D0h (force interrupt) 1.27 s after reset. ## DragonDOS (Dragon Data's controller) No Dragon Data document pinned. OBSERVED in MAME's `dragon64` (its default slot device, `dragon_fdc`, a WD2797 at 1 MHz): the controller's registers are at FF40-FF43 (FF40 command, FF41 track, FF42 sector) and the latch at FF48 (writes FF40 = D0h, FF48 = 24h, FF41 = 00, FF42 = 00, FF40 = 02h about 2.03 s after reset). So the two controllers swap their register and latch addresses; the Dragon latch's bits and its HALT/NMI wiring are unknown U15 (MAME is a detector only; the documented source to look for is Dragon Data's DragonDOS manual or the controller's schematic). ## The controller chip (WD179x family) FD1791-FD1797 (the "-02" sheet): "the 1793 is identical to the 1791 except the DAL lines are TRUE"; the 1795/7 add a side select output. The WD2797 belongs to the later WD279x line (the side select output and, by msx-python's account of its pinned WD279X-02 sheet, an on-chip data separator; not re-read here) with the same command set. Commands (WD): type I restore/seek/step/step-in/step-out with rates and verify; type II read/write sector (single or multiple); type III read address, read track, write track (formatting); type IV force interrupt. Status bits change meaning by command type; DRQ and INTRQ are pins. The sheet gives the step rates (3, 6, 10, 15 ms at a 2 MHz clock, doubled at the CoCo's 1 MHz: Table 1), the head settling time after a verified seek (15 ms, "doubles to 30 ms for a 1 MHz clock") and the index-pulse rules (an ID field within 5 revolutions): the board needs all of them for the NMI to arrive on the right cycle. **Family question (the chip rule).** WD179x/177x/279x controllers met by tonight's Phase 0s: msx-python (WD2793, Philips-style), bbcmicro-python (WD1770/1772), atarist-python (WD1772: in progress tonight, no documents committed yet when read), ti99-python (FD1771), and here (FD1793, WD2797; MAME models Tandy's later controller as a WD1773, contradiction C6). Their programming model is one family (the same four registers, the same command set; 177x adds motor control and differs in step rates and pins; 279x adds side select and a data separator). Recommendation (open decision 5): one `wd179x-python` chip core (name provisional; rows FD1771/FD1793/WD1773/WD2793/WD2797/WD1772), extracted by the first of these boards to need it at command level, the others pinning it; each board keeps its own latch, decode and HALT/NMI/DRQ wiring. ## Disk images From MAME's lists (OBSERVED file extensions): `coco_flop` 186 `.dsk`; `dragon_flop` 202 `.vdk`, 1 `.dsk`, 1 `.dmk`; `dragon_flex` 28 `.vdk`; `dragon_os9` 17 `.vdk`. The formats: `.dsk` (JVC: raw sectors, optional header, 18 sectors of 256 bytes, 35 tracks for RS-DOS), `.vdk` (Dragon: a header then raw sectors), `.dmk` (track-level with ID and data marks, needed for copy-protected disks). The format facts are community knowledge (no document pinned yet: U16); MAME's `jvc_dsk.cpp`, `vdk_dsk.cpp` and `coco_rawdsk.cpp` say `license:BSD-3-Clause` on their first lines and `dmkdsk.cpp` has no `license:` line (so GPL-2.0+ by MAME's rule); all stay closed (open decision 6). First milestone: sector-level images (`.dsk`, `.vdk`) with the controller at command level; `.dmk` and bit level later. ## Unknowns here U15 the DragonDOS latch bits and HALT/NMI wiring; U16 a pinned description of the JVC, VDK and DMK formats (candidates: the Color Computer Archive's documents, the Dragon archive sites, each checked for licence and robots.txt first).