Author Topic: Axe Q&A  (Read 600414 times)

0 Members and 3 Guests are viewing this topic.

Offline Aichi

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +76/-3
    • View Profile
    • Devrays
Re: Axe Q&A
« Reply #435 on: June 01, 2011, 08:12:01 am »
Take a look at the added video in my last post. The Axe Parser hooks have to be enabled.

Offline Aichi

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +76/-3
    • View Profile
    • Devrays
Re: Axe Q&A
« Reply #436 on: June 04, 2011, 01:24:40 pm »
Are there any optimizations for these routines?

Collision check routine for an object at r1, r2 and an object at r3, r4:
Code: [Select]
Lbl O
< (r2+6) and (r1+6 > r3 and (r3+6 > r1 and (r4+6 > r2
Return

Changing a tile (arg1 = X, arg2 = Y, HL = new tile ID):
Code: [Select]
Lbl W
-> {r2 + 4 / 8 * 60 + (r1 + V + 4 / 8) + L3 + J }
Return

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: Axe Q&A
« Reply #437 on: June 04, 2011, 01:32:31 pm »
Code: (Axe) [Select]
Lbl O
-r₂+5<11 and (r₁-r₃+5<11)
Return

Working on the second.

EDIT: All I can get there is to swap the J and L₃, like this:

Code: (Axe) [Select]
Lbl W
→{r₂+4/8*60+(r₁+V+4/8)+J+L₃}
Return

You should always put constants last in an expression. It actually makes a difference (in both speed and size).
« Last Edit: June 04, 2011, 01:36:05 pm by Deep Thought »




Offline Aichi

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +76/-3
    • View Profile
    • Devrays
Re: Axe Q&A
« Reply #438 on: June 04, 2011, 02:01:07 pm »
Wow, thanks a lot, Deep Thought. :O

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: Axe Q&A
« Reply #439 on: June 04, 2011, 03:05:10 pm »
Np. Make sure you test it first, because I haven't ;D

Should work though.
« Last Edit: June 04, 2011, 03:05:23 pm by Deep Thought »




Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #440 on: June 04, 2011, 05:28:35 pm »
Very good, padawan Deep Thought. But you still have much to learn to become a jedi master. ;)

10 bytes saved
Code: [Select]
Lbl O
Return!If -r₂sub(O0)
r₃-r₁
Lbl O0
+5<11
Return

3 bytes and ~1250 cycles saved  —  Note: although putting constants last is a good practice, in this case it saved nothing
Code: [Select]
Lbl W
→{r₂sub(W0)*60+(r₁+Vsub(W0))+J+L₃}
Lbl W0
*64+256/512
Return
« Last Edit: June 04, 2011, 05:43:09 pm by Runer112 »

Offline Aichi

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +76/-3
    • View Profile
    • Devrays
Re: Axe Q&A
« Reply #441 on: June 04, 2011, 06:03:24 pm »
 O.O
That's epic, Runer. I would have never be able to come up with those things.
Does your collision routine affect the speed as well? Speed has more priority than size for me, at least in these cases.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Axe Q&A
« Reply #442 on: June 04, 2011, 07:24:09 pm »
The collision routine will be 7 cycles slower if the y values are in the collision range, but it will be 115 cycles faster if they are not.

Also, if you're aiming for speed, you may want to use this instead of what I originally suggested for the second routine. Optimizing for size and optimizing for speed are two different beasts altogether!

Compared to my size-optimized suggestion: 8 bytes larger, ~1200 cycles faster
Code: [Select]
Lbl W
→{r₂sub(W0)*10*6+(r₁+Vsub(W0))+J+L₃}
Return
Lbl W0
/2/2+1/2
Return

Offline Aichi

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +76/-3
    • View Profile
    • Devrays
Re: Axe Q&A
« Reply #443 on: June 05, 2011, 02:28:24 pm »
Axe does automatically round off numbers by dividings. That causes a difference between X + 4 / 8 and X / 2 / 2 + 1 / 2.
* 64 + 256 / 512 seems fine though, thanks. :)

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Axe Q&A
« Reply #444 on: June 05, 2011, 04:30:26 pm »
Axe does automatically round off numbers by dividings. That causes a difference between X + 4 / 8 and X / 2 / 2 + 1 / 2.
* 64 + 256 / 512 seems fine though, thanks. :)
I don't think there should be a difference between the three.  Are you sure that there was one?

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Axe Q&A
« Reply #445 on: June 05, 2011, 04:30:38 pm »
Axe does automatically round off numbers by dividings. That causes a difference between X + 4 / 8 and X / 2 / 2 + 1 / 2.
* 64 + 256 / 512 seems fine though, thanks. :)
Well, X+4/4 is the same as X/2/2+1 though.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Aichi

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +76/-3
    • View Profile
    • Devrays
Re: Axe Q&A
« Reply #446 on: June 05, 2011, 05:21:48 pm »
Hm, strange, I've tested this:

Code: [Select]
.T
ClrHome
For(F,0,500)
If (Fsub(A)) - (Fsub(B))
Output(0,,F>Dec
End
End
sub(A)
+4 / 8
Return
sub(B)
/2/2+1/2
Return

And the screen stays white, so /2/2+1/2 is really equal to +4 / 8 for Axe Parser,
but /2/2+1/2 continues being not working (that seems to sound terribly for people who can actually speak correct english :P) in the code of my real project. It seems that any section of my code affects the collision routine.
I will use * 64 + 256 / 512, that works fine. :)

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Axe Q&A
« Reply #447 on: June 05, 2011, 05:26:41 pm »
Under what conditions does...
Code: [Select]
If inData(A,Data([num here],[another num],[etc],0))...return as true?

I made a little test program and it works fine, but when I put it into the source for Shift--taking out If D=2 or (D=3) and replacing it with If inData(D,Data(2,3,0))--it seems to always output true, even when I explicitly do 5→D immediately before ???
« Last Edit: June 05, 2011, 05:32:17 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Ashbad

  • Guest
Re: Axe Q&A
« Reply #448 on: June 05, 2011, 05:28:55 pm »
Under what conditions does...
Code: [Select]
If inData(A,Data([num here],[another num],[etc],0))...return as true?

I made a little test program and it works fine, but when I put it into the source for Shift--taking out If D=2 or (D=3) and replacing it with If inData(D,(2,3,0))--it seems to always output true ???

You need to do:

Code: [Select]
inData(D,Data(2,3,0))
It'll take the Data() in and check if anything in it is equal to D.  Always put 0 at the end, also. :)

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Axe Q&A
« Reply #449 on: June 05, 2011, 05:32:04 pm »
I know, look at the code box just above it :P
Forgot to type that in, but what I did was practically copy/paste from the working version and changed the numbers.  And it didn't work.
« Last Edit: June 05, 2011, 05:32:31 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue