Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: p2 on September 09, 2011, 01:49:04 pm

Title: Making my code faster
Post by: p2 on September 09, 2011, 01:49:04 pm
Is it possible to make my code faster?
(I want to make a few different difficulty-modes!)

EDIT: Screenie!!
(http://img.removedfromgame.com/imgs/CAR.gif)
(It's with sound - so you should try it on your TI!)

CARAXE is the ASM-program
The other programs are the surcecode! (CAR is the main-program)
Title: Re: Making my code faster
Post by: Eeems on September 09, 2011, 02:44:55 pm
Frameskipping would speed it up. ( So only display every other frame ).
Title: Re: Making my code faster
Post by: Runer112 on September 09, 2011, 03:50:23 pm
Pause statements is a crude way, but it works well.

Wouldn't that make the game slower, not faster?


Frameskipping would speed it up. ( So only display every other frame ).

With that, the game speed would remain the same, but it would be even choppier (notes and such would pass at half speed but seemingly at 2 pixels per jump)

Each frame sent to the screen takes about 1/100th of a second, and on top of that there's the time needed to render the frame. Cutting out about 15-20 of these per second would certainly save a lot of processing time, allowing the game to run faster.
Title: Re: Making my code faster
Post by: Eeems on September 09, 2011, 03:52:40 pm
Frameskipping would speed it up. ( So only display every other frame ).

With that, the game speed would remain the same, but it would be even choppier (notes and such would pass at half speed but seemingly at 2 pixels per jump)
Not at all, you see a lot of processing time is taken in displaying a frame. In TBP I gain a lot of speed by skipping a few frames. You do move two pixels, but it seems to move faster because in truth, the program has more time to work on the actual processing of whatever needs to be done in the background because all the foreground code ( so the displaying ) isn't taking up as much time. The game does start getting pretty choppy when you start skipping a lot of frames but usually just a one fameskip isn't noticeable unless you are looking closely.

EDIT: ninja'd :P With a much better explanation.
Title: Re: Making my code faster
Post by: p2 on September 10, 2011, 11:06:03 am
Er...
So may someone of you tell me how to make it faster??

The speed is more important than the size of the program!
Title: Re: Making my code faster
Post by: MGOS on September 10, 2011, 11:47:42 am
I'd use a counter variable and skip every second / third frame using an if statement with the modulus operator ^.


Code: [Select]
0->C   .Counter variable
game loop
   .do calculations here
   !If C^2    .Increase number to skip more frames -> gain more speed
      .do drawing stuff / displaying here
   End
   C++
End
Title: Re: Making my code faster
Post by: p2 on September 10, 2011, 11:52:20 am
Er...
a CALCULATOR game.
Or can you write that in Axe??

Aniway, Thanx!
Title: Re: Making my code faster
Post by: ztrumpet on September 10, 2011, 11:54:48 am
Er...
a CALCULATOR game.
Or can you write that in Axe??

Aniway, Thanx!
It is written in Axe. ;)
If you're wondering about the ++ operator, it's been in Axe since 0.5.2 or so, and if you're wondering about the ^ operator, it's been in Axe since before 0.1.0.
Title: Re: Making my code faster
Post by: Happybobjr on September 10, 2011, 11:56:49 am
Here i optimized it a bit.  A big problem you have is the line...
Dispgraph
Dispgraph^r


(note that i changed some things so this has a chance of not working the way you wish.)
Title: Re: Making my code faster
Post by: p2 on September 10, 2011, 11:59:54 am
I hope it'll be faster!!
Title: Re: Making my code faster
Post by: Happybobjr on September 10, 2011, 12:16:51 pm
tell me if it is :)
i hoped that helped.  There is some definite improvisation possibilities, but I can't think too hard right now :P