From 1a0343b578761e4168f386cbf4ea1c0db68d0d34 Mon Sep 17 00:00:00 2001 From: JaceCear <11230293+JaceCear@users.noreply.github.com> Date: Wed, 15 Apr 2026 20:19:08 +0200 Subject: [PATCH 1/3] Fix an infinite loop that can occur in some builds --- src/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core.c b/src/core.c index fceed3a0fa..da78c7ed82 100644 --- a/src/core.c +++ b/src/core.c @@ -609,9 +609,12 @@ void EngineMainLoop(void) } #endif + // NOTE: If other platforms do V-Sync asynchronously, we may need to incorporate this wait. +#if PLATFORM_GBA // Wait for vblank to finish while (REG_DISPSTAT & DISPSTAT_VBLANK) ; +#endif }; } From 014cdb0d3e4a16e0f2bebe86d5cd25a17fce19ea Mon Sep 17 00:00:00 2001 From: JaceCear <11230293+JaceCear@users.noreply.github.com> Date: Thu, 16 Apr 2026 14:21:13 +0200 Subject: [PATCH 2/3] Simplify in-vblank check --- src/core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/core.c b/src/core.c index da78c7ed82..a5216c549d 100644 --- a/src/core.c +++ b/src/core.c @@ -610,11 +610,9 @@ void EngineMainLoop(void) #endif // NOTE: If other platforms do V-Sync asynchronously, we may need to incorporate this wait. -#if PLATFORM_GBA // Wait for vblank to finish - while (REG_DISPSTAT & DISPSTAT_VBLANK) + while (PLATFORM_GBA && (REG_DISPSTAT & DISPSTAT_VBLANK)) ; -#endif }; } From ac0e50703798b882de85705b533d0afc47c43763 Mon Sep 17 00:00:00 2001 From: JaceCear <11230293+JaceCear@users.noreply.github.com> Date: Thu, 16 Apr 2026 14:26:01 +0200 Subject: [PATCH 3/3] More thorough explanation of the Vblank busy loop --- src/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core.c b/src/core.c index a5216c549d..f2d714331c 100644 --- a/src/core.c +++ b/src/core.c @@ -610,7 +610,8 @@ void EngineMainLoop(void) #endif // NOTE: If other platforms do V-Sync asynchronously, we may need to incorporate this wait. - // Wait for vblank to finish + // + // Wait for vblank to finish, we only compute the frame once the new frame started. while (PLATFORM_GBA && (REG_DISPSTAT & DISPSTAT_VBLANK)) ; };