Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: shmibs on January 13, 2012, 12:48:17 am

Title: consistant framerates?
Post 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?
Title: Re: consistant framerates?
Post by: Deep Toaster on January 13, 2012, 12:51:54 am
Maybe you could use interrupts to "trigger" (set a flag of some sort) routines in the main program?
Title: Re: consistant framerates?
Post by: shmibs on January 13, 2012, 12:53:49 am
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?
Title: Re: consistant framerates?
Post by: C0deH4cker on January 13, 2012, 10:02:19 am
You could use the DS<( command for this.
Title: Re: consistant framerates?
Post by: Hot_Dog on January 13, 2012, 10:09:34 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?

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.
Title: Re: consistant framerates?
Post by: Quigibo on January 14, 2012, 06:43:30 am
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:

Code: [Select]
:.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...