fixes AFC type 5 decoding

(At least for Super Mario Sunshine, from whose ucode it was derived - hopefully this won't break other games.)

Fixes Issue 4437.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7504 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
chiizufish 2011-05-02 15:23:27 +00:00
parent d27753796e
commit 263fc19d6f
1 changed files with 5 additions and 8 deletions

View File

@ -47,10 +47,10 @@ void CUCode_Zelda::AFCdecodebuffer(const s16 *coef, const char *src, signed shor
// In Super Mario Sunshine, you can get such a sound by talking to/jumping on anyone // In Super Mario Sunshine, you can get such a sound by talking to/jumping on anyone
for (int i = 0; i < 16; i += 4) for (int i = 0; i < 16; i += 4)
{ {
nibbles[i + 0] = (*src >> 6) & 0x02; nibbles[i + 0] = (*src >> 6) & 0x03;
nibbles[i + 1] = (*src >> 4) & 0x02; nibbles[i + 1] = (*src >> 4) & 0x03;
nibbles[i + 2] = (*src >> 2) & 0x02; nibbles[i + 2] = (*src >> 2) & 0x03;
nibbles[i + 3] = (*src >> 0) & 0x02; nibbles[i + 3] = (*src >> 0) & 0x03;
src++; src++;
} }
@ -67,10 +67,7 @@ void CUCode_Zelda::AFCdecodebuffer(const s16 *coef, const char *src, signed shor
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
{ {
int sample = delta * nibbles[i] + ((int)hist * coef[idx * 2]) + ((int)hist2 * coef[idx * 2 + 1]); int sample = delta * nibbles[i] + ((int)hist * coef[idx * 2]) + ((int)hist2 * coef[idx * 2 + 1]);
if (type == 9)
sample >>= 11; sample >>= 11;
else
sample >>= 13;
if (sample > 32767) if (sample > 32767)
sample = 32767; sample = 32767;
if (sample < -32768) if (sample < -32768)