// Initialisation routines for Vivace example 0943 #include #include #include #include #include "0943i.h" #include "0943.h" volatile int target_cycle; void target_incrementor() { target_cycle++; } END_OF_FUNCTION(target_incrementor); volatile int last_fps; volatile int frame_counter; void count_frames() { last_fps = frame_counter; frame_counter = 0; } END_OF_FUNCTION(count_frames); void init_example(void) { srand(time(NULL)); allegro_init(); install_keyboard(); install_timer(); LOCK_VARIABLE(target_cycle); LOCK_FUNCTION(target_incrementor); install_int_ex(target_incrementor, BPS_TO_TIMER(30)); LOCK_VARIABLE(last_fps); LOCK_VARIABLE(frame_counter); LOCK_FUNCTION(count_frames); install_int_ex(count_frames, BPS_TO_TIMER(1)); end_game = 0; pixels = 1000; dblbuffer = create_bitmap(320, 200); if (dblbuffer == NULL) { allegro_exit(); printf("Sorry, not enough memory"); exit(1); } clear(dblbuffer); if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) < 0) { printf("%s\n", allegro_error); exit(2); } actual_cycle = target_cycle = 0; /* Start up-to-date */ circle_pos = itofix(SCREEN_W / 2); add_pos = itofix(2); } void shutdown(void) { destroy_bitmap(dblbuffer); }