Core: Interrupt timing during reset (fixes #2651)

This commit is contained in:
Vicki Pfau 2022-10-09 22:07:58 -07:00
parent a2a888bf10
commit 8665b28f0d
6 changed files with 20 additions and 4 deletions

View File

@ -33,14 +33,20 @@ struct mTiming {
void mTimingInit(struct mTiming* timing, int32_t* relativeCycles, int32_t* nextEvent);
void mTimingDeinit(struct mTiming* timing);
void mTimingClear(struct mTiming* timing);
void mTimingInterrupt(struct mTiming* timing);
void mTimingSchedule(struct mTiming* timing, struct mTimingEvent*, int32_t when);
void mTimingScheduleAbsolute(struct mTiming* timing, struct mTimingEvent*, int32_t when);
void mTimingDeschedule(struct mTiming* timing, struct mTimingEvent*);
bool mTimingIsScheduled(const struct mTiming* timing, const struct mTimingEvent*);
int32_t mTimingTick(struct mTiming* timing, int32_t cycles);
int32_t mTimingCurrentTime(const struct mTiming* timing);
uint64_t mTimingGlobalTime(const struct mTiming* timing);
int32_t mTimingNextEvent(struct mTiming* timing);
int32_t mTimingUntil(const struct mTiming* timing, const struct mTimingEvent*);

View File

@ -25,6 +25,14 @@ void mTimingClear(struct mTiming* timing) {
timing->masterCycles = 0;
}
void mTimingInterrupt(struct mTiming* timing) {
if (!timing->root) {
return;
}
timing->reroot = timing->root;
timing->root = NULL;
}
void mTimingSchedule(struct mTiming* timing, struct mTimingEvent* event, int32_t when) {
int32_t nextEvent = when + *timing->relativeCycles;
event->when = nextEvent + timing->masterCycles;

View File

@ -660,6 +660,8 @@ static void _GBCoreReset(struct mCore* core) {
if (core->opts.skipBios) {
GBSkipBIOS(core->board);
}
mTimingInterrupt(&gb->timing);
}
static void _GBCoreRunFrame(struct mCore* core) {

View File

@ -217,8 +217,7 @@ bool GBDeserialize(struct GB* gb, const struct GBSerializedState* state) {
gb->cpu->memory.setActiveRegion(gb->cpu, gb->cpu->pc);
gb->timing.reroot = gb->timing.root;
gb->timing.root = NULL;
mTimingInterrupt(&gb->timing);
return true;
}

View File

@ -712,6 +712,8 @@ static void _GBACoreReset(struct mCore* core) {
if (forceSkip || (core->opts.skipBios && (gba->romVf || gba->memory.rom))) {
GBASkipBIOS(core->board);
}
mTimingInterrupt(&gba->timing);
}
static void _GBACoreRunFrame(struct mCore* core) {

View File

@ -211,8 +211,7 @@ bool GBADeserialize(struct GBA* gba, const struct GBASerializedState* state) {
GBAMatrixDeserialize(gba, state);
}
gba->timing.reroot = gba->timing.root;
gba->timing.root = NULL;
mTimingInterrupt(&gba->timing);
return true;
}