mirror of https://github.com/mgba-emu/mgba.git
Core: Fix frameskip
This commit is contained in:
parent
bae1ea0a32
commit
8615defda7
|
@ -71,6 +71,7 @@ static void _GBCoreLoadConfig(struct mCore* core, const struct mCoreConfig* conf
|
||||||
|
|
||||||
struct GB* gb = core->board;
|
struct GB* gb = core->board;
|
||||||
gb->audio.masterVolume = core->opts.volume;
|
gb->audio.masterVolume = core->opts.volume;
|
||||||
|
gb->video.frameskip = core->opts.frameskip;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _GBCoreDesiredVideoDimensions(struct mCore* core, unsigned* width, unsigned* height) {
|
static void _GBCoreDesiredVideoDimensions(struct mCore* core, unsigned* width, unsigned* height) {
|
||||||
|
|
|
@ -93,7 +93,9 @@ int32_t GBVideoProcessEvents(struct GBVideo* video, int32_t cycles) {
|
||||||
int lyc = video->p->memory.io[REG_LYC];
|
int lyc = video->p->memory.io[REG_LYC];
|
||||||
switch (video->mode) {
|
switch (video->mode) {
|
||||||
case 0:
|
case 0:
|
||||||
|
if (video->frameskipCounter <= 0) {
|
||||||
video->renderer->finishScanline(video->renderer, video->ly);
|
video->renderer->finishScanline(video->renderer, video->ly);
|
||||||
|
}
|
||||||
++video->ly;
|
++video->ly;
|
||||||
video->p->memory.io[REG_LY] = video->ly;
|
video->p->memory.io[REG_LY] = video->ly;
|
||||||
video->stat = GBRegisterSTATSetLYC(video->stat, lyc == video->ly);
|
video->stat = GBRegisterSTATSetLYC(video->stat, lyc == video->ly);
|
||||||
|
@ -106,9 +108,13 @@ int32_t GBVideoProcessEvents(struct GBVideo* video, int32_t cycles) {
|
||||||
} else {
|
} else {
|
||||||
video->nextMode = GB_VIDEO_HORIZONTAL_LENGTH;
|
video->nextMode = GB_VIDEO_HORIZONTAL_LENGTH;
|
||||||
video->mode = 1;
|
video->mode = 1;
|
||||||
++video->frameCounter;
|
--video->frameskipCounter;
|
||||||
|
if (video->frameskipCounter < 0) {
|
||||||
video->renderer->finishFrame(video->renderer);
|
video->renderer->finishFrame(video->renderer);
|
||||||
mCoreSyncPostFrame(video->p->sync);
|
mCoreSyncPostFrame(video->p->sync);
|
||||||
|
video->frameskipCounter = video->frameskip;
|
||||||
|
}
|
||||||
|
++video->frameCounter;
|
||||||
|
|
||||||
struct mCoreThread* thread = mCoreThreadGet();
|
struct mCoreThread* thread = mCoreThreadGet();
|
||||||
if (thread && thread->frameCallback) {
|
if (thread && thread->frameCallback) {
|
||||||
|
@ -214,8 +220,10 @@ void GBVideoProcessDots(struct GBVideo* video) {
|
||||||
if (video->x == GB_VIDEO_HORIZONTAL_PIXELS) {
|
if (video->x == GB_VIDEO_HORIZONTAL_PIXELS) {
|
||||||
video->dotCounter = INT_MIN;
|
video->dotCounter = INT_MIN;
|
||||||
}
|
}
|
||||||
|
if (video->frameskipCounter <= 0) {
|
||||||
video->renderer->drawRange(video->renderer, oldX, video->x, video->ly, video->objThisLine, video->objMax);
|
video->renderer->drawRange(video->renderer, oldX, video->x, video->ly, video->objThisLine, video->objMax);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GBVideoWriteLCDC(struct GBVideo* video, GBRegisterLCDC value) {
|
void GBVideoWriteLCDC(struct GBVideo* video, GBRegisterLCDC value) {
|
||||||
if (!GBRegisterLCDCIsEnable(video->p->memory.io[REG_LCDC]) && GBRegisterLCDCIsEnable(value)) {
|
if (!GBRegisterLCDCIsEnable(video->p->memory.io[REG_LCDC]) && GBRegisterLCDCIsEnable(value)) {
|
||||||
|
|
|
@ -78,6 +78,7 @@ static void _GBACoreSetSync(struct mCore* core, struct mCoreSync* sync) {
|
||||||
static void _GBACoreLoadConfig(struct mCore* core, const struct mCoreConfig* config) {
|
static void _GBACoreLoadConfig(struct mCore* core, const struct mCoreConfig* config) {
|
||||||
struct GBA* gba = core->board;
|
struct GBA* gba = core->board;
|
||||||
gba->audio.masterVolume = core->opts.volume;
|
gba->audio.masterVolume = core->opts.volume;
|
||||||
|
gba->video.frameskip = core->opts.frameskip;
|
||||||
|
|
||||||
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
||||||
struct GBACore* gbacore = (struct GBACore*) core;
|
struct GBACore* gbacore = (struct GBACore*) core;
|
||||||
|
|
|
@ -65,6 +65,8 @@ bool parseArguments(struct mArguments* args, int argc, char* const* argv, struct
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
memset(args, 0, sizeof(*args));
|
memset(args, 0, sizeof(*args));
|
||||||
|
args->frameskip = -1;
|
||||||
|
args->logLevel = INT_MIN;
|
||||||
if (subparser && subparser->extraOptions) {
|
if (subparser && subparser->extraOptions) {
|
||||||
// TODO: modularize options to subparsers
|
// TODO: modularize options to subparsers
|
||||||
strncat(options, subparser->extraOptions, sizeof(options) - strlen(options) - 1);
|
strncat(options, subparser->extraOptions, sizeof(options) - strlen(options) - 1);
|
||||||
|
@ -136,9 +138,15 @@ bool parseArguments(struct mArguments* args, int argc, char* const* argv, struct
|
||||||
}
|
}
|
||||||
|
|
||||||
void applyArguments(struct mArguments* args, struct mSubParser* subparser, struct mCoreConfig* config) {
|
void applyArguments(struct mArguments* args, struct mSubParser* subparser, struct mCoreConfig* config) {
|
||||||
|
if (args->frameskip >= 0) {
|
||||||
mCoreConfigSetOverrideIntValue(config, "frameskip", args->frameskip);
|
mCoreConfigSetOverrideIntValue(config, "frameskip", args->frameskip);
|
||||||
|
}
|
||||||
|
if (args->logLevel > INT_MIN) {
|
||||||
mCoreConfigSetOverrideIntValue(config, "logLevel", args->logLevel);
|
mCoreConfigSetOverrideIntValue(config, "logLevel", args->logLevel);
|
||||||
|
}
|
||||||
|
if (args->bios) {
|
||||||
mCoreConfigSetOverrideValue(config, "bios", args->bios);
|
mCoreConfigSetOverrideValue(config, "bios", args->bios);
|
||||||
|
}
|
||||||
if (subparser) {
|
if (subparser) {
|
||||||
subparser->apply(subparser, config);
|
subparser->apply(subparser, config);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue