More General Cleanup (#1638)

* LINKER_FILES in makefile

* COLPOLY_GET_NORMAL

* math header

* libc

* M_PI for cosf and sinf files

* MAXFLOAT

* Revert "MAXFLOAT"

This reverts commit 96b75ffaa8.

* Remove SHT_MINV

* SHRT_MAX

* Add M_PI

* Angle macros

* f suffix

* Format
This commit is contained in:
Derek Hensley
2024-06-03 11:33:03 -07:00
committed by GitHub
parent 312b65d5e3
commit f26e77ba40
144 changed files with 372 additions and 369 deletions
+2 -2
View File
@@ -7,8 +7,8 @@
*/
#include "z64prerender.h"
#include "libc/alloca.h"
#include "libc/stdbool.h"
#include "alloca.h"
#include "stdbool.h"
#include "PR/gs2dex.h"
#include "global.h"
+1 -1
View File
@@ -1,6 +1,6 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "libc/string.h"
#include "string.h"
CutsceneCamera* sCurCsCamera;
+1 -1
View File
@@ -1,5 +1,5 @@
#include "z64jpeg.h"
#include "libc/stdbool.h"
#include "stdbool.h"
#include "macros.h"
u8* sJpegBitStreamPtr;
+1 -1
View File
@@ -1,5 +1,5 @@
#include "z64jpeg.h"
#include "libc/stdbool.h"
#include "stdbool.h"
#include "macros.h"
void JpegUtils_ProcessQuantizationTable(u8* dqt, JpegQuantizationTable* qt, u8 count) {
+1 -1
View File
@@ -34,7 +34,7 @@ s16 gCfbUpperAdjust;
u8 gSysCfbHiResEnabled;
#include "sys_cfb.h"
#include "libc/stdbool.h"
#include "stdbool.h"
#include "buffers.h"
#include "libc64/malloc.h"
#include "z64vimode.h"
+2 -2
View File
@@ -71,7 +71,7 @@ f32 Math_PowF(f32 base, s32 exp) {
* @remark original name: "sinf_table"
*/
f32 Math_SinF(f32 rad) {
return sins(RAD_TO_BINANG(rad)) * SHT_MINV;
return sins(RAD_TO_BINANG(rad)) * (1.0f / SHRT_MAX);
}
/**
@@ -80,7 +80,7 @@ f32 Math_SinF(f32 rad) {
* @remark original name: "cosf_table"
*/
f32 Math_CosF(f32 rad) {
return coss(RAD_TO_BINANG(rad)) * SHT_MINV;
return coss(RAD_TO_BINANG(rad)) * (1.0f / SHRT_MAX);
}
/**
+2 -2
View File
@@ -448,8 +448,8 @@ void Matrix_RotateXFApply(f32 x) {
if (x != 0.0f) {
cmf = sCurrentMatrix;
sin = sins(RAD_TO_BINANG(x)) * SHT_MINV;
cos = coss(RAD_TO_BINANG(x)) * SHT_MINV;
sin = sins(RAD_TO_BINANG(x)) * (1.0f / SHRT_MAX);
cos = coss(RAD_TO_BINANG(x)) * (1.0f / SHRT_MAX);
tempY = cmf->xy;
tempZ = cmf->xz;
+9 -9
View File
@@ -4064,7 +4064,7 @@ void Actor_DrawDoorLock(PlayState* play, s32 frame, s32 type) {
if ((i % 2) != 0) {
rotZStep = 2.0f * entry->chainAngle;
} else {
rotZStep = M_PI - (2.0f * entry->chainAngle);
rotZStep = M_PIf - (2.0f * entry->chainAngle);
}
chainRotZ += rotZStep;
@@ -4902,11 +4902,11 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[]
Matrix_Scale(frozenScale, frozenScale, frozenScale, MTXMODE_APPLY);
if (bodyPartIndex & 1) {
Matrix_RotateYF(M_PI, MTXMODE_APPLY);
Matrix_RotateYF(M_PIf, MTXMODE_APPLY);
}
if (bodyPartIndex & 2) {
Matrix_RotateZF(M_PI, MTXMODE_APPLY);
Matrix_RotateZF(M_PIf, MTXMODE_APPLY);
}
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx),
@@ -4984,7 +4984,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[]
Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0,
((bodyPartIndex * 10 + gameplayFrames) * -20) & 0x1FF, 32, 128));
Matrix_RotateYF(M_PI, MTXMODE_APPLY);
Matrix_RotateYF(M_PIf, MTXMODE_APPLY);
currentMatrix->mf[3][0] = bodyPartsPos->x;
currentMatrix->mf[3][1] = bodyPartsPos->y;
currentMatrix->mf[3][2] = bodyPartsPos->z;
@@ -5026,7 +5026,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[]
// Apply and draw a light orb over each body part of frozen actor
for (bodyPartIndex = 0; bodyPartIndex < bodyPartsCount; bodyPartIndex++, bodyPartsPos++) {
Matrix_RotateZF(Rand_CenteredFloat(2 * M_PI), MTXMODE_APPLY);
Matrix_RotateZF(Rand_CenteredFloat(2 * M_PIf), MTXMODE_APPLY);
currentMatrix->mf[3][0] = bodyPartsPos->x;
currentMatrix->mf[3][1] = bodyPartsPos->y;
currentMatrix->mf[3][2] = bodyPartsPos->z;
@@ -5065,8 +5065,8 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[]
// Every body part draws two electric sparks at random orientations
for (bodyPartIndex = 0; bodyPartIndex < bodyPartsCount; bodyPartIndex++, bodyPartsPos++) {
// first electric spark
Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI));
Matrix_RotateZF(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY);
Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PIf));
Matrix_RotateZF(Rand_ZeroFloat(2 * M_PIf), MTXMODE_APPLY);
currentMatrix->mf[3][0] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + bodyPartsPos->x;
currentMatrix->mf[3][1] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + bodyPartsPos->y;
currentMatrix->mf[3][2] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + bodyPartsPos->z;
@@ -5077,8 +5077,8 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[]
gSPDisplayList(POLY_XLU_DISP++, gElectricSparkModelDL);
// second electric spark
Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PI));
Matrix_RotateZF(Rand_ZeroFloat(2 * M_PI), MTXMODE_APPLY);
Matrix_RotateXFApply(Rand_ZeroFloat(2 * M_PIf));
Matrix_RotateZF(Rand_ZeroFloat(2 * M_PIf), MTXMODE_APPLY);
currentMatrix->mf[3][0] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + bodyPartsPos->x;
currentMatrix->mf[3][1] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + bodyPartsPos->y;
currentMatrix->mf[3][2] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + bodyPartsPos->z;
+9 -9
View File
@@ -45,7 +45,7 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "libc/string.h"
#include "string.h"
#include "z64malloc.h"
#include "z64quake.h"
#include "z64shrink_window.h"
@@ -1536,10 +1536,10 @@ s32 Camera_CalcAtForFriendlyLockOn(Camera* camera, VecGeo* eyeAtDir, Vec3f* targ
deltaY = focalActorPosRot->pos.y - *yPosOffset;
temp_f0_6 = Math_FAtan2F(deltaY, OLib_Vec3fDistXZ(at, &camera->eye));
if (temp_f0_6 > 0.34906584f) { // (M_PI / 9)
phi_f16 = 1.0f - Math_SinF(temp_f0_6 - 0.34906584f);
} else if (temp_f0_6 < -0.17453292f) { // (M_PI / 18)
phi_f16 = 1.0f - Math_SinF(-0.17453292f - temp_f0_6);
if (temp_f0_6 > (f32)(M_PI / 9)) {
phi_f16 = 1.0f - Math_SinF(temp_f0_6 - (f32)(M_PI / 9));
} else if (temp_f0_6 < -(f32)(M_PI / 18)) {
phi_f16 = 1.0f - Math_SinF(-(f32)(M_PI / 18) - temp_f0_6);
} else {
phi_f16 = 1.0f;
}
@@ -1616,10 +1616,10 @@ s32 Camera_CalcAtForEnemyLockOn(Camera* camera, VecGeo* arg1, Vec3f* arg2, f32 y
focalActorAtOffsetTarget.y -= deltaY;
} else {
if (temp_f0_3 > 0.34906584f) { // (M_PI / 9)
temp = 1.0f - Math_SinF(temp_f0_3 - 0.34906584f);
} else if (temp_f0_3 < -0.17453292f) { // (M_PI / 18)
temp = 1.0f - Math_SinF(-0.17453292f - temp_f0_3);
if (temp_f0_3 > (f32)(M_PI / 9)) {
temp = 1.0f - Math_SinF(temp_f0_3 - (f32)(M_PI / 9));
} else if (temp_f0_3 < -(f32)(M_PI / 18)) {
temp = 1.0f - Math_SinF(-(f32)(M_PI / 18) - temp_f0_3);
} else {
temp = 1.0f;
}
+1 -1
View File
@@ -2,7 +2,7 @@
#include "alignment.h"
#include "sequence.h"
#include "libc/stdbool.h"
#include "stdbool.h"
#include "z64environment.h"
#include "z64transition.h"
+1 -1
View File
@@ -1,6 +1,6 @@
#include "z64eff_blure.h"
#include "libc/stdbool.h"
#include "stdbool.h"
#include "gfx.h"
#include "macros.h"
#include "sys_matrix.h"
+2 -2
View File
@@ -6,7 +6,7 @@
#include "global.h"
#include "z64shrink_window.h"
#include "libc/string.h"
#include "string.h"
CutsceneEntry sGlobalCutsceneList[] = {
// CS_ID_GLOBAL_78
@@ -173,7 +173,7 @@ s16 CutsceneManager_MarkNextCutscenes(void) {
s32 j;
s32 count = 0;
s16 csIdMax = CS_ID_NONE;
s16 priorityMax = SHT_MAX; // lower number means higher priority
s16 priorityMax = SHRT_MAX; // lower number means higher priority
s16 csId;
s16 priority;
+1 -1
View File
@@ -1,6 +1,6 @@
#include "z64transition.h"
#include "libc/stdbool.h"
#include "stdbool.h"
#include "gfx.h"
#include "regs.h"
#include "z64math.h"
+1 -1
View File
@@ -27,7 +27,7 @@
#include "z64curve.h"
#include "libc/stdbool.h"
#include "stdbool.h"
#include "z64actor.h"
#include "z64animation.h"
#include "z64curve.h"
+1 -1
View File
@@ -1,6 +1,6 @@
#include "z64jpeg.h"
#include "libc/stdbool.h"
#include "stdbool.h"
#include "main.h"
#include "sys_ucode.h"
#include "macros.h"
+1 -1
View File
@@ -62,7 +62,7 @@ Gfx* sSkyboxStarsDList;
#include "z64environment.h"
#include "global.h"
#include "libc/string.h"
#include "string.h"
#include "sys_cfb.h"
#include "objects/gameplay_keep/gameplay_keep.h"
+2 -2
View File
@@ -32,11 +32,11 @@ void* Lib_MemSet(void* buffer, s32 value, size_t size) {
}
f32 Math_CosS(s16 angle) {
return coss(angle) * SHT_MINV;
return coss(angle) * (1.0f / SHRT_MAX);
}
f32 Math_SinS(s16 angle) {
return sins(angle) * SHT_MINV;
return sins(angle) * (1.0f / SHRT_MAX);
}
s32 Math_StepToIImpl(s32 start, s32 target, s32 step) {
+1 -1
View File
@@ -20,7 +20,7 @@
*/
#include "z64frameadvance.h"
#include "libc/stdbool.h"
#include "stdbool.h"
#include "padutils.h"
#include "macros.h"
+2 -2
View File
@@ -1812,9 +1812,9 @@ void Player_AdjustSingleLeg(PlayState* play, Player* player, SkelAnime* skelAnim
temp_f20 = (temp_f20 < 0.0f) ? 0.0f : sqrtf(temp_f20);
sp48 = Math_FAtan2F(temp_f20, sp58);
phi_t1 = (M_PI - (Math_FAtan2F(sp54, temp_f20) + ((M_PI / 2.0f) - sp48))) * (0x8000 / M_PI);
phi_t1 = RAD_TO_BINANG(M_PIf - (Math_FAtan2F(sp54, temp_f20) + ((M_PIf / 2) - sp48)));
phi_t1 = -skelAnime->jointTable[shinLimbIndex].z + phi_t1;
temp_f8 = (sp48 - sp4C) * (0x8000 / M_PI);
temp_f8 = RAD_TO_BINANG(sp48 - sp4C);
if ((s16)(ABS_ALT(skelAnime->jointTable[shinLimbIndex].x) + ABS_ALT(skelAnime->jointTable[shinLimbIndex].y)) <
0) {
+1 -1
View File
@@ -1,6 +1,6 @@
#include "z64quake.h"
#include "libc/string.h"
#include "string.h"
#include "global.h"
#include "z64view.h"
+1 -1
View File
@@ -1,6 +1,6 @@
#include "z64skin.h"
#include "libc/stdbool.h"
#include "stdbool.h"
#include "global.h"
#include "gfx.h"
+1 -1
View File
@@ -34,7 +34,7 @@
#include "z64vis.h"
#include "global.h"
#include "sys_cfb.h"
#include "libc/stdbool.h"
#include "stdbool.h"
// Height of the fragments the z-buffer is split into.
// It is the maximum amount of lines such that all rgba16 SCREEN_WIDTH-long lines fit into TMEM.