all repos — mgba @ 65473a97f9606b51e7be0d81ef073d71235c0460

mGBA Game Boy Advance Emulator

GB Video: Frame event cleanup
Vicki Pfau vi@endrift.com
Tue, 18 Sep 2018 18:51:37 -0700
commit

65473a97f9606b51e7be0d81ef073d71235c0460

parent

3e75dae3dce0fdae8e7ea0edc73ddd20a5e0e7d4

3 files changed, 29 insertions(+), 24 deletions(-)

jump to
M include/mgba/internal/gb/gb.hinclude/mgba/internal/gb/gb.h

@@ -177,6 +177,7 @@ void GBGetGameCode(const struct GB* gba, char* out);

void GBTestKeypadIRQ(struct GB* gb); +void GBFrameStarted(struct GB* gb); void GBFrameEnded(struct GB* gb); CXX_GUARD_END
M src/gb/gb.csrc/gb/gb.c

@@ -816,6 +816,18 @@ memcpy(&out[4], cart->maker, 4);

} } +void GBFrameStarted(struct GB* gb) { + GBTestKeypadIRQ(gb); + + size_t c; + for (c = 0; c < mCoreCallbacksListSize(&gb->coreCallbacks); ++c) { + struct mCoreCallbacks* callbacks = mCoreCallbacksListGetPointer(&gb->coreCallbacks, c); + if (callbacks->videoFrameStarted) { + callbacks->videoFrameStarted(callbacks->context); + } + } +} + void GBFrameEnded(struct GB* gb) { GBSramClean(gb, gb->video.frameCounter);

@@ -828,7 +840,21 @@ mCheatRefresh(device, cheats);

} } - GBTestKeypadIRQ(gb); + // TODO: Move to common code + if (gb->stream && gb->stream->postVideoFrame) { + const color_t* pixels; + size_t stride; + gb->video.renderer->getPixels(gb->video.renderer, &stride, (const void**) &pixels); + gb->stream->postVideoFrame(gb->stream, pixels, stride); + } + + size_t c; + for (c = 0; c < mCoreCallbacksListSize(&gb->coreCallbacks); ++c) { + struct mCoreCallbacks* callbacks = mCoreCallbacksListGetPointer(&gb->coreCallbacks, c); + if (callbacks->videoFrameEnded) { + callbacks->videoFrameEnded(callbacks->context); + } + } } enum GBModel GBNameToModel(const char* model) {
M src/gb/video.csrc/gb/video.c

@@ -337,14 +337,6 @@ mTimingSchedule(timing, &video->frameEvent, 4 - ((video->p->cpu->executionState + 1) & 3));

return; } - size_t c; - for (c = 0; c < mCoreCallbacksListSize(&video->p->coreCallbacks); ++c) { - struct mCoreCallbacks* callbacks = mCoreCallbacksListGetPointer(&video->p->coreCallbacks, c); - if (callbacks->videoFrameEnded) { - callbacks->videoFrameEnded(callbacks->context); - } - } - GBFrameEnded(video->p); mCoreSyncPostFrame(video->p->sync); --video->frameskipCounter;

@@ -354,24 +346,10 @@ video->frameskipCounter = video->frameskip;

} ++video->frameCounter; - // TODO: Move to common code - if (video->p->stream && video->p->stream->postVideoFrame) { - const color_t* pixels; - size_t stride; - video->renderer->getPixels(video->renderer, &stride, (const void**) &pixels); - video->p->stream->postVideoFrame(video->p->stream, pixels, stride); - } - if (!GBRegisterLCDCIsEnable(video->p->memory.io[REG_LCDC])) { mTimingSchedule(timing, &video->frameEvent, GB_VIDEO_TOTAL_LENGTH); } - - for (c = 0; c < mCoreCallbacksListSize(&video->p->coreCallbacks); ++c) { - struct mCoreCallbacks* callbacks = mCoreCallbacksListGetPointer(&video->p->coreCallbacks, c); - if (callbacks->videoFrameStarted) { - callbacks->videoFrameStarted(callbacks->context); - } - } + GBFrameStarted(video->p); } static void _cleanOAM(struct GBVideo* video, int y) {