# Handoff: build `model3-python`, the Sega Model 3 board ## Context you are inheriting Read the charter (emulator-lineage `docs/charter.md`), the late-era method proposal (`docs/proposals/2026-11-late-era-method.md`), the N64 execution architecture (`../n64-python/docs/execution-architecture.md`) and `../model2-python/docs/` (the shared sound board, 315-5881, 315-5649 and the MAME practice). Model 3 (1996-1999) is era 3 by date and **era 4 by method**: a PowerPC at up to 166 MHz, and a scene-graph GPU known only through emulators. Read in order: [start-here.md](start-here.md), [board.md](board.md), [powerpc.md](powerpc.md), [real3d.md](real3d.md), [sound.md](sound.md), [cpu-cores.md](cpu-cores.md), [domains-and-speed.md](domains-and-speed.md), [sources.md](sources.md), [validation.md](validation.md), [mame-oracle.md](mame-oracle.md), [census.md](census.md). Then `python -I scripts/fetch_references.py` (32 files, about 88 MB). ## Scope The four steps as machine rows: 1.0, 1.5, 2.0, 2.1 (2.1 identical to 2.0 until a difference is shown). First row: **step 1.0** (Virtua Fighter 3: 66 MHz, the simplest periphery, no comm board, no 315-5881). Then 1.5 (Scud Race, with the DSB), then 2.0/2.1. ## Proposed package and classes ``` model3_python/ machine.py # step rows: CPU variant and ratio, bridge (105/106), culling RAM size, # TAP IDs, Real3D PCI id; per-game wiring (DSB/DSB2, drive, comm, 5881) console.py # build(set_name, rompath): reads the MAME zip by CRC, never copies bridge.py # MPC105/MPC106: DRAM, PCI configuration space, the 60x bus side scsi.py # 53C810 as the step 1.x DMA path (functional first: decision R5) real3d.py # the scene-graph walk, transform/cull/light, setup (front end) and status raster.py # the back end: textures, mip maps, fog, blending, Z, 3D-RAM tilegen.py # four layers, palette, mixing, scan-out, vblank tap.py # the JTAG chain with per-step ID codes sound.py # 68000 + two scsp-python instances; DSB, DSB2 (shared code with model2-python) periphery.py # 315-5649 I/O, EEPROM, RTC72421, billboard, comm board, drive boards protection.py # 315-5881 (shared with model2-python: decision R8) savestate.py # the shared state format (late-era L3) ``` ## The import boundary and sockets The board owns the bridge, the Real3D, the tile generator, the TAP, the periphery. The PowerPC core owns registers, caches, TLBs, the MMU's miss exceptions and its timing. Sockets: 1. **PowerPC bus port**: 60x-style transactions (address, size, burst, cache-inhibited, write-through, kind) with the bridge's waits; `run_until(deadline)`; interrupt and decrementer inputs; a trace hook. 2. **Real3D port**: memory windows (display list, culling, polygon), the texture FIFO, the flush command, status; a front-end/back-end split with joins at status reads, frame-buffer reads and scan-out (late-era section 4). 3. **SoundBoardSocket**: the USART stream; a thread in `-fast`. 4. **ProtectionSocket**: the 315-5881 window and its read callback into PowerPC RAM. ## What the board needs from its cores - **The shared PowerPC core** (decision R2): a `ppc603e` variant (16 KB 4-way caches, software TLB reload with IMISS/DMISS/HASH1/HASH2/ICMP/DCMP/RPA and `tlbli`/`tlbld`, the 603e timing tables, HID0/HID1, PLL ratio as a parameter) and `ppc603ev` (the same at higher clocks, U4). - **scsp-python** (x2), **m68000-python**, **z80-python** as in model2-python. ## Milestones | # | Milestone | Judge (tier) | Exit | | --- | --- | --- | --- | | R-M1 | Step 1.0 skeleton: work RAM, MPC105, system registers, interrupts, the 315-5649, EEPROM, RTC, TAP chain; the PowerPC pinned | 603EUM, MPC105 (2); MAME (5) | `vf3` from reset: the PowerPC's stream equal to MAME's (`-nodrc`) for one frame, or every difference named | | R-M2 | Tile generator and scan-out | MAME frames (5) | `vf3`'s boot text screens equal to MAME's | | R-M3 | Real3D front end: the 53C810 DMA path, display list, culling nodes, matrices, LOD, polygon fetch from VROM/polygon RAM; triangle lists out | MAME (5), Supermodel (5, closed box) | triangle lists per frame equal to MAME's on a slice, differences named | | R-M4 | Real3D back end: textures and mips, lighting, fog, blending, Z, gamma | MAME (5) | `vf3` attract frames compared pixel by pixel, every difference classified | | R-M5 | Sound: 68000, two SCSPs, USART | SCSP (2), MAME (5) | the sound program boots; USART traffic equals MAME's | | R-M6 | Step 1.5: 100 MHz ratio (C1), comm board, DSB (Scud Race) | MAME (5) | `scud` reaches its settings screen as MAME's does | | R-M7 | Step 2.0/2.1: 603ev, MPC106, PCI path, 4 MB culling RAM, new Real3D id, 315-5881, DSB2 | MAME (5) | `harley` (2.0, no 5881) and `daytona2` (2.1, 5881, DSB2) to attract | | R-M8 | Save states (shared format), the slice list, drive boards | - | a state round-trips; slices defined per step | Smoke lists before sweeps; no library sweep in Python, ever; sweeps run in model3-rust. ## Unknowns (U) and conflicts (C) | # | Unknown | Best source now | | --- | --- | --- | | U1 | Step 1.5's clock: 100 MHz (M3's table, MAME) or 66 MHz (Guru-Readme) | a board; the 603e PLL tables say what ratios are possible | | U2 | What changed on the step 2.1 video board (837-13368) | none | | U3 | The TAP chain in full (MAME needs a "JTAG patch" for some games) | MAME (5) | | U4 | The 603ev's differences from the 603e that software can see (PVR, HID bits, timing) | an IBM/Motorola 603ev document, not yet found | | U5 | A PowerPC test suite with hardware-captured results under a permissive licence | none found (shared with gekko-python) | | U6 | A Real3D Pro-1000 document (M3V's vocabulary suggests one existed) | ask (decision R10) | | U7 | The Real3D's arithmetic precision (float vs fixed), interpolation, Z format | none | | U8 | How the two SCSPs share sound RAM and interrupts | MAME's maps | | U9 | Whether games use the 53C810's SCRIPTS beyond a DMA pattern | MAME's `53c810` (5) | | U10 | Drive boards on Model 3 (CPU, protocol) | the ROMs; none run in MAME | | U11 | Real3D timing: when a flushed frame completes; whether games read results back | a MAME trace (first measurement) | | # | Conflict | Sides | Proposal | | --- | --- | --- | --- | | C1 | step 1.5 clock | M3's step table and config: 100 MHz; M3's Guru-Readme: 66 MHz, no 100 MHz oscillator | follow MAME (100 MHz via the PLL) provisionally; the PLL multiplier makes both readings possible | | C2 | "Step 1.5" boards | Guru-Readme: no PCB says "Step 1.5"; the same readme lists 837-12874/12875 "MODEL3 STEP 1.5" CPU and video boards | Sega's part numbers win; the first statement was about Scud Race's PCB markings | ## Domains and speed **Domains and channels:** A main (PowerPC, bridge, RAM, I/O), B Real3D front end (memory windows, flush, status), C Real3D back end (triangles in, frame out), D video (tile generator, scan-out), E sound (USART at MIDI-class rate), F periphery (comm, billboard, drive). Detail in [domains-and-speed.md](domains-and-speed.md). **Instructions per second, with arithmetic:** the 603e issues up to three per clock (603EUM 1-2); at 0.7-1.0 sustained (HYPOTHESIS): step 1.0 46-66 M/s, step 1.5 70-100 M/s, step 2.x 116-166 M/s. Budgets in desktop / phone app / phone browser host cycles per instruction (5.0e9 / 4.0e9 / 2.4e9 over the rate): step 1.0 76-109 / 61-87 / 36-52; step 1.5 50-71 / 40-57 / 24-34; step 2.x 30-43 / 24-34 / 14-21. An exact interpreter with cheap time-keeping is estimated at 25-60. **Does the no-JIT path reach real time?** Step 1.0: desktop and phone app yes, phone browser no (`recompile: wasm`). Step 1.5: desktop yes, phone app at the edge, browser no. **Step 2.x: desktop at the edge, phone app no, browser no**: the first board in the family's plans where `recompile: none` is not expected to reach real time on a phone app (HYPOTHESIS until a PowerPC `-fast` is measured). The Real3D needs three to five threads in software on desktop and a GPU backend on phones and in browsers. MAME (with its PowerPC recompiler) runs `scud` at 120 % on one core here (MEASURED). ## Open decisions for Aubrey - **R1. Scope and first row.** *Recommend* four step rows, 1.0 first (Virtua Fighter 3), 2.1 as a copy of 2.0 until a difference is known. - **R2. One PowerPC core with variants** (603e, 603ev, Gekko, Broadway), named neutrally (`powerpc-python`) or kept as `gekko-python` with a `ppc603e` variant. *Recommend* one core, neutral name, decided together with the gekko-python report: decode and UISA shared; MMU model, cache geometry, extensions and timing tables per variant. - **R3. Step 2 below real time without a recompiler.** *Recommend* stating it in the capability record from the start, building `-fast` with cheap time-keeping first (measure before deciding), then a recompiler as turbo (`native` on desktop and Android, `wasm` in browsers) with the interpreter as fallback; on iOS, a stated lower rate or a named concession, Aubrey's call when the numbers exist. - **R4. The Real3D as a functional model** (scene walk and arithmetic as functions, OBSERVED/FITTED per field, timing provisional and separate). *Recommend* yes: no other level is supportable by the evidence. - **R5. The 53C810 as a functional DMA model first**, a SCRIPTS core only if U9 shows games rely on more. *Recommend* yes. - **R6. A GPU backend for the Real3D** on phones and browsers, turbo under the per-pixel contract; precision differences become named concessions. *Recommend* yes, after the software back end exists. - **R7. MAME's BSD-3 Model 3 files read for facts, never transcribed** (as model2-python M8). *Recommend* yes; or, under the stricter PlayStation line, move `reference/mame-bsd/` to `trash/`. - **R8. The 315-5881 shared between Model 2 and Model 3** (and NAOMI later): extract when the second board is built; keys treated like firmware (never committed). *Recommend* yes. - **R9. sources.md rows** (Aubrey's file): the Motorola/IBM PowerPC and MPC105/106 manuals (facts only; UK Mirror Service copies), MAME's Model 3 files (BSD-3-Clause, holders in docs/sources.md), **Supermodel (GPL-3.0: closed box only, built in emu-tools-gpl if wanted)**. - **R10. A Real3D Pro-1000 document.** *Recommend* asking whether one can be found with clear terms (Real3D was Lockheed Martin's; its documentation may survive in archives) before milestone R-M3. - **R11. Supermodel as a second detector** for the Real3D, built in emu-tools-gpl. *Recommend* yes, before R-M4: two detectors that disagree point at the unknowns.