Mercurial > sdl-ios-xcode
comparison src/timer/dc/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 |
---|---|
34 /* | 34 /* |
35 jif = ms * HZ /1000 | 35 jif = ms * HZ /1000 |
36 ms = jif * 1000/HZ | 36 ms = jif * 1000/HZ |
37 */ | 37 */ |
38 | 38 |
39 void SDL_StartTicks(void) | 39 void |
40 SDL_StartTicks (void) | |
40 { | 41 { |
41 /* Set first ticks value */ | 42 /* Set first ticks value */ |
42 start = jiffies; | 43 start = jiffies; |
43 } | 44 } |
44 | 45 |
45 Uint32 SDL_GetTicks(void) | 46 Uint32 |
47 SDL_GetTicks (void) | |
46 { | 48 { |
47 return((jiffies-start)*1000/HZ); | 49 return ((jiffies - start) * 1000 / HZ); |
48 } | 50 } |
49 | 51 |
50 void SDL_Delay(Uint32 ms) | 52 void |
53 SDL_Delay (Uint32 ms) | |
51 { | 54 { |
52 thd_sleep(ms); | 55 thd_sleep (ms); |
53 } | 56 } |
54 | 57 |
55 /* Data to handle a single periodic alarm */ | 58 /* Data to handle a single periodic alarm */ |
56 static int timer_alive = 0; | 59 static int timer_alive = 0; |
57 static SDL_Thread *timer = NULL; | 60 static SDL_Thread *timer = NULL; |
58 | 61 |
59 static int RunTimer(void *unused) | 62 static int |
63 RunTimer (void *unused) | |
60 { | 64 { |
61 while ( timer_alive ) { | 65 while (timer_alive) { |
62 if ( SDL_timer_running ) { | 66 if (SDL_timer_running) { |
63 SDL_ThreadedTimerCheck(); | 67 SDL_ThreadedTimerCheck (); |
64 } | 68 } |
65 SDL_Delay(10); | 69 SDL_Delay (10); |
66 } | 70 } |
67 return(0); | 71 return (0); |
68 } | 72 } |
69 | 73 |
70 /* This is only called if the event thread is not running */ | 74 /* This is only called if the event thread is not running */ |
71 int SDL_SYS_TimerInit(void) | 75 int |
76 SDL_SYS_TimerInit (void) | |
72 { | 77 { |
73 timer_alive = 1; | 78 timer_alive = 1; |
74 timer = SDL_CreateThread(RunTimer, NULL); | 79 timer = SDL_CreateThread (RunTimer, NULL); |
75 if ( timer == NULL ) | 80 if (timer == NULL) |
76 return(-1); | 81 return (-1); |
77 return(SDL_SetTimerThreaded(1)); | 82 return (SDL_SetTimerThreaded (1)); |
78 } | 83 } |
79 | 84 |
80 void SDL_SYS_TimerQuit(void) | 85 void |
86 SDL_SYS_TimerQuit (void) | |
81 { | 87 { |
82 timer_alive = 0; | 88 timer_alive = 0; |
83 if ( timer ) { | 89 if (timer) { |
84 SDL_WaitThread(timer, NULL); | 90 SDL_WaitThread (timer, NULL); |
85 timer = NULL; | 91 timer = NULL; |
86 } | 92 } |
87 } | 93 } |
88 | 94 |
89 int SDL_SYS_StartTimer(void) | 95 int |
96 SDL_SYS_StartTimer (void) | |
90 { | 97 { |
91 SDL_SetError("Internal logic error: DC uses threaded timer"); | 98 SDL_SetError ("Internal logic error: DC uses threaded timer"); |
92 return(-1); | 99 return (-1); |
93 } | 100 } |
94 | 101 |
95 void SDL_SYS_StopTimer(void) | 102 void |
103 SDL_SYS_StopTimer (void) | |
96 { | 104 { |
97 return; | 105 return; |
98 } | 106 } |
99 | 107 |
100 #endif /* SDL_TIMER_DC */ | 108 #endif /* SDL_TIMER_DC */ |
109 /* vi: set ts=4 sw=4 expandtab: */ |