# Sockets: the slot, the controller ports, and what Neo Geo CD will need `megadrive-python` is the family's model: an add-on is **its own board in its own repository that pins the base board by commit**, and the base board offers narrow `typing.Protocol` sockets that cost nothing when empty (`megadrive-python/docs/expansion-sockets.md`, built 2026-10-21; nine sockets, a gate, "0 sweep rows moved"). This page names the sockets `neogeo` needs from its first milestone, and the ones a later `neogeocd-python` board will need. Neo Geo CD was **not researched in depth** here: its facts below were taken from the Neo Geo Development Wiki's register and memory-map pages and MAME's `neogeocd.cpp` map, enough to name a socket, not to build one. The wiki was set aside on 2026-11-26 (author respect): where MAME states a fact the row cites MAME, and the rest is tagged `[HYPOTHESIS: was wiki Page]` for `neogeocd-python`'s own Phase 0 to settle. ## Sockets the base board needs for itself These are not add-on hooks; they are how the board is assembled from data, and they are what the machine rows (AES, MV1 ... MV6) differ by. 1. **Cartridge slot** (`Cartridge` Protocol), 1, 2, 4 or 6 of them, one selected at a time by `$380021` on multi-slot MVS boards ([system-rom.md](system-rom.md)). A cartridge answers: - the 68000 P bus: `read_word/read_byte/write_word/write_byte` on `$000000-$0FFFFF` and the port zone `$200000-$2FFFFF` (writes there are how every banking and protection chip is driven), plus its ROMWAIT/PWAIT setting (wait states the board adds); - the Z80 bus: `read_m1(address)` for `$0000-$F7FF` and the `SDRD0` bank-set strobe (port read address); - the video buses: `fix_byte(address)` (S ROM, or NEO-CMC's fix taken from C ROM) and the sprite tile fetch `sprite_row(tile, row)` returning the 16 pixels of one tile row (C ROM pair, after any CMC decryption), so the board never sees how the cartridge stores tiles; - the sound buses: `read_adpcm_a(address)`, `read_adpcm_b(address)` ([sound.md](sound.md)); - `reset()`. Encryption (CMC42/50 graphics, CMC50 M1, PCM2 V, the KOF98/2002 P scrambles) is the cartridge object's business. **Recommendation:** the cartridge decrypts at load time, as MAME does, where the real chip is a pure function of address and data; live chips (SMA's random number generator and bank register, PVC, KOF98 overlay, the early security chips) are modelled live ([cartridges.md](cartridges.md)). The slot sees one interface either way. 2. **System ROM socket**: 128 KiB at `$C00000` (two MAME system ROMs, `sp-45.sp1` and `sp-j3.sp1` for the MV1C, are 512 KiB: census), the machine row names the file (BYOR). 3. **Board ROMs**: SFIX (fix, 128 KiB), SM1 (Z80, 128 KiB), L0 (shrink table, 128 KiB, first half used). On the AES these come from the cartridge side or are absent; [aes-vs-mvs.md](aes-vs-mvs.md). 4. **Controller ports** (two): the 8-bit input read at `$300000`/`$340000`, the start/select bits at `$380000`, and the 3 output bits each from `$380001`. Devices: joypad (default), mahjong panel, the NEO-FTC1B 4-player adapter, and the cartridge-specific controls the MVS cabinet provides (irrmaze trackball, popbounc dial); [inputs.md](inputs.md). 5. **Memory card slot**: 8-bit device on D15-D8 at `$800000-$BFFFFF`, bank register `$380011`, detect and write-protect bits in `$380000`, three lock bits in the system latch. 6. **Backup RAM and calendar** (MVS rows only): 64 KiB at `$D00000` with its lock; uPD4990A on `$380051`/`$320001`. Both persist between runs (BYO files, git-ignored). ## Sockets a Neo Geo CD board will need The Neo Geo CD keeps the 68000, Z80, YM2610 and the LSPC/NEO-B1 video, and replaces every cartridge ROM with RAM loaded from CD [MAME `neogeocd.cpp` 926-978]. So it is a different 68000 map wrapped around the same chips, which is what the sockets have to allow. | # | Socket | Why the CD needs it | Source | | --- | --- | --- | --- | | CD1 | **68000 address decode by claimed ranges** (as megadrive-python's socket 3): a device may claim `$000000-$1FFFFF` (2 MiB program RAM, which also covers work RAM), `$800000-$803FFF` (8 KiB on-board "memory card"), `$C00000-$C7FFFF` (512 KiB system ROM), `$E00000-$EFFFFF` (the upload window), `$FF0000-$FF01FF` (CD, DMA and control registers) | the CD's map differs in every one of these | [MAME neogeocd 926-935] | | CD2 | **Writable video memories**: the sprite tile store (4 MiB), the fix store (128 KiB), reached through the same `sprite_row`/`fix_byte` interface as a cartridge but backed by RAM that the CD board writes through the upload window | tiles arrive by DMA or 68000 writes, and the video must see them at once | [MAME neogeocd 418-476, 853-854] | | CD3 | **Z80 memory**: 64 KiB of RAM in place of M1 + windows; no bank switching | MAME comments out the bank read [neogeocd 967] | | CD4 | **ADPCM memory**: 1 MiB RAM in place of the V ROMs, through `read_adpcm_a/b` | [MAME neogeocd 978] | | CD5 | **Interrupt map and acknowledge**: three **vectored** CD interrupts (vectors `$15-$17`) and the vblank and timer vectors swapped (MAME: vblank on level 1 answered with autovector 2, timer on level 3 answered with autovector 1; "timer = level 1, vblank = level 2" is [HYPOTHESIS: was wiki 68k interrupts]); the base board's `acknowledge(level)` and level map must be replaceable by the add-on | [MAME neogeocd 862-863, 940-944 (`cdc_irq_ack`), 1037-1063] | | CD6 | **Layer enables**: sprites off, fix off, video off (`$FF0111`, `$FF0115`, `$FF0119`) as inputs to the compositor | [HYPOTHESIS: was wiki NeoGeo CD registers] | | CD7 | **Bus master**: the CD's DMA engine takes the 68000's bus | MAME has a DMA engine [neogeocd 483+, `do_dma`]; that "while DMA is working the 68k has no access to the bus" is [HYPOTHESIS: was wiki DMA] | | CD8 | **Clock domains**: `catch_up(mclk)` devices after each 68000 step (the CD drive and its controller run on their own clocks), as megadrive-python's socket 5 | [HYPOTHESIS: was wiki CD drive] | | CD9 | **Audio sources**: CD-DA mixed with the YM2610, each source with its own rate and a labelled gain | [MAME neogeocd 16 (CD-DA)] | | CD10 | **Resets**: power-on, reset button, the 68000's RESET instruction, and a **Z80 reset line** the 68000 drives (`$FF0183`, which also resets the YM2610 in MAME) | [MAME neogeocd 373-382] | | CD11 | **`$380000` upper bits** read differently (always 0 on CD) and the memory card sense: the input read must be overridable per machine | [HYPOTHESIS: was wiki REG_STATUS_B] | Not needed by the CD: the cartridge slot (empty), slot select, backup RAM, calendar, coin hardware. ## The gate As in `megadrive-python`: with nothing in the add-on sockets the board must be byte-for-byte what it was when the base was tagged (MAME lockstep replays `0 unexplained`, the picture hashes of the smoke list, the sound streams), and the hooks must be `None`-checked off the hot paths: the sprite fetch and the 68000's ROM/RAM reads gain nothing when no CD device is attached. ## Order 1. Sockets 1-6 are part of milestone M1 (the board cannot run without them); CD1-CD11 are designed in M1 as Protocols with test-only fakes and audited by `neogeocd-python`'s own Phase 0 before the base is tagged, as the pcengine and Sega boards did. 2. `neogeocd-python` Phase 0 (the CD drive protocol, LC8951/LC89515, the DMA microcode, loading files, the CD system ROMs: only `neocdz.zip`'s CDZ ROM and CD Universe BIOSes are held locally, not the front- or top-loader ROMs: [census](../tests/census/census-2026-11-12.txt)).