-
Notifications
You must be signed in to change notification settings - Fork 0
Sound
The SM8521's sound generator has three channels plus a direct DAC. Sound is the machine's weakest-documented subsystem and the hardest to get exactly right — even mature reference emulators flag their Game.com audio as imperfect.
-
SG0 / SG1 — wavetable. Each plays a 32-step, 4-bit waveform (16 bytes of register space)
at a rate set by a 12-bit period; the tone frequency is
2,764,800 / period / 32Hz. Each channel has a 5-bit output level. These produce the beeps, blips, and chiptune-style melodies. - SG2 — noise. A high-rate "almost periodic" noise channel clocked by a time-constant register. Long left unimplemented everywhere — MAME and the other emulators leave it silent. Tigerbyte generates it (an LFSR-based "false noise"), so noise sound effects play; the exact tap configuration is being refined against hardware, but it's the one channel that sets us apart from the prior emulation.
- SGDA — 8-bit DAC. A direct write-the-sample output. Most games use this for streamed music and speech (ADPCM decoded at 8 kHz), with the other channels stopped. The boot sound plays through here.
A master enable plus per-channel enables (SGC) gate everything.
The hard part isn't generating the waveforms — it's timing the DAC. On real hardware the DAC's playback rate is driven by the Timer 1 interrupt, which is the same timer that drives the kernel's game logic. Speed that interrupt up to make the audio pitch correct and you break game timing; slow it down for correct game timing and the audio becomes unintelligible. There is no documented way the real machine keeps both happy, and no public per-instruction cycle data to calibrate against — so DAC pitch accuracy is fundamentally an open problem, not just a missing feature.
All four sources are generated — both wavetable channels, the streaming DAC, and the SG2 noise channel that no other emulator implements — mixed to stereo and delivered through the libretro audio callback. The DAC and wavetable are correctly made mutually exclusive (the hardware's channel gating), and the wavetable pitch uses the hardware-correct clock rather than the value MAME derives from its wrong crystal.
The remaining work is the DAC's timing fidelity, and it's measured against a clean recording of the real console's boot jingle — captured, then compared band-by-band against Tigerbyte's output. That spectral comparison (not another emulator's output) is what tells us how close we are, and it ties directly into the cycle-accuracy work in Interrupts & Timers — the DAC rate is Timer-1-driven, so the audio gets exact when the timing does.
Tigerbyte
Hardware
Development