GB Audio: Reset envelope timer when reseting sound channel (fixes #287)
Jeffrey Pfau jeffrey@endrift.com
Sat, 24 Dec 2016 03:38:44 -0800
2 files changed,
5 insertions(+),
5 deletions(-)
M
CHANGES
→
CHANGES
@@ -43,6 +43,7 @@ - GB Video: Initialize LCDC in renderer
- GBA I/O: Mask off WAITCNT bits that cannot be written - GB Memory: Fix HDMA5 value after DMA completes - GB Video: Hblank IRQs should mask LYC=LY IRQs + - GB Audio: Reset envelope timer when reseting sound channel Misc: - SDL: Remove scancode key input - GBA Video: Clean up unused timers
M
src/gb/audio.c
→
src/gb/audio.c
@@ -161,7 +161,6 @@ }
} if (GBAudioRegisterControlIsRestart(value << 8)) { audio->playingCh1 = _resetEnvelope(&audio->ch1.envelope); - _updateEnvelopeDead(&audio->ch1.envelope); if (audio->nextEvent == INT_MAX) { audio->eventDiff = 0;@@ -219,7 +218,6 @@ }
} if (GBAudioRegisterControlIsRestart(value << 8)) { audio->playingCh2 = _resetEnvelope(&audio->ch2.envelope); - _updateEnvelopeDead(&audio->ch2.envelope); if (audio->nextEvent == INT_MAX) { audio->eventDiff = 0;@@ -337,9 +335,7 @@ audio->playingCh4 = false;
} } if (GBAudioRegisterNoiseControlIsRestart(value)) { - audio->playingCh4 = audio->ch4.envelope.initialVolume || audio->ch4.envelope.direction; - audio->ch4.envelope.currentVolume = audio->ch4.envelope.initialVolume; - _updateEnvelopeDead(&audio->ch4.envelope); + audio->playingCh4 = _resetEnvelope(&audio->ch4.envelope); if (audio->ch4.power) { audio->ch4.lfsr = 0x40;@@ -687,6 +683,9 @@
bool _resetEnvelope(struct GBAudioEnvelope* envelope) { envelope->currentVolume = envelope->initialVolume; _updateEnvelopeDead(envelope); + if (!envelope->dead) { + envelope->nextStep = envelope->stepTime; + } return envelope->initialVolume || envelope->direction; }