Partially implement frameskip
Jeffrey Pfau jeffrey@endrift.com
Fri, 03 May 2013 10:24:56 -0700
2 files changed,
13 insertions(+),
4 deletions(-)
M
src/gba/gba-video.h
→
src/gba/gba-video.h
@@ -169,6 +169,7 @@ uint16_t* vram;
union GBAOAM* oam; int framesPending; + int frameskip; int turbo; };
M
src/gba/renderers/video-software.c
→
src/gba/renderers/video-software.c
@@ -36,6 +36,7 @@ renderer->d.finishFrame = GBAVideoSoftwareRendererFinishFrame;
renderer->d.turbo = 0; renderer->d.framesPending = 0; + renderer->d.frameskip = 0; { pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;@@ -200,6 +201,9 @@ }
static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* renderer, int y) { struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer; + if (renderer->frameskip > 0) { + return; + } uint32_t* row = &softwareRenderer->outputBuffer[softwareRenderer->outputBufferStride * y]; if (softwareRenderer->dispcnt.forcedBlank) { for (int x = 0; x < VIDEO_HORIZONTAL_PIXELS; ++x) {@@ -229,10 +233,14 @@ static void GBAVideoSoftwareRendererFinishFrame(struct GBAVideoRenderer* renderer) {
struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer; pthread_mutex_lock(&softwareRenderer->mutex); - renderer->framesPending++; - pthread_cond_broadcast(&softwareRenderer->upCond); - if (!renderer->turbo) { - pthread_cond_wait(&softwareRenderer->downCond, &softwareRenderer->mutex); + if (renderer->frameskip > 0) { + --renderer->frameskip; + } else { + renderer->framesPending++; + pthread_cond_broadcast(&softwareRenderer->upCond); + if (!renderer->turbo) { + pthread_cond_wait(&softwareRenderer->downCond, &softwareRenderer->mutex); + } } pthread_mutex_unlock(&softwareRenderer->mutex); }