# The CD block: an SH-1 with its own firmware Sources: the Saturn Overview Manual (OVW 2.3, 3.6, tables 2.2, 3.1, 3.10-3.11), the CD Communication Interface part of the System Library User's Manual (ST-162, cited CDCI), the SH7032/SH7034 Hardware Manual (SH1HM), and MAME 0.285's device list and romsets (OBSERVED: run, never read). ## What it is - A separate subsystem on the A-bus's CS2 (DOC: CMH note 2; OVW fig. 2.1): an SH-1 CPU, a 64 KB ROM holding "the CPU CD BIOS", 512 KB of RAM used as the CD buffer, MPEG work RAM and the C3 error-correction cache, a 2x CD-ROM drive, and the optional MPEG card (DOC: OVW 2.3, table 2.2). The SH-1 "manages mechanical control, error correction (C3), and CD file management" (DOC: OVW 2.3). - Clock: OVW says the SH-1 runs at 20 MHz (table 2.2 and table 3.1); MAME 0.285 runs it as an "SH-1 (SH7032) @ 16.00 MHz" (OBSERVED). Conflict C3. - Which SH-1: the SH7034 has the 64 KB ROM on chip and 4 KB RAM; the SH7032 is the ROMless part with 8 KB RAM (DOC: SH1HM 1.1, table 1.1 note 1). OVW draws the 64 KB ROM as its own box beside the SH-1, which fits an SH7032 with an external ROM; MAME names the SH7032 and loads a 64 KB image into the CPU's region. Conflict C5: the two parts differ in on-chip RAM size and in where the ROM decodes, so a low-level CD block must know which. - Firmware images known (all three in every MAME Saturn set, SHA-1s in [census.md](census.md)): "Saturn CD Block 1.05", "1.06" (MAME's default) and "YGR022 315-5962". So the gate array has at least two generations, each with its own firmware: YGR022 by MAME's set description; YGR019 is the commonly given name of the first (a web search summary attributes it to a comment in MAME's driver source, which was not opened here). ## The host interface (documented) CDCI describes everything the main CPU can see, in Sega's words: - Command/response through registers (the CR words and the interrupt factor and mask registers HIRQREQ/HIRQMSK; CDCI 3.x), with flags such as CSCT (one sector stored), the command-end flag and its list of commands, and the data-transfer register through which sectors move by software, SH-2 DMA or SCU DMA. - **Periodic response**: without a command, the block reports status and the "CD report" every 13.3 ms at single speed, 6.7 ms at double speed, 16.7 ms when not playing (CDCI 3.3), the same timing as the SCDQ subcode flag. - A 200-sector buffer (about 460 KB), 24 selectors made of filters and buffer partitions that route sectors by subheader and frame address, a 23-pack subcode R-W buffer, ISO9660 directory functions inside the block, XA and multi-session, single or double speed (CDCI 1.3, ch. 4-5). What CDCI does not give: command execution times, seek and spin-up times, the exact order of HIRQ bits as a command proceeds, error behaviour, and the register addresses as physical addresses (CDCI is a C library manual; CMH places the registers in CS2, mirrored every 64 bytes). These are the timings games are sensitive to (U17). ## What is not documented at all The SH-1's own map, the YGR019/YGR022 gate array's registers (sector descrambling, subcode, the host FIFO), the serial protocol to the drive's mechanism controller, and the drive's own timing. No Sega or community document in this phase covers them; the public knowledge lives in emulators that are GPL (Ymir has a low-level mode: "CD Block LLE", libretro docs, which runs the SH-1 at 20 MHz and costs it 15-20% speed by its release notes) or unlicensed (the MiSTer core). Both are closed boxes for us. ## The choice: a high-level block, an SH-1 core, or both | | High-level (functional) | Low-level (SH-1 runs the real firmware) | | --- | --- | --- | | Evidence for its behaviour | CDCI (Sega, tier 2) for every command; timings from detectors only | the firmware itself (the behaviour is in the ROM), plus the undocumented gate array and drive | | What we would have to invent | every timing: command latency, seek, buffer fill rate; tagged FITTED/HYPOTHESIS | the YGR registers and the drive protocol, which are undocumented; learned only by watching the firmware run (allowed: it is a black box we execute, not code we copy) | | Licence and BYO | nothing to supply | the player supplies the CD block ROM, like the boot ROM (it is in every MAME set) | | Cost | small: a state machine and a sector source | an SH-1 at 16-20 MHz: about 10 M instructions a second more ([domains-and-speed.md](domains-and-speed.md)) | | New core | none | `sh1-python` ([cpu-cores.md](cpu-cores.md)) | | Modelling level (charter B) | functional | instruction (SH-1) + transaction (gate array) | The charter says a functional model is judged against a lower-level run where one exists (as the Super Game Boy's program is judged against snes-python). That argues for having both in the end: the high-level block as the fast path and the default for hosts, the low-level one as its judge. But the low-level path's blocker is knowledge, not code: the gate array and the drive protocol would have to be reconstructed by observation from scratch, which is a project of its own. **Recommendation (open decision 3):** build the high-level block first, from CDCI, with every timing marked and kept in one table; keep the `CdBlockPort` socket at the A-bus CS2 register level so a low-level block can plug in later without touching the base board. Defer `sh1-python` until the board boots games; then decide on evidence (how many games fail for CD timing reasons the high-level model cannot fix). The SH-1 core itself is cheap for the family (it is the SH-2's instruction set minus nine instructions, see cpu-cores.md); the gate array is the expensive part. ## The MPEG card Video CD playback; Sega, Victor and Hitachi made versions with a mask ROM (Sega MPR-17896-H), Hitachi MPEG audio and video decoders and 2 x 256K x 16 DRAM (DOC: CMH "MPEG card"). Its ROM is not dumped as far as CMH or this phase found. Out of scope until the base board plays games; listed as a socket.