Mercurial > sdl-ios-xcode
comparison src/timer/beos/SDL_systimer.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
30 #include "../SDL_timer_c.h" | 30 #include "../SDL_timer_c.h" |
31 | 31 |
32 static bigtime_t start; | 32 static bigtime_t start; |
33 | 33 |
34 void | 34 void |
35 SDL_StartTicks (void) | 35 SDL_StartTicks(void) |
36 { | 36 { |
37 /* Set first ticks value */ | 37 /* Set first ticks value */ |
38 start = system_time (); | 38 start = system_time(); |
39 } | 39 } |
40 | 40 |
41 Uint32 | 41 Uint32 |
42 SDL_GetTicks (void) | 42 SDL_GetTicks(void) |
43 { | 43 { |
44 return ((system_time () - start) / 1000); | 44 return ((system_time() - start) / 1000); |
45 } | 45 } |
46 | 46 |
47 void | 47 void |
48 SDL_Delay (Uint32 ms) | 48 SDL_Delay(Uint32 ms) |
49 { | 49 { |
50 snooze (ms * 1000); | 50 snooze(ms * 1000); |
51 } | 51 } |
52 | 52 |
53 /* Data to handle a single periodic alarm */ | 53 /* Data to handle a single periodic alarm */ |
54 static int timer_alive = 0; | 54 static int timer_alive = 0; |
55 static SDL_Thread *timer = NULL; | 55 static SDL_Thread *timer = NULL; |
56 | 56 |
57 static int | 57 static int |
58 RunTimer (void *unused) | 58 RunTimer(void *unused) |
59 { | 59 { |
60 while (timer_alive) { | 60 while (timer_alive) { |
61 if (SDL_timer_running) { | 61 if (SDL_timer_running) { |
62 SDL_ThreadedTimerCheck (); | 62 SDL_ThreadedTimerCheck(); |
63 } | 63 } |
64 SDL_Delay (10); | 64 SDL_Delay(10); |
65 } | 65 } |
66 return (0); | 66 return (0); |
67 } | 67 } |
68 | 68 |
69 /* This is only called if the event thread is not running */ | 69 /* This is only called if the event thread is not running */ |
70 int | 70 int |
71 SDL_SYS_TimerInit (void) | 71 SDL_SYS_TimerInit(void) |
72 { | 72 { |
73 timer_alive = 1; | 73 timer_alive = 1; |
74 timer = SDL_CreateThread (RunTimer, NULL); | 74 timer = SDL_CreateThread(RunTimer, NULL); |
75 if (timer == NULL) | 75 if (timer == NULL) |
76 return (-1); | 76 return (-1); |
77 return (SDL_SetTimerThreaded (1)); | 77 return (SDL_SetTimerThreaded(1)); |
78 } | 78 } |
79 | 79 |
80 void | 80 void |
81 SDL_SYS_TimerQuit (void) | 81 SDL_SYS_TimerQuit(void) |
82 { | 82 { |
83 timer_alive = 0; | 83 timer_alive = 0; |
84 if (timer) { | 84 if (timer) { |
85 SDL_WaitThread (timer, NULL); | 85 SDL_WaitThread(timer, NULL); |
86 timer = NULL; | 86 timer = NULL; |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 int | 90 int |
91 SDL_SYS_StartTimer (void) | 91 SDL_SYS_StartTimer(void) |
92 { | 92 { |
93 SDL_SetError ("Internal logic error: BeOS uses threaded timer"); | 93 SDL_SetError("Internal logic error: BeOS uses threaded timer"); |
94 return (-1); | 94 return (-1); |
95 } | 95 } |
96 | 96 |
97 void | 97 void |
98 SDL_SYS_StopTimer (void) | 98 SDL_SYS_StopTimer(void) |
99 { | 99 { |
100 return; | 100 return; |
101 } | 101 } |
102 | 102 |
103 #endif /* SDL_TIMER_BEOS */ | 103 #endif /* SDL_TIMER_BEOS */ |