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)
- 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)

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);
}
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 @@ static void GBVideoSoftwareRendererUpdateWindow(struct GBVideoSoftwareRenderer*
} else {
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);
}
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 @@ static uint8_t GBVideoSoftwareRendererWriteVideoRegister(struct GBVideoRenderer*
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;