From 5ae5cf110d722c751a3fbfec38ec8f4498a85616 Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Tue, 25 May 2021 04:03:11 -0400 Subject: [PATCH 1/2] [LEAK-INFORMED] fix fakematch in DrawWallpaper --- src/pokemon_storage_system.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index e5720d914..a7a418a30 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -5437,19 +5437,20 @@ static bool32 WaitForWallpaperGfxLoad(void) static void DrawWallpaper(const void *tilemap, s8 direction, u8 offset) { - s16 var = (offset * 2) + 3; + s16 var = offset * 256; + s16 var2 = (offset * 2) + 3; s16 x = ((sStorage->bg2_X / 8 + 10) + (direction * 24)) & 0x3F; - CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 0x14, 0x12, x, 2, 0x14, 0x12, 0x11, offset << 8, var); - - if (direction == 0) - return; - if (direction > 0) - x *= 1, x += 0x14; // x * 1 is needed to match, but can be safely removed as it makes no functional difference - else - x -= 4; + CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 0x14, 0x12, x, 2, 0x14, 0x12, 0x11, var, var2); + if (direction) + { + if (direction > 0) + x += 0x14; + else + x -= 4; FillBgTilemapBufferRect(2, 0, x, 2, 4, 0x12, 0x11); + } } static void TrimOldWallpaper(void *tilemap) From 5d5327c0b73784c47d18734a291b5463289ca9c5 Mon Sep 17 00:00:00 2001 From: Kurausukun Date: Tue, 25 May 2021 04:32:47 -0400 Subject: [PATCH 2/2] better match --- src/pokemon_storage_system.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index a7a418a30..c82caf0b0 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -5443,14 +5443,14 @@ static void DrawWallpaper(const void *tilemap, s8 direction, u8 offset) CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 0x14, 0x12, x, 2, 0x14, 0x12, 0x11, var, var2); - if (direction) - { - if (direction > 0) - x += 0x14; - else - x -= 4; + if (direction == 0) + return; + if (direction > 0) + x += 0x14; + else + x -= 4; + FillBgTilemapBufferRect(2, 0, x, 2, 4, 0x12, 0x11); - } } static void TrimOldWallpaper(void *tilemap)