Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
25 May, 2013, 04:26:51 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: [Axiom] Aiming Utility -  (Read 1189 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
Iambian
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 14:52:06
Date Registered: 04 September, 2008, 20:12:14
Location: Nowhere in particular
Posts: 636


Topic starter
Total Post Ratings: +167

View Profile
« on: 26 November, 2011, 11:11:26 »
+5

It spits out an angle that you can use to aim at targets given a delta X and Y. See the ReadME.

NOTE: This has not been tested. Please test this thing to see if it conforms to what the readme says. When I went about testing it, it drove me insane. I probably just need sleep.

Attached to this post is what I have so far. When I can verify that it works, I'll post another with source included in it. The arctangent routine that is used in the Axiom was sourced from CaDan. Please test it.

Arghablabbles. (This post will be edited as stuff is changed)

EDIT: Attachment replaced with one that actually works. This is to be version 0.02 of this Axiom. Thank you very much for your patience. I will continue to make this "better". And by better, I mean smaller with acceptable losses in accuracy, and also to make the routine "native" to the dimensions I gave it, rather than some hack job to make it "work". Also, source is included.

* arctan02.zip (62.49 KB - downloaded 21 times.)
« Last Edit: 28 November, 2011, 21:43:09 by Iambian » Logged

A Cherry-Flavored Iambian draws near... what do you do? ...
Projects in my development environment:
Celtic 3 (83+) 95% (Hold) | CaDan (83+) 15% (Rst) | E:SoR (84+) 10% (Rst) | CaDanITE (83+) 4% (Hold) | FF:TIoC (83+) 2% (Data)
Yeong
Eternally Young Scarlet Moon
LV12 Extreme Poster (Next: 5000)
************
Offline Offline

Gender: Male
Last Login: 20 May, 2013, 01:44:48
Date Registered: 15 October, 2010, 04:29:49
Location: Arden, NC
Posts: 3694


Total Post Ratings: +260

View Profile
« Reply #1 on: 26 November, 2011, 14:35:09 »
0

Cheesy
so with this, we can have that crazy shitload of bullets like CaDan in Axe? Cheesy
Perfect. Big smile
Logged

Project Redemption....

My project progresses:HERE
My Pastebin stuffs:HERE
Check your rate: HERE
My Animations: HERE
Spoiler for Images :D:

ノ◕ヮ◕)ノ:・゚ PENGUIN WAVE!!:„ø¤º°¨ ¨°º¤KEEP THE PENGUIN GOING ¸„ø¤º°¨ ¨°º¤øº LETS GO PENGUIN !¤¤º°¨¨°º¤øº¤ø„¸¸ø¤º°¨„ ø¤º°¨¨°º
Darl181
Vy'o'us pleorsdtu tlh'e gjaemue.
Coder Of Tomorrow
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Gender: Male
Last Login: Today at 03:49:31
Date Registered: 10 June, 2010, 00:32:08
Location: {I*9+L₁+1},{I*9+L₁+3}
Posts: 3282


Total Post Ratings: +267

View Profile WWW
« Reply #2 on: 27 November, 2011, 02:01:07 »
0

So this uses that giant method you posted in the CaDan topic? derp
Tho in my case imma stay with what's working already for Essence Tongue
« Last Edit: 27 November, 2011, 02:03:23 by Darl181 » Logged




 
Spoiler for Stuff:



OS 2.43  Boot 1.02  Hardware Rev. B

OS 1.04.32

OS 3.1.0.392  Boot1 3.0.99  Boot2 3.10.16
Spoiler for Misc:
Quote
You'll understand / It's not a shame / To be always / Losing the game / Burma-Shave
"Dynamic userbars!"
Omnimaga radio
Interactive Omnimaga radio
Our World of Text
Draw on websites
Then blow them up
In-browser flight simulator
Haxball: MMO soccer/air hockey game
  Draw with sand.  Yay?
