I'm need a pretty precise clock for a game I'm making with allegro, but I can't seem to get the allegro timer to run the way it's supposed to. I wrote this code to try to get it to tick 1000 times a second, but it just counts seconds:
In my game I've been calling install_int(timerisr,1), and the way I did it here withCode:#include "allegro.h" volatile long timer; void timerisr() { ++timer; } END_OF_FUNCTION(timerisr); int main() { allegro_init(); install_timer(); install_keyboard(); set_gfx_mode(GFX_AUTODETECT_WINDOWED,800,600,0,0); BITMAP *buffer = create_bitmap(SCREEN_W,SCREEN_H); LOCK_VARIABLE(timer); LOCK_FUNCTION(timerisr); install_int(timerisr,MSEC_TO_TIMER(1)); while (!key[KEY_ESC]) { clear_bitmap(buffer); textprintf_centre(buffer,font,SCREEN_W/2,SCREEN_H/2,15,"%d",timer); blit(buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H); } destroy_bitmap(buffer); } END_OF_MAIN();
install_int(timerisr,MSEC_TO_TIMER(1)) didn't work either. Does anybody know what I'm doing wrong?



LinkBack URL
About LinkBacks


