Author Topic: Some optimization  (Read 6018 times)

0 Members and 1 Guest are viewing this topic.

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Some optimization
« 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

If you like my work: why not give me an internet?








Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Some optimization
« Reply #1 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

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: Some optimization
« Reply #2 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
If you like my work: why not give me an internet?








Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Some optimization
« Reply #3 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
« Last Edit: December 15, 2011, 11:28:36 pm by Deep Thought »