Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Happybobjr on September 14, 2010, 07:18:23 am

Title: frame rate/speed
Post by: Happybobjr on September 14, 2010, 07:18:23 am
Is there any way to limit a programs frame rate/speed?
Title: Re: frame rate/speed
Post by: Raylin on September 14, 2010, 08:03:58 am
Use the Pause(EXP) command every now and again. But, I don't think you can do it accurately...
Title: Re: frame rate/speed
Post by: LordConiupiter on September 14, 2010, 09:38:11 am
u could use an interrupt to update the screen, and do a 'Stop' every time you updated the buffer.
Quote from: Documentation
Stop:Stops execution until the next interrupt occurs. Interrupts must be enabled or else the calculator will freeze.
Title: Re: frame rate/speed
Post by: Raylin on September 14, 2010, 09:45:19 am
Yeah, that too.
Title: Re: frame rate/speed
Post by: DJ Omnimaga on September 14, 2010, 12:26:02 pm
Another solution if you aren't using interrupts is to make sure DispGraph is only ran like every 2 or 3 loop. If slowed down too much it can make the game a bit too fast, though, so you may have to add a Pause command or stuff more features there.
Title: Re: frame rate/speed
Post by: SirCmpwn on September 19, 2010, 11:58:33 am
DO NOT USE STOP WITHIN AN INTERRUPT!
This would be bad.  Interrupt code turns OFF interrupts upon executing.
Title: Re: frame rate/speed
Post by: DJ Omnimaga on September 19, 2010, 12:39:30 pm
What kind of stuff can happen if you do so?
Title: Re: frame rate/speed
Post by: calc84maniac on September 19, 2010, 12:44:33 pm
The calc would hang and you would have to pull a battery.
Title: Re: frame rate/speed
Post by: calcdude84se on September 19, 2010, 12:53:26 pm
Code: [Select]
FnOff
Stop
or, in ASM
Code: [Select]
di
halt
Shortest way to freeze a z80 processor AFAIK ;D
Title: Re: frame rate/speed
Post by: DJ Omnimaga on September 19, 2010, 12:57:17 pm
The calc would hang and you would have to pull a battery.
Ah ok I was worried worse stuff migth happen or something x.x
Title: Re: frame rate/speed
Post by: Happybobjr on September 19, 2010, 01:08:24 pm
so nothing will make it even?
so i have a consistent speed of a ship or something in real time?
Title: Re: frame rate/speed
Post by: calcdude84se on September 19, 2010, 01:14:32 pm
Back to your original problem, interrupts would probably be the way to go.
An example:
Code: [Select]
0->C->X
ClrHome
fnInt(T,0
Repeat getKey(0)
!If C
Disp X+1->X>Dec
50->C
End
End
Return
Lbl T
C-1->C
(Untested, should work)
Edit: Oops, wrote getKey instead of getKey(0). Fixed.
Edit 2: Bad typo. Fixed
Title: Re: frame rate/speed
Post by: SirCmpwn on September 19, 2010, 01:15:49 pm
Ah ok I was worried worse stuff migth happen or something x.x

It would also clear RAM.
Title: Re: frame rate/speed
Post by: Happybobjr on September 19, 2010, 01:18:41 pm
Back to your original problem, interrupts would probably be the way to go.
An example:
Code: [Select]
0->C->X
ClrHome
fnInt(T,0
Repeat getKey(0)
!If C
Disp X+1->X>Dec
50->C
End
End
Return
Lbl T
C-1->C
(Untested, should work)
Edit: Oops, wrote getKey instead of getKey(0). Fixed.
Edit 2: Bad typo. Fixed

ok thanks
Title: Re: frame rate/speed
Post by: calcdude84se on September 19, 2010, 01:23:41 pm
And it crashes horribly... You get the idea, though.
Title: Re: frame rate/speed
Post by: SirCmpwn on September 19, 2010, 01:41:52 pm
And it crashes horribly... You get the idea, though.
As far as I'm aware, it's not much of a spectacular crash.  It just stops working.  Not nearly as spectacular as the Omnicalc/2.53 MP/Entries menu crash.
Title: Re: frame rate/speed
Post by: DJ Omnimaga on September 19, 2010, 01:43:02 pm
I had the Omnicalc entry menu crash in other OSes too. I forgot what could crash it, though. x.x (I think it had to do with long entries)
Title: Re: frame rate/speed
Post by: SirCmpwn on September 19, 2010, 01:47:01 pm
Ah, I found it!
Title: Re: frame rate/speed
Post by: calcdude84se on September 19, 2010, 01:49:40 pm
I probably just should have said "it crashes" :P
I've never actually used Axe interrupts, though, so someone should rewrite my code so that it works :)
Title: Re: frame rate/speed
Post by: DJ Omnimaga on September 19, 2010, 01:51:50 pm
Weird it seems different than the entry menu bug I got. If I recall, I had to store massive entries or something and it started wrapping around and glitching. Scrolling down too far would crash the calc.
Title: Re: frame rate/speed
Post by: Darl181 on September 19, 2010, 04:29:12 pm
Wow, I was thinking of updating the OS, but I think I won't know.  Maybe I should just get a 34 multiview
Title: Re: frame rate/speed
Post by: meishe91 on September 19, 2010, 05:01:44 pm
So what exactly is the status on finding an solution? Go with interrupts?

Ah, I found it!

I feel like thats bad...someone should fix that :P
Title: Re: frame rate/speed
Post by: ztrumpet on September 19, 2010, 05:10:33 pm
lol Sir, that's bad.  It needs to be fixed... :P
Title: Re: frame rate/speed
Post by: DJ Omnimaga on September 19, 2010, 11:34:02 pm
did you use Omnicalc 2.53MP patch btw? I remember the old Omnicalc had problems on 2.53MP then Dr'Dnar made a patch that worked on it.
Title: Re: frame rate/speed
Post by: Happybobjr on September 22, 2010, 10:32:26 am
lol Sir, that's bad.  It needs to be fixed... :P

i will just rewrite code and make it proportinatly slower
Title: Re: frame rate/speed
Post by: calcdude84se on September 25, 2010, 12:43:34 pm
*BUMP*
For future reference, maybe someone could write the interrupt code? (Not me, as I seem to be confused by Axe interrupts :P)
Title: Re: frame rate/speed
Post by: Happybobjr on September 25, 2010, 01:15:21 pm
Like

:.axample
:FnInt(A,6)
:lbl A
:Pause X (1-20 for how much slower you want it)
:return
:...rest of program...
:LnReg
Title: Re: frame rate/speed
Post by: calcdude84se on September 25, 2010, 01:50:18 pm
Code: [Select]
0->C->X
ClrHome
fnInt(T,0
Repeat getKey(0)
  !If C
    Disp X+1->X>Dec,i
    50->C
  End
  FnOn
End
LnReg
Return
Lbl T
  C-1->C
Never mind, I figured out why my code wasn't working... (and something I can bug quigibo about...)
Edit: Indented for readability.
Title: Re: frame rate/speed
Post by: DJ Omnimaga on September 25, 2010, 02:02:44 pm
What is wrong with the code?
Title: Re: frame rate/speed
Post by: calcdude84se on September 25, 2010, 02:23:34 pm
The code I just posted is fine and tested to work.
The problems that I solved were 1) I had forgotten LnReg (that's why it crashed before) and 2) For some mysterious reason, Disp, Disp >Dec, and possibly other OS routines disable interrupts, which means I had to insert an FnOn into the loop (it also could have been put in the If instead of the Repeat)
Number 2 is the one I'm going to bother Quigibo with.
Title: Re: frame rate/speed
Post by: DJ Omnimaga on September 25, 2010, 02:38:59 pm
Ah ok, what is it for? Is it the code to slow down the game to a specific framerate when fewer stuff is drawn?
Title: Re: frame rate/speed
Post by: calcdude84se on September 25, 2010, 02:45:09 pm
What it does is perform an action at a certain rate.
Lemme explain it for you :) (Note that it is only an example ;D)
Code: [Select]
.Initialize variables for the program
0->C->X
.Just to make it look nice
ClrHome
.Set up the timer interrupt
fnInt(T,0
.Main program loop
Repeat getKey(0)
.If the counter is zero
!If C
.Display and increment X and put a new line
Disp X+1->X>Dec,i
.Reset the counter to 50 again
50->C
End
.Because Disp is silly
FnOn
End
.Clean up and return
LnReg
Return
.The timer
Lbl T
.Just decrement C
C-1->C
In short, it's an example program that counts up at regular intervals. Note that the only weakness to this method is, if you don't reset the counter when it reaches 0, it will have to count down all the way from 65535 to 0 again. (This normally should not be a problem)
Title: Re: frame rate/speed
Post by: DJ Omnimaga on September 25, 2010, 02:50:23 pm
Ah ok. I assume this is less accurate if many actions are performed at once, though?
Title: Re: frame rate/speed
Post by: calcdude84se on September 25, 2010, 02:54:07 pm
No, it should as accurate as the interrupts are as timers, providing that you don't miss when the timer is 0. ;D
Title: Re: frame rate/speed
Post by: DJ Omnimaga on September 25, 2010, 03:02:13 pm
Ah ok, I was worried about when you had like 100 sprites to draw and another set of frames you had 1-2 :P
Title: Re: frame rate/speed
Post by: calcdude84se on September 25, 2010, 03:09:10 pm
Actually, something I missed: if the counter will hit 0 n times per second, then taking over an nth of a second will cause it to skip a cycle. (Very similar to interrupt routines, in fact)
But, again, unless you do a lot of stuff, this shouldn't be a problem :)