mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 10:42:07 +00:00
Replace SLONG by int32_t
All affected `printf` have been fixed. Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "types.h"
|
||||
@@ -10,7 +11,7 @@
|
||||
#include "asm/symbol.h"
|
||||
|
||||
#define fix2double(i) ((double)(i/65536.0))
|
||||
#define double2fix(d) ((SLONG)(d*65536.0))
|
||||
#define double2fix(d) ((int32_t)(d*65536.0))
|
||||
#ifndef PI
|
||||
#define PI (acos(-1))
|
||||
#endif
|
||||
@@ -28,21 +29,21 @@ math_DefinePI(void)
|
||||
* Print a fixed point value
|
||||
*/
|
||||
void
|
||||
math_Print(SLONG i)
|
||||
math_Print(int32_t i)
|
||||
{
|
||||
if (i >= 0)
|
||||
printf("%ld.%05ld", i >> 16,
|
||||
((SLONG) (fix2double(i) * 100000 + 0.5)) % 100000);
|
||||
printf("%d.%05d", i >> 16,
|
||||
((int32_t) (fix2double(i) * 100000 + 0.5)) % 100000);
|
||||
else
|
||||
printf("-%ld.%05ld", (-i) >> 16,
|
||||
((SLONG) (fix2double(-i) * 100000 + 0.5)) % 100000);
|
||||
printf("-%d.%05d", (-i) >> 16,
|
||||
((int32_t) (fix2double(-i) * 100000 + 0.5)) % 100000);
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate sine
|
||||
*/
|
||||
SLONG
|
||||
math_Sin(SLONG i)
|
||||
int32_t
|
||||
math_Sin(int32_t i)
|
||||
{
|
||||
return (double2fix(sin(fix2double(i) * 2 * PI / 65536)));
|
||||
}
|
||||
@@ -50,8 +51,8 @@ math_Sin(SLONG i)
|
||||
/*
|
||||
* Calculate cosine
|
||||
*/
|
||||
SLONG
|
||||
math_Cos(SLONG i)
|
||||
int32_t
|
||||
math_Cos(int32_t i)
|
||||
{
|
||||
return (double2fix(cos(fix2double(i) * 2 * PI / 65536)));
|
||||
}
|
||||
@@ -59,8 +60,8 @@ math_Cos(SLONG i)
|
||||
/*
|
||||
* Calculate tangent
|
||||
*/
|
||||
SLONG
|
||||
math_Tan(SLONG i)
|
||||
int32_t
|
||||
math_Tan(int32_t i)
|
||||
{
|
||||
return (double2fix(tan(fix2double(i) * 2 * PI / 65536)));
|
||||
}
|
||||
@@ -68,8 +69,8 @@ math_Tan(SLONG i)
|
||||
/*
|
||||
* Calculate arcsine
|
||||
*/
|
||||
SLONG
|
||||
math_ASin(SLONG i)
|
||||
int32_t
|
||||
math_ASin(int32_t i)
|
||||
{
|
||||
return (double2fix(asin(fix2double(i)) / 2 / PI * 65536));
|
||||
}
|
||||
@@ -77,8 +78,8 @@ math_ASin(SLONG i)
|
||||
/*
|
||||
* Calculate arccosine
|
||||
*/
|
||||
SLONG
|
||||
math_ACos(SLONG i)
|
||||
int32_t
|
||||
math_ACos(int32_t i)
|
||||
{
|
||||
return (double2fix(acos(fix2double(i)) / 2 / PI * 65536));
|
||||
}
|
||||
@@ -86,8 +87,8 @@ math_ACos(SLONG i)
|
||||
/*
|
||||
* Calculate arctangent
|
||||
*/
|
||||
SLONG
|
||||
math_ATan(SLONG i)
|
||||
int32_t
|
||||
math_ATan(int32_t i)
|
||||
{
|
||||
return (double2fix(atan(fix2double(i)) / 2 / PI * 65536));
|
||||
}
|
||||
@@ -95,8 +96,8 @@ math_ATan(SLONG i)
|
||||
/*
|
||||
* Calculate atan2
|
||||
*/
|
||||
SLONG
|
||||
math_ATan2(SLONG i, SLONG j)
|
||||
int32_t
|
||||
math_ATan2(int32_t i, int32_t j)
|
||||
{
|
||||
return (double2fix
|
||||
(atan2(fix2double(i), fix2double(j)) / 2 / PI * 65536));
|
||||
@@ -105,8 +106,8 @@ math_ATan2(SLONG i, SLONG j)
|
||||
/*
|
||||
* Multiplication
|
||||
*/
|
||||
SLONG
|
||||
math_Mul(SLONG i, SLONG j)
|
||||
int32_t
|
||||
math_Mul(int32_t i, int32_t j)
|
||||
{
|
||||
return (double2fix(fix2double(i) * fix2double(j)));
|
||||
}
|
||||
@@ -114,8 +115,8 @@ math_Mul(SLONG i, SLONG j)
|
||||
/*
|
||||
* Division
|
||||
*/
|
||||
SLONG
|
||||
math_Div(SLONG i, SLONG j)
|
||||
int32_t
|
||||
math_Div(int32_t i, int32_t j)
|
||||
{
|
||||
return (double2fix(fix2double(i) / fix2double(j)));
|
||||
}
|
||||
@@ -123,8 +124,8 @@ math_Div(SLONG i, SLONG j)
|
||||
/*
|
||||
* Round
|
||||
*/
|
||||
SLONG
|
||||
math_Round(SLONG i)
|
||||
int32_t
|
||||
math_Round(int32_t i)
|
||||
{
|
||||
return double2fix(round(fix2double(i)));
|
||||
}
|
||||
@@ -132,8 +133,8 @@ math_Round(SLONG i)
|
||||
/*
|
||||
* Ceil
|
||||
*/
|
||||
SLONG
|
||||
math_Ceil(SLONG i)
|
||||
int32_t
|
||||
math_Ceil(int32_t i)
|
||||
{
|
||||
return double2fix(ceil(fix2double(i)));
|
||||
}
|
||||
@@ -141,8 +142,8 @@ math_Ceil(SLONG i)
|
||||
/*
|
||||
* Floor
|
||||
*/
|
||||
SLONG
|
||||
math_Floor(SLONG i)
|
||||
int32_t
|
||||
math_Floor(int32_t i)
|
||||
{
|
||||
return double2fix(floor(fix2double(i)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user