Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Keoni29 on June 19, 2011, 12:31:18 pm

Title: Optimize level loading from external file
Post by: Keoni29 on June 19, 2011, 12:31:18 pm
Can I optimize this?
Code: [Select]
Lbl LV
If r1=1
prgrmSTAGE1
End
If r1=2
prgrmSTAGE2
End
etc.

Title: Re: Optimize level loading from external file
Post by: leafy on July 06, 2011, 01:03:16 am
I'm assuming this is axe:

Code: [Select]
Lbl LV
!If r1-1
prgmSTAGE1
Else!If -1
prgmSTAGE2
Else!If -1
prgmSTAGE3
etc.
End
Return
Title: Re: Optimize level loading from external file
Post by: z80man on July 06, 2011, 01:09:57 am
Here it looks like a look up table would be the best option depending on the number of options, but I'm no Axe expert and don't know how to do that. My suggestion though would be maybe if you could have a list of pointers to the other source files then have the r1 index jump to what it's offset points to.
Title: Re: Optimize level loading from external file
Post by: AngelFish on July 06, 2011, 01:15:32 am
I'd go with the lookup table idea. It's certainly possible in Axe if you have pointers to those files. Otherwise, since the level names are all the same size, you could store those mashed together in a big string and use r1*7 to index the file names in the string. An even more optimized way to do that would be to store a null value after each string like "prgmSTAGE1"[00]"prgmSTAGE2"[00]->Str1 and use r1*2*2*2 to index the string.