mirror of
https://github.com/mgba-emu/mgba.git
synced 2026-10-12 02:18:55 +00:00
GB: Add interrupt function for early exit
This commit is contained in:
@@ -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
@@ -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
@@ -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
@@ -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;
|
||||
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user