From a3e422e481308156da978585a65759b92c8bda69 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Fri, 22 May 2026 20:08:54 -0400 Subject: [PATCH] d_a_npc_md 99% for demo --- include/d/actor/d_a_npc_md.h | 26 +++++++-------- include/m_Do/m_Do_mtx.h | 35 ++++++++++---------- src/d/actor/d_a_npc_md.cpp | 58 ++++++++++++++++++--------------- src/d/actor/d_a_player_main.cpp | 2 +- src/m_Do/m_Do_mtx.cpp | 4 +-- 5 files changed, 66 insertions(+), 59 deletions(-) diff --git a/include/d/actor/d_a_npc_md.h b/include/d/actor/d_a_npc_md.h index 4c87e8bf2..6a47968a0 100644 --- a/include/d/actor/d_a_npc_md.h +++ b/include/d/actor/d_a_npc_md.h @@ -65,31 +65,31 @@ public: void setBitStatus(u32 status) { cLib_onBit(m30F0, status); } void clearStatus(u32 status) { cLib_offBit(m30F0, status); } - bool checkStatus(u32 status) { return cLib_checkBit(m30F0, status); } + BOOL checkStatus(u32 status) { return cLib_checkBit(m30F0, status); } void setStatus(u32 status) { m30F0 = status; } void clearStatus() { m30F0 = 0; } - bool checkStatusFly() { return cLib_checkBit(m30F0, daMdStts_FLY); } + BOOL checkStatusFly() { return cLib_checkBit(m30F0, daMdStts_FLY); } void onBitCamTagIn() { cLib_onBit(m30F0, daMdStts_CAM_TAG_IN); } void offBitCamTagIn() { cLib_offBit(m30F0, daMdStts_CAM_TAG_IN); } - bool checkStatusCamTagIn() { return cLib_checkBit(m30F0, daMdStts_CAM_TAG_IN); } + BOOL checkStatusCamTagIn() { return cLib_checkBit(m30F0, daMdStts_CAM_TAG_IN); } void onXYTalk() { cLib_onBit(m30F0, daMdStts_XY_TALK); } void offXYTalk() { cLib_offBit(m30F0, daMdStts_XY_TALK); } - bool isXYTalk() { return cLib_checkBit(m30F0, daMdStts_XY_TALK); } + BOOL isXYTalk() { return cLib_checkBit(m30F0, daMdStts_XY_TALK); } void noCarryAction() { cLib_onBit(m30F0, daMdStts_CARRY_ACTION); } void offNoCarryAction() { cLib_offBit(m30F0, daMdStts_CARRY_ACTION); } - bool isNoCarryAction() { return cLib_checkBit(m30F0, daMdStts_CARRY_ACTION); } + BOOL isNoCarryAction() { return cLib_checkBit(m30F0, daMdStts_CARRY_ACTION); } void onShipRide() { cLib_onBit(m30F0, daMdStts_SHIP_RIDE); } void offShipRide() { cLib_offBit(m30F0, daMdStts_SHIP_RIDE); } - bool isShipRide() { return cLib_checkBit(m30F0, daMdStts_SHIP_RIDE); } + BOOL isShipRide() { return cLib_checkBit(m30F0, daMdStts_SHIP_RIDE); } void onLightHit() { cLib_onBit(m30F0, daMdStts_LIGHT_HIT); } void offLightHit() { cLib_offBit(m30F0, daMdStts_LIGHT_HIT); } - bool isLightHit() { return cLib_checkBit(m30F0, daMdStts_LIGHT_HIT); } + BOOL isLightHit() { return cLib_checkBit(m30F0, daMdStts_LIGHT_HIT); } void onLightBodyHit() { cLib_onBit(m30F0, daMdStts_LIGHT_BODY_HIT); } void offLightBodyHit() { cLib_offBit(m30F0, daMdStts_LIGHT_BODY_HIT); } - bool isLightBodyHit() { return cLib_checkBit(m30F0, daMdStts_LIGHT_BODY_HIT); } + BOOL isLightBodyHit() { return cLib_checkBit(m30F0, daMdStts_LIGHT_BODY_HIT); } void onDefaultTalkXY() { cLib_onBit(m30F0, daMdStts_DEFAULT_TALK_XY); } void offDefaultTalkXY() { cLib_offBit(m30F0, daMdStts_DEFAULT_TALK_XY); } - bool isDefaultTalkXY() { return cLib_checkBit(m30F0, daMdStts_DEFAULT_TALK_XY); } + BOOL isDefaultTalkXY() { return cLib_checkBit(m30F0, daMdStts_DEFAULT_TALK_XY); } bool isOldLightBodyHit() { return mOldLightBodyHit; } void setOldLightBodyHit() { mOldLightBodyHit = isLightBodyHit(); } @@ -140,10 +140,11 @@ public: } } - u8 checkBitHairMode(u8 bit) { return m3134 & bit; } - void setBitHairMode(u8 bit) { m3134 |= bit; } + u8 checkBitHairMode(u8 bit) { return cLib_checkBit(m3134, bit); } + void setBitHairMode(u8 bit) { cLib_onBit(m3134, bit); } - u8 getPiyo2TalkCNT() { return m313C & 0xFF; } // TODO: fakematch? + u8 getPiyo2TalkCNT() { return m313C; } + void setPiyo2TalkCNT(u8 cnt) { m313C = cnt; } void countPiyo2TalkCNT() { m313C++; if (m313C >= 3) { @@ -165,7 +166,6 @@ public: void setTalkType(u8 type) { mType = type; } void setBitEffectStatus(u8 bit) { cLib_onBit(m3135, bit); } void setEffectStatus(u8 status) { m3135 = status; } - void setPiyo2TalkCNT(u8 cnt) { m313C = cnt; } ~daNpc_Md_c(); diff --git a/include/m_Do/m_Do_mtx.h b/include/m_Do/m_Do_mtx.h index 4880cf4bd..4bca7e358 100644 --- a/include/m_Do/m_Do_mtx.h +++ b/include/m_Do/m_Do_mtx.h @@ -18,13 +18,13 @@ void mDoMtx_XrotM(Mtx, s16); void mDoMtx_YrotM(Mtx, s16); void mDoMtx_ZrotM(Mtx, s16); void mDoMtx_MtxToRot(CMtxP, csXyz*); -void mDoMtx_lookAt(Mtx param_0, Vec const* param_1, Vec const* param_2, s16 param_3); -void mDoMtx_lookAt(Mtx param_0, Vec const* param_1, Vec const* param_2, Vec const* param_3, +void mDoMtx_lookAt(Mtx mtx, const Vec* param_1, const Vec* param_2, s16 param_3); +void mDoMtx_lookAt(Mtx mtx, const Vec* param_1, const Vec* param_2, const Vec* param_3, s16 param_4); void mDoMtx_concatProjView(f32 const (*param_0)[4], f32 const (*param_1)[4], f32 (*param_2)[4]); void mDoMtx_ZrotM(Mtx mtx, s16 z); bool mDoMtx_inverseTranspose(f32 const (*param_0)[4], f32 (*param_1)[4]); -void mDoMtx_QuatConcat(Quaternion const* param_0, Quaternion const* param_1, Quaternion* param_2); +void mDoMtx_QuatConcat(const Quaternion* param_0, const Quaternion* param_1, Quaternion* param_2); void mDoMtx_concat(const Mtx a, const Mtx b, Mtx c); inline void mDoMtx_multVecSR(const Mtx m, const Vec* src, Vec* dst) { @@ -79,16 +79,16 @@ inline void cMtx_ZrotS(Mtx mtx, s16 z) { mDoMtx_ZrotS(mtx, z); } -inline void cMtx_lookAt(Mtx param_0, const Vec* param_1, const Vec* param_2, s16 param_3) { - mDoMtx_lookAt(param_0, param_1, param_2, param_3); +inline void cMtx_lookAt(Mtx mtx, const Vec* param_1, const Vec* param_2, s16 param_3) { + mDoMtx_lookAt(mtx, param_1, param_2, param_3); } inline void cMtx_multVec(const Mtx mtx, const Vec* src, Vec* dst) { mDoMtx_multVec(mtx, src, dst); } -inline void cMtx_lookAt(Mtx param_0, const Vec* param_1, const Vec* param_2, const Vec* param_3, s16 param_4) { - mDoMtx_lookAt(param_0,param_1,param_2,param_3,param_4); +inline void cMtx_lookAt(Mtx mtx, const Vec* param_1, const Vec* param_2, const Vec* param_3, s16 param_4) { + mDoMtx_lookAt(mtx, param_1, param_2, param_3, param_4); } inline void cMtx_copy(CMtxP src, MtxP dst) { @@ -171,13 +171,13 @@ public: * Translates the `now` Matrix by the given cXyz * @param xyz The xyz translation vector */ - static inline void transS(cXyz const& xyz) { transS(xyz.x, xyz.y, xyz.z); } + static inline void transS(const cXyz& xyz) { transS(xyz.x, xyz.y, xyz.z); } /** * Translates a new Matrix by the given cXyz and then concatenates it with the `now` matrix * @param xyz The xyz translation vector */ - static inline void transM(cXyz const& xyz) { transM(xyz.x, xyz.y, xyz.z); } + static inline void transM(const cXyz& xyz) { transM(xyz.x, xyz.y, xyz.z); } /** * Translates a new Matrix by the given X, Y, and Z values and then concatenates it with the `now` matrix @@ -191,13 +191,13 @@ public: * Scales the `now` Matrix by the given cXyz * @param xyz The xyz scale vector */ - static void scaleS(cXyz const& xyz); + static void scaleS(const cXyz& xyz); /** * Scales a new Matrix by the given cXyz and then concatenates it with the `now` matrix * @param xyz The xyz scale vector */ - static void scaleM(cXyz const& xyz) { scaleM(xyz.x, xyz.y, xyz.z); } + static void scaleM(const cXyz& xyz) { scaleM(xyz.x, xyz.y, xyz.z); } /** * Scales a new Matrix by the given X, Y, and Z values and then concatenates it with the `now` matrix @@ -207,23 +207,25 @@ public: */ static void scaleM(f32 x, f32 y, f32 z); - static void XYZrotS(csXyz const& xyz); + static void XYZrotS(const csXyz& xyz); /** * Rotates the `now` matrix by the given csXyz in the order X, Y, Z * @param xyz The xyz rotation vector */ - static void XYZrotM(csXyz const& xyz) { XYZrotM(xyz.x, xyz.y, xyz.z); } + static void XYZrotM(const csXyz& xyz) { XYZrotM(xyz.x, xyz.y, xyz.z); } - static void ZXYrotS(csXyz const& xyz) { ZXYrotS(xyz.x, xyz.y, xyz.z); } + static void ZXYrotS(const csXyz& xyz) { ZXYrotS(xyz.x, xyz.y, xyz.z); } /** * Rotates the `now` matrix by the given csXyz in the order Z, X, Y * @param xyz The xyz rotation vector */ - static void ZXYrotM(csXyz const& xyz) { ZXYrotM(xyz.x, xyz.y, xyz.z); } + static void ZXYrotM(const csXyz& xyz) { ZXYrotM(xyz.x, xyz.y, xyz.z); } - static void quatM(Quaternion const*); + static void quatM(const Quaternion*); + + static void quatS(const Quaternion* quat) { MTXQuat(now, quat); } /** * Returns the `now` Matrix @@ -352,7 +354,6 @@ public: } // TODO - static void quatS(const Quaternion*) {} static void rYrotS(f32) {} static Mtx now; diff --git a/src/d/actor/d_a_npc_md.cpp b/src/d/actor/d_a_npc_md.cpp index 384374fad..e2f4a4bd1 100644 --- a/src/d/actor/d_a_npc_md.cpp +++ b/src/d/actor/d_a_npc_md.cpp @@ -2448,7 +2448,7 @@ BOOL daNpc_Md_c::land01NpcAction(void* param_1) { } } else if (mActionStatus != ACTION_ENDING) { if (m3144 != 0) { - if ((!chkAdanmaeDemoOrder()) && (m312A != 0)) { + if (!chkAdanmaeDemoOrder() && m312A != 0) { setNpcAction(&daNpc_Md_c::waitNpcAction); } } else if (m312A != 0) { @@ -2934,9 +2934,6 @@ BOOL daNpc_Md_c::jumpNpcAction(void* param_1) { /* 000092E0-000095C8 .text escapeNpcAction__10daNpc_Md_cFPv */ BOOL daNpc_Md_c::escapeNpcAction(void*) { - s16 sVar5; - s16 local_38; - if (mActionStatus == ACTION_STARTING) { setBitStatus(daMdStts_UNK4); cLib_onBit(attention_info.flags, fopAc_Attn_ACTION_CARRY_e); @@ -2975,14 +2972,14 @@ BOOL daNpc_Md_c::escapeNpcAction(void*) { f32 f31 = 250000.0f; f32 f30 = 1.0f; if (m313F != 0) { - sVar5 = (m313F < 0) ? DEMO_SELECT(-0x4000, (s16)-0x4000) : DEMO_SELECT(0x4000, (s16)0x4000); + s16 sVar5 = (m313F < 0) ? DEMO_SELECT(-0x4000, (s16)-0x4000) : DEMO_SELECT(0x4000, (s16)0x4000); m3144 = DEMO_SELECT(sVar5, (s16)sVar5) + cM_atan2s(m30C4.x, m30C4.z); } else if (m3146 == 0) { setNpcAction(&daNpc_Md_c::waitNpcAction); return TRUE; } - local_38 = m3144; - sVar5 = local_38; + s16 local_38 = m3144; + s16 sVar5 = local_38; if (routeCheck(f31, &local_38)) { cLib_distanceAngleS(sVar5, local_38); } @@ -4146,7 +4143,8 @@ BOOL daNpc_Md_c::actionTurnEvent(int staffIdx) { void daNpc_Md_c::initialSetAnmEvent(int staffIdx) { int* puVar1 = dComIfGp_evmng_getMyIntegerP(staffIdx, "Number"); if (puVar1 != NULL) { - int iVar1 = setAnm(getAnmType(*puVar1)); + u8 r4 = *puVar1; + int iVar1 = setAnm(getAnmType(r4)); if (iVar1 != 0) { setBitStatus(daMdStts_UNK1); } else { @@ -4190,19 +4188,19 @@ void daNpc_Md_c::initialLookUp(int) { /* 0000CAA4-0000CB8C .text actionLookDown__10daNpc_Md_cFi */ BOOL daNpc_Md_c::actionLookDown(int) { - s16 desiredYRot; cXyz local_14; cXyz cStack_20; - m30AC.y = -50.0f; cXyz local_38(0.0f, 0.0f, 0.0f); - desiredYRot = shape_angle.y; + cXyz* temp; + s16 desiredYRot = shape_angle.y; local_38.set(current.pos.x, eyePos.y, current.pos.z); local_14 = local_38; + temp = &local_14; mDoMtx_stack_c::YrotS(desiredYRot); mDoMtx_stack_c::multVec(&m30AC, &cStack_20); local_14 += cStack_20; - mJntCtrl.lookAtTarget(&shape_angle.y, &local_14, local_38, desiredYRot, m3110, false); + mJntCtrl.lookAtTarget(&shape_angle.y, temp, local_38, desiredYRot, m3110, false); return TRUE; } @@ -5345,7 +5343,8 @@ u32 daNpc_Md_c::getMsg() { 0x1803, 0x1804, }; - msgNo = l_msg_num[getPiyo2TalkCNT()]; + u8 count = getPiyo2TalkCNT(); + msgNo = l_msg_num[count]; countPiyo2TalkCNT(); } else { msgNo = 0x17F6; @@ -5406,9 +5405,10 @@ void daNpc_Md_c::setCollision() { local_20.setall(0.0f); local_2c = current.pos; + f32 radius = 30.0f; if ((!isShipRide()) && (!fopAcM_CheckStatus(this, fopAcStts_CARRY_e))) { mCyl1.SetC(local_2c); - mCyl1.SetR(30.0f); + mCyl1.SetR(radius); mCyl1.SetH(m30F8); dComIfG_Ccsp()->Set(&mCyl1); } else { @@ -5416,11 +5416,11 @@ void daNpc_Md_c::setCollision() { mCyl1.ClrTgHit(); } mCyl2.SetC(local_2c); - mCyl2.SetR(30.0f); + mCyl2.SetR(radius); mCyl2.SetH(m30F8); dComIfG_Ccsp()->Set(&mCyl2); mCyl3.SetC(local_2c); - mCyl3.SetR(30.0f); + mCyl3.SetR(radius); mCyl3.SetH(m30F8); dComIfG_Ccsp()->Set(&mCyl3); if (isLightHit()) { @@ -5450,7 +5450,7 @@ void daNpc_Md_c::setCollision() { /* 0000E95C-0000E9F0 .text setAttention__10daNpc_Md_cFb */ void daNpc_Md_c::setAttention(bool param_1) { - if ((!param_1) && (m312B >= 2)) { + if (!param_1 && m312B >= 2) { return; } eyePos.set(getEyePos().x, getEyePos().y, getEyePos().z); @@ -5533,6 +5533,9 @@ s32 daNpc_Md_c::lookBackWaist(s16 param_1, f32 param_2) { } else { sVar3 = l_HIO.m034.m1E * fVar1; } +#if VERSION == VERSION_DEMO + m3114 = sVar3; +#endif sVar3 = cLib_addCalcAngleS(&m3114, sVar3, 4, 0xc00, 0x180); sVar4 = cLib_addCalcAngleS(&m3116, l_HIO.m034.m22 * dVar6, 4, 0xc00, 0x180); uVar5 = false; @@ -5588,11 +5591,13 @@ void daNpc_Md_c::setBaseMtx() { } mpArmMorf->calc(); if (checkStatus(daMdStts_UNK80)) { - cMtx_copy(mpArmMorf->getModel()->getAnmMtx(m_handL_jnt_num), mDoMtx_stack_c::now); + J3DModel* model = mpArmMorf->getModel(); + cMtx_copy(model->getAnmMtx(m_handL_jnt_num), mDoMtx_stack_c::now); mDoMtx_stack_c::transM(0.37f, 3.81f, -11.13f); mDoMtx_stack_c::XYZrotM(0x1b24, -0x2913, -0x1982); } else { - cMtx_copy(getModel()->getAnmMtx(m_backbone2_jnt_num), mDoMtx_stack_c::now); + J3DModel* model = getModel(); + cMtx_copy(model->getAnmMtx(m_backbone2_jnt_num), mDoMtx_stack_c::now); mDoMtx_stack_c::transM(2.2f, -11.681f, 1.3f); mDoMtx_stack_c::XYZrotM(0x3f11, 0x2894, 0x7f7e); } @@ -5726,19 +5731,20 @@ BOOL daNpc_Md_c::draw() { mpMorf->entryDL(); m0520.remove(modelData); + J3DModel* limbModel; if (!isTypeShipRide()) { if (checkStatus(daMdStts_UNK1)) { - model = mpWingMorf->getModel(); - g_env_light.setLightTevColorType(model, &tevStr); + limbModel = mpWingMorf->getModel(); + g_env_light.setLightTevColorType(limbModel, &tevStr); mpWingMorf->entryDL(); } else { - model = mpArmMorf->getModel(); - g_env_light.setLightTevColorType(model, &tevStr); + limbModel = mpArmMorf->getModel(); + g_env_light.setLightTevColorType(limbModel, &tevStr); mpArmMorf->entryDL(); } } else { - model = mpArmMorf->getModel(); - g_env_light.setLightTevColorType(model, &tevStr); + limbModel = mpArmMorf->getModel(); + g_env_light.setLightTevColorType(limbModel, &tevStr); mpArmMorf->entryDL(); } @@ -5777,7 +5783,7 @@ BOOL daNpc_Md_c::draw() { mShadowId = dComIfGd_setShadow(mShadowId, 0, getModel(), &shadowPos, 800.0f, 20.0f, current.pos.y, mAcch.GetGroundH(), mAcch.m_gnd, &tevStr); if (mShadowId != 0) { - dComIfGd_addRealShadow(mShadowId, model); + dComIfGd_addRealShadow(mShadowId, limbModel); dComIfGd_addRealShadow(mShadowId, mpHarpModel); } } diff --git a/src/d/actor/d_a_player_main.cpp b/src/d/actor/d_a_player_main.cpp index 7f837706b..332ccdeea 100644 --- a/src/d/actor/d_a_player_main.cpp +++ b/src/d/actor/d_a_player_main.cpp @@ -373,7 +373,7 @@ BOOL daPy_lk_c::jointBeforeCB(int jnt_no, J3DTransformInfo* param_2, Quaternion* m3648 = *param_3; } else if (jnt_no == 1) { mDoMtx_copy(J3DSys::mCurrentMtx, root_mtx); - mDoMtx_quat(mDoMtx_stack_c::now, &m3648); + mDoMtx_stack_c::quatS(&m3648); mDoMtx_stack_c::inverse(); mDoMtx_concat(J3DSys::mCurrentMtx, mDoMtx_stack_c::get(), J3DSys::mCurrentMtx); } else if (jnt_no == 0x1D) { diff --git a/src/m_Do/m_Do_mtx.cpp b/src/m_Do/m_Do_mtx.cpp index bc6f3e843..7b7b92424 100644 --- a/src/m_Do/m_Do_mtx.cpp +++ b/src/m_Do/m_Do_mtx.cpp @@ -347,8 +347,8 @@ void mDoMtx_stack_c::rYrotM(f32 i_rad) { } /* 8000D940-8000D97C .text quatM__14mDoMtx_stack_cFPC10Quaternion */ -void mDoMtx_stack_c::quatM(const Quaternion* param_0) { +void mDoMtx_stack_c::quatM(const Quaternion* quat) { Mtx tmp; - mDoMtx_quat(tmp, param_0); + mDoMtx_quat(tmp, quat); mDoMtx_concat(now, tmp, now); }