From 4bb8744cd53ad1496e295542696568d77ad615b3 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 30 Mar 2021 22:39:10 -0700 Subject: [PATCH] GBA Video: Fix mode 5 frame 1 caching (fixes #2075) --- CHANGES | 1 + src/core/bitmap-cache.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index a124eb5ce..d14f07ee1 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,7 @@ Emulation fixes: Other fixes: - GBA: Fix non-USA 1.0 FireRed misdetecting as a ROM hack (fixes mgba.io/i/2100) - GBA: Fix crash when ROM loading fails + - GBA Video: Fix mode 5 frame 1 caching (fixes mgba.io/i/2075) Misc: - GBA: Default-enable VBA bug compat for Ruby and Emerald ROM hacks - Qt: Add ROM filename and size to bug reporter diff --git a/src/core/bitmap-cache.c b/src/core/bitmap-cache.c index 81aa84ffe..6cb14eaf0 100644 --- a/src/core/bitmap-cache.c +++ b/src/core/bitmap-cache.c @@ -139,18 +139,18 @@ void mBitmapCacheCleanRow(struct mBitmapCache* cache, struct mBitmapCacheEntry* return; } - size_t offset = cache->bitsStart[cache->buffer] + y * mBitmapCacheSystemInfoGetWidth(cache->sysConfig); + size_t offset = y * mBitmapCacheSystemInfoGetWidth(cache->sysConfig); void* vram; int bpe = mBitmapCacheSystemInfoGetEntryBPP(cache->sysConfig); uint32_t (*lookupEntry)(void*, uint32_t); switch (bpe) { case 3: lookupEntry = _lookupEntry8; - vram = &cache->vram[offset]; + vram = &cache->vram[offset + cache->bitsStart[cache->buffer]]; break; case 4: lookupEntry = _lookupEntry15; - vram = &cache->vram[offset << 1]; + vram = &cache->vram[offset * 2 + cache->bitsStart[cache->buffer]]; break; default: abort(); @@ -184,4 +184,4 @@ bool mBitmapCacheCheckRow(struct mBitmapCache* cache, const struct mBitmapCacheE const color_t* mBitmapCacheGetRow(struct mBitmapCache* cache, unsigned y) { color_t* row = &cache->cache[(cache->buffer * mBitmapCacheSystemInfoGetHeight(cache->sysConfig) + y) * mBitmapCacheSystemInfoGetWidth(cache->sysConfig)]; return row; -} \ No newline at end of file +}