Mercurial > sdl-ios-xcode
diff src/timer/macos/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 | 14717b52abc0 |
children | 4da1ee79c9af |
line wrap: on
line diff
--- a/src/timer/macos/SDL_systimer.c Sun May 21 17:27:13 2006 +0000 +++ b/src/timer/macos/SDL_systimer.c Sun May 28 13:04:16 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: */