Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Keoni29 on September 25, 2011, 11:00:22 am

Title: Some optimization
Post by: Keoni29 on September 25, 2011, 11:00:22 am
Can you optimize this?

L=Number of rows
S=Scroll height
r1: 0:Scroll Up
    1:Don't scroll, just refresh
    2:Scroll Down



Code: [Select]
Lbl SCROL
S+r1-1->S
If S>L
L-1->S
End
If S=L
0->S
End
RecallPic

Text(20,0,"SQ
Text(30,0,"SQ
Text(40,0,"SQ

For(r5,0,min(7,L-S-1)
Text(0,r5*6+20,S+r5->r2>Hex
End

For(r5,0,2
Fix 3
For(r2,0,min(7,L-S-1))
If r5=0
{r2+S+GDB1}>Hex->r4
ElseIf r5=1
{r2+S+GDB2}>Hex->r4
Else
{r2+S+GDB3}>Hex->r4
End
Text(r5*10+20,r2*6+10,{r3+2}>Char
Text {r3+3}>Char
Fix 2
End
End
DispgraphClrDraw

Title: Re: Some optimization
Post by: squidgetx on September 25, 2011, 11:06:10 am
Um, I'm not sure what that is supposed to be doing but you can check out the link in my sig for basic optimization help.

You can do !If r5 instead of If r5=0, likewise !If r5-1 for If r5=1. Text(x,y,ptr) if x and y are constants can be Text(y*256+x) : Text ptr
Title: Re: Some optimization
Post by: Keoni29 on September 25, 2011, 11:16:12 am
This part is the main problem:
Code: [Select]
For(r5,0,2
Fix 3
For(r2,0,min(7,L-S-1))
If r5=0
{r2+S+GDB1}>Hex->r3
ElseIf r5=1
{r2+S+GDB2}>Hex->r3
Else
{r2+S+GDB3}>Hex->r3
End
I don't want to repeat it every loop. I tried this, but it didnt work:
Code: [Select]
Lbl SCROL
S+r1-1->S
If S>L
L-1->S
End
If S=L
0->S
End
RecallPic

Text(20,0,"SQ
Text(30,0,"SQ
Text(40,0,"SQ

For(r5,0,min(7,L-S-1)
Text(0,r5*6+20,S+r5->r2>Hex
End

For(r5,0,2
If r5=0
{GDB1}->r4
ElseIf r5=1
{GDB2}->r4
Else
{GDB3}->r4
End
Fix 3
For(r2,0,min(7,L-S-1))
{r4+r2+S}>Hex->r3
Text(r5*10+20,r2*6+10,{r3+2}>Char
Text {r3+3}>Char
Fix 2
End
End
DispgraphClrDraw
Title: Re: Some optimization
Post by: Deep Toaster on September 25, 2011, 11:25:50 am
Not sure what you're trying to do, but here are some minor optimizations:
Quote from: Axe
Lbl SCROL
S+r1-1S
!If -L
S
ElseIf 0
L-1S
End
RecallPic

min(L-S-1,7)r6

"SQ"Str0

For(r5,0,r6)
Text(0,r5*6+20,S+r5r2>Hex
End

For(r5,0,2)
Text(r5+2*10,0,Str0)
Fix 3
For(r2,0,r6)
!If r5
GDB1
Else!If -1
GDB2
Else
GDB3
End
{+r2+S}r4
Text(r5*10+20,r2*6+10,{r3+2}>Char)
Text {r3+3}>Char
End
Fix 2
End
DispGraphClrDraw