# mednafen: Mednafen 1.32.1, fetched and built for the family (mednafen-build 0.1.0) Mednafen 1.32.1 built from its pinned release tarball, in the two forms the family runs as a closed box: - **`pce`**: the PC Engine trace build. The instruction-trace patch (`patches/mednafen-trace.patch`) makes the program write a per-instruction HuC6280 trace, for huc6280-python's rung 4b (Mednafen as an emulator referee beside MAME) and pcengine-python's lockstep recordings. - **`ss`**: the Saturn build, as published (no patch), sh2-python's Saturn detector. Version 0.1.0 (`CHANGELOG.md`). Since 2026-11-25 (decisions page T3) this folder holds the whole job: before, the patch alone was here (moved from `emu-tools-gpl` on 2026-11-24) and each consumer fetched the tarball and built Mednafen inside its own MIT repository. The programs run as separate executables; they do not write the shared contract's manifest yet (`build.py` has the contract's `--version` and exit codes). ## Paths | Path under `$EMU_TOOLS_GPL2` | What | | --- | --- | | `tools/mednafen/build.py` | fetches the tarball (SHA-256 checked) into `upstream/`, unpacks a tree per machine, patches, configures and builds: `python3 -I build.py --machine pce` or `--machine ss`; `JOBS` sets make's jobs (2 by default) | | `tools/mednafen/build/pce/bin/mednafen` | the PC Engine trace build (git-ignored) | | `tools/mednafen/build/ss/bin/mednafen` | the Saturn build (git-ignored) | | `tools/mednafen/build//build-info.json` | the tarball, patches and configure options of that build | | `tools/mednafen/patches/mednafen-trace.patch` | the trace patch (old location: `emu-tools-gpl/tools/huc6280-python/mednafen-trace.patch`, a link to this file) | | `tools/mednafen/tests/smoke.py` | the smoke test: version line, usage error, and, for each machine built, its pin and options, and for `pce` a trace of a program of its own | Who runs them: huc6280-python (`scripts/mednafen_trace.py`, `pce`; its `scripts/build_mednafen.py` runs this `build.py`), pcengine-python (`scripts/mednafen_record.py`, `pce`) and sh2-python (`scripts/build_referees.py`, `ss`), each through `EMU_TOOLS_GPL2` (emu-tools `docs/contract.md`, section 5). ## The builds Each keeps its consumer's configure options, in the order it gave them, so it is the program the consumer built before: - `pce` (from huc6280-python's `build_mednafen.py`): `--enable-pce`, pce-fast and every other system off, `--disable-nls --disable-alsa --disable-jack --disable-debugger --without-libflac`, installed under `build/pce`. - `ss` (from sh2-python's `build_referees.py`): `--disable-alsa --disable-jack --without-libflac` and every system but the Saturn off, installed under `build/ss` (sh2-python ran it from its build tree, `src/mednafen`, without installing; the program is the same apart from the install prefix compiled in for its data files). SDL2's development files are needed; libflac's are not installed here, hence `--without-libflac`. No sudo. A build is redone when the patch is newer than the program. Nothing is deleted: a half-unpacked tree stops `build.py` until it is moved aside. ## What it measures The `pce` build logs, from inside its CPU, one line per instruction (PC, A, X, Y, S, P and the cycle count in 7.16 MHz units, the master clock divided by 3), the eight MMU registers, and each read of the hardware page, in the text format huc6280-python's MAME replay reads; it stops by itself after `MEDNAFEN_TRACE_COUNT` instructions. Run it headless with SDL's dummy video and audio drivers (`SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy`, `MEDNAFEN_HOME`, `MEDNAFEN_TRACE=FILE`, `MEDNAFEN_TRACE_COUNT=N`; the consumers' scripts show the command line). **Every output is OBSERVED** (Mednafen 1.32.1, with the patch for `pce`): an emulator observed as a closed box, never a hardware fact. The patch applies to the pristine 1.32.1 tree; it touches `src/pce/huc6280.cpp`, `src/pce/huc6280.h` and `src/pce/pce.cpp`. Its licence preamble was corrected on 2026-11-24 (below); the rebuilt program was the same (the patch's hunks did not change; checked 2026-11-24 by building both and comparing the patched sources and a trace). ## Upstream, licence and pin - **Mednafen 1.32.1**, , the release tarball with SHA-256 `de7eb94ab66212ae7758376524368a8ab208234b33796625ca630547dbc83832` (the pin the consumers had). Its COPYING is the GPL-2.0 text. `huc6280.cpp` and `pce.cpp` grant "version 2 or any later version"; `huc6280.h` carries no licence statement, so by the family's rule of 2026-11-24 it is GPL-2.0-only, and a build of the tree is taken as GPL-2.0-only. - **The patch:** ours (alewman), first written in huc6280-python; it carries the three files' context lines, so it is GPL-2.0-only (its preamble said GPL-2.0-or-later until 2026-11-24, before the rule). - **`build.py`:** ours (alewman), GPL-2.0-only here; its steps were first published under MIT in huc6280-python and sh2-python, and that permission is kept for those parts (`../../notices/MIT-emulator-family.txt`). - This repository is GPL-2.0-only (`../../LICENSE`). Mednafen is not committed here; if a built program is ever shared, Mednafen's source at the release, the patch and this folder go with it. - Checked against `emulator-lineage/docs/sources.md` (Mednafen: closed box only).