mirror of https://github.com/mgba-emu/mgba.git
GB Serialize: Fix some deserialization bugs
This commit is contained in:
parent
549787227a
commit
a1e43c91a1
|
@ -699,7 +699,8 @@ void GBIODeserialize(struct GB* gb, const struct GBSerializedState* state) {
|
|||
memcpy(gb->memory.io, state->io, GB_SIZE_IO);
|
||||
gb->memory.ie = state->ie;
|
||||
|
||||
if (GBAudioEnableGetEnable(*gb->audio.nr52)) {
|
||||
gb->audio.enable = GBAudioEnableGetEnable(*gb->audio.nr52);
|
||||
if (GBAudioEnableGetEnable(gb->audio.enable)) {
|
||||
GBIOWrite(gb, REG_NR10, gb->memory.io[REG_NR10]);
|
||||
GBIOWrite(gb, REG_NR11, gb->memory.io[REG_NR11]);
|
||||
GBIOWrite(gb, REG_NR12, gb->memory.io[REG_NR12]);
|
||||
|
|
|
@ -440,6 +440,7 @@ static void _GBMBC1Update(struct GB* gb) {
|
|||
GBMBCSwitchSramBank(gb, 0);
|
||||
}
|
||||
if (!(state->bankLo & 0x1F)) {
|
||||
++state->bankLo;
|
||||
++bank;
|
||||
}
|
||||
GBMBCSwitchBank(gb, bank);
|
||||
|
|
|
@ -211,6 +211,7 @@ void GBMemoryReset(struct GB* gb) {
|
|||
switch (gb->memory.mbcType) {
|
||||
case GB_MBC1:
|
||||
gb->memory.mbcState.mbc1.mode = 0;
|
||||
gb->memory.mbcState.mbc1.bankLo = 1;
|
||||
break;
|
||||
case GB_MBC6:
|
||||
GBMBCSwitchHalfBank(gb, 0, 2);
|
||||
|
@ -784,10 +785,14 @@ void GBMemoryDeserialize(struct GB* gb, const struct GBSerializedState* state) {
|
|||
LOAD_32LE(when, 0, &state->memory.dmaNext);
|
||||
if (memory->dmaRemaining) {
|
||||
mTimingSchedule(&gb->timing, &memory->dmaEvent, when);
|
||||
} else {
|
||||
memory->dmaEvent.when = when + mTimingCurrentTime(&gb->timing);
|
||||
}
|
||||
LOAD_32LE(when, 0, &state->memory.hdmaNext);
|
||||
if (memory->hdmaRemaining) {
|
||||
mTimingSchedule(&gb->timing, &memory->hdmaEvent, when);
|
||||
} else {
|
||||
memory->hdmaEvent.when = when + mTimingCurrentTime(&gb->timing);
|
||||
}
|
||||
|
||||
GBSerializedMemoryFlags flags;
|
||||
|
|
|
@ -188,6 +188,8 @@ bool GBDeserialize(struct GB* gb, const struct GBSerializedState* state) {
|
|||
LOAD_32LE(when, 0, &state->cpu.eiPending);
|
||||
if (GBSerializedCpuFlagsIsEiPending(flags)) {
|
||||
mTimingSchedule(&gb->timing, &gb->eiPending, when);
|
||||
} else {
|
||||
gb->eiPending.when = when + mTimingCurrentTime(&gb->timing);
|
||||
}
|
||||
|
||||
gb->model = state->model;
|
||||
|
|
|
@ -140,8 +140,10 @@ void GBTimerDeserialize(struct GBTimer* timer, const struct GBSerializedState* s
|
|||
|
||||
GBSerializedTimerFlags flags = state->timer.flags;
|
||||
|
||||
LOAD_32LE(when, 0, &state->timer.nextIRQ);
|
||||
if (GBSerializedTimerFlagsIsIrqPending(flags)) {
|
||||
LOAD_32LE(when, 0, &state->timer.nextIRQ);
|
||||
mTimingSchedule(&timer->p->timing, &timer->irq, when);
|
||||
} else {
|
||||
timer->irq.when = when + mTimingCurrentTime(&timer->p->timing);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -904,13 +904,17 @@ void GBVideoDeserialize(struct GBVideo* video, const struct GBSerializedState* s
|
|||
}
|
||||
|
||||
uint32_t when;
|
||||
LOAD_32LE(when, 0, &state->video.nextMode);
|
||||
if (!GBSerializedVideoFlagsIsNotModeEventScheduled(flags)) {
|
||||
LOAD_32LE(when, 0, &state->video.nextMode);
|
||||
mTimingSchedule(&video->p->timing, &video->modeEvent, when);
|
||||
} else {
|
||||
video->modeEvent.when = when + mTimingCurrentTime(&video->p->timing);
|
||||
}
|
||||
LOAD_32LE(when, 0, &state->video.nextFrame);
|
||||
if (!GBSerializedVideoFlagsIsNotFrameEventScheduled(flags)) {
|
||||
LOAD_32LE(when, 0, &state->video.nextFrame);
|
||||
mTimingSchedule(&video->p->timing, &video->frameEvent, when);
|
||||
} else {
|
||||
video->frameEvent.when = when + mTimingCurrentTime(&video->p->timing);
|
||||
}
|
||||
|
||||
video->renderer->deinit(video->renderer);
|
||||
|
|
Loading…
Reference in New Issue