GB: Add interrupt function for early exit

This commit is contained in:
Vicki Pfau
2025-12-30 21:39:10 -08:00
parent 2c447678da
commit 2b778417e7
6 changed files with 12 additions and 5 deletions
+2
View File
@@ -197,6 +197,8 @@ void GBTestKeypadIRQ(struct GB* gb);
void GBFrameStarted(struct GB* gb);
void GBFrameEnded(struct GB* gb);
void GBInterrupt(struct GB* gb);
CXX_GUARD_END
#endif
+1 -1
View File
@@ -840,7 +840,7 @@ static void _sample(struct mTiming* timing, void* user, uint32_t cyclesLate) {
}
if (!mCoreSyncProduceAudio(audio->p->sync, &audio->buffer)) {
// Interrupted
audio->p->earlyExit = true;
GBInterrupt(audio->p);
}
mTimingSchedule(timing, &audio->sampleEvent, audio->sampleInterval * audio->timingFactor - cyclesLate);
}
+1 -1
View File
@@ -1431,7 +1431,7 @@ static void _GBVLPStartFrameCallback(void *context) {
GBVideoProxyRendererUnshim(&gb->video, &gbcore->proxyRenderer);
mVideoLogContextRewind(gbcore->logContext, core);
GBVideoProxyRendererShim(&gb->video, &gbcore->proxyRenderer);
gb->earlyExit = true;
GBInterrupt(gb);
}
}
+6 -1
View File
@@ -976,7 +976,7 @@ void GBProcessEvents(struct SM83Core* cpu) {
gb->timing.globalCycles += nextEvent;
#endif
nextEvent = mTimingTick(&gb->timing, nextEvent);
} while (gb->cpuBlocked);
} while (gb->cpuBlocked && !gb->earlyExit);
// This loop cannot early exit until the SM83 run loop properly handles mid-M-cycle-exits
cpu->nextEvent = nextEvent;
@@ -1219,6 +1219,11 @@ void GBFrameEnded(struct GB* gb) {
}
}
void GBInterrupt(struct GB* gb) {
gb->earlyExit = true;
mTimingInterrupt(&gb->timing);
}
enum GBModel GBNameToModel(const char* model) {
if (strcasecmp(model, "DMG") == 0 || strcasecmp(model, "GB") == 0) {
return GB_MODEL_DMG;
+1 -1
View File
@@ -237,7 +237,7 @@ static void _GBSIOLockstepNodeProcessEvents(struct mTiming* timing, void* user,
mTimingDeschedule(timing, &node->event);
mTimingSchedule(timing, &node->event, cycles);
} else {
node->d.p->p->earlyExit = true;
GBInterrupt(node->d.p->p);
mTimingSchedule(timing, &node->event, cyclesLate + 1);
}
}
+1 -1
View File
@@ -686,7 +686,7 @@ void _updateFrameCount(struct mTiming* timing, void* context, uint32_t cyclesLat
GBFrameEnded(video->p);
mCoreSyncPostFrame(video->p->sync);
++video->frameCounter;
video->p->earlyExit = true;
GBInterrupt(video->p);
GBFrameStarted(video->p);
}