# ym2203-lle A headless harness around the SSG block of nukeykt's YM2203-LLE, a die-derived model of Yamaha's YM2203C: register writes from an event file, one turn of the SSG's shared tone and envelope counter per step, and the three analogue outputs per step. Its SSG is Yamaha's own PSG, which ay8910-python uses as the judge of its Yamaha parts. Version 0.1.0 (`CHANGELOG.md`). Regrouped on 2026-11-24 from `tools/ay8910-python/` (ay8910-python's referee driver, gathered here on 2026-11-22); the tool now fetches and builds its upstream itself, and `run.py` speaks the family's tool contract, version 0 (`emu-tools/docs/contract.md`), for its manifest, command line and exit codes. The harness's own command line and outputs are as they were. ## Paths Under **`$EMU_TOOLS_GPL`** (a checkout of `emu-tools-gpl`): | Path | What | | --- | --- | | `tools/ym2203-lle/build.sh` | fetches YM2203-LLE at the pin and builds the harness | | `tools/ym2203-lle/build/ssg_ref` | the harness, built (git-ignored) | | `tools/ym2203-lle/build/build-info.json` | compiler, flags, upstream commit | | `tools/ym2203-lle/run.py` | the contract's command line | | `tools/ym2203-lle/tests/smoke.py` | the smoke test | | `tools/ym2203-lle/ssg_ref.c` | the harness's source (old location: `tools/ay8910-python/ssg_ref.c`, now a link to this file) | ## Build "$EMU_TOOLS_GPL/tools/ym2203-lle/build.sh" Clones into `upstream/YM2203-LLE` (git-ignored) at **`817387fd89affd0db5331034d6ae04d919e25a5e`** (a clone with local changes stops it; it never deletes anything) and compiles `ssg_ref.c` with the model's `fmopn.c` into `build/ssg_ref` with `gcc -O2 -w`, ay8910-python's flags (`CC` and `CFLAGS` override). No patches. A second or two. Gated on 2026-11-24 against ay8910-python's own `validation/build_referees.sh`: `build/ssg_ref` is byte-identical to the binary it builds, and every case of the consumer's `scripts/ssg_referee.py` gives byte-identical raw output (`CHANGELOG.md`). ## The harness (`build/ssg_ref`) "$EMU_TOOLS_GPL/tools/ym2203-lle/build/ssg_ref" EVENTS.bin OUT.bin STEPS PHASE The harness first selects the prescaler at which one step is four master clocks (FM = master / 2, SSG = master / 1). `EVENTS.bin` holds little-endian records of a 64-bit step, a register and a value, sorted, at most one to a step; a record is an address write (A0 = 0) over the high half of one master clock and a data write (A0 = 1) over its low half, on the `PHASE`th master clock (0-3) of its step. `OUT.bin` receives, per step, sampled at its end, the three outputs as the model gives them: three little-endian 32-bit floats (channel A, B, C), each one of the 32 levels of its DAC table. Exit status 2 on a usage error, 1 on an unreadable file. ## run.py (the contract) python3 -I run.py --input WRITES.jsonl --cycles N --out DIR [--phase P] python3 -I run.py --version `WRITES.jsonl` is JSON Lines, one write a line: `t` (the step), `reg` and `value` (0-255), at most one to a step. `--cycles` is the number of steps, `--phase` the master clock a write lands on (0 by default, as ay8910-python runs it). Writes `ssg.bin` (format `ym2203-lle/ssg-levels`, layout `, pinned at **`817387fd89affd0db5331034d6ae04d919e25a5e`**. LICENSE: the GPL-2.0 text; both files the harness compiles and includes, `fmopn.c` and `fmopn.h`, grant "either version 2 of the License, or (at your option) any later version", so it passes the family's rule of 2026-11-24 and stays in this GPL-3.0-or-later repository (`../../docs/upstreams.md`). Not committed here. - **`ssg_ref.c`:** our code (alewman), first published under MIT in ay8910-python (`../../notices/MIT-emulator-family.txt`); it keeps its MIT header. `build.sh`, `run.py` and `tests/smoke.py` are new here, GPL-3.0-or-later. Built with the model, the harness is a GPL-2.0-or-later work, distributable under GPL-3.0-or-later with this repository (`../../LICENSE`). If a build is ever shared, its source, this folder and the model at its pin go with it. - Checked against `emulator-lineage/docs/sources.md`.