# The +3's floppy disc controller (uPD765A) ## What the +3 has (DOC: +3 manual parts 27 and 30; Wiki) - An NEC uPD765A (the Wiki: "Zilog Z0765A (µPD765A)"; second sources exist), main status register at 2FFD (read), data register at 3FFD (read and write) (+3 manual part 30). - The motor is switched by bit 3 of port 1FFD, not by the FDC. - One internal 3-inch single-sided drive (A:), an optional second drive (B:) on the "Disk B:" connector. +3DOS uses the uPD765A's Read Data, Write Data, Read ID, Format a Track, Scan Equal, Seek, Recalibrate, Sense Drive Status and Sense Interrupt Status (part 27's routine list: "Low level uPD765A read command", "Uses the uPD765A scan equal command", "A = ST3 (Status register 3 of uPD765A)"). - Disc format: +3DOS uses the CP/M Plus format, 40 tracks of 9 512-byte sectors on the standard +3 disc (part 27, "Disk format and specification"; the board needs only what the controller sees: IDs, sizes, gaps, data). - The +2A carries the same gate array, which generates "three disc controller signals" for an external controller (the never-sold SI-1; Wiki). **Not established from the pinned sources** (U6): how the uPD765A's INT and TC pins and the second unit-select line are wired on the Z70830 board. Common report says INT is not connected (+3DOS polls the main status register) and TC is not driven (so every multi-sector read ends with an "end of cylinder" abnormal termination that +3DOS ignores). These are HYPOTHESIS until the +3 service manual's schematic (Amstrad documentation, distributable under its 1999 statement; not yet pinned) is read. ## The chip (DOC: NEC uPD765 data sheet, December 1978; AN-08) Command, execution and result phases through one data register; the main status register's RQM (D7) and DIO (D6) gate every byte of the command and result phases. In non-DMA mode each execution-phase byte raises INT, or the host polls RQM: "If the processor cannot handle Interrupts fast enough (every 13 µs) then it may poll the Main Status Register and then bit D7 (RQM) functions just like the Interrupt signal." A missed byte is an overrun (ST0 bits 7-6 = 01). TC ends a command early. Step rate 1-16 ms at an 8 MHz clock, 2-32 ms at 4 MHz. MAME runs the +3's FDC at 4 MHz ("NEC uPD765A FDC @ 4.00 MHz", `mame -listdevices specpls3`: OBSERVED, closed box), consistent with 250 kbit/s MFM, where a byte passes every 32 µs, about 113 Z80 T-states at 3.5469 MHz: tight for a polling loop in contended memory, which is why +3DOS's read loop lives in uncontended RAM (HYPOTHESIS, to confirm from the ROM's code addresses when the board boots it). ## Reuse: the family already has a uPD765A sms-python's SF-7000 (`src/sms_python/sf7000.py`, class `UPD765`, last changed in `7066415`) models the uPD765A from the same data sheet: one single-sided drive, non-DMA, polled, the rotation modelled in CPU cycles because the SF-7000 IPL times the index pulse. Its scope is close to the +3's (single-sided 3-inch drive, polled, no DMA). The chip rule says a chip that a second family board needs becomes its own core: this is the second board. Options are in the handoff brief's open decisions (extract `upd765-python` from sms-python with history before the +3 milestone, recommended). What the +3 needs beyond the SF-7000 model: two units (A:, B:), 512-byte sectors with the +3 and CP/M formats, copy-protected discs (weak sectors, unusual IDs, deleted data; the No-Intro +3 set is IPF flux images precisely for these), Read Track, and the result-phase behaviour without TC (U6). ## Disc images (census.md) - No-Intro "Sinclair - ZX Spectrum +3": 127 images, all `.ipf` (SPS/CAPS flux-level container). Reading IPF needs a decoder; the reference library (SPS's CAPSImg) has its own licence, to be checked before any use, and is a closed box until then (open decision). - TOSEC `[DSK]`: 866 images, 660 extended DSK and 206 standard DSK ("MV - CPC" and "EXTENDED CPC DSK" signatures): the CPCEMU formats, sector-level, simple to read with our own MIT parser from the format description (to pin when the milestone starts). ## The FDC in MAME's +3 boot (OBSERVED, closed box; mame-oracle.md) With no disc, the +3 ROM writes 3FFD seven times in the first three seconds: `03 AF 03` (Specify: SRT/HUT = AF, HLT/ND = 03, so non-DMA) and twice `04 01` (Sense Drive Status, unit 1), after which the menu reports "Drives A: and M: available".