From: kub Date: Wed, 28 Sep 2022 18:51:19 +0000 (+0000) Subject: platform, fix emu loop timing for vsync enabled X-Git-Tag: v2.00~293 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12ffc469333c8defc7efb503f23a36b5c9718c53;p=picodrive.git platform, fix emu loop timing for vsync enabled --- 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