# What the board needs from tms34010-python ## Where the core stands `../tms34010-python` is **Phase 0 only: documents and oracles, no core code** (its README: "Status: documents and oracles only. There is no core code in this repository yet"; last commit `8a15363`). Its handoff brief fixes the host contract and a seven-rung ladder. Three things in it are older than today's family rules and need settling before the core is built (open decision 3 in the brief): 1. It states "Python 3.12+"; the family floor is 3.11 (PyPy). 2. Its documents cite MAME's TMS34010 source by file and line (`34010ops.hxx`, `34010gfx.hxx`, `tms34010.cpp`), recorded as BSD-3-Clause in its provenance page. Today's brief treats MAME as a closed box; those citations are permitted by the licence but were written with MAME source open, which the core's provenance file must say. 3. Its validation page calls FBNeo's `tms34010` core "BSD-3, Marcos Medeiros 2015" and names it the tiebreaker; emulator-lineage `docs/sources.md` lists FinalBurn Neo as non-commercial (closed box only). Which licence covers that one file has to be checked before it is used even as a detector, and a closed box is never a tiebreaker (it is a detector). ## What Midway's boards use Measured in MAME 0.285 (OBSERVED, closed box), two frames of attract mode each, instructions counted with the debugger's trace (`scripts/mame/count.lua`; collapsed loops added back): | Set | Frames | Instructions | Per second at 54.70684 Hz | Of which in collapsed loops | Graphics instructions seen | | --- | --- | ---: | ---: | ---: | --- | | `term2` (Y, 50 MHz) | 600-602 | 100,172 | 2.74 M | 79 % | `FILL` x4, `PIXT` x4 | | `mk` (T, 50 MHz) | 2700-2702, a fight demo | 76,348 | 2.09 M | 60 % | `FILL` x4, `PIXT` x4 | | `umk3` (Wolf, 50 MHz) | 1800-1802 | 67,236 | 1.84 M | 85 % | `FILL` x4, `PIXT` x2 | | `mk2` (T, DCS) | 2700-2702 | >= 28,916 | >= 0.79 M | | the final loop was still running at the window's end, so it is uncounted | Most of the "loop" instructions are the CPU polling the DMA's busy bit (`mk`: about 4,590 status reads a frame while the blitter runs, `scripts/dma_stats.py`). The CPU is in practice a **command processor for the DMA**: the general instruction set carries the games, and the graphics instructions appear only as `FILL` (screen or buffer clears) and `PIXT` (each `PIXT` seen is the shift-register-transfer idiom below). tms34010-python's README reached the same conclusion on `mk`; `PIXBLT`, `LINE` and `DRAV` were never seen in these windows. ## The core's parts the board depends on, in the order the board needs them 1. **The general instruction set, interrupts and reset** (core rungs 1-4). Everything above. The board's first milestone cannot start without them. 2. **The display interrupt and the external interrupt lines.** One display interrupt per frame (tms34010-python: exactly two `RETI` in two frames on `mk`); the Wolf games take many more (66 `RETI` in two frames of `umk3`: HYPOTHESIS, the sound or security interrupts on LINT1/LINT2). The T-unit schematic routes `ADC_INT` to `LINT2` (NBA Jam manual, CPU board sheet with UF5, DOC by eye). The core must take `set_int1/set_int2` as levels, as its brief already says. 3. **FILL and PIXT with the field machinery** (core rung 5, only the forms Midway uses first): `FILL` over VRAM at the pixel size the game sets, and `PIXT` as a plain pixel read and write. 4. **The SRT idiom** (User's Guide, DPYCTL "SRT (bit 11) - VRAM serial-register transfer enable" and "the SRT bit enables conversion of an ordinary pixel access into a VRAM [shift-register transfer]", DOC). The traced sequence: set DPYCTL bit 11, one `PIXT` read, clear bit 11 (tms34010-python `docs/mame-oracle.md`). The core must hand the board a callback that says "this access is a shift-register transfer, read or write, at this row" instead of doing a memory access; the board's VRAM model performs it. 5. **HOLD/HLDA** (User's Guide section 2.5: "The TMS34010 hold interface permits other devices to request and be granted control of the local interface bus", DOC). The DMA blitter takes the bus this way (T-unit schematic, DOC by eye). The core needs a way for the board to say "the bus is held until cycle N"; the CPU then stalls at its next memory access. This is not in tms34010-python's brief; it is the first corner this board raises on the core (open decision 3). 6. **The video timing registers** are the board's, by the core's contract (HESYNC to VTOTAL, DPYCTL, DPYSTRT, DPYINT, DPYTAP, HCOUNT, VCOUNT, DPYADR, REFCNT: the core's `read_io` / `write_io` hand them to the board). The board implements the counters from VCLK (the 8 MHz dot clock), the blanking and sync edges, DPYADR's per-line advance, the display interrupt at DPYINT, and the serial (screen-refresh) transfers at the start of each line when DPYCTL's SRE bit is set. MAME synthesises HCOUNT and REFCNT on read (tms34010-python `docs/start-here.md`), which is a detector's habit, not a rule. 7. **The host interface** (HSTDATA, HSTADRL/H, HSTCTLL/H) is **unused** on these boards as far as the traces show: no access to `C00000C0-C00000F0` in any window, and the schematics show no host processor. The board leaves those registers inert apart from HSTCTLH's HLT and NMI bits, which the core owns. 8. **Cycle counts.** The DMA's polling loops mean the instruction count per frame depends on how long the DMA holds the bus and how many states each poll takes. A core that returns machine states per instruction from the User's Guide's section 13 (core rung 7) is what makes the board's frame match. Until then, the board runs, but its per-frame instruction counts are not comparable with MAME's. ## The clock INCLK is divided by 8 inside the chip (User's Guide appendix A, the data sheet's timing text: "Input clock INCLK is divided internally by 8 to produce output clocks LCLK1 and LCLK2", DOC). One machine state is one local clock period (section 1, "The TMS34010's machine state is a single local clock period"). So the boards run at **5.0, 6.0 and 6.25 million machine states per second** (40, 48, 50 MHz parts).