From 7bc28a25d846931a784f85e04d130b0e7ebe2971 Mon Sep 17 00:00:00 2001 From: PeachyPeach <72323920+PeachyPeachSM64@users.noreply.github.com> Date: Thu, 20 Nov 2025 02:44:43 +0100 Subject: [PATCH] Fix HOOK_ON_HUD_RENDER rate at 30hz (#1022) --- src/pc/djui/djui.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/pc/djui/djui.c b/src/pc/djui/djui.c index 37145208f..5c79ff3c6 100644 --- a/src/pc/djui/djui.c +++ b/src/pc/djui/djui.c @@ -18,6 +18,8 @@ #include "pc/utils/misc.h" static Gfx* sSavedDisplayListHead = NULL; +static Gfx* sHookHudRenderGfx = NULL; +static size_t sHookHudRenderGfxSize = 0; struct DjuiRoot* gDjuiRoot = NULL; struct DjuiText* gDjuiPauseOptions = NULL; @@ -187,7 +189,23 @@ void djui_render(void) { djui_base_render(&sDjuiRootBehind->base); } - smlua_call_event_hooks(HOOK_ON_HUD_RENDER, djui_reset_hud_params); + // To maintain consistency with other hooks, HOOK_ON_HUD_RENDER must run at 30 fps + // During interpolated frames, copy the generated display list without running the hook again + if (!sDjuiRendered60fps) { + Gfx *hookHudRenderStart = gDisplayListHead; + smlua_call_event_hooks(HOOK_ON_HUD_RENDER, djui_reset_hud_params); + size_t gfxSize = sizeof(Gfx) * (gDisplayListHead - hookHudRenderStart); + if (gfxSize > 0) { + if (gfxSize > sHookHudRenderGfxSize) { + sHookHudRenderGfx = realloc(sHookHudRenderGfx, gfxSize); + } + memcpy(sHookHudRenderGfx, hookHudRenderStart, gfxSize); + } + sHookHudRenderGfxSize = gfxSize; + } else if (sHookHudRenderGfx != NULL && sHookHudRenderGfxSize > 0) { + memcpy(gDisplayListHead, sHookHudRenderGfx, sHookHudRenderGfxSize); + gDisplayListHead += sHookHudRenderGfxSize / sizeof(Gfx); + } djui_panel_update(); djui_popup_update();