# Donkey Kong Jr. Math (U) — Pass 1 Disassembly (Pass 2 partial) ROM: `_wip/Donkey Kong Jr. Math (U)/Donkey Kong Jr. Math (U).nes` (24,592 bytes, iNES). Status: **Pass 1 complete — 81.9% code; Pass 2 partial.** `copilot/prg.s` is a real disassembly, not a skeleton: 6,589 instructions (13,416 bytes as code), **1,035 label definitions of which only 64 carry semantic names** — 971 are still address-based `Label_`. `locals.inc` holds **186 neutral `ZpXX` slots and no semantic zero-page aliases**. It builds **byte-identical** at the PRG level (`cmp reconstructed_prg.bin prg.bin`). This header said "Pass 2 complete" from `c204dac` (2026-10-18) until the 2026-10-19 correction; that claim counted the draft map's rows, not names actually present in `prg.s`. See "Pass 2 Status and Map Audit" below. ## ROM Facts | Property | Value | |----------|-------| | Mapper | 0 (NROM) — from the iNES header | | PRG | 16 KB (header claims map at CPU $C000–$FFFF) | | CHR | 8 KB | | Mirroring | Vertical | | Battery-backed flag | clear | | ROM SHA-256 | `263e5e9602943cfcb28c4d4492375a0e103c1d46c6f641ffab4da6f1f8422b4a` | | PRG SHA-256 | `de0612081266e6ad556d6c98dd7ad9c362ceac8531d9446239813feb1961221b` | ## Interrupt Vectors (taken from PRG $3FFA–$3FFF) | Vector | Target | Note | |--------|--------|------| | NMI | `$C4A9` | per-frame heartbeat | | RESET | `$C41E` | enters at $C41E inside the first pages (the Donkey Kong Jr.-style non-$C000 entry) | | IRQ | `$FFF0` | lands in the vector-page padding — unused placeholder | ## `copilot/` Contents | File | Purpose | |------|---------| | `Donkey Kong Jr. Math (U).nes` | original ROM image (reference) | | `prg.bin` / `header.bin` / `chr.bin` | split image, produced by `_tools/splitnes.py` | | `prg.s` | Pass 1: classified code/data split, 6,589 instructions, 64 semantic + 971 address-based `Label_` definitions, canonical audit comments | | `symbols.inc` | shared NES hardware constants (PPU/APU/controller) | | `locals.inc` | 186 neutral `ZpXX` zero-page slots (Pass 2 naming outstanding) | | `dkjm_label_map.tsv` / `dkjm_full_map.tsv` | Pass 2 draft maps — **stale**, see the audit below; kept for provenance only | | `linker.cfg` | PRG at $C000, 16 KB, `fill = yes` | | `Makefile` | links `reconstructed_prg.bin` and `cmp`s it against `prg.bin` | | `reconstructed_prg.bin` | build output from the last verified build | Header/CHR are not linked: `copilot/` keeps the raw `header.bin`/`chr.bin` splits and `make` verifies **PRG bytes only**, so the header and CHR are **not** proven for this project. Promotion to the top level adds `header.s` / `chr.s` (as e.g. `Burger Time (U)`), a HEADER/PRG/CHR `linker.cfg`, and a full-ROM `make` target. ## Build ```bash cd "_wip/Donkey Kong Jr. Math (U)/copilot" make # → cmp reconstructed_prg.bin prg.bin → "BYTE-IDENTICAL" ``` ## Pass Status | Pass | Status | |------|--------| | Pass 1 | **Complete** — 6,589 instructions, 13,416 bytes as code (81.9%), 2,968 bytes as data, byte accounting exact (16,384) | | Pass 2 | **Partial** — 64 of 1,035 label definitions named (6%); 186 zero-page slots still neutral `ZpXX`; the drafted maps are stale and have not been (and cannot be) applied | | Pass 3 | Outstanding — data tables/structures unnamed | | Promotion | Outstanding — add `header.s`/`chr.s` + HEADER/PRG/CHR `linker.cfg`, switch `make` to a whole-ROM `cmp`, move the `_tools` paths | ## Pass 2 Status and Map Audit (corrected 2026-10-19) The earlier "Pass 2 complete" text was wrong on every number it gave, because it read the draft map instead of the source: - **"240 semantic labels"** was the map's row count (`dkjm_full_map.tsv` has 243 `label` rows / 240 distinct old names). `prg.s` actually names **64** definitions; the other 971 are still `Label_`. - **"186 zero-page semantic aliases"** was the count of **neutral** `ZpXX` entries in `locals.inc`. There are **zero** semantic zero-page aliases. - Most of the listed "key renamed routines" (`InitSystem`, `InitPPU`, `InitGameState`, `UpdateOAM`, `UpdateScroll`, `WritePPU`, `PlaySoundEffect`, …) do not exist in the file. Draft-map audit (`dkjm_full_map.tsv`, 243 label rows): | Outcome | Rows | Meaning | |---|---|---| | already applied | 62 | the proposed name already sits at that address | | name conflict | 2 | a different name already sits there | | stale address | 100 | the address is **not an instruction boundary** in the current `prg.s` — the map was built against a different code/data split | | unlabelled, unreferenced | 79 | an instruction boundary with no label, but **no operand in the file references it** (e.g. `$C442`, called `InitGame_1` in the map, is really the fall-through tail of `ClearZeropage_1`) | | **safely applicable** | **0** | no row is both insertable and corroborated by control flow | The map is therefore kept only as provenance. Completing Pass 2 needs a fresh map derived from the committed split (routine entries plus `_Block[_n]` internal branch targets, as done for `Donkey Kong (JU)`). **Still owed:** a real power-on flow analysis (RESET/NMI/main-loop walk) in the style of the top-level project `OVERVIEW.md`s.