# MAME 0.285 as a detector: the recipe, as run MAME is GPL-2.0+ as a whole; its Pico driver `src/mame/sega/segapico.cpp` (Emmanuel Vadot) says `license:BSD-3-Clause` (its first line, read 2026-11-26 through a byte-range request at tag `mame0285`, `f379cd0`; nothing past the header was read). The driver is a closed box by this Phase 0's brief: MAME is run as the installed binary and its source is not opened. It is "preliminary" in MAME's own status, without save states. What it shows is tier 5: what software does, never what the hardware does. ## The recipe `scripts/mame_trace.py` runs one MAME process, headless, for a few emulated seconds, on a cartridge read in place from `$NO_INTRO_DIR/Sega - PICO` (MAME opens the zip itself): ```sh mame picou -cart "/Sega - PICO/.zip" -video none -sound none \ -nothrottle -noreadconfig -skip_gameinfo -snapshot_directory snap \ -cfg_directory cfg -nvram_directory nvram -autoboot_script run.lua ``` The Lua script installs read and write taps on the 68000's program space at $800000-$80001F (held in globals so they are not collected), logs each access as `frame R|W pc=… address data=… mask=…`, counts frames with a frame notifier, snapshots the screen and exits. With `--trace` it adds `-debug -debugger none` and the debugger command `trace cpu.trace,maincpu,noloop`, which writes every 68000 instruction (keep it to a second or two). Outputs go to `reference/mame/<run>/`, git-ignored. Run under `nice taskset -c 24-31`. Notes: MAME warns "-video none doesn't make much sense without -seconds_to_run"; the frame notifier ends the run instead. The screen tag is `:megadriv`. The cartridge slot is mandatory: MAME will not start `pico` without `-cart`. ## Runs made (2026-11-26), one at a time | Cartridge | Machine | Emulated | I/O accesses | Notes | | --- | --- | --- | --- | --- | | Magic Crayons (USA) | `picou` | 8 s (480 frames) | 2,487 | pen, buttons, page polled every frame; PCM control written 4 times, data never | | Tails and the Music Maker (USA) | `picou` | 2 s, with `--trace` | 37 | 2,047,512 68000 instructions traced (41 MB) | | Sonic The Hedgehog's Gameworld (Japan) | `picoj` | 10 s | 4,137 | PCM data writes (12), control writes (40), $800017 written once | | Melody Land (Japan) (Copera) | `copera` | 8 s | 611 | reads $80000F once; page register reads $33 | | Sonic The Hedgehog's Gameworld (USA) | `pico` | 10 s | 5,450 | pen read twice a frame | Five MAME processes in all, sequential, each under 15 s of wall time. What the logs show is folded into [memory-map.md](memory-map.md) and [inputs-and-pages.md](inputs-and-pages.md). ## What it can and cannot decide - **Can detect**: which registers a game touches, in what order and how often; the boot path; the 68000's instruction stream for a lockstep of the board's CPU side once the board answers I/O reads the same way (MAME's answers fed back as a replay, as megadrive-python's milestone 1 did). - **Cannot decide**: anything the hardware returns. MAME's idle page register ($92 on the Pico rows, $33 on the Copera), its PCM FIFO's free count, its 315-5641 clock and its interrupt wiring are its authors' choices. - **Instruction rate**: Tails and the Music Maker executed 2,047,512 instructions in 120 NTSC frames, about 1.02 M a second (game code with idle loops; the 68000's ceiling at 7.67 MHz and 4 clocks an instruction is 1.9 M). ## Other closed boxes, not run - **PicoDrive** (notaz and others; its COPYING, read 2026-11-26 at `26ecb2b`, forbids sale and commercial use): the most complete Pico emulator known, including the PCM. Non-commercial, so its source is never fetched; if wanted it would be run only as a shipped binary (its v1.93 release or a libretro build) from the GPL tools tree, as a second tier-5 detector. Not needed for Phase 0. - **Kega Fusion**: closed freeware, reported (not checked here) to run Pico cartridges; a binary only. Not run.