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 0fc6b02691
commit 9f057e2719
2 changed files with 4 additions and 3 deletions

View File

@ -1,5 +1,6 @@
0.10.1: (Future) 0.10.1: (Future)
Emulation fixes: 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 Serialize: Don't write BGP/OBP when loading SCGB state (fixes mgba.io/i/2694)
- GB SIO: Further fix bidirectional transfer starting - GB SIO: Further fix bidirectional transfer starting
- GBA: Fix resetting key IRQ state (fixes mgba.io/i/2716) - 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); 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; int period = 4 * (2048 - audio->ch1.control.frequency) * audio->timingFactor;
int32_t diff = timestamp - audio->ch1.lastUpdate; int32_t diff = timestamp - audio->ch1.lastUpdate;
if (diff >= period) { if (diff >= period) {
@ -490,7 +490,7 @@ void GBAudioRun(struct GBAudio* audio, int32_t timestamp, int channels) {
_updateSquareSample(&audio->ch1); _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; int period = 4 * (2048 - audio->ch2.control.frequency) * audio->timingFactor;
int32_t diff = timestamp - audio->ch2.lastUpdate; int32_t diff = timestamp - audio->ch2.lastUpdate;
if (diff >= period) { if (diff >= period) {
@ -863,7 +863,7 @@ bool _writeEnvelope(struct GBAudioEnvelope* envelope, uint8_t value, enum GBAudi
envelope->currentVolume &= 0xF; envelope->currentVolume &= 0xF;
} }
_updateEnvelopeDead(envelope); _updateEnvelopeDead(envelope);
return (envelope->initialVolume || envelope->direction) && envelope->dead != 2; return envelope->initialVolume || envelope->direction;
} }
static void _updateSquareSample(struct GBAudioSquareChannel* ch) { static void _updateSquareSample(struct GBAudioSquareChannel* ch) {