From d3c15ef6caf17dd80e47babca07048b449750b15 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Thu, 21 Sep 2017 14:52:09 +0300 Subject: [PATCH] =?UTF-8?q?Fixing=20APU=20bugs,=20one=20at=20a=20time:=20B?= =?UTF-8?q?largg=E2=80=99s=20dmg=5Fsound=208.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Core/apu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/apu.c b/Core/apu.c index dc64ca5..5328685 100755 --- a/Core/apu.c +++ b/Core/apu.c @@ -213,6 +213,7 @@ void GB_apu_div_event(GB_gameboy_t *gb) gb->apu.square_channels[GB_SQUARE_1].sample_length &= 0x7FF; 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; } } } @@ -474,8 +475,6 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value) /* Square channels */ case GB_IO_NR10: - gb->apu.square_sweep_countdown = ((value >> 4) & 7); - if (!gb->apu.square_sweep_countdown) gb->apu.square_sweep_countdown = 8; break; case GB_IO_NR11: @@ -554,6 +553,8 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value) if (index == GB_SQUARE_1) { 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; } /* Note that we don't change the sample just yet! This was verified on hardware. */