2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
10 # include <exec/types.h>
13 /****************************************************************************/
15 #define FIXED_ONE INT_TO_FIXED(1)
16 #define FIXED_PI 205887L
17 #define FIXED_2PI 411775L
18 #define FIXED_E 178144L
19 #define FIXED_ROOT2 74804L
20 #define FIXED_ROOT3 113512L
21 #define FIXED_GOLDEN 106039L
23 #define INT_TO_FIXED(x) ((x) << 16)
24 #define DOUBLE_TO_FIXED(x) ((Fixed32)(x * 65536.0 + 0.5))
25 #define FIXED_TO_INT(x) ((x) >> 16)
26 #define FIXED_TO_DOUBLE(x) (((double)x) / 65536.0)
27 #define ROUND_FIXED_TO_INT(x) (((x) + 0x8000) >> 16)
29 #define ANG90 (FIXED_PI/2)
30 #define ANG180 (FIXED_PI)
31 #define ANG270 (ANG180+ANG90)
32 #define ANG360 (FIXED_2PI)
34 /****************************************************************************/
38 Fixed32
FixSqrt( Fixed32
);
39 Fixed32
FixSqrti(ULONG x
);
40 //Fixed32 FixSinCos( Fixed32 theta, Fixed32 *sinus );
41 Fixed32
FixAtan2( Fixed32
, Fixed32
);
43 /****************************************************************************/
45 __inline
static Fixed32
FixMul(Fixed32 eins
,Fixed32 zwei
)
48 QUAD result
= (QUAD
)eins
* (QUAD
)zwei
;
55 ("muls.l %1,%1:%0 \n\t"
59 : "=d" (eins
), "=d" (zwei
)
60 : "0" (eins
), "1" (zwei
)
66 ("fmove.l %0,fp0 \n\t"
68 "fmul.s #$37800000,fp0 \n\t"
70 /* "fintrz.x fp0,fp0 \n\t"*/
74 : "0" (eins
), "d" (zwei
)
78 eins
= (Fixed32
) ( (double) eins
* (double) zwei
* 0.0000152587890625 );
81 #endif /* version060 */
88 /****************************************************************************/
90 __inline
static Fixed32
FixDiv(Fixed32 eins
,Fixed32 zwei
)
93 QUAD result
= ((QUAD
)eins
<< 16) / (QUAD
)zwei
;
94 eins
= (Fixed32
) result
;
103 "divs.l %1,d2:%0\n\t"
105 : "=d" (eins
), "=d" (zwei
)
106 : "0" (eins
), "1" (zwei
)
112 ("fmove.l %0,fp0 \n\t"
114 "fmul.s #$47800000,fp0 \n\t"
116 /* "fintrz.x fp0 \n\t"*/
120 : "0" (eins
), "d" (zwei
)
124 eins
= (double) eins
/ (double) zwei
* 65536.0;
126 #endif /* version060 */
128 #endif /* __AROS__ */
133 /****************************************************************************/
135 __inline
static LONG
FixSqr( Fixed32 a
)
137 // a = INT_TO_FIXED(a);
139 return FixMul( a
, a
);
142 /****************************************************************************/
144 __inline
static Fixed32
FixSinCos( Fixed32 theta
, Fixed32
*sinus
)
146 #define MAX_TRIG 1024
147 extern Fixed32 SinCosTab
[];
149 theta
= FIXED_TO_INT( FixMul( theta
<< 9, 20861 ) );
150 theta
&= (MAX_TRIG
- 1);
152 *sinus
= SinCosTab
[theta
];
154 if( ( theta
+= 256 ) >= MAX_TRIG
)
155 theta
= theta
- MAX_TRIG
;
157 return SinCosTab
[theta
];
160 /****************************************************************************/