Skip to content

Commit

Permalink
Ensure only the frequency is updated on SOUND1CNT_X writes (and not t…
Browse files Browse the repository at this point in the history
…he shadow frequency too).
  • Loading branch information
Arignir committed Feb 12, 2024
1 parent 371c5db commit 03d2d70
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/gba/memory/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,12 @@ mem_io_write8(
case IO_REG_SOUND1CNT_X + 1: {
io->sound1cnt_x.bytes[1] = val;

/*
** Only the frequency (and not the shadow frequency) is updated on register writes.
** Reference:
** - https://gbdev.gg8.se/wiki/articles/Gameboy_sound_hardware#Frequency_Sweep
*/
gba->apu.tone_and_sweep.sweep.frequency = io->sound1cnt_x.sample_rate;
gba->apu.tone_and_sweep.sweep.shadow_frequency = io->sound1cnt_x.sample_rate;

if (io->sound1cnt_x.reset) {
apu_tone_and_sweep_reset(gba);
Expand Down

0 comments on commit 03d2d70

Please sign in to comment.