Mercurial > sdl-ios-xcode
comparison src/timer/macos/SDL_MPWtimer.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 |
---|---|
43 #define WideTo64bit(w) (*(UInt64 *) &(w)) | 43 #define WideTo64bit(w) (*(UInt64 *) &(w)) |
44 | 44 |
45 UInt64 start; | 45 UInt64 start; |
46 | 46 |
47 void | 47 void |
48 SDL_StartTicks (void) | 48 SDL_StartTicks(void) |
49 { | 49 { |
50 #ifdef USE_MICROSECONDS | 50 #ifdef USE_MICROSECONDS |
51 UnsignedWide now; | 51 UnsignedWide now; |
52 | 52 |
53 Microseconds (&now); | 53 Microseconds(&now); |
54 start = WideTo64bit (now); | 54 start = WideTo64bit(now); |
55 #else | 55 #else |
56 /* FIXME: Should we implement a wrapping algorithm, like Win32? */ | 56 /* FIXME: Should we implement a wrapping algorithm, like Win32? */ |
57 #endif | 57 #endif |
58 } | 58 } |
59 | 59 |
60 Uint32 | 60 Uint32 |
61 SDL_GetTicks (void) | 61 SDL_GetTicks(void) |
62 { | 62 { |
63 #ifdef USE_MICROSECONDS | 63 #ifdef USE_MICROSECONDS |
64 UnsignedWide now; | 64 UnsignedWide now; |
65 | 65 |
66 Microseconds (&now); | 66 Microseconds(&now); |
67 return (Uint32) ((WideTo64bit (now) - start) / 1000); | 67 return (Uint32) ((WideTo64bit(now) - start) / 1000); |
68 #else | 68 #else |
69 return (LMGetTicks () * MS_PER_TICK); | 69 return (LMGetTicks() * MS_PER_TICK); |
70 #endif | 70 #endif |
71 } | 71 } |
72 | 72 |
73 void | 73 void |
74 SDL_Delay (Uint32 ms) | 74 SDL_Delay(Uint32 ms) |
75 { | 75 { |
76 #ifdef USE_MICROSECONDS | 76 #ifdef USE_MICROSECONDS |
77 Uint32 end_ms; | 77 Uint32 end_ms; |
78 | 78 |
79 end_ms = SDL_GetTicks () + ms; | 79 end_ms = SDL_GetTicks() + ms; |
80 do { | 80 do { |
81 /* FIXME: Yield CPU? */ ; | 81 /* FIXME: Yield CPU? */ ; |
82 } | 82 } |
83 while (SDL_GetTicks () < end_ms); | 83 while (SDL_GetTicks() < end_ms); |
84 #else | 84 #else |
85 UInt32 unused; /* MJS */ | 85 UInt32 unused; /* MJS */ |
86 Delay (ms / MS_PER_TICK, &unused); | 86 Delay(ms / MS_PER_TICK, &unused); |
87 #endif | 87 #endif |
88 } | 88 } |
89 | 89 |
90 | 90 |
91 /* Data to handle a single periodic alarm */ | 91 /* Data to handle a single periodic alarm */ |
97 | 97 |
98 static ExtendedTimerRec gExtendedTimerRec; | 98 static ExtendedTimerRec gExtendedTimerRec; |
99 | 99 |
100 | 100 |
101 int | 101 int |
102 SDL_SYS_TimerInit (void) | 102 SDL_SYS_TimerInit(void) |
103 { | 103 { |
104 /* We don't need a setup? */ | 104 /* We don't need a setup? */ |
105 return (0); | 105 return (0); |
106 } | 106 } |
107 | 107 |
108 void | 108 void |
109 SDL_SYS_TimerQuit (void) | 109 SDL_SYS_TimerQuit(void) |
110 { | 110 { |
111 /* We don't need a cleanup? */ | 111 /* We don't need a cleanup? */ |
112 return; | 112 return; |
113 } | 113 } |
114 | 114 |
115 /* Our Stub routine to set up and then call the real routine. */ | 115 /* Our Stub routine to set up and then call the real routine. */ |
116 pascal void | 116 pascal void |
117 TimerCallbackProc (TMTaskPtr tmTaskPtr) | 117 TimerCallbackProc(TMTaskPtr tmTaskPtr) |
118 { | 118 { |
119 Uint32 ms; | 119 Uint32 ms; |
120 | 120 |
121 WakeUpProcess (&((ExtendedTimerPtr) tmTaskPtr)->taskPSN); | 121 WakeUpProcess(&((ExtendedTimerPtr) tmTaskPtr)->taskPSN); |
122 | 122 |
123 ms = SDL_alarm_callback (SDL_alarm_interval); | 123 ms = SDL_alarm_callback(SDL_alarm_interval); |
124 if (ms) { | 124 if (ms) { |
125 SDL_alarm_interval = ROUND_RESOLUTION (ms); | 125 SDL_alarm_interval = ROUND_RESOLUTION(ms); |
126 PrimeTime ((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval); | 126 PrimeTime((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval); |
127 } else { | 127 } else { |
128 SDL_alarm_interval = 0; | 128 SDL_alarm_interval = 0; |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 int | 132 int |
133 SDL_SYS_StartTimer (void) | 133 SDL_SYS_StartTimer(void) |
134 { | 134 { |
135 /* | 135 /* |
136 * Configure the global structure that stores the timing information. | 136 * Configure the global structure that stores the timing information. |
137 */ | 137 */ |
138 gExtendedTimerRec.tmTask.qLink = NULL; | 138 gExtendedTimerRec.tmTask.qLink = NULL; |
139 gExtendedTimerRec.tmTask.qType = 0; | 139 gExtendedTimerRec.tmTask.qType = 0; |
140 gExtendedTimerRec.tmTask.tmAddr = NewTimerUPP (TimerCallbackProc); | 140 gExtendedTimerRec.tmTask.tmAddr = NewTimerUPP(TimerCallbackProc); |
141 gExtendedTimerRec.tmTask.tmCount = 0; | 141 gExtendedTimerRec.tmTask.tmCount = 0; |
142 gExtendedTimerRec.tmTask.tmWakeUp = 0; | 142 gExtendedTimerRec.tmTask.tmWakeUp = 0; |
143 gExtendedTimerRec.tmTask.tmReserved = 0; | 143 gExtendedTimerRec.tmTask.tmReserved = 0; |
144 GetCurrentProcess (&gExtendedTimerRec.taskPSN); | 144 GetCurrentProcess(&gExtendedTimerRec.taskPSN); |
145 | 145 |
146 /* Install the task record */ | 146 /* Install the task record */ |
147 InsXTime ((QElemPtr) & gExtendedTimerRec.tmTask); | 147 InsXTime((QElemPtr) & gExtendedTimerRec.tmTask); |
148 | 148 |
149 /* Go! */ | 149 /* Go! */ |
150 PrimeTime ((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval); | 150 PrimeTime((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval); |
151 return (0); | 151 return (0); |
152 } | 152 } |
153 | 153 |
154 void | 154 void |
155 SDL_SYS_StopTimer (void) | 155 SDL_SYS_StopTimer(void) |
156 { | 156 { |
157 RmvTime ((QElemPtr) & gExtendedTimerRec.tmTask); | 157 RmvTime((QElemPtr) & gExtendedTimerRec.tmTask); |
158 } | 158 } |
159 | 159 |
160 #endif /* SDL_TIMER_MACOS */ | 160 #endif /* SDL_TIMER_MACOS */ |
161 /* vi: set ts=4 sw=4 expandtab: */ | 161 /* vi: set ts=4 sw=4 expandtab: */ |