Author Topic: Routines  (Read 314426 times)

0 Members and 4 Guests are viewing this topic.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
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 :P

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

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
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,2
For(B,0,60,2
If Pxl-Test(B,A
Then
Pxl-On(B+1,A
Pxl-On(B,A+1
Pxl-On(B+1,A+1
Else
Pxl-Off(B+1,A
Pxl-Off(B,A+1
Pxl-Off(B+1,A+1
End
End
End

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 »

Offline Geekboy1011

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

i really need to try this soon X.x

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
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

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
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?

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
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?

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Routines
« Reply #36 on: March 05, 2010, 12:36:10 am »
What I mean is:
Code: [Select]
For(A,0,7
output(A,A,"HELLO
A+1->A
End
which is the equivalent of:
Code: [Select]
For(A,1,8,2)
output(A,A,"HELLO
End
in BASIC.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
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

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
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

Offline trevmeister66

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1009
  • Rating: +14/-5
    • View Profile
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]
DiagnosticOff
ClrDraw
6üA // X Variable
6üB // Y Variable
5üS // Size of "snake"
1üC // X direction
0üD // Y direction
0üE
[0664646464]üStr1
[0664646464]üStr2
sub(ZZ

Repeat getKey(15) or pxl-Test(A,B)
Pxl-On(A,B)
Pxl-Off({Str1+S-1},{Str2+S-1})
DispGraph
If getKey(1)
0üC
1üD
End
If getKey(2)
ú1üC
0üD
End
If getKey(3)
1üC
0üD
End
If getKey(4)
0üC
ú1üD
End
****MY PROBLEM STARTS HERE****
If getKey(54)  // If 2nd was pushed
0ü{Str1+S      // Store 0 into
0ü{Str2+S      // The 'new' location
1+SüS            // Increase S (size)
End
****AND ENDS HERE****
A+CüA
B+DüB
For(X,1,S-1)
{Str1+S-X-1}ü{Str1+S-X
{Str2+S-X-1}ü{Str2+S-X
End
Aü{Str1+0
Bü{Str2+0
Pause 50
End
Return

****DRAWS BOX AROUND SCREEN****
Lbl ZZ
For(X,0,95
Pxl-On(X,0)
Pxl-On(X,63)
End
For(X,0,63
Pxl-On(0,X)
Pxl-On(95,X)
End
Return

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 :)

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
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

Offline trevmeister66

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1009
  • Rating: +14/-5
    • View Profile
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 :)

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
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 :D
well let us know your findings so we can help if we can.
/e

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
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 x.x

I am still impressed by how fast it is, though.

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Routines
« Reply #44 on: March 05, 2010, 09:17:13 am »
Yay! Also I noticed for the others there is a way to speed them up a little, you just have to move the part where it stores to the first loops var outside the second loop to keep it from being set each time the second loop runs.

Yeah the compiled versions are usually around that large.
/e