# The MAME recipe (run 2026-11-26, MAME 0.285) MAME is a closed box here. Its X1 driver (`src/mame/sharp/x1.cpp`, `x1.h`, `x1_m.cpp`, `x1_v.cpp`, `x1twin.cpp`) is **LGPL-2.1+** by its `license:` lines ("Angelo Salese, Barry Rodewald"; read through raw.githubusercontent.com byte ranges 0-160 at tag `mame0285`, nothing else of the files fetched). Only the installed binary is run. The devices it uses are BSD-3-Clause by their lines (`machine/z80ctc.cpp` Wilbert Pol, `z80sio.cpp` Curt Coder and Joakim Larsson Edstrom, `z80dma.cpp` Couriersud, `wd_fdc.cpp` Olivier Galibert, `i8255.cpp` Curt Coder, `video/mc6845.cpp` Wilbert Pol and Nigel Barnes, `sound/ay8910.cpp`, `sound/ymopm.cpp` Aaron Giles, `formats/x1_tap.cpp` Barry Rodewald, `formats/d88_dsk.cpp` Miodrag Milanovic) but are not fetched either. Tier 5: a detector of I/O order and values; not a judge of timing or of the sub-CPU. ## Devices (`mame -listdevices x1`, `x1turbo`; OBSERVED) | Driver | CPU | Video | Others | | --- | --- | --- | --- | | `x1` | Zilog Z80 @ 4.00 MHz (`:x1_cpu`) | Hitachi HD6845S CRTC @ 894.88 kHz | AY-3-8910A @ 2.00 MHz, Z80 CTC @ 4.00 MHz, Fujitsu MB8877 FDC @ 1.00 MHz (four 5.25-inch DD drives), Intel 8255 PPI, cassette, cartridge slot, "Sharp X1 Keyboard" (`x1kb`) | | `x1turbo` | as above | as above | plus Zilog Z80 DMA, Z80 SIO, a second CTC (`ctc_ym`) and **YM2151 @ 2.00 MHz** (C1) | No MCS-48 device appears: the sub-CPU is modelled, not run (its ROM, `80c48`, is "NO GOOD DUMP KNOWN"). ## Command ```sh MAME_ROMPATH=... python -I scripts/mame_trace.py --driver x1 --seconds 3 --trace 0.05 ``` It runs `nice taskset -c 24-31 mame x1 -rompath $MAME_ROMPATH -homepath -snapshot_directory /snap -video none -sound none -nothrottle -noreadconfig -skip_gameinfo -log -seconds_to_run 8 -autoboot_script run.lua -debug -debugger none`. The Lua installs write and read taps on the Z80's `io` space (0000h-FFFFh, held in globals) writing `O|I port value seconds` to `io.log`, traces `T pc totalcycles` per instruction for the first 0.05 emulated seconds through `trace T.trace,:x1_cpu,noloop,{logerror ...}`, and stops from a frame notifier at 3 emulated seconds with one snapshot. Output: the git-ignored `reference/mame/x1/`. ## Run made (one MAME process, 2.8 s wall time) `x1`, 3 emulated seconds, 0.05 s traced: 170,188 I/O accesses, 33,576 traced instructions. MAME warned "80c48 NOT FOUND (NO GOOD DUMP KNOWN)" and "ank.fnt ROM NEEDS REDUMP" and ran. The snapshot shows **"IPL is under preparing"** on a black screen. ## What it showed (OBSERVED) - 0-2.25 ms: 255 reads of port 4000h returning 00h, every 8.75 µs, before any `OUT` (U5). - 2.249 ms: 8255② control `1A03h <- 82h` (A out, B in, C out: mode 0); `1A02h <- 72h`; `1A01h` read 25h. - 2.28-2.52 ms: CRTC R0-R13 = 37h, 28h, 2Dh, 34h, 1Fh, 02h, 19h, 1Ch, 00h, 07h, 60h, 07h, 00h, 00h at 18-µs steps (video.md). - 2.53 ms: `1000h`, `1100h`, `1200h`, `1300h <- 00h` (palette planes and priority); `1C00h <- 07h`, `1B00h <- 3Fh` (PSG R7: all tone and noise off, ports A and B input). - From 2.6 ms: attribute fill `2000h... <- 07h` (white), then the text. - From 0.82 s: the sub-CPU loop: `1900h <- E4h`, `1900h <- 00h` (set the key-interrupt vector to 00h = no interrupt), with `1A01h` polled between bytes; 27,626 pairs and 110,505 reads of 1A01h in the remaining 2.2 s, the IPL waiting on the sub-CPU (MAME's model never satisfies it, or the IPL repeats by design: U17). - Port counts over the run: `I 1Axx` 110,505; `O 19xx` 55,252; `O 20xx`-`23xx` and `O 30xx`-`33xx` 534/512 each (text and attribute fills); `I 40xx` 255; `O 18xx` 28. - Instruction timing: 0.05 s = 200,000 T-states for 33,576 instructions, 6.0 T-states each on average; no wait states visible in MAME's model.