Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: shmibs on January 13, 2012, 12:48:17 am
-
if i were writing a processor-intensive program that had a lot of variance in framerates, how could make them stable?
interrupts would slow things down too much, wouldn't they? would measuring out the difference in number of cycles at any branch in the code and then adding in a wait for that long on the slower one work?
-
Maybe you could use interrupts to "trigger" (set a flag of some sort) routines in the main program?
-
if the interrupts are firing constantly and incrementing a counter and then storing another value, wouldn't that cause a lot of lag? how much, approximately, is it at the lowest speed?
-
You could use the DS<( command for this.
-
if i were writing a processor-intensive program that had a lot of variance in framerates, how could make them stable?
interrupts would slow things down too much, wouldn't they? would measuring out the difference in number of cycles at any branch in the code and then adding in a wait for that long on the slower one work?
Interrupts wouldn't slow things down if you wrote your own routine.
So let's say you want 15 frames per second, approximately. You could have a counter set to 8 (An interrupt routine happens about 108 - 120 times per second, and 15 * 8 = 120), and decrease the counter everytime the interrupt routine runs. Reset the counter to 8 when it reaches zero. When you reach the end of your code that is looping, check to see if the counter is = to 8. If not, don't loop again until it is.
-
Just to add to Hot_Dog's idea, I would have interrupt routine simply decrease a variable (call it "A") until it reaches zero and then just stop. That's it. In the regular code, just do the computation, and then right after add a "While A:End" so that it waits for the trigger if the computation was too quick. Immediately after, set A to be 8 or whatever you need for the desired framerate and the counter will do its thing. Here is the code:
:.Setup interrupt
:fnInt(INT,6)
:
:.Main loop
:While <GameLoop>
: <Computation>
: While A:End
: 8->A
: <Update screen>
:End
:Return
:
:.Interrupt
:Lbl INT
:Return!If A
:-1->A
:Return
Replace "A" with an unused variable though...