diff src/timer/macos/SDL_MPWtimer.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
line wrap: on
line diff
--- a/src/timer/macos/SDL_MPWtimer.c	Sun May 21 17:27:13 2006 +0000
+++ b/src/timer/macos/SDL_MPWtimer.c	Sun May 28 13:04:16 2006 +0000
@@ -34,7 +34,7 @@
 #include "SDL_timer.h"
 #include "../SDL_timer_c.h"
 
-#define MS_PER_TICK	(1000/60)		/* MacOS tick = 1/60 second */
+#define MS_PER_TICK	(1000/60)       /* MacOS tick = 1/60 second */
 
 /* Note: This is only a step above the original 1/60s implementation.
  *       For a good implementation, see FastTimes.[ch], by Matt Slot.
@@ -44,42 +44,46 @@
 
 UInt64 start;
 
-void SDL_StartTicks(void)
+void
+SDL_StartTicks (void)
 {
 #ifdef USE_MICROSECONDS
-	UnsignedWide now;
-	
-	Microseconds(&now);
-	start = WideTo64bit(now);
+    UnsignedWide now;
+
+    Microseconds (&now);
+    start = WideTo64bit (now);
 #else
-	/* FIXME: Should we implement a wrapping algorithm, like Win32? */
+    /* FIXME: Should we implement a wrapping algorithm, like Win32? */
 #endif
 }
 
-Uint32 SDL_GetTicks(void)
+Uint32
+SDL_GetTicks (void)
 {
 #ifdef USE_MICROSECONDS
-	UnsignedWide now;
-	
-	Microseconds(&now);
-	return (Uint32)((WideTo64bit(now)-start)/1000);
+    UnsignedWide now;
+
+    Microseconds (&now);
+    return (Uint32) ((WideTo64bit (now) - start) / 1000);
 #else
-	return(LMGetTicks()*MS_PER_TICK);
+    return (LMGetTicks () * MS_PER_TICK);
 #endif
 }
 
-void SDL_Delay(Uint32 ms)
+void
+SDL_Delay (Uint32 ms)
 {
 #ifdef USE_MICROSECONDS
-	Uint32 end_ms;
-	
-	end_ms = SDL_GetTicks() + ms;
-	do {
-		/* FIXME: Yield CPU? */ ;
-	} while ( SDL_GetTicks() < end_ms );
+    Uint32 end_ms;
+
+    end_ms = SDL_GetTicks () + ms;
+    do {
+        /* FIXME: Yield CPU? */ ;
+    }
+    while (SDL_GetTicks () < end_ms);
 #else
-	UInt32		unused; /* MJS */
-	Delay(ms/MS_PER_TICK, &unused);
+    UInt32 unused;              /* MJS */
+    Delay (ms / MS_PER_TICK, &unused);
 #endif
 }
 
@@ -87,66 +91,71 @@
 /* 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)
 {
-	/* We don't need a setup? */
-	return(0);
+    /* We don't need a setup? */
+    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 = NewTimerUPP(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 = NewTimerUPP (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: */