# The shape: a machine row in megadrive-python, a socket device, or a board of its own? Read at megadrive-python `origin/main` 05a618e (README, `docs/expansion-sockets.md`, `machine.py`, `board.py`, `system.py`, `vdp.py`; the checked-out branch there is `pin-2-od2`, not read) and m68000-python `main` 55d3d60. ## What the Pico shares with a Mega Drive and what it does not | | Mega Drive (megadrive-python) | Pico | | --- | --- | --- | | 68000 | m68000-python, MCLK/7 | the same part family (MC68HC000), the same clock (tier 5 + DOC) | | VDP and PSG | 315-5313(A), in the board (`vdp.py`), PSG from sn76489-python | 315-5313A: the same chip (OBSERVED marking) | | Z80, its RAM, the bus arbiter | yes, cycle-interleaved with the 68000 (`system.py`, `arbiter.py`) | **absent** | | YM2612 | ym2612-python | **absent** | | I/O chip, pads, version register at $A10001 | yes (`io.py`) | **absent**; buttons, pen, page and version at $800001-$80000D | | TMSS at $A14000, boot ROM | on later models | absent; games write "SEGA" to $800019-$80001F instead | | Interrupts | the VDP alone drives IPL (levels 2, 4, 6) | levels 3 and 5 too, so a second source merges onto IPL (U4) | | Sound mix | FM + PSG through the board's analogue model | PSG + 315-5641 ADPCM | | Cartridge | Mega Drive mappers, SRAM, EEPROM | plain ROM up to 4 MB in the census; one cartridge with a battery in MAME's list; the Keyboard Pico's cartridge carries a keyboard socket | | Bus timing | measured: refresh, arbiter, DMA (Kabuto, MoD, Nuked-MD) | **nothing measured** (U9) | ## Option A: a machine row in megadrive-python A row in `machine.MACHINES` (`"pico"`, `"picou"`, `"picoj"`) is how megadrive-python holds model differences (VSRAM size, TMSS, version register, the FM variant, the audio path). A Pico row would have to switch off the Z80, the arbiter, the FM chip, the I/O chip and the $A0/$A1 decode, and switch on a new I/O block, a new sound chip, a pen and a second interrupt source. That is not a model difference; it is a different board inside the Mega Drive's code, and every Mega Drive change would then carry Pico code (the same argument `expansion-sockets.md` gives for not folding the 32X and the Sega CD in as variants). **Not recommended.** ## Option B: a socket device on megadrive-python The nine sockets were built for things added to a Mega Drive. A Pico subtracts: - Socket 3's claimable range includes $800000-$9FFFFF, so an I/O block at $800000 could be claimed today. - But there is no way to build a `System` without its Z80 (`System.__init__` constructs `Z80CPU` unconditionally) or its YM2612, the I/O chip is built in the `Board`, the $A0/$A1 pages always answer, and every 68000 cycle is timed by the Z80-aware arbiter. - The design dropped the interrupt socket ("neither add-on interrupts the main 68000"), and the Pico needs exactly that. So a socket device would need megadrive-python to grow "absent" switches for four of its own parts plus an interrupt socket, all behind its gate. **Not recommended**: it bends the finished board around a machine that is mostly missing pieces. ## Option C (recommended): `pico-python`, a board of its own that reuses megadrive-python's VDP pico-python owns its own small board: the memory map above, the I/O block, the pen, buttons and pages, the 315-5641 wrapper, the interrupt merge, the cartridge slot (with room for a cartridge-side keyboard), a 68000-led scheduler with no Z80, and the frontend's pen and page controls. It reuses, by pin, never by copy: - **m68000-python** for the CPU (pinned at the revision megadrive-python pins, so one 68000 is resolved; `set_ipl`, autovectors and the access clock are already its API); - **megadrive-python's `VDP`** (with its `Renderer`), driven as a chip. The VDP's coupling to its board is narrow already. At 05a618e it reads exactly nine things from the board, `dma_read_word`, `open_bus`, `psg`, `sound_sync`, `devices`, `dma_started`, `cart_refresh_due`, `ram_refresh_due`, `dma_bus`, and four fields of its `Machine`: `vdp`, `pal`, `hv_reads`, `dma_figures`. Its bus side is `read_word/read_byte/ write_word/write_byte(offset, ..., mclk)`, `sync(mclk)` and the `ipl` property; - **sn76489-python** for the PSG, through the VDP as on the Mega Drive; - **upd7759-python** (proposed, [pcm.md](pcm.md)) for the ADPCM decoder. ### What megadrive-python would need for option C Small, and nothing that changes a Mega Drive cycle (its gate: the MAME lockstep, the VDPFIFOTesting and HV captures, the compat sweep moving 0 rows): 1. **A named `VDPHost` protocol** in `sockets.py` (or beside `vdp.py`) listing the nine board attributes the VDP uses today, so a second board can host it knowingly and a change to that list is visible. Today the contract is implicit duck typing. 2. **A VDP-only configuration**: the VDP takes a whole `Machine`, which imports ym2612-python's FM variants. Either a small `VDPConfig` (the four fields) that `Machine` provides, or a documented promise that only those four fields are read. Without it the Pico board must build a fake Mega Drive `Machine` with an FM variant it does not have. 3. **The refresh and DMA-bus hooks made the host's**: `DMA_TAKES_REFRESH` writes to `board.cart_refresh_due` and `board.ram_refresh_due`, which are the Mega Drive's refresh model. A host without that model must be able to say so (a host that keeps the two at "never due" works today, HYPOTHESIS until tried). 4. A **pin**: pico-python pins a megadrive-python commit as segacd-python and sega32x-python do. ### The chip rule and the VDP The charter: "A chip that a second project needs becomes its own core, extracted with history and pinned by both; until then it stays in its board behind a pin-shaped interface." segacd-python and sega32x-python pin megadrive-python whole, as add-ons to a whole Mega Drive; the Pico is the first family board that needs the VDP *without* the Mega Drive. system16-python already named System 18 as the next (its open decision 6). Items 1-3 above are exactly the pin-shaped interface the rule asks for; whether the VDP then moves into its own repository (`ym7101-python`, say) is open decision 2 in the brief. Recommendation: do items 1-3 in megadrive-python first and pin it; extract when a second VDP host (this board or System 18) reaches its video milestone, so the interface is proven by a real second user before it moves. ## What this costs megadrive-rust and the Rust tiers Nothing until a `pico-rust` exists. When it does, it pins megadrive-rust for the VDP in the same way (its `VDPHost` trait being the transcription of item 1), and the Pico's Rust tiers stay a strict subset of the Mega Drive's work: no Z80, no FM.