# Handoff: build `snk68-python`, SNK's 68000 boards ## Context you are inheriting - Phase 0 (2026-11-26): documents, 19 pinned references, a census, a MAME recipe and a capture decoder; no emulator code. Read [start-here.md](start-here.md), then [timing.md](timing.md) and this brief. - Evidence: SNK's Ikari III schematics (SCH-A7007, 12 clean sheets: tier 2), real-board sync captures for Ikari III and P.O.W. and an OSSC readout for Prehistoric Isle (tier 1, timing only), Yamaha's and NEC's documents, MAME 0.285 (tier 5) and va7deo's FPGA cores (tier 4) as closed boxes. This board starts better evidenced than most in the family. - The triple-Z80 boards are [snk-python](../snk-python); the two share only a Z80 sound CPU and an OPL-family chip. ## Decided by Aubrey (standing rules that apply here) MIT, nothing from GPL/LGPL code, closed boxes run not read; furrtek's lineage set aside (nothing lost here); romsets by `MAME_ROMPATH`, never committed; reference boards correct, not fast; sound good enough; technical defaults taken and marked PROVISIONAL; the chip rule. ## Scope `snk68.cpp` (pow, streetsm on map P; ikari3, searchar on map I) first, then `prehisle.cpp` (another video design on the same CPU and sound). Bootlegs (powbl's OKI, streetsmwbl, prehisleb) later. ## Package and classes (proposed) ```text snk68_python/ board.py # Snk68Board: 68000 + Z80, the order of record, DTACK waits, frame stepping decode.py # the PAL20L10 decode and the 74138s (from the PAL dumps and sheet 2) clock.py # ClockGateArray: K9's H/V counters, HBL, VBL, SYNC, flip (sheet 1; MEASURED) video.py # SpriteGenerator (sheets 3-6), FixLayer (7), Palette (8) prehisle.py # PrehisleVideo: text, foreground, ROM background, sprites, palette RAM sound.py # SoundBoard: Z80, latches, NMI one-shot, YmSocket, AdpcmSocket inputs.py # SnkIo (B9), DIPs, Ls30Rotary (C1/C2 path, U4) machines.py # MachineRow per set: map P / I / prehisle, ROM layout romset.py # MAME sets read in place by CRC ``` **Import boundary.** The board owns decode, RAM, waits, the clock gate array, video, inputs, latches and the NMI one-shot. Cores: m68000-python (68000), z80-python (Z80), the proposed `ym3812-python` (YM3812), the proposed `upd7759-python` (uPD7759). ## Sockets | Socket | Filled by | Empty behaviour | | --- | --- | --- | | `YmSocket` | `ym3812-python`'s YM3812 | silence; status 0; timers still counted if the sound program waits on them | | `AdpcmSocket` | `upd7759-python` in stand-alone mode, with the 1 Mbit ROM | silence; BUSY idle | ## What the board needs from its cores - **m68000-python** (`55d3d60`): IPL lines and autovectors (its `acknowledge`), and the host-side stall its README describes ("`cpu.step_clocks` says at which clock of the step the access ends ... the host adds its own stall clocks"): enough for the DTACK waits. - **z80-python** (`1302260`): INT and NMI. No WAIT needed (pulled up on sheet 12). - **upd7759-python**: stand-alone mode (ST, ALE/AEN ROM fetch, BUSY, RESET) as well as the slave mode System 16B needs. ## Unknowns (U) and conflicts (C) | | What | Blocks | Where the answer is | | --- | --- | --- | --- | | U1 | the length of the DTACK wait on video and sprite RAM accesses | M1 cycle order | sheet 2 (VDTACT, OBJDTACT logic) and the sprite sheets; a bus capture would judge | | U2 | interrupt levels: VBL and "VIC" to IPL | M1 | sheet 2 (H15) | | U3 | which games are A7008 or A8007 (Street Smart is listed on both) | scope | PCB photographs (va7deo `doc/PCB/`, not fetched) | | U4 | what C1/C2 (rotary path) are; whether MAME lacks their dumps | M4 | sheet 9; PCB photographs | | U5 | HBL, VBL, SYNC positions within the line and frame | M2 | CAP-IK3 (decode the edges against CLK), sheet 1 | | U6 | the uPD7759's BUSY path back to the Z80 | M3 | sheet 12 | | U7 | Prehistoric Isle's hardware beyond MAME's view | M6 | no schematic in hand; PCB photographs (va7deo) | | | Conflict | Sources | Resolution | | --- | --- | --- | --- | | C1 | Prehistoric Isle at 54.07 Hz with 289 lines (OSSC readout on a real board; va7deo) against MAME's 59.19 Hz with 264 | OBSERVED vs MAME | the real unit's readout, PROVISIONAL until a capture | | C2 | the uPD7759's clock: own resonator on X1 (sheet 12) and MAME 640 kHz, against va7deo's "4 MHz crystal for Z80 / YM3812 / uPD7759" | DOC vs tier-4 README | the sheet; read the resonator's value in M0 | | C3 | the SNK I/O custom as "Rotary" (va7deo) against sheet 9, where it carries joysticks, buttons and coins and the rotary goes through C1/C2 | tier-4 README vs DOC | the sheet | ## Milestones | | Step | Evidence | Exit test | | --- | --- | --- | --- | | M0 | Read SCH-A7007 into `docs/schematic-a7007.md`; turn the PAL dumps into equations; decode CAP-IK3's edge positions | SCH-A7007 (2), captures (1) | U1, U2, U5, U6 answered or narrowed to named nets | | M1 | ikari3 CPU side: 68000, decode, RAM, DTACK waits, IPL; clock gate array | M0 | boot lockstep with MAME's 68000 trace for 600 frames (detector); **HBL/VBL/SYNC edges equal to CAP-IK3** (judge) | | M2 | video: sprites, FIX layer, palette | M0, sheets 3-8 | attract frames against MAME's (detector); va7deo's listed P.O.W. issues checked | | M3 | sound: Z80, latches, NMI one-shot, sockets empty, then YM3812 and uPD7759 when their cores land | sheet 12, DS7759, AM3812 | command stream equal to MAME's over 60 s of attract; audio "good enough" | | M4 | inputs: SNK I/O, DIPs, LS-30 rotary | sheet 9 | rotary turns through 12 positions in Ikari III's test mode | | M5 | pow, streetsm (map P), searchar (map I) | as above | M1-M4's tests per set; P.O.W.'s timing rung against CAP-POW | | M6 | Prehistoric Isle | MAME (5), OSSC-PI (1) | boots; frame of 289 lines (C1) | ## The chip rule | Chip | Family consumers | Where | | --- | --- | --- | | 68000, Z80 | many | m68000-python, z80-python | | YM3812 | snk-python, snk68-python, deco16-python, ibmpc-python (and YM3526/Y8950 relatives) | proposed `ym3812-python` (snk-python's decision 1) | | uPD7759 | system16-python, pico-python, konami68k-python, snk68-python | proposed `upd7759-python` (system16's and pico's decision 3) | | sprite generator, palette, K9 clock array, SNK I/O | this board only (MAME shares the sprite and palette devices with Alpha Denshi's boards, none in the family) | this board | ## Domains and speed Full working in [domains-and-speed.md](domains-and-speed.md). - **Domains:** C (68000 side), V (video: K9 counters, sprites, text, palette), A (Z80, YM3812, uPD7759). C and V are coupled per access by DTACK, so they step together in the order of record; A meets them only at the two latches and the NMI. - **Need:** 68000 9 MHz / about 12 cycles = 0.75 M instructions a second; Z80 0.57 M; total **about 1.3 M**; YM3812 1.0 M slot steps; video **6.0 M dots a second (MEASURED)**. - **No-JIT path:** x-python on PyPy carries the CPUs (m68000-python about 33 M/s on PyPy, its README) and lands near or below real time with per-dot video and FM. **x-rust reaches real time on desktop, phone and browser** (m68000-rust about 134 M/s native, 112 M/s as WebAssembly). x-rust-fast for run-ahead only; threads unneeded; `recompile: none` on every target, the iPhone included. ## Open decisions for Aubrey (each with a recommendation) 1. **A separate repository for the 68000 boards.** *Recommend: yes, this one (`snk68-python`), with Prehistoric Isle inside it as a second video design; nothing but the sound Z80 is shared with snk-python.* 2. **`upd7759-python` gains a fourth consumer** and needs both stand-alone and slave modes. *Recommend: create it now as a core with two front ends over one decoder (system16's and pico's decision 3), stand-alone mode from DS7759 and this board's sheet 12.* 3. **`ym3812-python`** (snk-python's decision 1). *Recommend: yes; this board needs only the YM3812 variant, so it can be the first consumer to test it.* 4. **Prehistoric Isle's frame rate (C1).** *Recommend: 289 lines (54.07 Hz) from the real board's OSSC readout, PROVISIONAL, with MAME's 264 kept as the overruled reading.* 5. **The va7deo PCB photographs** (4-18 MB each, ten for Ikari III, five each side for Prehistoric Isle) would settle U3, U4 and U7. *Recommend: pin the few M0 needs (Ikari III's C1/C2 area, Prehistoric Isle's top side) when M0 starts, not now.*