foxygit / fake-08-xbox360 Log in
commit 8b2810ba193df0734c1dc5d5e5bc20036318fc64
Author:     mrfox <jens.se@icloud.com>
AuthorDate: Wed Nov 25 17:25:33 2026 +0100
Commit:     mrfox <jens.se@icloud.com>
CommitDate: Wed Nov 25 17:25:33 2026 +0100

    xex video: pace frames by the clock while the Guide shows

    Frames that show XAM's surface don't latch at vertical blank, so the
    title ran at ~380 fps under the Guide (Celeste kept playing at 6x).
    They are now held to 60 per second by the time base.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---
 platform/xex/runtime/video.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/platform/xex/runtime/video.c b/platform/xex/runtime/video.c
index 990b163..210bd87 100644
--- a/platform/xex/runtime/video.c
+++ b/platform/xex/runtime/video.c
@@ -488,7 +488,18 @@ static void wait_for_flip(void)
         low_priority_hint();
     }
     if (display.pending_system) {
-        /* XAM's commands have drawn the Guide into its surface */
+        /* XAM's commands have drawn the Guide into its surface. Nothing
+         * latches at vertical blank on this path, so keep one frame per
+         * refresh (60 Hz) by the clock, or the title runs fast under it. */
+        static uint64_t last_system_flip;
+        const uint64_t frame = 49875000ull / 60;
+        uint64_t t = timebase_now();
+        if (last_system_flip && t - last_system_flip < frame) {
+            while (timebase_now() - last_system_flip < frame) low_priority_hint();
+            last_system_flip += frame;
+        } else {
+            last_system_flip = t;
+        }
         show_system_surface();
         display.pending = 0;
         return;