all repos — mgba @ 813b2c069761773be3e08e39c74e75c25ba6e667

mGBA Game Boy Advance Emulator

Partially implement frameskip
Jeffrey Pfau jeffrey@endrift.com
Fri, 03 May 2013 10:24:56 -0700
commit

813b2c069761773be3e08e39c74e75c25ba6e667

parent

3ad2510b784e278614ec4ab406b5eeecba91d4d4

2 files changed, 13 insertions(+), 4 deletions(-)

jump to
M src/gba/gba-video.hsrc/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.csrc/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); }