From 4bcf3ab8233d44ee12d95a9328bec67fc74e1902 Mon Sep 17 00:00:00 2001 From: Benjamin Haisch Date: Fri, 25 Apr 2008 11:02:37 +0000 Subject: (Poissbly) fixed sound glitches due to a non-implemented decoding variant. svn-id: r31716 --- engines/made/sound.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'engines') diff --git a/engines/made/sound.cpp b/engines/made/sound.cpp index 3cb2ea69fd..27cf516b11 100644 --- a/engines/made/sound.cpp +++ b/engines/made/sound.cpp @@ -34,7 +34,7 @@ void decompressSound(byte *source, byte *dest, uint16 chunkSize, uint16 chunkCou int16 prevSample = 0, workSample = 0; byte soundBuffer[1025]; - byte soundBuffer3[1024]; + byte deltaSoundBuffer[1024]; int16 soundBuffer2[16]; byte deltaType, type; uint16 workChunkSize, byteCount, bitCount; @@ -106,17 +106,24 @@ void decompressSound(byte *source, byte *dest, uint16 chunkSize, uint16 chunkCou } - if (deltaType == 1) { - for (i = 0; i < chunkSize - 1; i += 2) { - l = i / 2; - soundBuffer3[i] = soundBuffer[l]; - soundBuffer3[i + 1] = (soundBuffer[l + 1] + soundBuffer[l]) / 2; - } - for (i = 0; i < chunkSize; i++) { - soundBuffer[i] = soundBuffer3[i]; + if (deltaType > 0) { + if (deltaType == 1) { + for (i = 0; i < chunkSize - 1; i += 2) { + l = i / 2; + deltaSoundBuffer[i] = soundBuffer[l]; + deltaSoundBuffer[i + 1] = (soundBuffer[l] + soundBuffer[l + 1]) / 2; + } + } else if (deltaType == 2) { + for (i = 0; i < chunkSize - 1; i += 4) { + l = i / 4; + deltaSoundBuffer[i] = soundBuffer[l]; + deltaSoundBuffer[i + 2] = (soundBuffer[l] + soundBuffer[l + 1]) / 2; + deltaSoundBuffer[i + 1] = (deltaSoundBuffer[i + 2] + soundBuffer[l]) / 2; + deltaSoundBuffer[i + 3] = (deltaSoundBuffer[i + 2] + soundBuffer[l + 1]) / 2; + } } - } else if (deltaType == 2) { - debug(2, "****************************************"); + for (i = 0; i < chunkSize; i++) + soundBuffer[i] = deltaSoundBuffer[i]; } prevSample = workSample; -- cgit v1.2.3