# Handoff: build `odyssey2-python`, the Odyssey 2 / Videopac board ## Context you are inheriting The family's shape: chips are cores, boards compose cores; CPUs always get their own core; a non-CPU chip used by one machine stays in its board and is extracted when a second family project needs it; never copy a file between repositories, pin the sibling by commit. Read the charter first (emulator-lineage `docs/charter.md`), then [start-here.md](start-here.md). This is an era-1 machine: one main clock domain, cycle level everywhere. Read in order before writing code: 1. [README.md](../README.md), [start-here.md](start-here.md). 2. [cpu-mcs48.md](cpu-mcs48.md), [vdc-8244.md](vdc-8244.md), [inputs-cartridges-bios.md](inputs-cartridges-bios.md), [the-voice.md](the-voice.md), [videopac-plus.md](videopac-plus.md). 3. [sources.md](sources.md), [validation.md](validation.md), [mame-oracle.md](mame-oracle.md), [census.md](census.md), [provenance.md](provenance.md). Then `python -I scripts/fetch_references.py` (9 files, about 70 MB; `--verify` to check). Text versions of the PDFs with a text layer land in `reference/text/`; VG003 and the Voice schematic are scans, read with `pdftoppm`. ## Decided by Aubrey (standing rules that apply here) - Name `odyssey2-python`, package `odyssey2_python` (the x-python naming rule). - Local, no remote, until he says otherwise. Bring your own BIOS, chip ROMs and cartridges, identified by SHA-1; nothing of Philips's, Magnavox's, Intel's or Thomson's in the repository. - Python floor = PyPy's (3.11), PyPy must work; modern over compat; reference boards are correct, not fast; sound may be less exact than pictures; smoke lists before sweeps. - Technical choices are made, marked provisional and reported; policy waits for him. - MAME and every GPL or unlicensed emulator stay closed boxes: run, never read or fetched. ## Proposed by this Phase 0 (technical defaults, provisional) - **The PAL G7000 and the NTSC Odyssey 2 as rows from milestone 1** (same BIOS image), because the tier-2 chip document (I8245) and GUST's observations are of the PAL part and MAME gives both; `c52` from milestone 5; `g7400`, `jopac`, `odyssey3` at milestone 7. - **One timeline in 8244 half-clocks** (the X9 resolution), with the 8048's machine cycle as 20 half-clocks (NTSC) or 18 (PAL), so the locked ratios stay exact integers. On the G7400 (two crystals, GUST 13.2) use MAME's two clocks as a fixed rational ratio, provisional (C11). - **The 8244 modelled per half-clock**, with the bus write landing at the half-clock its machine cycle maps to (U18 says where inside the cycle: provisional "end of the cycle"). - **The palette as a named table tagged FITTED** until a measurement exists (U5). - **Firmware and chip ROMs by SHA-1** (census.md), never by file name. ## Package and classes (proposed) ``` odyssey2_python/ machine.py # machine rows: crystal, dividers, video chip, BIOS SHA-1, region keyboard console.py # build(machine, cartridge=None, firmware_dir=...) -> Console bus.py # P1 decode: VDC, RAM, copy mode (P1.6), keyboard enable, VPP (P1.5), cart ~WR vdc.py # Vdc8244: registers, sync, objects, grid, collisions, X/Y, IRQ, T1 output vdc_sound.py # the 8244's sound block (shift register, noise, volume, IRQ) inputs.py # keyboard matrix, joysticks on the bus cartridge.py # CartridgeSlot and devices: rom (2/4/8 KB banks), rally, 4in1, ktaa, test plus.py # G7400: Ef9340, Ef9341, the 8243's use, pin B, picture mixing (milestone 7) sockets.py # socket Protocols and their test-only fakes savestate.py # whole-machine states naming firmware and cartridges by hash ``` ## The import boundary | Owner | Owns | | --- | --- | | **mcs48-python** (pinned) | the 8048: registers, RAM, PSW, timer/counter, interrupts, internal-ROM fetches from host bytes, the 8243 protocol (MOVD/ANLD/ORLD) as host calls | | **this board** | the BIOS bytes handed to the core, P1/P2 decode, external RAM, the 8244/8245 whole, keyboard and joysticks, the cartridge port and cartridge devices, the G7400 additions | | **sp0256-python** (new core, decision 3) | the SP0256: sequencer, filter, resident ROM as data, the serial ROM protocol | | **odyssey2-voice-python** (add-on, decision 4) | The Voice's latch, reset and bank logic, its ROM board, the pass-through slot | ## Sockets 1. **CartridgeSlot**: the 30-pin port as signals (BORIS 2.0): `read(addr)` on /PSEN with P1.0/P1.1, `write`/`read` on the RAM-enable path (P1.4, ~WR gated by P1.6), T0 back to the CPU, pin B to the G7400 mixer, and a clock hook for devices with their own time (The Voice). Fakes for tests: an empty slot, a ROM, a recorder. 2. **Overlay** (G7400): the EF9340/41's picture and bright-colour signal into the 8245's mixer and CX collision input, per half-clock. 3. **Expander** (G7400): the 8243's four ports. ## Domains and speed **Domains and channels** (charter, "Domains and channels"): | Domain | Parts | Clock | Channels to others | | --- | --- | --- | --- | | D1 main | 8048, 8244/8245, external RAM, keyboard, joysticks, cartridge ROM; on the G7400 also the EF9340/41 and 8243 | one crystal on Odyssey 2 / G7000 (ratios 3:2 and 5:3); two on the G7400 | the cartridge port (to D2): MOVX writes to 80h-FFh, T0 | | D2 The Voice | SP0256, its latch and ROMs | 3.12 MHz, its own crystal | in: the command/bank/reset writes; out: LRQ on T0, audio | | producers | 8244 sound waveform (from register writes and the shift clock), picture output, SP0256 filter output | | read-only logs | The 8048 and the 8244 meet on every MOVX, at INT and at T1, several times a line: they are one domain. On the G7400 the second crystal makes two clocks inside D1, converted at the bus; splitting them would cost a synchronisation per MOVX and pays nothing. D2 is the only real channel boundary: the CPU sees it only through T0 and its writes, so D2 can run behind D1 until the next T0 read or write to 80h-FFh. The order of record: earlier time first, D1 first on a tie. **Instructions per second, with the arithmetic:** - 8048: XTAL / 15 = 5,369,317 / 15 = 357,954 machine cycles/s (NTSC); 5,911,492 / 15 = 394,099 (PAL). At 1.94 cycles per instruction (measured on MAME's trace of the BIOS, 23,932 cycles / 12,332 instructions) that is **~184,500 instructions/s NTSC, ~203,000 PAL**. - 8244: 3,579,545 clocks/s, 7.16 M half-clocks/s (NTSC); 7.09 M (PAL). Per frame 263 x 455 = 119,665 half-clocks (NTSC), 313 x 456 = 142,728 (PAL). - SP0256: 3.12 MHz input; about 10,000 samples/s (the Intellivoice console figure) through a 12-pole filter run as 6 two-pole sections: ~60,000 section steps/s plus the sequencer. Total per emulated second: ~0.2 M CPU instructions plus ~7.2 M video half-clock steps; the video chip, not the CPU, sets the cost. **Does the no-JIT path reach real time?** - *Python reference*: the CPU is easy (z80-python's bare core: 2.73 M instructions/s on CPython 3.14, 67 M on PyPy 7.3.20, its 0.4.0 release notes). A per-half-clock 8244 at 7.2 M steps/s is beyond CPython and at best near real time on PyPy (an estimate: no measurement exists yet). Acceptable by the rule "reference boards are correct, not fast"; if tests need speed, the spec may evaluate runs of half-clocks with no register write and no object edge as one step, provided it stays the readable definition. - *Rust (x-rust)*: ~7.4 M simple steps per emulated second is a small load for a compiled interpreter on a desktop, a phone or WebAssembly (no measurement yet: confirm at the first Rust milestone). Expected **real time on all three with `recompile: none`**, likely with room for 2 frames of run-ahead. A `-fast` tier is built only if a target's measurement says it is needed (charter: tiers only where a target needs them); a cached interpreter and threads are not expected to be needed. D2 on its own thread is possible but would not pay. ## The gate (defined at milestone 1, before any add-on) The board's lockstep cases (the BIOS's instruction stream against MAME's trace with a fixed cartridge, `0 unexplained` over a fixed number of frames, both rows), its unit tests of documented facts, and later its picture rows. With an empty overlay and The Voice absent, the base board must not move these when the G7400 row or an add-on lands. ## Milestones | # | Milestone | Judge (tier) | Exit | | --- | --- | --- | --- | | M0 | **mcs48-python rungs 1-4**, with R1 (T1 sampled per cycle in counter mode) and R2 (bus strobe cycle) raised upstream (cpu-mcs48.md) | Intel manuals, T48, its two hardware measurements (1-2) | mcs48-python's own exits; its pin recorded here | | M1 | **Bus and timing skeleton**: machine rows, P1 decode with copy mode, external RAM, BIOS by SHA-1, `o2_rom` cartridges with banks, keyboard and joysticks, the 8244 register file, sync (lines, frame), status bits, VBL to INT, T1, X/Y counters; no pixels | VG003, I8245, BORIS (2-3); MAME (5) | with Bowling + Basketball inserted, the BIOS reaches its SELECT GAME loop and the 8048 stream equals MAME's for 3 frames on both rows, or each difference is named; one frame = 5,983 / 7,929 machine cycles (MAME's model; labelled detector) | | M2 | **Pictures**: grid (and dots, wide segments), characters with the LSS displacement rule, quads with truncation, sprites with X9/S/D, colours, P1.7 luminance | I8245, VG003 (2) | I8245's stated geometry as unit tests (the grid corner 13h,0Bh shown at 18h,18h; bar spacing; character rows doubled); SELECT GAME pixel-compared with MAME's snapshot, every difference triaged | | M3 | **Collisions, overlap status, mid-frame writes, line interrupts, X/Y latch** | I8245 (2), GUST (3) | the documented rules as unit tests; a smoke list of 10 cartridges (problem titles and well-behaved ones) reaching gameplay with the detectors' frames compared; every dot rule tagged HYPOTHESIS (U7) | | M4 | **Sound** | I8245 (2); detectors (5) | the BIOS tunes and key clicks against MAME's audio by ear and spectrum; IRQ cadence (24 shifts) as unit tests | | M5 | **The rest of the cartridge types (4in1, ktaa, test), the `c52` row, save states** | MAME's list (data), detectors | a save state loads into a fresh machine and continues identically; every non-plus cartridge in the census boots to its title | | M6 | **Smoke list grown from failures**; Gust's programs run (if decision 11) and the test cartridge (if dumped) | Gust (3), Philips (2) | named results for each program; the smoke list green | | M7 | **G7400, Jopac, Odyssey 3 rows**: EF9340/41, 8243, pin B, transparency and mixing, external collisions, `o2_rally` | EF9340/41 data sheets (2, owed), GUST ch. 14 (3) | the G7400 SELECT GAME screen and 5 Videopac+ cartridges against MAME's frames, differences triaged | | M8 | **The Voice** (add-on, on sp0256-python) | SPDS, SPAL2 (2), SPIS (3) | Voice titles speak; LRQ timing as unit tests; the 10 kHz rate kept against MAME's (a known detector difference) | Full No-Intro sweeps only when the board might be ready, and only after the missing Odyssey 2 set is back (decision 8). ## The chip rule | Chip | Users in or near the family (MAME 0.285 `-listxml`) | Proposal | | --- | --- | --- | | Intel 8048 | 433 MAME parents with an MCS-48 part (mcs48-python's count) | the existing core, mcs48-python (to be built) | | Intel 8244/8245 | 6 machines, all this driver | stays in the board | | EF9340/41 | 3 machines, all this driver (the G7400 family) | stays in the board | | Intel 8243 | 71 machines (Sega System 16 sound boards, others) | the expander protocol is in mcs48-python's contract; the 8243 itself is 10 lines of board logic, no core | | SP0256 | 31 machines, including the Intellivoice (intellivision-python's add-on) and The Voice | **its own core, sp0256-python**: this is the second family consumer (decision 3) | ## Unknowns (U) and conflicts (C) **Unknowns** (best source now; none settleable without hardware unless noted): | # | Unknown | Best source now | Status | | --- | --- | --- | --- | | U1 | The board wiring: P1.5/P1.6 roles, what drives T1 (VBL, HBL or both), the INT source | GUST 13.5, 16.1; BORIS; VG003's schematic pages | read VG003's schematic before M1 | | U2 | Power-on contents of 8244 registers and RAMs | none | random or zero by option | | U3 | Reads and writes of 8244 addresses no source lists | none | open bus, logged | | U4 | How VBL becomes a level on INT and is cleared | I8245 (no vertical interrupt inside the chip) | VG003 schematic | | U5 | The 16-colour palette and output levels | none measured | FITTED table | | U6 | What is drawn when two characters meet on a line | "unpredictable" (BORIS) | detectors | | U7 | Collision dot rules | I8245 prose only | detectors; HYPOTHESIS | | U8 | The NTSC X counter with 227.5 clocks per line | GUST's PAL figures only | detectors | | U9 | Noise polynomial, chop frequency, sound reset values | I8245 prose | detectors; good-enough rule | | U10 | PAL sync: which part is master on the G7000, what the external logic does | I8245, GUST | VG003 | | U11 | Character registers read back while graphics are on ("junk") | GUST (observed) | detectors | | U12 | The Voice's decode gates | VOICESCH (traced, "accuracy cannot be guaranteed") | HYPOTHESIS | | U13 | What the G7400's 8243 drives | none | MAME (detector) | | U14 | The EF9340/41 clock and its relation to the 8245's dot clock | none | the data sheet | | U15 | P2 during /PSEN fetches; the joysticks' active level | BORIS | VG003 | | U16 | The G7400 and French keyboard matrices | MAME's input ports (detector) | | | U17 | Bank schemes of `o2_rally`, `o2_4in1`, `o2_ktaa` | MAME's device names only; Gust's KTAA page for KTAA | detectors; GUST's MegaCART/KTAA pages | | U18 | Where inside a machine cycle the 8244 sees a write | I8245 bus timing (ns, against ALE/RD/WR) + the MCS-48 state timing | provisional | | U19 | Status bit 0's exact window and the horizontal interrupt's place against T1 | I8245: 20 us before HBL, ends 5 us before HBL ends | provisional | **Conflicts** (sources disagree): | # | Conflict | Sides | Proposal | | --- | --- | --- | --- | | C1 | the 8048 clock | BORIS: "1.79 MHz ... divided by 5"; GUST, MAME: 5.37 MHz, machine cycle = XTAL/15 | the same machine cycle (358 kHz): BORIS names the state clock (XTAL/3). Follow XTAL/15 | | C2 | VDC clocks per PAL line | I8245: 227.0; GUST (X wraps after E3h) and MAME: 228 | 228 (observation outranks a 1978 preliminary) | | C3 | lines per frame | NTSC 262 (BORIS, GUST) vs 263 (MAME); PAL 312 (GUST), 313 or 312 (I8245), 313 (MAME); BORIS: 6,026 machine cycles per NTSC frame vs 5,983 by MAME | provisional MAME's (263, 313); read VG003's "timing of TV frame scan" appendix first; HYPOTHESIS until then | | C4 | control bits 3 and 7 | I8245: "enable grid" (luminance) and "grid segment width"; BORIS, GUST: grid on/off and fill mode | the same effects under different names: use I8245's mechanism, the programmers' names as aliases | | C5 | status bit 0 | I8245: horizontal status from 20 us before HBL to 5 us before its end; BORIS: 1 = scan active, 0 = HBLANK | I8245's window (U19) | | C6 | status bit 3 | I8245: = vertical blanking; BORIS: 1 for 40 us at the start of VBLANK; GUST: "the start of the VBLANK" | detectors decide which the BIOS sees; I8245 provisional | | C7 | the grid's vertical bars | I8245: segments 2 or 16 clocks wide, bars 14 clocks apart (cannot touch when wide) | VG003's grid page and the detectors | | C8 | which part on the G7000 | I8245 calls the PAL chip 8245 yet says "the 8244 will be operated in the Slave mode" in Europe | VG003; MAME runs an 8245 as its own sync | | C9 | The Voice's trigger | BORIS: "writing a 1 to any address from $80-$DF"; the address carries the utterance | the schematic and MAME decide (U12) | | C10 | mcs48-python's Python floor | its brief: 3.12+; the family: PyPy's 3.11 | raise on mcs48-python (R3) | | C11 | G7400 clocks | GUST: CPU and VDC on separate sources, "no fixed relationship"; MAME: fixed values | a fixed rational ratio from MAME's figures, provisional; determinism needs a fixed one | ## Open decisions for Aubrey (each with a recommendation) 1. **Build mcs48-python first.** It is Phase 0 only (no code). Recommend starting its rungs 1-4 now, with requests R1-R4 from cpu-mcs48.md written into its brief, before this board's milestone 1. 2. **Scope and first rows.** Recommend the PAL G7000 and NTSC Odyssey 2 rows together from milestone 1 (one BIOS image, the tier-2 document describes the PAL chip); C52 at M5; the G7400 family at M7. 3. **sp0256-python now.** This board is the SP0256's second family consumer (with intellivision-python's Intellivoice). Recommend building it as its own core before either add-on starts, from the GI documents both repositories pin, with one Phase 0 brief shared by the two boards. 4. **The Voice as its own add-on repository** (`odyssey2-voice-python`, pinning this board and sp0256-python) rather than a device inside this board. Recommend the separate repository, matching the family's add-on shape and intellivision-python's plan for the Intellivoice. 5. **The 8244 character ROM.** It is mask data inside Intel's chip. Recommend treating it as firmware: the player supplies the dump (SHA-1 41538271...7fef, MAME's `charset_i8244.bin`), never shipped; VG003's drawn table is used only in local tests to check the dump. The same rule for the EF9341's ROM (MAME marks its dump bad: a correct dump is wanted). 6. **No free replacement BIOS** for now; run only the player's own (identified by SHA-1). A free BIOS would be its own project, if ever wanted. 7. **The EF9340/41 stay in the board** (only the G7400 family uses them in MAME 0.285). Recommend yes, behind the Overlay socket, built at milestone 7. 8. **The No-Intro Odyssey 2 set is missing** (the folder under `$NO_INTRO_DIR` is empty). Recommend refetching it; meanwhile the RetroAchievements mirror's 37 Odyssey 2 zips serve as a smoke list through `census.py --dir`. 9. **Documents to fetch by hand**: the Console5 wiki's `8245.pdf` (behind a Cloudflare challenge; this agent did not work around it) and the EF9340 and EF9341 data sheets (datasheet aggregators refuse automated fetches). Recommend Aubrey fetches them; the next session pins them by SHA-256 and reads the 8245 copy against I8245. 10. **O2EM (Artistic-2.0)**: recommend closed box only, built as a detector in emu-tools-gpl if wanted, until you rule on Artistic-2.0 (it is not on the charter's permissive list). 11. **Soren Gust's GPL test programs**: recommend building ASL and the programs in emu-tools-gpl at milestone 3 and running them as programs (source unread); their verdicts stay detectors until someone records a console's screen. 12. **MAME's per-file licences** for `video/i8244.cpp`, `ef9340_1.cpp`, `sound/sp0256.cpp`, `bus/odyssey2/*`: not opened by this phase. Recommend keeping MAME a closed box here (as decided for the PlayStation), even if some are BSD-3. 13. **Remote**: local until milestone 1 passes, then a private GitHub remote. 14. **sources.md rows**: recommend adding the rows proposed at the end of [sources.md](sources.md).