author | Ryan C. Gordon |
Thu, 14 Nov 2013 11:51:24 -0500 | |
changeset 7981 | 6d538bc1b395 |
parent 7649 | src/timer/beos/SDL_systimer.c@4f801cd08f3f |
child 8093 | b43765095a6f |
permissions | -rw-r--r-- |
slouken@0 | 1 |
/* |
slouken@5535 | 2 |
Simple DirectMedia Layer |
slouken@6885 | 3 |
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org> |
slouken@0 | 4 |
|
slouken@5535 | 5 |
This software is provided 'as-is', without any express or implied |
slouken@5535 | 6 |
warranty. In no event will the authors be held liable for any damages |
slouken@5535 | 7 |
arising from the use of this software. |
slouken@0 | 8 |
|
slouken@5535 | 9 |
Permission is granted to anyone to use this software for any purpose, |
slouken@5535 | 10 |
including commercial applications, and to alter it and redistribute it |
slouken@5535 | 11 |
freely, subject to the following restrictions: |
slouken@0 | 12 |
|
slouken@5535 | 13 |
1. The origin of this software must not be misrepresented; you must not |
slouken@5535 | 14 |
claim that you wrote the original software. If you use this software |
slouken@5535 | 15 |
in a product, an acknowledgment in the product documentation would be |
slouken@5535 | 16 |
appreciated but is not required. |
slouken@5535 | 17 |
2. Altered source versions must be plainly marked as such, and must not be |
slouken@5535 | 18 |
misrepresented as being the original software. |
slouken@5535 | 19 |
3. This notice may not be removed or altered from any source distribution. |
slouken@0 | 20 |
*/ |
slouken@1402 | 21 |
#include "SDL_config.h" |
slouken@0 | 22 |
|
icculus@7981 | 23 |
#ifdef SDL_TIMER_HAIKU |
slouken@1635 | 24 |
|
icculus@7981 | 25 |
#include <os/kernel/OS.h> |
slouken@0 | 26 |
|
slouken@0 | 27 |
#include "SDL_timer.h" |
slouken@0 | 28 |
|
slouken@0 | 29 |
static bigtime_t start; |
urkle@7649 | 30 |
static SDL_bool ticks_started = SDL_FALSE; |
slouken@0 | 31 |
|
slouken@1895 | 32 |
void |
urkle@7649 | 33 |
SDL_InitTicks(void) |
slouken@0 | 34 |
{ |
urkle@7649 | 35 |
if (ticks_started) { |
urkle@7649 | 36 |
return; |
urkle@7649 | 37 |
} |
urkle@7649 | 38 |
ticks_started = SDL_TRUE; |
urkle@7649 | 39 |
|
slouken@1895 | 40 |
/* Set first ticks value */ |
slouken@1895 | 41 |
start = system_time(); |
slouken@0 | 42 |
} |
slouken@0 | 43 |
|
slouken@1895 | 44 |
Uint32 |
slouken@1895 | 45 |
SDL_GetTicks(void) |
slouken@0 | 46 |
{ |
urkle@7649 | 47 |
if (!ticks_started) { |
urkle@7649 | 48 |
SDL_InitTicks(); |
urkle@7649 | 49 |
} |
urkle@7649 | 50 |
|
slouken@1895 | 51 |
return ((system_time() - start) / 1000); |
slouken@0 | 52 |
} |
slouken@0 | 53 |
|
slouken@5514 | 54 |
Uint64 |
slouken@5514 | 55 |
SDL_GetPerformanceCounter(void) |
slouken@5514 | 56 |
{ |
slouken@5514 | 57 |
return system_time(); |
slouken@5514 | 58 |
} |
slouken@5514 | 59 |
|
slouken@5514 | 60 |
Uint64 |
slouken@5514 | 61 |
SDL_GetPerformanceFrequency(void) |
slouken@5514 | 62 |
{ |
slouken@5514 | 63 |
return 1000000; |
slouken@5514 | 64 |
} |
slouken@5514 | 65 |
|
slouken@1895 | 66 |
void |
slouken@1895 | 67 |
SDL_Delay(Uint32 ms) |
slouken@0 | 68 |
{ |
slouken@1895 | 69 |
snooze(ms * 1000); |
slouken@0 | 70 |
} |
slouken@0 | 71 |
|
icculus@7981 | 72 |
#endif /* SDL_TIMER_HAIKU */ |
slouken@0 | 73 |
|
slouken@1895 | 74 |
/* vi: set ts=4 sw=4 expandtab: */ |