# Sound: the VDP's PSG and the 315-5641 ADPCM chip, and a shared upd7759 core ## The PSG The Pico keeps the SN76489-style PSG inside the 315-5313A (PICODOC: "SN76489/SN76496 part of VDP if fully functional, though"; MAME 0.285 lists "Sega VDP PSG" on MCLK/15). It is the Mega Drive's PSG, reached through the VDP's port at $C00011. The family already has it: sn76489-python's `SEGA_VDP_PSG` variant, wired by megadrive-python. Nothing new. There is no FM chip. JSK: "the sound effects and music sound like they are being produced on a Master System. This is because the Pico doesn't have a Z80 CPU or YM2612". ## The 315-5641 What is known: | Fact | Evidence | | --- | --- | | The chip is marked 315-5641 (IC4 on the PAL VA0 board) | OBSERVED (JSK photograph) | | It is reached through $800010 (data FIFO) and $800012 (control) | DOC (PICODOC, ROM-RE); OBSERVED (games under MAME) | | A read of $800010 gives the FIFO's free bytes | DOC (PICODOC) | | The format "looks like it's some variant of 4bit ADPCM" | DOC (PICODOC, hedged) | | Control bits 2-0 pick a rate or type: 0 "8kHz 4bit ADPCM?", 1-7 "16kHz variants?"; bit 14 "enable playback?"; bit 15 of a read clear = busy | DOC (PICODOC, all with question marks) | | MAME 0.285 models it as "Sega 315-5641 PCM" at 1.28 MHz (Pico) and 640 kHz (Copera) | tier 5 (`-listxml`) | What NEC says of the uPD7759 (tier 2): - ADPCM speech synthesis at 5, 6 or 8 kHz sampling (DS7759 p.1, features); - a 640 kHz ceramic resonator (DS7759 p.3), 630-650 kHz allowed (p.6, electrical characteristics); - two modes: **stand-alone**, reading its own speech ROM, and **slave**, where a host feeds it bytes one at a time against /DRQ (DS7759 p.5, "Pin function for slave mode"; p.12, "Slave mode"); NEC's product description (D7759) and the uPD7755/56 user's manual (UM7756) cover the same family. Reading the two together (HYPOTHESIS, to be tested): the 315-5641 is a uPD7759-class decoder in slave mode with a byte FIFO in front of /DRQ, which turns the uPD7759's byte-by-byte handshake into "fill the FIFO, take an interrupt (level 3?) when it runs low". The "16 kHz variants" would follow from running the decoder at twice NEC's clock, as MAME's 1.28 MHz for the Pico (against 640 kHz for the Copera) would also suggest: 8 kHz at 640 kHz becomes 16 kHz at 1.28 MHz. Nothing read so far confirms that the 315-5641 contains a uPD7759 core at all; the name "D77591" sometimes attached to it was not found in any source read here and is not used. Unknowns: the FIFO's depth (MAME returned 59 free bytes, $3B, which says nothing about the hardware), when the level-3 interrupt fires, what the control bits mean, the decoder itself (U14, U15). ## The decoder: no document describes it The uPD7759's ADPCM step table and state machine are in none of NEC's documents read for system16-python (its U11) or here. The only full description known is MAME's `devices/sound/upd7759.cpp`, whose `license:` line says BSD-3-Clause (read 2026-11-26, header bytes only; it was not opened). system16-python's open decision 3 asks Aubrey whether that file may be read for facts with its notice kept (as pcenginecd-python did with MAME's BSD-3 `msm5205.cpp`). The Pico needs the same answer, and one decision should cover both boards. ## A shared core: `upd7759-python` The chip rule: a non-CPU chip stays in its board until a second family board needs it. system16-python (System 16B: a uPD7759 in slave mode, fed by the Z80 from an NMI handler) proposed keeping the chip in the board "behind a pin-shaped class; extract on a second family consumer". The Pico is that second consumer, if the 315-5641 is a uPD7759 inside. Proposal (open decision 3 in the brief): - One core repository, **`upd7759-python`** (package `upd7759_python`), owning the decoder and both modes: stand-alone (uPD7759 with an address bus; uPD7755/56 with mask ROM, as variants) and slave (/DRQ, /BUSY, /ST, /RESET, MD), stepped on its own clock. Interface: `write_data(byte)`, `drq`, `busy`, `reset(level)`, `start()`, and `samples(until_clock)`, with the clock rate a parameter so 640 kHz and 1.28 MHz are rows, not forks. - The **315-5641's FIFO and interrupt** stay in pico-python as a wrapper around the core until a source shows them on the same die (then they become a core variant). - The decoder's provenance follows decision 3 of system16-python; until it is decided the core's first rung can still be built and judged on everything NEC documents (pins, modes, handshake timing), with the decoder behind a named socket. - Users: system16-python (System 16B; its System 18 row uses an RF5C68 instead, by its sound.md), pico-python. Outside the family, MAME lists many arcade boards with a uPD7759 (not counted). Timing is generous: at 8 kHz (16 kHz on the Pico, if the hypothesis holds) a sample per 80 or 160 resonator clocks, a few thousand nibbles a second.