From 1629eede4ef1cb4cf729da64927245c8f51f6cff Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 21 Oct 2020 21:44:04 -0700 Subject: [PATCH] GB Video: Fix drawing background when window is force-disabled by frontend --- CHANGES | 1 + src/gb/extra/proxy.c | 6 +++--- src/gb/renderers/software.c | 6 ++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index ae415c477..769db0642 100644 --- a/CHANGES +++ b/CHANGES @@ -22,6 +22,7 @@ Emulation fixes: - GB MBC: Fix MBC1 mode changing behavior - GB MBC: Fix some MBC3 bit masking - GB Video: Fix state after skipping BIOS (fixes mgba.io/i/1715 and mgba.io/i/1716) + - GB Video: Fix drawing background when window is force-disabled by frontend - GBA: Fix timing advancing too quickly in rare cases - GBA: Clear GBP connection on reset - GBA Audio: Fix deserializing SOUNDCNT_L diff --git a/src/gb/extra/proxy.c b/src/gb/extra/proxy.c index 4d45155e9..0170d4962 100644 --- a/src/gb/extra/proxy.c +++ b/src/gb/extra/proxy.c @@ -132,15 +132,15 @@ static bool _parsePacket(struct mVideoLogger* logger, const struct mVideoLoggerD } break; case DIRTY_VRAM: - proxyRenderer->backend->disableBG = proxyRenderer->d.disableBG; - proxyRenderer->backend->disableWIN = proxyRenderer->d.disableWIN; - proxyRenderer->backend->disableOBJ = proxyRenderer->d.disableOBJ; if (item->address <= GB_SIZE_VRAM - 0x1000) { logger->readData(logger, &logger->vram[item->address >> 1], 0x1000, true); proxyRenderer->backend->writeVRAM(proxyRenderer->backend, item->address); } break; case DIRTY_SCANLINE: + proxyRenderer->backend->disableBG = proxyRenderer->d.disableBG; + proxyRenderer->backend->disableWIN = proxyRenderer->d.disableWIN; + proxyRenderer->backend->disableOBJ = proxyRenderer->d.disableOBJ; if (item->address < GB_VIDEO_VERTICAL_PIXELS) { proxyRenderer->backend->finishScanline(proxyRenderer->backend, item->address); } diff --git a/src/gb/renderers/software.c b/src/gb/renderers/software.c index 8d2f9db3e..f0436ee85 100644 --- a/src/gb/renderers/software.c +++ b/src/gb/renderers/software.c @@ -540,7 +540,7 @@ static void GBVideoSoftwareRendererDrawRange(struct GBVideoRenderer* renderer, i if (GBRegisterLCDCIsWindow(softwareRenderer->lcdc) && wy == y && wx <= endX) { softwareRenderer->hasWindow = true; } - if (GBRegisterLCDCIsWindow(softwareRenderer->lcdc) && softwareRenderer->hasWindow && wx <= endX) { + if (GBRegisterLCDCIsWindow(softwareRenderer->lcdc) && softwareRenderer->hasWindow && wx <= endX && !softwareRenderer->d.disableWIN) { if (wx > 0 && !softwareRenderer->d.disableBG) { GBVideoSoftwareRendererDrawBackground(softwareRenderer, maps, startX, wx, softwareRenderer->scx - softwareRenderer->offsetScx, softwareRenderer->scy + y - softwareRenderer->offsetScy); } @@ -549,9 +549,7 @@ static void GBVideoSoftwareRendererDrawRange(struct GBVideoRenderer* renderer, i if (GBRegisterLCDCIsWindowTileMap(softwareRenderer->lcdc)) { maps += GB_SIZE_MAP; } - if (!softwareRenderer->d.disableWIN) { - GBVideoSoftwareRendererDrawBackground(softwareRenderer, maps, wx, endX, -wx - softwareRenderer->offsetWx, y - wy - softwareRenderer->offsetWy); - } + GBVideoSoftwareRendererDrawBackground(softwareRenderer, maps, wx, endX, -wx - softwareRenderer->offsetWx, y - wy - softwareRenderer->offsetWy); } else if (!softwareRenderer->d.disableBG) { GBVideoSoftwareRendererDrawBackground(softwareRenderer, maps, startX, endX, softwareRenderer->scx - softwareRenderer->offsetScx, softwareRenderer->scy + y - softwareRenderer->offsetScy); }