From 706135113c3c75c4c828a899beafd226f31ddd76 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Thu, 19 May 2022 20:59:48 +0300 Subject: [PATCH] Fix AGB APU regression --- Core/apu.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Core/apu.c b/Core/apu.c index ca00d74..f0ccb5b 100644 --- a/Core/apu.c +++ b/Core/apu.c @@ -68,10 +68,6 @@ static uint8_t agb_bias_for_channel(GB_gameboy_t *gb, unsigned index) static void update_sample(GB_gameboy_t *gb, unsigned index, int8_t value, unsigned cycles_offset) { - if (gb->model > GB_MODEL_CGB_E && index == GB_WAVE) { - /* For some reason, channel 3 is inverted on the AGB */ - value ^= 0xF; - } if (gb->model > GB_MODEL_CGB_E) { /* On the AGB, because no analog mixing is done, the behavior of NR51 is a bit different. @@ -83,6 +79,11 @@ static void update_sample(GB_gameboy_t *gb, unsigned index, int8_t value, unsign unsigned right_volume = (gb->io_registers[GB_IO_NR50] & 7) + 1; unsigned left_volume = ((gb->io_registers[GB_IO_NR50] >> 4) & 7) + 1; + if (index == GB_WAVE) { + /* For some reason, channel 3 is inverted on the AGB */ + value ^= 0xF; + } + GB_sample_t output; uint8_t bias = agb_bias_for_channel(gb, index);