From 2ffce49e164a0b51e88e343af4bf00f6d1d395bd Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Fri, 22 Sep 2017 14:39:39 +0300 Subject: [PATCH] Minor bugfixes related to sweeping --- Core/apu.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Core/apu.c b/Core/apu.c index 43f2da8..136e537 100755 --- a/Core/apu.c +++ b/Core/apu.c @@ -523,7 +523,6 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value) gb->apu.square_channels[index].sample_length &= 0xFF; gb->apu.square_channels[index].sample_length |= (value & 7) << 8; if (index == GB_SQUARE_1) { - gb->apu.sweep_decreasing = false; gb->apu.shadow_sweep_sample_legnth = gb->apu.new_sweep_sample_legnth = gb->apu.square_channels[0].sample_length; @@ -549,13 +548,12 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value) gb->apu.square_channels[index].length_enabled = false; } - if (index == GB_SQUARE_1 && gb->io_registers[GB_IO_NR10] & 7) { - /* APU bug: if shift is nonzero, overflow check also occurs on trigger */ - /* Todo: check actual timing */ - gb->apu.square_sweep_calculate_countdown = 0x3 - gb->apu.lf_div; - } - if (index == GB_SQUARE_1) { + gb->apu.sweep_decreasing = false; + if (gb->io_registers[GB_IO_NR10] & 7) { + /* APU bug: if shift is nonzero, overflow check also occurs on trigger */ + gb->apu.square_sweep_calculate_countdown = 0x13 - gb->apu.lf_div; + } gb->apu.sweep_enabled = gb->io_registers[GB_IO_NR10] & 0x77; gb->apu.square_sweep_countdown = ((gb->io_registers[GB_IO_NR10] >> 4) & 7); if (!gb->apu.square_sweep_countdown) gb->apu.square_sweep_countdown = 8;