GB Audio: Fix channels 1/2 not playing when resetting volume (fixes #2614)

This commit is contained in:
Vicki Pfau 2022-11-28 22:37:31 -08:00
parent 4fefa0c51a
commit 083585b565
2 changed files with 4 additions and 3 deletions

View File

@ -3,6 +3,7 @@ Features:
- New unlicensed GB mappers: NT (older types 1 and 2), Li Cheng, GGB-81
- Debugger: Add range watchpoints
Emulation fixes:
- GB Audio: Fix channels 1/2 not playing when resetting volume (fixes mgba.io/i/2614)
- GB Serialize: Don't write BGP/OBP when loading SCGB state (fixes mgba.io/i/2694)
- GB SIO: Further fix bidirectional transfer starting
- GBA: Fix resetting key IRQ state (fixes mgba.io/i/2716)

View File

@ -480,7 +480,7 @@ void GBAudioRun(struct GBAudio* audio, int32_t timestamp, int channels) {
GBAudioSample(audio, timestamp);
}
if (audio->playingCh1 && (channels & 0x1)) {
if (audio->playingCh1 && (channels & 0x1) && audio->ch1.envelope.dead != 2) {
int period = 4 * (2048 - audio->ch1.control.frequency) * audio->timingFactor;
int32_t diff = timestamp - audio->ch1.lastUpdate;
if (diff >= period) {
@ -490,7 +490,7 @@ void GBAudioRun(struct GBAudio* audio, int32_t timestamp, int channels) {
_updateSquareSample(&audio->ch1);
}
}
if (audio->playingCh2 && (channels & 0x2)) {
if (audio->playingCh2 && (channels & 0x2) && audio->ch2.envelope.dead != 2) {
int period = 4 * (2048 - audio->ch2.control.frequency) * audio->timingFactor;
int32_t diff = timestamp - audio->ch2.lastUpdate;
if (diff >= period) {
@ -863,7 +863,7 @@ bool _writeEnvelope(struct GBAudioEnvelope* envelope, uint8_t value, enum GBAudi
envelope->currentVolume &= 0xF;
}
_updateEnvelopeDead(envelope);
return (envelope->initialVolume || envelope->direction) && envelope->dead != 2;
return envelope->initialVolume || envelope->direction;
}
static void _updateSquareSample(struct GBAudioSquareChannel* ch) {