# MAME as a detector for the TI-99/4A board (tier 5, closed box) MAME 0.285's TI-99 drivers are Michael Zapf's, under **LGPL-2.1+** (their `license:` lines, read from the first 400 bytes of each file at tag `mame0285` on 2026-11-26; the full table is in ../tms9900-python docs/validation.md). Nothing of MAME's source is read or kept: it is run as a binary and only its output is used. One MAME process at a time, under `nice`, short runs. ## Recipes, as run on 2026-11-26 **Bus census** (this repository): read and write taps on the CPU's program space count accesses per 1 KiB device block in 8000-9FFF and per 8 KiB block elsewhere. ```sh # a shell with MAME_ROMPATH set (the family's profile-env file) python -I scripts/mame_bus_census.py --machine ti99_4a --start 1 --frames 119 # 1.986 s python -I scripts/mame_bus_census.py --machine ti99_4a --start 120 --frames 60 # 1.001 s ``` MAME runs headless (`-video none -sound none -nothrottle -noreadconfig -skip_gameinfo -autoboot_script tests/mame_runs/census.lua`), cwd `tests/mame_runs/` (git-ignored). The Lua script holds its taps and frame notifier in globals (MAME collects them otherwise) and arms the counting between the two frames. Output: `tests/detectors/mame-bus-census-2026-11-26.txt`. **Instruction trace**: `../tms9900-python/scripts/mame_trace.py` (its docs/mame-oracle.md): 5,762 instructions from reset in 2 frames; 161,014 in 1 s at the title screen. ## What the runs show (OBSERVED, detector only) - From power-on to frame 120: 464,736 console-ROM reads, 363,931 scratchpad reads and 198,300 writes, 24,326 VDP writes (each preceded by a read of the same VDP-write address), 4,196 VDP reads, 11,853 GROM reads, 6,300 GROM writes (each preceded by a read), 7 sound writes (each preceded by a read), 16 reads in the DSR space and none in the cartridge or expansion space. - The paired reads are the TMS9900's read-before-write as MAME models it, landing in each device's write block; the TI document predicts them ([CTD] B.1.2.1). - 16 DSR-space reads = one per CRU base 1000-1F00: the power-up peripheral poll [CTD] B.1.4. - At the title screen only GROM traffic (6,643 reads, 3,322 writes) and 60 VDP reads (one status read per frame) cross the channels: the GPL interpreter's loop. ## MAME's view of the machine (`mame -listxml ti99_4a`, `-listslots`) - CPU `tms9900` at 3,000,000 Hz; `tms9901`; `ti99_datamux` ("datamux_16_8"); `tms9918a`; `sn94624` at 447,443 Hz; three console `grom` devices and five cartridge `grom` slots; `scratchpad` RAM; screen 342 × 262 at 59.922738 Hz, pixel clock 5,369,317 Hz. - `ti99_4ae` (Europe): the same with 313 lines at 50.158969 Hz. - Slots: `gromport` (single, multi-cartridge extender, GRAM Kracker), `ioport` (PEB, speech synthesizer, Arcturus sidecar, I/O port splitter), `joyport` (twin joysticks, Mechatronics mouse). The speech device `ti99_speech` holds a `cd2501e` at 640 kHz and the two VSM images. ## What MAME can and cannot decide - Detects: instruction-stream differences, device-access counts and order, VRAM contents (a later recipe can dump VRAM at a frame through the VDP device's memory space), screenshots. - Cannot decide: wait-state counts, GROM timing and prefetch, the read-back value of the GROM address, the noise LFSR, the speech chip's identity and tables. Each of these is a named unknown in the brief with its own route to a judge.