3 #include "fixed32.hpp"
\r
14 fp = fopen("sintab.dat", "rb");
\r
15 fread(SinTab, 4, 256, fp);
\r
16 fread(CosTab, 4, 256, fp);
\r
22 FixedMul(Fixed32 num1, Fixed32 num2)
\r
26 short int hi1, hi2, lo1, lo2;
\r
30 lo1 = (num1 & 0xFFFF);
\r
31 lo2 = (num2 & 0xFFFF);
\r
38 return (Mm1 + Mm2 + mm + (((long)MM) << 16));
\r
43 FixedDiv(Fixed32 numer, Fixed32 denom)
\r
45 return (numer / ROUND_FIXED_TO_INT(denom));
\r
50 CosSin(Iangle theta, Fixed32 *Cos, Fixed32 *Sin)
\r
52 *Sin = SinTab[theta];
\r
53 *Cos = CosTab[theta];
\r
57 /* ASM fixedpoint math routines
\r
58 ;--------------------------------------------------
\r
59 ; Sqrt - Fixed Point Square Root (High/Normal Precision)
\r
62 ; Modified : ebx,ecx,edx
\r
65 ;This is the High Precision version for the sqrt.
\r
66 ;It gives the optimal 8.16 precision but takes
\r
67 ;a little longer (24 iterations, 48 bits intead of
\r
68 ;16 iterations and 32 bits)
\r
70 xor eax,eax ;eax is root
\r
73 mov edx,ecx ;edx = val
\r
74 sub edx,ebx ;val - bitsqr
\r
76 sub edx,eax ;val - root
\r
78 mov ecx,edx ;val >= (root+bitsqr) -> accept subs
\r
79 shr eax,1 ;root >> 1
\r
80 or eax,ebx ;root | bitsqr
\r
81 shr ebx,2 ;bitsqr>>2
\r
85 shr eax,1 ;val < (root+bitsqr) -> dont change val
\r
86 shr ebx,2 ;bitsqr>>2
\r
88 ; we now have the 8.8 precision
\r
95 mov edx,ecx ;edx = val
\r
96 sub edx,ebx ;val - bitsqr
\r
98 sub edx,eax ;val - root
\r
100 mov ecx,edx ;val >= (root+bitsqr) -> accept subs
\r
101 shr eax,1 ;root >> 1
\r
102 or eax,ebx ;root | bitsqr
\r
103 shr ebx,2 ;bitsqr>>2
\r
107 shr eax,1 ;val < (root+bitsqr) -> dont change val
\r
108 shr ebx,2 ;bitsqr>>2
\r