all repos — mgba @ 5a0e4e7a2d23cb5736b792c4e985ac950ca5587d

mGBA Game Boy Advance Emulator

GBA Audio: Fix integer overflow sampling of channel 3
Jeffrey Pfau jeffrey@endrift.com
Sun, 23 Nov 2014 00:23:37 -0800
commit

5a0e4e7a2d23cb5736b792c4e985ac950ca5587d

parent

ebe543e482699a068d34f53466aec433fa8ba1fc

1 files changed, 3 insertions(+), 3 deletions(-)

jump to
M src/gba/gba-audio.csrc/gba/gba-audio.c

@@ -655,9 +655,9 @@ ch->wavedata[i] = ((ch->wavedata[i] & 0xF0F0F0F0) >> 4) | ((ch->wavedata[i] & 0x000F0F0F) << 12);

ch->wavedata[i] |= bitsCarry >> 20; bitsCarry = bits; } - ch->sample = (bitsCarry >> 20); - ch->sample >>= 2; - ch->sample *= volume; + ch->sample = bitsCarry >> 24; + ch->sample -= 8; + ch->sample *= volume * 4; return 8 * (2048 - ch->control.rate); }