diff --git a/lib/rt64 b/lib/rt64 index 3ae6485..c9f3819 160000 --- a/lib/rt64 +++ b/lib/rt64 @@ -1 +1 @@ -Subproject commit 3ae6485d70e9899587b2afdb7551b9256f6427be +Subproject commit c9f38195ef1a6d56953957dc2ad84049a146818d diff --git a/patches/input_latency.c b/patches/input_latency.c index 0098192..bec156c 100644 --- a/patches/input_latency.c +++ b/patches/input_latency.c @@ -153,11 +153,16 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx, GameState* gameState) { // @recomp Wait on the VI framebuffer to change if this task has a framebuffer swap. if (scTask->flags & OS_SC_SWAPBUFFER) { - while (osViGetCurrentFramebuffer_recomp() != cfb->fb1) { + int viCounter = 0; + while (osViGetCurrentFramebuffer() != cfb->fb1) { + osRecvMesg(&vi_queue, NULL, OS_MESG_BLOCK); + viCounter++; + } + + // If we didn't wait the full number of VIs needed between frames then wait one extra VI afterwards. + if (viCounter < gameState->framerateDivisor) { osRecvMesg(&vi_queue, NULL, OS_MESG_BLOCK); } - // Wait one extra VI afterwards. - osRecvMesg(&vi_queue, NULL, OS_MESG_BLOCK); } // @recomp Flush any extra messages from the VI queue. diff --git a/patches/patches.h b/patches/patches.h index 21b7c53..c3a0c5b 100644 --- a/patches/patches.h +++ b/patches/patches.h @@ -5,6 +5,7 @@ #define osCreateMesgQueue osCreateMesgQueue_recomp #define osRecvMesg osRecvMesg_recomp #define osSendMesg osSendMesg_recomp +#define osViGetCurrentFramebuffer osViGetCurrentFramebuffer_recomp #define sinf __sinf_recomp #define cosf __cosf_recomp #define gRandFloat sRandFloat