From 23667b3e3907514ce4fb7805b7e1f1560b2fa331 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Wed, 30 Sep 2026 13:12:16 +0900 Subject: [PATCH] Fix screen redraws during effects Normal redraws can overwrite effect frames with gfx_texture, causing brief flashes during fade-out. Suppress redraws while an effect is running and clear pending redraws at effect boundaries. --- src/effect.c | 2 ++ src/gfx_draw.c | 9 ++++++++- src/gfx_private.h | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/effect.c b/src/effect.c index da4ec35..c6e2ee5 100644 --- a/src/effect.c +++ b/src/effect.c @@ -191,6 +191,7 @@ static void eff_init(struct effect *eff, SDL_Rect *rect, EffectTexture *old, Eff if (!eff->is_fullscreen) gfx_updateScreen(); // Flush pending display changes. + gfx_setEffectRunning(true); } static void eff_finish(struct effect *eff, bool present) { @@ -1912,4 +1913,5 @@ void effect_step(struct effect *eff, float progress) { void effect_finish(struct effect *eff) { eff->finish(eff); + gfx_setEffectRunning(false); } diff --git a/src/gfx_draw.c b/src/gfx_draw.c index 1d68599..3c7346d 100644 --- a/src/gfx_draw.c +++ b/src/gfx_draw.c @@ -45,6 +45,7 @@ #include "debugger.h" static bool gfx_dirty; +static bool gfx_effect_running; static void gfx_pal_check(void) { if (nact->ags.pal_changed) { @@ -64,7 +65,7 @@ SDL_Color gfx_getPaletteColor(uint8_t color) { } void gfx_updateScreen(void) { - if (!gfx_dirty) + if (!gfx_dirty || gfx_effect_running) return; SDL_RenderClear(gfx_renderer); SDL_RenderCopy(gfx_renderer, gfx_texture, NULL, NULL); @@ -73,6 +74,12 @@ void gfx_updateScreen(void) { gfx_dirty = false; } +void gfx_setEffectRunning(bool running) { + gfx_effect_running = running; + // Effects present directly. Do not replay pending redraws over their frames. + gfx_dirty = false; +} + void gfx_requestRedraw(void) { gfx_dirty = true; } diff --git a/src/gfx_private.h b/src/gfx_private.h index f0065c2..83d704c 100644 --- a/src/gfx_private.h +++ b/src/gfx_private.h @@ -37,6 +37,8 @@ extern surface_t *gfx_dibinfo; extern int view_w; extern int view_h; +void gfx_setEffectRunning(bool running); + SDL_Surface *gfx_dib_to_surface_with_alpha(int x, int y, int w, int h); SDL_Surface *gfx_dib_to_surface_colorkey(int x, int y, int w, int h, int col);