GB Video: Fix window y changing mid-window (fixes #1345)

This commit is contained in:
Vicki Pfau 2019-03-09 12:44:11 -08:00
parent 837f952230
commit 57ad372c78
9 changed files with 10 additions and 6 deletions

View File

@ -14,6 +14,7 @@ Emulation fixes:
- GB I/O: Filter IE top bits properly (fixes mgba.io/i/1329) - 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 Video: Fix scanline cache with scale factor change edge cases
- GBA DMA: Fix DMA0-2 lengths (fixes mgba.io/i/1344) - 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: Other fixes:
- Qt: More app metadata fixes - Qt: More app metadata fixes
- Qt: Fix load recent from archive (fixes mgba.io/i/1325) - Qt: Fix load recent from archive (fixes mgba.io/i/1325)

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

View File

@ -220,15 +220,15 @@ static void GBVideoSoftwareRendererDeinit(struct GBVideoRenderer* renderer) {
UNUSED(softwareRenderer); UNUSED(softwareRenderer);
} }
static void GBVideoSoftwareRendererUpdateWindow(struct GBVideoSoftwareRenderer* renderer, bool before, bool after) { static void GBVideoSoftwareRendererUpdateWindow(struct GBVideoSoftwareRenderer* renderer, bool before, bool after, uint8_t oldWy) {
if (renderer->lastY >= GB_VIDEO_VERTICAL_PIXELS || after == before) { if (renderer->lastY >= GB_VIDEO_VERTICAL_PIXELS || !(after || before)) {
return; return;
} }
if (renderer->lastY >= renderer->wy) { if (renderer->lastY >= renderer->wy) {
if (!after) { if (!after) {
renderer->currentWy -= renderer->lastY; renderer->currentWy -= renderer->lastY;
renderer->hasWindow = true; renderer->hasWindow = true;
} else { } else if (!before) {
if (!renderer->hasWindow) { if (!renderer->hasWindow) {
if (renderer->lastY > renderer->wy) { if (renderer->lastY > renderer->wy) {
renderer->currentWy = GB_VIDEO_VERTICAL_PIXELS; renderer->currentWy = GB_VIDEO_VERTICAL_PIXELS;
@ -241,6 +241,8 @@ static void GBVideoSoftwareRendererUpdateWindow(struct GBVideoSoftwareRenderer*
} else { } else {
renderer->currentWy += renderer->lastY; renderer->currentWy += renderer->lastY;
} }
} else if (renderer->wy != oldWy) {
renderer->currentWy += oldWy - renderer->wy;
} }
} }
} }
@ -251,10 +253,11 @@ static uint8_t GBVideoSoftwareRendererWriteVideoRegister(struct GBVideoRenderer*
GBVideoCacheWriteVideoRegister(renderer->cache, address, value); GBVideoCacheWriteVideoRegister(renderer->cache, address, value);
} }
bool wasWindow = _inWindow(softwareRenderer); bool wasWindow = _inWindow(softwareRenderer);
uint8_t wy = softwareRenderer->wy;
switch (address) { switch (address) {
case REG_LCDC: case REG_LCDC:
softwareRenderer->lcdc = value; softwareRenderer->lcdc = value;
GBVideoSoftwareRendererUpdateWindow(softwareRenderer, wasWindow, _inWindow(softwareRenderer)); GBVideoSoftwareRendererUpdateWindow(softwareRenderer, wasWindow, _inWindow(softwareRenderer), wy);
break; break;
case REG_SCY: case REG_SCY:
softwareRenderer->scy = value; softwareRenderer->scy = value;
@ -264,11 +267,11 @@ static uint8_t GBVideoSoftwareRendererWriteVideoRegister(struct GBVideoRenderer*
break; break;
case REG_WY: case REG_WY:
softwareRenderer->wy = value; softwareRenderer->wy = value;
GBVideoSoftwareRendererUpdateWindow(softwareRenderer, wasWindow, _inWindow(softwareRenderer)); GBVideoSoftwareRendererUpdateWindow(softwareRenderer, wasWindow, _inWindow(softwareRenderer), wy);
break; break;
case REG_WX: case REG_WX:
softwareRenderer->wx = value; softwareRenderer->wx = value;
GBVideoSoftwareRendererUpdateWindow(softwareRenderer, wasWindow, _inWindow(softwareRenderer)); GBVideoSoftwareRendererUpdateWindow(softwareRenderer, wasWindow, _inWindow(softwareRenderer), wy);
break; break;
case REG_BGP: case REG_BGP:
softwareRenderer->lookup[0] = value & 3; softwareRenderer->lookup[0] = value & 3;