The Game
You just lost the game
Zombo.com
light post color is #dfefff
dark post color is #cae4ff
quote box color is #6699ff
transparent color is...transparent 0.o
Spoiler for Forum search alternative (bookmarklet):
https://www.squarefree.com/bookmarklets/search.html
javascript:q=""+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);if(!q)q=prompt("No%20selected%20text;%20enter%20search%20term.").replace(/\s\+/g,"%252B");if(q!=null)location="http://www.google.com/search?q="+q.replace(/\s+/g,"+")+"+site:"+location.hostname;void(0);
epic7
Chopin!
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: Today at 03:32:19
Date Registered: 22 October, 2011, 01:45:43
Location: Northeast US
Posts: 2172


Total Post Ratings: +122

View Profile
« Reply #3 on: 27 November, 2011, 02:02:46 »
0

YES!
Logged



Current Projects:
TitleLanguageProgressStatus
DrillMiner    C (ndless)   35%         Active
?     C (ndless)   0%        Unconfirmed

Spoiler for Programming languages I currently know:
Java (Learning in AP Comp Sci)
C (Specifically Ndless)
Unity JavaScript
LabView (For FIRST robotics)
z80 ASM (Just a little bit Tongue)
Iambian
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 14:52:06
Date Registered: 04 September, 2008, 20:12:14
Location: Nowhere in particular
Posts: 636


Topic starter
Total Post Ratings: +167

View Profile
« Reply #4 on: 27 November, 2011, 09:46:19 »
0

Remember guys. I need people to test this thing because I didn't think this thing would actually work the first time around. As far as I can tell, it doesn't crash the system, but I don't know if it's giving the right outputs.

Cheesy
so with this, we can have that crazy shitload of bullets like CaDan in Axe? Cheesy
Perfect. Big smile
No. This allows you to aim like the enemies can in CaDan. Your Axe project still needs to be responsible for the bullets it outputs.
Logged

A Cherry-Flavored Iambian draws near... what do you do? ...
Projects in my development environment:
Celtic 3 (83+) 95% (Hold) | CaDan (83+) 15% (Rst) | E:SoR (84+) 10% (Rst) | CaDanITE (83+) 4% (Hold) | FF:TIoC (83+) 2% (Data)
Darl181
Vy'o'us pleorsdtu tlh'e gjaemue.
Coder Of Tomorrow
LV12 Extreme Poster (Next: 5000)
*
Offline Offline

Gender: Male
Last Login: Today at 03:49:31
Date Registered: 10 June, 2010, 00:32:08
Location: {I*9+L₁+1},{I*9+L₁+3}
Posts: 3282


Total Post Ratings: +267

View Profile WWW
« Reply #5 on: 27 November, 2011, 18:23:32 »
0

So this takes in X,Y,deltaX and deltaY?
How does it handle inflation...I'm supposing the coder has to inflate it theirself.  *256?
« Last Edit: 27 November, 2011, 18:23:51 by Darl181 » Logged




 
Spoiler for Stuff:



OS 2.43  Boot 1.02  Hardware Rev. B

OS 1.04.32

OS 3.1.0.392  Boot1 3.0.99  Boot2 3.10.16
Spoiler for Misc:
Quote
You'll understand / It's not a shame / To be always / Losing the game / Burma-Shave
"Dynamic userbars!"
Omnimaga radio
Interactive Omnimaga radio
Our World of Text
Draw on websites
Then blow them up
In-browser flight simulator
Haxball: MMO soccer/air hockey game
  Draw with sand.  Yay?
The Game
You just lost the game
Zombo.com
light post color is #dfefff
dark post color is #cae4ff
quote box color is #6699ff
transparent color is...transparent 0.o
Spoiler for Forum search alternative (bookmarklet):
https://www.squarefree.com/bookmarklets/search.html
javascript:q=""+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);if(!q)q=prompt("No%20selected%20text;%20enter%20search%20term.").replace(/\s\+/g,"%252B");if(q!=null)location="http://www.google.com/search?q="+q.replace(/\s+/g,"+")+"+site:"+location.hostname;void(0);
Iambian
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 14:52:06
Date Registered: 04 September, 2008, 20:12:14
Location: Nowhere in particular
Posts: 636


Topic starter
Total Post Ratings: +167

View Profile
« Reply #6 on: 27 November, 2011, 20:57:25 »
0

