From 6b1dc161dc5c4ba99498ed175d22ca5d9d65c291 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 20 Apr 2020 13:29:59 +0200 Subject: [PATCH] Use frame counter instead of real clock --- libretro/core-mapper.c | 41 ---------------------------------------- libretro/libretro-core.c | 3 +++ libretro/platform.c | 5 ++++- 3 files changed, 7 insertions(+), 42 deletions(-) diff --git a/libretro/core-mapper.c b/libretro/core-mapper.c index 05a114a..68943cf 100644 --- a/libretro/core-mapper.c +++ b/libretro/core-mapper.c @@ -16,17 +16,6 @@ char DISKA_NAME[512]="\0"; char DISKB_NAME[512]="\0"; char TAPE_NAME[512]="\0"; -//TIME -#ifdef __CELLOS_LV2__ -#include "sys/sys_time.h" -#include "sys/timer.h" -#define usleep sys_timer_usleep -#else -#include -#include -#include -#endif - extern void Screen_SetFullUpdate(int scr); long frame=0; @@ -103,36 +92,6 @@ void retro_set_input_poll(retro_input_poll_t cb) input_poll_cb = cb; } -long GetTicks(void) -{ // in MSec -#ifndef _ANDROID_ - -#ifdef __CELLOS_LV2__ - - //#warning "GetTick PS3\n" - - unsigned long ticks_micro; - uint64_t secs; - uint64_t nsecs; - - sys_time_get_current_time(&secs, &nsecs); - ticks_micro = secs * 1000000UL + (nsecs / 1000); - - return ticks_micro;///1000; -#else - struct timeval tv; - gettimeofday (&tv, NULL); - return (tv.tv_sec*1000000 + tv.tv_usec);///1000; -#endif - -#else - - struct timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); - return (now.tv_sec*1000000 + now.tv_nsec/1000);///1000; -#endif - -} int slowdown=0; #if defined(ANDROID) || defined(__ANDROID__) diff --git a/libretro/libretro-core.c b/libretro/libretro-core.c index 2992e78..420159f 100644 --- a/libretro/libretro-core.c +++ b/libretro/libretro-core.c @@ -31,6 +31,7 @@ int retrojoy_init=0,retro_ui_finalized=0; int retro_sound_finalized=0; float retro_fps=49.8607597; +long long retro_frame_counter; extern int ToggleTV; extern int CURRENT_TV; @@ -621,6 +622,8 @@ void retro_run(void) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) update_variables(); + retro_frame_counter++; + if(pauseg==0){ if (ToggleTV == 1) diff --git a/libretro/platform.c b/libretro/platform.c index 0735303..060760b 100644 --- a/libretro/platform.c +++ b/libretro/platform.c @@ -647,9 +647,12 @@ void PLATFORM_DisplayScreen(void) retro_Render(); } +extern float retro_fps; +extern long long retro_frame_counter; + double PLATFORM_Time(void) { - return GetTicks()/1000 ;//* 1e-3; + return retro_frame_counter * (1000.0 / retro_fps); } void PLATFORM_PaletteUpdate(void)