[TI BASIC] Optimizing

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Virtuoso

Post by Virtuoso »

LX131(L)->T
LY131(L)->U
If LT31(L)=1
to
LX131(L->T
LY131(L->U
If 1=LT31(L
User avatar
dysfunction
Calc Master
Posts: 1454
Joined: Wed 22 Dec, 2004 3:07 am
Location: Through the Aura

Post by dysfunction »

@DarkerLine: Thanks, that will at least shave off some size, though I don't think it will have much effect on speed...
Image


"You're very clever, young man, but it's turtles all the way down!"
DarkerLine
Calc Wizard
Posts: 526
Joined: Tue 08 Mar, 2005 1:37 am
Location: who wants to know?
Contact:

Post by DarkerLine »

In the same way, you could shrink the first code you posted by almost 75%.
Virtuoso

Post by Virtuoso »

consider using shorter list names also
User avatar
dysfunction
Calc Master
Posts: 1454
Joined: Wed 22 Dec, 2004 3:07 am
Location: Through the Aura

Post by dysfunction »

@Virtuoso: Most of these optimiztions shave off only bery tiny amounts of code- I'll make these corrections later, since they make the code harder to read.
Image


"You're very clever, young man, but it's turtles all the way down!"
DarkerLine
Calc Wizard
Posts: 526
Joined: Tue 08 Mar, 2005 1:37 am
Location: who wants to know?
Contact:

Post by DarkerLine »

There really isn't much you could shorten the list names.
You could use W31, X31, Y31, Z31 instead of X131, Y131, X231, Y231, but that only shrinks it by one byte.

Unless you wanted to make it completely arbitrary and incomprehensible by going L_AA, L_AB, L_AC, ... ,L_ZZ?
Guest

Virtuoso

Post by Guest »

All you gotta do is just remember shorter is faster :)

At least thats always been the case for me in BASIC.
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Post by tr1p1ea »

That isnt always the case, especially when there are loops involved. Often you get caught between making it smaller or making it faster.
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
dysfunction
Calc Master
Posts: 1454
Joined: Wed 22 Dec, 2004 3:07 am
Location: Through the Aura

Post by dysfunction »

Yes, this is large but fast.
Image


"You're very clever, young man, but it's turtles all the way down!"
User avatar
DJ_O
Calc King
Posts: 2324
Joined: Mon 20 Dec, 2004 6:47 pm
Location: Quebec (Canada)
Contact:

Post by DJ_O »

Memory might not be a problem if you use Flash Gordon or such program. The code limit on the 83+ is 188229 bytes (in extended TI-BASIC language).
Image Image Image Now active at https://discord.gg/cuZcfcF (CodeWalrus server)
User avatar
dysfunction
Calc Master
Posts: 1454
Joined: Wed 22 Dec, 2004 3:07 am
Location: Through the Aura

Post by dysfunction »

Yeah, I intend on using archive as much as possible. Zpic allows pics to be recalled directly from ROM, so I might not even need Flash Gordon.
Image


"You're very clever, young man, but it's turtles all the way down!"
Toaster
Extreme Poster
Posts: 322
Joined: Tue 15 Feb, 2005 12:08 am
Location: Lost in a land of mysteries.....

Post by Toaster »

When you call pics with zpic out of ROM they dont display right. :P I wish there was some program that would call pics out of ROM but so far I have not found anything. :(
Join me at:
http://nanotech.pcriot.com
or
http://emancipal.co.nr

Coming soon..
Rewrite 3D Level Editor - 55% done!!
Emancipal - The Creator 5% done
User avatar
dysfunction
Calc Master
Posts: 1454
Joined: Wed 22 Dec, 2004 3:07 am
Location: Through the Aura

Post by dysfunction »

Actually, they do display right with ZPIC when called out of Archive.
Image


"You're very clever, young man, but it's turtles all the way down!"
MooK
New Member
Posts: 61
Joined: Sat 12 Mar, 2005 1:58 pm

Post by MooK »

Hi...I was wondering which would be faster for detecting whether or not an object was in the correct domain. I am not looking for size since this is a game written in basic, I will sacrifice space (since my game is turning out really small, my graphics for the sprites only take about 50 k :twisted: ) for speed.
Example 1:
X+(X=0)-(X=95->X
Y+(Y=0)-(Y=63->Y

or Example 2:

If X=0:1->X
If Y=0:1->Y
If X=95:94->X
If Y=63:62->X

or maybe a combo of both? Example 3:

If X=0 or X=95:X+(X=0)-(X=95->X
If Y=0 or X=63:Y+(Y=0)-(Y=63->Y


I am just trying to avoid the extra restoring when X or Y is not out of range. Also, I use a modified version of the first example of code for changing my X and Y when a correct key is pressed, so for more speed would I change to whichever of the 3 types of code is fastest? Thank You.
DarkerLine
Calc Wizard
Posts: 526
Joined: Tue 08 Mar, 2005 1:37 am
Location: who wants to know?
Contact:

Post by DarkerLine »

I'm pretty sure Example 1 is faster.

Code: Select all

X+(X=0)-(X=95->X 
Y+(Y=0)-(Y=63->Y 
Except that you can optimize it to

Code: Select all

X+not(X)-(X=95->X
Y+not(Y)-(Y=63->Y
just try to be nice to people.
_________________
My TI Blog - http://mpl.unitedti.org/
Post Reply