From 98529063ba822b0e2524a2882f0ea3b13f537482 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 14 Sep 2015 19:25:48 -0700 Subject: [PATCH] GBA Audio: Fix audio channels being silenced at the wrong time --- CHANGES | 1 + src/gba/audio.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 264a3af39..255232226 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,7 @@ Bugfixes: - GBA: Fix BIOS check on big endian - Libretro: Fix a memory leak with the render buffer - GBA Audio: Fix 8-bit writes to audio channel 3 and 4 registers + - GBA Audio: Fix audio channels being silenced at the wrong time Misc: - Qt: Window size command line options are now supported - Qt: Increase usability of key mapper diff --git a/src/gba/audio.c b/src/gba/audio.c index 6fac940b3..1b2d121e9 100644 --- a/src/gba/audio.c +++ b/src/gba/audio.c @@ -345,12 +345,10 @@ void GBAAudioWriteSOUND1CNT_X(struct GBAAudio* audio, uint16_t value) { audio->nextCh1 = 0; } audio->playingCh1 = 1; - if (audio->ch1.envelope.stepTime) { - audio->ch1.envelope.nextStep = 0; - } else { - audio->ch1.envelope.nextStep = INT_MAX; - } audio->ch1.envelope.currentVolume = audio->ch1.envelope.initialVolume; + if (audio->ch1.envelope.currentVolume > 0) { + audio->ch1.envelope.dead = 0; + } if (audio->ch1.envelope.stepTime) { audio->ch1.envelope.nextStep = 0; } else { @@ -372,6 +370,9 @@ void GBAAudioWriteSOUND2CNT_HI(struct GBAAudio* audio, uint16_t value) { if (GBAAudioRegisterControlIsRestart(value)) { audio->playingCh2 = 1; audio->ch2.envelope.currentVolume = audio->ch2.envelope.initialVolume; + if (audio->ch2.envelope.currentVolume > 0) { + audio->ch2.envelope.dead = 0; + } if (audio->ch2.envelope.stepTime) { audio->ch2.envelope.nextStep = 0; } else { @@ -419,6 +420,9 @@ void GBAAudioWriteSOUND4CNT_HI(struct GBAAudio* audio, uint16_t value) { if (GBAAudioRegisterCh4ControlIsRestart(value)) { audio->playingCh4 = 1; audio->ch4.envelope.currentVolume = audio->ch4.envelope.initialVolume; + if (audio->ch4.envelope.currentVolume > 0) { + audio->ch4.envelope.dead = 0; + } if (audio->ch4.envelope.stepTime) { audio->ch4.envelope.nextStep = 0; } else {