# ym2608-lle: closed-box harnesses around YM2608-LLE Two harnesses around nukeykt's YM2608-LLE, a die-derived model of Yamaha's OPNA family built from decapped chips (the YM2608B by Raki, the YM2610 by John McMaster, the YM2612 by HardWareMan, as the model's notice credits): a probe of its YM2610 build for ym2610-python, and an event-file referee of its YM2612 build that megadrive-python's withdrawn sound cores used. Moved here from `emu-tools-gpl` on 2026-11-24 (licence verdict in `../../docs/upstreams.md`). Version 0.1.0 (`CHANGELOG.md`): since 2026-11-24 the tool fetches and builds its upstream itself (`build.sh`), and `run.py` gives both harnesses the contract's manifest, `--version` and exit codes. The binaries keep the command lines and outputs they had. ## Paths Under **`$EMU_TOOLS_GPL2`** (a checkout of `emu-tools-gpl2`): | Path | What | | --- | --- | | `tools/ym2608-lle/build.sh` | fetches YM2608-LLE at the pin and builds both binaries | | `tools/ym2608-lle/build/lle2610_probe` | the YM2610 probe, built (git-ignored) | | `tools/ym2608-lle/build/lle2612_ref` | the YM2612 referee, built (git-ignored) | | `tools/ym2608-lle/build/build-info.json` | compiler, flags, upstream commit, patches per binary | | `tools/ym2608-lle/run.py` | the contract's command line over both | | `tools/ym2608-lle/tests/smoke.py` | the smoke test | | `tools/ym2608-lle/lle2610_probe.c` | the probe's source (old location: `emu-tools-gpl/tools/ym2610-python/lle2610_probe.c`, now a link to this file) | | `tools/ym2608-lle/lle2612_ref.c`, `build_lle2612_ref.sh` | the referee's source and its old one-binary build (old location: `emu-tools-gpl/tools/megadrive-python/validation/`, where only a note remains) | | `tools/ym2608-lle/patches/ym2610-build-fix.patch` | the YM2610 build fix (below) | ## Build "$EMU_TOOLS_GPL2/tools/ym2608-lle/build.sh" Clones into `upstream/YM2608-LLE` (git-ignored) at **`7a2aca7b6830b96e48e3a4e1a40d15525993fa60`**, or checks an existing clone out at the pin (a clone with local changes stops the script; it never deletes anything). Then it compiles, with `gcc -O2 -w` (the consumers' flags; `CC` and `CFLAGS` override; `patch` must be on the PATH): - `build/lle2610_probe`: `lle2610_probe.c` with the model's YM2610 build (`fmopna_2610.c`), from a copy of the model in `build/src-2610/` with `patches/ym2610-build-fix.patch` applied. At this pin the YM2610 build does not compile as published: two assignments in the shared implementation name members the YM2610 build's structure does not declare. The patch drops those two lines, the same change ym2610-python's old build made by dropping the lines its compiler named; the script checks that exactly two lines went. The fetched tree is not touched. - `build/lle2612_ref`: `lle2612_ref.c` with the model's YM2612 build (`fmopna_2612.c`), from the fetched tree as published (no patch). A few seconds on the family's machine (2026-11-24). Gated on 2026-11-24 against the consumers' builds: both binaries are byte-identical to the ones ym2610-python's `validation/build_referees.sh` and `build_lle2612_ref.sh` build from their own checkouts, and the probe's full output is identical (`CHANGELOG.md`). ## What they measure What the model's pins show, clock by clock: the probe sets the YM2610's input pins, calls the model's clock function and reads its output pins (the serial DAC output, BUSY, the timer and flag behaviour, the SSG, both ADPCM units); the YM2610B bonding input is held at 0. The YM2612 referee drives timed register writes on the pins (chip select, write strobe, the two address lines and the data bus, held for 16 chip clocks) and records the chip's two DAC output pins. **Every output is OBSERVED** (YM2608-LLE at `7a2aca7`, via ym2608-lle 0.1.0): a closed-box measurement of a die-derived model, never a hardware fact, overruled by any document or hardware measurement that disagrees. ## lle2610_probe "$EMU_TOOLS_GPL2/tools/ym2608-lle/build/lle2610_probe" [NAME [ARG ...]] Run without arguments it makes every measurement and prints them as text (about 10 to 16 seconds here); with a name it makes one: clock, fm, ssg, busy, timers, flagctl, pages, adpcma, adpcmb, lfo. `lfo` takes a rate and optionally a number of windows (the AM depth per 32 samples); `adpcma` takes a constant ROM byte and optionally a sample count and the total and channel levels; `adpcmb` takes a constant ROM byte and optionally a sample count and delta-N. One "clock" is one period of the input clock; serial output bits are taken at the rising edges of the shift clock, counted from the first one after SH1 rises. ym2610-python records the full run in its `validation/results/lle2610_probe-2026-11-19.txt`. ## lle2612_ref "$EMU_TOOLS_GPL2/tools/ym2608-lle/build/lle2612_ref" EVENTS.bin OUT.bin CHIP_CLOCKS [EVERY] `EVENTS.bin` holds little-endian records of a 64-bit chip-clock count (the master clock divided by 7), a port byte and a data byte, sorted by clock. `OUT.bin` receives one record per EVERY-th chip clock (1 by default): the two DAC output pins as signed 16-bit words, left then right, each a 9-bit two's-complement sample with 1 added to a non-negative value, or the bare sign between channels. Exit status 2 on a usage error. The old one-binary build still works, for a YM2608-LLE checkout named by `YM2608_LLE_SRC`: `YM2608_LLE_SRC=DIR sh build_lle2612_ref.sh [OUT_DIR]` (the YM2608-LLE step of megadrive-python's old `validation/build_referees.sh`, byte-identical binary). ## run.py (the contract) python3 -I run.py --machine ym2610 --out DIR [--measure NAME [ARG ...]] python3 -I run.py --machine ym2612 --input WRITES.jsonl --cycles N --out DIR [--stride N] python3 -I run.py --version `ym2610` runs the probe (every measurement, or one with its arguments) and writes its text as `probe.txt` (format `ym2608-lle/probe-text`). `ym2612` reads a write script, JSON Lines with `t` (the chip clock the write starts on), `port` (0-3: address and data of part I and II) and `data` (0-255), runs the referee for `--cycles` chip clocks and writes `ym2612.bin` (format `ym2608-lle/dac-pins`: the records above, layout `, pinned at **`7a2aca7b6830b96e48e3a4e1a40d15525993fa60`**. Its LICENSE is the GPL-2.0 text; the implementation files grant "version 2 or any later version", but the YM2610 and YM2612 build wrappers the harnesses compile and include carry no grant, so by the family's rule of 2026-11-24 they are GPL-2.0-only, and so is each harness as built. - **These harnesses:** our code (alewman), first published under MIT in ym2610-python and megadrive-python; each keeps its MIT header (`../../notices/MIT-emulator-family.txt`). `build.sh`, `run.py`, `tests/smoke.py` and the patch are new here, GPL-2.0-only (the patch carries the model's context lines). This repository is GPL-2.0-only (`../../LICENSE`). YM2608-LLE is not committed here; if a built harness is ever shared, its source, this folder and the model at its pin go with it. - Checked against `emulator-lineage/docs/sources.md`.