Expand description
The ADPCM unit: 64 KiB of RAM, its pointers, the MSM5205 decoder and the audio source
(adpcm.py).
Tiers (the base board’s docs/validation.md): [hw: pcetech 8] MacDonald, tier 2, names the
registers and a few bit meanings and says the rest is “currently trying to document”; [mfr:
Hudson BIOS manual and System Card ROM] tier 3, the BIOS source (AD_STAT, AD_PLAY,
ad_*_addr_set in Super CD-ROM2 System V3.00 (J).ASM) shows how the registers are driven;
[emu] Mesen2 PceAdpcm.cpp, Geargrafx adpcm*.cpp, Mednafen pcecd.cpp and MAME
pce_cd.cpp are tier 5 detectors: where a behaviour comes only from them it is a field of
AdpcmSwitches (a named switch) with a U/C entry in the reference’s docs/m8-record.md.
Registers (offsets from $1800):
| reg | write | read |
|---|---|---|
$08/$09 | the 16-bit address latch (low / high) | ($08 reads the CD data bus: the unit) |
$0A | the byte for the write pointer, which then steps | the read buffer; next fetch starts |
$0B | DMA control (bit 1 requests CD-to-ADPCM DMA; bit 0 follows a waiting block) | the same |
$0C | – | bit 7 read busy, bit 3 playing, bit 2 write busy, bit 0 end reached |
$0D | control (below) | the last value written |
$0E | rate: playback at 32 / (16 - n) kHz, n = value & $0F | the same |
Control $0D: bit 7 reset (pointers and length to zero, flags cleared, the read buffer is
kept), bit 6 stop at length zero (clear: keep playing), bit 5 play, bit 4 latch the length
from the address latch (a length of zero then means 64 KiB), bit 3 copy the latch to the read
pointer on a rising edge (bit 2 set: as it is; clear: one less, so the first read fetch lands
on it), bit 1 the same for the write pointer (bit 0). [hw: pcetech 8; mfr: the BIOS routines
ad_read_addr_set, ad_write_addr_set, ad_length_set]
Flags: the half flag (IRQ2 source $04, $1803 bit 2) is set while less than half of the
length is left and the end flag (source $08, $180C bit 0) when the length has run out.
[hw: pcetech 8 $1803 bit 2; mfr: AD_STAT reads $180C bit 0 then $1803 bit 2, and
$180C bit 3 for busy]
Decoder (MSM5205, 4-bit): a 12-bit signal and a step index 0-48. A nibble is a sign bit and
three magnitude bits; the signal moves by step/8 + step/4*b0 + step/2*b1 + step*b2 (integer
divisions of step = floor(16 * 1.1 ** index)), the index by -1 -1 -1 -1 +2 +4 +6 +8 clamped
to 0..48. Each byte holds two samples, the high nibble first. The audio is the signal held
between samples (the AudioSource below).
Differences forced by Rust:
Adpcmis its own audio source: the reference’sAdpcmSource(an object that holds the unit) is theorigin,takenandheldfields and theAudioSourceimpl here; the fader it asks the audio player for is the sharedFader(cdda.rs). The reference’s source first catches the unit up to the mixer’s clock; the board has always done that already (it runs the port device at every advance), and this source cannot reach the unit.on_irq(the reference’s callback into the unit) is the listirq_changes, applied by the unit after each call.- The step table is the 49 integers
floor(16 * 1.1 ** index)written out, so that it does not depend on a platform’spow(wasm).
Structs§
- Adpcm
- RAM, pointers, flags and the decoder. Time comes from the unit (
run(mclk)and thenowof each register access); the unit callsrunfor every event fromnext_event. - Adpcm
Switches - Switches: behaviours only tier 5 gives, or undecidable between sources (the reference’s
docs/m8-record.md; its
Adpcmclass attributes, with its defaults).
Constants§
- ADPCM_
RAM_ BYTES - DELTA
DELTA[index * 8 + magnitude], the signal change for a 3-bit magnitude [MSM5205 data sheet as modelled by MAMEmsm5205.cpp, Mednafenokiadpcm.cpp, Geargrafx: tier 3/5].- INDEX_
STEP - IRQ_END
- IRQ_
HALF - LENGTH_
MASK - [emu: Mesen2, Geargrafx] 17 bits: a length of 64 KiB needs the 17th
- OUTPUT_
HZ - STEPS
floor(16 * 1.1 ** index)for index 0..48.