### Author Topic: Routines  (Read 165292 times)

0 Members and 1 Guest are viewing this topic.

#### Builderboy

• Physics Guru
• CoT Emeritus
• LV13 Extreme Addict (Next: 9001)
• Posts: 5673
• Rating: +613/-9
• Would you kindly?
##### Re: Routines
« Reply #30 on: February 26, 2010, 05:43:11 pm »
Oops, I changed T to B accidentally, i fixed it, made them all B's

With only these two terms of the Maclaurin series (X and X^3/6) Sin can actually be approximated within 1/100 of the real Sin function (remember we only have to go up to PI/2 because i use symmetry) and so the way this could be improved in accuracy is by using 100x instead of 10x.  You would have to be tricky with the math though because 150x150x150 would not fit into the regular int

#### DJ Omnimaga

• Former TI programmer
• CoT Emeritus
• LV15 Omnimagician (Next: --)
• Posts: 55829
• Rating: +3151/-232
• CodeWalrus founder & retired Omnimaga founder
##### Re: Routines
« Reply #31 on: March 04, 2010, 11:48:42 pm »
I made my first Axe Parser program tonight. I took the following program by Calc84maniac:

Code: [Select]
For(A,0,92,2For(B,0,60,2If Pxl-Test(B,AThenPxl-On(B+1,APxl-On(B,A+1Pxl-On(B+1,A+1ElsePxl-Off(B+1,APxl-Off(B,A+1Pxl-Off(B+1,A+1EndEndEnd
And with his help (such as telling me For doesn't support the last argument yet), I managed to turn this into an Axe Parser program, but a bit more complex. It is a program that pixelates the screen content in a style similar to old Super Nintendo games, such as when you are having a dream in Final Fantasy VI.

It is obviously slow, because it runs through multiple For( loops, but it is MUCH quicker than waht it would be in TI-BASIC. For every blur instances, it renders in about 0.75 seconds. Here's my code below:

Quote from: BASIC Code
:For(X,0,47
:For(Y,0,31
:2*X→A
:2*Y→B
:If pxl-Test(A,B
:Pxl-On(A+1,B
:Pxl-On(A,B+1
:Pxl-On(A+1,B+1
:Else
:Pxl-Off(A+1,B
:Pxl-Off(A,B+1
:Pxl-Off(A+1,B+1
:End
:End
:End
:DispGraph
:For(X,0,23
:For(Y,0,15
:4*X→A
:4*Y→B
:If pxl-Test(A,B
:For(C,0,3
:For(D,0,3
:Pxl-On(A+C,B+D
:End
:End
:Else
:For(C,0,3
:For(D,0,3
:Pxl-Off(A+C,B+D
:End
:End
:End
:End
:End
:DispGraph
:For(X,0,11
:For(Y,0,7
:8*X→A
:8*Y→B
:If pxl-Test(A,B
:For(C,0,7
:For(D,0,7
:Pxl-On(A+C,B+D
:End
:End
:Else
:For(C,0,7
:For(D,0,7
:Pxl-Off(A+C,B+D
:End
:End
:End
:End
:End
:DispGraph
Generated by SourceCoder, © 2005 Cemetech

With a screenshot attached below, showing it in action after recalling a pic in a BASIC program. NOTE: It runs at regular 83+ speed (6 MHz). If Axe was made so programs would run at the calc speed automatically, this would be twice as fast as it is now on SE models.
« Last Edit: March 04, 2010, 11:50:16 pm by DJ Omnimaga »
In case you are wondering where I went, I left Omni back in 2015 to form CodeWalrus due to various reasons explained back then, but I stopped calc dev in 2016 and am now mostly active on the CW Discord server at https://discord.gg/cuZcfcF

#### Geekboy1011

• The Oneironaut
• Donator
• LV11 Super Veteran (Next: 3000)
• Posts: 2028
• Rating: +119/-2
• Dream that Awakening dream
##### Re: Routines
« Reply #32 on: March 04, 2010, 11:54:47 pm »
thats awsome dj

i really need to try this soon X.x

#### Eeems

• Mr. Dictator
• LV13 Extreme Addict (Next: 9001)
• Posts: 6171
• Rating: +318/-36
• little oof
##### Re: Routines
« Reply #33 on: March 05, 2010, 12:06:18 am »
Wow! Pretty intense!
The easiest way to "add the last argument to for loops" would be to just add a <var>+#-><var> to the end (<var> stands for the variable that the for loop increments and # is the amount extra that you want to increment it).
That could probably help to speed your program up a little tiny bit. Especially due to the fact that adding is faster then multiplication here.
/e

#### DJ Omnimaga

• Former TI programmer
• CoT Emeritus
• LV15 Omnimagician (Next: --)
• Posts: 55829
• Rating: +3151/-232
• CodeWalrus founder & retired Omnimaga founder
##### Re: Routines
« Reply #34 on: March 05, 2010, 12:14:38 am »
mhmm what would you mean? Do you mean something like For(X,0,47*2?
In case you are wondering where I went, I left Omni back in 2015 to form CodeWalrus due to various reasons explained back then, but I stopped calc dev in 2016 and am now mostly active on the CW Discord server at https://discord.gg/cuZcfcF

#### Builderboy

• Physics Guru
• CoT Emeritus
• LV13 Extreme Addict (Next: 9001)
• Posts: 5673
• Rating: +613/-9
• Would you kindly?
##### Re: Routines
« Reply #35 on: March 05, 2010, 12:29:57 am »
Hey that looks awesome!  I don't know what You are talking about Eeems O.o what do you mean exactly?

#### Eeems

• Mr. Dictator
• LV13 Extreme Addict (Next: 9001)
• Posts: 6171
• Rating: +318/-36
• little oof
##### Re: Routines
« Reply #36 on: March 05, 2010, 12:36:10 am »
What I mean is:
Code: [Select]
For(A,0,7output(A,A,"HELLOA+1->AEndwhich is the equivalent of:
Code: [Select]
For(A,1,8,2)output(A,A,"HELLOEndin BASIC.
/e

#### DJ Omnimaga

• Former TI programmer
• CoT Emeritus
• LV15 Omnimagician (Next: --)
• Posts: 55829
• Rating: +3151/-232
• CodeWalrus founder & retired Omnimaga founder
##### Re: Routines
« Reply #37 on: March 05, 2010, 12:38:25 am »
oooh ok I see, I'll give this a try

thanks for the tips
In case you are wondering where I went, I left Omni back in 2015 to form CodeWalrus due to various reasons explained back then, but I stopped calc dev in 2016 and am now mostly active on the CW Discord server at https://discord.gg/cuZcfcF

#### Eeems

• Mr. Dictator
• LV13 Extreme Addict (Next: 9001)
• Posts: 6171
• Rating: +318/-36
• little oof
##### Re: Routines
« Reply #38 on: March 05, 2010, 12:40:51 am »
Np! I actually use a form of this in the most recent version of alien. For drawing the background, every time a pixel is drawn it adds 3 to A otherwise it will increment normally. This keeps it from having multiple "stars" in a row.
/e

#### trevmeister66

• LV9 Veteran (Next: 1337)
• Posts: 1009
• Rating: +14/-5
##### Re: Routines
« Reply #39 on: March 05, 2010, 12:43:55 am »
I have a question about a routine. I'm working on a project that has an array of numbers. Every time I go through the main loop, I move the numbers down one slot, and put in a new number in the 1st (or 0th) slot. While I do have this working fine, my problem comes when I try to increase the size of my array. I know that the arrays already have their max size, but I have it so it only does 'S' number of slots in the array, but when I increase 'S', it doesn't do what I want.

Well after rereading what i just said, I'm just going to post the code:
Code: [Select]
DiagnosticOffClrDraw6üA // X Variable6üB // Y Variable5üS // Size of "snake"1üC // X direction0üD // Y direction0üE[0664646464]üStr1[0664646464]üStr2sub(ZZRepeat getKey(15) or pxl-Test(A,B)Pxl-On(A,B)Pxl-Off({Str1+S-1},{Str2+S-1})DispGraphIf getKey(1)0üC1üDEndIf getKey(2)ú1üC0üDEndIf getKey(3)1üC0üDEndIf getKey(4)0üCú1üDEnd****MY PROBLEM STARTS HERE****If getKey(54)  // If 2nd was pushed0ü{Str1+S      // Store 0 into0ü{Str2+S      // The 'new' location1+SüS            // Increase S (size)End****AND ENDS HERE****A+CüAB+DüBFor(X,1,S-1){Str1+S-X-1}ü{Str1+S-X{Str2+S-X-1}ü{Str2+S-XEndAü{Str1+0Bü{Str2+0Pause 50EndReturn****DRAWS BOX AROUND SCREEN****Lbl ZZFor(X,0,95Pxl-On(X,0)Pxl-On(X,63)EndFor(X,0,63Pxl-On(0,X)Pxl-On(95,X)EndReturn
When I remove the "If getKey(54)....End" part, it works normally.... any suggestions?

SPOILER: it's a snake game, or an attempt at one rather.

Also, sorry about my lack of using the correct program to retrieve the proper symbols.
« Last Edit: March 05, 2010, 12:45:20 am by trevmeister66 »
Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit

#### Eeems

• Mr. Dictator
• LV13 Extreme Addict (Next: 9001)
• Posts: 6171
• Rating: +318/-36
• little oof
##### Re: Routines
« Reply #40 on: March 05, 2010, 01:03:28 am »
Well, I didn't look too closely, but the problem might be trying to use str1/str2 for your array, I would try L1/L2 instead. They have a large amount of room and Str1/2 only have what you define at the start.
but from what you say I guess you already understand this. Could you create a simple test that just lists off all the numbers in eacharray and see if it's calling the correct area?
/e

#### trevmeister66

• LV9 Veteran (Next: 1337)
• Posts: 1009
• Rating: +14/-5
##### Re: Routines
« Reply #41 on: March 05, 2010, 01:05:55 am »
Well, I didn't look too closely, but the problem might be trying to use str1/str2 for your array, I would try L1/L2 instead. They have a large amount of room and Str1/2 only have what you define at the start.
but from what you say I guess you already understand this. Could you create a simple test that just lists off all the numbers in eacharray and see if it's calling the correct area?
Hmm I might try your idea, although I believe it doesn't matter what you name your arrays/strings/pics because Axe just creates it into what it needs to be, regardless of what you name it. I'll just mess around with it some more.
Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit

#### Eeems

• Mr. Dictator
• LV13 Extreme Addict (Next: 9001)
• Posts: 6171
• Rating: +318/-36
• little oof
##### Re: Routines
« Reply #42 on: March 05, 2010, 01:07:50 am »
Ah ok. Also I just thought, using L1/2 makes your program smaller because you don't have to store the in it, it's stored on the ram
well let us know your findings so we can help if we can.
/e

#### DJ Omnimaga

• Former TI programmer
• CoT Emeritus
• LV15 Omnimagician (Next: --)
• Posts: 55829
• Rating: +3151/-232
• CodeWalrus founder & retired Omnimaga founder
##### Re: Routines
« Reply #43 on: March 05, 2010, 02:17:01 am »
Np! I actually use a form of this in the most recent version of alien. For drawing the background, every time a pixel is drawn it adds 3 to A otherwise it will increment normally. This keeps it from having multiple "stars" in a row.
Btw tried your method and altough I got no speed gain in the part where the screen is pixelated to have 4x4 or 8x8 squares, for the 2x2 part it goes 1.5x faster than it did.

The only issue, though, with both methods, is that the produced ASM code is horribly bigger than  the original source. The source program "BLUR" is 298 bytes large while the ASM one called "LOL" is 779 bytes. I saved a few bytes with your method, though, because it was in the 800s before. I guess maybe that kind of ASM program is a bit memory hungry or I did it wrong

I am still impressed by how fast it is, though.
In case you are wondering where I went, I left Omni back in 2015 to form CodeWalrus due to various reasons explained back then, but I stopped calc dev in 2016 and am now mostly active on the CW Discord server at https://discord.gg/cuZcfcF

• Mr. Dictator