mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-04 04:50:31 +00:00
Updates the SDL library to the latest standard bugfix release
This commit is contained in:
parent
cb766f2878
commit
083d2175ea
1280 changed files with 343926 additions and 179615 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -49,7 +49,8 @@ typedef struct _SDL_TimerMap
|
|||
} SDL_TimerMap;
|
||||
|
||||
/* The timers are kept in a sorted list */
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
/* Data used by the main thread */
|
||||
SDL_Thread *thread;
|
||||
SDL_atomic_t nextID;
|
||||
|
|
@ -78,14 +79,13 @@ static SDL_TimerData SDL_timer_data;
|
|||
* Timers are removed by simply setting a canceled flag
|
||||
*/
|
||||
|
||||
static void
|
||||
SDL_AddTimerInternal(SDL_TimerData *data, SDL_Timer *timer)
|
||||
static void SDL_AddTimerInternal(SDL_TimerData *data, SDL_Timer *timer)
|
||||
{
|
||||
SDL_Timer *prev, *curr;
|
||||
|
||||
prev = NULL;
|
||||
for (curr = data->timers; curr; prev = curr, curr = curr->next) {
|
||||
if ((Sint32)(timer->scheduled-curr->scheduled) < 0) {
|
||||
if ((Sint32)(timer->scheduled - curr->scheduled) < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -99,8 +99,7 @@ SDL_AddTimerInternal(SDL_TimerData *data, SDL_Timer *timer)
|
|||
timer->next = curr;
|
||||
}
|
||||
|
||||
static int SDLCALL
|
||||
SDL_TimerThread(void *_data)
|
||||
static int SDLCALL SDL_TimerThread(void *_data)
|
||||
{
|
||||
SDL_TimerData *data = (SDL_TimerData *)_data;
|
||||
SDL_Timer *pending;
|
||||
|
|
@ -114,7 +113,7 @@ SDL_TimerThread(void *_data)
|
|||
* 2. Handle any timers that should dispatch this cycle
|
||||
* 3. Wait until next dispatch time or new timer arrives
|
||||
*/
|
||||
for ( ; ; ) {
|
||||
for (;;) {
|
||||
/* Pending and freelist maintenance */
|
||||
SDL_AtomicLock(&data->lock);
|
||||
{
|
||||
|
|
@ -153,7 +152,7 @@ SDL_TimerThread(void *_data)
|
|||
while (data->timers) {
|
||||
current = data->timers;
|
||||
|
||||
if ((Sint32)(tick-current->scheduled) < 0) {
|
||||
if ((Sint32)(tick - current->scheduled) < 0) {
|
||||
/* Scheduled for the future, wait a bit */
|
||||
delay = (current->scheduled - tick);
|
||||
break;
|
||||
|
|
@ -174,7 +173,7 @@ SDL_TimerThread(void *_data)
|
|||
current->scheduled = tick + interval;
|
||||
SDL_AddTimerInternal(data, current);
|
||||
} else {
|
||||
if (!freelist_head) {
|
||||
if (freelist_head == NULL) {
|
||||
freelist_head = current;
|
||||
}
|
||||
if (freelist_tail) {
|
||||
|
|
@ -205,8 +204,7 @@ SDL_TimerThread(void *_data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_TimerInit(void)
|
||||
int SDL_TimerInit(void)
|
||||
{
|
||||
SDL_TimerData *data = &SDL_timer_data;
|
||||
|
||||
|
|
@ -237,14 +235,13 @@ SDL_TimerInit(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TimerQuit(void)
|
||||
void SDL_TimerQuit(void)
|
||||
{
|
||||
SDL_TimerData *data = &SDL_timer_data;
|
||||
SDL_Timer *timer;
|
||||
SDL_TimerMap *entry;
|
||||
|
||||
if (SDL_AtomicCAS(&data->active, 1, 0)) { /* active? Move to inactive. */
|
||||
if (SDL_AtomicCAS(&data->active, 1, 0)) { /* active? Move to inactive. */
|
||||
/* Shutdown the timer thread */
|
||||
if (data->thread) {
|
||||
SDL_SemPost(data->sem);
|
||||
|
|
@ -277,8 +274,7 @@ SDL_TimerQuit(void)
|
|||
}
|
||||
}
|
||||
|
||||
SDL_TimerID
|
||||
SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param)
|
||||
SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param)
|
||||
{
|
||||
SDL_TimerData *data = &SDL_timer_data;
|
||||
SDL_Timer *timer;
|
||||
|
|
@ -302,7 +298,7 @@ SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param)
|
|||
SDL_RemoveTimer(timer->timerID);
|
||||
} else {
|
||||
timer = (SDL_Timer *)SDL_malloc(sizeof(*timer));
|
||||
if (!timer) {
|
||||
if (timer == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -315,7 +311,7 @@ SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param)
|
|||
SDL_AtomicSet(&timer->canceled, 0);
|
||||
|
||||
entry = (SDL_TimerMap *)SDL_malloc(sizeof(*entry));
|
||||
if (!entry) {
|
||||
if (entry == NULL) {
|
||||
SDL_free(timer);
|
||||
SDL_OutOfMemory();
|
||||
return 0;
|
||||
|
|
@ -340,8 +336,7 @@ SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param)
|
|||
return entry->timerID;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_RemoveTimer(SDL_TimerID id)
|
||||
SDL_bool SDL_RemoveTimer(SDL_TimerID id)
|
||||
{
|
||||
SDL_TimerData *data = &SDL_timer_data;
|
||||
SDL_TimerMap *prev, *entry;
|
||||
|
|
@ -375,45 +370,43 @@ SDL_RemoveTimer(SDL_TimerID id)
|
|||
#else
|
||||
|
||||
#include <emscripten/emscripten.h>
|
||||
#include <emscripten/eventloop.h>
|
||||
|
||||
typedef struct _SDL_TimerMap
|
||||
{
|
||||
int timerID;
|
||||
int timeoutID;
|
||||
Uint32 interval;
|
||||
SDL_TimerCallback callback;
|
||||
void *param;
|
||||
struct _SDL_TimerMap *next;
|
||||
} SDL_TimerMap;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int nextID;
|
||||
SDL_TimerMap *timermap;
|
||||
} SDL_TimerData;
|
||||
|
||||
static SDL_TimerData SDL_timer_data;
|
||||
|
||||
static void
|
||||
SDL_Emscripten_TimerHelper(SDL_TimerMap *entry, Uint32 interval, SDL_TimerCallback callback, void *param)
|
||||
static void SDL_Emscripten_TimerHelper(void *userdata)
|
||||
{
|
||||
Uint32 new_timeout;
|
||||
|
||||
new_timeout = callback(interval, param);
|
||||
|
||||
if (new_timeout != 0) {
|
||||
entry->timeoutID = EM_ASM_INT({
|
||||
return Browser.safeSetTimeout(function() {
|
||||
dynCall('viiii', $0, [$1, $2, $3, $4]);
|
||||
}, $2);
|
||||
}, &SDL_Emscripten_TimerHelper, entry, interval, callback, param);
|
||||
SDL_TimerMap *entry = (SDL_TimerMap *)userdata;
|
||||
entry->interval = entry->callback(entry->interval, entry->param);
|
||||
if (entry->interval > 0) {
|
||||
entry->timeoutID = emscripten_set_timeout(&SDL_Emscripten_TimerHelper,
|
||||
entry->interval,
|
||||
entry);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_TimerInit(void)
|
||||
int SDL_TimerInit(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TimerQuit(void)
|
||||
void SDL_TimerQuit(void)
|
||||
{
|
||||
SDL_TimerData *data = &SDL_timer_data;
|
||||
SDL_TimerMap *entry;
|
||||
|
|
@ -425,24 +418,24 @@ SDL_TimerQuit(void)
|
|||
}
|
||||
}
|
||||
|
||||
SDL_TimerID
|
||||
SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param)
|
||||
SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param)
|
||||
{
|
||||
SDL_TimerData *data = &SDL_timer_data;
|
||||
SDL_TimerMap *entry;
|
||||
|
||||
entry = (SDL_TimerMap *)SDL_malloc(sizeof(*entry));
|
||||
if (!entry) {
|
||||
if (entry == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return 0;
|
||||
}
|
||||
entry->timerID = ++data->nextID;
|
||||
entry->callback = callback;
|
||||
entry->param = param;
|
||||
entry->interval = interval;
|
||||
|
||||
entry->timeoutID = EM_ASM_INT({
|
||||
return Browser.safeSetTimeout(function() {
|
||||
dynCall('viiii', $0, [$1, $2, $3, $4]);
|
||||
}, $2);
|
||||
}, &SDL_Emscripten_TimerHelper, entry, interval, callback, param);
|
||||
entry->timeoutID = emscripten_set_timeout(&SDL_Emscripten_TimerHelper,
|
||||
entry->interval,
|
||||
entry);
|
||||
|
||||
entry->next = data->timermap;
|
||||
data->timermap = entry;
|
||||
|
|
@ -450,8 +443,7 @@ SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param)
|
|||
return entry->timerID;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_RemoveTimer(SDL_TimerID id)
|
||||
SDL_bool SDL_RemoveTimer(SDL_TimerID id)
|
||||
{
|
||||
SDL_TimerData *data = &SDL_timer_data;
|
||||
SDL_TimerMap *prev, *entry;
|
||||
|
|
@ -470,9 +462,7 @@ SDL_RemoveTimer(SDL_TimerID id)
|
|||
}
|
||||
|
||||
if (entry) {
|
||||
EM_ASM_({
|
||||
window.clearTimeout($0);
|
||||
}, entry->timeoutID);
|
||||
emscripten_clear_timeout(entry->timeoutID);
|
||||
SDL_free(entry);
|
||||
|
||||
return SDL_TRUE;
|
||||
|
|
@ -486,10 +476,9 @@ SDL_RemoveTimer(SDL_TimerID id)
|
|||
which wraps back to zero every ~49 days. The newer SDL_GetTicks64()
|
||||
doesn't have this problem, so we just wrap that function and clamp to
|
||||
the low 32-bits for binary compatibility. */
|
||||
Uint32
|
||||
SDL_GetTicks(void)
|
||||
Uint32 SDL_GetTicks(void)
|
||||
{
|
||||
return (Uint32) (SDL_GetTicks64() & 0xFFFFFFFF);
|
||||
return (Uint32)(SDL_GetTicks64() & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
#include "SDL_timer.h"
|
||||
|
||||
#define ROUND_RESOLUTION(X) \
|
||||
(((X+TIMER_RESOLUTION-1)/TIMER_RESOLUTION)*TIMER_RESOLUTION)
|
||||
(((X + TIMER_RESOLUTION - 1) / TIMER_RESOLUTION) * TIMER_RESOLUTION)
|
||||
|
||||
extern void SDL_TicksInit(void);
|
||||
extern void SDL_TicksQuit(void);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -26,8 +26,7 @@
|
|||
|
||||
static SDL_bool ticks_started = SDL_FALSE;
|
||||
|
||||
void
|
||||
SDL_TicksInit(void)
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
if (ticks_started) {
|
||||
return;
|
||||
|
|
@ -35,14 +34,12 @@ SDL_TicksInit(void)
|
|||
ticks_started = SDL_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksQuit(void)
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetTicks64(void)
|
||||
Uint64 SDL_GetTicks64(void)
|
||||
{
|
||||
if (!ticks_started) {
|
||||
SDL_TicksInit();
|
||||
|
|
@ -52,20 +49,17 @@ SDL_GetTicks64(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetPerformanceCounter(void)
|
||||
Uint64 SDL_GetPerformanceCounter(void)
|
||||
{
|
||||
return SDL_GetTicks();
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetPerformanceFrequency(void)
|
||||
Uint64 SDL_GetPerformanceFrequency(void)
|
||||
{
|
||||
return 1000;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_Delay(Uint32 ms)
|
||||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -29,8 +29,7 @@
|
|||
static bigtime_t start;
|
||||
static SDL_bool ticks_started = SDL_FALSE;
|
||||
|
||||
void
|
||||
SDL_TicksInit(void)
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
if (ticks_started) {
|
||||
return;
|
||||
|
|
@ -41,36 +40,31 @@ SDL_TicksInit(void)
|
|||
start = system_time();
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksQuit(void)
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetTicks64(void)
|
||||
Uint64 SDL_GetTicks64(void)
|
||||
{
|
||||
if (!ticks_started) {
|
||||
SDL_TicksInit();
|
||||
}
|
||||
|
||||
return (Uint64) ((system_time() - start) / 1000);
|
||||
return (Uint64)((system_time() - start) / 1000);
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetPerformanceCounter(void)
|
||||
Uint64 SDL_GetPerformanceCounter(void)
|
||||
{
|
||||
return system_time();
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetPerformanceFrequency(void)
|
||||
Uint64 SDL_GetPerformanceFrequency(void)
|
||||
{
|
||||
return 1000000;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_Delay(Uint32 ms)
|
||||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
snooze(ms * 1000);
|
||||
}
|
||||
|
|
|
|||
75
Engine/lib/sdl/src/timer/n3ds/SDL_systimer.c
Normal file
75
Engine/lib/sdl/src/timer/n3ds/SDL_systimer.c
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifdef SDL_TIMER_N3DS
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
static SDL_bool ticks_started = SDL_FALSE;
|
||||
static u64 start_tick;
|
||||
|
||||
#define NSEC_PER_MSEC 1000000ULL
|
||||
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
if (ticks_started) {
|
||||
return;
|
||||
}
|
||||
ticks_started = SDL_TRUE;
|
||||
|
||||
start_tick = svcGetSystemTick();
|
||||
}
|
||||
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
|
||||
Uint64 SDL_GetTicks64(void)
|
||||
{
|
||||
u64 elapsed;
|
||||
if (!ticks_started) {
|
||||
SDL_TicksInit();
|
||||
}
|
||||
|
||||
elapsed = svcGetSystemTick() - start_tick;
|
||||
return elapsed / CPU_TICKS_PER_MSEC;
|
||||
}
|
||||
|
||||
Uint64 SDL_GetPerformanceCounter(void)
|
||||
{
|
||||
return svcGetSystemTick();
|
||||
}
|
||||
|
||||
Uint64 SDL_GetPerformanceFrequency(void)
|
||||
{
|
||||
return SYSCLOCK_ARM11;
|
||||
}
|
||||
|
||||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
svcSleepThread(ms * NSEC_PER_MSEC);
|
||||
}
|
||||
|
||||
#endif /* SDL_TIMER_N3DS */
|
||||
|
||||
/* vi: set sts=4 ts=4 sw=4 expandtab: */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -28,42 +28,37 @@
|
|||
#include "SDL_timer.h"
|
||||
|
||||
static SDL_bool ticks_started = SDL_FALSE;
|
||||
static TUint start = 0;
|
||||
static TInt tickPeriodMilliSeconds;
|
||||
static TUint start = 0;
|
||||
static TInt tickPeriodMilliSeconds;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void
|
||||
SDL_TicksInit(void)
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
if (ticks_started)
|
||||
{
|
||||
if (ticks_started) {
|
||||
return;
|
||||
}
|
||||
ticks_started = SDL_TRUE;
|
||||
start = User::TickCount();
|
||||
start = User::TickCount();
|
||||
|
||||
TTimeIntervalMicroSeconds32 period;
|
||||
TInt tmp = UserHal::TickPeriod(period);
|
||||
TInt tmp = UserHal::TickPeriod(period);
|
||||
|
||||
(void)tmp; /* Suppress redundant warning. */
|
||||
|
||||
tickPeriodMilliSeconds = period.Int() / 1000;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksQuit(void)
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetTicks64(void)
|
||||
Uint64 SDL_GetTicks64(void)
|
||||
{
|
||||
if (! ticks_started)
|
||||
{
|
||||
if (!ticks_started) {
|
||||
SDL_TicksInit();
|
||||
}
|
||||
|
||||
|
|
@ -73,20 +68,17 @@ SDL_GetTicks64(void)
|
|||
return (Uint64)(deltaTics * tickPeriodMilliSeconds);
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetPerformanceCounter(void)
|
||||
Uint64 SDL_GetPerformanceCounter(void)
|
||||
{
|
||||
return (Uint64)User::TickCount();
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetPerformanceFrequency(void)
|
||||
Uint64 SDL_GetPerformanceFrequency(void)
|
||||
{
|
||||
return 1000000;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_Delay(Uint32 ms)
|
||||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
User::After(TTimeIntervalMicroSeconds32(ms * 1000));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -43,8 +43,7 @@ static SDL_bool ticks_started = SDL_FALSE;
|
|||
static ULONG ulTmrFreq = 0;
|
||||
static ULLONG ullTmrStart = 0;
|
||||
|
||||
void
|
||||
SDL_TicksInit(void)
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
ULONG ulTmrStart; /* for 32-bit fallback. */
|
||||
ULONG ulRC;
|
||||
|
|
@ -66,18 +65,16 @@ SDL_TicksInit(void)
|
|||
}
|
||||
|
||||
ulTmrFreq = 0; /* Error - use DosQuerySysInfo() for timer. */
|
||||
DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &ulTmrStart, sizeof (ULONG));
|
||||
DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &ulTmrStart, sizeof(ULONG));
|
||||
ullTmrStart = (ULLONG) ulTmrStart;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksQuit(void)
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetTicks64(void)
|
||||
Uint64 SDL_GetTicks64(void)
|
||||
{
|
||||
Uint64 ui64Result;
|
||||
ULLONG ullTmrNow;
|
||||
|
|
@ -92,15 +89,14 @@ SDL_GetTicks64(void)
|
|||
} else {
|
||||
/* note that this counter rolls over to 0 every ~49 days. Fix your system so DosTmrQueryTime works if you need to avoid this. */
|
||||
ULONG ulTmrNow;
|
||||
DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &ulTmrNow, sizeof (ULONG));
|
||||
DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &ulTmrNow, sizeof(ULONG));
|
||||
ui64Result = (((Uint64) ulTmrNow) - ullTmrStart);
|
||||
}
|
||||
|
||||
return ui64Result;
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetPerformanceCounter(void)
|
||||
Uint64 SDL_GetPerformanceCounter(void)
|
||||
{
|
||||
QWORD qwTmrNow;
|
||||
|
||||
|
|
@ -110,14 +106,12 @@ SDL_GetPerformanceCounter(void)
|
|||
return *((Uint64 *)&qwTmrNow);
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetPerformanceFrequency(void)
|
||||
Uint64 SDL_GetPerformanceFrequency(void)
|
||||
{
|
||||
return (ulTmrFreq == 0)? 1000 : (Uint64)ulTmrFreq;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_Delay(Uint32 ms)
|
||||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
HTIMER hTimer = NULLHANDLE;
|
||||
ULONG ulRC;
|
||||
|
|
|
|||
85
Engine/lib/sdl/src/timer/ps2/SDL_systimer.c
Normal file
85
Engine/lib/sdl/src/timer/ps2/SDL_systimer.c
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifdef SDL_TIMER_PS2
|
||||
|
||||
#include "SDL_thread.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_error.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <timer.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
static uint64_t start;
|
||||
static SDL_bool ticks_started = SDL_FALSE;
|
||||
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
if (ticks_started) {
|
||||
return;
|
||||
}
|
||||
ticks_started = SDL_TRUE;
|
||||
|
||||
start = GetTimerSystemTime();
|
||||
}
|
||||
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
|
||||
Uint64 SDL_GetTicks64(void)
|
||||
{
|
||||
uint64_t now;
|
||||
|
||||
if (!ticks_started) {
|
||||
SDL_TicksInit();
|
||||
}
|
||||
|
||||
now = GetTimerSystemTime();
|
||||
return (Uint64)((now - start) / (kBUSCLK / CLOCKS_PER_SEC));
|
||||
}
|
||||
|
||||
Uint64 SDL_GetPerformanceCounter(void)
|
||||
{
|
||||
return SDL_GetTicks64();
|
||||
}
|
||||
|
||||
Uint64 SDL_GetPerformanceFrequency(void)
|
||||
{
|
||||
return 1000;
|
||||
}
|
||||
|
||||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
struct timespec tv = { 0 };
|
||||
tv.tv_sec = ms / 1000;
|
||||
tv.tv_nsec = (ms % 1000) * 1000000;
|
||||
nanosleep(&tv, NULL);
|
||||
}
|
||||
|
||||
#endif /* SDL_TIMER_PS2 */
|
||||
|
||||
/* vim: ts=4 sw=4
|
||||
*/
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -34,8 +34,7 @@
|
|||
static struct timeval start;
|
||||
static SDL_bool ticks_started = SDL_FALSE;
|
||||
|
||||
void
|
||||
SDL_TicksInit(void)
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
if (ticks_started) {
|
||||
return;
|
||||
|
|
@ -45,14 +44,12 @@ SDL_TicksInit(void)
|
|||
gettimeofday(&start, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksQuit(void)
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetTicks64(void)
|
||||
Uint64 SDL_GetTicks64(void)
|
||||
{
|
||||
struct timeval now;
|
||||
|
||||
|
|
@ -64,14 +61,12 @@ SDL_GetTicks64(void)
|
|||
return (Uint64)(((Sint64)(now.tv_sec - start.tv_sec) * 1000) + ((now.tv_usec - start.tv_usec) / 1000));
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetPerformanceCounter(void)
|
||||
Uint64 SDL_GetPerformanceCounter(void)
|
||||
{
|
||||
return SDL_GetTicks64();
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetPerformanceFrequency(void)
|
||||
Uint64 SDL_GetPerformanceFrequency(void)
|
||||
{
|
||||
return 1000;
|
||||
}
|
||||
|
|
@ -79,8 +74,9 @@ SDL_GetPerformanceFrequency(void)
|
|||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
const Uint32 max_delay = 0xffffffffUL / 1000;
|
||||
if(ms > max_delay)
|
||||
if (ms > max_delay) {
|
||||
ms = max_delay;
|
||||
}
|
||||
sceKernelDelayThreadCB(ms * 1000);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -73,8 +73,7 @@ static SDL_bool has_monotonic_time = SDL_FALSE;
|
|||
static struct timeval start_tv;
|
||||
static SDL_bool ticks_started = SDL_FALSE;
|
||||
|
||||
void
|
||||
SDL_TicksInit(void)
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
if (ticks_started) {
|
||||
return;
|
||||
|
|
@ -87,8 +86,7 @@ SDL_TicksInit(void)
|
|||
has_monotonic_time = SDL_TRUE;
|
||||
} else
|
||||
#elif defined(__APPLE__)
|
||||
kern_return_t ret = mach_timebase_info(&mach_base_info);
|
||||
if (ret == 0) {
|
||||
if (mach_timebase_info(&mach_base_info) == 0) {
|
||||
has_monotonic_time = SDL_TRUE;
|
||||
start_mach = mach_absolute_time();
|
||||
} else
|
||||
|
|
@ -98,14 +96,12 @@ SDL_TicksInit(void)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksQuit(void)
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetTicks64(void)
|
||||
Uint64 SDL_GetTicks64(void)
|
||||
{
|
||||
if (!ticks_started) {
|
||||
SDL_TicksInit();
|
||||
|
|
@ -118,7 +114,7 @@ SDL_GetTicks64(void)
|
|||
return (Uint64)(((Sint64)(now.tv_sec - start_ts.tv_sec) * 1000) + ((now.tv_nsec - start_ts.tv_nsec) / 1000000));
|
||||
#elif defined(__APPLE__)
|
||||
const uint64_t now = mach_absolute_time();
|
||||
return ((((now - start_mach) * mach_base_info.numer) / mach_base_info.denom) / 1000000);
|
||||
return (((now - start_mach) * mach_base_info.numer) / mach_base_info.denom) / 1000000;
|
||||
#else
|
||||
SDL_assert(SDL_FALSE);
|
||||
return 0;
|
||||
|
|
@ -130,8 +126,7 @@ SDL_GetTicks64(void)
|
|||
}
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetPerformanceCounter(void)
|
||||
Uint64 SDL_GetPerformanceCounter(void)
|
||||
{
|
||||
Uint64 ticks;
|
||||
if (!ticks_started) {
|
||||
|
|
@ -160,11 +155,10 @@ SDL_GetPerformanceCounter(void)
|
|||
ticks *= 1000000;
|
||||
ticks += now.tv_usec;
|
||||
}
|
||||
return (ticks);
|
||||
return ticks;
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetPerformanceFrequency(void)
|
||||
Uint64 SDL_GetPerformanceFrequency(void)
|
||||
{
|
||||
if (!ticks_started) {
|
||||
SDL_TicksInit();
|
||||
|
|
@ -179,13 +173,12 @@ SDL_GetPerformanceFrequency(void)
|
|||
freq /= mach_base_info.numer;
|
||||
return freq;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 1000000;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_Delay(Uint32 ms)
|
||||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
int was_error;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -34,8 +34,7 @@
|
|||
static uint64_t start;
|
||||
static SDL_bool ticks_started = SDL_FALSE;
|
||||
|
||||
void
|
||||
SDL_TicksInit(void)
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
if (ticks_started) {
|
||||
return;
|
||||
|
|
@ -45,14 +44,12 @@ SDL_TicksInit(void)
|
|||
start = sceKernelGetProcessTimeWide();
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksQuit(void)
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetTicks64(void)
|
||||
Uint64 SDL_GetTicks64(void)
|
||||
{
|
||||
uint64_t now;
|
||||
|
||||
|
|
@ -61,17 +58,15 @@ SDL_GetTicks64(void)
|
|||
}
|
||||
|
||||
now = sceKernelGetProcessTimeWide();
|
||||
return (Uint64) ((now - start) / 1000);
|
||||
return (Uint64)((now - start) / 1000);
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetPerformanceCounter(void)
|
||||
Uint64 SDL_GetPerformanceCounter(void)
|
||||
{
|
||||
return sceKernelGetProcessTimeWide();
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetPerformanceFrequency(void)
|
||||
Uint64 SDL_GetPerformanceFrequency(void)
|
||||
{
|
||||
return 1000000;
|
||||
}
|
||||
|
|
@ -79,8 +74,9 @@ SDL_GetPerformanceFrequency(void)
|
|||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
const Uint32 max_delay = 0xffffffffUL / 1000;
|
||||
if(ms > max_delay)
|
||||
if (ms > max_delay) {
|
||||
ms = max_delay;
|
||||
}
|
||||
sceKernelDelayThreadCB(ms * 1000);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
@ -31,17 +31,16 @@
|
|||
|
||||
/* The first (low-resolution) ticks value of the application */
|
||||
static DWORD start = 0;
|
||||
static BOOL ticks_started = FALSE;
|
||||
static BOOL ticks_started = FALSE;
|
||||
|
||||
/* The first high-resolution ticks value of the application */
|
||||
static LARGE_INTEGER start_ticks;
|
||||
/* The number of ticks per second of the high-resolution performance counter */
|
||||
static LARGE_INTEGER ticks_per_second;
|
||||
|
||||
static void
|
||||
SDL_SetSystemTimerResolution(const UINT uPeriod)
|
||||
static void SDL_SetSystemTimerResolution(const UINT uPeriod)
|
||||
{
|
||||
#ifndef __WINRT__
|
||||
#if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
||||
static UINT timer_period = 0;
|
||||
|
||||
if (uPeriod != timer_period) {
|
||||
|
|
@ -58,8 +57,7 @@ SDL_SetSystemTimerResolution(const UINT uPeriod)
|
|||
#endif
|
||||
}
|
||||
|
||||
static void SDLCALL
|
||||
SDL_TimerResolutionChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
static void SDLCALL SDL_TimerResolutionChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
{
|
||||
UINT uPeriod;
|
||||
|
||||
|
|
@ -74,8 +72,7 @@ SDL_TimerResolutionChanged(void *userdata, const char *name, const char *oldValu
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksInit(void)
|
||||
void SDL_TicksInit(void)
|
||||
{
|
||||
BOOL rc;
|
||||
|
||||
|
|
@ -94,24 +91,22 @@ SDL_TicksInit(void)
|
|||
so we'll rely on it here.
|
||||
*/
|
||||
rc = QueryPerformanceFrequency(&ticks_per_second);
|
||||
SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */
|
||||
SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */
|
||||
QueryPerformanceCounter(&start_ticks);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_TicksQuit(void)
|
||||
void SDL_TicksQuit(void)
|
||||
{
|
||||
SDL_DelHintCallback(SDL_HINT_TIMER_RESOLUTION,
|
||||
SDL_TimerResolutionChanged, NULL);
|
||||
|
||||
SDL_SetSystemTimerResolution(0); /* always release our timer resolution request. */
|
||||
SDL_SetSystemTimerResolution(0); /* always release our timer resolution request. */
|
||||
|
||||
start = 0;
|
||||
ticks_started = SDL_FALSE;
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetTicks64(void)
|
||||
Uint64 SDL_GetTicks64(void)
|
||||
{
|
||||
LARGE_INTEGER now;
|
||||
BOOL rc;
|
||||
|
|
@ -121,30 +116,27 @@ SDL_GetTicks64(void)
|
|||
}
|
||||
|
||||
rc = QueryPerformanceCounter(&now);
|
||||
SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */
|
||||
return (Uint64) (((now.QuadPart - start_ticks.QuadPart) * 1000) / ticks_per_second.QuadPart);
|
||||
SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */
|
||||
return (Uint64)(((now.QuadPart - start_ticks.QuadPart) * 1000) / ticks_per_second.QuadPart);
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetPerformanceCounter(void)
|
||||
Uint64 SDL_GetPerformanceCounter(void)
|
||||
{
|
||||
LARGE_INTEGER counter;
|
||||
const BOOL rc = QueryPerformanceCounter(&counter);
|
||||
SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */
|
||||
return (Uint64) counter.QuadPart;
|
||||
SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */
|
||||
return (Uint64)counter.QuadPart;
|
||||
}
|
||||
|
||||
Uint64
|
||||
SDL_GetPerformanceFrequency(void)
|
||||
Uint64 SDL_GetPerformanceFrequency(void)
|
||||
{
|
||||
LARGE_INTEGER frequency;
|
||||
const BOOL rc = QueryPerformanceFrequency(&frequency);
|
||||
SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */
|
||||
return (Uint64) frequency.QuadPart;
|
||||
SDL_assert(rc != 0); /* this should _never_ fail if you're on XP or later. */
|
||||
return (Uint64)frequency.QuadPart;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_Delay(Uint32 ms)
|
||||
void SDL_Delay(Uint32 ms)
|
||||
{
|
||||
/* Sleep() is not publicly available to apps in early versions of WinRT.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue