From 8a0c5b9a1fe04eb027fc8a1d5120044885834d59 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 29 Jun 2015 01:08:14 -0700 Subject: [PATCH] GBA Audio: Fix sample order in audio channel 3 --- CHANGES | 1 + src/gba/audio.c | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 74697337c..ad9b36312 100644 --- a/CHANGES +++ b/CHANGES @@ -50,6 +50,7 @@ Bugfixes: - GBA Memory: Fix load/store multiple video memory waitstates - GBA: Fix timing of reading from timer registers - Util: Allow loading IPS patches that grow the ROM + - GBA Audio: Fix sample order in audio channel 3 Misc: - Qt: Handle saving input settings better - Debugger: Free watchpoints in addition to breakpoints diff --git a/src/gba/audio.c b/src/gba/audio.c index 652ebc2f0..2fe4ff8f6 100644 --- a/src/gba/audio.c +++ b/src/gba/audio.c @@ -704,15 +704,15 @@ static int32_t _updateChannel3(struct GBAAudioChannel3* ch) { start = 3; end = 0; } - uint32_t bitsCarry = ch->wavedata[end] & 0x0F000000; + uint32_t bitsCarry = ch->wavedata[end] & 0x000000F0; uint32_t bits; for (i = start; i >= end; --i) { - bits = ch->wavedata[i] & 0x0F000000; - ch->wavedata[i] = ((ch->wavedata[i] & 0xF0F0F0F0) >> 4) | ((ch->wavedata[i] & 0x000F0F0F) << 12); - ch->wavedata[i] |= bitsCarry >> 20; + bits = ch->wavedata[i] & 0x000000F0; + ch->wavedata[i] = ((ch->wavedata[i] & 0x0F0F0F0F) << 4) | ((ch->wavedata[i] & 0xF0F0F000) >> 12); + ch->wavedata[i] |= bitsCarry << 20; bitsCarry = bits; } - ch->sample = bitsCarry >> 24; + ch->sample = bitsCarry >> 4; ch->sample -= 8; ch->sample *= volume * 4; return 8 * (2048 - ch->control.rate);