]> icculus.org git repositories - btb/d2x.git/blob - arch/sdl/timer.c
added timer_delay, faster timer_get_fixed_seconds
[btb/d2x.git] / arch / sdl / timer.c
1 /*
2  * $Source: /cvs/cvsroot/d2x/arch/sdl/timer.c,v $
3  * $Revision: 1.4 $
4  * $Author: btb $
5  * $Date: 2002-09-01 02:46:06 $
6  *
7  * SDL library timer functions
8  *
9  * $Log: not supported by cvs2svn $
10  * Revision 1.3  2001/10/19 09:45:02  bradleyb
11  * Moved arch/sdl_* to arch/sdl
12  *
13  * Revision 1.2  2001/01/29 13:35:09  bradleyb
14  * Fixed build system, minor fixes
15  *
16  */
17
18 #ifdef HAVE_CONFIG_H
19 #include <conf.h>
20 #endif
21
22 #include <SDL/SDL.h>
23
24 #include "maths.h"
25 #include "timer.h"
26
27 fix timer_get_fixed_seconds(void) {
28 #if 1
29         return approx_msec_to_fsec(SDL_GetTicks());
30 #else
31   fix x;
32   unsigned long tv_now = SDL_GetTicks();
33   x=i2f(tv_now/1000) | fixdiv(i2f(tv_now % 1000),i2f(1000));
34   return x;
35 #endif
36 }
37
38 void timer_delay(fix seconds)
39 {
40 #if 1
41         SDL_Delay(approx_fsec_to_msec(seconds));
42 #else
43         SDL_Delay(f2i(fixmul(seconds, i2f(1000))));
44 #endif
45 }