diff options
| author | Derek Hensley <hensley.derek58@gmail.com> | 2024-06-03 11:33:03 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-03 14:33:03 -0400 |
| commit | f26e77ba4088f20e72e13409f9ad535039abd291 (patch) | |
| tree | fa39e6c8bb57bfe5729854c8ea2bd3e25ea4155f /src/code | |
| parent | 312b65d5e34878df4b70d8b9922e1082213b3662 (diff) | |
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 96b75ffaa89b1a4ca1c08278b28bc3c70224701a.
* Remove SHT_MINV
* SHRT_MAX
* Add M_PI
* Angle macros
* f suffix
* Format
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/PreRender.c | 4 | ||||
| -rw-r--r-- | src/code/cutscene_camera.c | 2 | ||||
| -rw-r--r-- | src/code/jpegdecoder.c | 2 | ||||
| -rw-r--r-- | src/code/jpegutils.c | 2 | ||||
| -rw-r--r-- | src/code/sys_cfb.c | 2 | ||||
| -rw-r--r-- | src/code/sys_math.c | 4 | ||||
| -rw-r--r-- | src/code/sys_matrix.c | 4 | ||||
| -rw-r--r-- | src/code/z_actor.c | 18 | ||||
| -rw-r--r-- | src/code/z_camera.c | 18 | ||||
| -rw-r--r-- | src/code/z_common_data.c | 2 | ||||
| -rw-r--r-- | src/code/z_eff_blure.c | 2 | ||||
| -rw-r--r-- | src/code/z_eventmgr.c | 4 | ||||
| -rw-r--r-- | src/code/z_fbdemo_fade.c | 2 | ||||
| -rw-r--r-- | src/code/z_fcurve_data_skelanime.c | 2 | ||||
| -rw-r--r-- | src/code/z_jpeg.c | 2 | ||||
| -rw-r--r-- | src/code/z_kankyo.c | 2 | ||||
| -rw-r--r-- | src/code/z_lib.c | 4 | ||||
| -rw-r--r-- | src/code/z_pause.c | 2 | ||||
| -rw-r--r-- | src/code/z_player_lib.c | 4 | ||||
| -rw-r--r-- | src/code/z_quake.c | 2 | ||||
| -rw-r--r-- | src/code/z_skin.c | 2 | ||||
| -rw-r--r-- | src/code/z_viszbuf.c | 2 |
22 files changed, 44 insertions, 44 deletions
diff --git a/src/code/PreRender.c b/src/code/PreRender.c index fa8805b41..52a914a07 100644 --- a/src/code/PreRender.c +++ b/src/code/PreRender.c @@ -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" diff --git a/src/code/cutscene_camera.c b/src/code/cutscene_camera.c index f225651fe..6eb782787 100644 --- a/src/code/cutscene_camera.c +++ b/src/code/cutscene_camera.c @@ -1,6 +1,6 @@ #include "prevent_bss_reordering.h" #include "global.h" -#include "libc/string.h" +#include "string.h" CutsceneCamera* sCurCsCamera; diff --git a/src/code/jpegdecoder.c b/src/code/jpegdecoder.c index e6998adc9..01d097641 100644 --- a/src/code/jpegdecoder.c +++ b/src/code/jpegdecoder.c @@ -1,5 +1,5 @@ #include "z64jpeg.h" -#include "libc/stdbool.h" +#include "stdbool.h" #include "macros.h" u8* sJpegBitStreamPtr; diff --git a/src/code/jpegutils.c b/src/code/jpegutils.c index fbf6c69c2..a24f86a89 100644 --- a/src/code/jpegutils.c +++ b/src/code/jpegutils.c @@ -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) { diff --git a/src/code/sys_cfb.c b/src/code/sys_cfb.c index a16a6b5c1..974e6cdf7 100644 --- a/src/code/sys_cfb.c +++ b/src/code/sys_cfb.c @@ -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" diff --git a/src/code/sys_math.c b/src/code/sys_math.c index 99d13c332..9649218b1 100644 --- a/src/code/sys_math.c +++ b/src/code/sys_math.c @@ -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); } /** diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index 66db1a35c..42ae4277b 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -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; diff --git a/src/code/z_actor.c b/src/code/z_actor.c index d8a4a8072..8f08b3f31 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -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; diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 609e035b1..ad2170d5f 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -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; } diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index e6d291831..bbbc420f4 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -2,7 +2,7 @@ #include "alignment.h" #include "sequence.h" -#include "libc/stdbool.h" +#include "stdbool.h" #include "z64environment.h" #include "z64transition.h" diff --git a/src/code/z_eff_blure.c b/src/code/z_eff_blure.c index 6ac53632f..22dab6432 100644 --- a/src/code/z_eff_blure.c +++ b/src/code/z_eff_blure.c @@ -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" diff --git a/src/code/z_eventmgr.c b/src/code/z_eventmgr.c index 5bad9f1a1..35e2f1fef 100644 --- a/src/code/z_eventmgr.c +++ b/src/code/z_eventmgr.c @@ -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; diff --git a/src/code/z_fbdemo_fade.c b/src/code/z_fbdemo_fade.c index f1e535594..64502a68e 100644 --- a/src/code/z_fbdemo_fade.c +++ b/src/code/z_fbdemo_fade.c @@ -1,6 +1,6 @@ #include "z64transition.h" -#include "libc/stdbool.h" +#include "stdbool.h" #include "gfx.h" #include "regs.h" #include "z64math.h" diff --git a/src/code/z_fcurve_data_skelanime.c b/src/code/z_fcurve_data_skelanime.c index 6569d95d7..2cc953246 100644 --- a/src/code/z_fcurve_data_skelanime.c +++ b/src/code/z_fcurve_data_skelanime.c @@ -27,7 +27,7 @@ #include "z64curve.h" -#include "libc/stdbool.h" +#include "stdbool.h" #include "z64actor.h" #include "z64animation.h" #include "z64curve.h" diff --git a/src/code/z_jpeg.c b/src/code/z_jpeg.c index cc2f24ee0..00cbe135a 100644 --- a/src/code/z_jpeg.c +++ b/src/code/z_jpeg.c @@ -1,6 +1,6 @@ #include "z64jpeg.h" -#include "libc/stdbool.h" +#include "stdbool.h" #include "main.h" #include "sys_ucode.h" #include "macros.h" diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 5f9757296..ae2487ecc 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -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" diff --git a/src/code/z_lib.c b/src/code/z_lib.c index 00bb37bc8..648f56cff 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -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) { diff --git a/src/code/z_pause.c b/src/code/z_pause.c index b16cc62c1..a1bcf8d92 100644 --- a/src/code/z_pause.c +++ b/src/code/z_pause.c @@ -20,7 +20,7 @@ */ #include "z64frameadvance.h" -#include "libc/stdbool.h" +#include "stdbool.h" #include "padutils.h" #include "macros.h" diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index bfe41894e..f08a1f4b5 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -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) { diff --git a/src/code/z_quake.c b/src/code/z_quake.c index 9c42e1f37..37b51df70 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -1,6 +1,6 @@ #include "z64quake.h" -#include "libc/string.h" +#include "string.h" #include "global.h" #include "z64view.h" diff --git a/src/code/z_skin.c b/src/code/z_skin.c index cbf85860b..5ced3edea 100644 --- a/src/code/z_skin.c +++ b/src/code/z_skin.c @@ -1,6 +1,6 @@ #include "z64skin.h" -#include "libc/stdbool.h" +#include "stdbool.h" #include "global.h" #include "gfx.h" diff --git a/src/code/z_viszbuf.c b/src/code/z_viszbuf.c index 86fb64474..e6ab69bdf 100644 --- a/src/code/z_viszbuf.c +++ b/src/code/z_viszbuf.c @@ -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. |
