Mail Archives: djgpp/1998/04/15/10:39:22
Robert Robbins writes:
> I want to execute a function which uses putpixel while a sprite can
> still be moved with the arrow keys. ALLEGRO's install_int function
> only illustrates using a counter.
Just because the Allegro timer example is a counter, that doesn't
mean you are unable to replace this with different code of your own!
The timer callback is just a C function, so you can easily insert
whatever instructions you like inside it. Many internal parts of
Allegro use timers for various things like this: look at the
pointer display code in mouse.c, the music playback code in midi.c,
or the double-click detection code in gui.c.
I must advise against drawing to the screen from inside a timer
interrupt, though. This will only work reliably if the main program
doesn't ever touch the screen itself, because the SVGA bank
switching code will get very confused if your timer code interrupts
some other drawing operation. The Allegro graphics functions are
in general not reentrant, so this is likely to cause you a lot of
grief.
Shawn Hargreaves.
- Raw text -