How can I make my game run at the same speed on any computer?

Description

How can I make my game run at the same speed on any computer?
You need to make sure the game logic gets updated at a regular rate, but skip the screen refresh every now and then if the computer is too slow to keep up. This can be done by installing a timer handler that will increment a global variable at your game logic speed, eg:
      volatile int speed_counter = 0;

void increment_speed_counter() { speed_counter++; }

END_OF_FUNCTION(increment_speed_counter)

void play_the_game() { LOCK_VARIABLE(speed_counter); LOCK_FUNCTION(increment_speed_counter);

install_int_ex(increment_speed_counter, BPS_TO_TIMER(60));

while (!game_over) { while (speed_counter > 0) { update_game_logic(); speed_counter--; }

update_display(); } }