all repos — mgba @ 8615defda763c928eadb4c0919081a74b6bd28fc

mGBA Game Boy Advance Emulator

Core: Fix frameskip
Jeffrey Pfau jeffrey@endrift.com
Sun, 14 Feb 2016 17:37:53 -0800
commit

8615defda763c928eadb4c0919081a74b6bd28fc

parent

bae1ea0a32fbb9a16059b0f1a9e866ef67679053

4 files changed, 25 insertions(+), 7 deletions(-)

jump to
M src/gb/core.csrc/gb/core.c

@@ -71,6 +71,7 @@ UNUSED(config);

struct GB* gb = core->board; gb->audio.masterVolume = core->opts.volume; + gb->video.frameskip = core->opts.frameskip; } static void _GBCoreDesiredVideoDimensions(struct mCore* core, unsigned* width, unsigned* height) {
M src/gb/video.csrc/gb/video.c

@@ -93,7 +93,9 @@ if (video->nextMode <= 0) {

int lyc = video->p->memory.io[REG_LYC]; switch (video->mode) { case 0: - video->renderer->finishScanline(video->renderer, video->ly); + if (video->frameskipCounter <= 0) { + video->renderer->finishScanline(video->renderer, video->ly); + } ++video->ly; video->p->memory.io[REG_LY] = video->ly; video->stat = GBRegisterSTATSetLYC(video->stat, lyc == video->ly);

@@ -106,9 +108,13 @@ }

} else { video->nextMode = GB_VIDEO_HORIZONTAL_LENGTH; video->mode = 1; + --video->frameskipCounter; + if (video->frameskipCounter < 0) { + video->renderer->finishFrame(video->renderer); + mCoreSyncPostFrame(video->p->sync); + video->frameskipCounter = video->frameskip; + } ++video->frameCounter; - video->renderer->finishFrame(video->renderer); - mCoreSyncPostFrame(video->p->sync); struct mCoreThread* thread = mCoreThreadGet(); if (thread && thread->frameCallback) {

@@ -214,7 +220,9 @@ }

if (video->x == GB_VIDEO_HORIZONTAL_PIXELS) { video->dotCounter = INT_MIN; } - video->renderer->drawRange(video->renderer, oldX, video->x, video->ly, video->objThisLine, video->objMax); + if (video->frameskipCounter <= 0) { + video->renderer->drawRange(video->renderer, oldX, video->x, video->ly, video->objThisLine, video->objMax); + } } void GBVideoWriteLCDC(struct GBVideo* video, GBRegisterLCDC value) {
M src/gba/core.csrc/gba/core.c

@@ -78,6 +78,7 @@

static void _GBACoreLoadConfig(struct mCore* core, const struct mCoreConfig* config) { struct GBA* gba = core->board; gba->audio.masterVolume = core->opts.volume; + gba->video.frameskip = core->opts.frameskip; #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 struct GBACore* gbacore = (struct GBACore*) core;
M src/platform/commandline.csrc/platform/commandline.c

@@ -65,6 +65,8 @@ "g"

#endif ; memset(args, 0, sizeof(*args)); + args->frameskip = -1; + args->logLevel = INT_MIN; if (subparser && subparser->extraOptions) { // TODO: modularize options to subparsers strncat(options, subparser->extraOptions, sizeof(options) - strlen(options) - 1);

@@ -136,9 +138,15 @@ return true;

} void applyArguments(struct mArguments* args, struct mSubParser* subparser, struct mCoreConfig* config) { - mCoreConfigSetOverrideIntValue(config, "frameskip", args->frameskip); - mCoreConfigSetOverrideIntValue(config, "logLevel", args->logLevel); - mCoreConfigSetOverrideValue(config, "bios", args->bios); + if (args->frameskip >= 0) { + mCoreConfigSetOverrideIntValue(config, "frameskip", args->frameskip); + } + if (args->logLevel > INT_MIN) { + mCoreConfigSetOverrideIntValue(config, "logLevel", args->logLevel); + } + if (args->bios) { + mCoreConfigSetOverrideValue(config, "bios", args->bios); + } if (subparser) { subparser->apply(subparser, config); }