# Handoff: build `taitof2-python` (and, after it, `taitof3-python`) ## Context you are inheriting Chips are cores, boards compose cores; boards pin cores by commit and raise core corners on the core. F2 is era 2 (a 68000 and a Z80 in lockstep, cycle level throughout); F3 is late era 2 to early era 3 (a cached 32-bit CPU, a programmable DSP on the sound board). Nearest family models: `../cps1-python` (a 68000 arcade board with sockets for sound and video chips and a MAME detector), `../neogeo-python` (68000 + Z80 + YM2610), `../megadrive-python` (a mature 68000 + Z80 board on `m68000-python`). Rules: Python >= 3.11, CPython and PyPy; MIT; MAME and the MiSTer F2 core are closed boxes; no ROM, PAL or MCU dump in the repository; sets through `MAME_ROMPATH`; local git only; no sweeps. ### Read in this order README.md; docs/start-here.md; docs/f2-board.md; docs/cores.md; docs/domains.md; docs/census.md; docs/validation.md; docs/mame-oracle.md; docs/provenance.md; then, for F3, docs/f3-board.md, docs/f3-sound.md and 12me21's notes (`reference/src/12me21-taito-f3`, start at `website/home.html` and `terms.txt`). ## Scope In (F2): the 68000 side's RAM, ROM, palette, I/O chips (TC0220IOC, TC0510NIO, TE7750), watchdog, interrupts and video timing; TC0100SCN, TC0480SCP, TC0200OBJ, TC0280GRD, TC0430GRW, TC0360PRI, TC0110PCR; the TC0140SYT link; the Z80 sound side with the YM2610 behind a socket. Out (F2, first pass): the C-Chip (Mega Blast), the YM2203 + MSM6295 Cameltry clones and the Drive Out bootleg, the TC8521 quiz board (`yesnoj`). F3 (separate repository, decision 1): the 68EC020 board (TC0630FDP, TC0650FDA, TC0640FIO, EEPROM, timer) and the Taito Ensoniq sound board. Waits on `m68020-python` (decision 2) and, for effects, `es5510-python` (decision 4). ## Proposed names - Package **`taitof2_python`**, class `taitof2_python.TaitoF2` constructed with a `config` naming the chip set (the fifteen rows of f2-board.md; one `BoardConfig` per MAME parent family: `"cameltry"` = TC0100SCN + TC0280GRD + TC0360PRI + TC0220IOC, ...), so a game is a ROM set plus a config, as on the real PCBs. - Modules: `bus.py` (per-config decode), `io.py` (TC0220IOC, TC0510NIO, TE7750), `video/` (`tc0100scn.py`, `tc0480scp.py`, `tc0200obj.py`, `tc0280grd.py` with TC0430GRW as its variant, `tc0360pri.py`, `tc0110pcr.py`, `timing.py`), `sound/` (`tc0140syt.py`, `sound_cpu.py`), `domains.py`, `machine.py`. - Later, **`taitof3_python`**: `TaitoF3`; `video/fdp.py` (with `lineram.py`, `sprites.py`, `priority.py`), `video/fda.py`, `fio.py`, `eeprom.py` (or the shared core, decision 5), `sound/` (`board.py` the Taito Ensoniq board as a socketed unit, `otis.py`, `duart.py`, `mb87078.py`, `mb8421.py`, the ESP behind a socket). - Sockets: `Cpu` (m68000-python's bus callables), `SoundCpu` (z80-python), `SoundDevice` (YM2610: silent stub until ym2610-python has code), `Protection` (empty; C-Chip later). F3: `Cpu` (m68020-python), `SoundBoard` (the whole Ensoniq board: other Taito boards carry the same one), `Dsp` (ES5510). ## Import boundary The board imports `m68000_python`, `z80_python` and, when it has code, `ym2610_python`. Nothing imports the board. Video chips never call the CPU; the CPU reaches them through `bus.py`. ## Unknowns (U) - U1 every TC0xxx latch timing (mid-frame writes) - f2-board.md. - U2 TC0200OBJ per-line limits and buffer swap - f2-board.md. - U3 TC0360PRI blend modes - f2-board.md. - U4 F2's real frame rate and line count - f2-board.md, census.md. - U5 TC0100SCN column scroll - f2-board.md. - U6 the C-Chip program and protocol - f2-board.md. - U7 the FDP's sprite-drawing budget - f3-board.md. - U8 the priority-cell model's corners (a theory by its author) - f3-board.md. - U9 F3 line count and pixel clock (432 x 262 at 6.6715 MHz, supported by the timer arithmetic) - f3-board.md. - U10 what a "freeze" access does to the 68EC020 - f3-board.md. - U11 = C1 below. - U12 the ES5510 instruction set and timing - f3-sound.md. - U13 OTIS at 15.238 MHz against its 10 MHz rating - f3-sound.md. - U14 the MB87078 attenuation curve - f3-sound.md. - U15 the DUART timer programming - f3-sound.md. - U16 = C6. - U17 what the main board's "sound bank switch" (300000h) selects - domains.md. - U18 the 93C46's exact command timing (no data sheet pinned: provenance.md). - U19 which TC0140SYT line interrupts the Z80 (NMI or INT) - domains.md. ## Contradictions (C) - C1 F3 main CPU clock: 15.23809 MHz (12me21 `clocks.txt`; supported by the interrupt-5 arithmetic) vs 16 MHz (MAME 0.285). Take 12me21's. - C2 "Bubble Bobble II-era F2 games" (the task brief) vs `bublbob2` in `taito_f3.cpp`: Bubble Bobble II is F3. - C3 OTIS "up to 10 MHz operation" (Ensoniq specification) vs 15.238 MHz on F3 (12me21 and MAME agree). - C4 F2 refresh exactly 60 Hz in MAME with no raw screen timing; nothing measured. - C5 ESP clock: 8 MHz (12me21) vs 10 MHz (MAME). - C6 stereo order at the connector (12me21: recordings and MAME vs manuals and one sound test). - C7 the F3 sound CPU: MC68000 in MAME; MC68EC000FN16 on 12me21's single-PCB board, MC68000P12F on another (12me21 `mbv.txt`): both exist; the AVEC difference matters. ## Milestones F2-M1 skeleton (Cameltry boots), F2-M2 TC0100SCN + palette + TC0360PRI, F2-M3 sprites, F2-M4 ROZ, F2-M5 sound domain, F2-M6 TC0480SCP, F2-M7 seeded faults; then F3-M1..M6. Exit tests in [validation.md](validation.md). ## Domains and speed (Full arithmetic in [domains.md](domains.md).) - **Domains**: F2 main (68000 + video) and sound (Z80 + YM2610), meeting at the TC0140SYT and the sound reset. F3 main (68EC020 + FDP/FDA) and sound (68000 + OTIS + ESP + DUART), meeting at the MB8421 dual-port RAM, the sound resets and a bank latch. - **Need** (MAME traces, instruction counts only): F2 68000 0.79 M instructions/s in attract (ceiling 3 M), Z80 0.40 M (ceiling 1 M); F3 68EC020 1.66 M (ceiling ~5 M), sound 68000 2.57 M (ceiling 3.8 M); plus F2 ~21 M layer-pixels/s, F3 ~35 M layer-pixels/s, OTIS 0.95 M voice-samples/s, ESP up to 8 M operations/s. - **No-JIT path**: the family's interpreters run 104-191 M 68000 instructions/s (`m68000-rust-fast`) and ~50 M Z80 (`z80-rust`); even `m68000-python` on PyPy runs 19-34 M. F2 is real time at `x-rust` on every target. F3 is real time at `x-rust` on desktop, phone app and desktop browser; on the phone browser and A55-class handhelds it is marginal until `-fast` puts the sound domain on its own thread. **`recompile: none` for both; no turbo tier planned.** The Python reference is below real time (per-dot video in Python), as every family board. ## Open decisions for Aubrey 1. **F3 as a sibling repository, `taitof3-python`, not a row of this board.** Recommended: the two systems share no CPU, no video chip and no sound chip; only the name. The F3 documents here move there (with history) when its build starts. 2. **Start `m68020-python` with the 68EC020 as its first variant, F3 as its first board.** Recommended: F3 needs no MMU and no FPU, so it is the smallest useful 68020; the Amiga AGA rows (68EC020) and the X68030 (68030 as a later variant) both proposed the same core. One Phase 0 for that core, coordinating the three boards' needs, before any F3 build. 3. **MAME's BSD-3 Taito files stay closed** (they would be "code OK with notice" by their `license:` lines). Recommended: closed for F3, where 12me21's measurements suffice; for F2, where nothing else exists, **allow reading them as facts with notice** if Aubrey wants F2 to move faster, recorded per file in provenance.md. Default if no answer: closed (the PSX precedent). 4. **ES5510 ESP: its own core, `es5510-python`, deferred.** Recommended: it is a programmable processor (the chip rule; precedent `dsp16-python`), it has no datasheet in hand (CCRMA's copy is set aside), and F3 games play without effects. Build F3 with a pass-through ESP socket first (OTIS channel 1 to the DAC: HYPOTHESIS that this is the dry path), and ask Aubrey to fetch Dattorro's scan himself if he wants the core. 5. **A small shared 93C46 core** (`eeprom93-python`), since `cps2-python` and `cps3-python` already model one in-board. Recommended: yes, when the second of the three boards reaches its EEPROM; until then each keeps a pin-shaped in-board module. 6. **The F3 sound board as a socketed unit** (`SoundBoard`), because MAME's same `taito_en` serves six other Taito drivers. Recommended: yes, inside `taitof3-python`; extract only if a second Taito board joins the family. 7. **Ask `m68000-python` for an AVEC acknowledge without the E-clock wait** (the MC68EC000 on F3's sound board). Recommended: raise it upstream now as a request with this repository's evidence (12me21 `audiocpu.txt` pin 23 ~AVEC); it is small and the core's claims already name the E-clock rule as MAME's alone. 8. **Take 12me21's clocks (C1, C5) over MAME's**, tagged MEASURED with the file named, MAME's values kept as counted disagreements. Recommended. 9. **F2 first pass without the C-Chip and the YM2203 variants.** Recommended: seven sets of 71 (C-Chip 3, YM2203 2, Drive Out 1, the TC8521 quiz 1); add them as configs later. 10. **Speed answer as the plan:** `recompile: none`, `-fast` with the sound domain on a thread, no turbo unless a measured target fails. Recommended.