|
SGDK
A free and open development kit for the Sega Mega Drive
|
Mathematical methods. More...
Go to the source code of this file.
Classes | |
| struct | Vect2D_u16 |
| 2D Vector structure - u16 type. More... | |
| struct | Vect2D_s16 |
| 2D Vector structure - s16 type. More... | |
| struct | Vect2D_u32 |
| 2D Vector structure - u32 type. More... | |
| struct | Vect2D_s32 |
| 2D Vector structure - s32 type. More... | |
| struct | Vect2D_f16 |
| 2D Vector structure - f16 (fix16) type. More... | |
| struct | Vect2D_f32 |
| 2D Vector structure - f32 (fix32) type. More... | |
| struct | Vect2D_ff16 |
| 2D Vector structure - ff16 (fastfix16) type. More... | |
| struct | Vect2D_ff32 |
| 2D Vector structure - ff32 (fastfix32) type. More... | |
| struct | Mat2D_f16 |
| 2x2 Matrice structure - f16 (fix16) type. Internally uses 2 2D vectors. More... | |
| struct | Mat2D_f32 |
| 2x2 Matrice structure - f32 (fix32) type. Internally uses 2 2D vectors. More... | |
| struct | Mat2D_ff16 |
| 2x2 Matrice structure - ff16 (fastfix16) type. Internally uses 2 2D vectors. More... | |
| struct | Mat2D_ff32 |
| 2x2 Matrice structure - ff32 (fastfix32) type. Internally uses 2 2D vectors. More... | |
Macros | |
| #define | PI 3.14159265358979323846 |
| PI number (3,1415..) | |
| #define | FIX16_INT_BITS 10 |
| #define | FIX16_FRAC_BITS (16 - FIX16_INT_BITS) |
| #define | FIX16_INT_MASK (((1 << FIX16_INT_BITS) - 1) << FIX16_FRAC_BITS) |
| #define | FIX16_FRAC_MASK ((1 << FIX16_FRAC_BITS) - 1) |
| #define | FIX32_INT_BITS 22 |
| #define | FIX32_FRAC_BITS (32 - FIX32_INT_BITS) |
| #define | FIX32_INT_MASK (((1 << FIX32_INT_BITS) - 1) << FIX32_FRAC_BITS) |
| #define | FIX32_FRAC_MASK ((1 << FIX32_FRAC_BITS) - 1) |
| #define | FASTFIX16_INT_BITS 8 |
| #define | FASTFIX16_FRAC_BITS (16 - FASTFIX16_INT_BITS) |
| #define | FASTFIX16_INT_MASK (((1 << FASTFIX16_INT_BITS) - 1) << FASTFIX16_FRAC_BITS) |
| #define | FASTFIX16_FRAC_MASK ((1 << FASTFIX16_FRAC_BITS) - 1) |
| #define | FASTFIX32_INT_BITS 16 |
| #define | FASTFIX32_FRAC_BITS (32 - FASTFIX32_INT_BITS) |
| #define | FASTFIX32_INT_MASK (((1 << FASTFIX32_INT_BITS) - 1) << FASTFIX32_FRAC_BITS) |
| #define | FASTFIX32_FRAC_MASK ((1 << FASTFIX32_FRAC_BITS) - 1) |
| #define | FIX16(value) |
| Convert specified value to fix16. | |
| #define | FIX32(value) |
| Convert specified value to fix32. | |
| #define | FASTFIX16(value) |
| Convert specified value to "fast" fix16. | |
| #define | FASTFIX32(value) |
| Convert specified value to "fast" fix32. | |
| #define | F16(value) |
| Convert specified value to fix16 (short version) | |
| #define | F32(value) |
| Convert specified value to fix32 (short version) | |
| #define | FF16(value) |
| Convert specified value to "fast" fix16 (short version) | |
| #define | FF32(value) |
| Convert specified value to "fast" fix32 (short version) | |
| #define | F16_PI ((fix16) F16(PI)) |
| #define | F16_RAD_TO_DEG F16(57.29577951308232) |
| #define | F32_PI ((fix32) F32(PI)) |
| #define | min(X, Y) |
| Returns the lowest value between X an Y. | |
| #define | max(X, Y) |
| Returns the highest value between X an Y. | |
| #define | clamp(X, L, H) |
| Returns L if X is less than L, H if X is greater than H or X if in between L and H. | |
| #define | abs(X) |
| Returns the absolute value of X. | |
| #define | distance_approx(dx, dy) |
| #define | getApproximatedLog2(value) |
| #define | getLog2Int(value) |
| #define | intToFix16(a) |
| #define | fix16ToInt(a) |
| #define | fix16ToFix32(a) |
| #define | fix16Frac(a) |
| #define | fix16Int(a) |
| #define | fix16Round(a) |
| #define | fix16ToRoundedInt(a) |
| #define | fix16Add(a, b) |
| #define | fix16Sub(a, b) |
| #define | fix16Neg(a) |
| #define | fix16Mul(a, b) |
| #define | fix16Div(a, b) |
| #define | fix16Avg(a, b) |
| #define | fix16Log2(a) |
| #define | fix16Log10(a) |
| #define | fix16Sqrt(a) |
| #define | intToFix32(a) |
| #define | fix32ToInt(a) |
| #define | fix32ToFix16(a) |
| #define | fix32Frac(a) |
| #define | fix32Int(a) |
| #define | fix32Round(a) |
| #define | fix32ToRoundedInt(a) |
| #define | fix32Add(a, b) |
| #define | fix32Sub(a, b) |
| #define | fix32Neg(a) |
| #define | fix32Mul(a, b) |
| #define | fix32Div(a, b) |
| #define | fix32Avg(a, b) |
| #define | intToFastFix16(a) |
| #define | fastFix16ToInt(a) |
| #define | fastFix16Frac(a) |
| #define | fastFix16Int(a) |
| #define | fastFix16Round(a) |
| #define | fastFix16ToRoundedInt(a) |
| #define | fastFix16Mul(a, b) |
| #define | fastFix16Div(a, b) |
| #define | intToFastFix32(a) |
| #define | fastFix32ToInt(a) |
| #define | fastFix32Frac(a) |
| #define | fastFix32Int(a) |
| #define | fastFix32Round(a) |
| #define | fastFix32ToRoundedInt(a) |
| #define | fastFix32Mul(a, b) |
| #define | fastFix32Div(a, b) |
| #define | getApproximatedDistanceV(dx, dy) |
Typedefs | |
| typedef Vect2D_u16 | V2u16 |
| alias for Vect2D_u16 | |
| typedef Vect2D_s16 | V2s16 |
| alias for Vect2D_s16 | |
| typedef Vect2D_u32 | V2u32 |
| alias for Vect2D_u32 | |
| typedef Vect2D_s32 | V2s32 |
| alias for Vect2D_s32 | |
| typedef Vect2D_f16 | V2f16 |
| alias for Vect2D_f16 | |
| typedef Vect2D_f32 | V2f32 |
| alias for Vect2D_f32 | |
| typedef Vect2D_ff16 | V2ff16 |
| alias for Vect2D_ff16 | |
| typedef Vect2D_ff32 | V2ff32 |
| alias for Vect2D_ff32 | |
| typedef Mat2D_f16 | M2f16 |
| alias for Mat2D_f16 | |
| typedef Mat2D_f32 | M2f32 |
| alias for Mat2D_f32 | |
| typedef Mat2D_ff16 | M2ff16 |
| alias for Mat2D_ff16 | |
| typedef Mat2D_ff32 | M2ff32 |
| alias for Mat2D_ff32 | |
Functions | |
| u8 | rol8 (u8 value, u16 number) |
| ROL instruction for byte (8 bit) value. | |
| u16 | rol16 (u16 value, u16 number) |
| ROL instruction for short (16 bit) value. | |
| u32 | rol32 (u32 value, u16 number) |
| ROL instruction for long (32 bit) value. | |
| u8 | ror8 (u8 value, u16 number) |
| ROR instruction for byte (8 bit) value. | |
| u16 | ror16 (u16 value, u16 number) |
| ROR instruction for short (16 bit) value. | |
| u32 | ror32 (u32 value, u16 number) |
| ROR instruction for long (32 bit) value. | |
| u32 | mulu (u16 op1, u16 op2) |
| 16x16=32 unsigned multiplication. Force GCC to use proper 68000 mulu instruction. | |
| s32 | muls (s16 op1, s16 op2) |
| 16x16=32 signed multiplication. Force GCC to use proper 68000 muls instruction. | |
| u16 | divu (u32 op1, u16 op2) |
| Direct divu instruction (unsigned 32/16=16:16) access using inline assembly to process op1/op2 operation. | |
| s16 | divs (s32 op1, s16 op2) |
| Direct divs instruction (signed 32/16=16:16) access using inline assembly to process op1/op2 operation. | |
| u16 | modu (u32 op1, u16 op2) |
| Direct divu instruction (unsigned 32/16=16:16) access using inline assembly. | |
| s16 | mods (s32 op1, s16 op2) |
| Direct divs instruction (signed 32/16=16:16) access using inline assembly. | |
| u32 | divmodu (u32 op1, u16 op2) |
| Direct divu instruction (unsigned 32/16=16:16) access using inline assembly to process op1/op2 operation and op1op2 at same time. | |
| s32 | divmods (s32 op1, s16 op2) |
| Direct divs instruction (signed 32/16=16:16) access using inline assembly to process op1/op2 operation and op1op2 at same time. | |
| u32 | u16ToBCD (u16 value) |
| Convert u16 to BCD. | |
| u32 | u32ToBCD (u32 value) |
| Convert u32 to BCD. | |
| u32 | getNextPow2 (u32 value) |
| Return next pow2 value which is greater than specified 32 bits unsigned value. Ex: getNextPow2(700) = 1024 getNextPow2(18) = 32 | |
| u16 | getLog2 (u32 value) |
| Return integer log2 of specified 32 bits unsigned value. Ex: getLog2Int(1024) = 10 getLog2Int(12345) = 13 | |
| u32 | getApproximatedDistance (s32 dx, s32 dy) |
| Return euclidean distance approximation for specified vector. The returned distance is not 100% perfect but calculation is fast. | |
| u32 | getApproximatedDistanceV (V2s32 *v) |
| Return euclidean distance approximation for specified vector. The returned distance is not 100% perfect but calculation is fast. | |
| s16 | F16_toInt (fix16 value) |
| Convert fix16 to integer. | |
| fix32 | F16_toFix32 (fix16 value) |
| Convert specified fix16 value to fix32. | |
| fastfix16 | F16_toFastFix16 (fix16 value) |
| Convert specified fix16 value to fastfix16. | |
| fastfix32 | F16_toFastFix32 (fix16 value) |
| Convert specified fix16 value to fastfix32. | |
| fix16 | F16_frac (fix16 value) |
| Return fractional part of the specified value (fix16). | |
| fix16 | F16_int (fix16 value) |
| Return integer part of the specified value (fix16). | |
| fix16 | F16_abs (fix16 x) |
| Return the absolute value of the specified value (fix16). | |
| fix16 | F16_round (fix16 value) |
| Round the specified value to nearest integer (fix16). | |
| s16 | F16_toRoundedInt (fix16 value) |
| Round and convert the specified fix16 to integer. | |
| fix16 | F16_mul (fix16 val1, fix16 val2) |
| Compute and return the result of the multiplication of val1 and val2 (fix16). | |
| fix16 | F16_div (fix16 val1, fix16 val2) |
| Compute and return the result of the division of val1 by val2 (fix16). | |
| fix16 | F16_avg (fix16 val1, fix16 val2) |
| Compute and return the result of the average of val1 by val2 (fix16). | |
| fix16 | F16_log2 (fix16 value) |
| Compute and return the result of the Log2 of specified value (fix16). | |
| fix16 | F16_log10 (fix16 value) |
| Compute and return the result of the Log10 of specified value (fix16). | |
| fix16 | F16_sqrt (fix16 value) |
| Compute and return the result of the root square of specified value (fix16). | |
| fix16 | F16_normalizeAngle (fix16 angle) |
| Return a normalized form of the input angle degree: Output value is guaranteed to be in [FIX16(0)..FIX16(360)[ range. | |
| fix16 | F16_sin (fix16 angle) |
| Compute sinus of specified angle (in degree) and return it (fix16). | |
| fix16 | F16_cos (fix16 angle) |
| Compute cosinus of specified angle (in degree) and return it (fix16). | |
| fix16 | F16_tan (fix16 angle) |
| Compute the tangent of specified angle (in degree) and return it (fix16). | |
| fix16 | F16_atan (fix16 x) |
| Compute the arctangent of specified value and return it in degree (fix16). | |
| fix16 | F16_atan2 (fix16 y, fix16 x) |
| Compute the arctangent of y/x. i.e: return the angle (in degree) for the (0,0)-(x,y) vector. | |
| fix16 | sinFix16 (u16 value) |
| Compute sinus of specified value and return it as fix16. The input value is an integer defined as [0..1024] range corresponding to radian [0..2PI] range. | |
| fix16 | cosFix16 (u16 value) |
| Compute cosinus of specified value and return it as fix16. The input value is an integer defined as [0..1024] range corresponding to radian [0..2PI] range. | |
| fix16 | F16_degreeToRadian (fix16 degree) |
| Convert degree to radian (fix16) | |
| fix16 | F16_radianToDegree (fix16 radian) |
| Convert radian to degree (fix16) | |
| fix16 | F16_getAngle (fix16 x1, fix16 y1, fix16 x2, fix16 y2) |
| Compute and return the angle in degree between the 2 points defined by (x1,y1) and (x2,y2). | |
| void | F16_computePosition (fix16 *x2, fix16 *y2, fix16 x1, fix16 y1, fix16 ang, fix16 dist) |
| Compute the new position of the point defined by (x1, y1) by moving it by the given 'distance' in the 'angle' direction and store the result in (x2, y2). | |
| void | F16_computePositionEx (fix16 *x2, fix16 *y2, fix16 x1, fix16 y1, fix16 ang, fix16 dist, fix16 cosMul, fix16 sinMul) |
| Compute the new position of the point defined by (x1, y1) by moving it by the given 'distance' in the 'angle' direction and store the result in (x2, y2). | |
| s32 | F32_toInt (fix32 value) |
| Convert fix32 to integer. | |
| fix16 | F32_toFix16 (fix32 value) |
| Convert specified fix32 value to fix16. | |
| fastfix16 | F32_toFastFix16 (fix32 value) |
| Convert specified fix32 value to fastfix16. | |
| fastfix32 | F32_toFastFix32 (fix32 value) |
| Convert specified fix32 value to fastfix32. | |
| fix32 | F32_frac (fix32 value) |
| Return fractional part of the specified value (fix32). | |
| fix32 | F32_int (fix32 value) |
| Return integer part of the specified value (fix32). | |
| fix32 | F32_round (fix32 value) |
| Round the specified value to nearest integer (fix32). | |
| s32 | F32_toRoundedInt (fix32 value) |
| Round and convert the specified fix32 value to integer. | |
| fix32 | F32_mul (fix32 val1, fix32 val2) |
| Compute and return the result of the multiplication of val1 and val2 (fix32). WARNING: result can easily overflow so its recommended to stick with fix16 type for mul and div operations. | |
| fix32 | F32_div (fix32 val1, fix32 val2) |
| Compute and return the result of the division of val1 by val2 (fix32). WARNING: result can easily overflow so its recommended to stick with fix16 type for mul and div operations. | |
| fix32 | F32_avg (fix32 val1, fix32 val2) |
| Compute and return the result of the average of val1 by val2 (fix32). | |
| fix32 | F32_sin (fix16 angle) |
| Compute sinus of specified angle (in degree) and return it as fix32. | |
| fix32 | F32_cos (fix16 angle) |
| Compute cosinus of specified angle (in degree) and return it as fix32. | |
| fix32 | sinFix32 (u16 value) |
| Compute sinus of specified value and return it as fix32. The input value is an integer defined as [0..1024] range corresponding to radian [0..2PI] range. | |
| fix32 | cosFix32 (u16 value) |
| Compute cosinus of specified value and return it as fix32. The input value is an integer defined as [0..1024] range corresponding to radian [0..2PI] range. | |
| s16 | FF16_toInt (fastfix16 value) |
| Convert fastfix16 to integer. | |
| fix16 | FF16_toFix16 (fastfix16 value) |
| Convert fastfix16 to fix16. | |
| fix32 | FF16_toFix32 (fastfix16 value) |
| Convert fastfix16 to fix32. | |
| fastfix32 | FF16_toFastFix32 (fastfix16 value) |
| Convert fastfix16 to fastfix32. | |
| fastfix16 | FF16_frac (fastfix16 value) |
| Return fractional part of the specified value (fastfix16). | |
| fastfix16 | FF16_int (fastfix16 value) |
| Return integer part of the specified value (fastfix16). | |
| fastfix16 | FF16_round (fastfix16 value) |
| Round the specified value to nearest integer (fastfix16). | |
| s16 | FF16_toRoundedInt (fastfix16 value) |
| Round and convert the specified fastfix16 value to integer (fastfix16). | |
| fastfix16 | FF16_mul (fastfix16 val1, fastfix16 val2) |
| Compute and return the result of the multiplication of val1 and val2 (fastfix16). | |
| fastfix16 | FF16_div (fastfix16 val1, fastfix16 val2) |
| Compute and return the result of the division of val1 by val2 (fastfix16). | |
| fastfix32 | FF32_fromInt (s16 value) |
| Convert integer to fastfix32. | |
| s16 | FF32_toInt (fastfix32 value) |
| Convert fastfix32 to integer. | |
| fix16 | FF32_toFix16 (fastfix32 value) |
| Convert fastfix32 to fix16. | |
| fix32 | FF32_toFix32 (fastfix32 value) |
| Convert fastfix32 to fix32. | |
| fastfix16 | FF32_toFastFix16 (fastfix32 value) |
| Convert fastfix32 to fastfix16. | |
| fastfix32 | FF32_frac (fastfix32 value) |
| Return fractional part of the specified value (fastfix32). | |
| fastfix32 | FF32_int (fastfix32 value) |
| Return integer part of the specified value (fastfix32). | |
| fastfix32 | FF32_round (fastfix32 value) |
| Round the specified value to nearest integer (fastfix32). | |
| s32 | FF32_toRoundedInt (fastfix32 value) |
| Round and convert the specified fastfix32 value to integer. | |
| fastfix32 | FF32_mul (fastfix32 val1, fastfix32 val2) |
| Compute and return the result of the multiplication of val1 and val2 (fastfix32). WARNING: result can easily overflow so its recommended to stick with fix16 type for mul and div operations. | |
| fastfix32 | FF32_div (fastfix32 val1, fastfix32 val2) |
| Compute and return the result of the division of val1 by val2 (fastfix32). WARNING: result can easily overflow so its recommended to stick with fix16 type for mul and div operations. | |
| fastfix32 | FF32_getLog2Fast (fastfix32 value) |
| Return a not accurate but fast log2 approximation of the specified value (fastfixed32) Ex: getLog2(FASTFIX32(1)) = 0 getLog2(12345 << 16) = ~9.5 (real value = ~13.6) | |
| fix16 | V2D_F16_getAngle (V2f16 *pt1, V2f16 *pt2) |
| Compute and return the angle in degree (fix16) between the 2 points pt1 and pt2. | |
| void | V2D_F16_computePosition (V2f16 *pt, fix16 ang, fix16 dist) |
| Compute the new position of the point 'pt' by moving it by the given 'distance' in the 'angle' direction. | |
| void | V2D_F16_computePositionEx (V2f16 *pt, fix16 ang, fix16 dist, fix16 cosMul, fix16 sinMUl) |
| Compute the new position of the point 'pt' by moving it by the given 'distance' in the 'angle' direction. | |
| u32 | V2D_S32_getApproximatedDistance (V2s32 *v) |
| Return euclidean distance approximation for specified vector. The returned distance is not 100% perfect but calculation is fast. | |
Variables | |
| const fix16 | trigtab_f16 [90+1] |
| const fix32 | trigtab_f32 [(90 *4)+1] |
| const fix16 | log2tab_f16 [0x10000] |
| const fix16 | log10tab_f16 [0x10000] |
| const fix16 | sqrttab_f16 [0x10000] |
Mathematical methods.
This unit provides basic maths methods.
You can find a tutorial about how use maths with SGDK here.
| #define abs | ( | X | ) |
Returns the absolute value of X.
| #define clamp | ( | X, | |
| L, | |||
| H ) |
| #define distance_approx | ( | dx, | |
| dy ) |
| #define F16 | ( | value | ) |
| #define F32 | ( | value | ) |
| #define FASTFIX16 | ( | value | ) |
| #define fastFix16Div | ( | a, | |
| b ) |
| #define fastFix16Frac | ( | a | ) |
| #define fastFix16Int | ( | a | ) |
| #define fastFix16Mul | ( | a, | |
| b ) |
| #define fastFix16Round | ( | a | ) |
| #define fastFix16ToInt | ( | a | ) |
| #define fastFix16ToRoundedInt | ( | a | ) |
| #define FASTFIX32 | ( | value | ) |
| #define fastFix32Div | ( | a, | |
| b ) |
| #define fastFix32Frac | ( | a | ) |
| #define fastFix32Int | ( | a | ) |
| #define fastFix32Mul | ( | a, | |
| b ) |
| #define fastFix32Round | ( | a | ) |
| #define fastFix32ToInt | ( | a | ) |
| #define fastFix32ToRoundedInt | ( | a | ) |
| #define FF16 | ( | value | ) |
| #define FF32 | ( | value | ) |
| #define FIX16 | ( | value | ) |
| #define fix16Add | ( | a, | |
| b ) |
| #define fix16Avg | ( | a, | |
| b ) |
| #define fix16Div | ( | a, | |
| b ) |
| #define fix16Frac | ( | a | ) |
| #define fix16Int | ( | a | ) |
| #define fix16Log10 | ( | a | ) |
| #define fix16Log2 | ( | a | ) |
| #define fix16Mul | ( | a, | |
| b ) |
| #define fix16Neg | ( | a | ) |
| #define fix16Round | ( | a | ) |
| #define fix16Sqrt | ( | a | ) |
| #define fix16Sub | ( | a, | |
| b ) |
| #define fix16ToFix32 | ( | a | ) |
| #define fix16ToInt | ( | a | ) |
| #define fix16ToRoundedInt | ( | a | ) |
| #define FIX32 | ( | value | ) |
| #define fix32Add | ( | a, | |
| b ) |
| #define fix32Avg | ( | a, | |
| b ) |
| #define fix32Div | ( | a, | |
| b ) |
| #define fix32Frac | ( | a | ) |
| #define fix32Int | ( | a | ) |
| #define fix32Mul | ( | a, | |
| b ) |
| #define fix32Neg | ( | a | ) |
| #define fix32Round | ( | a | ) |
| #define fix32Sub | ( | a, | |
| b ) |
| #define fix32ToFix16 | ( | a | ) |
| #define fix32ToInt | ( | a | ) |
| #define fix32ToRoundedInt | ( | a | ) |
| #define getApproximatedDistanceV | ( | dx, | |
| dy ) |
| #define getApproximatedLog2 | ( | value | ) |
| #define getLog2Int | ( | value | ) |
| #define intToFastFix16 | ( | a | ) |
| #define intToFastFix32 | ( | a | ) |
| #define intToFix16 | ( | a | ) |
| #define intToFix32 | ( | a | ) |
| #define max | ( | X, | |
| Y ) |
Returns the highest value between X an Y.
| #define min | ( | X, | |
| Y ) |
Returns the lowest value between X an Y.
Compute cosinus of specified value and return it as fix16.
The input value is an integer defined as [0..1024] range corresponding to radian [0..2PI] range.
Compute cosinus of specified value and return it as fix32.
The input value is an integer defined as [0..1024] range corresponding to radian [0..2PI] range.
Direct divs instruction (signed 32/16=16:16) access using inline assembly to process op1/op2 operation and op1op2 at same time.
| op1 | first operand - dividende (32 bit) |
| op2 | second operand - divisor (16 bit) |
Direct divu instruction (unsigned 32/16=16:16) access using inline assembly to process op1/op2 operation and op1op2 at same time.
| op1 | first operand - dividende (32 bit) |
| op2 | second operand - divisor (16 bit) |
Direct divs instruction (signed 32/16=16:16) access using inline assembly to process op1/op2 operation.
| op1 | first operand (32 bit) |
| op2 | second operand (16 bit) |
Direct divu instruction (unsigned 32/16=16:16) access using inline assembly to process op1/op2 operation.
| op1 | first operand - dividende (32 bit) |
| op2 | second operand - divisor (16 bit) |
Compute the new position of the point defined by (x1, y1) by moving it by the given 'distance' in the 'angle' direction and store the result in (x2, y2).
| x2 | new X position |
| y2 | new Y position |
| x1 | current X position |
| y1 | current Y position |
| ang | angle in degree |
| dist | distance to move |
| void F16_computePositionEx | ( | fix16 * | x2, |
| fix16 * | y2, | ||
| fix16 | x1, | ||
| fix16 | y1, | ||
| fix16 | ang, | ||
| fix16 | dist, | ||
| fix16 | cosMul, | ||
| fix16 | sinMul ) |
Compute the new position of the point defined by (x1, y1) by moving it by the given 'distance' in the 'angle' direction and store the result in (x2, y2).
Return a not accurate but fast log2 approximation of the specified value (fastfixed32) Ex:
getLog2(FASTFIX32(1)) = 0
getLog2(12345 << 16) = ~9.5 (real value = ~13.6)
| value | fastfixed32 value to return log2 of |
Return euclidean distance approximation for specified vector.
The returned distance is not 100% perfect but calculation is fast.
| dx | delta X. |
| dy | delta Y. |
Return euclidean distance approximation for specified vector.
The returned distance is not 100% perfect but calculation is fast.
| v | 2D vector. |
Return integer log2 of specified 32 bits unsigned value. Ex:
getLog2Int(1024) = 10
getLog2Int(12345) = 13
| value | value to return log2 of |
Direct divs instruction (signed 32/16=16:16) access using inline assembly.
| op1 | first operand (32 bit) |
| op2 | second operand (16 bit) |
Direct divu instruction (unsigned 32/16=16:16) access using inline assembly.
| op1 | first operand (32 bit) |
| op2 | second operand (16 bit) |
16x16=32 signed multiplication. Force GCC to use proper 68000 muls instruction.
| op1 | first operand |
| op2 | second operand |
16x16=32 unsigned multiplication. Force GCC to use proper 68000 mulu instruction.
| op1 | first operand |
| op2 | second operand |
ROL instruction for short (16 bit) value.
| value | value to apply bit rotation |
| number | number of bit rotation |
ROL instruction for long (32 bit) value.
| value | value to apply bit rotation |
| number | number of bit rotation |
ROL instruction for byte (8 bit) value.
| value | value to apply bit rotation |
| number | number of bit rotation |
ROR instruction for short (16 bit) value.
| value | value to apply bit rotation |
| number | number of bit rotation |
ROR instruction for long (32 bit) value.
| value | value to apply bit rotation |
| number | number of bit rotation |
ROR instruction for byte (8 bit) value.
| value | value to apply bit rotation |
| number | number of bit rotation |
Compute sinus of specified value and return it as fix16.
The input value is an integer defined as [0..1024] range corresponding to radian [0..2PI] range.
Compute sinus of specified value and return it as fix32.
The input value is an integer defined as [0..1024] range corresponding to radian [0..2PI] range.
Compute the new position of the point 'pt' by moving it by the given 'distance' in the 'angle' direction.
| pt | point to move |
| ang | angle in degree |
| dist | distance to move |