diff --git a/include/def/z_actor.h b/include/def/z_actor.h index 876c70195..4b765846a 100644 --- a/include/def/z_actor.h +++ b/include/def/z_actor.h @@ -197,7 +197,8 @@ void func_8003555C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* void func_800355B8(GlobalContext* globalCtx, Vec3f* pos); u8 func_800355E4(GlobalContext* globalCtx, Collider* collider); void func_80035844(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3); -Actor* func_800358DC(Actor* actor, Vec3f* spawnPos, Vec3s* spawnRot, f32* arg3, s32 timer, s16* unused, GlobalContext* globalCtx, s16 params, s32 arg8); +void func_80035844(Vec3f* arg0, Vec3f* arg1, VecRot* arg2, s32 arg3); +Actor* func_800358DC(Actor* actor, Vec3f* spawnPos, VecRot* spawnRot, f32* arg3, s32 timer, s16* unused, GlobalContext* globalCtx, s16 params, s32 arg8); void func_800359B8(Actor* actor, s16 arg1, VecRot* arg2); u16 func_80037C30(GlobalContext* globalCtx, s16 arg1); s32 func_80037D98(GlobalContext* globalCtx, Actor* actor, s16 arg2, s32* arg3); diff --git a/include/def/z_lib.h b/include/def/z_lib.h index aa2e16663..d57699eea 100644 --- a/include/def/z_lib.h +++ b/include/def/z_lib.h @@ -24,6 +24,7 @@ f32 Math_SmoothStepToF(f32* pValue, f32 target, f32 fraction, const Step& step, s16 Math_SmoothStepToS(s16* pValue, s16 target, s16 scale, const Step& step, const Step& minStep); s16 Math_SmoothStepToS(Rotation* pValue, s16 target, s16 scale, const Step& step, const Step& minStep); s32 Math_StepToAngleS(s16* pValue, s16 target, const Step& step); +s32 Math_StepToAngleS(Rotation* pValue, s16 target, const Step& step); s32 Math_StepToF(f32* pValue, f32 target, const Step& step); s32 Math_StepRotationToF(f32* pValue, f32 target, const Step& step); f32 Math_AngleDiffF(f32 a, f32 b); diff --git a/include/framerate.h b/include/framerate.h index 201bde5e0..f296e8b35 100644 --- a/include/framerate.h +++ b/include/framerate.h @@ -108,6 +108,8 @@ class Timer return m_counter; } + float abs() const; + s16 toS16() const { return (s16)m_counter; @@ -126,17 +128,21 @@ class Timer s64 m_counterInt; }; +typedef Timer Counter; +typedef Timer Rotation; + class Step { public: Step(); Step(const Step& t); Step(float n); + Step(const Rotation& r); + float value() const; protected: float m_value; }; -typedef Timer Counter; -typedef Timer Rotation; + diff --git a/include/z64math.h b/include/z64math.h index 7c615cbb1..dd3654823 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -95,7 +95,7 @@ struct VecSph { struct PosRot { Vec3f pos; - Vec3s rot; + VecRot rot; }; // size = 0x14 #define LERP(x, y, scale) (((y) - (x)) * (scale) + (x)) diff --git a/src/code/framerate.cpp b/src/code/framerate.cpp index d4bc3d9e9..76571eafa 100644 --- a/src/code/framerate.cpp +++ b/src/code/framerate.cpp @@ -10,29 +10,29 @@ static FramerateProfile g_profile = PROFILE_BOOT; #if FRAME_RATE == 20 static Framerate g_profileRates[] = { -FRAMERATE_30FPS, // PROFILE_BOOT -FRAMERATE_60FPS, // PROFILE_PAUSE -FRAMERATE_20FPS, // PROFILE_GAMEPLAY -FRAMERATE_60FPS, // PROFILE_UNKNOWN1 -FRAMERATE_60FPS, // PROFILE_UNKNOWN2 -FRAMERATE_60FPS, // PROFILE_SAMPLE -FRAMERATE_60FPS, // PROFILE_OPENING -FRAMERATE_60FPS, // PROFILE_SELECT -FRAMERATE_60FPS, // PROFILE_TITLE -FRAMERATE_60FPS, // PROFILE_FILE_CHOOSE + FRAMERATE_30FPS, // PROFILE_BOOT + FRAMERATE_60FPS, // PROFILE_PAUSE + FRAMERATE_20FPS, // PROFILE_GAMEPLAY + FRAMERATE_60FPS, // PROFILE_UNKNOWN1 + FRAMERATE_60FPS, // PROFILE_UNKNOWN2 + FRAMERATE_60FPS, // PROFILE_SAMPLE + FRAMERATE_60FPS, // PROFILE_OPENING + FRAMERATE_60FPS, // PROFILE_SELECT + FRAMERATE_60FPS, // PROFILE_TITLE + FRAMERATE_60FPS, // PROFILE_FILE_CHOOSE }; #else static Framerate g_profileRates[] = { -FRAMERATE_30FPS, // PROFILE_BOOT -FRAMERATE_60FPS, // PROFILE_PAUSE -FRAMERATE_60FPS, // PROFILE_GAMEPLAY -FRAMERATE_60FPS, // PROFILE_UNKNOWN1 -FRAMERATE_60FPS, // PROFILE_UNKNOWN2 -FRAMERATE_60FPS, // PROFILE_SAMPLE -FRAMERATE_60FPS, // PROFILE_OPENING -FRAMERATE_60FPS, // PROFILE_SELECT -FRAMERATE_60FPS, // PROFILE_TITLE -FRAMERATE_60FPS, // PROFILE_FILE_CHOOSE + FRAMERATE_30FPS, // PROFILE_BOOT + FRAMERATE_60FPS, // PROFILE_PAUSE + FRAMERATE_60FPS, // PROFILE_GAMEPLAY + FRAMERATE_60FPS, // PROFILE_UNKNOWN1 + FRAMERATE_60FPS, // PROFILE_UNKNOWN2 + FRAMERATE_60FPS, // PROFILE_SAMPLE + FRAMERATE_60FPS, // PROFILE_OPENING + FRAMERATE_60FPS, // PROFILE_SELECT + FRAMERATE_60FPS, // PROFILE_TITLE + FRAMERATE_60FPS, // PROFILE_FILE_CHOOSE }; #endif @@ -122,6 +122,18 @@ void Timer::update() m_counter = (float)m_counterInt * COUNTER_STEP; } +float Timer::abs() const +{ + float v = toFloat(); + + if(v < 0.0f) + { + return -v; + } + + return v; +} + Timer& Timer::operator++() // pre { m_counterInt++; @@ -201,7 +213,7 @@ Timer& Timer::operator+=(const Timer f) Timer& Timer::operator-=(const Timer f) { s64 step = f.m_counterInt * COUNTER_STEP; - + if(step == 0) { if(f.m_counterInt > 0) @@ -288,7 +300,6 @@ s32 Timer::operator>>(long n) return whole() >> n; } - Step::Step() : m_value(0) { } @@ -300,7 +311,12 @@ Step::Step(const Step& t) Step::Step(float n) { - m_value = n;// * FRAMERATE_SCALER; + m_value = n; // * FRAMERATE_SCALER; +} + +Step::Step(const Rotation& r) +{ + m_value = (s16)r; } float Step::value() const diff --git a/src/code/z_actor.cpp b/src/code/z_actor.cpp index 26774727d..ecbe2162d 100644 --- a/src/code/z_actor.cpp +++ b/src/code/z_actor.cpp @@ -4141,7 +4141,8 @@ void Actor_SetDropFlagJntSph(Actor* actor, ColliderJntSph* jntSph, s32 freezeFla } } -void func_80035844(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3) { +template +static inline void _func_80035844(Vec3f* arg0, Vec3f* arg1, T* arg2, s32 arg3) { f32 dx = arg1->x - arg0->x; f32 dz = arg1->z - arg0->z; f32 dy = arg3 ? (arg1->y - arg0->y) : (arg0->y - arg1->y); @@ -4150,10 +4151,20 @@ void func_80035844(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3) { arg2->x = Math_Atan2S(sqrtf(SQ(dx) + SQ(dz)), dy); } +void func_80035844(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3) +{ + _func_80035844(arg0, arg1, arg2, arg3); +} + +void func_80035844(Vec3f* arg0, Vec3f* arg1, VecRot* arg2, s32 arg3) +{ + _func_80035844(arg0, arg1, arg2, arg3); +} + /** * Spawns En_Part (Dissipating Flames) actor as a child of the given actor. */ -Actor* func_800358DC(Actor* actor, Vec3f* spawnPos, Vec3s* spawnRot, f32* arg3, s32 timer, s16* unused, +Actor* func_800358DC(Actor* actor, Vec3f* spawnPos, VecRot* spawnRot, f32* arg3, s32 timer, s16* unused, GlobalContext* globalCtx, s16 params, s32 arg8) { EnPart* spawnedEnPart; diff --git a/src/code/z_camera.cpp b/src/code/z_camera.cpp index af66e907d..c461f5795 100644 --- a/src/code/z_camera.cpp +++ b/src/code/z_camera.cpp @@ -6954,8 +6954,8 @@ s32 Camera_Special9(Camera* camera) { camera->unk_14C &= ~(0x4 | 0x2); camera->animState++; anim->targetYaw = ABS(playerPosRot->rot.y - adjustedPlayerPosRot.rot.y) >= 0x4000 - ? BINANG_ROT180(adjustedPlayerPosRot.rot.y) - : adjustedPlayerPosRot.rot.y; + ? BINANG_ROT180(adjustedPlayerPosRot.rot.y.whole()) + : adjustedPlayerPosRot.rot.y.whole(); case 1: spec9->doorParams.timer1--; if (spec9->doorParams.timer1 <= 0) { diff --git a/src/code/z_lib.cpp b/src/code/z_lib.cpp index 45eec3142..b788837c9 100644 --- a/src/code/z_lib.cpp +++ b/src/code/z_lib.cpp @@ -274,7 +274,8 @@ s32 Math_StepUntilS(Rotation* pValue, s16 limit, const Step& step) * Changes pValue by step towards target angle, setting it equal when the target is reached. * Returns true when target is reached, false otherwise. */ -s32 Math_StepToAngleS(s16* pValue, s16 target, const Step& _step) { +template +static inline s32 _Math_StepToAngleS(T* pValue, s16 target, const Step& _step) { float step = _step.value(); s32 diff = target - *pValue; @@ -304,6 +305,16 @@ s32 Math_StepToAngleS(s16* pValue, s16 target, const Step& _step) { return false; } +s32 Math_StepToAngleS(s16* pValue, s16 target, const Step& _step) +{ + return _Math_StepToAngleS(pValue, target, _step); +} + +s32 Math_StepToAngleS(Rotation* pValue, s16 target, const Step& _step) +{ + return _Math_StepToAngleS(pValue, target, _step); +} + /** * Changes pValue by step. If pvalue reaches limit, sets it equal to limit. * Returns true when limit is reached, false otherwise. diff --git a/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.cpp b/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.cpp index 0db8e4fad..dceb088bf 100644 --- a/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.cpp +++ b/src/overlays/actors/ovl_Bg_Bdan_Objects/z_bg_bdan_objects.cpp @@ -327,7 +327,7 @@ void func_8086C618(BgBdanObjects* pthis, GlobalContext* globalCtx) { pthis->actionFunc = func_8086C6EC; } else { pthis->dyna.actor.shape.rot.y += pthis->dyna.actor.world.rot.y; - func_800F436C(&pthis->dyna.actor.projectedPos, 0x2063, ABS(pthis->dyna.actor.world.rot.y) / 512.0f); + func_800F436C(&pthis->dyna.actor.projectedPos, 0x2063, pthis->dyna.actor.world.rot.y.abs() / 512.0f); } } diff --git a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.cpp b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.cpp index 40c1baa6a..635e5f5e9 100644 --- a/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.cpp +++ b/src/overlays/actors/ovl_Bg_Breakwall/z_bg_breakwall.cpp @@ -171,7 +171,7 @@ Actor* BgBreakwall_SpawnFragments(GlobalContext* globalCtx, BgBreakwall* pthis, } for (i = 0; i < count; angle2 += 0x4000, i++) { - angle1 = ABS(pthis->dyna.actor.world.rot.y) + angle2; + angle1 = pthis->dyna.actor.world.rot.y.abs() + angle2; Matrix_Translate(pthis->dyna.actor.world.pos.x, pthis->dyna.actor.world.pos.y, pthis->dyna.actor.world.pos.z, MTXMODE_NEW); Matrix_RotateZYX(pthis->dyna.actor.world.rot.x, pthis->dyna.actor.world.rot.y, pthis->dyna.actor.world.rot.z, diff --git a/src/overlays/actors/ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.cpp b/src/overlays/actors/ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.cpp index 5f4ef3751..c0dca40e8 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.cpp +++ b/src/overlays/actors/ovl_Bg_Hidan_Kousi/z_bg_hidan_kousi.cpp @@ -107,7 +107,7 @@ void BgHidanKousi_Destroy(Actor* thisx, GlobalContext* globalCtx) { void func_80889ACC(BgHidanKousi* pthis) { s32 pad[2]; - Vec3s* rot = &pthis->dyna.actor.world.rot; + auto rot = &pthis->dyna.actor.world.rot; f32 temp1 = D_80889E40[pthis->dyna.actor.params & 0xFF] * Math_SinS(rot->y); f32 temp2 = D_80889E40[pthis->dyna.actor.params & 0xFF] * Math_CosS(rot->y); diff --git a/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.cpp b/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.cpp index e1048fa6d..484ddf0b0 100644 --- a/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.cpp +++ b/src/overlays/actors/ovl_Bg_Mizu_Shutter/z_bg_mizu_shutter.cpp @@ -104,7 +104,7 @@ void BgMizuShutter_Destroy(BgMizuShutter* thisx, GlobalContext* globalCtx) { void BgMizuShutter_WaitForSwitch(BgMizuShutter* pthis, GlobalContext* globalCtx) { if (Flags_GetSwitch(globalCtx, (u16)pthis->dyna.actor.params & 0x3F)) { - if (ABS(pthis->dyna.actor.world.rot.x) > 0x2C60) { + if (pthis->dyna.actor.world.rot.x.abs() > 0x2C60) { OnePointCutscene_Init(globalCtx, 4510, -99, &pthis->dyna.actor, MAIN_CAM); } else { OnePointCutscene_Attention(globalCtx, &pthis->dyna.actor); diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.cpp b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.cpp index 96a9f88c9..f6395b548 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.cpp +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.cpp @@ -682,7 +682,7 @@ void EnGoroiwa_SetupWait(EnGoroiwa* pthis) { pthis->actionFunc = EnGoroiwa_Wait; pthis->actor.speedXZ = 0.0f; EnGoroiwa_UpdateFlags(pthis, ENGOROIWA_ENABLE_OC); - pthis->waitTimer = waitDurations_84[pthis->actor.home.rot.z & 1]; + pthis->waitTimer = waitDurations_84[pthis->actor.home.rot.z.whole() & 1]; pthis->rollRotSpeed = 0.0f; } diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.cpp b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.cpp index 6c56733cf..e53b77e38 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.cpp +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.cpp @@ -322,8 +322,8 @@ void func_80AD95D8(EnPoSisters* pthis) { Animation_MorphToPlayOnce(&pthis->skelAnime, &gPoeSistersDamagedAnim, -3.0f); if (pthis->collider.base.ac != NULL) { pthis->actor.world.rot.y = (pthis->collider.info.acHitInfo->toucher.dmgFlags & 0x1F824) - ? pthis->collider.base.ac->world.rot.y - : Actor_WorldYawTowardActor(&pthis->actor, pthis->collider.base.ac) + 0x8000; + ? (float)pthis->collider.base.ac->world.rot.y + : (float)Actor_WorldYawTowardActor(&pthis->actor, pthis->collider.base.ac) + 0x8000; } if (pthis->unk_194 != 0) { pthis->actor.speedXZ = 10.0f; diff --git a/src/overlays/actors/ovl_En_Trap/z_en_trap.cpp b/src/overlays/actors/ovl_En_Trap/z_en_trap.cpp index eee82edb5..15d8d3734 100644 --- a/src/overlays/actors/ovl_En_Trap/z_en_trap.cpp +++ b/src/overlays/actors/ovl_En_Trap/z_en_trap.cpp @@ -322,7 +322,7 @@ void EnTrap_Update(Actor* thisx, GlobalContext* globalCtx) { // if in initial position: } else if ((thisx->world.pos.x == thisx->home.pos.x) && (thisx->world.pos.z == thisx->home.pos.z)) { // of the available 4-way directions, get the one which is closest to the direction of player: - pthis->vClosestDirection = ((thisx->yawTowardsPlayer - thisx->world.rot.y) + 0x2000) & 0xC000; + pthis->vClosestDirection = ((thisx->yawTowardsPlayer - thisx->world.rot.y.whole()) + 0x2000) & 0xC000; pthis->vMovementMetric = 0.0f; if (thisx->xzDistToPlayer < 200.0f) { pthis->vMovementMetric = BEGIN_MOVE_OUT; diff --git a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.cpp b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.cpp index 891e4c165..e544d567f 100644 --- a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.cpp +++ b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.cpp @@ -193,7 +193,7 @@ void func_80B53764(EnZl3* pthis, GlobalContext* globalCtx) { s32 func_80B537E8(EnZl3* pthis) { s16 yawTowardsPlayer = pthis->actor.yawTowardsPlayer; - s16* rotY = &pthis->actor.world.rot.y; + auto rotY = &pthis->actor.world.rot.y; s16* unk_3D0 = &pthis->unk_3D0; s16 retVal; s16 pad[2]; @@ -206,7 +206,7 @@ s32 func_80B537E8(EnZl3* pthis) { void func_80B538B0(EnZl3* pthis) { s16 yawTowardsPlayer = pthis->actor.yawTowardsPlayer; - s16* rotY = &pthis->actor.world.rot.y; + auto rotY = &pthis->actor.world.rot.y; if (ABS((s16)(yawTowardsPlayer - *rotY)) >= 0x1556) { D_80B5A468 = 1; @@ -1680,14 +1680,14 @@ s32 func_80B571FC(EnZl3* pthis) { void func_80B57240(EnZl3* pthis) { s32 temp_a1 = func_80B571FC(pthis); - s16* rotY = &pthis->actor.world.rot.y; + auto rotY = &pthis->actor.world.rot.y; Math_SmoothStepToS(rotY, temp_a1, 2, 6400, 1000); pthis->actor.shape.rot.y = *rotY; } void func_80B57298(EnZl3* pthis) { - s16* rotY = &pthis->actor.world.rot.y; + auto rotY = &pthis->actor.world.rot.y; s16 temp_a1 = func_80B571A8(pthis); Math_SmoothStepToS(rotY, temp_a1, 2, 6400, 1000); diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.cpp b/src/overlays/actors/ovl_Fishing/z_fishing.cpp index 4e1a82e3f..2e0a6a471 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.cpp +++ b/src/overlays/actors/ovl_Fishing/z_fishing.cpp @@ -389,24 +389,38 @@ f32 Fishing_RandZeroOne(void) { return fabsf(rand); } -s16 Fishing_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step) { - s16 stepSize; - s16 diff; +template +static inline s16 _Fishing_SmoothStepToS(T* pValue, s16 target, s16 scale, s16 step) +{ + s16 stepSize; + s16 diff; - diff = target - *pValue; - stepSize = diff / scale; + diff = target - *pValue; + stepSize = diff / scale; - if (stepSize > step) { - stepSize = step; - } + if(stepSize > step) + { + stepSize = step; + } - if (stepSize < -step) { - stepSize = -step; - } + if(stepSize < -step) + { + stepSize = -step; + } - *pValue += stepSize; + *pValue += stepSize; - return stepSize; + return stepSize; +} + +s16 Fishing_SmoothStepToS(s16* pValue, s16 target, s16 scale, s16 step) +{ + return _Fishing_SmoothStepToS(pValue, target, scale, step); +} + +s16 Fishing_SmoothStepToS(Rotation* pValue, s16 target, s16 scale, s16 step) +{ + return _Fishing_SmoothStepToS(pValue, target, scale, step); } void Fishing_SpawnRipple(Vec3f* projectedPos, FishingEffect* effect, Vec3f* pos, f32 arg3, f32 arg4, s16 arg5, diff --git a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.cpp b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.cpp index 42cf2f63a..9bfccdf04 100644 --- a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.cpp +++ b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.cpp @@ -48,7 +48,7 @@ static u32 sFlags[3][2] = { { 0, 0 }, { 1, 0 }, { 0, 1 } }; static void (*sFlagSwitchFuncs[])(GlobalContext* globalCtx, s32 flag) = { Flags_UnsetSwitch, Flags_SetSwitch }; void ObjMakeoshihiki_Init(Actor* thisx, GlobalContext* globalCtx) { - BlockConfig* block = &sBlocks[thisx->home.rot.z & 1]; + BlockConfig* block = &sBlocks[thisx->home.rot.z.whole() & 1]; s32 typeIdx; Vec3f* spawnPos; @@ -80,7 +80,7 @@ void ObjMakeoshihiki_Init(Actor* thisx, GlobalContext* globalCtx) { } void ObjMakeoshihiki_Draw(Actor* thisx, GlobalContext* globalCtx) { - BlockConfig* block = &sBlocks[thisx->home.rot.z & 1]; + BlockConfig* block = &sBlocks[thisx->home.rot.z.whole() & 1]; s32 i; s32 sfxCond1; s32 sfxCond2; diff --git a/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.cpp b/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.cpp index a332d27ea..c505de92a 100644 --- a/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.cpp +++ b/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.cpp @@ -338,7 +338,7 @@ void ObjTimeblock_Update(Actor* thisx, GlobalContext* globalCtx) { void ObjTimeblock_Draw(Actor* thisx, GlobalContext* globalCtx) { if (((ObjTimeblock*)thisx)->isVisible) { - Color_RGB8* primColor = &sPrimColors[thisx->home.rot.z & 7]; + Color_RGB8* primColor = &sPrimColors[thisx->home.rot.z.whole() & 7]; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_timeblock.c", 762); diff --git a/src/overlays/actors/ovl_Obj_Warp2block/z_obj_warp2block.cpp b/src/overlays/actors/ovl_Obj_Warp2block/z_obj_warp2block.cpp index c67659deb..9f775929b 100644 --- a/src/overlays/actors/ovl_Obj_Warp2block/z_obj_warp2block.cpp +++ b/src/overlays/actors/ovl_Obj_Warp2block/z_obj_warp2block.cpp @@ -312,7 +312,7 @@ void ObjWarp2block_Update(Actor* thisx, GlobalContext* globalCtx) { void ObjWarp2block_Draw(Actor* thisx, GlobalContext* globalCtx) { Color_RGB8* sp44; - sp44 = &sColors[thisx->home.rot.z & 7]; + sp44 = &sColors[thisx->home.rot.z.whole() & 7]; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_warp2block.c", 584); func_80093D18(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_player_actor/z_player.cpp b/src/overlays/actors/ovl_player_actor/z_player.cpp index 1874a479e..b3d4cc690 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.cpp +++ b/src/overlays/actors/ovl_player_actor/z_player.cpp @@ -9223,7 +9223,7 @@ void Player_Init(Actor* pthisx, GlobalContext* globalCtx2) { MREG(64) = 0; } -void func_808471F4(s16* pValue) { +static void func_808471F4(s16* pValue) { s16 step; step = (ABS(*pValue) * 100.0f) / 1000.0f; @@ -9232,6 +9232,16 @@ void func_808471F4(s16* pValue) { Math_ScaledStepToS(pValue, 0, step); } +static void func_808471F4(Rotation* pValue) +{ + s16 step; + + step = (pValue->abs() * 100.0f) / 1000.0f; + step = CLAMP(step, 400, 4000); + + Math_ScaledStepToS(pValue, 0, step); +} + void func_80847298(Player* pthis) { s16 sp26; @@ -10589,7 +10599,7 @@ s16 func_8084ABD8(GlobalContext* globalCtx, Player* pthis, s32 arg2, s16 arg3) { temp3 = ((sControlInput->rel.stick_y >= 0) ? 1 : -1) * (s32)((1.0f - Math_CosS(sControlInput->rel.stick_y * 200)) * 1500.0f); pthis->actor.focus.rot.x += temp3; - pthis->actor.focus.rot.x = CLAMP(pthis->actor.focus.rot.x, -temp1, temp1); + pthis->actor.focus.rot.x = CLAMP((float)pthis->actor.focus.rot.x, -temp1, temp1); temp1 = 19114; temp2 = pthis->actor.focus.rot.y - pthis->actor.shape.rot.y;