34 0: (Round, Frac: Longword); |
34 0: (Round, Frac: Longword); |
35 1: (QWordValue : QWord); |
35 1: (QWordValue : QWord); |
36 end; |
36 end; |
37 {$endif FPC_LITTLE_ENDIAN} |
37 {$endif FPC_LITTLE_ENDIAN} |
38 |
38 |
39 operator := (i: LongInt) z : hwFloat; |
39 function int2hwFloat (i: LongInt) : hwFloat; |
40 |
40 |
41 operator + (z1, z2: hwFloat) z : hwFloat; |
41 operator + (z1, z2: hwFloat) z : hwFloat; |
42 operator - (z1, z2: hwFloat) z : hwFloat; |
42 operator - (z1, z2: hwFloat) z : hwFloat; |
43 operator - (z1: hwFloat) z : hwFloat; |
43 operator - (z1: hwFloat) z : hwFloat; |
44 |
44 |
45 operator * (z1, z2: hwFloat) z : hwFloat; |
45 operator * (z1, z2: hwFloat) z : hwFloat; |
46 operator * (z1: hwFloat; z2: LongInt) z : hwFloat; |
46 operator * (z1: hwFloat; z2: LongInt) z : hwFloat; |
47 operator / (z1, z2: hwFloat) z : hwFloat; |
47 operator / (z1, z2: hwFloat) z : hwFloat; |
|
48 operator / (z1: hwFloat; z2: LongInt) z : hwFloat; |
48 |
49 |
49 operator < (z1, z2: hwFloat) b : boolean; |
50 operator < (z1, z2: hwFloat) b : boolean; |
50 operator > (z1, z2: hwFloat) b : boolean; |
51 operator > (z1, z2: hwFloat) b : boolean; |
51 |
52 |
52 function cstr(z: hwFloat): string; |
53 function cstr(z: hwFloat): string; |
53 function hwRound(t: hwFloat): LongInt; |
54 function hwRound(t: hwFloat): LongInt; |
54 function hwAbs(t: hwFloat): hwFloat; |
55 function hwAbs(t: hwFloat): hwFloat; |
55 function hwSqr(t: hwFloat): hwFloat; |
56 function hwSqr(t: hwFloat): hwFloat; |
56 function hwSqrt(t: hwFloat): hwFloat; |
57 function hwSqrt(t: hwFloat): hwFloat; |
57 function Distance(dx, dy: hwFloat): hwFloat; |
58 function Distance(dx, dy: hwFloat): hwFloat; |
|
59 function DistanceI(dx, dy: LongInt): hwFloat; |
58 function AngleSin(Angle: Longword): hwFloat; |
60 function AngleSin(Angle: Longword): hwFloat; |
59 function AngleCos(Angle: Longword): hwFloat; |
61 function AngleCos(Angle: Longword): hwFloat; |
|
62 function SignAs(num, signum: hwFloat): hwFloat; |
60 |
63 |
61 const _1div1024: hwFloat = (isNegative: false; QWordValue: 4194304); |
64 const _1div1024: hwFloat = (isNegative: false; QWordValue: 4194304); |
62 _1div10000: hwFloat = (isNegative: false; QWordValue: 429496); |
65 _1div10000: hwFloat = (isNegative: false; QWordValue: 429496); |
63 _1div50000: hwFloat = (isNegative: false; QWordValue: 85899); |
66 _1div50000: hwFloat = (isNegative: false; QWordValue: 85899); |
64 _1div100000: hwFloat = (isNegative: false; QWordValue: 42950); |
67 _1div100000: hwFloat = (isNegative: false; QWordValue: 42950); |
93 _0_93: hwFloat = (isNegative: false; QWordValue: 3994319585); |
96 _0_93: hwFloat = (isNegative: false; QWordValue: 3994319585); |
94 _0_96: hwFloat = (isNegative: false; QWordValue: 4123168604); |
97 _0_96: hwFloat = (isNegative: false; QWordValue: 4123168604); |
95 _0_995: hwFloat = (isNegative: false; QWordValue: 4273492459); |
98 _0_995: hwFloat = (isNegative: false; QWordValue: 4273492459); |
96 _0_999: hwFloat = (isNegative: false; QWordValue: 4290672328); |
99 _0_999: hwFloat = (isNegative: false; QWordValue: 4290672328); |
97 _1_9: hwFloat = (isNegative: false; QWordValue: 8160437862); |
100 _1_9: hwFloat = (isNegative: false; QWordValue: 8160437862); |
|
101 _0: hwFloat = (isNegative: false; QWordValue: 0); |
|
102 _1: hwFloat = (isNegative: false; QWordValue: 4294967296); |
|
103 _2: hwFloat = (isNegative: false; QWordValue: 4294967296 * 2); |
|
104 _3: hwFloat = (isNegative: false; QWordValue: 4294967296 * 3); |
|
105 _4: hwFloat = (isNegative: false; QWordValue: 4294967296 * 4); |
|
106 _5: hwFloat = (isNegative: false; QWordValue: 4294967296 * 5); |
|
107 _6: hwFloat = (isNegative: false; QWordValue: 4294967296 * 6); |
|
108 _10: hwFloat = (isNegative: false; QWordValue: 4294967296 * 10); |
|
109 _16: hwFloat = (isNegative: false; QWordValue: 4294967296 * 16); |
|
110 _19: hwFloat = (isNegative: false; QWordValue: 4294967296 * 19); |
|
111 _20: hwFloat = (isNegative: false; QWordValue: 4294967296 * 20); |
|
112 _25: hwFloat = (isNegative: false; QWordValue: 4294967296 * 25); |
|
113 _30: hwFloat = (isNegative: false; QWordValue: 4294967296 * 30); |
|
114 _128: hwFloat = (isNegative: false; QWordValue: 4294967296 * 128); |
|
115 _450: hwFloat = (isNegative: false; QWordValue: 4294967296 * 450); |
|
116 _1024: hwFloat = (isNegative: false; QWordValue: 4398046511104); |
|
117 _2048: hwFloat = (isNegative: false; QWordValue: 8796093022208); |
|
118 _10000: hwFloat = (isNegative: false; QWordValue: 4294967296 * 10000); |
98 |
119 |
99 cLittle: hwFloat = (isNegative: false; QWordValue: 1); |
120 cLittle: hwFloat = (isNegative: false; QWordValue: 1); |
100 cHHKick: hwFloat = (isNegative: false; QWordValue: 128849018); |
121 cHHKick: hwFloat = (isNegative: false; QWordValue: 128849018); |
101 {$ENDIF} |
122 {$ENDIF} |
102 |
123 |
263 Result:= x + y; |
291 Result:= x + y; |
264 Result.QWordValue:= Round(sqrt(1.0 / $100000000 * (Result.QWordValue)) * $100000000); |
292 Result.QWordValue:= Round(sqrt(1.0 / $100000000 * (Result.QWordValue)) * $100000000); |
265 Distance:= Result |
293 Distance:= Result |
266 end; |
294 end; |
267 |
295 |
|
296 function DistanceI(dx, dy: LongInt): hwFloat; |
|
297 begin |
|
298 DistanceI:= Distance(int2hwFloat(dx), int2hwFloat(dy)) |
|
299 end; |
|
300 |
|
301 function SignAs(num, signum: hwFloat): hwFloat; |
|
302 begin |
|
303 SignAs:= num; |
|
304 SignAs.isNegative:= signum.isNegative |
|
305 end; |
|
306 |
268 {$INCLUDE SinTable.inc} |
307 {$INCLUDE SinTable.inc} |
269 |
308 |
270 function AngleSin(Angle: Longword): hwFloat; |
309 function AngleSin(Angle: Longword): hwFloat; |
271 begin |
310 begin |
272 AngleSin.isNegative:= false; |
311 AngleSin.isNegative:= false; |