<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wikiti.brandonw.net/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wikiti.brandonw.net/index.php?action=history&amp;feed=atom&amp;title=83Plus%3ABCALLs%3A40D8</id>
		<title>83Plus:BCALLs:40D8 - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wikiti.brandonw.net/index.php?action=history&amp;feed=atom&amp;title=83Plus%3ABCALLs%3A40D8"/>
		<link rel="alternate" type="text/html" href="https://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:40D8&amp;action=history"/>
		<updated>2026-04-24T11:24:16Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.5</generator>

	<entry>
		<id>https://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:40D8&amp;diff=4745&amp;oldid=prev</id>
		<title>FloppusMaximus: A curious discovery</title>
		<link rel="alternate" type="text/html" href="https://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:40D8&amp;diff=4745&amp;oldid=prev"/>
				<updated>2006-06-01T04:19:48Z</updated>
		
		<summary type="html">&lt;p&gt;A curious discovery&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:83Plus:BCALLs:By Name:FP_Math|ATan2Rad]] [[Category:83Plus:BCALLs:By Name|ATan2Rad]] [[Category:83Plus:BCALLs:By Address|40D8 - ATan2Rad]]&lt;br /&gt;
== Synopsis ==&lt;br /&gt;
'''Official Name:''' ATan2Rad&lt;br /&gt;
&lt;br /&gt;
'''BCALL Address:''' 40D8&lt;br /&gt;
&lt;br /&gt;
Compute the arctangent of [[83Plus:RAM:8478|OP1]] divided by [[83Plus:RAM:8483|OP2]], placing the result in the correct quadrant according to the signs of its arguments.&lt;br /&gt;
&lt;br /&gt;
=== Inputs ===&lt;br /&gt;
* [[83Plus:RAM:8478|OP1]] = Y coordinate&lt;br /&gt;
* [[83Plus:RAM:8483|OP2]] = X coordinate&lt;br /&gt;
* D = 0 (see below)&lt;br /&gt;
&lt;br /&gt;
=== Outputs ===&lt;br /&gt;
* [[83Plus:RAM:8478|OP1]] = angle in radians&lt;br /&gt;
&lt;br /&gt;
=== Destroys ===&lt;br /&gt;
* AF, BC, DE, HL&lt;br /&gt;
* OP1-OP5&lt;br /&gt;
&lt;br /&gt;
== Comments ==&lt;br /&gt;
The official documentation makes no mention of the effect of the D register; the initialization of D seems to have been left out accidentally.  To obtain the documented behavior, D should be set to zero.  In any case, D affects the output as follows:&lt;br /&gt;
&lt;br /&gt;
* If D is between 60h and DFh, the inverse hyperbolic tangent is computed instead.&lt;br /&gt;
* Otherwise, if bit 5 of D is set, the answer will be returned in degrees or radians depending on the mode.  If bit 5 is clear, the answer will always be returned in radians.&lt;br /&gt;
&lt;br /&gt;
Furthermore, this routine also uses the low bits of D to encode the original octant.  Specifically:&lt;br /&gt;
&lt;br /&gt;
* If the input point is below the X-axis, 0Ch will be added to D.&lt;br /&gt;
* If it is left of the Y-axis, D will be XORed with 4.&lt;br /&gt;
* If it is closer to the Y-axis than to the X-axis, D will be ORed with 10h.&lt;br /&gt;
&lt;br /&gt;
As a result, if the low bits of D are not initially zero, strange things will happen to the output octant.&lt;/div&gt;</summary>
		<author><name>FloppusMaximus</name></author>	</entry>

	</feed>