# mesen2-runner changelog - **0.4.0** (2026-11-25): a second pinned upstream, **MesenCE** (Mesen2's continuation), for famicom-python's AccuracyCoin MesenCE column, which until now ran a MesenCE build kept in that MIT repository (decisions page T2). One runner, two cores. No Mesen2 patch; MesenCE is built as published. - `build.sh --core mesence` fetches MesenCE at `4b8a196e299b` (the commit famicom-python had built) into `upstream/MesenCE` and builds it as Mesen2 is built (`make core`, GCC, no LTO, no static linking), recording `upstream/build-info-mesence.json`. `--core mesen2`, or no option, is the old build. - `run.py --core mesen2|mesence` (single runs and `--batch`, not a batch line) runs that core's own build; `--lib` still wins, and `MESEN_CORE` does not override a core named by `--core`. A core not built exits 3 naming its path. - The manifest names the core's upstream and pin for either own build (MesenCE: commit `4b8a196e…`, `patches` `[]`, `built_by` `build.sh`), and its `contract` is now **1** (emu-tools' contract version 1 of 2026-11-25, which accepted the `end` field 0.3.0 already wrote). `--version` names both pins. - Gated: the smoke test passes (new: `--version`'s second pin, `--core`'s library choice and usage error, a batch line refusing `core`, and part 3, a NES run on MesenCE's own build: upstream, picture and an instruction trace with MesenCE's pad numbering). famicom-python's AccuracyCoin on MesenCE: 143 of 147 on its old build and on `--core mesence`, the same four failures and codes, and the script log's 256 result bytes identical (OBSERVED, 2026-11-25). - **0.3.0** (2026-11-24): what the consumers reported after moving to `run.py`. No Mesen2 patch. - **`emu.stop(code)` is reported, and ends the run cleanly**: the runner replaces the Lua call for the run, so the run ends at the end of the frame in which the script called it (Mesen2's own stop ran on another thread at a moment the host's timing picked and dropped the script log: 0.2.0 gave `stopped (code)` and exit 1 on the NES, `timeout` elsewhere, and no picture). The manifest's new `end` field says `{"by": "script-stop", "frame": F, "stop_code": C}`; the exit status stays 0 and `status` `ok` (the run did what the script asked; a non-zero code is the consumer's to read). The script log, trace, host stream and `--frames-out` picture end with that frame. - **`--until log:TEXT`** (the contract's `--until`): the run ends at the end of the frame in which the `--lua` script logs a line starting with TEXT; `--frames` is the most it runs. `end` records `until` and `reached`. - **`--frames-at` for `snes`**, with the NES's meaning (each frame's picture, equal to a run of that many frames with `--frames-out`). - **`--audio-out` ends exactly at `--frames`**: the emulator is held at the end of the frame before the recorder stops, so every run gives the same file, a prefix of what 0.2.0 wrote (about 0.08 frame short of `--frames` x rate / 60.0988, Mesen2 mixing in blocks; OBSERVED). - `snes-cx4`: the "host stream" line now counts the rows `run.py` writes (`R of F frames, complete`, or the missing ones, which also set `status`); 0.2.0 printed `0 frames` from the adapter's polled copy, which `run.py` does not use and no longer makes. The run is held at the end of its last frame, so a `--trace-window` reaching past it stops there. - The manifest's `script_messages` holds only Mesen2's lines from before the end of the last frame (0.2.0 also listed the player's lines from the frames the SNES and PC Engine ran while being stopped, which varied from run to run). - The famicom-python shims find the library without a variable: `MESEN_LIB`, `MESEN_CORE`, the checkout's hand build, then this tool's `build.sh` build; exit 3 naming them without one. `vanish_probe.py` falls back to this tool's build too. - Retired (moved to `attic/`, not deleted): the snes-python, pcengine-python and hg51b-python shims and their compat modules, which no family repository's code used any more. - README: `--trace-window` holds END minus START frames, from the end of frame START to the end of frame END, so END is excluded in Mesen2's frame column (OBSERVED on Mega Man X2); the new options; the run-to-run notes (compare `.gz` contents: gzip's header has a time stamp). - Gated: the smoke test passes (new checks for each option), and the outputs of 20 smoke-style cases on the NES, SNES, PC Engine and Cx4 machines plus a batch and the famicom shim are identical before and after (`audio.wav` excepted, by design: before, it varied between runs). - **0.2.0** (2026-11-24): what kept consumers on the old in-process drivers. No Mesen2 patch was needed: everything goes through Mesen2's exported settings and its Lua API. - **The whole script log**: `run.py` writes every `emu.log` line to a file as it is logged (Lua's io library, allowed for the run through Mesen2's DebugConfig), so `script-log.txt` is complete however long (Mesen2 keeps 500 lines), and ends with the last frame. The NES frames and the Cx4 host stream are read from it too: no frame lost between polls, and the host stream holds exactly frames 1 to `--frames`. The runner's end-of-run marker now comes after every script's last-frame callbacks. - **`--fds-bios PATH`**, else **`FDS_BIOS`**: the player's Disk System BIOS (loose or zipped), copied into the run's Mesen2 home for the run and removed afterwards; SHA-1 in the manifest. An FDS image without one exits 3. - **`--batch FILE`**: JSON lines of options, each a run with its own `--out`, in one process that starts the library once (it cannot start twice); a summary line per run. - **`--no-sprites`** for `pce`. - **`--reset-at N`** for `nes`, `snes` and `snes-cx4` (refused on `pce`, where Mesen2's Lua reset stalled the emulator), and **`--power-on-ram zeros|ones|random`** (zeros by default, recorded in the manifest's `power_on`) for every machine. - **SNES pictures repeat**: `snes` and `snes-cx4` turn off Mesen2's frame skipping at maximum speed, which made a picture one drawn two or three frames earlier and varied between runs (the cause of WaveHDMA's and `--reset-at`'s varying pictures; RAM was already zeros in `run.py`). The old SNES shim keeps Mesen2's defaults, as before. - **`--input` and `--lua` for `snes-cx4`** (port 1), and `--region` there as on `snes`. - The manifest names a MesenCE library (by its path) as MesenCE, its commit unknown. - README: Pillow is needed for pictures; every option documented. Smoke test covers each new option. The shims' command lines and outputs are unchanged (gated before and after). - **0.1.0** (2026-11-23): first version. The five Mesen2 drivers gathered on 2026-11-22 (famicom-, snes-, pcengine-, huc6280-python, and hg51b-mesen-harness folded in) regrouped as one runner with NES, SNES, Cx4 and PC Engine adapters; `run.py` speaks contract 0 (manifest, PNG frames, trace/insn for the NES, input scripts, exit codes); `build.sh` fetches Mesen2 `b9fa69d`, applies `patches/mesen2-detector-fixes.patch` and builds the core; the old entry points stay as shims with their command lines and outputs (gated before and after); the PC Engine driver, which stopped at import as parked, runs again.