Commit b48c030a authored by Vladimir Serbinenko's avatar Vladimir Serbinenko
Browse files

Use libretro pacing rather than real time for pacing

parent 171854c1
...@@ -35,6 +35,7 @@ void retro_poll_event(int joyon); ...@@ -35,6 +35,7 @@ void retro_poll_event(int joyon);
void retro_key_up(int key); void retro_key_up(int key);
void retro_key_down(int key); void retro_key_down(int key);
void retro_loop(void); void retro_loop(void);
void retro_init_time(void);
/* Variables */ /* Variables */
#ifdef _WIN32 #ifdef _WIN32
...@@ -626,6 +627,8 @@ bool retro_load_game(const struct retro_game_info *info) ...@@ -626,6 +627,8 @@ bool retro_load_game(const struct retro_game_info *info)
update_variables(); update_variables();
retro_init_time();
app_init(); app_init();
memset(SNDBUF,0,1024*2*2); memset(SNDBUF,0,1024*2*2);
......
...@@ -36,10 +36,14 @@ ...@@ -36,10 +36,14 @@
#include "MYOSGLUE.h" #include "MYOSGLUE.h"
#include "STRCONST.h" #include "STRCONST.h"
#include "DATE2SEC.h"
extern char RETRO_ROM[512]; extern char RETRO_ROM[512];
extern char RETRO_DIR[512]; extern char RETRO_DIR[512];
LOCALVAR ui5b TimeDelta;
LOCALVAR int64_t current_us;
/* Forward declarations */ /* Forward declarations */
void DoEmulateOneTick(void); void DoEmulateOneTick(void);
blnr InitEmulation(void); blnr InitEmulation(void);
...@@ -1156,9 +1160,21 @@ GLOBALOSGLUPROC DoneWithDrawingForTick(void) ...@@ -1156,9 +1160,21 @@ GLOBALOSGLUPROC DoneWithDrawingForTick(void)
} }
void retro_init_time(void)
{
time_t Current_Time;
struct tm *s;
(void) time(&Current_Time);
s = localtime(&Current_Time);
TimeDelta = Date2MacSeconds(s->tm_sec, s->tm_min, s->tm_hour,
s->tm_mday, 1 + s->tm_mon, 1900 + s->tm_year);
}
//retro loop //retro loop
void retro_loop(void) void retro_loop(void)
{ {
current_us += 1000000 / 60;
if(DSKLOAD==1) if(DSKLOAD==1)
{ {
(void) Sony_Insert1(RPATH, falseblnr); (void) Sony_Insert1(RPATH, falseblnr);
...@@ -1170,15 +1186,8 @@ void retro_loop(void) ...@@ -1170,15 +1186,8 @@ void retro_loop(void)
if (ForceMacOff) if (ForceMacOff)
return; return;
RunOnEndOfSixtieth(); RunOnEndOfSixtieth();
DoEmulateExtraTime(); DoEmulateExtraTime();
#if 0
if (0/*CurSpeedStopped*/)
return;//WaitForTheNextEvent();
DoEmulateExtraTime();
RunOnEndOfSixtieth();
#endif
} }
GLOBALOSGLUPROC WaitForNextTick(void) { } GLOBALOSGLUPROC WaitForNextTick(void) { }
...@@ -1188,13 +1197,9 @@ GLOBALOSGLUPROC WaitForNextTick(void) { } ...@@ -1188,13 +1197,9 @@ GLOBALOSGLUPROC WaitForNextTick(void) { }
LOCALVAR ui5b TrueEmulatedTime = 0; LOCALVAR ui5b TrueEmulatedTime = 0;
LOCALVAR ui5b CurEmulatedTime = 0; LOCALVAR ui5b CurEmulatedTime = 0;
#include "DATE2SEC.h"
#define TicksPerSecond 1000000 #define TicksPerSecond 1000000
LOCALVAR blnr HaveTimeDelta = falseblnr;
LOCALVAR ui5b TimeDelta;
LOCALVAR ui5b NewMacDateInSeconds; LOCALVAR ui5b NewMacDateInSeconds;
LOCALVAR ui5b LastTimeSec; LOCALVAR ui5b LastTimeSec;
...@@ -1202,28 +1207,9 @@ LOCALVAR ui5b LastTimeUsec; ...@@ -1202,28 +1207,9 @@ LOCALVAR ui5b LastTimeUsec;
LOCALPROC GetCurrentTicks(void) LOCALPROC GetCurrentTicks(void)
{ {
struct timeval t; LastTimeSec = current_us / 1000000;
LastTimeUsec = current_us % 1000000;
gettimeofday(&t, NULL); NewMacDateInSeconds = TimeDelta + LastTimeSec;
if (! HaveTimeDelta)
{
time_t Current_Time;
struct tm *s;
(void) time(&Current_Time);
s = localtime(&Current_Time);
TimeDelta = Date2MacSeconds(s->tm_sec, s->tm_min, s->tm_hour,
s->tm_mday, 1 + s->tm_mon, 1900 + s->tm_year) - t.tv_sec;
#if 0 /* how portable is this ? */
CurMacDelta = ((ui5b)(s->tm_gmtoff) & 0x00FFFFFF)
| ((s->tm_isdst ? 0x80 : 0) << 24);
#endif
HaveTimeDelta = trueblnr;
}
NewMacDateInSeconds = t.tv_sec + TimeDelta;
LastTimeSec = (ui5b)t.tv_sec;
LastTimeUsec = (ui5b)t.tv_usec;
} }
#define MyInvTimeStep 16626 /* TicksPerSecond / 60.14742 */ #define MyInvTimeStep 16626 /* TicksPerSecond / 60.14742 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment