Applying sind/cosd/atan2d macros across the board (#518)

This commit is contained in:
mrshigure 2025-01-10 16:20:22 -08:00 committed by GitHub
parent 40da624fe7
commit 2455408432
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
47 changed files with 3431 additions and 3414 deletions

View file

@ -302,7 +302,7 @@ static void CoinChgAppear(omObjData *object, coinChg *coin_chg) {
f32 angle;
OSu16tof32(&coin_chg->angle, &angle);
angle = sin(M_PI * angle / 180.0);
angle = sind(angle);
scale = angle;
object->rot.x = 405.0f * angle;
BoardModelScaleSet(coin_chg->coin_model, scale, scale, scale);
@ -342,8 +342,8 @@ static void CoinChgSeparate(omObjData *object, coinChg *coin_chg) {
} else {
spacing = 105.0f;
}
y_offset = (200.0 * sin((M_PI * (2.0f * x_scale)) / 180.0));
x_scale = sin((M_PI * x_scale) / 180.0);
y_offset = 200.0 * sind(2.0f * x_scale);
x_scale = sind(x_scale);
object->rot.x = 45.0f + (315.0f * x_scale);
if (coin_chg->tens != 0) {
coin_x = object->trans.x + (x_scale * -spacing);
@ -379,7 +379,7 @@ static void CoinChgShow(omObjData* object, coinChg* coin_chg) {
f32 y_pos;
OSu16tof32(&coin_chg->angle, &angle);
angle = (f32) sin((M_PI * angle) / 180.0);
angle = sind(angle);
if (coin_chg->minus != 0) {
y_pos = (-50.0f * angle) + object->trans.y;
} else {

View file

@ -6,7 +6,7 @@
#include "game/flag.h"
#include "game/objsub.h"
#include "game/process.h"
#include "math.h"
#include "ext_math.h"
#define BLOCK_SPAWN 0
#define BLOCK_HIT 2
@ -312,7 +312,7 @@ static void SpawnBlock(BlockWork *arg0, omObjData *arg1)
}
arg1->rot.y = rotY;
arg1->scale.x = arg1->scale.y = arg1->scale.z = sin(M_PI * scaleAngle / 180.0);
arg1->scale.x = arg1->scale.y = arg1->scale.z = sind(scaleAngle);
}
static void HitBlock(BlockWork *arg0, omObjData *arg1)
@ -325,7 +325,7 @@ static void HitBlock(BlockWork *arg0, omObjData *arg1)
}
OSs16tof32(&arg0->hit_y_velocity, &var_f30);
arg1->trans.y += 0.2f * sin((M_PI * var_f30) / 180.0);
arg1->trans.y += 0.2f * sind(var_f30);
}
static void OpenBlock(BlockWork *arg0, omObjData *arg1)

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -12,6 +12,8 @@
#include "game/board/tutorial.h"
#include "game/board/window.h"
#include "ext_math.h"
// structs
typedef struct structActiveMG {
s16 unk_00;
@ -767,7 +769,7 @@ static void SeparateStatus(bitcopy* arg0, omObjData* arg1) {
return;
}
OSu8tof32((u8*)&arg0->unk_03, &temp_f29);
temp_f30 = sin((temp_f29 * M_PI) / 180.0) * 4.0 + 1.0;
temp_f30 = sind(temp_f29) * 4.0 + 1.0;
arg0->unk_03 += 6;
if (arg0->unk_03 > 0x5A) {
arg0->unk_03 = 0x5A;
@ -797,9 +799,9 @@ static void PopupVS(bitcopy* arg0, omObjData* arg1) {
}
OSs16tof32(&arg0->unk_04, &temp_f31);
if (arg0->unk_04 < 0x5A) {
var_f30 = 2.0 * sin((M_PI * temp_f31) / 180.0);
var_f30 = 2.0 * sind(temp_f31);
} else {
var_f30 = 1.0 + sin((M_PI * temp_f31) / 180.0);
var_f30 = 1.0 + sind(temp_f31);
if (arg0->unk_04 >= 0xB4) {
var_f30 = 1.0f;
temp_r28 = (bitcopy*) mgSetupObj->work;
@ -958,7 +960,7 @@ static void UpdateLuckyValue(bitcopy* arg0, omObjData* arg1) {
case 1:
if (arg0->unk_03 < 0x5A) {
OSu8tof32((u8*) &arg0->unk_03, &temp_f28);
temp_f29 = sin((M_PI * temp_f28) / 180.0);
temp_f29 = sind(temp_f28);
HuSprScaleSet(temp_r27->unk_00[0], 8, temp_f29, temp_f29);
HuSprScaleSet(temp_r27->unk_00[0], 9, temp_f29, temp_f29);
arg0->unk_03 += 2;
@ -1006,7 +1008,7 @@ static void UpdateLuckyValue(bitcopy* arg0, omObjData* arg1) {
return;
}
temp_f28 = (arg0->unk_04 % 360);
temp_f29 = (1.0 + (0.5 * sin((M_PI * temp_f28) / 180.0)));
temp_f29 = (1.0 + (0.5 * sind(temp_f28)));
HuSprScaleSet(temp_r27->unk_00[0], 8, temp_f29, temp_f29);
HuSprScaleSet(temp_r27->unk_00[0], 9, temp_f29, temp_f29);
break;
@ -1075,7 +1077,7 @@ static void UpdateMGList(bitcopy* arg0, omObjData* arg1) {
case 1:
if (arg0->unk_03 < 0x5A) {
OSu8tof32((u8*) &arg0->unk_03, &var_f26);
temp_f27 = sin((M_PI * var_f26) / 180.0);
temp_f27 = sind(var_f26);
arg0->unk_03 += 3;
HuSprScaleSet(temp_r24->unk_00[0], temp_r22, temp_f27, temp_f27);
return;
@ -1166,7 +1168,7 @@ static void UpdateMGList(bitcopy* arg0, omObjData* arg1) {
case 5:
if (arg0->unk_03 < 0x5A) {
OSu8tof32((u8*) &arg0->unk_03, &var_f26);
temp_f27 = (1.0 + (2.0 * sin((M_PI * var_f26) / 180.0)));
temp_f27 = (1.0 + (2.0 * sind(var_f26)));
arg0->unk_03 += 4;
if (arg0->unk_03 > 0x5A) {
arg0->unk_03 = 0x5A;

View file

@ -300,7 +300,7 @@ static void ExitBox(ItemGiveWork2* arg0, omObjData* arg1) {
}
arg1->trans.y = spC.y + (700.0f * cosd(arg0->unk_08));
arg1->rot.y = sin((M_PI * temp) / 180.0);
arg1->rot.y = sind(temp);
arg0->unk_08 -= 1.5f;
arg0->unk_06 -= 30;
}

View file

@ -20,6 +20,7 @@
#include "game/board/window.h"
#include "dolphin.h"
#include "ext_math.h"
#include "string.h"
typedef struct {
@ -238,7 +239,7 @@ static void ShowLogo(void) {
HuSprGrpPosSet(logoSprGrp, 288.0f, 240.0f);
for (spA = 0; spA < 90; spA += 4) {
OSs16tof32(&spA, &var_f27);
temp_f28 = sin(var_f27 * M_PI / 180.0);
temp_f28 = sind(var_f27);
HuSprScaleSet(logoSprGrp, 0, temp_f28, temp_f28);
HuPrcVSleep();
}
@ -246,7 +247,7 @@ static void ShowLogo(void) {
for (spA = 0; spA < 540; spA += 4) {
sp8 = spA % 180;
OSs16tof32(&sp8, &var_f27);
temp_f28 = 1.0 + 0.699999988079071 * sin(var_f27 * M_PI / 180.0);
temp_f28 = 1.0 + 0.7f * sind(var_f27);
HuSprScaleSet(logoSprGrp, 0, temp_f28, temp_f28);
HuPrcVSleep();
}
@ -254,7 +255,7 @@ static void ShowLogo(void) {
HuPrcSleep(0x78);
for (spA = 0; spA < 90; spA += 4) {
OSs16tof32(&spA, &var_f27);
temp_f28 = cos(var_f27 * M_PI / 180.0);
temp_f28 = cosd(var_f27);
HuSprScaleSet(logoSprGrp, 0, temp_f28, temp_f28);
HuPrcVSleep();
}
@ -586,7 +587,7 @@ static void PlayerDiceNumHide(omObjData *arg0, PlayerStartWork *arg1) {
arg1->unk02 = 2;
}
OSs16tof32(&arg1->unk06, &var_f28);
arg0->rot.x = 1.0 + 1.2999999523162842 * sin(var_f28 * M_PI / 180.0);
arg0->rot.x = 1.0 + 1.3f * sind(var_f28);
break;
case 2:
arg1->unk06 += 9;
@ -595,8 +596,8 @@ static void PlayerDiceNumHide(omObjData *arg0, PlayerStartWork *arg1) {
arg1->unk02 = 3;
}
OSs16tof32(&arg1->unk06, &var_f28);
arg0->rot.x = cos(0.5f * var_f28 * M_PI / 180.0);
arg0->rot.y = 1.0 + 1.2999999523162842 * sin(var_f28 * M_PI / 180.0);
arg0->rot.x = cosd(0.5f * var_f28);
arg0->rot.y = 1.0 + 1.3f * sind(var_f28);
break;
case 3:
BoardModelVisibilitySet(arg1->unk0A, 0);

View file

@ -12,7 +12,7 @@
#include "game/objsub.h"
#include "game/disp.h"
#include "math.h"
#include "ext_math.h"
static void WarpInit(s32);
static void WarpLaunch(s32);
@ -234,7 +234,7 @@ static void WarpImpact(s32 player) {
speed = 4.0f;
for (angle = 0.0f, temp = angle; angle < 180.0f; angle += speed) {
temp_f30 = sin((M_PI * angle) / 180.0);
temp_f30 = sind(angle);
BoardModelScaleSet(warpImpactMdl, 0.5f + temp_f30, 0.5f + temp_f30, 0.5f + temp_f30);
HuPrcVSleep();
}
@ -245,4 +245,4 @@ static void WarpImpact(s32 player) {
BoardPlayerIdleSet(warpImpactPlayer[i]);
}
warpState = 6;
}
}

View file

@ -3,7 +3,7 @@
#include "game/hsfmotion.h"
#include "game/disp.h"
#include "math.h"
#include "ext_math.h"
#define DISP_HALF_W (HU_DISP_WIDTH/2.0f)
#define DISP_HALF_H (HU_DISP_HEIGHT/2.0f)
@ -129,10 +129,10 @@ void CamMotionEx(s16 arg0, s16 arg1, Vec *arg2, Vec *arg3, Vec *arg4, float arg5
var_f30 = var_f31;
break;
case 1:
var_f30 = arg5 * sin(90.0f * (var_f31 / arg5) * M_PI / 180.0);
var_f30 = arg5 * sind(90.0f * (var_f31 / arg5));
break;
case 2:
var_f30 = arg5 * (1.0 - cos(90.0f * (var_f31 / arg5) * M_PI / 180.0));
var_f30 = arg5 * (1.0 - cosd(90.0f * (var_f31 / arg5)));
break;
}
var_r31 = temp_r21;
@ -346,9 +346,9 @@ static void SetObjCamMotion(s16 arg0, HsfTrack *arg1, float arg2, HsfexStruct02
case 14:
VECSubtract(&arg3->unk08, &arg3->unk20, &spC);
VECNormalize(&spC, &spC);
sp18.x = spC.x * spC.y * (1.0 - cos(M_PI * arg2 / 180.0)) - spC.z * sin(M_PI * arg2 / 180.0);
sp18.y = spC.y * spC.y + (1.0f - spC.y * spC.y) * cos(M_PI * arg2 / 180.0);
sp18.z = spC.y * spC.z * (1.0 - cos(M_PI * arg2 / 180.0)) + spC.x * sin(M_PI * arg2 / 180.0);
sp18.x = spC.x * spC.y * (1.0 - cosd(arg2)) - spC.z * sind(arg2);
sp18.y = spC.y * spC.y + (1.0f - spC.y * spC.y) * cosd(arg2);
sp18.z = spC.y * spC.z * (1.0 - cosd(arg2)) + spC.x * sind(arg2);
VECNormalize(&sp18, &arg3->unk14);
break;
}
@ -432,7 +432,7 @@ void Hu3D2Dto3D(Vec *arg0, s16 arg1, Vec *arg2) {
}
}
temp_r31 = &Hu3DCamera[i];
temp_f30 = sin((temp_r31->fov / 2) * M_PI / 180.0) / cos((temp_r31->fov / 2) * M_PI / 180.0);
temp_f30 = sind(temp_r31->fov / 2) / cosd(temp_r31->fov / 2);
temp_f31 = temp_f30 * arg0->z * 2.0f;
temp_f29 = temp_f31 * HU_DISP_ASPECT;
temp_f28 = arg0->x / HU_DISP_WIDTH;
@ -461,8 +461,8 @@ void Hu3D3Dto2D(Vec *arg0, s16 arg1, Vec *arg2) {
temp_r31 = &Hu3DCamera[i];
C_MTXLookAt(sp1C, &temp_r31->pos, &temp_r31->up, &temp_r31->target);
PSMTXMultVec(sp1C, arg0, &sp10);
temp_f31 = (sin((temp_r31->fov / 2) * M_PI / 180.0) / cos((temp_r31->fov / 2) * M_PI / 180.0)) * sp10.z * HU_DISP_ASPECT;
temp_f30 = (sin((temp_r31->fov / 2) * M_PI / 180.0) / cos((temp_r31->fov / 2) * M_PI / 180.0)) * sp10.z;
temp_f31 = (sind(temp_r31->fov / 2) / cosd(temp_r31->fov / 2)) * sp10.z * HU_DISP_ASPECT;
temp_f30 = (sind(temp_r31->fov / 2) / cosd(temp_r31->fov / 2)) * sp10.z;
arg2->x = DISP_HALF_W + sp10.x * (DISP_HALF_W / -temp_f31);
arg2->y = DISP_HALF_H + sp10.y * (DISP_HALF_H / temp_f30);
arg2->z = 0.0f;

View file

@ -6,7 +6,7 @@
#include "game/sprite.h"
#include "game/hsfman.h"
#include "game/audio.h"
#include "math.h"
#include "ext_math.h"
Vec CRot;
Vec Center;
@ -23,15 +23,15 @@ void omOutView(omObjData *object)
float rot_x = CRot.x;
float rot_y = CRot.y;
float rot_z = CRot.z;
pos.x = (sin(M_PI*rot_y/180.0)*cos(M_PI*rot_x/180.0)*CZoom)+Center.x;
pos.y = (-sin(M_PI*rot_x/180.0)*CZoom)+Center.y;
pos.z = (cos(M_PI*rot_y/180.0)*cos(M_PI*rot_x/180.0)*CZoom)+Center.z;
pos.x = (sind(rot_y)*cosd(rot_x)*CZoom)+Center.x;
pos.y = (-sind(rot_x)*CZoom)+Center.y;
pos.z = (cosd(rot_y)*cosd(rot_x)*CZoom)+Center.z;
target.x = Center.x;
target.y = Center.y;
target.z = Center.z;
up.x = sin(M_PI*rot_y/180.0)*sin(M_PI*rot_x/180.0);
up.y = cos(M_PI*rot_x/180.0);
up.z = cos(M_PI*rot_y/180.0)*sin(M_PI*rot_x/180.0);
up.x = sind(rot_y)*sind(rot_x);
up.y = cosd(rot_x);
up.z = cosd(rot_y)*sind(rot_x);
Hu3DCameraPosSet(1, pos.x, pos.y, pos.z, up.x, up.y, up.z, target.x, target.y, target.z);
}
@ -43,15 +43,15 @@ void omOutViewMulti(omObjData *object)
float rot_x = CRotM[i].x;
float rot_y = CRotM[i].y;
float rot_z = CRotM[i].z;
pos.x = (sin(M_PI*rot_y/180.0)*cos(M_PI*rot_x/180.0)*CZoomM[i])+CenterM[i].x;
pos.y = (-sin(M_PI*rot_x/180.0)*CZoomM[i])+CenterM[i].y;
pos.z = (cos(M_PI*rot_y/180.0)*cos(M_PI*rot_x/180.0)*CZoomM[i])+CenterM[i].z;
pos.x = (sind(rot_y)*cosd(rot_x)*CZoomM[i])+CenterM[i].x;
pos.y = (-sind(rot_x)*CZoomM[i])+CenterM[i].y;
pos.z = (cosd(rot_y)*cosd(rot_x)*CZoomM[i])+CenterM[i].z;
target.x = CenterM[i].x;
target.y = CenterM[i].y;
target.z = CenterM[i].z;
up.x = sin(M_PI*rot_y/180.0)*sin(M_PI*rot_x/180.0);
up.y = cos(M_PI*rot_x/180.0);
up.z = cos(M_PI*rot_y/180.0)*sin(M_PI*rot_x/180.0);
up.x = sind(rot_y)*sind(rot_x);
up.y = cosd(rot_x);
up.z = cosd(rot_y)*sind(rot_x);
Hu3DCameraPosSetV((1 << i), &pos, &up, &target);
}
}
@ -145,4 +145,4 @@ void omSysPauseCtrl(s16 flag)
} else {
omDBGSysKeyObj->work[0] |= 0x100;
}
}
}