GBA Audio: Clear GB audio state when disabled

This commit is contained in:
Vicki Pfau 2023-03-25 04:27:54 -07:00
parent cb0ad844c1
commit cdb0c4193b
2 changed files with 15 additions and 0 deletions

View File

@ -7,6 +7,7 @@ Features:
Emulation fixes: Emulation fixes:
- GB Video: Implement DMG-style sprite ordering - GB Video: Implement DMG-style sprite ordering
- GBA Audio: Fix improperly deserializing GB audio registers (fixes mgba.io/i/2793) - GBA Audio: Fix improperly deserializing GB audio registers (fixes mgba.io/i/2793)
- GBA Audio: Clear GB audio state when disabled
- GBA Memory: Make VRAM access stalls only apply to BG RAM - GBA Memory: Make VRAM access stalls only apply to BG RAM
- GBA Overrides: Fix saving in PMD:RRT (JP) (fixes mgba.io/i/2862) - GBA Overrides: Fix saving in PMD:RRT (JP) (fixes mgba.io/i/2862)
- GBA SIO: Fix SIOCNT SI pin value after attaching player 2 (fixes mgba.io/i/2805) - GBA SIO: Fix SIOCNT SI pin value after attaching player 2 (fixes mgba.io/i/2805)

View File

@ -231,8 +231,22 @@ void GBAAudioWriteSOUNDCNT_HI(struct GBAAudio* audio, uint16_t value) {
} }
void GBAAudioWriteSOUNDCNT_X(struct GBAAudio* audio, uint16_t value) { void GBAAudioWriteSOUNDCNT_X(struct GBAAudio* audio, uint16_t value) {
GBAAudioSample(audio, mTimingCurrentTime(&audio->p->timing));
audio->enable = GBAudioEnableGetEnable(value); audio->enable = GBAudioEnableGetEnable(value);
GBAudioWriteNR52(&audio->psg, value); GBAudioWriteNR52(&audio->psg, value);
if (!audio->enable) {
int i;
for (i = REG_SOUND1CNT_LO; i < REG_SOUNDCNT_HI; i += 2) {
audio->p->memory.io[i >> 1] = 0;
}
audio->psg.ch3.size = 0;
audio->psg.ch3.bank = 0;
audio->psg.ch3.volume = 0;
audio->volume = 0;
audio->volumeChA = 0;
audio->volumeChB = 0;
audio->p->memory.io[REG_SOUNDCNT_HI >> 1] &= 0xFF00;
}
} }
void GBAAudioWriteSOUNDBIAS(struct GBAAudio* audio, uint16_t value) { void GBAAudioWriteSOUNDBIAS(struct GBAAudio* audio, uint16_t value) {