From f7465887710430dca424817bd54dc6df71c5d02c Mon Sep 17 00:00:00 2001 From: Lord-Nightmare Date: Thu, 4 Apr 2019 06:44:43 -0400 Subject: Fix 12-bit wrapping behavior in YM2608/2610 ADPCM_A decoding, fixes some glitches in certain samples in the metal slug series, and likely other games. [Lord Nightmare, madbr] --- src/devices/sound/fm.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/devices/sound/fm.cpp b/src/devices/sound/fm.cpp index 8f679e99357..23ea6633674 100644 --- a/src/devices/sound/fm.cpp +++ b/src/devices/sound/fm.cpp @@ -2499,11 +2499,12 @@ struct ym2610_state ch->adpcm_acc += jedi_table[ch->adpcm_step + data]; + /* the 12-bit accumulator wraps on the ym2610 and ym2608 (like the msm5205), it does not saturate (like the msm5218) */ + ch->adpcm_acc &= 0xfff; + /* extend 12-bit signed int */ - if (ch->adpcm_acc & ~0x7ff) + if (ch->adpcm_acc & 0x800) ch->adpcm_acc |= ~0xfff; - else - ch->adpcm_acc &= 0xfff; ch->adpcm_step += step_inc[data & 7]; Limit( ch->adpcm_step, 48*16, 0*16 ); -- cgit v1.2.3