So this takes in X,Y,deltaX and deltaY?
How does it handle inflation...I'm supposing the coder has to inflate it theirself.  *256?
No, it just takes a delta X and delta Y. You have to do the (X2-X1),(Y2-Y1) yourself. The Axiom takes two arguments and gives out a single answer.

Each 16 bit argument is truncated to 8 bits for you. I just simply chop off the high byte.
Logged

A Cherry-Flavored Iambian draws near... what do you do? ...
Projects in my development environment:
Celtic 3 (83+) 95% (Hold) | CaDan (83+) 15% (Rst) | E:SoR (84+) 10% (Rst) | CaDanITE (83+) 4% (Hold) | FF:TIoC (83+) 2% (Data)
Quigibo
The Executioner
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 21 May, 2013, 02:03:21
Date Registered: 22 January, 2010, 05:02:37
Location: Los Angeles
Posts: 2022


Total Post Ratings: +1019

View Profile
« Reply #7 on: 27 November, 2011, 21:26:49 »
0

So basically this is the function better known as "atan2".  That's cool!  I added this recently for the next version of axe.
Logged

___Axe_Parser___
Today the calculator, tomorrow the world!
DJ Omnimaga
Retired Omnimaga founder (Site issues must be PM'ed to Netham45, Eeems, Shmibs, Deep Thought and AngelFish, not me.)
Editor
LV15 Omnimagician (Next: --)
*
Online Online

Gender: Male
Last Login: Today at 04:23:20
Date Registered: 25 August, 2008, 07:00:21
Location: Québec (Canada)
Posts: 50233


Total Post Ratings: +2615

View Profile WWW
« Reply #8 on: 27 November, 2011, 23:13:47 »
0

This seems interesting. I sometimes had troubles in the past with enemy aiming when I worked on some shooters, although in my case it was TI-BASIC. Good work I guess Cheesy
Logged

Retired 83+ coder, Omnimaga/TIMGUL founder. Now doing power metal music (formerly did electronica)

Follow me on Bandcamp|Facebook|Reverbnation|Youtube|Twitter|Myspace
Iambian
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 14:52:06
Date Registered: 04 September, 2008, 20:12:14
Location: Nowhere in particular
Posts: 636


Topic starter
Total Post Ratings: +167

View Profile
« Reply #9 on: 28 November, 2011, 15:57:06 »
0

So basically this is the function better known as "atan2".  That's cool!  I added this recently for the next version of axe.
Curious to know, but how are you calculating atan in your version? My guess is that you're going to use polynomial approximation?

My version uses a 256 byte LUT to help calculate the angle and it uses linear interpolation to fill the gap that the LUT creates. I can probably get away with a 64 byte LUT and further the linear interpolation to help give a "good enough" result, but I'd want a test routine to help me figure out if the values I'm getting are good.

And so it seems like I'm going to have to learn Axe (yeah, I don't know it very well) to pull together a test routine for this mess. Wish me luck on this one. Then I'll probably modify the routine and probably try to optimize it. But first thing is first. Gotta make sure it works.

EDIT: Also, I assume you're going to be using the tan-1( token? If you do that, what should I change mine to, since I happen to be using that as well?
EDIT2: Okay. Actually writing the test routine. Things appear to fail. Need some time to figure out the problem.
EDIT3: Success!
« Last Edit: 28 November, 2011, 21:43:54 by Iambian » Logged

A Cherry-Flavored Iambian draws near... what do you do? ...
Projects in my development environment:
Celtic 3 (83+) 95% (Hold) | CaDan (83+) 15% (Rst) | E:SoR (84+) 10% (Rst) | CaDanITE (83+) 4% (Hold) | FF:TIoC (83+) 2% (Data)
Quigibo
The Executioner
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 21 May, 2013, 02:03:21
Date Registered: 22 January, 2010, 05:02:37
Location: Los Angeles
Posts: 2022


Total Post Ratings: +1019

View Profile
« Reply #10 on: 28 November, 2011, 23:39:15 »
+1

