port: rename some math functions to avoid conflicts with libc

This commit is contained in:
fgsfds 2023-08-13 17:13:08 +02:00
parent 6cb545aaf0
commit d51a7bc9d6
10 changed files with 22 additions and 22 deletions

View File

@ -57,7 +57,7 @@ s32 func0f096890(s32 arg0)
return value - (((value - nextvalue) * (arg0 & mask)) >> shiftamount);
}
u16 acos(s16 arg0)
u16 acosx(s16 arg0)
{
s32 value = arg0 >= 0 ? arg0 : -arg0;
@ -70,7 +70,7 @@ u16 acos(s16 arg0)
return value;
}
s16 asin(s16 arg0)
s16 asinx(s16 arg0)
{
s32 value = arg0 >= 0 ? arg0 : -arg0;

View File

@ -17,7 +17,7 @@ f32 acosf(f32 value)
intval = value * 32767.0f;
}
return acos(intval) * M_PI / 65535.0f;
return acosx(intval) * M_PI / 65535.0f;
}
f32 asinf(f32 value)
@ -32,5 +32,5 @@ f32 asinf(f32 value)
intval = value * 32767.0f;
}
return asin(intval) * M_PI / 65535.0f;
return asinx(intval) * M_PI / 65535.0f;
}

View File

@ -2213,7 +2213,7 @@ Gfx *bgScissorToViewport(Gfx *gdl)
Gfx *bgScissorWithinViewportF(Gfx *gdl, f32 viewleft, f32 viewtop, f32 viewright, f32 viewbottom)
{
gdl = bgScissorWithinViewport(gdl, viewleft, viewtop, ceil(viewright), ceil(viewbottom));
gdl = bgScissorWithinViewport(gdl, viewleft, viewtop, ceiltoint(viewright), ceiltoint(viewbottom));
return gdl;
}

View File

@ -21,7 +21,7 @@ f32 ceilf(f32 value)
return fvalue + 1;
}
s32 ceil(f32 value)
s32 ceiltoint(f32 value)
{
s32 ivalue;

View File

@ -21,7 +21,7 @@ f32 floorf(f32 value)
return fvalue - 1;
}
s32 floor(f32 value)
s32 floortoint(f32 value)
{
s32 ivalue;

View File

@ -40,7 +40,7 @@ s32 raceInitAnimGroup(struct attackanimconfig *configs)
struct attackanimconfig *config = configs;
while (config->animnum != 0) {
u16 angle = raceGetAnimSumAngleAsInt(config->animnum, 0, floor(config->unk04));
u16 angle = raceGetAnimSumAngleAsInt(config->animnum, 0, floortoint(config->unk04));
if (config->unk04 > 0) {
if (angle < 0x8000) {
@ -67,7 +67,7 @@ s32 raceInitAnimConfigSingle(struct attackanimconfig *config)
if (config->animnum != 0) {
u16 angle = raceGetAnimSumAngleAsInt(config->animnum, 0, floor(config->unk04));
u16 angle = raceGetAnimSumAngleAsInt(config->animnum, 0, floortoint(config->unk04));
if (config->unk04 > 0) {
if (angle < 0x8000) {

View File

@ -4,7 +4,7 @@
#include "data.h"
#include "types.h"
u16 acos(s16 arg0);
s16 asin(s16 arg0);
u16 acosx(s16 arg0);
s16 asinx(s16 arg0);
#endif

View File

@ -5,6 +5,6 @@
#include "types.h"
f32 ceilf(f32 value);
s32 ceil(f32 value);
s32 ceiltoint(f32 value);
#endif

View File

@ -5,6 +5,6 @@
#include "types.h"
f32 floorf(f32 value);
s32 floor(f32 value);
s32 floortoint(f32 value);
#endif

View File

@ -1718,7 +1718,7 @@ s32 modelConstrainOrWrapAnimFrame(s32 frame, s16 animnum, f32 endframe)
frame = 0;
}
} else if (endframe >= 0 && frame > (s32)endframe) {
frame = ceil(endframe);
frame = ceiltoint(endframe);
} else if (frame >= animGetNumFrames(animnum)) {
if (var8005efbc || (g_Anims[animnum].flags & ANIMFLAG_LOOP)) {
frame = frame % animGetNumFrames(animnum);
@ -2091,7 +2091,7 @@ void modelSetAnimFrame(struct model *model, f32 frame)
struct anim *anim = model->anim;
if (anim) {
framea = floor(frame);
framea = floortoint(frame);
forwards = anim->speed >= 0;
frameb = (forwards ? framea + 1 : framea - 1);
@ -2120,7 +2120,7 @@ void modelSetAnimFrame2(struct model *model, f32 frame1, f32 frame2)
modelSetAnimFrame(model, frame1);
if (anim->animnum2) {
s32 framea = floor(frame2);
s32 framea = floortoint(frame2);
s32 frameb;
bool forwards = anim->speed2 >= 0;
@ -2225,11 +2225,11 @@ void modelSetAnimFrame2WithChrStuff(struct model *model, f32 curframe, f32 endfr
}
if (forwards) {
floorcur = floor(curframe) + 1;
floorend = floor(endframe);
floorcur = floortoint(curframe) + 1;
floorend = floortoint(endframe);
} else {
floorcur = ceil(curframe) - 1;
floorend = ceil(endframe);
floorcur = ceiltoint(curframe) - 1;
floorend = ceiltoint(endframe);
}
if (g_Anims[anim->animnum].flags & ANIMFLAG_ABSOLUTETRANSLATION) {
@ -2464,8 +2464,8 @@ void modelSetAnimFrame2WithChrStuff(struct model *model, f32 curframe, f32 endfr
}
if (anim->animnum2 && (g_Anims[anim->animnum].flags & ANIMFLAG_ABSOLUTETRANSLATION) == 0) {
s32 floorcur2 = floor(curframe2);
s32 floorend2 = floor(endframe2);
s32 floorcur2 = floortoint(curframe2);
s32 floorend2 = floortoint(endframe2);
if ((forwards && floorcur2 < floorend2) || (!forwards && floorend2 < floorcur2)) {
if (rwdata->unk02 != 0) {