all repos — mgba @ e32c0673dabb4df27bb2c7da94d0592806a6c56d

mGBA Game Boy Advance Emulator

GB Audio: Reset envelope timer when reseting sound channel (fixes #287)
Jeffrey Pfau jeffrey@endrift.com
Sat, 24 Dec 2016 03:38:44 -0800
commit

e32c0673dabb4df27bb2c7da94d0592806a6c56d

parent

eaec17488e6d837c47a7f7ff07b3421328d5fcf2

2 files changed, 5 insertions(+), 5 deletions(-)

jump to
M CHANGESCHANGES

@@ -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.csrc/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; }