From c8f4d4aad9c6d5f65589ff6c22592dee471a8ac4 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 20 Dec 2023 02:18:19 -0800 Subject: [PATCH] GB Audio: Fix restarting envelope when writing to register (fixes #3067) --- CHANGES | 1 + src/gb/audio.c | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index f4d714888..b5a6b9136 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,7 @@ Emulation fixes: - ARM: Fake bpkt instruction should take no cycles (fixes mgba.io/i/2551) - GB Audio: Fix channels 1/2 staying muted if restarted after long silence - GB Audio: Fix channel 1 restarting if sweep applies after stop (fixes mgba.io/i/2965) + - GB Audio: Fix restarting envelope when writing to register (fixes mgba.io/i/3067) - GB I/O: Read back proper SVBK value after writing 0 (fixes mgba.io/i/2921) - GB I/O: Fix STAT writing IRQ trigger conditions (fixes mgba.io/i/2501) - GB Serialize: Add missing Pocket Cam state to savestates diff --git a/src/gb/audio.c b/src/gb/audio.c index e9c014d05..8a778b2ed 100644 --- a/src/gb/audio.c +++ b/src/gb/audio.c @@ -880,9 +880,6 @@ static void _sample(struct mTiming* timing, void* user, uint32_t cyclesLate) { bool _resetEnvelope(struct GBAudioEnvelope* envelope) { envelope->currentVolume = envelope->initialVolume; _updateEnvelopeDead(envelope); - if (!envelope->dead) { - envelope->nextStep = envelope->stepTime; - } return envelope->initialVolume || envelope->direction; } @@ -967,6 +964,7 @@ static void _updateEnvelopeDead(struct GBAudioEnvelope* envelope) { envelope->dead = 1; } else { envelope->dead = 0; + envelope->nextStep = envelope->stepTime; } }