GBA Audio: Prevent write to audio registers if audio is OFF

On hardware, if audio is OFF it isn't possible to write to registers at
addresses 0x4000060h to 0x4000081 (inclusive).
This commit is contained in:
Antonio Niño Díaz 2021-03-21 18:31:06 +00:00 committed by Vicki Pfau
parent c0cfa602af
commit aec8ef45ef
1 changed files with 233 additions and 227 deletions

View File

@ -342,8 +342,15 @@ void GBAIOInit(struct GBA* gba) {
void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value) { void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value) {
if (address < REG_SOUND1CNT_LO && (address > REG_VCOUNT || address < REG_DISPSTAT)) { if (address < REG_SOUND1CNT_LO && (address > REG_VCOUNT || address < REG_DISPSTAT)) {
value = gba->video.renderer->writeVideoRegister(gba->video.renderer, address, value); gba->memory.io[address >> 1] = gba->video.renderer->writeVideoRegister(gba->video.renderer, address, value);
} else { return;
}
if (address >= REG_SOUND1CNT_LO && address <= REG_SOUNDCNT_LO && !gba->audio.enable) {
// Ignore writes to most audio registers if the hardware is off.
return;
}
switch (address) { switch (address) {
// Video // Video
case REG_DISPSTAT: case REG_DISPSTAT:
@ -584,7 +591,6 @@ void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value) {
} }
break; break;
} }
}
gba->memory.io[address >> 1] = value; gba->memory.io[address >> 1] = value;
} }