# The cassette interface ## Wiring - Write: PPI port C bit 5 (CASW), a level the BIOS toggles [TDB p. 43]. - Motor: PPI port C bit 4 (CASON), L = on, a relay in the machine [TDB p. 43]. - Read: PSG port A bit 7 (CSAR) [TDB p. 44; TH2 5.2.2: "the seventh bit of port B of the general-purpose I/O interface (register 15 of the PSG)" says the transcription, which conflicts with the TDB's table: **C2**. The TDB's PSG table puts CSAR on port A bit 7, an input, which is where an input must be (port B is the output port); the TH2 text is taken to be a slip, to confirm against the TH2 scan]. The cassette is pure software timing: "The pulse width is determined by counting the T-STATE of the CPU, so, while the cassette interface is active, any interrupt is inhibited" [TH2 5.2.2]. The board therefore needs no cassette logic beyond two pins and a motor: a tape is a **signal source and sink in time** (a level per CPU clock). ## The format [TH2 5.2] | | 1200 baud | 2400 baud | | --- | --- | --- | | bit 0 | one cycle of 1200 Hz | one cycle of 2400 Hz | | bit 1 | two cycles of 2400 Hz | two cycles of 4800 Hz | | long header | 2400 Hz x 16,000 (about 6.7 s) | 4800 Hz x 32,000 | | short header | 2400 Hz x 4,000 (about 1.7 s) | 4800 Hz x 8,000 | Pulse widths in CPU T-states: 2963 (833 us), 1491 (417 us), 746 (208 us), 373 (104 us) [TH2 fig. 5.11]. A byte is a 0 start bit, eight data bits LSB first, two 1 stop bits [TH2 fig. 5.12]. The baud rate is detected from the long header. Files: BASIC (header 10 x D3h + 6-byte name), ASCII (10 x EAh, 256-byte blocks with short headers, CTRL+Z ends) and machine code (10 x D0h; start, end and entry addresses) [TH2 5.2.5]. ## Image formats - **`.wav`**: the signal itself; the board's tape device thresholds it into CSAR levels at the CPU clock. Faithful for any loader, including turbo loaders. - **`.cas`** (the community's container: blocks of bytes separated by an 8-byte marker, no timing): a `.cas` player synthesises the standard FSK signal from the bytes at a chosen baud rate, so the real BIOS (or C-BIOS 0.32's new TAPION/TAPIN, which now read 1200 and 2400 baud) loads it unmodified. Turbo loaders and custom formats need `.wav`. The `.cas` marker bytes and layout are community convention (U19: the document that defines it was not found in this phase; MAME's `msx1_cass` list is a detector of what images exist). The census's MAME cassette list (`msx1_cass.xml`) names the tapes MAME knows; the No-Intro MSX sets hold cartridges only. ## Speed concern Loading a tape is minutes of emulated time; a host may fast-forward (run unthrottled), which changes nothing emulated. A BIOS patch that skips the signal (TAPIN as a host call) would be a concession in a downstream tier, never the specification.