# m68000-winuae-referee 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` run the built binary and read what it prints. Nothing in m68000-python includes or copies from this directory. **Licence: GPL-2.0-or-later** (`LICENSE`), because `winuae_referee.cpp` `#include`s WinUAE's `cputest.cpp` and reproduces parts of WinUAE's cputest code (the handler-table set-up and the 68000 branch of its exception-cycle count). The two shim files are our own glue and carry MIT headers, but the tool as a whole is GPL (family charter, "Licences and provenance", rule 6). Code flows one way: never copy from here into an MIT project. Local only. Moved out of the MIT repository m68000-python on 2026-11-19 (provenance rewrite, wave 2; m68000-python `docs/provenance.md`). It was in m68000-python from `b3ac8ed` (2026-09-21) to that date, including tag `v0.1.0` and the PyPI 0.1.0 sdist. If this tool is ever shared, its complete source (this directory plus WinUAE at the pinned commit) goes with it. ## Build and use ```sh python build_winuae.py # fetches WinUAE 1977af50 into src/, builds build/winuae/winuae_referee export WINUAE_REFEREE=$PWD/build/winuae/winuae_referee cd ../m68000-python && python validation/referees/calibrate.py winuae ``` Expected: `TOTAL winuae vs m68000: 308416/314988 judged cases agree` (re-run 2026-11-19 from this directory; the binary is byte-identical to the one built inside m68000-python before the move). | File | What | Licence | | --- | --- | --- | | `winuae_referee.cpp` | the driver | GPL-2.0-or-later (WinUAE-derived) | | `winuae_shim.cpp`, `winuae_shim.h` | Unix stand-ins for od-win32 helpers | MIT (own), inside a GPL tool | | `build_winuae.py` | the build steps, moved from m68000-python's `build_referees.py` | GPL-2.0-or-later as part of this tool (own code) | | `src/`, `build/` | WinUAE at the pinned commit and the build | WinUAE's (GPL-2.0-or-later) | ## 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_referees.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.