mirror of https://github.com/mgba-emu/mgba.git
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:
parent
c0cfa602af
commit
aec8ef45ef
12
src/gba/io.c
12
src/gba/io.c
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue