2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
19 typedef long fix; //16 bits int, 16 bits frac
20 typedef short fixang; //angles
27 //Convert an int to a fix
28 #define i2f(i) ((i)<<16)
30 //Get the int part of a fix
31 #define f2i(f) ((f)>>16)
33 //Get the int part of a fix, with rounding
34 #define f2ir(f) (((f)+f0_5)>>16)
36 //Convert fix to float and float to fix
37 #define f2fl(f) (((float) (f)) / 65536.0)
38 #define fl2f(f) ((fix) ((f) * 65536))
40 //Some handy constants
59 fix fixmul(fix a,fix b);
60 #pragma aux fixmul parm [eax] [edx] = \
65 fix fixdiv(fix a,fix b);
66 #pragma aux fixdiv parm [eax] [ebx] modify exact [eax edx] = \
72 fix fixmuldiv(fix a,fix b,fix c);
73 #pragma aux fixmuldiv parm [eax] [edx] [ebx] modify exact [eax edx] = \
77 #pragma aux fixmulaccum parm [esi] [eax] [edx] modify exact [eax edx] = \
82 #pragma aux fixquadadjust parm [esi] modify exact [eax edx] = \
87 #pragma aux fixquadnegate parm [eax] modify exact [ebx] = \
96 #pragma aux fixdivquadlong parm [eax] [edx] [ebx] modify exact [eax edx] = \
99 //computes the square root of a long, returning a short
100 ushort long_sqrt(long a);
102 //computes the square root of a quad, returning a long
103 ulong quad_sqrt(long low,long high);
105 //computes the square root of a fix, returning a fix
108 //multiply two fixes, and add 64-bit product to a quad
109 void fixmulaccum(quad *q,fix a,fix b);
111 //extract a fix from a quad product
112 fix fixquadadjust(quad *q);
114 //divide a quad by a long
115 long fixdivquadlong(ulong qlow,long qhigh,long d);
118 void fixquadnegate(quad *q);
120 //compute sine and cosine of an angle, filling in the variables
121 //either of the pointers can be NULL
122 void fix_sincos(fix a,fix *s,fix *c); //with interpolation
123 void fix_fastsincos(fix a,fix *s,fix *c); //no interpolation
125 //compute inverse sine & cosine
126 fixang fix_asin(fix v);
127 fixang fix_acos(fix v);
129 //given cos & sin of an angle, return that angle.
130 //parms need not be normalized, that is, the ratio of the parms cos/sin must
131 //equal the ratio of the actual cos & sin for the result angle, but the parms
132 //need not be the actual cos & sin.
133 //NOTE: this is different from the standard C atan2, since it is left-handed.
134 fixang fix_atan2(fix cos,fix sin);
136 #pragma aux fix_fastsincos parm [eax] [esi] [edi] modify exact [eax ebx];
137 #pragma aux fix_sincos parm [eax] [esi] [edi] modify exact [eax ebx];
139 #pragma aux fix_asin "*" parm [eax] value [ax] modify exact [eax];
140 #pragma aux fix_acos "*" parm [eax] value [ax] modify exact [eax];
141 #pragma aux fix_atan2 "*" parm [eax] [ebx] value [ax] modify exact [eax ebx];
143 #pragma aux long_sqrt "*" parm [eax] value [ax] modify [];
144 #pragma aux fix_sqrt "*" parm [eax] value [eax] modify [];
145 #pragma aux quad_sqrt "*" parm [eax] [edx] value [eax] modify [];