all repos — mgba @ 57ad372c782ef6ccd8cb776dca35d20a7076d006

mGBA Game Boy Advance Emulator

GB Video: Fix window y changing mid-window (fixes #1345)
Vicki Pfau vi@endrift.com
Sat, 09 Mar 2019 12:44:11 -0800
commit

57ad372c782ef6ccd8cb776dca35d20a7076d006

parent

837f952230ae3a83bdbfa4f3d459ba0841622daf

M CHANGESCHANGES

@@ -14,6 +14,7 @@ - GB Video: Fix window being enabled mid-scanline (fixes mgba.io/i/1328)

- GB I/O: Filter IE top bits properly (fixes mgba.io/i/1329) - GBA Video: Fix scanline cache with scale factor change edge cases - GBA DMA: Fix DMA0-2 lengths (fixes mgba.io/i/1344) + - GB Video: Fix window y changing mid-window (fixes mgba.io/i/1345) Other fixes: - Qt: More app metadata fixes - Qt: Fix load recent from archive (fixes mgba.io/i/1325)
M src/gb/renderers/software.csrc/gb/renderers/software.c

@@ -220,15 +220,15 @@ struct GBVideoSoftwareRenderer* softwareRenderer = (struct GBVideoSoftwareRenderer*) renderer;

UNUSED(softwareRenderer); } -static void GBVideoSoftwareRendererUpdateWindow(struct GBVideoSoftwareRenderer* renderer, bool before, bool after) { - if (renderer->lastY >= GB_VIDEO_VERTICAL_PIXELS || after == before) { +static void GBVideoSoftwareRendererUpdateWindow(struct GBVideoSoftwareRenderer* renderer, bool before, bool after, uint8_t oldWy) { + if (renderer->lastY >= GB_VIDEO_VERTICAL_PIXELS || !(after || before)) { return; } if (renderer->lastY >= renderer->wy) { if (!after) { renderer->currentWy -= renderer->lastY; renderer->hasWindow = true; - } else { + } else if (!before) { if (!renderer->hasWindow) { if (renderer->lastY > renderer->wy) { renderer->currentWy = GB_VIDEO_VERTICAL_PIXELS;

@@ -241,6 +241,8 @@ }

} else { renderer->currentWy += renderer->lastY; } + } else if (renderer->wy != oldWy) { + renderer->currentWy += oldWy - renderer->wy; } } }

@@ -251,10 +253,11 @@ if (renderer->cache) {

GBVideoCacheWriteVideoRegister(renderer->cache, address, value); } bool wasWindow = _inWindow(softwareRenderer); + uint8_t wy = softwareRenderer->wy; switch (address) { case REG_LCDC: softwareRenderer->lcdc = value; - GBVideoSoftwareRendererUpdateWindow(softwareRenderer, wasWindow, _inWindow(softwareRenderer)); + GBVideoSoftwareRendererUpdateWindow(softwareRenderer, wasWindow, _inWindow(softwareRenderer), wy); break; case REG_SCY: softwareRenderer->scy = value;

@@ -264,11 +267,11 @@ softwareRenderer->scx = value;

break; case REG_WY: softwareRenderer->wy = value; - GBVideoSoftwareRendererUpdateWindow(softwareRenderer, wasWindow, _inWindow(softwareRenderer)); + GBVideoSoftwareRendererUpdateWindow(softwareRenderer, wasWindow, _inWindow(softwareRenderer), wy); break; case REG_WX: softwareRenderer->wx = value; - GBVideoSoftwareRendererUpdateWindow(softwareRenderer, wasWindow, _inWindow(softwareRenderer)); + GBVideoSoftwareRendererUpdateWindow(softwareRenderer, wasWindow, _inWindow(softwareRenderer), wy); break; case REG_BGP: softwareRenderer->lookup[0] = value & 3;