### Author Topic: Axe Q&A  (Read 543400 times)

0 Members and 2 Guests are viewing this topic.

#### Yeong

• Not a bridge
• LV12 Extreme Poster (Next: 5000)
• Posts: 3739
• Rating: +278/-12
• Survivor of Apocalypse
##### Re: Axe Q&A
« Reply #1455 on: April 05, 2012, 08:40:17 pm »
I'm sorry, but I didn't quite get what you're saying.
Sig wipe!

#### Runer112

• Project Author
• LV11 Super Veteran (Next: 3000)
• Posts: 2289
• Rating: +639/-31
##### Re: Axe Q&A
« Reply #1456 on: April 05, 2012, 08:42:58 pm »
Using a constant pointer like Str1 instead of a variable pointer like A is an optimization technique. Both methods will produce the same end results. But if you use a constant, your code will be smaller and faster.

#### Yeong

• Not a bridge
• LV12 Extreme Poster (Next: 5000)
• Posts: 3739
• Rating: +278/-12
• Survivor of Apocalypse
##### Re: Axe Q&A
« Reply #1457 on: April 05, 2012, 08:43:59 pm »
ah, ok.
I was stuck on where you mentioned something about 2 byte storing.
Sig wipe!

#### Deep Toaster

• So much to do, so much time, so little motivation
• LV13 Extreme Addict (Next: 9001)
• Posts: 8217
• Rating: +758/-15
##### Re: Axe Q&A
« Reply #1458 on: April 05, 2012, 08:46:24 pm »
A static variable is the same as a number to Axe, so 0→{L6}r is exactly the same as 0→{37696}r to Axe.

Variables are really shortcuts for {POINTER}r, so 0→A is exactly the same as 0→{°A}r is exactly the same as 0→{34852}r.

So if you were to do 0→{A}r, what you're really doing is  0→{{34852}r}r. That's why it's less optimized.

EDIT: Ninja'd.
« Last Edit: April 05, 2012, 08:47:30 pm by Deep Thought »

#### mrmprog

• LV7 Elite (Next: 700)
• Posts: 559
• Rating: +35/-1
##### Re: Axe Q&A
« Reply #1459 on: April 07, 2012, 10:57:23 pm »
What is the fastest way to count the black pixels in an 8*8 area?

#### leafy

