# Provenance Audited 2026-11-13 (provenance audit, wave 1) at `71e34eb` on `master`, all branches and history included. The standard: nothing copied or transcribed from GPL/LGPL (or unlicensed, or AI-objecting authors') code; facts about the hardware are usable with their source named; permissive sources keep their notice beside what was taken. No GPL source was opened for this audit. Verdicts: **clean** (own work from facts or permissive sources, cited), **cite** (clean, but a source name or notice is owed), **rewrite**, **unclear**. ## Summary | Verdict | Count | | --- | --- | | clean | 9 | | cite | 3 | | rewrite | 0 | | unclear | 0 | ## The code | Part | Where its behaviour came from | Licence of the source | Verdict | | --- | --- | --- | --- | | Instruction handlers (`_alu.py`, `_loads.py`, `_control.py`, `_rotate.py`, `_flags.py`) | GBCTR's per-M-cycle tables and pseudocode; Pan Docs; Mooneye results (`daa`, `reg_f`, ...); corrected against die tracings (rung 5: Gekkio's VHDL; dmg-sim until 2026-11-26, see "Author respect"); SonoSooS's "Gameboy CPU internals" gist cited until 2026-11-26, now set aside and re-cited ("Author respect") | GBCTR CC BY-SA 4.0 (facts); Pan Docs CC0; Mooneye MIT | clean | | `_core.py` (bus, dispatch, HALT), `stop.py` | GBCTR, Pan Docs (SonoSooS until 2026-11-26, set aside); SameBoy's `GB_cpu_run`, `halt()`, `stop()` named as agreeing readings; HALT entry from Gekkio's VHDL (run as a simulator); HALT wake from dmg-sim until 2026-11-26, now from Mooneye ROMs (see "Author respect") | as above; SameBoy Expat; gb-research VHDL MIT OR Apache-2.0; Mooneye MIT | clean (behaviour only; no SameBoy code taken: `provenance_check.py` finds only a generic half-carry expression) | | `_opcodes.py` (512 mnemonics, lengths, timing categories) | Generated by `scripts/gen_opcode_table.py` from GBCTR `opcodes.toml` (mnemonic text, category) and gbdev `gb-opcodes` `Opcodes.json` (length) | GBCTR CC BY-SA 4.0; gb-opcodes CC0 | **cite**: the file names GBCTR but not its licence. Mnemonics and timing classes are facts about the instruction set, so this is not treated as an adaptation; add "GBCTR, CC BY-SA 4.0, Joonas Javanainen" to the header. If share-alike exposure is unwanted, the mnemonics can come from gb-opcodes (CC0) instead | | `harness.py` (minimal test-ROM host) | Modelled on Gekkio's mock SoC `test_soc.vhd` (named in the docstring) | MIT OR Apache-2.0 | clean | | `disasm.py`, `debug.py`, `trace.py`, `console.py`, `state.py`, `cpu.py`, `__main__.py` | Own; mnemonics from `_opcodes.py` | n/a | clean | | `replay.py`, `scripts/mame_trace.py` | MAME 0.285 run as a closed-box detector; trace format | MAME `lr35902.cpp` is BSD-3-Clause anyway | clean | | `scripts/die/test_soc_irq.vhd` | A copy of Gekkio's `test_soc.vhd` with two signals added, header and SPDX kept | MIT OR Apache-2.0, (c) 2020-2022 Joonas Javanainen | **cite**: the SPDX line and copyright are kept; the MIT permission text itself is not in the repository. Add a `LICENSES/MIT.txt` (or the notice in the file) naming Joonas Javanainen | | `scripts/die/bus_dump_tb.vhd`, `scripts/die_*.py` | Own testbenches | n/a | clean. (`scripts/dmgsim/bus_probe.sv` and `scripts/dmgsim_*.py`, own code that drove dmg-sim and named its internal nets, left the repository on 2026-11-26: "Author respect") | | `scripts/gbctr_timing.py`, `gen_opcode_table.py`, `fetch_references.py`, `build_referees.py`, `pinned_*.json` | Own tools; outputs from GBCTR (`tests/gbctr_timing.json`) are git-ignored, never committed | n/a | clean | | Tests (`tests/*.py`) | SingleStepTests sm83 and adtennant `sm83-test-data` (fetched, not committed); blargg and Mooneye ROMs (fetched); Gambatte hwtests' hardware-captured results cited by name in comments; SameSuite | SST MIT; adtennant MIT; Mooneye MIT; blargg none stated (freely distributed); Gambatte GPL-2.0 (ROMs run, outputs used as hardware facts); SameSuite X11 | clean | | `docs/timing.md` | Quotes two SameBoy C expressions (`interrupt_queue = gb->interrupt_enable`, the DMG HALT `GB_advance_cycles(gb, 2)` line) and one SameBoy comment | Expat, (c) Lior Halphon | **cite**: add "SameBoy, Expat licence, (c) Lior Halphon" beside the quotes | | Other docs | Facts with their sources; Gambatte's `testrunner.cpp` result convention described in prose (a fact about the test format, no code) | as cited | clean | ## Tests and fixtures Nothing third-party is committed (`.gitignore` excludes `reference/`, ROMs, traces, generated JSON). Fetched and pinned in `scripts/pinned_repos.json` / `pinned_files.json`: SingleStepTests sm83 (MIT; generated by JSMoo from Ares, emulator-derived), adtennant v2 (MIT), Mooneye source and built ROMs (MIT), blargg gb-test-roms (no licence stated), gambatte-core `test/` (GPL-2.0, run as ROMs only), SameSuite (X11), SameBoy (Expat, builds the free boot ROM and a tester), Pan Docs (CC0), GBCTR (CC BY-SA 4.0), gbops (MIT), gb-opcodes (CC0), gbit (MIT), gb-research sm83-cpu-core (CC0 / MIT OR Apache-2.0), little-things-gb (none stated). The SonoSooS gist (none stated) was pinned until 2026-11-26 and is set aside ("Author respect"). ## provenance_check.py runs `pcengine-python/scripts/provenance_check.py --repo sm83-python --reference --licences sm83-python/scripts/pinned_repos.json`, permissive references only: - `reference/src/SameBoy/Core` (Expat): 3 pairs. The SameBoy comment quoted in `docs/timing.md` (attributed there); a half-carry expression in `_alu.py` (the generic formula); a mnemonic list in `tests/test_readability.py`. Nothing copied. - `reference/src/gb-research/sm83-cpu-core` (MIT OR Apache-2.0): hits only on `scripts/die/test_soc_irq.vhd` (the declared copy) and on this repository's own testbench files that the referee build copies into that tree. - `reference/src/gbops` (MIT): 0 pairs. - `reference/src/gbit` (MIT): the undefined-opcode list and mnemonic lists (facts). Not run against GPL references (gambatte-core) or CC BY-SA ones. ## History No file was ever deleted and no removed line cites a GPL source (`git log --all --diff-filter=D`, and removed lines searched for emulator names, "transcrib", "port of", "copied", GPL). Nothing to rewrite for provenance. The owner's full name, once in the author fields of 10 commits, was mapped to the handle `alewman` by a history rewrite (2026-11-21, wave D of the family's history clean-up; commit hashes older than that changed with it). `docs/handoff-brief.md` holds machine paths (`/data/emu/...`). ## Owed - SPDX headers: 3 of 51 source files carry one (charter rule 2). - The three **cite** items above. ## Closed-box sources removed (2026-11-24) Aubrey's rule of 2026-11-24: an MIT repository does not download or keep the source of anything the family's `sources.md` marks closed box only. gambatte-core's pin (https://github.com/pokemon-speedrunning/gambatte-core @ `5a41a68c`, GPL-2.0) now fetches only `test/hwtests/` (the suite); its test runner, assembler script and build files moved aside unopened, out of the repository. metroboy's pin is its prose only (README, docs, notes). **Kept, with a question for Aubrey:** dmg-sim (`786f8c8a`, CC BY-SA 4.0, closed box only), because `scripts/build_referees.py` builds it with Icarus Verilog for the die rung and no shipped build exists. (Answered 2026-11-26, for a different reason: dmg-sim and metroboy are set aside for the author's wishes; see "Author respect" below.) ## Author respect (2026-11-26) Kept apart from the licence findings above: this is respect, not law. furrtek objects to AI use of his work, and the family sets his work and its lineage aside for that wish (Aubrey, 2026-11-26; emulator-lineage `docs/sources.md` at `d9b8ce2`, the "set aside (author's wishes)" verdict and the Excluded row). The lineage that touched this repository: - **msinger's dmg-sim** (`786f8c8a`): SystemVerilog generated from msinger's dmg-schematics, whose DMG-CPU B schematics "were derived from the schematics in furrtek/DMG-CPU-Inside" (its README); its `sm83/` is msinger's own but lives in the same netlist, so it goes with it. - **GateBoy / metroboy** (`36797ad4`): a gate-level port of furrtek's schematics; its README, `docs/` and `notes/` were pinned and read. **History, plainly.** The earlier documents said furrtek's own repository was not used; that was true of DMG-CPU-Inside itself, but his lineage was used. dmg-sim was fetched, built and run as the second die model from 2026-10-05 (finding 1) to 2026-11-26: it ran Mooneye `daa`, the all-opcodes ROM (533 cases) and 24 timer-woken HALT cases, and commit `e2e10cb` (2026-10-07) changed the core from it: a halted CPU drives `$0000` (Gekkio's VHDL shows the same) and wakes in the cycle after IF rises with no idle cycle (dmg-sim alone). GateBoy's README was read for the eight clock phases and for its CPU being a guess (C6); its source was never used here. On 2026-11-26: both pins left `scripts/pinned_repos.json`; `scripts/dmgsim_run.py`, `dmgsim_rows.py`, `dmgsim_halt.py` and `scripts/dmgsim/bus_probe.sv` left the tree (copies in `/data/backup/sm83-python-furrtek-lineage-2026-11-26/moved-from-repo-at-f827a64/`); `build_referees.py` lost its `dmgsim` step, `die_compare.py` its `--dmgsim` option, `tests/test_die.py` its two dmg-sim tests; the fetched trees `reference/src/dmg-sim` (with its build) and `reference/src/metroboy` moved unopened to `/data/backup/sm83-python-furrtek-lineage-2026-11-26/reference/src/`. No behaviour changed. **The die rung (5) becomes one tracing:** Gekkio's VHDL SM83, traced from his own photographs of an SGB-CPU 01 die (`gb-research/sm83-cpu-core/README.markdown`); nothing in gb-research or GBCTR names furrtek, his schematics, msinger's or GateBoy (searched 2026-11-26). The wake-up, which the mock SoC cannot show, moves to rung 6's test ROMs. ### The facts | # | Where | What | Set-aside source | Other evidence today | Status | | --- | --- | --- | --- | --- | --- | | 1 | validation.md rung 5; timing.md "The bus"; README rung table | the core's bus (kind, address, data, internal cycles) equals the die on all 533 cases | dmg-sim (second tracing) | DIE: Gekkio's VHDL, the same 533 cases (`tests/test_die.py`) | backed | | 2 | timing.md table; undocumented-behavior.md U12, C1 | internal-cycle addresses are GBCTR's; `JR` drives `{PCH, $00}` | dmg-sim | DIE: Gekkio's VHDL; DOC: GBCTR (same author as the VHDL: not independent) | backed (one author) | | 3 | `_core.py` locked step; validation.md change 2 | a locked CPU drives `$0000` | dmg-sim | DIE: Gekkio's VHDL (the `D3 lock` case) | backed | | 4 | `_core.py` halted step; `tests/test_special_states.py`; timing.md "HALT" | a halted CPU drives `$0000` on every cycle | dmg-sim | DIE: Gekkio's VHDL (the 15 HALT-entry scenarios, `die_halt.py`) | backed | | 5 | `_core.py` wake; timing.md "Wake"; validation.md change 3 | the CPU resumes in the cycle after IF rises, no idle cycle | dmg-sim alone (commit `e2e10cb`) | TEST ROM: with one extra idle cycle at the wake, gameboy-python fails Mooneye `halt_ime1_timing2-GS` and `di_timing-GS` (verified on DMG), which pass without it (ablation, 2026-11-26, OBSERVED) | backed | | 6 | undocumented-behavior.md U14, U7 | the wake has no cycle of its own: it is the dispatch's discarded fetch (IME 1) or the refetch (IME 0) | dmg-sim | as 5 | backed at M-cycle level | | 7 | validation.md results rung 5 (old text) | the wake agrees cycle by cycle on 24 timer-driven cases (2-15 halted cycles, IME on and off) | dmg-sim alone | none at that resolution | **needs new evidence**: the 24 cases of `die_programs.py` `add_timer_halt_cases` on a real SM83 (a DMG, or a Super Game Boy's SGB-CPU 01 through a flash cart), comparing the register snapshots the program stores | | 8 | start-here.md "The bus" | an M-cycle is eight half-periods of the 4 MiHz clock, the read sampled late | GateBoy README (phases A-H) | DOC: GBCTR `appendix/external-bus.typ` | backed | | 9 | undocumented-behavior.md C6; docs/README.md finding 1 | GateBoy's CPU is "my current best guess", never a judge | GateBoy README | moot: GateBoy is no longer used at all | kept as history | | 10 | build-log.md "Not done" | STOP could be tested on dmg-sim | dmg-sim (a plan, never run) | none | STOP **needs new evidence** as before: Gambatte `speedchange` (CGB), a DMG STOP probe | Counts: 9 facts about the hardware or the core (1-8, 10; row 9 is a rule about a set-aside source), 7 backed by other evidence (1-6, 8), 2 needing new evidence (7, 10; neither changes a behaviour, row 7 only the resolution of a check that already passes at M-cycle level). ### SonoSooS's *Gameboy CPU internals*: set aside (Aubrey, 2026-11-26) **The lineage.** The gist says its decode ROM knowledge comes from "efforts by emu-russia (dmgcpu) and gekkio"; emu-russia/dmgcpu (CC0) calls msinger's dmg-schematics "the main source of both correct schematics and signal names" (its README, read 2026-11-26), and dmg-schematics derive from furrtek's DMG-CPU-Inside. The question left open here earlier the same day (whether SonoSooS itself is set aside) is answered: **set aside by Aubrey, 2026-11-26**, for author respect, not for its licence (none stated). **What changed.** Its pin (`reference/docs/SonoSooS-DMGCPU.md`, gist rev `8efa6645`) left `scripts/pinned_files.json`; the fetched copy moved unopened to `/data/backup/sm83-python-sonosoos-2026-11-26/reference/docs/`. Every citation in README.md, docs/ (start-here, timing, undocumented-behavior, validation) and the source comments (`_control.py`, `_core.py`, `_rotate.py`, `stop.py`) now names the evidence that was already beside it. No behaviour changed; nothing in the code came from the gist beyond the facts below. | # | Where | What | Other evidence today | Status | | --- | --- | --- | --- | --- | | S1 | start-here.md "Fetch/execute overlap"; `_core.py` `_dispatch` | dispatch begins at a fetch whose opcode is discarded, PC put back | DOC: GBCTR `fetch_cycle()` returns `IR, intr`; DIE: Gekkio's VHDL, rung 5's dispatch cases; SameBoy `GB_cpu_run` | backed | | S2 | start-here.md; timing.md "HALT"; `_control.py` | HALT's second cycle fetches the next byte without incrementing PC (root of the HALT bug) | DIE: Gekkio's VHDL, 15 HALT-entry scenarios; TEST ROM: blargg `halt_bug`; SameBoy `halt()` | backed | | S3 | start-here.md; undocumented-behavior.md U10; `_rotate.py` | the CB opcode's fetch has no interrupt check | DOC: GBCTR's CB pseudocode (`IR = fetch_cycle(...)`, no `intr`); SameBoy `cb_prefix()` | backed by DOC only, as before (no test isolates it) | | S4 | undocumented-behavior.md U3 | the 11 holes lock the CPU; *why*: the decode yields no fetch | TEST ROM: Gambatte `undef_ops` (hardware-captured); DIE: the VHDL never fetches after `$D3` | behaviour backed; the explanation is now HYPOTHESIS | | S5 | start-here.md "Interrupts"; timing.md "Interrupt dispatch"; C2 | dispatch is 5 M-cycles, with a discarded fetch and two IDU cycles on the bus | DIE: Gekkio's VHDL, rung 5; DOC: Pan Docs (its "5 M-cycles" links to the gist, so second-hand); SameBoy | backed (by the die) | | S6 | start-here.md "Interrupts"; U8 | the vector is chosen late, a later higher-priority interrupt wins (old explanation: "PC is only written in M3") | TEST ROM: Mooneye `ie_push`, Gambatte `irq_precedence/late_*`; SameBoy's sampling points | backed; the M3 explanation dropped | | S7 | start-here.md "HALT" table; U6 | the four HALT cases, dispatch at the HALT when IME = 1 and pending | DIE: Gekkio's VHDL (incl. IME = 1, IF raised before the fetch); TEST ROM: Mooneye `halt_ime*`, SameSuite `ei_delay_halt`; Pan Docs; SameBoy | backed | | S8 | timing.md "HALT" Wake; U14; rows 5-6 above | the wake is the dispatch's discarded fetch or the refetch, no cycle of its own | TEST ROM: the Mooneye ablation of row 5 (OBSERVED) | backed at M-cycle level (row 7's cycle-by-cycle check still open) | | S9 | timing.md "EI, DI, RETI" | EI takes effect after the next instruction | DOC: GBCTR; TEST ROM: Mooneye `ei_sequence`, `ei_timing` | backed | | S10 | start-here.md "The bus" | every M-cycle drives an address | DOC: GBCTR; DIE: Gekkio's VHDL, 533 cases | backed | | S11 | start-here.md "STOP"; timing.md "STOP"; U11; `stop.py` | STOP is one byte that appears as two when waking fetches; the IME = 0 outcome table | DOC: Pan Docs (LIJI's flowchart; "the second byte is not always ignored", which links to the gist); SameBoy `stop()`; CGB speed switch: Gambatte `speedchange` | DMG **needs new evidence** (as row 10): a DMG STOP probe over joypad lines × pending × IME, recording PC after the wake | | S12 | U11 | a "zombie mode", and a glitched interrupt to `$0000` when the joypad interrupt fires during the STOP wake | none (Pan Docs only allows "a glitch") | **needs new evidence**, now HYPOTHESIS, not modelled: the same DMG STOP probe, pressing a button during the wake with IE = joypad | | S13 | U13 | a possible NMI (vector `$80`) | DIE: Gekkio's VHDL has an `nmi` input dispatching to `$0080`; his mock SoC ties it low | the core path is backed; that no SoC drives it is HYPOTHESIS, settled only by die study of the SoC side; not implemented | Counts: 13 facts; 10 backed by other evidence (S1-S10, S3 by DOC only), S13 half backed, 2 needing new evidence (S11 on DMG, S12); none changes a behaviour. **What could replace the second tracing.** No respect-clean, independent die tracing of the SM83 is known: emu-russia/dmgcpu and msinger's visual-sm83 are both built on dmg-schematics. The candidates are hardware runs: Mooneye, Gambatte (dmg08), blargg, GBMicrotest (see gameboy-python's provenance.md for its lineage note), and a real-console probe of the 24 HALT cases.