all repos — mgba @ c73ad72d4106801ffd716b97e25cdc42e8720f44

mGBA Game Boy Advance Emulator

GBA Video: Latch scanline at end of Hblank (fixes #1319)
Vicki Pfau vi@endrift.com
Mon, 27 Jan 2020 18:17:26 -0800
commit

c73ad72d4106801ffd716b97e25cdc42e8720f44

parent

88bb89423699cae986f058786d28cec87ea87809

M CHANGESCHANGES

@@ -8,6 +8,7 @@ - GBA Serialize: Fix serializing DMA transfer register

- GBA Serialize: Fix audio serialization for desynced FIFOs - GBA Serialize: Fix audio DMA timing deserialization - GBA Video: Fix OAM not invalidating after reset (fixes mgba.io/i/1630) + - GBA Video: Latch scanline at end of Hblank (fixes mgba.io/i/1319) Other fixes: - Qt: Only dynamically reset video scale if a game is running - Qt: Fix race condition with proxied video events
M src/gba/renderers/video-software.csrc/gba/renderers/video-software.c

@@ -701,16 +701,16 @@ softwareRenderer->bg[3].sx = softwareRenderer->bg[3].refx;

softwareRenderer->bg[3].sy = softwareRenderer->bg[3].refy; if (softwareRenderer->bg[0].enabled > 0) { - softwareRenderer->bg[0].enabled = 4; + softwareRenderer->bg[0].enabled = 3; } if (softwareRenderer->bg[1].enabled > 0) { - softwareRenderer->bg[1].enabled = 4; + softwareRenderer->bg[1].enabled = 3; } if (softwareRenderer->bg[2].enabled > 0) { - softwareRenderer->bg[2].enabled = 4; + softwareRenderer->bg[2].enabled = 3; } if (softwareRenderer->bg[3].enabled > 0) { - softwareRenderer->bg[3].enabled = 4; + softwareRenderer->bg[3].enabled = 3; } }

@@ -737,7 +737,7 @@ renderer->bg[bg].enabled = 0;

} else if (!wasActive && active) { if (renderer->nextY == 0 || GBARegisterDISPCNTGetMode(renderer->dispcnt) > 2) { // TODO: Investigate in more depth how switching background works in different modes - renderer->bg[bg].enabled = 4; + renderer->bg[bg].enabled = 3; } else { renderer->bg[bg].enabled = 1; }

@@ -811,7 +811,7 @@ }

#define TEST_LAYER_ENABLED(X) \ !renderer->d.disableBG[X] && \ - (renderer->bg[X].enabled == 4 && \ + (renderer->bg[X].enabled == 3 && \ (GBAWindowControlIsBg ## X ## Enable(renderer->currentWindow.packed) || \ (GBARegisterDISPCNTIsObjwinEnable(renderer->dispcnt) && GBAWindowControlIsBg ## X ## Enable (renderer->objwin.packed))) && \ renderer->bg[X].priority == priority)

@@ -919,19 +919,19 @@ renderer->bg[3].sx += renderer->bg[3].dmx;

renderer->bg[3].sy += renderer->bg[3].dmy; } - if (renderer->bg[0].enabled > 0 && renderer->bg[0].enabled < 4) { + if (renderer->bg[0].enabled > 0 && renderer->bg[0].enabled < 3) { ++renderer->bg[0].enabled; DIRTY_SCANLINE(renderer, y); } - if (renderer->bg[1].enabled > 0 && renderer->bg[1].enabled < 4) { + if (renderer->bg[1].enabled > 0 && renderer->bg[1].enabled < 3) { ++renderer->bg[1].enabled; DIRTY_SCANLINE(renderer, y); } - if (renderer->bg[2].enabled > 0 && renderer->bg[2].enabled < 4) { + if (renderer->bg[2].enabled > 0 && renderer->bg[2].enabled < 3) { ++renderer->bg[2].enabled; DIRTY_SCANLINE(renderer, y); } - if (renderer->bg[3].enabled > 0 && renderer->bg[3].enabled < 4) { + if (renderer->bg[3].enabled > 0 && renderer->bg[3].enabled < 3) { ++renderer->bg[3].enabled; DIRTY_SCANLINE(renderer, y); }
M src/gba/video.csrc/gba/video.c

@@ -129,6 +129,10 @@ video->vcount = 0;

} video->p->memory.io[REG_VCOUNT >> 1] = video->vcount; + if (video->vcount < GBA_VIDEO_VERTICAL_PIXELS && video->frameskipCounter <= 0) { + video->renderer->drawScanline(video->renderer, video->vcount); + } + if (video->vcount == GBARegisterDISPSTATGetVcountSetting(dispstat)) { dispstat = GBARegisterDISPSTATFillVcounter(dispstat); if (GBARegisterDISPSTATIsVcounterIRQ(dispstat)) {

@@ -176,9 +180,6 @@ mTimingSchedule(timing, &video->event, VIDEO_HBLANK_LENGTH - cyclesLate);

// Begin Hblank dispstat = GBARegisterDISPSTATFillInHblank(dispstat); - if (video->vcount < GBA_VIDEO_VERTICAL_PIXELS && video->frameskipCounter <= 0) { - video->renderer->drawScanline(video->renderer, video->vcount); - } if (video->vcount < GBA_VIDEO_VERTICAL_PIXELS) { GBADMARunHblank(video->p, -cyclesLate);