GB Audio: Reset envelope timer when reseting sound channel (fixes #287)

This commit is contained in:
Jeffrey Pfau 2016-12-24 03:38:44 -08:00
parent eaec17488e
commit e32c0673da
2 changed files with 5 additions and 5 deletions

View File

@ -43,6 +43,7 @@ Bugfixes:
- 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

View File

@ -161,7 +161,6 @@ void GBAudioWriteNR14(struct GBAudio* audio, uint8_t value) {
}
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 @@ void GBAudioWriteNR24(struct GBAudio* audio, uint8_t value) {
}
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 @@ void GBAudioWriteNR44(struct GBAudio* audio, uint8_t value) {
}
}
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 @@ void _sample(struct GBAudio* audio, int32_t cycles) {
bool _resetEnvelope(struct GBAudioEnvelope* envelope) {
envelope->currentVolume = envelope->initialVolume;
_updateEnvelopeDead(envelope);
if (!envelope->dead) {
envelope->nextStep = envelope->stepTime;
}
return envelope->initialVolume || envelope->direction;
}