# MAME as a detector for the board (closed box, tier 5) MAME 0.285 (`mame` on the PATH), run headless, never read. Machines used: `coco` ("Color Computer 1/2"), `dragon32`, `dragon64`; others listed in [machines.md](machines.md). **Licence lines** (read 2026-11-26 from the first 160 bytes of each file at tag `mame0285`, commit f379cd060ac3; nothing else of the source fetched or kept): `trs/coco.cpp`, `coco12.cpp`, `coco3.cpp`, `dragon.cpp`, `gime.cpp`, `devices/video/mc6847.cpp`, `machine/6883sam.cpp`, `machine/6821pia.cpp`, `machine/wd_fdc.cpp`, `bus/coco/coco_fdc.cpp`, `bus/coco/dragon_fdc.cpp`, `bus/coco/cococart.cpp`, `imagedev/cassette.cpp`, `lib/formats/coco_cas.cpp`, `coco_rawdsk.cpp`, `vdk_dsk.cpp`, `jvc_dsk.cpp` say `license:BSD-3-Clause`; `lib/formats/dmkdsk.cpp` has no `license:` line, so GPL-2.0+ by MAME's rule. Tonight's brief keeps all of them closed; whether the BSD ones may be read is open decision 6 (recommendation: keep closed). **Device tree** (OBSERVED, `-listxml`/`-listdevices`): `coco` = MC6809E at 894,886 Hz, `sam` MC6883 at 14.31 MHz, `vdg` MC6847 at 3.57 MHz, `pia0`, `pia1`, `dac` "6-Bit Binary Weighted DAC", `sbs` "1-Bit DAC", `cassette`, `ext` cartridge slot with `coco_fdc` by default (a **WD1773 at 8 MHz**, against Tandy's WD1793 at 1 MHz: C6); screen 372x243 of 456x262 half clocks, 59.92 Hz. `dragon32`/`dragon64` = MC6809E at 888,625 Hz, SAM at 14.21 MHz, VDG at 3.55 MHz, screen 456x312, 49.97 Hz, both defaulting to the `dragon_fdc` cartridge (a WD2797 at 1 MHz); `dragon64` adds a MOS 6551 `acia`. `coco3` = `gime` "TCC1014 (VC2645QC)" at 28.63 MHz. ## The recipe (run 2026-11-26) ```sh # MAME_ROMPATH from the family's environment profile python -I scripts/mame_run.py --machine coco --ext "" --frames 180 python -I scripts/mame_run.py --machine coco --frames 180 --trace-frames 60 # with the disk cartridge python -I scripts/mame_run.py --machine dragon32 --frames 180 --trace-frames 60 python -I scripts/mame_run.py --machine dragon64 --frames 250 ``` `scripts/mame_run.py` writes `tests/mame_traces//run.lua` and runs, in that directory: ``` nice mame -rompath "$MAME_ROMPATH" -video none -sound none -nothrottle \ -noreadconfig -skip_gameinfo -snapshot_directory snap -autoboot_script run.lua \ -seconds_to_run N [-ext ""] [-debug -debugger none -log] ``` The Lua installs write taps on `:maincpu`'s program space for FF00-FF3F (PIAs), FF40-FF5F (cartridge I/O) and FFC0-FFDF (SAM), held in globals; logs `time W address data`; with `--trace-frames` it runs the debugger command `trace cpu.trace,maincpu,noloop,{tracelog "%04X %02X %02X %04X %04X %04X %04X %02X %02X %d ",pc,a,b,x,y,u,s,dp,cc,totalcycles}` and `trace off,maincpu` after that many frames; after `--frames` it saves a snapshot and exits. Everything stays in the git-ignored `tests/mame_traces/`. ## What the runs showed (OBSERVED, MAME's model) | Run | Emulated | Writes logged | Trace | Screen at the end | | --- | --- | --- | --- | --- | | `coco`, no cartridge | 3.00 s | 2,562 | - | Extended Color BASIC banner and `OK` (default BIOS `b12e11`) | | `coco`, disk cartridge | 3.00 s | 2,599 | 203,671 instructions in the first 60 frames (894,950 cycles) | "DISK EXTENDED COLOR BASIC 1.1 / COPYRIGHT (C) 1982 BY TANDY / UNDER LICENSE FROM MICROSOFT / OK" | | `dragon32` (default slot: DragonDOS cartridge; run before the FF40-FF5F tap was added) | 3.60 s | 1,291 | 242,758 instructions in the first 60 frames (1,065,949 cycles) | "DRAGONDOS 1.0 / OK" | | `dragon64` (default slot: DragonDOS) | 5.00 s | 1,435 | - | "DRAGONDOS 1.0 / OK" with the cursor | Facts the board docs use from these runs: the reset vectors (A027 Color BASIC 1.2, B3B4 Dragon 32); the PIA set-up order and values (34h, then FF03 = B5h, FF23 = 37h, [pia-io.md](pia-io.md)); PIA0 written through its FF1C-FF1F mirror by Color BASIC; the SAM writes at reset and during the start-up screen ([sam.md](sam.md)); the disk controllers' first register writes ([disk.md](disk.md)); the Dragon 64's ACIA writes at FF06/FF07; the CPU's average of 4.39 cycles per instruction while BASIC starts and idles (894,950 / 203,671), 4.39 on the Dragon (1,065,949 / 242,758), which the speed arithmetic uses. ## What MAME can and cannot decide Can: find differences in the PIA, SAM and disk-register write streams, the instruction stream and its cycle counts from reset, interrupt entry points, and final pictures over a few emulated seconds of firmware. It is the board's lockstep detector at milestone 1 (as m6809-python's rung 4 uses it on Williams), with every difference a question. Cannot: judge the SAM's line phase (it uses 228 VDG clocks a line: C2), the cross modes' pictures on real hardware, artifact colours, the Dragon's PAL padding, the sound bus mixing, or the disk controller's timing (its CoCo controller is a different chip: C6). Every MAME disagreement is a question, never a verdict.