Yeah, mine is lossy, but its very compact and tiny.  The most I have seen it off is by 4 binary degrees but on average its usually less than 3.  It is exact every 45 degrees.  This is the routine I'm using:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
p_ArcTan:
.db __ArcTanEnd-1-$
ex de,hl ;de = y
pop hl
ex (sp),hl ;hl = x
push hl
ld a,h ;\
xor d ; |Get pairity
rla ;/
jr c,__ArcTanSS ;\
add hl,de ; |
add hl,de ; |
__ArcTanSS: ; |
or a ; |hl = x +- y
sbc hl,de ;/
ex de,hl ;de = x +- y
ld b,6 ;\
__ArcTan64: ; |
add hl,hl ; |hl = 64y
djnz __ArcTan64 ;/
call $3F00+sub_SDiv ;hl = 64y/(x +- y)
pop af ;\
rla ; |Right side, fine
ret nc ;/
sbc a,a ;\
sub h ; |Reverse sign extend
ld h,a ;/
ld a,l ;\
add a,128 ; |Add or sub 128
ld l,a ;/
ret
__ArcTanEnd:

The arguments are currently backwards; (X,Y) instead of the traditional (Y,X).  I'm not sure which one I'm going to use yet.
« Last Edit: 28 November, 2011, 23:40:07 by Quigibo » Logged

___Axe_Parser___
Today the calculator, tomorrow the world!
Builderboy
Physics Guru
LV13 Extreme Addict (Next: 9001)
*************
Online Online

Gender: Male
Last Login: Today at 04:12:47
Date Registered: 20 April, 2009, 00:28:53
Location: Ravenholm
Posts: 5643


Total Post Ratings: +589

View Profile
« Reply #11 on: 29 November, 2011, 00:43:42 »
0

I think (X,Y) would make more sense to newer users, as well as users that have not used the Atan2() function before.
Logged

Quigibo
The Executioner
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 21 May, 2013, 02:03:21
Date Registered: 22 January, 2010, 05:02:37
Location: Los Angeles
Posts: 2022


Total Post Ratings: +1019

View Profile
« Reply #12 on: 29 November, 2011, 09:09:51 »
0

Yeah.  Nearly every programming language uses (Y,X) and every spreadsheet and math program uses (X,Y).  So I think I'll end up sticking with X,Y just because it optimizes better, and its more consistent with the rest of the Axe syntax when looked at independently of other programming languages.  Iambian used this convention as well.

Logged

___Axe_Parser___
Today the calculator, tomorrow the world!
Iambian
LV7 Elite (Next: 700)
*******
Offline Offline

Gender: Male
Last Login: 14 May, 2013, 14:52:06
Date Registered: 04 September, 2008, 20:12:14
Location: Nowhere in particular
Posts: 636


Topic starter
Total Post Ratings: +167

View Profile
« Reply #13 on: 29 November, 2011, 11:52:37 »
0

Okay. Not tested yet, but I reduced the size of the LUT to 64 bytes (old was 256) and did more linear interpolating to make up the difference. In the end, the size of the compile went from 400 bytes down to 206. Once I can verify that the new routine works "well", I'd like to run a speed test to compare Quigibo's routine versus mine, you know, to see if all that "extra stuff" in my routine is actually worth it.

Just as a note, because of the way the lookup table works, the results you get from X or Y going past -110 and 110 gets unstable since it's reading outside of the table's boundaries. I'm hoping this isn't a problem for some people, especially since the screen's only 96 by 64 pixels.

Can't test right now, though. Got a long as hell road trip coming up in less than 12 hours and I should've been asleep a long time ago.

If you guys want to run those tests while I'm gone, feel free to do so. I'm going to drop the untested code as an attachment on this post. Compare the results with the attachment on the first post of this thread and see if there's (much) difference. The attachments include everything you need to rebuild the Axiom. If you're running a Windows system, just double-click Z_MAKE.bat after extracting everything and it'll do its magic. Oh, and don't forget that it compiles to a .8xp file while Axioms ought to be .8xv's (?). Whoops.

* arctan03.zip (62.48 KB - downloaded 18 times.)
Logged

A Cherry-Flavored Iambian draws near... what do you do? ...
Projects in my development environment:
Celtic 3 (83+) 95% (Hold) | CaDan (83+) 15% (Rst) | E:SoR (84+) 10% (Rst) | CaDanITE (83+) 4% (Hold) | FF:TIoC (83+) 2% (Data)
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.495 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.