From 5edfbfc1f78e15e0ec64e9f71071eda1100b6a4d Mon Sep 17 00:00:00 2001 From: PabloMK7 Date: Tue, 17 Dec 2019 15:00:37 +0100 Subject: [PATCH] Fix stack overflow on screen filters --- .../rosalina/source/menus/screen_filters.c | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/sysmodules/rosalina/source/menus/screen_filters.c b/sysmodules/rosalina/source/menus/screen_filters.c index 53b4eb8..ca7932b 100644 --- a/sysmodules/rosalina/source/menus/screen_filters.c +++ b/sysmodules/rosalina/source/menus/screen_filters.c @@ -55,37 +55,38 @@ typedef struct { u8 z; } Pixel; +static u16 g_c[0x600]; +static Pixel g_px[0x400]; + void applyColorSettings(color_setting_t* cs) { - u16 c[0x600]; - Pixel px[0x400]; u8 i = 0; - memset(c, 0, sizeof(c)); - memset(px, 0, sizeof(px)); + memset(g_c, 0, sizeof(g_c)); + memset(g_px, 0, sizeof(g_px)); do { - px[i].r = i; - px[i].g = i; - px[i].b = i; - px[i].z = 0; + g_px[i].r = i; + g_px[i].g = i; + g_px[i].b = i; + g_px[i].z = 0; } while(++i); do { - *(c + i + 0x000) = px[i].r | (px[i].r << 8); - *(c + i + 0x100) = px[i].g | (px[i].g << 8); - *(c + i + 0x200) = px[i].b | (px[i].b << 8); + *(g_c + i + 0x000) = g_px[i].r | (g_px[i].r << 8); + *(g_c + i + 0x100) = g_px[i].g | (g_px[i].g << 8); + *(g_c + i + 0x200) = g_px[i].b | (g_px[i].b << 8); } while(++i); - colorramp_fill(c + 0x000, c + 0x100, c + 0x200, 0x100, cs); + colorramp_fill(g_c + 0x000, g_c + 0x100, g_c + 0x200, 0x100, cs); do { - px[i].r = *(c + i + 0x000) >> 8; - px[i].g = *(c + i + 0x100) >> 8; - px[i].b = *(c + i + 0x200) >> 8; + g_px[i].r = *(g_c + i + 0x000) >> 8; + g_px[i].g = *(g_c + i + 0x100) >> 8; + g_px[i].b = *(g_c + i + 0x200) >> 8; } while(++i); - writeLut((u32*)px); + writeLut((u32*)g_px); } Menu screenFiltersMenu = {