diff --git a/Core/apu.c b/Core/apu.c index ff83f5e..1262f85 100644 --- a/Core/apu.c +++ b/Core/apu.c @@ -243,25 +243,22 @@ static void render(GB_gameboy_t *gb) unsigned left_volume = 0; unsigned right_volume = 0; unrolled for (unsigned i = GB_N_CHANNELS; i--;) { - if (gb->apu.is_active[i]) { + if (GB_apu_is_DAC_enabled(gb, i)) { if (mask & 1) { - left_volume += (gb->io_registers[GB_IO_NR50] & 7) * CH_STEP * 0xF; + left_volume += ((gb->io_registers[GB_IO_NR50] & 7) + 1) * CH_STEP * 0xF; } if (mask & 0x10) { - right_volume += ((gb->io_registers[GB_IO_NR50] >> 4) & 7) * CH_STEP * 0xF; + right_volume += (((gb->io_registers[GB_IO_NR50] >> 4) & 7) + 1) * CH_STEP * 0xF; } } - else { - left_volume += gb->apu_output.current_sample[i].left * CH_STEP; - right_volume += gb->apu_output.current_sample[i].right * CH_STEP; - } mask >>= 1; } gb->apu_output.highpass_diff = (GB_double_sample_t) {left_volume * (1 - gb->apu_output.highpass_rate) + gb->apu_output.highpass_diff.left * gb->apu_output.highpass_rate, right_volume * (1 - gb->apu_output.highpass_rate) + gb->apu_output.highpass_diff.right * gb->apu_output.highpass_rate}; - case GB_HIGHPASS_MAX:; + case GB_HIGHPASS_MAX: + unreachable(); } }