# Provenance Where each part of this core's behaviour came from, the licence of that source, and a verdict. Written for the family's provenance audit (wave 1, 2026-11-13) against the rules in emulator-lineage's `docs/charter.md` ("Licences and provenance") and `docs/methodology.md` ("Provenance in practice"). Source keys (DS, RDS, GDS, VDS, NDS, CL, LK, BC, CAP, LT, SST) are docs/start-here.md's. Verdicts: **clean** (own work from facts or permissive sources, cited), **cite** (clean, but a source must be named or a notice kept), **rewrite** (derived from material we may not take), **unclear** (what would settle it). The repository has a private GitHub remote: nothing here is public yet. ## Summary The core is built from manufacturers' data sheets, 6502.org research (Bruce Clark, Jeff Laughton) and logic-analyser captures of two real chips, and checked against SingleStepTests (MIT) and MAME 0.285 run as a closed box. No code was taken from anywhere. Two things need attention, both from Phase 0's research rule, which allowed "GPL programs are run, their sources read for facts" (`docs/handoff-brief.md`, `2997977`), a rule the family no longer allows: - one line of `docs/mame-oracle.md` quotes a comment from MAME's Lynx driver source (`rewrite`, documentation only); - `scripts/pinned_repos.json` records that 6502Decoder's `em_6502.c` (GPL-3.0) and the MiSTer Lynx `rtl/cpu.vhd` (GPL-2.0) were "read for facts only" (`unclear`). Counts: 12 clean, 0 cite, 1 rewrite, 1 unclear. ## The core | Part | Behaviour from | Source licence | Verdict | | --- | --- | --- | --- | | `_core.py`: registers, fetch, addressing modes cycle by cycle, dummy-read addresses | CAP (hardware captures, tier 1; each helper names its evidence), DS Tables 4-1/5-7 | captures carry no licence statement (measurements of a chip: facts); WDC data sheet | clean | | `_alu.py`: binary arithmetic (NMOS rules) and 65C02 decimal | DS Table 7-1; BC "Decimal Mode" Appendix A (6502.org), confirmed by both captured parts running Clark's exhaustive test | facts; 6502.org tutorial prose | clean | | `_bits.py`: TSB TRB RMB SMB BBR BBS | CL sections 3-4, DS Table 5-2, RDS | facts | clean | | `_nops.py`: every undefined opcode's length, cycles and reads | DS Table 7-1, CL section 9, LK (Laughton, observed on a chip), CAP, LT (drhelius Lynx tests, MIT, hardware-derived expectations) | facts | clean | | `_dispatch.py`: the opcode tables per row | DS Tables 5-2/7-1, GDS Tables IV/V, VDS Table 2, NDS, RDS; CAP's measured counts | facts | clean | | `_control.py`: branches, stack, BRK, interrupts, reset, WAI, STP | docs/timing.md (CAP), DS, GF (George Foot's bench notes), the 6502-python frame (MIT) | facts; MIT | clean | | `cpu.py` rows, `harness.py`, `state.py`, tooling (`debug`, `console`, `disasm`, `trace`, `__main__`) | own work, on 6502-python's tooling hooks (MIT) | MIT | clean | `provenance_check.py` (pcengine-python) was run against each permissive reference tree pinned here (2026-11-13, `--repo . --licences scripts/pinned_repos.json`): | `--reference` | Licence | Result | | --- | --- | --- | | `reference/src/mame/src/devices/cpu/m6502` | BSD-3-Clause | 0 file pairs with hits | | `reference/src/CLK` | MIT | 0 | | `reference/src/Felix` | MIT | 1 pair: `_alu.py` line 28 `(a & 15) + (operand & 15) + carry`, the generic low-digit sum every decimal adder writes; nothing else | | `reference/src/handy` | zlib | 0 | It was not run against the GPL trees (6502Decoder, the MiSTer core, MAME's Lynx driver). ## Tests, fixtures and scripts | Part | Source | Licence / terms | Verdict | | --- | --- | --- | --- | | `tests/datasheet.py`: opcode tables transcribed from DS and GDS | manufacturer data sheets | facts | clean | | SingleStepTests 65x02 `wdc65c02`, `rockwell65c02`, `synertek65c02` @ `2f6980a2` (fetched, gitignored) | Thomas Harte | MIT | clean (detector) | | Dormann's 65C02 extended test and NMOS functional test, Clark's decimal test (amb5l @ `966b1a35`, assembled by `scripts/build_tools.py`, gitignored) | Klaus Dormann, Bruce Clark | GPL-3.0 | clean: run as programs, never committed | | `tests/capture_replay.py`, `scripts/decode_capture.py`: captures decoded by `decode6502` (hoglet67/6502Decoder @ `c32dd600`, built and run as an external program) | David Banks's captures; George Foot's capture | decoder GPL-3.0 (run only); captures no licence stated, never committed | clean (see the `unclear` item for the decoder's source) | | `tests/mame_replay.py`, `scripts/mame_trace.py`: MAME 0.285 traces (gitignored) | MAME run as a closed box | MAME binary; traces not committed | clean | | `tests/test_tooling.py`: compares the disassembler with MAME's `.lst` dispatch tables read at test time from the fetched tree | MAME `src/devices/cpu/m6502` | BSD-3-Clause; nothing copied into the repository | clean | Nothing fetched into `reference/` is committed, and no commit ever added one (all 19 commits checked). ## Findings **rewrite (documentation only): `docs/mame-oracle.md` line 23.** It quoted the line that instantiates the `lynx` driver's CPU and the comment beside it (`src/mame/atari/lynx.cpp` line 81; the quotation is not repeated here). The pin records that driver as GPL-2.0+, so the quote is text taken from GPL source. Replace it with the fact in our own words, sourced from what MAME shows when run (`mame -listxml lynx` names the `G65SC02` device) and from VDS (no bit instructions). Added in `1b0e5e9`. No code depends on it. **unclear: Phase 0 read two GPL CPU models "for facts".** `scripts/pinned_repos.json` (added in `9fb8a67`) says of 6502Decoder "GPL-3.0 (run as an external program; em_6502.c read for facts only)" and of the MiSTer Lynx core "GPL-2.0 (read for facts only)"; docs/validation.md lists `rtl/cpu.vhd` as "read only". No fact in the code or docs is attributed to either source; every cycle the core makes is judged by CAP (tier 1) and the data sheets, and rung 4 replays 168 million captured instructions with no mismatch. Two statements lean on the decoder's model rather than on a capture: C2 ("the decoder: one byte, one cycle" for `x7`/`xF` on parts without bit instructions) and U11 ("agree with the decoder's model"). What would settle it: (1) confirm C2's decoder opinion is the output of running `decode6502` (or drop it: GDS, VDS, NDS, CL, Dormann and CAP on the G65SC12 already say the same); (2) change the two licence notes to "run only; source not read" and say in docs/validation.md that the build relies on no fact read from either file. Nothing in the core needs to change on present evidence. ## Owed (not provenance breaches) - ~~SPDX headers on each source file (charter rule 2).~~ Done in wave 2. ## How this was checked The repository's comments, docstrings, docs, pinned-source records, fetch and build scripts, and `git log --all -p` (emulator names, "transcribed", "port of", "copied", source-file extensions, added and deleted files). The permissive-tree runs above. No GPL source was opened by this audit. ## Wave 2 (2026-11-13) The specification pass that brings the repository to the charter (one commit per item). No GPL source was opened in it. - **The `rewrite` finding is closed.** `docs/mame-oracle.md` no longer quotes the `lynx` driver's source: the line now says, in our own words, what MAME shows when run (`mame -listxml lynx`, run on 2026-11-13: one CPU, "GTE G65SC02", 4,000,000 Hz) and that this agrees with VDS. The finding above no longer repeats the quotation either. A search of `docs/`, `tests/`, `src/` and `scripts/` found no other quoted GPL code or comment. Two short quoted comments from MAME's `src/devices/cpu/m6502` (BSD-3-Clause, so permitted with credit) were paraphrased as well, so that no document quotes emulator source: the `g65sc02` row of `docs/mame-oracle.md` and C5 in `docs/undocumented-behavior.md`. - **No machine path.** `scripts/mame_trace.py` took its ROM set from a fixed path that named a mirror; it now reads `MAME_ROMPATH` (or `--rompath`) and stops when neither is given, and finds MAME through `$MAME` or PATH. cc65 is found on PATH or through `CC65_BIN` (`scripts/build_tools.py`, `tests/test_tooling.py`). The docs name sibling repositories relative to this one's parent. Everything else outside the repository's history is under the gitignored `reference/` and `tests/mame_traces/`, reached by relative path (README, "Working on it"). - **SPDX headers.** Every Python file (`src/`, `tests/`, `scripts/`: 42) and `pyproject.toml` start with `# SPDX-License-Identifier: MIT` (after the shebang where there is one), inserted by a one-purpose script; the AST of every module is unchanged. The JSON pin files cannot hold a comment; they are data written here, under the repository's MIT licence. **No NOTICE file**: the audit has no `cite` row, and nothing from a permissive source is kept in the repository (6502-python, MIT, is a dependency fetched by commit, not a copy; SingleStepTests, the Lynx tests and the permissive emulators are fetched into the gitignored `reference/` and never committed; the one `provenance_check.py` hit against Felix is the generic low-digit sum). - The `unclear` finding (6502Decoder's `em_6502.c`, the MiSTer `cpu.vhd`) is unchanged: settling it is Aubrey's call and outside this pass. ## 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, unless a program with no shipped build is built from it. The AtariLynx_MiSTer pin (https://github.com/MiSTer-devel/AtariLynx_MiSTer @ `3708e457e413aa7a33f8bec8fcd79eba45ce4702`, GPL-2.0) was removed, and MAME's GPL-2.0+ lynx driver (`lynx.cpp`, `lynx.h`, `lynx_m.cpp`) left the MAME sparse list (the m6502 family, BSD-3, stays). Both moved aside unopened, out of the repository (not deleted). **Kept, with a question for Aubrey:** 6502Decoder (`c32dd600`, GPL-3.0), because `scripts/build_tools.py` builds `decode6502` from it (rung 4's capture decoder) and no shipped build exists. Aubrey's answer (decisions page T3, 2026-11-25): it moves; done on 2026-11-25 (below). The "read for facts" note on `em_6502.c` is the unclear item above. ## The capture decoder's build moved to emu-tools-gpl (2026-11-25) Decisions page T3: `decode6502` is now built by emu-tools-gpl's `tools/6502decoder` (6502decoder-build 0.1.0, GPL-3.0-or-later: `build.py`, the same pin `c32dd600` and the same `gcc -O2 -D_GNU_SOURCE` of the same thirteen files), at `$EMU_TOOLS_GPL/tools/6502decoder/build/decode6502`. `scripts/build_tools.py` runs that build as a program; `scripts/decode_capture.py` and `tests/capture_replay.py` run the program there (the capture tests skip without it; `decode_capture.py` exits 3). The 6502Decoder pin stays for the real captures only: its sparse list dropped `/src/`, `/build.sh` and `/test/run_tests.sh`, and keeps `README.txt`, `LICENSE.txt` and the four `test/` captures. Moved unopened to a backup outside the repository (not deleted): the whole old checkout `reference/src/6502Decoder` (its `.git` held the source's objects) and `reference/build/decode6502` (sha1 `92f1ac00`); the checkout was fetched again with the narrower list, and its four captures are the same files (SHA-1 checked). Identity check, 2026-11-25: the old and new decoders on the BBC Master, BBC B (Rockwell R65C02) and NMOS BBC B reset captures, with the options `decode_capture.py` and `capture_replay.py` use (`-a -h -i -y`, and `-s -Y`), and the first 2,000,000 lines of the Master Clark BCD capture: the same output byte for byte (5 files, 4,799,606 lines; OBSERVED); the quick capture-replay tests pass (5 of 5) on the new one. w65c02-rust reaches the decoder only through this repository's `tests/capture_replay.py`, so it follows unchanged.