# Sound: the Z80, the YM2151, the uPD7759 (16B) and the uPD7751 (16A) DOC from CMSND (16B) and CMP16 "Sound hardware" (Pre-16/16A) unless tagged. ## System 16B **Parts**: Z80-B, YM2151 @ 4 MHz (8 MHz / 2), uPD7759 on a 640 kHz resonator; 2 KB Z80 work RAM, 32 KB program ROM, up to 1 MB of sample ROM in 16 KB banks. The Z80's clock source was not traced (MAME: 5 MHz; U1). **Decode** (the 315-5214, a Signetics CK2605 PLA): memory 0000-7FFF program ROM, 8000-BFFF sample ROM bank, C000-FFFF work RAM (2 KB mirrored; games use F800-FFFF). I/O (A7, A6): 00-3F YM2151; 40-7F write = uPD7759 data, read D7 = uPD7759 /BUSY (D6-D0 undefined); 80-BF write = sound control latch; C0-FF read = the sound command latch. The PLA enables devices for reads and writes alike (a ROM write would fight the bus; no game does it). **Sound control latch**: D7 uPD7759 mode (inverted: drives /MD and gates the Z80's /WR and data bus to the chip), D6 uPD7759 /RESET, D5-D0 sample ROM bank lines to the ROM board (per-board meaning in [memory-map.md](memory-map.md)). The latch is cleared by D7 of the 68000's miscellaneous output latch, which /RESET clears. **uPD7759 in slave mode** (every known game): the uPD7759's /DRQ is wired to the Z80's **/NMI**; the Z80 answers each request by writing one ADPCM byte to port 0x40 from a short NMI handler (`exx / ld b,(hl) / out (c),b / inc hl / exx / retn`, HL in the bank window). The message inputs I0-I7 are grounded, /ST pulled up, the address bus unconnected: stand-alone mode cannot work on this board. The data sheet's slave-mode timing: speech data set-up 2-7.5 us to /DRQ falling, hold 1.25 us after /DRQ rising; MD input 200 us after RESET rises (DS7759 AC characteristics, "2.2 Slave mode"). So the board's sample stream is a Z80-timed handshake: the Z80's NMI latency decides whether a byte arrives in time, and the specification must run the chip and the Z80 against one clock. **Sound command**: a 68000 write to mapper register 0x07 latches the byte and strobes the Z80's /INT (CMSND; CM16B ยง2 says NMI: C3); the Z80's handler reads port 0xC0, which pulses the 315-5195 to drive the byte. Whether that read clears /INT is unknown (U10). The 8751 can also send sound commands through the 315-5195. **The YM2151's /IRQ is not connected** on 16B: drivers poll the timer flags (CMSND "Miscellaneous"). The MB3771 power monitor's /RESET goes to the YM2151 and the Z80. **The output stage**: MAME models the 16B mixer and filters as a netlist (`nl_segas16b.cpp`, **CC0-1.0** by its `license:` line, Couriersud): a candidate for the board's analog stage under the "sound: good enough" rule once its facts are traced to the schematic it was drawn from (open decision 3). ## Pre-System 16 and 16A **Parts**: Z80 @ 4 MHz, YM2151 @ 4 MHz (YM3012 DAC), an **N7751** (NEC uPD7751, an 8048-class part with a 1 KB mask ROM: CMP16 "(8048 clone)"; MAME runs `7751.bin` as an MCS-48 program with an Intel 8243 expander) driving a signed 8-bit DAC. **Z80 map**: 0000-7FFF program ROM, F800-FFFF work RAM. I/O: 00-3F YM2151 (CMP16 gives even = data, odd = register select), 80-BF the N7751 control latch (write), C0-FF the 8255's port A (reading strobes the PPI's /ACK); JT16 adds PC7 /OBF -> the Z80's /NMI. **N7751 control latch**: D7-D5 the sample number S2-S0 (read by the 7751 on P2.6-P2.4), D4-D1 the four sample ROMs' active-low chip selects (two at once: bus fight), D0 sample ROM A14. **N7751 wiring**: /RST from the YM2151's CT2 pin (pin 9), /INT from CT1 (pin 8), T0 and T1 grounded, BUS = the sample ROM data, P4-P7 (through the 8243 on P2.3-P2.0) = sample ROM A13-A0, P1 = the DAC. The Z80 resets the 7751 by pulsing bit 6 of YM2151 register 0x1B and starts a sample by pulsing **bit 7**, which reaches pin 8 (/INT). MacDonald found this "reversed from some documentation"; ym2151-python's timers-and-bus.md records the same split: Yamaha's manual maps D6 to CT1, while IKAOPM's die trace has **bit 7 driving pin 8**. Body Slam on a real board agrees with the die (a corner for ym2151-python, raised in its favour; handoff brief). ## Users of each chip (the chip rule) | Chip | Users in the family today | Where it lives | | --- | --- | --- | | Z80 | many | z80-python (pinned core) | | YM2151 | cps1-python (Phase 0), this board; MAME has 2,322 YM2151 machines (ym2151-python users.md) | ym2151-python (Phase 0; this board is its second named consumer) | | uPD7759 | this board only (other arcade boards use it; none is in the family yet, not counted here) | **in the board**, behind a pin-shaped class; extract on a second family consumer | | uPD7751 | this board (16A) | **mcs48-python** as the CPU (the rule: CPUs get a core), the speech wiring in the board | | 8243 expander | this board (16A); MCS-48 systems | in the board (mcs48-python's ports P4-P7 are the 8243 protocol on P2: its README) | | 8255 PPI | this board (16A), Out Run | in the board | | YM3438, RF5C68, 315-5313 PSG | System 18 row | ym2612-python, segacd-python's PCM (in-board there), sn76489-python ([system18-outrun.md](system18-outrun.md)) | ## What no document gives The **uPD7759's ADPCM decoding and data stream** (the step table, the state machine, the silence/repeat commands): NEC's documents give pins, modes and timing only; the 5-byte header (the sample count, then 0x5A 0xA5 0x69 0x55) is stated by jotego's jt7759 README, and MAME's BSD-3 `upd7759.cpp` holds the only full description known (U11, open decision 3).