From d2e453c256ee0a8e6a88d559b41c8f4f0d9d939f Mon Sep 17 00:00:00 2001 From: Geralt <84459734+MathisMartin31@users.noreply.github.com> Date: Tue, 26 May 2026 06:55:53 +0200 Subject: [PATCH] Prevent bad colors in case `affine_background_set_color` is called twice by mistake (#505) Co-authored-by: MathisMartin31 --- source/affine_background.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/affine_background.c b/source/affine_background.c index 340bc86..da44bbb 100644 --- a/source/affine_background.c +++ b/source/affine_background.c @@ -63,11 +63,13 @@ void affine_background_update() void affine_background_set_color(COLOR color) { - // Reload the palette to reset any previous color scaling + // Reload the palette to reset any previous color scaling. + // Take source color directly from `affine_background_gfxPal` to avoid excessive + // darkening in case this function is called twice by mistake. affine_background_change_background(_background); for (int i = 0; i < AFFINE_BG_PAL_LEN; i++) { - clr_rgbscale(&pal_bg_mem[AFFINE_BG_PB] + i, &pal_bg_mem[AFFINE_BG_PB] + i, 1, color); + clr_rgbscale(&pal_bg_mem[AFFINE_BG_PB] + i, affine_background_gfxPal + i, 1, color); } }