From 2936f7fa574cc745bb1e95127db9165439252e7d Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 22 Jul 2017 19:51:11 +0300 Subject: [PATCH] Fixed channel 3 counter behavior, verified with new tests. The DIV register ticks the APU at 512Hz. --- Core/apu.c | 2 +- Core/apu.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/apu.c b/Core/apu.c index 4ff7664d..6a54518d 100755 --- a/Core/apu.c +++ b/Core/apu.c @@ -283,7 +283,7 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value) } } gb->apu.is_active[GB_WAVE] = true; - gb->apu.wave_channel.pulse_length = ~gb->io_registers[GB_IO_NR31]; + gb->apu.wave_channel.pulse_length = (~gb->io_registers[GB_IO_NR31]) * 2; gb->apu.wave_channel.sample_countdown = gb->apu.wave_channel.sample_length + 3; gb->apu.wave_channel.current_sample_index = 0; /* Note that we don't change the sample just yet! This was verified on hardware. */ diff --git a/Core/apu.h b/Core/apu.h index 6690a588..88117fb9 100644 --- a/Core/apu.h +++ b/Core/apu.h @@ -11,8 +11,8 @@ #define CH_STEP (MAX_CH_AMP/0xF/7) #endif -/* Lengths are in either DIV ticks (256Hz, triggered by the DIV register) or - APU ticks (2MHz, triggered by an internal APU clock)*/ +/* Lengths are in either DIV ticks (512Hz, triggered by the DIV register) or + APU ticks (2MHz, triggered by an internal APU clock) */ typedef struct {