# Sockets: what the base board offers to the Jaguar CD, cartridges, peripherals and CoJag The family's pattern (`pcengine-python` 961e85c `docs/sockets.md`, `megadrive-python` `docs/expansion-sockets.md`, `segacd-python/docs/sockets.md`): the base console is one board with documented sockets; add-on hardware is a separate board that pins it by commit and copies nothing. For the Jaguar the add-on is the **Jaguar CD** (`jaguarcd-python`, not created in this phase). A second, different kind of consumer is **CoJag**, Atari Games' arcade board built on Tom and Jerry (below): it does not plug into a socket, it reuses the chips. Sources: **[TR10]** p.10-12, 29-30 (the console's port pinouts and audio routing, tier 2 with community edits); **[CDDOC]** *Jaguar CD-ROM* section of the 1995 developer binder (`jaguar/docs/dev/06 - Jaguar CD-ROM.pdf`, image-only, OCRed here into `reference/ocr/`, tier 2; a programmer's document about the CD BIOS, not a hardware description); **[TRM]** p.83, 90-96, 132; MAME `atari/jaguar.cpp` `jaguarcd_map`, Butch notes and CoJag maps (tier 5); MiSTer `rtl/jaguar.v` and `rtl/Butch/butch.v` (tier 4; Butch there is written anew, not from a netlist: no Butch netlist is public). ## The console's three connectors [TR10 p.10-12] - **Cartridge / expansion port**, 2 x 50 pins (the table in TR10 runs to row 54): the **full 24-bit address** `EA0-EA23`, **32-bit data** `ED0-ED31`, `ROM1` (the cartridge window's chip select), write enables `EWE0L`/`EWE2L`, output enables `EOE0L`/`EOE1L`, `ERW`, **`WAITL`** (a cartridge may stretch a bus cycle), `RESETL`/`RESET1L`, `ECPUCLK`, `PLL`, **`EINT0`/`EINT1`** (Jerry's external interrupts), **`GPIO0-GPIO4`**, `E2DATA` (the EEPROM's data out), **`SCK`, `WS`, `TXD`, `RXD`** (Jerry's synchronous serial port), `UART0`/`UART1`, `CART_IN`/`CART_OUT`, 9 V and 5 V. - **DSP port** at the back, 2 x 6 pins: `SCK`, `WS`, `TXD`, `RXD` (the same four I2S lines as the cartridge port: "care must be taken to avoid contention"), `UART_TXD`, `UART_RXD`. JagLink-style networking uses the UART; the Voice Modem plugs in here. - **Two controller ports** (DB15HD): the `JOYSTICK`/`JOYBUTS` matrix of [jerry.md](jerry.md). ## What the Jaguar CD needs from the base board The CD unit sits **on top of the console in the cartridge slot** and has its own cartridge slot (pass-through; the Memory Track save cartridge goes there). Facts gathered: | Need | Evidence | Socket | | --- | --- | --- | | A 256 KiB CD BIOS at `800000-83FFFF` instead of the cartridge | MAME `jaguarcd_map`; MiSTer `override = cdbios && cd_en` | cartridge slot: a device that **claims part of the window** and passes the rest through | | Butch registers at `DFFF00-DFFF3F` (interrupt status/enables, DSA command port to the drive, I2S control, subcode, I2S FIFO data, EEPROM at `$2C`) | MAME's Butch notes (tier 5) | same: a claim inside `ROM1`, decoded by the device from `EA` lines, with **writes** to cartridge space | | CD data and CD audio enter **through Jerry's I2S receiver**, the drive supplying bit clock and word strobe; software sets `SMODE` to `$14` (Jerry's clock tristated) for a DSP handler; the boot ROM leaves `SMODE` = `$15` | [CDDOC] p.7 ("set SMODE to $14 ... default of $15 by the Boot ROM"), `CD_jeri`; [TR10 p.29]; MiSTer wires Butch's `i2srxd`, `sck`, `ws` into Jerry | **I2S port**: the board's I2S unit can be clock master or slave; an external device drives `SCK`, `WS`, `RXD` | | An interrupt per CD block, about every 90 us at double speed, taken by the GPU as "interrupt 1" via Jerry's I2S interrupt; maximum tolerable latency about 54 us | [CDDOC] p.7 ("loads a piece of GPU interrupt code which handles interrupts redirected from Jerry's I2S interrupt") | no new line: Jerry's I2S interrupt -> `J_INT` -> GPU interrupt 1, all in the base ([interrupts.md](interrupts.md)) | | Butch's own interrupt to Jerry's external interrupt 0 | MiSTer `j_xeint[0] = b_eint`, `j_xeint[1]` tied high | **`EINT0`/`EINT1`** input lines | | Red Book audio: **no separate mix-in**: a DSP handler copies I2S input to the DACs ("To play Red Book audio you need a very simple interrupt handler that reads the incoming data from the CD and outputs it to the DACs") | [CDDOC] p.7 | none (the CD adds no audio source; the base's audio output is the only one) | | CD EEPROM behind Butch and the Memory Track flash in the pass-through slot | MAME (Butch `$2C`), MiSTer `eeprom_*` ports on Butch | inside the add-on; Memory Track is a `Cartridge` the CD unit holds | | Bus timing: Butch answers within a `ROM1` cycle; whether it uses `WAITL` is unknown | none read | cartridge accesses carry their clock and may **extend the cycle** | | Boot: the console's boot ROM recognises the CD BIOS cartridge and runs it; the CD boot ROM loads the disc's table of contents to `$2C00` and a boot program under 64 KiB | [CDDOC]; MAME runs `jaguarcd` with `jag_cd.bin` at `800000` | none beyond the cartridge slot | What the CD does **not** need: a second CPU (the drive's controller is not emulated by MAME or MiSTer: a command/response state machine on the DSA port), a bus-master socket (no source shows Butch mastering the bus; MiSTer's Butch has an `addr_ch3` output whose role was not read: **U17**), or a video socket. ## The sockets (proposed; each a narrow `typing.Protocol` with a test-only fake in M1) 1. **Cartridge slot**: `CartridgeSlot` holding a `Cartridge` with `claims() -> [(first, last)]` inside `800000-DFFFFF`, `read(address, width, clock)`, `write(address, value, width, clock)` (writes reach the cartridge: flash carts, Butch), and `wait_clocks(address, clock) -> int` for `WAITL`. The `$400` MEMCON byte and the start address at `$404` are read through `read` like any other access; nothing in the board parses headers except the `--skip-boot` loader. An **empty slot is a state** (the boot ROM's red screen comes from it, measured: [mame-oracle.md](mame-oracle.md)). A device may hold a second `Cartridge` and pass accesses through (the CD unit). 2. **Cartridge EEPROM lines**: the cartridge offers an optional `SerialEeprom` on three lines: chip select pulsed by any access to GPIO1, clock pulsed by any access to GPIO0 (data in from `ED0` on writes), data out read as `JOYSTICK` bit 0 ([eeprom.md](eeprom.md)). Modelled as decode strobes delivered to the cartridge, not as an EEPROM inside the board, because the part is on the cartridge and its size varies (U16). 3. **GPIO decodes**: `F14800-F17FFF`, six strobes with the address and data of the access, delivered to whatever is attached (the cartridge for GPIO0-4 per the pinout; nothing on GPIO5 in a console). CoJag uses GPIO2-5 for guns, switches and a latch (MAME `r3000_map`). 4. **Jerry's external interrupts**: `ExternalInterrupt.set(line, level)` for `EINT0`/`EINT1` (rising-edge sampled by `J_INT` source 0 and DSP interrupts 4/5). One bit per source, wired-OR. 5. **Synchronous serial (I2S) port**: the four lines `SCK`, `WS`, `TXD`, `RXD` as a `SerialPort` peer. With `SMODE` bit 0 set Jerry drives `SCK`/`WS` and peers listen; with it clear a peer drives them and Jerry's receiver and word-strobe interrupt follow the peer's clock. The console's audio DAC is the default listener on `TXD` ([jerry.md](jerry.md), U11). The CD unit, the DSP-port devices and the cartridge port all attach here; contention is the user's problem, as on hardware (log it). 6. **Asynchronous serial (UART)**: `TXD`/`RXD` at a baud derived from `ASICLK`, delivered as bytes with their clock: a second console (JagLink) or a modem. Not needed for any game to boot. 7. **Controller ports**: `ControllerPort.read(row_select) -> (j_bits, b_bits)` per port, for the standard pad, Team Tap (decoded rows, [jerry.md](jerry.md)), rotary controller, and later the light gun (it needs the `LPH`/`LPV` latch strobe from port 1's `B0`, a line into Tom's video counters) and analogue/bank-switching controllers. 8. **Audio out**: one stereo stream from the I2S transmitter (or the PWM DACs if U11 resolves the other way), with its sample clock; the CD adds nothing to it (above). 9. **External bus master**: the arbiter's level 10 (`brlin`, a daisy-chained request, [bus-arbitration.md](bus-arbitration.md)). Offered as a socket only on paper: no device that uses it is known. Not built until one is. 10. **Reset**: `reset(kind, clock)`, kinds `POWER_ON` and `BUTTON` (the console has no reset button; the CD unit's own reset is a register inside the add-on). `RESETL`/`RESET1L` on the cartridge port are outputs of the console. 11. **Straps**: a `Straps` record read at reset: `ROMHI`, `ROMWIDTH`, `NOCPU` (`MA4`: also the GPU lock, [memory-map.md](memory-map.md) U1), `CPU32`, `BIGEND`, and `JOYBUTS` bit 4 (NTSC = 1). CoJag and a PAL console are different straps, not different code. The base board's gate is defined **before** any add-on: lockstep traces and the smoke list are recorded with an empty cartridge slot or a plain ROM cartridge, and attaching a fake device that claims nothing must leave them byte-for-byte unchanged. ## The 16 MiB aftermarket image *The Snowman* (No-Intro aftermarket set) is 16 MiB, larger than the 6 MiB window. No banking register is documented anywhere read in this phase; how its cartridge maps the extra space was not determined (**U18**). It is a `Cartridge` with its own claims and write-triggered banking once the scheme is known; the base board needs nothing beyond socket 1's writes. ## CoJag: a consumer of the chips, not of the board MAME's `atari/jaguar.cpp` (tier 5) runs CoJag games (*Area 51*, *Maximum Force*, *Vicious Circle*, *Fishin' Frenzy*, *Freeze*, ...) with an R3041 (`R3000_CLOCK` 40 MHz crystal) or a 68EC020 (`M68K_CLOCK` 50 MHz), Tom and Jerry at 26 MHz from `COJAG_CLOCK` 52 MHz, a 14.31818 MHz oscillator near Jerry (board-layout comment), IDE, EEPROM and a watchdog; the chips sit at `04F00000` on the R3041 board and at `F00000` on the 68020 board. MAME rates these games "good" where it rates the console "preliminary". Consequences for this board, all cheap now and expensive later: - **Tom and Jerry must not assume a 68000 or the console's memory map**: their classes take the host interface (16- or 32-bit bus, `CPU32` strap, address base) as constructor arguments, and hold no module-level state, so a later `cojag-python` instantiates them. - They stay **inside this repository** (`jaguar_python.tom`, `jaguar_python.jerry`) until such a board exists (chip rule: extract on the second consumer); then they move to a shared package by an open decision, not before. - The 68000 is the console's choice and enters only through `jaguar_python.console`. - CoJag has no cartridge, so sockets 1-2 are console-only; sockets 3-5 and 7 are what a CoJag board would wire differently (guns on GPIO2, IDE on an external interrupt, MAME `external_int`). The jrisc core's census found that *Fishin' Frenzy* and *Freeze* need no CHD: the cheapest second program corpus for both repositories when the time comes.