diff options
| author | engineer124 <47598039+engineer124@users.noreply.github.com> | 2023-12-13 15:16:24 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-13 15:16:24 +1100 |
| commit | 5607eec18bae68e4cd38ef6d1fa69d7f1d84bfc8 (patch) | |
| tree | bb13ad49718f8883bc65d7bd0a9db4d791800cf2 /src/code | |
| parent | ed4da0ecef698ad0112c7cdf575368ac3c61903b (diff) | |
Use more `TRUNCF_BINANG` for f32 -> s16 casts (#1503)
* TRUNCF_BINANG
* brackets
* extra cast
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/cutscene_camera.c | 12 | ||||
| -rw-r--r-- | src/code/z_bgcheck.c | 6 | ||||
| -rw-r--r-- | src/code/z_camera.c | 49 | ||||
| -rw-r--r-- | src/code/z_en_item00.c | 2 | ||||
| -rw-r--r-- | src/code/z_lib.c | 2 | ||||
| -rw-r--r-- | src/code/z_message.c | 22 | ||||
| -rw-r--r-- | src/code/z_message_nes.c | 18 | ||||
| -rw-r--r-- | src/code/z_parameter.c | 2 | ||||
| -rw-r--r-- | src/code/z_player_lib.c | 6 | ||||
| -rw-r--r-- | src/code/z_quake.c | 2 | ||||
| -rw-r--r-- | src/code/z_skelanime.c | 6 | ||||
| -rw-r--r-- | src/code/z_snap.c | 4 | ||||
| -rw-r--r-- | src/code/z_sub_s.c | 4 |
13 files changed, 68 insertions, 67 deletions
diff --git a/src/code/cutscene_camera.c b/src/code/cutscene_camera.c index 53474bf88..e2d4bdd0a 100644 --- a/src/code/cutscene_camera.c +++ b/src/code/cutscene_camera.c @@ -401,9 +401,9 @@ s16 CutsceneCamera_Interp_Linear(Vec3f* camPos, f32* camFov, s16* camRoll, CsCmd targetRoll = CAM_DEG_TO_BINANG(miscCmd->roll); - rollDiffToTarget = (s16)(targetRoll - (s16)interpState->initRoll); + rollDiffToTarget = (s16)(targetRoll - TRUNCF_BINANG(interpState->initRoll)); - *camRoll = (s16)interpState->initRoll + (s16)(rollDiffToTarget * lerp); + *camRoll = TRUNCF_BINANG(interpState->initRoll) + TRUNCF_BINANG(rollDiffToTarget * lerp); } if (interpState->curFrame >= pointCmd->duration) { @@ -467,9 +467,9 @@ s16 CutsceneCamera_Interp_Scale(Vec3f* camPos, f32* camFov, s16* camRoll, CsCmdC targetRoll = CAM_DEG_TO_BINANG(miscCmd->roll); - rollDiffToTarget = (s16)(targetRoll - (s16)interpState->initRoll); + rollDiffToTarget = (s16)(targetRoll - TRUNCF_BINANG(interpState->initRoll)); - *camRoll += (s16)(rollDiffToTarget * lerp); + *camRoll += TRUNCF_BINANG(rollDiffToTarget * lerp); } if (interpState->curFrame >= pointCmd->duration) { @@ -532,9 +532,9 @@ s16 CutsceneCamera_Interp_Geo(Vec3f* camPos, f32* camFov, s16* camRoll, CsCmdCam targetRoll = CAM_DEG_TO_BINANG(miscCmd->roll); - rollDiffToTarget = (s16)(targetRoll - (s16)interpState->initRoll); + rollDiffToTarget = (s16)(targetRoll - TRUNCF_BINANG(interpState->initRoll)); - *camRoll += (s16)(rollDiffToTarget * lerp); + *camRoll += TRUNCF_BINANG(rollDiffToTarget * lerp); } if (interpState->curFrame >= pointCmd->duration) { diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index a43c37070..5742321bd 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -3570,17 +3570,17 @@ s32 BgCheck_SphVsDynaWall(CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* continue; } - bgActor->boundingSphere.radius += (s16)radius; + bgActor->boundingSphere.radius += TRUNCF_BINANG(radius); r = bgActor->boundingSphere.radius; dx = bgActor->boundingSphere.center.x - resultPos.x; dz = bgActor->boundingSphere.center.z - resultPos.z; if ((SQ(r) < SQ(dx) + SQ(dz)) || (!Math3D_XYInSphere(&bgActor->boundingSphere, resultPos.x, resultPos.y) && !Math3D_YZInSphere(&bgActor->boundingSphere, resultPos.y, resultPos.z))) { - bgActor->boundingSphere.radius -= (s16)radius; + bgActor->boundingSphere.radius -= TRUNCF_BINANG(radius); continue; } - bgActor->boundingSphere.radius -= (s16)radius; + bgActor->boundingSphere.radius -= TRUNCF_BINANG(radius); if (BgCheck_SphVsDynaWallInBgActor(colCtx, xpFlags, &colCtx->dyna, &(colCtx->dyna.bgActors + i)->dynaLookup.wall, outX, outZ, outPoly, outBgId, &resultPos, radius, i, actor)) { diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 252dc3d91..5e04f1613 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -695,7 +695,7 @@ s16 func_800CC260(Camera* camera, Vec3f* arg1, Vec3f* arg2, VecGeo* arg3, Actor* sp90.yaw = D_801B9E18[i] + arg3->yaw; rand = Rand_ZeroOne(); - sp90.pitch = D_801B9E34[i] + (s16)(arg3->pitch * rand); + sp90.pitch = D_801B9E34[i] + TRUNCF_BINANG(arg3->pitch * rand); if (sp90.pitch > 0x36B0) { // 76.9 degrees sp90.pitch -= 0x3E80; // -87.9 degrees @@ -1752,7 +1752,8 @@ s16 Camera_CalcDefaultPitch(Camera* camera, s16 pitch, s16 flatSurfacePitchTarge s16 pitchTarget; // if slopePitchAdj is positive, then it is attenuated by a factor of Math_CosS(slopePitchAdj) - slopePitchAdjAttenuated = (slopePitchAdj > 0) ? (s16)(Math_CosS(slopePitchAdj) * slopePitchAdj) : slopePitchAdj; + slopePitchAdjAttenuated = + (slopePitchAdj > 0) ? TRUNCF_BINANG(Math_CosS(slopePitchAdj) * slopePitchAdj) : slopePitchAdj; pitchTarget = flatSurfacePitchTarget - slopePitchAdjAttenuated; if (ABS(pitchTarget) < pitchMag) { @@ -1801,7 +1802,7 @@ s16 Camera_CalcDefaultYaw(Camera* camera, s16 yaw, s16 target, f32 attenuationYa attenuationSpeedRatio = Camera_QuadraticAttenuation(0.5f, camera->speedRatio); yawUpdRate = 1.0f / camera->yawUpdateRateInv; - return yaw + (s16)(yawDiffToTarget * attenuationYawDiffAdj * attenuationSpeedRatio * yawUpdRate); + return yaw + TRUNCF_BINANG(yawDiffToTarget * attenuationYawDiffAdj * attenuationSpeedRatio * yawUpdRate); } void Camera_CalcDefaultSwing(Camera* camera, VecGeo* arg1, VecGeo* arg2, f32 arg3, f32 arg4, SwingAnimation* swing2, @@ -2218,14 +2219,14 @@ s32 Camera_Normal1(Camera* camera) { } if (!(roData->interfaceFlags & NORMAL1_FLAG_3) || !func_800CB924(camera)) { - spB4.yaw = Camera_CalcDefaultYaw(camera, sp9C.yaw, (s16)(focalActorPosRot->rot.y - (s16)(sp72 * sp6C)), - roData->unk_14, spC0); + spB4.yaw = Camera_CalcDefaultYaw( + camera, sp9C.yaw, (s16)(focalActorPosRot->rot.y - TRUNCF_BINANG(sp72 * sp6C)), roData->unk_14, spC0); } if (!(roData->interfaceFlags & NORMAL1_FLAG_3) || (camera->speedRatio < 0.01f)) { - spB4.pitch = Camera_CalcDefaultPitch(camera, sp9C.pitch, - roData->unk_20 + (s16)((roData->unk_20 - sp74.pitch) * sp6C * 0.75f), - rwData->unk_08); + spB4.pitch = Camera_CalcDefaultPitch( + camera, sp9C.pitch, roData->unk_20 + TRUNCF_BINANG((roData->unk_20 - sp74.pitch) * sp6C * 0.75f), + rwData->unk_08); } } else if (roData->interfaceFlags & NORMAL1_FLAG_1) { VecGeo sp64; @@ -3747,14 +3748,14 @@ s32 Camera_Battle1(Camera* camera) { } else { sp104 = (1.0f - camera->speedRatio) * 0.05f; sp88 = (sp8A >= 0) ? CAM_DEG_TO_BINANG(spFC) : -CAM_DEG_TO_BINANG(spFC); - spBC.yaw = atToEyeNextDir.yaw - (s16)((sp88 - sp8A) * sp104); + spBC.yaw = atToEyeNextDir.yaw - TRUNCF_BINANG((sp88 - sp8A) * sp104); } if (!skipEyeAtCalc) { spF8 = atToTargetDir.pitch * roData->swingPitchAdj; var2 = swingPitchInitial + ((swingPitchFinal - swingPitchInitial) * distRatio); - sp8A = CAM_DEG_TO_BINANG(var2) - (s16)((spA4.pitch * (0.5f + (distRatio * (1.0f - 0.5f)))) + 0.5f); - sp8A += (s16)spF8; + sp8A = CAM_DEG_TO_BINANG(var2) - TRUNCF_BINANG((spA4.pitch * (0.5f + (distRatio * (1.0f - 0.5f)))) + 0.5f); + sp8A += TRUNCF_BINANG(spF8); if (sp8A < -0x2AA8) { sp8A = -0x2AA8; @@ -4101,15 +4102,15 @@ s32 Camera_KeepOn1(Camera* camera) { sp104 = (1.0f - camera->speedRatio) * 0.05f; spF0 = (spF2 >= 0) ? CAM_DEG_TO_BINANG(spFC) : -CAM_DEG_TO_BINANG(spFC); - spE8.yaw = atToEyeNext.yaw - (s16)((spF0 - spF2) * sp104); + spE8.yaw = atToEyeNext.yaw - TRUNCF_BINANG((spF0 - spF2) * sp104); } if (!skipEyeAtCalc) { spF2 = CAM_DEG_TO_BINANG(F32_LERPIMP(roData->unk_14, roData->unk_18, sp74)); - spF2 -= (s16)((spD0.pitch * (0.5f + (sp74 * 0.5f))) + 0.5f); + spF2 -= TRUNCF_BINANG((spD0.pitch * (0.5f + (sp74 * 0.5f))) + 0.5f); spF8 = spD8.pitch * roData->unk_1C; - spF2 += (s16)spF8; + spF2 += TRUNCF_BINANG(spF8); if (spF2 < -0x3200) { spF2 = -0x3200; @@ -4316,7 +4317,7 @@ s32 Camera_KeepOn3(Camera* camera) { } swingAngle = LERPIMP(roData->unk_14, roData->unk_18, phi_f14); - sp98.pitch = CAM_DEG_TO_BINANG(swingAngle) + ((s16) - (spA0.pitch * roData->unk_1C)); + sp98.pitch = CAM_DEG_TO_BINANG(swingAngle) + TRUNCF_BINANG(-(spA0.pitch * roData->unk_1C)); swingAngle = LERPIMP(roData->unk_0C, roData->unk_10, phi_f14); phi_a3 = CAM_DEG_TO_BINANG(swingAngle); @@ -4424,8 +4425,8 @@ s32 Camera_KeepOn3(Camera* camera) { at->z += (rwData->unk_10.z - at->z) / timer; sp98.r = (rwData->unk_00 * timer) + sp80.r + 1.0f; - sp98.yaw = sp80.yaw + (s16)(rwData->unk_04 * timer); - sp98.pitch = sp80.pitch + (s16)(rwData->unk_08 * timer); + sp98.yaw = sp80.yaw + TRUNCF_BINANG(rwData->unk_04 * timer); + sp98.pitch = sp80.pitch + TRUNCF_BINANG(rwData->unk_08 * timer); *eyeNext = OLib_AddVecGeoToVec3f(at, &sp98); *eye = *eyeNext; camera->fov = Camera_ScaledStepToCeilF(roData->unk_20, camera->fov, 0.5f, 0.1f); @@ -4704,8 +4705,8 @@ s32 Camera_KeepOn4(Camera* camera) { if (rwData->timer != 0) { Camera_SetStateFlag(camera, CAM_STATE_DISABLE_MODE_CHANGE); - rwData->unk_10 += (s16)rwData->unk_00; - rwData->unk_12 += (s16)rwData->unk_04; + rwData->unk_10 += TRUNCF_BINANG(rwData->unk_00); + rwData->unk_12 += TRUNCF_BINANG(rwData->unk_04); rwData->timer--; } else { Camera_SetStateFlag(camera, CAM_STATE_10 | CAM_STATE_4); @@ -6635,9 +6636,9 @@ s32 Camera_Special5(Camera* camera) { spA4 = BINANG_SUB(focalActorPosRot->rot.y, sp6C.yaw); sp74.r = roData->eyeDist; rand = Rand_ZeroOne(); - sp74.yaw = - BINANG_ROT180(focalActorPosRot->rot.y) + - (s16)((spA4 < 0) ? -(s16)(0x1553 + (s16)(rand * 2730.0f)) : (s16)(0x1553 + (s16)(rand * 2730.0f))); + sp74.yaw = BINANG_ROT180(focalActorPosRot->rot.y) + + (s16)((spA4 < 0) ? -(s16)(0x1553 + TRUNCF_BINANG(rand * 2730.0f)) + : (s16)(0x1553 + TRUNCF_BINANG(rand * 2730.0f))); sp74.pitch = roData->pitch; *eyeNext = OLib_AddVecGeoToVec3f(&spA8.pos, &sp74); *eye = *eyeNext; @@ -6839,8 +6840,8 @@ s32 Camera_Special9(Camera* camera) { s16 camEyeSide; s16 randFloat; - spB0.pitch = ((s16)(Rand_ZeroOne() * 0x280) + 0xBB8); - randFloat = ((s16)(Rand_ZeroOne() * 0x4CE) + 0x5DC); + spB0.pitch = TRUNCF_BINANG(Rand_ZeroOne() * 0x280) + 0xBB8; + randFloat = TRUNCF_BINANG(Rand_ZeroOne() * 0x4CE) + 0x5DC; // The camera will either position itself either to the left or to the right // of the door when it jumps behind it. It's effectively 50/50 percent chance diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 84638af47..421db8070 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -415,7 +415,7 @@ void func_800A6780(EnItem00* this, PlayState* play) { if (this->actor.velocity.y < -1.5f) { this->actor.velocity.y = -1.5f; } - this->actor.home.rot.z += (s16)((this->actor.velocity.y + 3.0f) * 1000.0f); + this->actor.home.rot.z += TRUNCF_BINANG((this->actor.velocity.y + 3.0f) * 1000.0f); this->actor.world.pos.x += (Math_CosS(this->actor.yawTowardsPlayer) * (-3.0f * Math_CosS(this->actor.home.rot.z))); this->actor.world.pos.z += diff --git a/src/code/z_lib.c b/src/code/z_lib.c index 0d4d00626..00bb37bc8 100644 --- a/src/code/z_lib.c +++ b/src/code/z_lib.c @@ -76,7 +76,7 @@ s32 Math_ScaledStepToS(s16* pValue, s16 target, s16 step) { step = -step; } - *pValue += (s16)(step * f0); + *pValue += TRUNCF_BINANG(step * f0); if (((s16)(*pValue - target) * step) >= 0) { *pValue = target; diff --git a/src/code/z_message.c b/src/code/z_message.c index eb2d0d8cb..7e6c9356a 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -1457,16 +1457,16 @@ void Message_DrawTextDefault(PlayState* play, Gfx** gfxP) { switch (character) { case 0x8169: case 0x8175: - msgCtx->textPosX -= (s16)(6.0f * msgCtx->textCharScale); + msgCtx->textPosX -= TRUNCF_BINANG(6.0f * msgCtx->textCharScale); break; case 0x8145: - msgCtx->textPosX -= (s16)(3.0f * msgCtx->textCharScale); + msgCtx->textPosX -= TRUNCF_BINANG(3.0f * msgCtx->textCharScale); break; case 0x8148: case 0x8149: - msgCtx->textPosX -= (s16)(2.0f * msgCtx->textCharScale); + msgCtx->textPosX -= TRUNCF_BINANG(2.0f * msgCtx->textCharScale); break; default: @@ -1494,34 +1494,34 @@ void Message_DrawTextDefault(PlayState* play, Gfx** gfxP) { charTexIndex += FONT_CHAR_TEX_SIZE; switch (character) { case 0x8144: - msgCtx->textPosX += (s16)(8.0f * msgCtx->textCharScale); + msgCtx->textPosX += TRUNCF_BINANG(8.0f * msgCtx->textCharScale); break; case 0x816A: case 0x8176: - msgCtx->textPosX += (s16)(10.0f * msgCtx->textCharScale); + msgCtx->textPosX += TRUNCF_BINANG(10.0f * msgCtx->textCharScale); break; case 0x8141: case 0x8142: case 0x8168: - msgCtx->textPosX += (s16)(12.0f * msgCtx->textCharScale); + msgCtx->textPosX += TRUNCF_BINANG(12.0f * msgCtx->textCharScale); break; case 0x8194: - msgCtx->textPosX += (s16)(14.0f * msgCtx->textCharScale); + msgCtx->textPosX += TRUNCF_BINANG(14.0f * msgCtx->textCharScale); break; case 0x8145: - msgCtx->textPosX += (s16)(15.0f * msgCtx->textCharScale); + msgCtx->textPosX += TRUNCF_BINANG(15.0f * msgCtx->textCharScale); break; default: if ((msgCtx->msgMode >= MSGMODE_SCENE_TITLE_CARD_FADE_IN_BACKGROUND) && (msgCtx->msgMode <= MSGMODE_SCENE_TITLE_CARD_FADE_OUT_BACKGROUND)) { - msgCtx->textPosX += (s16)((16.0f * msgCtx->textCharScale) - 1.0f); + msgCtx->textPosX += TRUNCF_BINANG((16.0f * msgCtx->textCharScale) - 1.0f); } else { - msgCtx->textPosX += (s16)(16.0f * msgCtx->textCharScale); + msgCtx->textPosX += TRUNCF_BINANG(16.0f * msgCtx->textCharScale); } break; } @@ -2200,7 +2200,7 @@ void Message_Decode(PlayState* play) { msgCtx->unk11FFA = msgCtx->textboxY + 6; msgCtx->unk11F1A[spD2] = 0; if (msgCtx->unk11F18 == 0) { - msgCtx->unk11F1A[spD2] = (s16)((msgCtx->textCharScale * 16.0f * 16.0f) - spC0) / 2; + msgCtx->unk11F1A[spD2] = TRUNCF_BINANG((msgCtx->textCharScale * 16.0f * 16.0f) - spC0) / 2; } spC0 = 0.0f; if (curChar == 0xB) { diff --git a/src/code/z_message_nes.c b/src/code/z_message_nes.c index 0bd3c99a3..db74d56c1 100644 --- a/src/code/z_message_nes.c +++ b/src/code/z_message_nes.c @@ -825,16 +825,16 @@ void Message_DrawTextNES(PlayState* play, Gfx** gfxP, u16 textDrawPos) { switch (character) { case 0x8169: case 0x8175: - msgCtx->textPosX -= (s16)(6.0f * msgCtx->textCharScale); + msgCtx->textPosX -= TRUNCF_BINANG(6.0f * msgCtx->textCharScale); break; case 0x8145: - msgCtx->textPosX -= (s16)(3.0f * msgCtx->textCharScale); + msgCtx->textPosX -= TRUNCF_BINANG(3.0f * msgCtx->textCharScale); break; case 0x8148: case 0x8149: - msgCtx->textPosX -= (s16)(2.0f * msgCtx->textCharScale); + msgCtx->textPosX -= TRUNCF_BINANG(2.0f * msgCtx->textCharScale); break; default: @@ -866,26 +866,26 @@ void Message_DrawTextNES(PlayState* play, Gfx** gfxP, u16 textDrawPos) { //! @TODO: u8 character but > 0x255 cases switch (character) { case 0x8144: - msgCtx->textPosX += (s16)(8.0f * msgCtx->textCharScale); + msgCtx->textPosX += TRUNCF_BINANG(8.0f * msgCtx->textCharScale); break; case 0x816A: case 0x8176: - msgCtx->textPosX += (s16)(10.0f * msgCtx->textCharScale); + msgCtx->textPosX += TRUNCF_BINANG(10.0f * msgCtx->textCharScale); break; case 0x8141: case 0x8142: case 0x8168: - msgCtx->textPosX += (s16)(12.0f * msgCtx->textCharScale); + msgCtx->textPosX += TRUNCF_BINANG(12.0f * msgCtx->textCharScale); break; case 0x8194: - msgCtx->textPosX += (s16)(14.0f * msgCtx->textCharScale); + msgCtx->textPosX += TRUNCF_BINANG(14.0f * msgCtx->textCharScale); break; case 0x8145: - msgCtx->textPosX += (s16)(15.0f * msgCtx->textCharScale); + msgCtx->textPosX += TRUNCF_BINANG(15.0f * msgCtx->textCharScale); break; default: @@ -998,7 +998,7 @@ void Message_DecodeNES(PlayState* play) { } msgCtx->unk11F1A[spC6] = 0; if (msgCtx->unk11F18 != 0) { - msgCtx->unk11F1A[spC6] = (s16)((msgCtx->textCharScale * 16.0f * 16.0f) - spA4) / 2; + msgCtx->unk11F1A[spC6] = TRUNCF_BINANG((msgCtx->textCharScale * 16.0f * 16.0f) - spA4) / 2; } spA4 = 0.0f; diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index c1098f23a..f2b4330fc 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -4601,7 +4601,7 @@ void Interface_DrawClock(PlayState* play) { } timeInSeconds = TIME_TO_SECONDS_F(CURRENT_TIME); - timeInSeconds -= ((s16)(timeInSeconds / 3600.0f)) * 3600.0f; + timeInSeconds -= TRUNCF_BINANG(timeInSeconds / 3600.0f) * 3600.0f; Gfx_SetupDL42_Overlay(play->state.gfxCtx); diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index ec051f1fb..8901069e3 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1895,8 +1895,8 @@ void func_80124F18(s16* arg0, f32* arg1, s16 arg2, f32 arg3, f32 arg4) { } *arg1 = CLAMP(*arg1, -arg4, arg4); - *arg0 += (s16)*arg1; - if (((arg2 - *arg0) * (s16)*arg1) < 0) { + *arg0 += TRUNCF_BINANG(*arg1); + if (((arg2 - *arg0) * TRUNCF_BINANG(*arg1)) < 0) { *arg0 = arg2; } } @@ -2168,7 +2168,7 @@ s32 Player_OverrideLimbDrawGameplayCommon(PlayState* play, s32 limbIndex, Gfx** rotX = player->upperLimbRot.x; if ((player->transformation == PLAYER_FORM_DEKU) && (player->stateFlags3 & PLAYER_STATE3_40)) { if (player->heldActor != NULL) { - rotX += (s16)(((EnArrow*)(player->heldActor))->bubble.unk_144 * -470.0f); + rotX += TRUNCF_BINANG(((EnArrow*)(player->heldActor))->bubble.unk_144 * -470.0f); } } diff --git a/src/code/z_quake.c b/src/code/z_quake.c index 9423983e1..c4b6e6782 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -184,7 +184,7 @@ QuakeRequest* Quake_RequestImpl(Camera* camera, u32 type) { // Add a unique random identifier to the upper bits of the index // The `~3` assumes there are only 4 requests - req->index = index + ((s16)(Rand_ZeroOne() * 0x10000) & ~3); + req->index = index + (TRUNCF_BINANG(Rand_ZeroOne() * 0x10000) & ~3); sQuakeRequestCount++; diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 58542b786..c7062332c 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -944,13 +944,13 @@ void SkelAnime_InterpFrameTable(s32 limbCount, Vec3s* dst, Vec3s* start, Vec3s* for (i = 0; i < limbCount; i++, dst++, start++, target++) { base = start->x; diff = target->x - base; - dst->x = (s16)(diff * weight) + base; + dst->x = TRUNCF_BINANG(diff * weight) + base; base = start->y; diff = target->y - base; - dst->y = (s16)(diff * weight) + base; + dst->y = TRUNCF_BINANG(diff * weight) + base; base = start->z; diff = target->z - base; - dst->z = (s16)(diff * weight) + base; + dst->z = TRUNCF_BINANG(diff * weight) + base; } } else { for (i = 0; i < limbCount; i++, dst++, target++) { diff --git a/src/code/z_snap.c b/src/code/z_snap.c index 3524fe3ab..cd5a03704 100644 --- a/src/code/z_snap.c +++ b/src/code/z_snap.c @@ -171,8 +171,8 @@ s32 Snap_ValidatePictograph(PlayState* play, Actor* actor, s32 flag, Vec3f* pos, // Check in capture region Actor_GetProjectedPos(play, pos, &projectedPos, &distance); // Convert to projected position to device coordinates, shift to be relative to the capture region's top-left corner - x = (s16)PROJECTED_TO_SCREEN_X(projectedPos, distance) - PICTO_VALID_TOPLEFT_X; - y = (s16)PROJECTED_TO_SCREEN_Y(projectedPos, distance) - PICTO_VALID_TOPLEFT_Y; + x = TRUNCF_BINANG(PROJECTED_TO_SCREEN_X(projectedPos, distance)) - PICTO_VALID_TOPLEFT_X; + y = TRUNCF_BINANG(PROJECTED_TO_SCREEN_Y(projectedPos, distance)) - PICTO_VALID_TOPLEFT_Y; // checks if the coordinates are within the capture region if ((x < 0) || (x > PICTO_VALID_WIDTH) || (y < 0) || (y > PICTO_VALID_HEIGHT)) { diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index d36f65b34..767018e58 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -589,8 +589,8 @@ s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex) { Path* SubS_GetDayDependentPath(PlayState* play, u8 pathIndex, u8 pathIndexNone, s32* startPointIndex) { Path* path = NULL; s32 found = false; - s16 time1 = TIME_TO_MINUTES_F(CURRENT_TIME); - s16 time2 = TIME_TO_MINUTES_F(CURRENT_TIME); + s16 time1 = TRUNCF_BINANG(TIME_TO_MINUTES_F(CURRENT_TIME)); + s16 time2 = TRUNCF_BINANG(TIME_TO_MINUTES_F(CURRENT_TIME)); s32 time = ((time1 % 60) + (time2 / 60) * 60) / 30; s32 day = CURRENT_DAY; |
