# Sound: YM2151 (OPM) and MSM6258 (ADPCM) Aubrey's rule applies: sound may be less exact than pictures ("Sound: good enough"), and the board takes both chips at the level their sources support. ## YM2151: the pinned core `../ym2151-python` is the family's OPM core-to-be: **still Phase 0 (restarted 2026-11-19), with a specification and no core yet** (its README and phase0-status.md, read 2026-11-26 at `3207328`); its referee is Nuked-OPM, run as a closed box from emu-tools-gpl; its first consumer is cps1-python. The X68000 board's sound milestone waits for that core, and nothing earlier needs it (a stub register file with /IRQ held high and CT2/CT1 as plain latches carries the board to the IPL screen and floppy boot). Its `docs/users.md` already lists the X68000: four MAME machines at **4 MHz** (`sharp/x68k.cpp`), /IRQ to the MFP's input I3, and the CT outputs: **bit 7 (CT2) selects the ADPCM's clock, bit 6 (CT1) is the floppy's ready line**. So the board needs from the core: any input clock (the core counts input clocks and "never assumes a rate", users.md), /IRQ as a live line, and the CT outputs readable whenever they change; users.md says all three are planned. At 4 MHz the OPM produces a sample every 64 clocks, 62.5 kHz (the YM2151's clock/64 rate: ym2151-python's docs; arithmetic for this clock). Registers at E90001 (address) and E90003 (data) (HYPOTHESIS; not touched in the IPL's first 60 frames). ## MSM6258: in the board **The chip (DOC: ADPCM, the MSM6258/6258V data sheet in OKI's 1987 voice synthesis LSI data book, printed pp. 110-125):** a CMOS ADPCM speech processor whose "ADPCM analysis and synthesis block is identical to the popular OKI MSM5218", with a built-in 8-bit ADC and 10-bit DAC (external converters of up to 12 bits possible); it "accepts 4 to 8MHz master clocks", with sampling frequencies fosc/1024, fosc/768 and fosc/512 (4.0, 5.3 and 8.0 kHz at 4.096 MHz) selected by SAM1/SAM2; 3 or 4 bits per sample (pin-selected); an MPU-interface version (MSM6258V) with CS, RD, WR and D/C (D/C high: ADPCM data; low: command or status) and an MCK output at fsample/2 for synchronising the CPU. **On the X68000** (HYPOTHESIS unless marked): - At E92000: command and status E92001, data E92003. DMAC channel 3's device address is E92003 (OBSERVED: dmac.md), so the ADPCM's data is fed by DMA, one byte (two 4-bit samples) per request. - The master clock is 4 MHz or 8 MHz, chosen by the YM2151's CT2 (users.md: the cited MAME lines); MAME runs it at 4.00 MHz (OBSERVED). The divider (1024, 768 or 512) comes from 8255 port C bits 2-3, and the left/right output enables from port C bits 0-1 (active low). The IPL writes port C = 0B (OBSERVED): bits 0-1 = 11 (both outputs off), bits 2-3 = 10. With 8 MHz and /512 the rate is **15.625 kHz**, the X68000's best-known ADPCM rate; with 4 MHz and /1024, 3.9 kHz (arithmetic). - 4 bits per sample (HYPOTHESIS). - The MPU version's command register bits (play, record, stop) are not in the data book's text layer (U21: read the page images, or another edition of the data sheet). **Reuse and the chip rule.** The ADPCM algorithm (the MSM5218/MSM5205 step table and index adjustments) is already in two family places: pcenginecd-python's MSM5205 unit (`adpcm.py`, from MAME's BSD-3-Clause `msm5205.cpp` with its notice) and msm6295-python's decoder (a different OKI chip with the same ADPCM family; its `docs/decoder.md`). The MSM6258 as a chip (MPU interface, DMA-fed, CT2 clock switch, PPI-set rate) is used by one family machine, the X68000 (and in MAME by a few arcade boards: not counted here), so **it stays in the board**. Whether the shared ADPCM decode step becomes a tiny shared core is open decision 6; the recommendation is no: the step is a dozen lines and the chips differ in everything around it. ## Mixing The OPM's two channels and the ADPCM's two gated outputs are mixed to stereo by analogue circuitry whose levels and filters are unknown (U22: HYPOTHESIS, FITTED by ear against detectors; the "good enough" rule).