2 // C Implementation: timer
7 // Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
9 // Copyright: See COPYING file that comes with this distribution
17 unsigned int st_get_ticks(void)
19 if(st_pause_count != 0)
20 return SDL_GetTicks() - st_pause_ticks - SDL_GetTicks() + st_pause_count;
22 return SDL_GetTicks() - st_pause_ticks;
25 void st_pause_ticks_init(void)
31 void st_pause_ticks_start(void)
33 st_pause_count = SDL_GetTicks();
36 void st_pause_ticks_stop(void)
38 st_pause_ticks += SDL_GetTicks() - st_pause_count;
42 void timer_init(timer_type* ptimer)
48 void timer_start(timer_type* ptimer, unsigned int period)
50 ptimer->time = st_get_ticks();
51 ptimer->period = period;
54 void timer_stop(timer_type* ptimer)
59 int timer_check(timer_type* ptimer)
61 if((ptimer->time != 0) && (ptimer->time + ptimer->period > st_get_ticks()))
70 int timer_started(timer_type* ptimer)
78 int timer_get_left(timer_type* ptimer)
80 return (ptimer->period - (st_get_ticks() - ptimer->time));
83 int timer_get_gone(timer_type* ptimer)
85 return (st_get_ticks() - ptimer->time);