# Handoff: build `konamigx-python`, Konami's System GX ## Context you are inheriting Read the family's CLAUDE.md (`../CLAUDE.md`), the family charter and methodology (emulator-lineage `docs/`), then in this repository: [start-here.md](start-here.md), [census.md](census.md), [schematic.md](schematic.md), [memory-map.md](memory-map.md), [video.md](video.md), [sound.md](sound.md), [protection.md](protection.md), [cpu-cores.md](cpu-cores.md), [domains-and-speed.md](domains-and-speed.md), [validation.md](validation.md), [mame-oracle.md](mame-oracle.md), [sources.md](sources.md), [provenance.md](provenance.md). Then `python -I scripts/fetch_references.py` (4 files, ~7 MB; `--verify` to check). System GX (1994-97) is a 24 MHz MC68EC020 board with a 68000 sound system, two K054539s and a TMS57002 effects DSP, a K056832/K055673/K055555/K054338 video chain, and on some boards a K053936 ROZ, a second screen and an ESC bus-master protection device. It sits between eras 2 and 3: one fast 32-bit CPU with a cache, a separate sound domain, and a DSP that runs its program every sample. **No hardware-tier oracle exists for any custom chip**; Konami's schematic sheets (seven of them, tier 2) are the strongest evidence. Expect FITTED behaviour, tagged honestly. ## Scope In: the 42 sets of MAME 0.285's `konami/konamigx.cpp`, as rows in this order: **type 2** (the base board: Salamander 2, Twin Bee Yahhoo!, Gokujou Parodius, Puzzle-dama, Tokimeki Puzzle-dama, Tokkae-dama, Dragoon Might, Daisu-Kiss, Winning Spike, Lethal Enforcers II with its guns, Sexy Parodius last for its protection); then **type 1** (Racin' Force, Open Golf: ROZ, ADC0834, lamps); **type 4** (Run and Gun 2, Rushing Heroes, Versus Net Soccer: ROZ, second screen, its own protection); **type 3** (Soccer Superstars: two wide screens). Out: the Sexy Parodius bootleg (two MSM6295, no sound CPU), Racin' Force's LAN, hosts, sites. Related Konami boards with the same chips (Mystic Warriors, Moo Mesa, Lethal Enforcers, Xexex, djmain) are future boards, not rows. ## Package and classes (proposed) ``` konamigx_python/ machine.py # row table: set -> board type (1-4), screens, controls, EEPROM image, # protection kind (esc, type4, none), ROM regions romset.py # MAME zips read in place from $MAME_ROMPATH, verified by SHA-1; the BIOS # 300a01.34k by SHA-1; factory EEPROM images found, never copied board.py # build(set, rompath) -> Board; the rational-time timeline; save states main.py # MainDomain: the 68EC020 socket (m68020-python), decode per type, port # sizes and waits per region, autovectored levels, 051550 reset/watchdog, # the ESC's bus-request lines clocks.py # 48 and 32 MHz, the dividers, DOTSEL -> dot clock (DOC, schematic.md) io.py # inputs, DIP switches, control latch, EEPROM latch, ADC0834, lamps, guns eeprom.py # 93C46 (16-bit), until a shared serial-EEPROM core exists (decision 7) protection/ esc.py # EscDevice socket: bus master on the main bus; functional model FITTED to MAME type4.py video/ k053252.py # CRTC: raster, interrupts; frame rate per game from its registers k056832.py # tilemaps k055673.py # sprites with the K053246 registers k053936.py # ROZ ("PSAC") for types 1, 3, 4 k055555.py # PCU2 priority mixer k054338.py # CLTC colour, shadow, alpha, brightness; colour RAM 8K x 24 bit sound/ domain.py # SoundDomain: m68000-python, its map, the K056800 sound side k056800.py # MIRAC: the channel (both sides) and the audio router k054539.py # until k054539-python exists (decision 3) dasp.py # DaspDomain: TMS57002 socket (tms57002-python or in-board, decision 4), # 256 KB delay DRAM, the latch at 500000, the 056602 DAC as the sink ``` Every chip module is pin-shaped (registers in, pixels or samples out, channels named) so it can be extracted later. ## Import boundary - **Cores own:** instruction semantics, register files, exception processing, the 68020's cache and bus protocol (`m68020-python`); the 68000 (`m68000-python`); the TMS57002's program execution (`tms57002-python`, or `sound/dasp.py`). - **The board owns:** decode and port sizes, wait states and DTACK sources (the palette's own DTACK, DOC), interrupt wiring, reset and halt gating, all Konami customs, the ESC, the clocks and the timeline, the EEPROM, inputs. ## Sockets | Socket | Default | Replaceable by | | --- | --- | --- | | `Cpu68020` (main) | m68020-python | a Rust core through the same calls | | `Cpu68000` (sound) | m68000-python | m68000-rust | | `Dasp` | tms57002-python (or in-board) | a pass-through (K054539 mix to the DAC): a named concession, off by default | | `EscDevice` | functional model FITTED to MAME | a real program if the ESC is ever dumped | | `Pcm` (x2) | k054539 module | k054539-python | | `Eeprom` | 93C46 module | a shared serial-EEPROM core | ## What the board needs from its cores - **m68020-python** (new; decision 1): the 68EC020's instruction set, 24-bit bus, two-wire arbitration (`BR`/`BG`) so the ESC can take the bus, dynamic bus sizing with the board answering each access's port size and wait, the 256-byte instruction cache with CACR, autovector acknowledge, `RESET`/`HALT` inputs; a bus callback per access with its size, address, value and the cycle it ends on. - **m68000-python** (pin by commit): nothing new. - **tms57002-python** (new; decision 4): a 256-word program per sample, host-port loading of program and coefficients, `BIO`, `PC0`, `EMPTY`, `DREADY`, the external delay DRAM through a callback, serial in and out one sample frame at a time. ## Milestones | # | Milestone | Judge (tier) | Exit | | --- | --- | --- | --- | | M0 | romsets and BIOS by SHA-1, row table, timeline unit (U24) | census | 42/42 load, nothing copied | | M1 | main domain on the BIOS: decode, work RAM, port sizes, watchdog, CRTC registers and interrupts, the ESC socket as a stub | MAME trace (5) | Salamander 2 reaches its ROM/RAM CHECK with the 68EC020 PC-for-PC equal to MAME for 600 frames, or each difference named | | M2 | CRTC timing and frame rate from the game's writes; dot clock from `DOTSEL` | sheet (2), MAME log (5) | Salamander 2 at 59.19 Hz and Racin' Force at ~54 Hz from their own registers | | M3 | sound domain: 68000, map, K056800 both sides, `SNDINT`, resets; K054539 register state | MAME trace and watchpoints (5) | sound 68000 lockstep for 600 frames; the channel's byte log equal | | M4 | DASP: program and coefficient load through the latch, one sample frame equal to MAME | MAME trace (5) | 256 instructions a frame equal in PC and accumulator for 1,000 frames | | M5 | pictures of type 2: K056832, K055673/K053246, K055555, K054338 | MAME pictures (5) | Salamander 2 and Twin Bee Yahhoo! attract loops compared, differences recorded | | M6 | the ESC, functional | MAME memory after each command (5) | Salamander 2 plays; Sexy Parodius's difference named | | M7 | audio: K054539s through the K056800 to the DASP and the DAC | MAME audio (5) | "good enough" | | M8 | Lethal Enforcers II guns; Winning Spike, Dragoon Might, Daisu-Kiss, the puzzle games | MAME (5) | each reaches play | | M9 | type 1 (Racin' Force, Open Golf): K053936, PSAC, ADC0834, lamps | MAME (5; "preliminary" there) | attract compared | | M10 | type 4 and type 3: second screens, palettes, type-4 protection | MAME (5) | each reaches play | | M11 | save states, run-ahead, full-library smoke | self | identical continuation; 42 sets reach attract | ## The chip rule | Chip | Family users | Proposal | | --- | --- | --- | | MC68EC020 | taitof3 (Phase 0), amiga AGA rows, X68030 (a 68030 variant), this board | `m68020-python` (decision 1) | | MC68000 | many | m68000-python | | TMS57002 | this board; MAME also Taito G-NET and ZN (no family board yet) | `tms57002-python` (decision 4) | | K054539 | konami68k-python (X-Men, Premier Soccer), this board | `k054539-python` (decision 3) | | K053246 (+ K053247/K055673), K053936 | konami68k-python, this board | in-board now; decision 5 | | K056832, K055555, K054338, K053252, K056800 | this board only in the family (MAME: mystwarr, moo, xexex, djmain and others) | in-board, pin-shaped | | 93C46 | cps1/cps2, jaguar, lynx, taitof3 and others | taitof3's `eeprom93-python` proposal (decision 7) | | ADC0834, ESC, 056602, 056766, 056820 | none | in-board | ## Unknowns (U) and contradictions (C) | # | Unknown | Best source now | | --- | --- | --- | | U1 | the 68020's pipeline overlap, so exact clocks per instruction; how much faster than MAME's tables the wait loops really run | manual's BC/CC/WC bounds; WinUAE as a detector; cputest on an A1200 if someone runs it | | U2 | the missing schematic sheets: CPU, decode, waits, sound CPU, K054539s, I/O, EEPROM | another GX manual | | U3 | which register bit drives `DOTSEL0/1` | traces of the control latch against the CRTC settings | | U4 | the 18 MHz net's exact frequency; whether the K054539s run at 46,875 Hz frames like the DASP | sheets with the sound CPU; MAME says 18.432 MHz | | U5 | the ESC's identity (MCU with a program, or a gate array) | a board photograph; the missing sheet | | U6 | the ESC's command format, results and bus cycles | MAME watchpoints and memory dumps (5) | | U7 | which source drives which interrupt level (CRTC `CCUINT1/2`, `SNDINT` analogue on main, ESC) | traces of SR and the level | | U8 | wait states and DTACK per region (the palette's DTACK from the 054338) | traces; none better | | U9 | type 1's RAM at `DC0000` and `F80000`/`FC0000` | MAME watchpoints | | U10 | how the two K054539s split `200000-2004FF` | MAME watchpoints | | U11-U15 | tilemap modes and scroll; sprite list and depth; ROZ sources S1/S2 and the PSAC map; priority rules; shadow/alpha/brightness | [video.md](video.md) | | U16 | K056800 register semantics and audio-routing bits | MAME (5) | | U17 | the DASP latch's bit assignment at `500000` | MAME traces of the sound CPU at program load | | U18 | the TMS57002's instruction set and timing | MAME as a detector; a TI data manual if one appears | | U19 | type 4 protection | MAME watchpoints | | U20 | bit 7 of the EEPROM latch pulsed at boot | MAME | | U21 | how often the sound CPU reads the DASP status in play (decides threading) | a watchpoint run | | U22 | dot clocks of the type 3/4 second screens | their CRTC writes | | U23 | whether MAME's GX files carry furrtek-derived facts | only by opening them (not done) or asking their authors | | U24 | the board timeline's common unit (48 and 32 MHz oscillators, 18.432 MHz audio) | the clocks above: 96 MHz covers 48 and 32; the audio clock needs a rational step | | # | Contradiction | Sides | Proposal | | --- | --- | --- | --- | | C1 | the DASP's clock | MAME: 12 MHz; Konami's sheet: CLKIN 24 MHz with CLKSEL low (512 fs) | not a conflict if the chip runs one instruction per two input clocks; specify the pin (24 MHz) and the derived rate (46,875 Hz, 256 instructions a frame), tag the internal ratio HYPOTHESIS | | C2 | the screen | MAME `-listxml`: 1024 x 1024 at 62.06 MHz (a placeholder); the CRTC: 384 x 264 at 6 MHz on Salamander 2, 512 x 289 at 8 MHz (~54 Hz) on Racin' Force | the CRTC is the spec; the frame rate is per game | | C3 | the K056800 | MAME: a host latch; the sheet: also an audio router between the K054539s, an external input and the DASP | model both | | C4 | the ESC | MAME: a write handler at `CC0000`; the sheet: a 68020-style bus master with its own clock that can halt the main CPU | a bus-master socket; a functional model inside it, FITTED | | C5 | the task's "K053246/K055673 sprites" | MAME 0.285 lists only `k055673` as a device; its map has both K053246 registers (`k053246_w`) and K055673 registers | one sprite module with both register sets | | C6 | the task's "K053936 ROZ" | MAME 0.285 lists no `k053936` device on any GX set; types 1, 3 and 4 have its control and line RAM in their maps, drawn by the driver | in-board K053936 for types 1/3/4 only | ## Domains and speed Summary of [domains-and-speed.md](domains-and-speed.md): - **Domains**: main (68EC020, video chips, ESC, EEPROM, I/O), sound (68000, two K054539s, the K056800's sound side), dasp (TMS57002, 256 KB DRAM, DAC). **Channels**: the K056800's registers and `SNDINT`; `SOUNDRESET` and the K054539 resets; the DASP's host port and latch; the serial sample streams into and out of the DASP; the picture producer. - **Need** (MAME 0.285, attract, one emulated second each): 68EC020 3.35-3.93 M instructions a second (5.16 M in boot; up to ~2x more if the real cache-overlapped timing is faster than MAME's tables: plan 5 M typical, 10 M worst), 68000 0.51 M, TMS57002 12.0 M (256 per sample x 46,875). **About 18 M a second typical, 23 M worst: 7-9x the Mega Drive's ~2.5 M.** Clock ticks ~45 M a second (24 + 8 + 12 + ~0.75). Pixels 6-8 M a second a screen; types 3/4 draw two. MAME itself runs these games at 340-406% of real time on this desktop. - **No-JIT path**: plain Rust ~0.7-1.5x real time on desktop (HYPOTHESIS, scaled from megadrive-rust); `-fast` ~1-2.5x; **threads at the dasp channel and a picture producer** ~2-4x: desktop native and desktop browser (with threads) reach real time. A **cached interpreter** must invalidate on RAM writes (Racin' Force runs half its code from work RAM); pre-decoding the DASP's fixed 256-word program per load is the largest single no-JIT win. **Phones are marginal; phone browsers are not expected to reach real time** with `recompile: none` alone; a DASP-bypass concession (named, off by default) would close most of the gap. All HYPOTHESIS until a Rust board measures it. - **Python**: ~0.05-0.2x real time with PyPy: correct, not fast; rungs use short windows. ## Open decisions for Aubrey (each with a recommendation) 1. **`m68020-python`.** **Recommend** one Phase 0 for the core, with the 68EC020 as its first variant and **Taito F3 as its first board, System GX second** (agreeing with taitof2-python's decision 2), semantics exact and timing at the transaction level from the manual's cache/worst-case figures, the overlap FITTED where a detector shows it matters. The GX adds bus arbitration with an outside master and code in RAM under the cache. 2. **Board order.** **Recommend** this board after Taito F3 (which brings up the 68020 core) and after konami68k-python reaches its X-Men row (which brings up the K054539 and the K053246); start with Salamander 2 or Twin Bee Yahhoo! (type 2, no ROZ, no second screen). 3. **`k054539-python`.** **Recommend** extracting it now as its own core: this is the second family board needing it (konami68k-python's decision 4 said "extract at the second board"), and the GX uses two of them. Built first wherever it is first needed (likely konami68k's X-Men). 4. **`tms57002-python`.** **Recommend** its own core repository (a processor running a program; precedent dsp16-python, ssp1601-python; Taito G-NET and ZN in MAME use it too), built after the board plays with the DASP as a **pass-through socket** first, its instruction semantics tagged FITTED to MAME (no data manual exists in hand). Alternative: keep it in `sound/dasp.py` until a ZN or G-NET board joins the family. 5. **A shared Konami video core.** **Recommend** not yet: the GX's video chips are a later generation than konami68k's (K056832 vs K052109, K055555 vs K053251); only the K053246 sprite generator and the K053936 overlap. Keep both in-board, pin-shaped; revisit when a third Konami board (Mystic Warriors or Moo Mesa, which share the GX's K056832/K055555/K054338 chain) starts, and extract `konami-gx-video-python` then. 6. **MAME's GX files.** Almost all are BSD-3-Clause (the K053252 is LGPL-2.1+, the TMS57002 instruction table GPL-2.0+ by having no line). **Recommend** keeping MAME closed for this board, as the brief says and as konami68k-python recommended: the furrtek-lineage question (U23) cannot be answered without opening them, and six of the GX's chips are in his die studies. If Aubrey prefers to open the BSD files for facts, ask their copyright holders first whether furrtek's research is inside. 7. **Serial EEPROM.** **Recommend** joining taitof2-python's proposed shared 93C46 core (`eeprom93-python`, its decision 5); the GX's 93C46 is the 16-bit organisation. 8. **The ESC.** **Recommend** a bus-master socket with a functional model FITTED to MAME's results, honest about being FITTED; if Aubrey ever wants this tier raised, a board photograph of a type 2 ROM board (to identify the chip) is the cheapest step and needs no probing. 9. **Lineage cost, recorded.** furrtek's studies cover the K053252, K053936, K054338, K054539, K055555 and the K056832's predecessors; jtcores' Konami cores nearest the GX are built on them. **Recommend** recording the GX chips in the furrtek row and the jtcores `rungun`/`moo`/`prmr` cores as "set aside (author's wishes: furrtek lineage)" in sources.md (proposed rows 6 and 7 in [sources.md](sources.md)), and accepting FITTED behaviour for those six chips.