From 3a6e75ca7d5728a8f88b987d77dabd511e135211 Mon Sep 17 00:00:00 2001 From: MetalliC <0vetal0@gmail.com> Date: Fri, 19 Aug 2016 18:49:11 +0300 Subject: [PATCH] aica: add ADPCM diff value clamp based on encoder research [kode54, MetalliC] if there is known issues with YMZ280B it might be worth try to same decoder there --- src/devices/sound/aica.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/devices/sound/aica.cpp b/src/devices/sound/aica.cpp index 4e1b4d5fd40..99fa33a4ea4 100644 --- a/src/devices/sound/aica.cpp +++ b/src/devices/sound/aica.cpp @@ -351,8 +351,14 @@ void aica_device::InitADPCM(int *PrevSignal, int *PrevQuant) signed short aica_device::DecodeADPCM(int *PrevSignal, unsigned char Delta, int *PrevQuant) { + int x = (*PrevQuant * quant_mul[Delta & 7]) / 8; + if (x > 0x7FFF) x = 0x7FFF; + if (Delta & 8) x = -x; + x += *PrevSignal; +#if 0 // older implementation int x = *PrevQuant * quant_mul [Delta & 15]; x = *PrevSignal + ((int)(x + ((UINT32)x >> 29)) >> 3); +#endif *PrevSignal=ICLIP16(x); *PrevQuant=(*PrevQuant*TableQuant[Delta&7])>>ADPCMSHIFT; *PrevQuant=(*PrevQuant<0x7f)?0x7f:((*PrevQuant>0x6000)?0x6000:*PrevQuant);