• CoT Emeritus
• LV10 31337 u53r (Next: 2000)
• Posts: 1554
• Rating: +475/-97
• Seizon senryakuuuu!
##### Re: Axe Q&A
« Reply #1460 on: April 07, 2012, 11:40:45 pm »
I suppose you could use bit arithmetic with a pointer to a Pt-Get('ed sprite. I'm not too clear on how that would work though.
In-progress: Graviter (...)

#### jacobly

• LV5 Advanced (Next: 300)
• Posts: 205
• Rating: +161/-1
##### Re: Axe Q&A
« Reply #1461 on: April 08, 2012, 12:45:57 am »
Code: [Select]
:Lbl Count:0→r3:pt-Get(r1,r2):For(8):{→r1}:While :Select(,r3ʳ++) and (-1) .subtract not negative:End:r1+1:End:Return r3

#### calcdude84se

• Needs Motivation
• LV11 Super Veteran (Next: 3000)
• Posts: 2272
• Rating: +78/-13
• Wondering where their free time went...
##### Re: Axe Q&A
« Reply #1462 on: April 08, 2012, 11:49:22 am »
I suppose you could use bit arithmetic with a pointer to a Pt-Get('ed sprite. I'm not too clear on how that would work though.
If it's byte-aligned, he could even work with the bytes directly, instead of using Pt-Get(. With that said, the fastest way to find the number of set bits in a byte (which is a necessary part of this) is almost certainly a look-up table. Yes, it's 256 bytes, but it's far faster than any bit arithmetic you can do.
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
Spoiler For "PartesOS links":
I'll put it online when it does something.

#### mrmprog

• LV7 Elite (Next: 700)
• Posts: 559
• Rating: +35/-1
##### Re: Axe Q&A
« Reply #1463 on: April 08, 2012, 02:08:20 pm »
Thanks. I have another one:If I have four numbers, and one will be zero, what is the fastest way to find the next smallest number?

#### calcdude84se

• Needs Motivation
• LV11 Super Veteran (Next: 3000)
• Posts: 2272
• Rating: +78/-13
• Wondering where their free time went...
##### Re: Axe Q&A
« Reply #1464 on: April 08, 2012, 04:06:10 pm »
If exactly one number will be zero and the numbers aren't sorted in any way, I'm pretty sure the best way is to go through them with a variable containing the minimum value, while ignoring zeroes.
Here, for example, is some code that will give the minimum non-zero value in the first 100 bytes of L1 in M (And -1 if they're all 0):
Code: [Select]
-1->ML1->XFor(100If ({X}->V<M)?V=/=0V->MEndX++EndThere's probably a more optimized way to write that, but it should work.
If there could be more than one zero, the essence of what you have to do is have a flag that records whether you've already encountered one zero.
Edit: Runer112 wins by far. The method I've proposed would work better across lots of values (perhaps at least 10) than across 4.
« Last Edit: April 09, 2012, 03:25:15 pm by calcdude84se »
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
Spoiler For "PartesOS links":
I'll put it online when it does something.

#### Runer112

• Project Author
• LV11 Super Veteran (Next: 3000)
• Posts: 2289
• Rating: +639/-31
##### Re: Axe Q&A
« Reply #1465 on: April 08, 2012, 11:47:21 pm »
If it's only four numbers, the fastest way would be a couple of nested min() commands, like this.

Code: [Select]
min(min(A-1,B-1),min(C-1,D-1))+1
EDIT: Actually, I'm not entirely sure if this will work how you want it to. It depends whether or not you want 0 as a result if two or more of the values are 0. For instance, if the numbers were 0, 0, 1, 2, this routine would return 1.
« Last Edit: April 08, 2012, 11:52:55 pm by Runer112 »

#### parserp

• Hero Extraordinaire
• LV10 31337 u53r (Next: 2000)
• Posts: 1455
• Rating: +88/-7
• The King Has Returned
##### Re: Axe Q&A
« Reply #1466 on: April 16, 2012, 09:57:10 pm »

How do I achieve this? (program image and text)

#### Yeong

• Not a bridge
• LV12 Extreme Poster (Next: 5000)
• Posts: 3739
• Rating: +278/-12
• Survivor of Apocalypse
##### Re: Axe Q&A
« Reply #1467 on: April 16, 2012, 09:58:36 pm »
I'm pretty sure you can do the image with one of the axe command that I don't remember. (Something like #Image or something?)
but text, I have no clue.
Sig wipe!

#### Runer112

• Project Author
• LV11 Super Veteran (Next: 3000)
• Posts: 2289
• Rating: +639/-31
##### Re: Axe Q&A
« Reply #1468 on: April 16, 2012, 10:02:54 pm »
To quote the documentation:

Quote from: Documentation.pdf
The next thing you absolutely need is an Axe Header. You must start the first line with a
period, which is a comment in Axe, followed by the name you want for the compiled
program. If you want a program description, you can type a space and then the
description on that same line, but this is optional. In the above example your program
might look like this:

Code: [Select]
PROGRAM:MARIOSRC:.MARIO A fun platformer:

And to quote the commands list:

Quote
#Icon(HEX) Key: identity()   Tells the parser to replace the default icon with the new icon. The icon must be 64 hex characters long.

#### parserp

• Hero Extraordinaire
• LV10 31337 u53r (Next: 2000)
• Posts: 1455
• Rating: +88/-7
• The King Has Returned
##### Re: Axe Q&A
« Reply #1469 on: April 16, 2012, 10:04:14 pm »
Ah. That makes sense. Thanks!