Time handling in scumm

Dec 10, 2012 at 12:57 PM
Edited Dec 10, 2012 at 1:00 PM

I haven't had the time to check that subject yet. Do you know how is handled the logical delta time between the updates of the different game components (actors, objects, etc?)

Is it constant a fixed frame rate  or is it declared somewhere as a variable in the script engine? Can the script engine modify the update refresh rate during the game?

For the moment, the update method is called by XNA (which is by default at a fixed 60 fps frame rate if I remember correctly)

Dec 10, 2012 at 4:23 PM

I'll try to look at that when I'm home - in 5-6 hours.

Dec 11, 2012 at 1:08 AM

I'm not sure about that, but I think each script has its delay value. From ScummVm:

void Scumm::decreaseScriptDelay(int amount)
	ScriptSlot *ss = &vm.slot[0];
	int i;
	for (i=0; i<20; i++,ss++) {
		if(ss->status==1) {
			ss->delay -= amount;
			if (ss->delay < 0){
				ss->status = 2;
				ss->delay = 0;

Dec 11, 2012 at 9:40 AM
Edited Dec 11, 2012 at 9:44 AM

I have looked in the main scummVM source code and in the main game loop function.

It seems that every scumm games use a common 60 fps rate. Each game has a variable called "VAR_TIMER_NEXT" that is used to tell to the gameloop how many ticks we should wait before calling the various update methods. (Actors, Scripts, Input handling, etc.)

In the case of monkey island, we should wait 6 ticks between each updates.

In ScummVM, they have a proper game loop so they compute the correct amout of time to wait before calling the update method. XNA has already a nice implementation of the gameloop. You can choose between variable or fixed framerate and it handle special cases when your game is slowing down.


So what I did in the update method of the Xna Game is to check if the target frame rate of the XNA game object is the same as the one indicated by the "VAR_TIMER_NEXT". If it is not the same, I adjust it and let XNA handle the gameloop.

For the scripts, I think the delay property is the number of ticks we should wait before continuing running the script.


Dec 12, 2012 at 2:54 PM

Sounds perfect.