early-access version 2281

This commit is contained in:
pineappleEA
2021-12-07 02:20:09 +01:00
parent c2ae6d480a
commit c4fa174d53
591 changed files with 36978 additions and 18653 deletions
+12 -15
View File
@@ -104,10 +104,9 @@ SDL_TicksQuit(void)
ticks_started = SDL_FALSE;
}
Uint32
SDL_GetTicks(void)
Uint64
SDL_GetTicks64(void)
{
Uint32 ticks;
if (!ticks_started) {
SDL_TicksInit();
}
@@ -116,21 +115,19 @@ SDL_GetTicks(void)
#if HAVE_CLOCK_GETTIME
struct timespec now;
clock_gettime(SDL_MONOTONIC_CLOCK, &now);
ticks = (Uint32)((now.tv_sec - start_ts.tv_sec) * 1000 + (now.tv_nsec - start_ts.tv_nsec) / 1000000);
return (Uint64)(((Sint64)(now.tv_sec - start_ts.tv_sec) * 1000) + ((now.tv_nsec - start_ts.tv_nsec) / 1000000));
#elif defined(__APPLE__)
uint64_t now = mach_absolute_time();
ticks = (Uint32)((((now - start_mach) * mach_base_info.numer) / mach_base_info.denom) / 1000000);
const uint64_t now = mach_absolute_time();
return ((((now - start_mach) * mach_base_info.numer) / mach_base_info.denom) / 1000000);
#else
SDL_assert(SDL_FALSE);
ticks = 0;
return 0;
#endif
} else {
struct timeval now;
gettimeofday(&now, NULL);
ticks = (Uint32)((now.tv_sec - start_tv.tv_sec) * 1000 + (now.tv_usec - start_tv.tv_usec) / 1000);
return (Uint64)(((Sint64)(now.tv_sec - start_tv.tv_sec) * 1000) + ((now.tv_usec - start_tv.tv_usec) / 1000));
}
return (ticks);
}
Uint64
@@ -203,7 +200,7 @@ SDL_Delay(Uint32 ms)
struct timespec elapsed, tv;
#else
struct timeval tv;
Uint32 then, now, elapsed;
Uint64 then, now, elapsed;
#endif
/* Set the timeout interval */
@@ -211,7 +208,7 @@ SDL_Delay(Uint32 ms)
elapsed.tv_sec = ms / 1000;
elapsed.tv_nsec = (ms % 1000) * 1000000;
#else
then = SDL_GetTicks();
then = SDL_GetTicks64();
#endif
do {
errno = 0;
@@ -222,13 +219,13 @@ SDL_Delay(Uint32 ms)
was_error = nanosleep(&tv, &elapsed);
#else
/* Calculate the time interval left (in case of interrupt) */
now = SDL_GetTicks();
now = SDL_GetTicks64();
elapsed = (now - then);
then = now;
if (elapsed >= ms) {
if (elapsed >= ((Uint64)ms)) {
break;
}
ms -= elapsed;
ms -= (Uint32)elapsed;
tv.tv_sec = ms / 1000;
tv.tv_usec = (ms % 1000) * 1000;