sdl12-compat: PresentScreen: clear VideoSurfacePresentTicks before pumping events

From 575b1d3e1bb41f8606d183e0107d2b80db865d0a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Noel?= <[EMAIL REDACTED]>
Date: Thu, 17 Sep 2026 18:21:25 +0200
Subject: [PATCH] PresentScreen: clear VideoSurfacePresentTicks before pumping
 events

 PresentScreen() pumps events when SDL_INIT_EVENTTHREAD is enabled.
 SDL_PumpEvents() can observe an expired VideoSurfacePresentTicks
 and recursively invoke PresentScreen().

 With YUV overlays, the 2nd call consumes and presents the queued
 overlay. After it returns, the original PresentScreen() continues and
 presents the screen again without the overlay, causing visible flicker.
 This can be observed with the intro video in Loki's SC3U

 Clear VideoSurfacePresentTicks before SDL_PumpEvents() since
 PresentScreen() has already committed to presenting the frame.
---
 src/SDL12_compat.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index dae581578..97445c263 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -7273,6 +7273,12 @@ PresentScreen(void)
         return;
     }
 
+    /* We're going to present this frame.
+     *
+     * Clear this before SDL_PumpEvents(), otherwise PumpEvents can recursively call PresentScreen().
+     */
+    VideoSurfacePresentTicks = 0;
+
     /* We don't actually implement an event thread in sdl12-compat, but some
      * games will only call SDL_PeepEvents(), which doesn't otherwise pump
      * events, and get stuck when they've consumed all the events.
@@ -7307,7 +7313,6 @@ PresentScreen(void)
     SDL20_RenderPresent(renderer);
     VideoSurfaceUpdatedInBackgroundThread = SDL_FALSE;
     VideoSurfaceLastPresentTicks = SDL20_GetTicks();
-    VideoSurfacePresentTicks = 0;
 
     UnlockVideoRenderer();
 }