From fdd03e505e7eb3e2475320d1c6854b1f4106c829 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 17 Nov 2021 17:33:18 -0800 Subject: [PATCH] GBA Video: Fix cache updating with proxy and GL renderers --- CHANGES | 1 + src/gba/extra/proxy.c | 4 ++++ src/gba/renderers/gl.c | 8 ++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 326290587..40be45656 100644 --- a/CHANGES +++ b/CHANGES @@ -29,6 +29,7 @@ Other fixes: - GB Video: Fix memory leak when reseting SGB games - GBA: Fix out of bounds ROM accesses on patched ROMs smaller than 32 MiB - GBA: Fix maximum tile ID in caching for 256-color modes + - GBA Video: Fix cache updating with proxy and GL renderers - Libretro: Fix crash when using Game Boy codes (fixes mgba.io/i/2281) - Qt: Fix corrupted savestate and fatal error text - Qt: Fix sprite compositing when sprite tiles go out of bounds (fixes mgba.io/i/2348) diff --git a/src/gba/extra/proxy.c b/src/gba/extra/proxy.c index 1a2c57028..a7f28d153 100644 --- a/src/gba/extra/proxy.c +++ b/src/gba/extra/proxy.c @@ -8,6 +8,7 @@ #include #include #include +#include static void GBAVideoProxyRendererInit(struct GBAVideoRenderer* renderer); static void GBAVideoProxyRendererReset(struct GBAVideoRenderer* renderer); @@ -267,6 +268,9 @@ uint16_t GBAVideoProxyRendererWriteVideoRegister(struct GBAVideoRenderer* render if (address > REG_BLDY) { return value; } + if (renderer->cache) { + GBAVideoCacheWriteVideoRegister(renderer->cache, address, value); + } mVideoLoggerRendererWriteVideoRegister(proxyRenderer->logger, address, value); if (!proxyRenderer->logger->block) { diff --git a/src/gba/renderers/gl.c b/src/gba/renderers/gl.c index 7ab07c2be..2c16943d5 100644 --- a/src/gba/renderers/gl.c +++ b/src/gba/renderers/gl.c @@ -948,6 +948,9 @@ void GBAVideoGLRendererReset(struct GBAVideoRenderer* renderer) { void GBAVideoGLRendererWriteVRAM(struct GBAVideoRenderer* renderer, uint32_t address) { struct GBAVideoGLRenderer* glRenderer = (struct GBAVideoGLRenderer*) renderer; + if (renderer->cache) { + mCacheSetWriteVRAM(renderer->cache, address); + } glRenderer->vramDirty |= 1 << (address >> 12); } @@ -959,8 +962,9 @@ void GBAVideoGLRendererWriteOAM(struct GBAVideoRenderer* renderer, uint32_t oam) void GBAVideoGLRendererWritePalette(struct GBAVideoRenderer* renderer, uint32_t address, uint16_t value) { struct GBAVideoGLRenderer* glRenderer = (struct GBAVideoGLRenderer*) renderer; - UNUSED(address); - UNUSED(value); + if (renderer->cache) { + mCacheSetWritePalette(renderer->cache, address >> 1, mColorFrom555(value)); + } glRenderer->paletteDirty = true; int r = M_R5(value); int g = M_G5(value) << 1;