mirror of https://github.com/mgba-emu/mgba.git
GBA Timers: Fix deserializing count-up timers
This commit is contained in:
parent
1815f1d961
commit
80930c80e5
1
CHANGES
1
CHANGES
|
@ -2,6 +2,7 @@
|
||||||
Emulation fixes:
|
Emulation fixes:
|
||||||
- GBA SIO: Fix Multiplayer busy bit
|
- GBA SIO: Fix Multiplayer busy bit
|
||||||
- GBA SIO: Fix double-unloading active driver
|
- GBA SIO: Fix double-unloading active driver
|
||||||
|
- GBA Timers: Fix deserializing count-up timers
|
||||||
Other fixes:
|
Other fixes:
|
||||||
- Core: Fix ELF loading regression (fixes mgba.io/i/1669)
|
- Core: Fix ELF loading regression (fixes mgba.io/i/1669)
|
||||||
- Core: Fix crash modifying hash table entry (fixes mgba.io/i/1673)
|
- Core: Fix crash modifying hash table entry (fixes mgba.io/i/1673)
|
||||||
|
|
|
@ -971,16 +971,13 @@ void GBAIODeserialize(struct GBA* gba, const struct GBASerializedState* state) {
|
||||||
for (i = 0; i < 4; ++i) {
|
for (i = 0; i < 4; ++i) {
|
||||||
LOAD_16(gba->timers[i].reload, 0, &state->timers[i].reload);
|
LOAD_16(gba->timers[i].reload, 0, &state->timers[i].reload);
|
||||||
LOAD_32(gba->timers[i].flags, 0, &state->timers[i].flags);
|
LOAD_32(gba->timers[i].flags, 0, &state->timers[i].flags);
|
||||||
if (i > 0 && GBATimerFlagsIsCountUp(gba->timers[i].flags)) {
|
|
||||||
// Overwrite invalid values in savestate
|
|
||||||
gba->timers[i].lastEvent = 0;
|
|
||||||
} else {
|
|
||||||
LOAD_32(when, 0, &state->timers[i].lastEvent);
|
LOAD_32(when, 0, &state->timers[i].lastEvent);
|
||||||
gba->timers[i].lastEvent = when + mTimingCurrentTime(&gba->timing);
|
gba->timers[i].lastEvent = when + mTimingCurrentTime(&gba->timing);
|
||||||
}
|
|
||||||
LOAD_32(when, 0, &state->timers[i].nextEvent);
|
LOAD_32(when, 0, &state->timers[i].nextEvent);
|
||||||
if (GBATimerFlagsIsEnable(gba->timers[i].flags)) {
|
if ((i < 1 || !GBATimerFlagsIsCountUp(gba->timers[i].flags)) && GBATimerFlagsIsEnable(gba->timers[i].flags)) {
|
||||||
mTimingSchedule(&gba->timing, &gba->timers[i].event, when);
|
mTimingSchedule(&gba->timing, &gba->timers[i].event, when);
|
||||||
|
} else {
|
||||||
|
gba->timers[i].event.when = when + mTimingCurrentTime(&gba->timing);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOAD_16(gba->memory.dma[i].reg, (REG_DMA0CNT_HI + i * 12), state->io);
|
LOAD_16(gba->memory.dma[i].reg, (REG_DMA0CNT_HI + i * 12), state->io);
|
||||||
|
|
Loading…
Reference in New Issue