From 12ffc469333c8defc7efb503f23a36b5c9718c53 Mon Sep 17 00:00:00 2001 From: kub Date: Wed, 28 Sep 2022 18:51:19 +0000 Subject: [PATCH] platform, fix emu loop timing for vsync enabled --- platform/common/emu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/common/emu.c b/platform/common/emu.c index f371f5bc..f44aa5d3 100644 --- a/platform/common/emu.c +++ b/platform/common/emu.c @@ -1381,7 +1381,7 @@ static void emu_loop_prep(void) } /* our tick here is 1 us right now */ -#define ms_to_ticks(x) (unsigned int)(x * 1000) +#define ms_to_ticks(x) (int)(x * 1000) #define get_ticks() plat_get_ticks_us() #define vsync_delay_x3 3*ms_to_ticks(1) @@ -1542,7 +1542,7 @@ void emu_loop(void) // we are too fast plat_video_wait_vsync(); timestamp = get_ticks(); - diff = timestamp * 3 - timestamp_aim_x3; + diff = timestamp_aim_x3 - timestamp * 3; } if (diff > target_frametime_x3 + vsync_delay_x3) { // still too fast -- 2.39.5