mirror of
https://github.com/arnavbhatt288/sdl-2.30.3-kolibri.git
synced 2024-12-22 13:28:48 +01:00
add timer support
Signed-off-by: Arnav Bhatt <arnav@ghativega.in>
This commit is contained in:
parent
0adb12e106
commit
e432f80a05
2
Makefile
2
Makefile
@ -70,7 +70,7 @@ thread_OBJS = src/thread/SDL_thread.o src/thread/generic/SDL_syscond.o \
|
|||||||
src/thread/generic/SDL_sysmutex.o src/thread/generic/SDL_syssem.o \
|
src/thread/generic/SDL_sysmutex.o src/thread/generic/SDL_syssem.o \
|
||||||
src/thread/generic/SDL_systhread.o src/thread/generic/SDL_systls.o
|
src/thread/generic/SDL_systhread.o src/thread/generic/SDL_systls.o
|
||||||
|
|
||||||
timer_OBJS = src/timer/SDL_timer.o src/timer/dummy/SDL_systimer.o
|
timer_OBJS = src/timer/SDL_timer.o src/timer/kolibri/SDL_systimer.o
|
||||||
|
|
||||||
video_OBJS = src/video/SDL_blit_0.o src/video/SDL_blit_1.o src/video/SDL_blit_A.o \
|
video_OBJS = src/video/SDL_blit_0.o src/video/SDL_blit_1.o src/video/SDL_blit_A.o \
|
||||||
src/video/SDL_blit_auto.o src/video/SDL_blit_copy.o src/video/SDL_blit_N.o \
|
src/video/SDL_blit_auto.o src/video/SDL_blit_copy.o src/video/SDL_blit_N.o \
|
||||||
|
@ -92,8 +92,8 @@
|
|||||||
/* Enable the dummy thread support (src/thread/dummy/\*.c) */
|
/* Enable the dummy thread support (src/thread/dummy/\*.c) */
|
||||||
#define SDL_THREADS_DISABLED 1
|
#define SDL_THREADS_DISABLED 1
|
||||||
|
|
||||||
/* Enable the dummy timer support (src/timer/dummy/\*.c) */
|
/* Enable the Kolibri timer support (src/timer/dummy/\*.c) */
|
||||||
#define SDL_TIMER_DUMMY 1
|
#define SDL_TIMER_KOLIBRI 1
|
||||||
|
|
||||||
/* Enable the Kolibri video driver (src/video/kolibri/\*.c) */
|
/* Enable the Kolibri video driver (src/video/kolibri/\*.c) */
|
||||||
#define SDL_VIDEO_DRIVER_KOLIBRI 1
|
#define SDL_VIDEO_DRIVER_KOLIBRI 1
|
||||||
|
54
src/timer/kolibri/SDL_systimer.c
Normal file
54
src/timer/kolibri/SDL_systimer.c
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
|
||||||
|
#include "../../SDL_internal.h"
|
||||||
|
|
||||||
|
#ifdef SDL_TIMER_KOLIBRI
|
||||||
|
|
||||||
|
#include <sys/ksys.h>
|
||||||
|
|
||||||
|
#include "SDL_timer.h"
|
||||||
|
|
||||||
|
static uint64_t start_tick;
|
||||||
|
static SDL_bool ticks_started = SDL_FALSE;
|
||||||
|
|
||||||
|
void SDL_TicksInit(void)
|
||||||
|
{
|
||||||
|
if (ticks_started)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ticks_started = SDL_TRUE;
|
||||||
|
|
||||||
|
/* Set first ticks value */
|
||||||
|
start_tick = _ksys_get_ns_count();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDL_TicksQuit(void)
|
||||||
|
{
|
||||||
|
ticks_started = SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint64 SDL_GetTicks64(void)
|
||||||
|
{
|
||||||
|
uint64_t elapsed;
|
||||||
|
if (!ticks_started) {
|
||||||
|
SDL_TicksInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (Uint64)((_ksys_get_ns_count() - start_tick) / 1000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint64 SDL_GetPerformanceCounter(void)
|
||||||
|
{
|
||||||
|
return _ksys_get_ns_count();
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint64 SDL_GetPerformanceFrequency(void)
|
||||||
|
{
|
||||||
|
return 1000000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDL_Delay(Uint32 ms)
|
||||||
|
{
|
||||||
|
_ksys_delay((uint32_t)(ms / 10 + (ms % 10 > 0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user