# winuae: a one-instruction referee around WinUAE's 68000 CPU-tester core A one-instruction driver around WinUAE's 68000 CPU-tester core ("cputest", Toni Wilen and the UAE authors), used by m68000-python as a closed-box referee: m68000-python's `validation/referees/referee.py`, `calibrate.py`, `questions.py`, `bus_errors.py` and `rerun_680x0.py` (and `tests/test_referee_evidence.py`) run the built binary and read what it prints. Nothing in m68000-python includes or copies from this folder. Tool `winuae-referee`, version 0.2.0 (`CHANGELOG.md`): WinUAE pinned at `6e0d5ae` (2026-10-27), the commit that gave WinUAE's tree its `COPYING`, since 2026-11-24 (Aubrey's decision; 0.1.0 was pinned at `1977af5`). Until 2026-11-24 this was the stand-alone repository `m68000-winuae-referee` (now archived as `zzz-m68000-winuae-referee`); its two commits were merged into this repository's history with the folder. The build steps are unchanged; the build lands at a shorter path than the stand-alone repository's (below). ## Paths Under **`$EMU_TOOLS_GPL2`** (a checkout of `emu-tools-gpl2`): | Path | What | | --- | --- | | `tools/winuae/build_winuae.py` | fetches WinUAE at the pin and builds the referee | | `tools/winuae/build/winuae_referee` | the referee, built (git-ignored): m68000-python finds it here through `EMU_TOOLS_GPL2` (its `WINUAE_REFEREE` was retired on 2026-11-24) | | `tools/winuae/build/build-info.json`, `build/PIN` | compiler, flags and the WinUAE commit; the commit alone | | `tools/winuae/upstream/winuae-6e0d5ae15a9e/` | WinUAE's source at the pin, fetched (git-ignored, never committed) (the 0.1.0 tree was moved aside on 2026-11-24) | | `tools/winuae/tests/smoke.py` | the smoke test | | `tools/winuae/winuae_referee.cpp`, `winuae_shim.cpp`, `winuae_shim.h` | the driver and the Unix stand-ins | The stand-alone repository built to `build/winuae/winuae_referee` and fetched into `src/`; both are now one level shorter (`build/`, `upstream/`). ## Build python3 -I "$EMU_TOOLS_GPL2/tools/winuae/build_winuae.py" python3 -I "$EMU_TOOLS_GPL2/tools/winuae/build_winuae.py" --version # winuae-referee 0.2.0 (WinUAE 6e0d5ae) The script downloads GitHub's archive of at **`6e0d5ae15a9e7ae071d64fa052a34429ed787476`** (2026-10-27) into `upstream/` (once; a tree whose fetch did not finish stops the script until it is moved aside, and nothing is ever deleted), then builds with `g++` (C++17, `-O2`, zlib), up to eight jobs under `nice`: about three minutes on the family's machine (2026-11-24). Exit status as the family's tool contract says: 0 built, 2 a usage error, 3 the source could not be fetched, anything else a failed build. Every run rebuilds `build/` from the fetched tree, so a checkout that held a 0.1.0 build gets the new pin's by running the script once; `build/PIN` and `build/build-info.json` name the commit it was built from. ## The referee's protocol The binary reads one case per line on standard input and writes one result per case on standard output, all numbers hexadecimal: - `C d0..d7 a0..a6 usp ssp sr pc : ...`: a case (registers, SR, the instruction's own address, then n bytes of memory). - `B `: a bus-error region for the cases that follow (mode bit 0 data read, bit 1 write, bit 2 program read); size 0 turns it off. - `F` flushes the output (end of a batch); `Q` quits. Each case answers `R exc= pc= sr= r= usp= ssp= cyc= excyc= trace= frame= frame1= extra= a= w= flags=`: the exception the instruction raised (0 for none); the registers at the moment of the exception (the tester never executes the exception itself; it builds the frame separately); the stack frame it builds, and the partial group 1/2 frame when an odd vector turns the exception into an address error; the instruction's data accesses in order (`a`, kind, size and address; not its prefetches) and its byte writes (`w`); the clock count up to the exception (`cyc`); and `excyc`, the exception's own cost as the tester's hardware side adds it before comparing with a measured count. **Every output is OBSERVED** (WinUAE at `6e0d5ae`, via winuae-referee 0.2.0): a closed-box run of an emulator's core, never a hardware fact. ## How the driver is built (moved from m68000-python's docs/referees.md) **What was built.** WinUAE's CPU tester (`cputest`, readme `cputest/readme.txt`) generates its test data on a PC by running each test instruction on a special core that `gencpu` emits when built with `CPU_TESTER` set: `cpuemu_90_test.cpp`, the 68000 in cycle-exact prefetch mode with address and bus errors. That core, not WinUAE's emulator loop, is what the Amiga-side program compares real hardware against. `build_winuae.py` follows the readme's build steps on Linux: gencpu with `CPU_TESTER` switched on (the switch is a `#define 0` in `gencpu.cpp`, changed in a copy), then the generator's own sources (`cputest.cpp`, `cputest_support.cpp`, `newcpu_common.cpp`, `readcpu.cpp`, `disasm.cpp`, the FPU and softfloat units it links) with two Unix adjustments made to copies in `build/`: `od-unix/machdep/m68k.h` defines `cctrue()` inline where the tester defines its own, and TCHAR-wide calls get a char overload (`winuae_shim.h`). `winuae_referee.cpp` `#include`s the fetched `cputest.cpp` (renaming its `main`), sets up one test region over the 24-bit space, and for each case loads the state, runs the instruction's handler once, and prints what the generator would have recorded. The build took one attempt at each step; nothing blocked it. **What it models, and what it does not.** The tester never executes an exception: when the instruction raises one, it records the exception number and builds the frame separately (`doexcstack`), and the Amiga side adds a fixed cost for the exception's own processing (`cputest/main.c`, `getexceptioncycles`: 58 for a bus error, 54 for an address error after its aborted access, 34 for vectors 4-11, 30 for TRAPV, 44 for an interrupt, and 28 more when an odd vector turns a group 1/2 exception into an address error). So the referee's view is the state *at the moment the exception is raised* plus the frame; `referee.py` recovers the same view from a corpus case or a core run (the frame read off the stack, the SSP before it, the SR it stacked). The core reads the prefetch queue from memory ("no real prefetch"), so the queue's contents and the order of bus cycles are not modelled; the driver logs the order of the instruction's data accesses, a T3 detector. Cases it cannot represent are counted as not judged: an access in the top 1 KB of the address space (where the tester builds its frames), an odd SSP when an exception is taken, a double fault, RESET in supervisor mode (the tester treats it as a reset) and a STOP that stops. ## Smoke test python3 -I "$EMU_TOOLS_GPL2/tools/winuae/tests/smoke.py" Needs no ROM: it checks the version line and the usage-error exit status, and, once the referee is built, that `build/PIN` names the pin (a build left from an older pin fails) and that the fetched tree carries upstream's `COPYING` with the GPL-2.0 text; then it runs a NOP and a TRAP #15 of its own through it and checks the PC, the clock count, the vector, the frame and the exception cost. Under a second. ## Gate (2026-11-24) **0.2.0, WinUAE `1977af5` to `6e0d5ae`.** The driver built unchanged at the new pin; its rename of the tester's trim helper, which only the old pin needed, was then dropped (`CHANGELOG.md`). The 68000 tester cores gencpu generates are byte-identical at both pins; five of the twenty objects differ (`cpuemu_95_test`, `disasm`, `fpp`, `newcpu_common` and the driver), from the changed headers they include, so the binaries differ. m68000-python's own commands (run, unchanged, from its checkout at `0a0b5bb` with its CPython 3.14 venv), with `WINUAE_REFEREE` naming a 0.1.0 build at `1977af5` and then the 0.2.0 build: `validation/referees/calibrate.py winuae` prints the same report apart from wall time (`TOTAL winuae vs m68000: 308416/314988 judged cases agree (317500 cases, 2512 not judged)`) and writes a byte-identical `--dump` of its 6572 disagreements; `bus_errors.py` prints the same table apart from wall time (read 87930/97354, write 23327/70378, program 76792/232309 agree) and a byte-identical `--dump`; `tests/test_referee_evidence.py` passes (33 tests) both times; `questions.py` prints an identical report and `rerun_680x0.py --jobs 4` an identical table and `--json` file, apart from wall time. No number moved. **0.1.0, the fold.** m68000-python's own commands, with `WINUAE_REFEREE` naming the stand-alone repository's build and then this folder's: `validation/referees/calibrate.py winuae` (`TOTAL winuae vs m68000: 308416/314988 judged cases agree`, as recorded on 2026-11-19) and `bus_errors.py` print the same reports apart from wall times, and `tests/test_referee_evidence.py` passes (33 tests) both times; the two binaries are byte-identical, and so are the fetched trees. ## Upstream, licence and pin - **WinUAE** (Toni Wilen and the UAE authors), , pinned at **`6e0d5ae15a9e7ae071d64fa052a34429ed787476`** (2026-10-27, "Add COPYING file") since 2026-11-24, by Aubrey's decision of that day. 0.1.0 was pinned at `1977af501f6c3389c2eefe119ecb10c82d6582f3` (2026-09-17), the commit m68000-python's `docs/referees.md` names, whose tree had no licence file. - **Why this repository, not `emu-tools-gpl`** (verdict and evidence in `../../docs/upstreams.md`): at the pin the tree's licence file, `COPYING`, is the GPL-2.0 text, and 41 of the 48 upstream files the tool compiles, includes or reproduces, among them `cputest.cpp`, carry no licence statement, so they are GPL-2.0-only by the family's rule of 2026-11-24; `include/uae/types.h`, which the driver and almost every unit include, is GPL-2.0-only in its own words. The rest grant "or later" or are permissive (SoftFloat, BSD), which GPL-2.0-only code may be combined with. - **The tool as built is GPL-2.0-only.** `winuae_referee.cpp` `#include`s WinUAE's `cputest.cpp` and reproduces parts of WinUAE's cputest code (the handler-table set-up of `cputest.cpp` and the 68000 branch of `cputest/main.c`'s exception-cycle count), so it is WinUAE-derived: its header is GPL-2.0-only from 2026-11-24 (it said GPL-2.0-or-later, which is not ours to grant for WinUAE's code); both reproduced pieces are unchanged upstream between `1977af5` and `6e0d5ae`. `build_winuae.py` is our own code and keeps GPL-2.0-or-later; the two shim files are our own glue and keep their MIT headers (`../../notices/MIT-emulator-family.txt`); `tests/smoke.py` is new here, GPL-2.0-only. This repository is GPL-2.0-only (`../../LICENSE`; the stand-alone repository carried a copy of the same GPL-2.0 text). Code flows one way: never copy from here into an MIT project. - **No WinUAE source is committed**, here or in the stand-alone repository's history (its seven files were all ours); the source is fetched at the pin into `upstream/`. If the tool is ever shared, its complete source (this folder plus WinUAE at the pin) goes with it. - **History.** It was in m68000-python from `b3ac8ed` (2026-09-21) to 2026-11-19, including tag `v0.1.0` and the PyPI 0.1.0 sdist, then moved out (provenance rewrite, wave 2; m68000-python's `docs/provenance.md`) into the stand-alone repository, and into this folder on 2026-11-24. - Checked against `emulator-lineage/docs/sources.md` (whose row still says GPL-2.0-or-later and names the stand-alone repository; an update is proposed for its owner).