comparison src/timer/macos/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
47 47
48 static double start_tick; 48 static double start_tick;
49 static int is_fast_inited = 0; 49 static int is_fast_inited = 0;
50 50
51 void 51 void
52 SDL_StartTicks (void) 52 SDL_StartTicks(void)
53 { 53 {
54 if (!is_fast_inited) // important to check or FastTime may hang machine! 54 if (!is_fast_inited) // important to check or FastTime may hang machine!
55 SDL_SYS_TimerInit (); 55 SDL_SYS_TimerInit();
56 56
57 start_tick = FastMicroseconds (); 57 start_tick = FastMicroseconds();
58 } 58 }
59 59
60 Uint32 60 Uint32
61 SDL_GetTicks (void) 61 SDL_GetTicks(void)
62 { 62 {
63 63
64 if (!is_fast_inited) 64 if (!is_fast_inited)
65 SDL_SYS_TimerInit (); 65 SDL_SYS_TimerInit();
66 66
67 return FastMilliseconds (); 67 return FastMilliseconds();
68 } 68 }
69 69
70 void 70 void
71 SDL_Delay (Uint32 ms) 71 SDL_Delay(Uint32 ms)
72 { 72 {
73 Uint32 stop, now; 73 Uint32 stop, now;
74 74
75 stop = SDL_GetTicks () + ms; 75 stop = SDL_GetTicks() + ms;
76 do { 76 do {
77 #if TARGET_API_MAC_CARBON 77 #if TARGET_API_MAC_CARBON
78 MPYield (); 78 MPYield();
79 #else 79 #else
80 SystemTask (); 80 SystemTask();
81 #endif 81 #endif
82 82
83 now = SDL_GetTicks (); 83 now = SDL_GetTicks();
84 84
85 } 85 }
86 while (stop > now); 86 while (stop > now);
87 } 87 }
88 88
129 129
130 static ExtendedTimerRec gExtendedTimerRec; 130 static ExtendedTimerRec gExtendedTimerRec;
131 131
132 132
133 int 133 int
134 SDL_SYS_TimerInit (void) 134 SDL_SYS_TimerInit(void)
135 { 135 {
136 FastInitialize (); 136 FastInitialize();
137 is_fast_inited = 1; 137 is_fast_inited = 1;
138 138
139 return (0); 139 return (0);
140 } 140 }
141 141
142 void 142 void
143 SDL_SYS_TimerQuit (void) 143 SDL_SYS_TimerQuit(void)
144 { 144 {
145 /* We don't need a cleanup? */ 145 /* We don't need a cleanup? */
146 return; 146 return;
147 } 147 }
148 148
149 /* Our Stub routine to set up and then call the real routine. */ 149 /* Our Stub routine to set up and then call the real routine. */
150 pascal void 150 pascal void
151 TimerCallbackProc (TMTaskPtr tmTaskPtr) 151 TimerCallbackProc(TMTaskPtr tmTaskPtr)
152 { 152 {
153 Uint32 ms; 153 Uint32 ms;
154 154
155 WakeUpProcess (&((ExtendedTimerPtr) tmTaskPtr)->taskPSN); 155 WakeUpProcess(&((ExtendedTimerPtr) tmTaskPtr)->taskPSN);
156 156
157 ms = SDL_alarm_callback (SDL_alarm_interval); 157 ms = SDL_alarm_callback(SDL_alarm_interval);
158 if (ms) { 158 if (ms) {
159 SDL_alarm_interval = ROUND_RESOLUTION (ms); 159 SDL_alarm_interval = ROUND_RESOLUTION(ms);
160 PrimeTime ((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval); 160 PrimeTime((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval);
161 } else { 161 } else {
162 SDL_alarm_interval = 0; 162 SDL_alarm_interval = 0;
163 } 163 }
164 } 164 }
165 165
166 int 166 int
167 SDL_SYS_StartTimer (void) 167 SDL_SYS_StartTimer(void)
168 { 168 {
169 /* 169 /*
170 * Configure the global structure that stores the timing information. 170 * Configure the global structure that stores the timing information.
171 */ 171 */
172 gExtendedTimerRec.tmTask.qLink = NULL; 172 gExtendedTimerRec.tmTask.qLink = NULL;
173 gExtendedTimerRec.tmTask.qType = 0; 173 gExtendedTimerRec.tmTask.qType = 0;
174 gExtendedTimerRec.tmTask.tmAddr = NewTimerProc (TimerCallbackProc); 174 gExtendedTimerRec.tmTask.tmAddr = NewTimerProc(TimerCallbackProc);
175 gExtendedTimerRec.tmTask.tmCount = 0; 175 gExtendedTimerRec.tmTask.tmCount = 0;
176 gExtendedTimerRec.tmTask.tmWakeUp = 0; 176 gExtendedTimerRec.tmTask.tmWakeUp = 0;
177 gExtendedTimerRec.tmTask.tmReserved = 0; 177 gExtendedTimerRec.tmTask.tmReserved = 0;
178 GetCurrentProcess (&gExtendedTimerRec.taskPSN); 178 GetCurrentProcess(&gExtendedTimerRec.taskPSN);
179 179
180 /* Install the task record */ 180 /* Install the task record */
181 InsXTime ((QElemPtr) & gExtendedTimerRec.tmTask); 181 InsXTime((QElemPtr) & gExtendedTimerRec.tmTask);
182 182
183 /* Go! */ 183 /* Go! */
184 PrimeTime ((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval); 184 PrimeTime((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval);
185 return (0); 185 return (0);
186 } 186 }
187 187
188 void 188 void
189 SDL_SYS_StopTimer (void) 189 SDL_SYS_StopTimer(void)
190 { 190 {
191 RmvTime ((QElemPtr) & gExtendedTimerRec.tmTask); 191 RmvTime((QElemPtr) & gExtendedTimerRec.tmTask);
192 } 192 }
193 193
194 #endif /* SDL_TIMER_MACOS */ 194 #endif /* SDL_TIMER_MACOS */
195 /* vi: set ts=4 sw=4 expandtab: */ 195 /* vi: set ts=4 sw=4 expandtab: */