OSDN Git Service

49a084fed42da5d4f0d9b3c2f405e74dd839a515
[proj16/16.git] / 16 / w_modex / FIXED32.HPP
1 #ifndef FIXEDPOINT_HPP\r
2     #define FIXEDPOINT_HPP\r
3 \r
4 typedef long Fixed32;          // 16.16 FixedPoint\r
5 typedef unsigned char Iangle;  // Integer angle (0..255)\r
6 \r
7 /* Macros for Type Conversion */\r
8 #define INT_TO_FIXED(x) ((x) << 16)\r
9 #define FIXED_TO_INT(x) ((x) >> 16)\r
10 #define ROUND_FIXED_TO_INT(x) (((x) + 0x8000) >> 16)\r
11 \r
12 // Loads Fixed32 datafiles\r
13 void initFixed32(void);\r
14 \r
15 // Common math functions\r
16 Fixed32 FixedMul(Fixed32 num1, Fixed32 num2);\r
17 Fixed32 FixedDiv(Fixed32 numer, Fixed32 denom);\r
18 void CosSin(Iangle theta, Fixed32 *Cos, Fixed32 *Sin);\r
19 \r
20 Fixed32 FixedMulASM(Fixed32 num1, Fixed32 num2);\r
21 #pragma aux FixedMulASM =   \\r
22     "imul edx"              \\r
23     "add eax, 8000h"        \\r
24     "adc edx, 0"            \\r
25     "shrd eax, edx, 16"     \\r
26     parm caller [eax] [edx] \\r
27     value [eax]             \\r
28     modify [eax edx];\r
29 \r
30 Fixed32 FixedDivASM(Fixed32 numer, Fixed32 denom);  // No rounding!\r
31 #pragma aux FixedDivASM =   \\r
32     "xor eax, eax"          \\r
33     "shrd eax, edx, 16"     \\r
34     "sar edx, 16"           \\r
35     "idiv ebx"              \\r
36     parm caller [edx] [ebx] \\r
37     value [eax]             \\r
38     modify [eax ebx edx];\r
39 \r
40 #endif\r
41 \r