Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: FinaleTI on June 13, 2011, 09:02:01 pm

Title: Need some help speed optimizing a routine
Post by: FinaleTI on June 13, 2011, 09:02:01 pm
I've been working on a text routine for the ObjectStack for the Axe GUI Library, but it's incredibly slow.
I'm only so-so at optimizing, and that's mainly size optimizing, so I'm having some trouble speeding it up. Even at 15mHz speed, it's still slow for large chunks of text. If anyone could help me speed this up, it would be greatly appreciated.

Here is the routine in question:
Code: [Select]
:Lbl TEX
:0→{L5}r
:0→{L5+2}
:r1→r4
:For(r5,0,length(r3))
:If {r3+r5}=1
:{L5+2} xor 1→{L5+2}
:End
:If {r3+r5}=3
:{L5} xor 1→{L5}
:End
:If {r3+r5}=2
:{L5+1} xor 1→{L5+1}
:End
:If {r3+r5}>3
:Pt-On(r1,r2,{r3+r5}*8+Pic1TX)
:If {L5+2}
:ref(r1,r2,{{r3+r5}+Pic2TX},4)
:rref(r1,r2,{{r3+r5}+Pic2TX},4)
:For(θ,4,7)
:0→{L1+θ}
:End
:conj({r3+r5}*8+Pic1TX,L1,4)
:Pt-On(r1+1→r1,r2,L1)
:End
:If {L5}
:rref(r1-{L5+2},r2,{{r3+r5}+Pic2TX}+{L5+2},6)
:End
:If {L5+1}
:ref(r1-{L5+2},r2+6,{{r3+r5}+Pic2TX}+{L5+2},1)
:End
:r1+{{r3+r5}+Pic2TX}→r1
:End
:If r1≥84
:r4→r1
:r2+6→r2
:End
:End
:Normal
:Return

Pic2TX is a list of the width of every small font character, Pic1TX is a compilation of sprites creating the full small font set.

Attached in the zip is: GUILIB3, the library with the routine in question; GUICML, the source for my library testing; ZGUITEXT, the library containing Pic1TX; ZGUITWID, the library containing Pic2TX; ZDROPMEN, Nemo's dropdown menu routine, slightly modified for my own devious purposes.

Again, any help is greatly appreciated, and would benefit anyone who would use the GUI Library once it's finished. Thank you in advance.
Title: Re: Need some help speed optimizing a routine
Post by: calc84maniac on June 13, 2011, 10:50:30 pm
Untested, but this should work I think:
Code: [Select]
:Lbl TEX
:0→r5
:r1→r4
:While {r3}→r6
:!If -1
:r5 xor 1→r5
:Else!If -1
:r5 xor 2→r5
:Else!If -1
:r5 xor 4→r5
:Else
:Pt-On(r1,r2,r6*8+Pic1TX)
:If r5 and 1
:ref(r1,r2,{r6+Pic2TX},4)
:rref(r1,r2,{r6+Pic2TX},4)
:conj(r6*8+Pic1TX,L1,4)
:0->{L1+4}r->{L1+6}r
:Pt-On(r1+1→r1,r2,L1)
:End
:If r5 and 2
:rref(r1-(r5 and 1),r2,{r6+Pic2TX}+(r5 and 1),6)
:End
:If r5 and 4
:ref(r1-(r5 and 1),r2+6,{r6+Pic2TX}+(r5 and 1),1)
:End
:r1+{r6+Pic2TX}→r1
:End
:If r1≥84
:r4→r1
:r2+6→r2
:End
:r3+1->r3
:End
:Normal
:Return

Edit: Switched to AND logic