From c66b6fbafc3308c7aeedd2ab7e32b1cc7c21a836 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Mon, 16 Jul 2018 23:08:25 +0300 Subject: [PATCH] Fixed an edge case with DAC discharge emulation --- Core/apu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Core/apu.c b/Core/apu.c index 260947d..a77f4aa 100644 --- a/Core/apu.c +++ b/Core/apu.c @@ -28,7 +28,6 @@ static void update_sample(GB_gameboy_t *gb, unsigned index, int8_t value, unsign } else { gb->apu.samples[index] = value; - gb->apu_output.dac_discharge[index] = 1.0; } if (gb->apu_output.sample_rate) { @@ -887,6 +886,11 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value) } } gb->io_registers[reg] = value; + for (unsigned i = 0; i < GB_N_CHANNELS; i++) { + if (gb->apu.is_active[i]) { + gb->apu_output.dac_discharge[i] = 1.0; + } + } } size_t GB_apu_get_current_buffer_length(GB_gameboy_t *gb)