src/timer/amigaos/SDL_systimer.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/timer/amigaos/SDL_systimer.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/timer/amigaos/SDL_systimer.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -60,18 +60,18 @@
     1.4  static clock_t start;
     1.5  
     1.6  void
     1.7 -SDL_StartTicks (void)
     1.8 +SDL_StartTicks(void)
     1.9  {
    1.10      /* Set first ticks value */
    1.11 -    start = clock ();
    1.12 +    start = clock();
    1.13  }
    1.14  
    1.15  Uint32
    1.16 -SDL_GetTicks (void)
    1.17 +SDL_GetTicks(void)
    1.18  {
    1.19      clock_t ticks;
    1.20  
    1.21 -    ticks = clock () - start;
    1.22 +    ticks = clock() - start;
    1.23  
    1.24  #ifdef __SASC
    1.25  // CLOCKS_PER_SEC == 1000 !
    1.26 @@ -85,21 +85,21 @@
    1.27  }
    1.28  
    1.29  void
    1.30 -SDL_Delay (Uint32 ms)
    1.31 +SDL_Delay(Uint32 ms)
    1.32  {
    1.33  // Do a busy wait if time is less than 50ms
    1.34  
    1.35      if (ms < 50) {
    1.36 -        clock_t to_wait = clock ();
    1.37 +        clock_t to_wait = clock();
    1.38  
    1.39  #ifndef __SASC
    1.40          ms *= (CLOCKS_PER_SEC / 1000);
    1.41  #endif
    1.42          to_wait += ms;
    1.43  
    1.44 -        while (clock () < to_wait);
    1.45 +        while (clock() < to_wait);
    1.46      } else {
    1.47 -        Delay (ms / 20);
    1.48 +        Delay(ms / 20);
    1.49      }
    1.50  }
    1.51  
    1.52 @@ -107,29 +107,29 @@
    1.53  
    1.54  ULONG MY_CLOCKS_PER_SEC;
    1.55  
    1.56 -void PPC_TimerInit (void);
    1.57 +void PPC_TimerInit(void);
    1.58  APTR MyTimer;
    1.59  
    1.60  ULONG start[2];
    1.61  
    1.62  void
    1.63 -SDL_StartTicks (void)
    1.64 +SDL_StartTicks(void)
    1.65  {
    1.66      /* Set first ticks value */
    1.67      if (!MyTimer)
    1.68 -        PPC_TimerInit ();
    1.69 +        PPC_TimerInit();
    1.70  
    1.71 -    PPCGetTimerObject (MyTimer, PPCTIMERTAG_CURRENTTICKS, start);
    1.72 +    PPCGetTimerObject(MyTimer, PPCTIMERTAG_CURRENTTICKS, start);
    1.73      start[1] >>= 10;
    1.74      start[1] |= ((result[0] & 0x3ff) << 22);
    1.75      start[0] >>= 10;
    1.76  }
    1.77  
    1.78  Uint32
    1.79 -SDL_GetTicks (void)
    1.80 +SDL_GetTicks(void)
    1.81  {
    1.82      ULONG result[2];
    1.83 -    PPCGetTimerObject (MyTimer, PPCTIMERTAG_CURRENTTICKS, result);
    1.84 +    PPCGetTimerObject(MyTimer, PPCTIMERTAG_CURRENTTICKS, result);
    1.85  
    1.86  //      PPCAsr64p(result,10);
    1.87  // Non va, la emulo:
    1.88 @@ -143,26 +143,26 @@
    1.89  }
    1.90  
    1.91  void
    1.92 -SDL_Delay (Uint32 ms)
    1.93 +SDL_Delay(Uint32 ms)
    1.94  {
    1.95  // Do a busy wait if time is less than 50ms
    1.96  
    1.97      if (ms < 50) {
    1.98          ULONG to_wait[2], actual[2];
    1.99 -        PPCGetTimerObject (MyTimer, PPCTIMERTAG_CURRENTTICKS, result);
   1.100 +        PPCGetTimerObject(MyTimer, PPCTIMERTAG_CURRENTTICKS, result);
   1.101          actual[1] = 0;
   1.102          to_wait[1] += ms * 1000 / MY_CLOCKS_PER_SEC;
   1.103  
   1.104          while (actual[1] < to_wait[1]) {
   1.105 -            PPCGetTimerObject (MyTimer, PPCTIMERTAG_CURRENTTICKS, actual);
   1.106 +            PPCGetTimerObject(MyTimer, PPCTIMERTAG_CURRENTTICKS, actual);
   1.107          }
   1.108      } else {
   1.109 -        Delay (ms / 50);
   1.110 +        Delay(ms / 50);
   1.111      }
   1.112  }
   1.113  
   1.114  void
   1.115 -PPC_TimerInit (void)
   1.116 +PPC_TimerInit(void)
   1.117  {
   1.118      struct TagItem tags[] = {
   1.119          PPCTIMERTAG_CPU, TRUE,
   1.120 @@ -170,30 +170,29 @@
   1.121      };
   1.122  
   1.123  
   1.124 -    if (MyTimer = PPCCreateTimerObject (tags)) {
   1.125 +    if (MyTimer = PPCCreateTimerObject(tags)) {
   1.126          ULONG result[2];
   1.127  
   1.128 -        PPCGetTimerObject (MyTimer, PPCTIMERTAG_TICKSPERSEC, result);
   1.129 -        D (bug
   1.130 -           ("Timer inizializzato, TPS: %lu - %lu\n", result[0], result[1]));
   1.131 +        PPCGetTimerObject(MyTimer, PPCTIMERTAG_TICKSPERSEC, result);
   1.132 +        D(bug("Timer inizializzato, TPS: %lu - %lu\n", result[0], result[1]));
   1.133  //              PPCAsr64p(result,10);
   1.134          result[1] >>= 10;
   1.135          result[1] |= ((result[0] & 0x3ff) << 22);
   1.136          result[0] >>= 10;
   1.137  
   1.138 -        D (bug ("Shiftato TPS: %lu - %lu\n", result[0], result[1]));
   1.139 +        D(bug("Shiftato TPS: %lu - %lu\n", result[0], result[1]));
   1.140          MY_CLOCKS_PER_SEC = result[1];
   1.141  
   1.142 -        PPCGetTimerObject (MyTimer, PPCTIMERTAG_CURRENTTICKS, result);
   1.143 +        PPCGetTimerObject(MyTimer, PPCTIMERTAG_CURRENTTICKS, result);
   1.144  
   1.145 -        D (bug ("Current ticks: %lu - %lu\n", result[0], result[1]));
   1.146 +        D(bug("Current ticks: %lu - %lu\n", result[0], result[1]));
   1.147          result[1] >>= 10;
   1.148          result[1] |= ((result[0] & 0x3ff) << 22);
   1.149          result[0] >>= 10;
   1.150  //              PPCAsr64p(result,10);
   1.151 -        D (bug ("Shiftato: %lu - %lu\n", result[0], result[1]));
   1.152 +        D(bug("Shiftato: %lu - %lu\n", result[0], result[1]));
   1.153      } else {
   1.154 -        D (bug ("Errore nell'inizializzazione del timer!\n"));
   1.155 +        D(bug("Errore nell'inizializzazione del timer!\n"));
   1.156      }
   1.157  }
   1.158  
   1.159 @@ -206,61 +205,61 @@
   1.160  static SDL_Thread *timer_thread = NULL;
   1.161  
   1.162  static int
   1.163 -RunTimer (void *unused)
   1.164 +RunTimer(void *unused)
   1.165  {
   1.166 -    D (bug ("SYSTimer: Entering RunTimer loop..."));
   1.167 +    D(bug("SYSTimer: Entering RunTimer loop..."));
   1.168  
   1.169      if (GfxBase == NULL)
   1.170 -        GfxBase = (struct GfxBase *) OpenLibrary ("graphics.library", 37);
   1.171 +        GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 37);
   1.172  
   1.173      while (timer_alive) {
   1.174          if (SDL_timer_running) {
   1.175 -            SDL_ThreadedTimerCheck ();
   1.176 +            SDL_ThreadedTimerCheck();
   1.177          }
   1.178          if (GfxBase)
   1.179 -            WaitTOF ();         // Check the timer every fifth of seconds. Was SDL_Delay(1)->BusyWait!
   1.180 +            WaitTOF();          // Check the timer every fifth of seconds. Was SDL_Delay(1)->BusyWait!
   1.181          else
   1.182 -            Delay (1);
   1.183 +            Delay(1);
   1.184      }
   1.185 -    D (bug ("SYSTimer: EXITING RunTimer loop..."));
   1.186 +    D(bug("SYSTimer: EXITING RunTimer loop..."));
   1.187      return (0);
   1.188  }
   1.189  
   1.190  /* This is only called if the event thread is not running */
   1.191  int
   1.192 -SDL_SYS_TimerInit (void)
   1.193 +SDL_SYS_TimerInit(void)
   1.194  {
   1.195 -    D (bug ("Creating thread for the timer (NOITIMER)...\n"));
   1.196 +    D(bug("Creating thread for the timer (NOITIMER)...\n"));
   1.197  
   1.198      timer_alive = 1;
   1.199 -    timer_thread = SDL_CreateThread (RunTimer, NULL);
   1.200 +    timer_thread = SDL_CreateThread(RunTimer, NULL);
   1.201      if (timer_thread == NULL) {
   1.202 -        D (bug ("Creazione del thread fallita...\n"));
   1.203 +        D(bug("Creazione del thread fallita...\n"));
   1.204  
   1.205          return (-1);
   1.206      }
   1.207 -    return (SDL_SetTimerThreaded (1));
   1.208 +    return (SDL_SetTimerThreaded(1));
   1.209  }
   1.210  
   1.211  void
   1.212 -SDL_SYS_TimerQuit (void)
   1.213 +SDL_SYS_TimerQuit(void)
   1.214  {
   1.215      timer_alive = 0;
   1.216      if (timer_thread) {
   1.217 -        SDL_WaitThread (timer_thread, NULL);
   1.218 +        SDL_WaitThread(timer_thread, NULL);
   1.219          timer_thread = NULL;
   1.220      }
   1.221  }
   1.222  
   1.223  int
   1.224 -SDL_SYS_StartTimer (void)
   1.225 +SDL_SYS_StartTimer(void)
   1.226  {
   1.227 -    SDL_SetError ("Internal logic error: AmigaOS uses threaded timer");
   1.228 +    SDL_SetError("Internal logic error: AmigaOS uses threaded timer");
   1.229      return (-1);
   1.230  }
   1.231  
   1.232  void
   1.233 -SDL_SYS_StopTimer (void)
   1.234 +SDL_SYS_StopTimer(void)
   1.235  {
   1.236      return;
   1.237  }