Author Topic: Need some help speed optimizing a routine  (Read 1251 times)

0 Members and 1 Guest are viewing this topic.

Offline FinaleTI

  • Believe in the pony that believes in you!
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1830
  • Rating: +121/-2
  • Believe in the pony that believes in you!
    • View Profile
    • dmuckerman.tumblr.com
Need some help speed optimizing a routine
« 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.


Spoiler For Projects:

My projects haven't been worked on in a while, so they're all on hiatus for the time being. I do hope to eventually return to them in some form or another...

Spoiler For Pokemon TI:
Axe port of Pokemon Red/Blue to the 83+/84+ family. On hold.

Spoiler For Nostalgia:
My big personal project, an original RPG about dimensional travel and a few heroes tasked with saving the world.
Coding-wise, on hold, but I am re-working the story.

Spoiler For Finale's Super Insane Tunnel Pack of Doom:
I will be combining Blur and Collision Course into a single gamepack. On hold.

Spoiler For Nostalgia Origins: Sky's Story:
Prequel to Nostalgia. On hold, especially while the story is re-worked.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2898
  • Rating: +467/-17
    • View Profile
    • TI-Boy CE
Re: Need some help speed optimizing a routine
« Reply #1 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
« Last Edit: June 13, 2011, 10:54:14 pm by calc84maniac »
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman