Well, I understand the whole point of it, with the whole keeping game speed constant across systems and all. My problem is the concept involved in the implimentation of it.
For example, one tutorial explains it like this (I've included only the relevant parts)
Code:
volatile long speed_counter = 0; //A long integer which will store the value of the speed counter.
void increment_speed_counter() //A function to increment the speed counter
{
speed_counter++; // This will just increment the speed counter by one.
}
END_OF_FUNCTION(increment_speed_counter); //Make sure you tell it that it's the end of the function
LOCK_VARIABLE(speed_counter); //Used to set the timer - which regulates the game's
LOCK_FUNCTION(increment_speed_counter); //speed.
install_int_ex(increment_speed_counter, BPS_TO_TIMER(60)); //Set our BPS
...
while(!key[KEY_ESC]) //If the user hits escape, quit the program
{
while(speed_counter > 0)
{
//input
speed_counter--;
}
...
//output
}
...
That's a clipped version of what the site describes, minus paragraphs inbetween that describe what's going on.
What's evading me is exactly what this does. As far as I can tell, 60 times per second, it increments the speed_counter. When it hits the input phase, it checks the users keypresses until the speed_counter hits 0. Then the program does whatever, blits to the screen, and loops around again. How does this help to regulate the game speed?
-edit-
I fixed a few misspellings.