From be8b95f80389718f7d95c6ced9ba2cb3d32108b4 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 31 Mar 2021 23:16:01 -0700 Subject: [PATCH] GBA Video: Fix mode 3-5 overflow with mosaic (fixes #1691) --- CHANGES | 1 + src/gba/renderers/software-bg.c | 17 ++++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index 9fc667493..bffa9dfb4 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ Emulation fixes: - GB Serialize: Fix switching speed modes when loading a state (fixes mgba.io/i/2097) - GBA Memory: Fix loading Thumb savestates when in ARM mode - GBA Video: Fix window start on modes 3-5 with mosaic (fixes mgba.io/i/1690) + - GBA Video: Fix mode 3-5 overflow with mosaic (fixes mgba.io/i/1691) 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 diff --git a/src/gba/renderers/software-bg.c b/src/gba/renderers/software-bg.c index acaf0bbfa..57fc26491 100644 --- a/src/gba/renderers/software-bg.c +++ b/src/gba/renderers/software-bg.c @@ -55,15 +55,14 @@ UNUSED(palette); \ PREPARE_OBJWIN; -#define BACKGROUND_BITMAP_ITERATE(W, H) \ - x += background->dx; \ - y += background->dy; \ - \ - if (x < 0 || y < 0 || (x >> 8) >= W || (y >> 8) >= H) { \ - continue; \ - } \ - localX = x; \ - localY = y; \ +#define BACKGROUND_BITMAP_ITERATE(W, H) \ + x += background->dx; \ + y += background->dy; \ + if ((x < 0 || y < 0 || (x >> 8) >= W || (y >> 8) >= H) && !mosaicWait) { \ + continue; \ + } \ + localX = x; \ + localY = y; #define MODE_2_COORD_OVERFLOW \ localX = x & (sizeAdjusted - 1); \