# Video and sound: reusing tms9918-python and sn76489-python Both chips have family cores. This page says what the board needs from each and what is new. Tags as in memory-and-bus.md. ## Video: TMS9918A (NTSC), TMS9929A (PAL) → `../tms9918-python` | Machine | VDP | VRAM | Source | | --- | --- | --- | --- | | TI-99/4A (US) | TMS9918A | 16 KiB, eight TMS4116 | [CTD] fig. A ("TMS 9918A ... 16K × 8 TMS 4116"); MAME 0.285 `ti99_4a` device `tms9918a` (OBSERVED) | | TI-99/4A (Europe) | TMS9929A (50 Hz) | 16 KiB | MAME `ti99_4ae`: 50.159 Hz, 313 lines (OBSERVED); no TI document read for the European board (U13) | | TI-99/4 (1979) | TMS9918 (no A: no Graphics II) | 16 KiB | tms9918-python docs/consumers.md (MAME's `tms9918`); a later machine row | tms9918-python (`de266ef`, 2026-11-24) already has the TMS9918A, TMS9928A and TMS9929A rows, 16 KiB VRAM, the access-window schedule and the /INT level. What the 99/4A adds: 1. **An unlocked clock.** The ColecoVision and SG-1000 run their Z80 at XTAL/3 from the VDP's crystal; the 99/4A's CPU has its own 48 MHz crystal (3.000 MHz) and the VDP its own 10.738635 MHz. The board converts CPU clocks to VDP master clocks at 10,738,635 / 3,000,000 (exactly 3.579545) and brings the VDP up to each access; the core's `run(master_clocks)` needs nothing new, but the board's timeline needs a common unit (domains-and-speed.md). 2. **GROMCLK.** The GROMs and the sound chip are clocked from the VDP's 447 kHz output (master / 24). tms9918-python's brief lists "GROMCLK and CPUCLK outputs" as later rows; the board can derive GROMCLK from the VDP's master clock count without the core (the core only needs to expose its clock count, which it does through `run`). No core change requested. 3. **/INT → TMS9901 INT2.** The VDP's interrupt goes to the 9901, which encodes it to the CPU's level 1 [CTD A.5]: the board reads the core's `int_line` level. 4. **Ports.** 8800 read data, 8802 read status, 8C00 write data, 8C02 write address, decoded anywhere in each 1 KiB block (A14 picks MODE): the board decodes, the core sees MODE. 5. **The CPU's read-before-write.** A MOVB to 8C00 reads 8C00 first: inside the VDP-write block, so the VDP sees no read (reads are only decoded at 8800-8BFF); the read returns whatever the board's 8-bit bus floats to (U14). A MOVB *to* 8800 (a mistake in software) would be a VDP data read: the decode must keep reads and writes apart exactly as TI's logic does. 6. **Access windows.** [GPL] L-1 asks for "at least 6 µs" between VDP operations; the CPU's own speed (an access through the multiplexer every few µs) means 99/4A software mostly respects the windows that tms9918-python models; programs that do not are the test cases for its rung 4. Upstream requests: none for the TMS9918A/9929A rows. The plain TMS9918 row is wanted only for a TI-99/4 machine row (later). ## Sound: TMS9919 = SN94624 → `../sn76489-python`, a new variant TI's block diagram calls the console's sound chip the **TMS9919 complex sound generator** [CTD fig. A]; MAME 0.285 names it **SN94624** at 447,443 Hz (OBSERVED, `listxml`). [GPL] appendix C ("Sound Generator Chip (SGC) Control Summary") gives the programmer's view and points to a "TMS9919 SGC Specification" that was not found. What [GPL] C-2..C-4 states (DOC), against sn76489-python's `SN76489AN` row: | Behaviour | TMS9919 per [GPL] | SN76489AN in sn76489-python | Same? | | --- | --- | --- | --- | | three tone generators, one noise, 4-bit attenuation in 2 dB steps (1111 = off) | yes | yes | yes | | latch/data byte format (1 RR T DDDD, then 0 0 DDDDDD), 10-bit N, low 4 bits first | yes | yes | yes | | tone frequency | **N = 111860 / f**; lowest 110 Hz, highest 55,938 Hz | f = clock / 32N | yes, with the 99/4A's numbers: 111,860 × 32 = 3.5795 MHz | | noise byte 1110 0 T SS: T = 0 white, 1 periodic; SS = shift rate 0-2, 3 = tone 3's frequency | yes | yes | yes | | input clock | **447 kHz** (GROMCLK, [CTD] fig. A) | 3.58 MHz typical | **no** | The two lines together say the TMS9919's square wave is f = 447,443 / (4N) where the SN76489A's is f = 3.58 MHz / (32N) (447,443 / 4 = 111,860.8, [GPL]'s constant). In sn76489-python's terms (its `chip.py`: one *tick* is 16 input clocks, a tone flips every N ticks) the TMS9919 ticks every **2** input clocks instead of 16. So the chip behaves as the SN76489A's sound core behind a different input prescaler (DOC by arithmetic from two TI statements; the die is not known to us). What [GPL] does not state, and the variant must treat as provisional: - U15 the noise LFSR's length and taps (white noise), and the periodic noise length: the SN76489A's are in sn76489-python's spec with their evidence; the SN94624's are not documented anywhere found (MAME's `sn76496.cpp` header comments, BSD-3-Clause prose, would be a closed-box reading of the same question; kept closed). - U16 tone N = 0 (period 1,024 or 1?), the output's DC level and polarity, whether the chip has the SN76489A's READY wait (the 99/4A's sound write goes through the multiplexer; whether the chip holds READY is not in [CTD]). - U17 whether the 99/4 (1979) had the same chip (MAME says SN94624 for both). **Request upstream** (a fix starts upstream: sn76489-python owns variants): add a `TMS9919` (alias `SN94624`) variant row: the SN76489AN's behaviour with 2 input clocks per tick (today `CLOCKS_PER_SAMPLE = 16` is a module constant in `chip.py`, so the variant record needs a `clocks_per_tick` field) and its unknowns (U15-U17) marked provisional, so the board can say `SN76489(TMS9919)`. The board feeds it GROMCLK cycles (VDP master clocks / 24). Audio in: the speech synthesizer's output and the cassette input are mixed into the console's audio by the board (the I/O port's AUDIO IN; the 9901's audio gate bit, tms9901-keyboard.md).