all repos — mgba @ b309e9894c941771d2dabd9e6fcd7e0dad3af6fc

mGBA Game Boy Advance Emulator

GB Video: Fix video frames getting missed when LCDC is off
Jeffrey Pfau jeffrey@endrift.com
Wed, 21 Sep 2016 14:10:42 -0700
commit

b309e9894c941771d2dabd9e6fcd7e0dad3af6fc

parent

1e10098e337730f580359fb64cc182473412d904

2 files changed, 20 insertions(+), 15 deletions(-)

jump to
M CHANGESCHANGES

@@ -6,6 +6,7 @@ - GBA Cheats: Fix holding onto pointers that may get invalidated

- Qt: Fix "close" button on Overrides view - Qt: Fix saving overrides - FFmpeg: Fix encoding AAC + - GB Video: Fix video frames getting missed when LCDC is off Misc: - All: Only update version info if needed - FFmpeg: Encoding cleanup
M src/gb/video.csrc/gb/video.c

@@ -91,8 +91,10 @@ if (video->nextEvent != INT_MAX) {

video->nextEvent -= cycles; } if (video->nextEvent <= 0) { - if (video->nextEvent != INT_MAX) { + if (video->nextMode != INT_MAX) { video->nextMode -= video->eventDiff; + } + if (video->nextFrame != INT_MAX) { video->nextFrame -= video->eventDiff; } video->nextEvent = INT_MAX;

@@ -116,22 +118,9 @@ }

} else { video->nextMode = GB_VIDEO_HORIZONTAL_LENGTH; video->mode = 1; - --video->frameskipCounter; - if (video->frameskipCounter < 0) { - mCoreSyncPostFrame(video->p->sync); - video->frameskipCounter = video->frameskip; - } - ++video->frameCounter; if (video->nextFrame != 0) { video->nextFrame = 0; - } - - 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 (GBRegisterSTATIsVblankIRQ(video->stat) || GBRegisterSTATIsOAMIRQ(video->stat)) {

@@ -209,6 +198,21 @@ if (video->nextFrame <= 0) {

if (video->p->cpu->executionState == LR35902_CORE_FETCH) { GBFrameEnded(video->p); video->nextFrame = GB_VIDEO_TOTAL_LENGTH; + video->nextEvent = GB_VIDEO_TOTAL_LENGTH; + + --video->frameskipCounter; + if (video->frameskipCounter < 0) { + mCoreSyncPostFrame(video->p->sync); + video->frameskipCounter = video->frameskip; + } + ++video->frameCounter; + + 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); + } struct mCoreThread* thread = mCoreThreadGet(); mCoreThreadFrameStarted(thread); } else {

@@ -296,7 +300,7 @@ }

if (GBRegisterLCDCIsEnable(video->p->memory.io[REG_LCDC]) && !GBRegisterLCDCIsEnable(value)) { video->mode = 0; video->nextMode = INT_MAX; - video->nextEvent = INT_MAX; + video->nextEvent = video->nextFrame; video->stat = GBRegisterSTATSetMode(video->stat, video->mode); video->p->memory.io[REG_STAT] = video->stat; video->ly = 0;