# The MAME recipe (run 2026-11-26, MAME 0.285) MAME's PC-8801 driver (`src/mame/nec/pc8801.cpp`, `pc8801.h`, Angelo Salese) and its disk unit (`src/devices/bus/nec_fdd/pc80s31k.cpp`, Angelo Salese and Olivier Galibert) are **BSD-3-Clause** by their `license:` lines, as are the devices it uses (`video/upd3301.cpp` Curt Coder and Angelo Salese, `machine/i8257.cpp`, `i8255.cpp`, `i8214.cpp`, `i8251.cpp`, `upd1990a.cpp`, `upd765.cpp`, `sound/ymopn.cpp` Aaron Giles; read through raw.githubusercontent.com byte ranges 0-160 at tag `mame0285`). The brief treats MAME's drivers as closed boxes, so **nothing of them was fetched or read** beyond those lines; whether a later session may read the BSD files with notice is decision 3. Tier 5: a detector. ## Devices (`mame -listdevices`; OBSERVED) | Driver | Main CPU | Disk unit | Video | Sound | Others | | --- | --- | --- | --- | --- | --- | | `pc8801mk2sr` | Zilog Z80 @ 3.99 MHz (`:z80`) | `pc80s31`: Z80 @ 4.00 MHz (`:pc80s31:fdc_cpu`), uPD765A @ 8.00 MHz, two 8255s, six latches | uPD3301 @ 14.31 MHz, screen @ 14.31 MHz, i8257 @ 3.99 MHz | YM2203 OPN @ 3.99 MHz, beep @ 2.40 kHz | i8214 @ 3.99 MHz, 8251, uPD1990A @ 32.76 kHz, Centronics, cassette, MSX-style joystick port, expansion slot | | `pc8801ma` | as above | `pc80s31k` (the 8 KB disk ROM) | as above | YM2608 OPNA @ 7.98 MHz | as above | ## Commands ```sh MAME_ROMPATH=... python -I scripts/mame_trace.py --driver pc8801mk2sr --seconds 3 --trace 0.05 MAME_ROMPATH=... python -I scripts/mame_trace.py --driver pc8801mk2sr --cpu sub --seconds 3 --trace 0.05 MAME_ROMPATH=... python -I scripts/mame_trace.py --driver pc8801ma --seconds 3 ``` Each runs `nice taskset -c 24-31 mame -rompath $MAME_ROMPATH -homepath -snapshot_directory /snap -video none -sound none -nothrottle -noreadconfig -skip_gameinfo -log -seconds_to_run 8 -autoboot_script run.lua` (plus `-debug -debugger none` with `--trace`). The Lua taps the chosen CPU's 8-bit `io` space (00h-FFh; a first attempt with a 0000h-FFFFh range failed: "end address is outside of the global address mask ff"), writes `O|I port value seconds` lines, traces `T pc totalcycles` for the given seconds, and stops at 3 emulated seconds with one snapshot. Output: the git-ignored `reference/mame/-/`. ## Runs made (four MAME processes, one at a time, each about 3 s of wall time) 1. `pc8801mk2sr`, main, 0.05 s traced: failed at script start (the address-mask error above); the run directory was moved to `trash/`. 2. `pc8801mk2sr`, main, 3 s, 0.05 s traced: 76,018 I/O accesses, 25,562 traced instructions. 3. `pc8801mk2sr`, disk unit, 3 s, 0.05 s traced: 128,475 I/O accesses, 27,927 traced instructions. 4. `pc8801ma`, main, 3 s: 58,026 I/O accesses. Both snapshots show N88-BASIC's disk start-up prompt **"How many files(0-15)?"** with the function-key bar (load, auto, go to, list, run). ## What they showed (OBSERVED) - Main, first 0.22 ms: `IN 30h` (D3h: DIP switches), `OUT 53h <- FFh` (all planes and text off), `IN 31h` (79h), `OUT 32h <- A8h`, the palette `54h`-`5Bh` (80h, 07h, 37h, 3Fh, 00h, 07h, 37h, 3Fh), `OUT 71h <- FFh` (extension ROMs off). - 16 ms: `E6h <- 00h` (interrupt masks off), `30h <- 22h`, `40h <- 11h`, `31h <- 00h`, `EBh <- 00h` (kanji read end). - 32.55 ms: the uPD3301/8257 set-up of video.md (channel 2 at F3C8h, 3,000 bytes; five reset parameters CEh 98h 67h DEh 13h). - 0.312 s: `FFh <- 91h` (the disk link 8255), then `FEh` polled (62,888 reads in 3 s), `FDh <- 00h`; at 2.017 s the first byte from the disk unit (`FCh = 0Fh`; which command it answers is U12), then `C1h`, `C3h`, `C8h`, `CAh` written (not in YK-IO: expansion-board probes? U13) and the GVRAM bank ports `5Ch`/`5Fh`/`5Dh`/`5Eh` (the screen clear). - The disk unit: `F7h <- 08h`, `FFh <- 91h` in its first 0.12 ms; `FEh` polled 128,442 times; the uPD765A's main status at `FAh` (80h) and `SPECIFY` (03h) to `FBh` at 2.0168 s; `FDh <- 0Fh` at 2.017375 s, read by the main CPU 25 µs later. - The MA boots the same way, 0.5 s sooner to the disk handshake (1.51 s against 2.02 s). - Timing: main 25,562 instructions in 199,680 T-states (7.8 average); unit 27,927 in 200,000 (7.2 average).