platform, fix emu loop timing for vsync enabled
authorkub <derkub@gmail.com>
Wed, 28 Sep 2022 18:51:19 +0000 (18:51 +0000)
committerkub <derkub@gmail.com>
Wed, 28 Sep 2022 18:51:19 +0000 (18:51 +0000)
platform/common/emu.c

index f371f5b..f44aa5d 100644 (file)
@@ -1381,7 +1381,7 @@ static void emu_loop_prep(void)
 }\r
 \r
 /* our tick here is 1 us right now */\r
-#define ms_to_ticks(x) (unsigned int)(x * 1000)\r
+#define ms_to_ticks(x) (int)(x * 1000)\r
 #define get_ticks() plat_get_ticks_us()\r
 #define vsync_delay_x3 3*ms_to_ticks(1)\r
 \r
@@ -1542,7 +1542,7 @@ void emu_loop(void)
                                // we are too fast\r
                                plat_video_wait_vsync();\r
                                timestamp = get_ticks();\r
-                               diff = timestamp * 3 - timestamp_aim_x3;\r
+                               diff = timestamp_aim_x3 - timestamp * 3;\r
                        }\r
                        if (diff > target_frametime_x3 + vsync_delay_x3) {\r
                                // still too fast\r