Mail Archives: djgpp/1998/01/25/03:18:54
On 25 Jan 1998 01:01:57 GMT in comp.os.msdos.djgpp Jean-Luc Romano
<jromano AT slate DOT Mines DOT EDU> wrote:
: I have to mention that I am not familiar with the
: initialise_timer() routine at all, so I do not know if that routine
: has anything to do with what I am trying to accomplish.
: Can anyone tell me if there is a better way of checking to see
: if a certain amount of time has elapsed?
I think that if you install_timer() (part of the Allegro library) it
speeds up the system clock dramatically. Either don't do this (which
will upset some other parts of Allegro) or use Allegro's timer
routines for what you want to do.
The simplest way to use Allegro's routines to do this is like so:
volatile int global_ticks = 0;
void my_timer_function () {
global_ticks++;
}
END_OF_FUNCTION (my_timer_function);
Then at initialisation:
LOCK_VARIABLE (global_ticks);
LOCK_FUNCTION (my_timer_function);
install_timer();
install_int_ex (my_timer_function, BPS_TO_TIMER (1));
Look up timers in the Allegro help files for full information. The
effect of the above is that global_ticks will be increased once (the
`1') per second. You can read this variable in your main loop.
--
george DOT foot AT merton DOT oxford DOT ac DOT uk
- Raw text -