Mercurial > sdl-ios-xcode
comparison src/timer/beos/SDL_systimer.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | 92947e3a18db |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
29 #include "SDL_timer.h" | 29 #include "SDL_timer.h" |
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 SDL_StartTicks(void) | 34 void |
35 SDL_StartTicks (void) | |
35 { | 36 { |
36 /* Set first ticks value */ | 37 /* Set first ticks value */ |
37 start = system_time(); | 38 start = system_time (); |
38 } | 39 } |
39 | 40 |
40 Uint32 SDL_GetTicks(void) | 41 Uint32 |
42 SDL_GetTicks (void) | |
41 { | 43 { |
42 return((system_time()-start)/1000); | 44 return ((system_time () - start) / 1000); |
43 } | 45 } |
44 | 46 |
45 void SDL_Delay(Uint32 ms) | 47 void |
48 SDL_Delay (Uint32 ms) | |
46 { | 49 { |
47 snooze(ms*1000); | 50 snooze (ms * 1000); |
48 } | 51 } |
49 | 52 |
50 /* Data to handle a single periodic alarm */ | 53 /* Data to handle a single periodic alarm */ |
51 static int timer_alive = 0; | 54 static int timer_alive = 0; |
52 static SDL_Thread *timer = NULL; | 55 static SDL_Thread *timer = NULL; |
53 | 56 |
54 static int RunTimer(void *unused) | 57 static int |
58 RunTimer (void *unused) | |
55 { | 59 { |
56 while ( timer_alive ) { | 60 while (timer_alive) { |
57 if ( SDL_timer_running ) { | 61 if (SDL_timer_running) { |
58 SDL_ThreadedTimerCheck(); | 62 SDL_ThreadedTimerCheck (); |
59 } | 63 } |
60 SDL_Delay(10); | 64 SDL_Delay (10); |
61 } | 65 } |
62 return(0); | 66 return (0); |
63 } | 67 } |
64 | 68 |
65 /* This is only called if the event thread is not running */ | 69 /* This is only called if the event thread is not running */ |
66 int SDL_SYS_TimerInit(void) | 70 int |
71 SDL_SYS_TimerInit (void) | |
67 { | 72 { |
68 timer_alive = 1; | 73 timer_alive = 1; |
69 timer = SDL_CreateThread(RunTimer, NULL); | 74 timer = SDL_CreateThread (RunTimer, NULL); |
70 if ( timer == NULL ) | 75 if (timer == NULL) |
71 return(-1); | 76 return (-1); |
72 return(SDL_SetTimerThreaded(1)); | 77 return (SDL_SetTimerThreaded (1)); |
73 } | 78 } |
74 | 79 |
75 void SDL_SYS_TimerQuit(void) | 80 void |
81 SDL_SYS_TimerQuit (void) | |
76 { | 82 { |
77 timer_alive = 0; | 83 timer_alive = 0; |
78 if ( timer ) { | 84 if (timer) { |
79 SDL_WaitThread(timer, NULL); | 85 SDL_WaitThread (timer, NULL); |
80 timer = NULL; | 86 timer = NULL; |
81 } | 87 } |
82 } | 88 } |
83 | 89 |
84 int SDL_SYS_StartTimer(void) | 90 int |
91 SDL_SYS_StartTimer (void) | |
85 { | 92 { |
86 SDL_SetError("Internal logic error: BeOS uses threaded timer"); | 93 SDL_SetError ("Internal logic error: BeOS uses threaded timer"); |
87 return(-1); | 94 return (-1); |
88 } | 95 } |
89 | 96 |
90 void SDL_SYS_StopTimer(void) | 97 void |
98 SDL_SYS_StopTimer (void) | |
91 { | 99 { |
92 return; | 100 return; |
93 } | 101 } |
94 | 102 |
95 #endif /* SDL_TIMER_BEOS */ | 103 #endif /* SDL_TIMER_BEOS */ |
104 /* vi: set ts=4 sw=4 expandtab: */ |