Mercurial > sdl-ios-xcode
diff src/timer/macos/SDL_systimer.c @ 1895:c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 10 Jul 2006 21:04:37 +0000 |
parents | 1834c192d89f |
children |
line wrap: on
line diff
--- a/src/timer/macos/SDL_systimer.c Thu Jul 06 18:01:37 2006 +0000 +++ b/src/timer/macos/SDL_systimer.c Mon Jul 10 21:04:37 2006 +0000 @@ -40,46 +40,50 @@ #define NewTimerProc NewTimerUPP #endif -#define MS_PER_TICK (1000.0/60.0) /* MacOS tick = 1/60 second */ +#define MS_PER_TICK (1000.0/60.0) /* MacOS tick = 1/60 second */ -#define kTwoPower32 (4294967296.0) /* 2^32 */ +#define kTwoPower32 (4294967296.0) /* 2^32 */ static double start_tick; -static int is_fast_inited = 0; +static int is_fast_inited = 0; -void SDL_StartTicks(void) +void +SDL_StartTicks(void) { - if ( ! is_fast_inited ) // important to check or FastTime may hang machine! - SDL_SYS_TimerInit(); + if (!is_fast_inited) // important to check or FastTime may hang machine! + SDL_SYS_TimerInit(); - start_tick = FastMicroseconds(); + start_tick = FastMicroseconds(); } -Uint32 SDL_GetTicks(void) +Uint32 +SDL_GetTicks(void) { - - if ( ! is_fast_inited ) - SDL_SYS_TimerInit(); - - return FastMilliseconds(); + + if (!is_fast_inited) + SDL_SYS_TimerInit(); + + return FastMilliseconds(); } -void SDL_Delay(Uint32 ms) +void +SDL_Delay(Uint32 ms) { - Uint32 stop, now; + Uint32 stop, now; - stop = SDL_GetTicks() + ms; - do { - #if TARGET_API_MAC_CARBON - MPYield(); - #else - SystemTask(); - #endif + stop = SDL_GetTicks() + ms; + do { +#if TARGET_API_MAC_CARBON + MPYield(); +#else + SystemTask(); +#endif - now = SDL_GetTicks(); + now = SDL_GetTicks(); - } while ( stop > now ); + } + while (stop > now); } /* @@ -115,72 +119,77 @@ } }*/ - + /* Data to handle a single periodic alarm */ typedef struct _ExtendedTimerRec { - TMTask tmTask; - ProcessSerialNumber taskPSN; + TMTask tmTask; + ProcessSerialNumber taskPSN; } ExtendedTimerRec, *ExtendedTimerPtr; static ExtendedTimerRec gExtendedTimerRec; -int SDL_SYS_TimerInit(void) +int +SDL_SYS_TimerInit(void) { - FastInitialize (); - is_fast_inited = 1; - - return(0); + FastInitialize(); + is_fast_inited = 1; + + return (0); } -void SDL_SYS_TimerQuit(void) +void +SDL_SYS_TimerQuit(void) { - /* We don't need a cleanup? */ - return; + /* We don't need a cleanup? */ + return; } /* Our Stub routine to set up and then call the real routine. */ -pascal void TimerCallbackProc(TMTaskPtr tmTaskPtr) +pascal void +TimerCallbackProc(TMTaskPtr tmTaskPtr) { - Uint32 ms; + Uint32 ms; - WakeUpProcess(&((ExtendedTimerPtr) tmTaskPtr)->taskPSN); + WakeUpProcess(&((ExtendedTimerPtr) tmTaskPtr)->taskPSN); - ms = SDL_alarm_callback(SDL_alarm_interval); - if ( ms ) { - SDL_alarm_interval = ROUND_RESOLUTION(ms); - PrimeTime((QElemPtr)&gExtendedTimerRec.tmTask, - SDL_alarm_interval); - } else { - SDL_alarm_interval = 0; - } + ms = SDL_alarm_callback(SDL_alarm_interval); + if (ms) { + SDL_alarm_interval = ROUND_RESOLUTION(ms); + PrimeTime((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval); + } else { + SDL_alarm_interval = 0; + } } -int SDL_SYS_StartTimer(void) +int +SDL_SYS_StartTimer(void) { - /* - * Configure the global structure that stores the timing information. - */ - gExtendedTimerRec.tmTask.qLink = NULL; - gExtendedTimerRec.tmTask.qType = 0; - gExtendedTimerRec.tmTask.tmAddr = NewTimerProc(TimerCallbackProc); - gExtendedTimerRec.tmTask.tmCount = 0; - gExtendedTimerRec.tmTask.tmWakeUp = 0; - gExtendedTimerRec.tmTask.tmReserved = 0; - GetCurrentProcess(&gExtendedTimerRec.taskPSN); + /* + * Configure the global structure that stores the timing information. + */ + gExtendedTimerRec.tmTask.qLink = NULL; + gExtendedTimerRec.tmTask.qType = 0; + gExtendedTimerRec.tmTask.tmAddr = NewTimerProc(TimerCallbackProc); + gExtendedTimerRec.tmTask.tmCount = 0; + gExtendedTimerRec.tmTask.tmWakeUp = 0; + gExtendedTimerRec.tmTask.tmReserved = 0; + GetCurrentProcess(&gExtendedTimerRec.taskPSN); - /* Install the task record */ - InsXTime((QElemPtr)&gExtendedTimerRec.tmTask); + /* Install the task record */ + InsXTime((QElemPtr) & gExtendedTimerRec.tmTask); - /* Go! */ - PrimeTime((QElemPtr)&gExtendedTimerRec.tmTask, SDL_alarm_interval); - return(0); + /* Go! */ + PrimeTime((QElemPtr) & gExtendedTimerRec.tmTask, SDL_alarm_interval); + return (0); } -void SDL_SYS_StopTimer(void) +void +SDL_SYS_StopTimer(void) { - RmvTime((QElemPtr)&gExtendedTimerRec.tmTask); + RmvTime((QElemPtr) & gExtendedTimerRec.tmTask); } #endif /* SDL_TIMER_MACOS */ +/* vi: set ts=4 sw=4 expandtab: */