Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Timer problems

This thread is locked; no one can reply to it. rss feed Print
Timer problems
Miles Lombardi
Member #5,876
May 2005

     if (room == ROOM_TITLE){
        rm_title_Start();
        while (room == ROOM_TITLE){rm_title_Loop(); }
        rm_title_End();
     }

Simple code, effectively a class constructor, main loop then destructor, for those who are too lazy to make a class, or just haven't got round to it yet.

Aaaaaanyway.

void rm_title_Start(){
     install_int (rm_title_callback, 1000);
}

It does that.
But then it enters the while loop and pointer errors before any of that functions code is executed.

Could someone help?
I don't know why it's doing this.

Dennis
Member #1,090
July 2003
avatar

Is rm_title_callback defined correctly? Did you remember to put END_OF_FUNCTION?
And did you lock all the used memory correctly with LOCK_FUNCTION and LOCK_VARIABLE?

Miles Lombardi
Member #5,876
May 2005

I didn't put end of function, and when i put that it worked.
Sorta, it stopped somewhere else XD.
What does lock_function do?

Dennis
Member #1,090
July 2003
avatar

I hope you did not just put END_OF_FUNCTION but END_OF_FUNCTION(rm_title_callback).
Regarding LOCK_FUNCTION:

install_int_ex said:

In a DOS protected mode environment like DJGPP, memory is virtualised and can be swapped to disk. Due to the non-reentrancy of DOS, if a disk swap occurs inside an interrupt handler the system will die a painful death, so you need to make sure you lock all the memory (both code and data) that is touched inside timer routines. Allegro will lock everything it uses, but you are responsible for locking your handler functions. The macros LOCK_VARIABLE (variable), END_OF_FUNCTION (function_name), END_OF_STATIC_FUNCTION (function_name), and LOCK_FUNCTION (function_name) can be used to simplify this task.

Go to: