From 2d766982799b03c4333b6784593c903f54d55e45 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sun, 31 Jan 2021 19:17:26 +0200 Subject: [PATCH] Emulation of NR43 bit 3 glitch on CGB-C and older --- Core/apu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Core/apu.c b/Core/apu.c index 126dd43..c7345f0 100644 --- a/Core/apu.c +++ b/Core/apu.c @@ -1209,7 +1209,15 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value) } /* Step LFSR */ if (new_bit && (!old_bit || gb->model <= GB_MODEL_CGB_C)) { - step_lfsr(gb, 0); + if (gb->model <= GB_MODEL_CGB_C) { + bool previous_narrow = gb->apu.noise_channel.narrow; + gb->apu.noise_channel.narrow = true; + step_lfsr(gb, 0); + gb->apu.noise_channel.narrow = previous_narrow; + } + else { + step_lfsr(gb, 0); + } } break; }