GBA Audio: Fix improperly deserializing GB audio registers (fixes #2793)

This commit is contained in:
Vicki Pfau 2023-01-30 00:21:18 -08:00
parent a67b0c0fb2
commit d1f589e002
4 changed files with 15 additions and 2 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:
- GBA Audio: Fix improperly deserializing GB audio registers (fixes mgba.io/i/2793)
- GBA Memory: Make VRAM access stalls only apply to BG RAM
- GBA Video: Disable BG target 1 blending when OBJ blending (fixes mgba.io/i/2722)
Other fixes:

View File

@ -1089,6 +1089,8 @@ void GBAudioPSGDeserialize(struct GBAudio* audio, const struct GBSerializedPSGSt
audio->ch4.lastEvent = currentTime + (when & (cycles - 1)) - cycles;
}
}
audio->ch4.nSamples = 0;
audio->ch4.samples = 0;
}
void GBAudioSerialize(const struct GBAudio* audio, struct GBSerializedState* state) {

View File

@ -506,6 +506,16 @@ void GBAAudioSerialize(const struct GBAAudio* audio, struct GBASerializedState*
void GBAAudioDeserialize(struct GBAAudio* audio, const struct GBASerializedState* state) {
GBAudioPSGDeserialize(&audio->psg, &state->audio.psg, &state->audio.flags);
uint16_t reg;
LOAD_16(reg, REG_SOUND1CNT_X, state->io);
GBAIOWrite(audio->p, REG_SOUND1CNT_X, reg & 0x7FFF);
LOAD_16(reg, REG_SOUND2CNT_HI, state->io);
GBAIOWrite(audio->p, REG_SOUND2CNT_HI, reg & 0x7FFF);
LOAD_16(reg, REG_SOUND3CNT_X, state->io);
GBAIOWrite(audio->p, REG_SOUND3CNT_X, reg & 0x7FFF);
LOAD_16(reg, REG_SOUND4CNT_HI, state->io);
GBAIOWrite(audio->p, REG_SOUND4CNT_HI, reg & 0x7FFF);
LOAD_32(audio->chA.internalSample, 0, &state->audio.internalA);
LOAD_32(audio->chB.internalSample, 0, &state->audio.internalB);
memcpy(audio->chA.samples, state->samples.chA, sizeof(audio->chA.samples));

View File

@ -296,8 +296,8 @@ static const int _isWSpecialRegister[REG_INTERNAL_MAX >> 1] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
// Audio
1, 1, 1, 0, 1, 0, 1, 0,
1, 0, 1, 0, 1, 0, 1, 0,
0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 1, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 0, 0, 0, 0,