all repos — mgba @ b25ed450a8789f502725de3a88eb367a808eaa4e

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

b25ed450a8789f502725de3a88eb367a808eaa4e

parent

040bd516c7b6b1d798a526fc2c9a93436c8018d7

M CHANGESCHANGES

@@ -2,6 +2,7 @@ 0.7.2: (Future)

Emulation fixes: - 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

@@ -218,15 +218,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;

@@ -236,6 +236,8 @@ }

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

@@ -246,10 +248,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;

@@ -259,11 +262,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;