GB Video: Frame event cleanup

This commit is contained in:
Vicki Pfau 2018-09-18 18:51:37 -07:00
parent 3e75dae3dc
commit 65473a97f9
3 changed files with 29 additions and 24 deletions

View File

@ -177,6 +177,7 @@ void GBGetGameCode(const struct GB* gba, char* out);
void GBTestKeypadIRQ(struct GB* gb); void GBTestKeypadIRQ(struct GB* gb);
void GBFrameStarted(struct GB* gb);
void GBFrameEnded(struct GB* gb); void GBFrameEnded(struct GB* gb);
CXX_GUARD_END CXX_GUARD_END

View File

@ -816,6 +816,18 @@ void GBGetGameCode(const struct GB* gb, char* out) {
} }
} }
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) { void GBFrameEnded(struct GB* gb) {
GBSramClean(gb, gb->video.frameCounter); GBSramClean(gb, gb->video.frameCounter);
@ -828,7 +840,21 @@ void GBFrameEnded(struct GB* gb) {
} }
} }
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) { enum GBModel GBNameToModel(const char* model) {

View File

@ -337,14 +337,6 @@ void _updateFrameCount(struct mTiming* timing, void* context, uint32_t cyclesLat
return; 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); GBFrameEnded(video->p);
mCoreSyncPostFrame(video->p->sync); mCoreSyncPostFrame(video->p->sync);
--video->frameskipCounter; --video->frameskipCounter;
@ -354,24 +346,10 @@ void _updateFrameCount(struct mTiming* timing, void* context, uint32_t cyclesLat
} }
++video->frameCounter; ++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])) { if (!GBRegisterLCDCIsEnable(video->p->memory.io[REG_LCDC])) {
mTimingSchedule(timing, &video->frameEvent, GB_VIDEO_TOTAL_LENGTH); mTimingSchedule(timing, &video->frameEvent, GB_VIDEO_TOTAL_LENGTH);
} }
GBFrameStarted(video->p);
for (c = 0; c < mCoreCallbacksListSize(&video->p->coreCallbacks); ++c) {
struct mCoreCallbacks* callbacks = mCoreCallbacksListGetPointer(&video->p->coreCallbacks, c);
if (callbacks->videoFrameStarted) {
callbacks->videoFrameStarted(callbacks->context);
}
}
} }
static void _cleanOAM(struct GBVideo* video, int y) { static void _cleanOAM(struct GBVideo* video, int y) {