// // Generated by dtk // Translation Unit: d_a_msw.cpp // #include "d/dolzel_rel.h" // IWYU pragma: keep #include "d/actor/d_a_msw.h" #include "d/res/res_msw.h" #include "d/d_bg_s_movebg_actor.h" #include "d/d_procname.h" #include "d/d_priority.h" #include "m_Do/m_Do_ext.h" #include "d/d_com_inf_game.h" #include "d/d_s_play.h" /* 00000078-000002D4 .text ride_call_back__FP4dBgWP10fopAc_ac_cP10fopAc_ac_c */ void ride_call_back(dBgW* bgw, fopAc_ac_c* i_ac, fopAc_ac_c* i_pt) { msw_class* pActor = static_cast(i_ac); cMtx_YrotS(*calc_mtx, -i_ac->current.angle.y); cXyz tmp = i_pt->current.pos - i_ac->current.pos; cXyz pos1; MtxPosition(&tmp, &pos1); cXyz pos2; tmp = i_pt->old.pos - i_ac->current.pos; MtxPosition(&tmp, &pos2); s16 z = pos1.z * ((REG0_F(0) + 20.0f) / i_ac->scale.z); s16 x = -pos1.x * ((REG0_F(0) + 20.0f) / i_ac->scale.x); cLib_addCalcAngleS2(&i_ac->current.angle.x, z, 10, 0x800); cLib_addCalcAngleS2(&i_ac->current.angle.z, x, 10, 0x800); f32 dist = (REG0_F(4) + 50.0f) * std::fabsf(pos1.z - pos2.z); if (pActor->m2BC.x < dist) { pActor->m2BC.x = dist; } dist = (REG0_F(4) + 50.0f) * std::fabsf(pos1.x - pos2.x); if (pActor->m2BC.z < dist) { pActor->m2BC.z = dist; } dist = (REG0_F(8) + 5.0f) * std::fabsf(pos1.x - pos2.x); if (dist > 10.0f && pActor->m2B0.x < dist) { cLib_addCalc2(&pActor->m2B0.x, dist, 1.0f, REG0_F(7) + 1.2f); } dist = (REG0_F(8) + 5.0f) * std::fabsf(pos1.z - pos2.z); if (dist > 10.0f && pActor->m2B0.z < dist) { cLib_addCalc2(&pActor->m2B0.z, dist, 1.0f, REG0_F(7) + 1.2f); } } /* 00000310-00000540 .text chain_Draw__FP9msw_class */ void chain_Draw(msw_class* i_this) { s16 angle1; s32 angle2; for (int i = 0; i < 4; i++) { cXyz tmp = i_this->m310[i] - i_this->m2E0[i]; angle1 = -cM_atan2s(tmp.y, tmp.z); // TODO: std::sqrtf(float) angle2 = cM_atan2s(tmp.x, std::sqrtf(tmp.y * tmp.y + tmp.z * tmp.z)); MtxTrans(i_this->m2E0[i].x, i_this->m2E0[i].y, i_this->m2E0[i].z, false); s16 var_r4; s32 var_r20; if (i_this->m83C[i] != 0) { var_r20 = i_this->m83C[i] * cM_ssin(i_this->m298 * 18000) * (REG6_F(6) + 100.0f); var_r4 = i_this->m298 * 3000; } else { var_r4 = 0; var_r20 = 0; } cMtx_YrotM(*calc_mtx, var_r4); cMtx_XrotM(*calc_mtx, angle1 + var_r20); cMtx_YrotM(*calc_mtx, angle2); i_this->mpChainModels[i]->setBaseTRMtx(*calc_mtx); g_env_light.setLightTevColorType(i_this->mpChainModels[i], &i_this->tevStr); mDoExt_modelUpdateDL(i_this->mpChainModels[i]); } } /* 00000540-000005E8 .text daMsw_Draw__FP9msw_class */ static BOOL daMsw_Draw(msw_class* i_this) { g_env_light.settingTevStruct(TEV_TYPE_BG0, &i_this->current.pos, &i_this->tevStr); g_env_light.setLightTevColorType(i_this->mpModel, &i_this->tevStr); mDoExt_modelUpdateDL(i_this->mpModel); dComIfGd_setListBG(); chain_Draw(i_this); dComIfGd_setList(); return TRUE; } /* 000005E8-0000080C .text msw_move__FP9msw_class */ void msw_move(msw_class* i_this) { i_this->m298 += 1; #if VERSION > VERSION_DEMO // Branchless comparison // Probably something #ifdef'd out for debug switch (i_this->m29A) { case 0: break; } #endif cLib_addCalcAngleS2(&i_this->current.angle.x, 0, 10, 0x200); cLib_addCalcAngleS2(&i_this->current.angle.z, 0, 10, 0x200); i_this->m2C8.x = i_this->m2BC.x * cM_ssin(i_this->m298 * 1500); i_this->m2C8.z = i_this->m2BC.z * cM_ssin(i_this->m298 * 1300); cLib_addCalc2(&i_this->m2BC.x, REG0_F(9), 1.0f, REG0_F(3) + 20.0f); cLib_addCalc2(&i_this->m2BC.z, REG0_F(9), 1.0f, REG0_F(3) + 20.0f); i_this->m2A4.x = i_this->m2B0.x * cM_ssin(i_this->m298 * 750); i_this->m2A4.z = i_this->m2B0.z * cM_ssin(i_this->m298 * 900); cLib_addCalc0(&i_this->m2B0.x, 1.0f, REG0_F(6) + 0.25f); cLib_addCalc0(&i_this->m2B0.z, 1.0f, REG0_F(6) + 0.25f); i_this->shape_angle = i_this->current.angle + i_this->m2C8; i_this->current.pos = i_this->home.pos + i_this->m2A4; } /* 0000080C-00000AD4 .text daMsw_Execute__FP9msw_class */ static BOOL daMsw_Execute(msw_class* i_this) { /* Nonmatching - retail-only regalloc */ fopAc_ac_c* actor = i_this; fopAc_ac_c* player = dComIfGp_getPlayer(0); msw_move(i_this); MtxTrans(actor->current.pos.x, actor->current.pos.y, actor->current.pos.z, false); cMtx_YrotM(*calc_mtx, actor->shape_angle.y); cMtx_XrotM(*calc_mtx, actor->shape_angle.x); cMtx_ZrotM(*calc_mtx, actor->shape_angle.z); MtxScale(actor->scale.x, 1.0f, actor->scale.z, true); i_this->mpModel->setBaseTRMtx(*calc_mtx); MtxPush(); for (int chainIdx = 0; chainIdx < 4; chainIdx++) { static f32 xd[4] = { 1.0f, 1.0f, -1.0f, -1.0f }; static f32 zd[4] = { 1.0f, -1.0f, 1.0f, -1.0f }; cXyz src; src.x = (200.0f + REG0_F(10)) * xd[chainIdx]; src.y = 0.0f; src.z = (200.0f + REG0_F(10)) * zd[chainIdx]; MtxPosition(&src, &i_this->m2E0[chainIdx]); if (i_this->m844 != 0) { i_this->m844--; i_this->m310[chainIdx] = i_this->m2E0[chainIdx]; i_this->m310[chainIdx].y = i_this->m2E0[chainIdx].y + 1000.0f; } if (i_this->m83C[chainIdx] != 0) { i_this->m83C[chainIdx]--; } if (i_this->mChainCyls[chainIdx].ChkTgHit() && i_this->m83C[chainIdx] < 10) { i_this->m83C[chainIdx] = REG6_S(3) + 15; mDoAud_seStart(JA_SE_LK_HIT_SBRIDGE_CHAIN, &i_this->m2E0[chainIdx], 0, dComIfGp_getReverb(fopAcM_GetRoomNo(actor))); cXyz scale; scale.x = scale.y = scale.z = 2.0f; dComIfGp_particle_set(dPa_name::ID_COMMON_PURPLE_HIT, i_this->mChainCyls[chainIdx].GetTgHitPosP(), &player->shape_angle, &scale); } i_this->mChainCyls[chainIdx].SetC(i_this->m2E0[chainIdx]); dComIfG_Ccsp()->Set(&i_this->mChainCyls[chainIdx]); } MtxPull(); MTXCopy(*calc_mtx, i_this->mMtx); i_this->mpBgW->Move(); return TRUE; } /* 00000AD4-00000B38 .text daMsw_IsDelete__FP9msw_class */ static BOOL daMsw_IsDelete(msw_class* i_this) { for (int i = 0; i < 4; i++) { mDoAud_seDeleteObject(&i_this->m2E0[i]); } return TRUE; } /* 00000B38-00000B88 .text daMsw_Delete__FP9msw_class */ static BOOL daMsw_Delete(msw_class* i_this) { dComIfG_resDeleteDemo(&i_this->mPhs, "Msw"); dComIfG_Bgsp()->Release(i_this->mpBgW); return TRUE; } /* 00000B88-00000D3C .text daMsw_CreateInit__FP10fopAc_ac_c */ BOOL daMsw_CreateInit(fopAc_ac_c* i_this) { msw_class* pActor = static_cast(i_this); J3DModelData* modelData = static_cast(dComIfG_getObjectRes("Msw", MSW_BDL_MSWNG)); pActor->mpModel = mDoExt_J3DModel__create(modelData, 0, 0x11020203); if (pActor->mpModel == NULL) { return FALSE; } modelData = static_cast(dComIfG_getObjectRes("Msw", MSW_BDL_OBM_CHAIN1)); JUT_ASSERT(DEMO_SELECT(519, 523), modelData != NULL); for (int chainIdx = 0; chainIdx < 4; chainIdx++) { pActor->mpChainModels[chainIdx] = mDoExt_J3DModel__create(modelData, 0, 0x11020203); if (pActor->mpChainModels[chainIdx] == NULL) { return FALSE; } } pActor->mpBgW = new dBgW(); if (pActor->mpBgW == NULL) { return FALSE; } cBgD_t* pBgd = static_cast(dComIfG_getObjectRes("Msw", MSW_DZB_MSWING)); BOOL error = pActor->mpBgW->Set(pBgd, cBgW::MOVE_BG_e, &pActor->mMtx); if (error == TRUE) { return FALSE; } pActor->mpBgW->SetCrrFunc(dBgS_MoveBGProc_Typical); pActor->mpBgW->SetRideCallback(ride_call_back); return TRUE; } /* 00000D3C-00000FE0 .text daMsw_Create__FP10fopAc_ac_c */ static cPhs_State daMsw_Create(fopAc_ac_c* i_this) { static dCcD_SrcCyl himo_cyl_src = { // dCcD_SrcGObjInf { /* Flags */ 0, /* SrcObjAt Type */ 0, /* SrcObjAt Atp */ 0, /* SrcObjAt SPrm */ 0, /* SrcObjTg Type */ ~(AT_TYPE_WATER | AT_TYPE_UNK20000 | AT_TYPE_WIND | AT_TYPE_UNK400000 | AT_TYPE_LIGHT), /* SrcObjTg SPrm */ cCcD_TgSPrm_Set_e | cCcD_TgSPrm_IsEnemy_e, /* SrcObjCo SPrm */ cCcD_CoSPrm_Set_e | cCcD_CoSPrm_IsPlayer_e | cCcD_CoSPrm_VsGrpAll_e, /* SrcGObjAt Se */ 0, /* SrcGObjAt HitMark */ 0, /* SrcGObjAt Spl */ 0, /* SrcGObjAt Mtrl */ 0, /* SrcGObjAt SPrm */ 0, /* SrcGObjTg Se */ 0, /* SrcGObjTg HitMark */ 0, /* SrcGObjTg Spl */ 0, /* SrcGObjTg Mtrl */ 0, /* SrcGObjTg SPrm */ dCcG_TgSPrm_Shield_e, /* SrcGObjCo SPrm */ 0, }, // cM3dGCylS {{ /* Center */ {0.0f, 0.0f, 0.0f}, /* Radius */ 10.0f, /* Height */ 1000.0f, }}, }; fopAcM_SetupActor(i_this, msw_class); msw_class* a_this = static_cast(i_this); cPhs_State phase_state = dComIfG_resLoad(&a_this->mPhs, "Msw"); if (phase_state == cPhs_COMPLEATE_e) { a_this->m2A0 = (fopAcM_GetParam(a_this) >> 0) & 0xFF; if (a_this->m2A0 == 0xFF) { a_this->m2A0 = 0; } if (!fopAcM_entrySolidHeap(a_this, daMsw_CreateInit, 0x10040)) { return cPhs_ERROR_e; } if (a_this->mpModel == NULL) { return cPhs_ERROR_e; } if (dComIfG_Bgsp()->Regist(a_this->mpBgW, a_this)) { return cPhs_ERROR_e; } switch (a_this->m2A0) { case 1: a_this->scale.x = 1.5f; a_this->scale.z = 1.5f; break; case 2: a_this->scale.x = 2.0f; a_this->scale.z = 2.0f; break; case 3: a_this->scale.x = 3.0f; a_this->scale.z = 3.0f; break; default: a_this->scale.z = 1.0f; a_this->scale.x = 1.0f; break; } a_this->scale.y = 1.0f; fopAcM_SetMtx(a_this, a_this->mpModel->getBaseTRMtx()); fopAcM_SetMin(a_this, a_this->scale.x * -200.0f, -5000.0f, a_this->scale.z * -200.0f); fopAcM_SetMax(a_this, a_this->scale.x * 200.0f, 5000.0f, a_this->scale.z * 200.0f); a_this->mStts.Init(0xFF, 0xFF, a_this); for (int chainIdx = 0; chainIdx < 4; chainIdx++) { a_this->mChainCyls[chainIdx].Set(himo_cyl_src); a_this->mChainCyls[chainIdx].SetStts(&a_this->mStts); } a_this->m844 = 10; daMsw_Execute(a_this); } return phase_state; } static actor_method_class l_daMsw_Method = { (process_method_func)daMsw_Create, (process_method_func)daMsw_Delete, (process_method_func)daMsw_Execute, (process_method_func)daMsw_IsDelete, (process_method_func)daMsw_Draw, }; actor_process_profile_definition g_profile_MSW = { /* LayerID */ fpcLy_CURRENT_e, /* ListID */ 0x0003, /* ListPrio */ fpcPi_CURRENT_e, /* ProcName */ PROC_MSW, /* Proc SubMtd */ &g_fpcLf_Method.base, /* Size */ sizeof(msw_class), /* SizeOther */ 0, /* Parameters */ 0, /* Leaf SubMtd */ &g_fopAc_Method.base, /* Priority */ PRIO_MSW, /* Actor SubMtd */ &l_daMsw_Method, /* Status */ fopAcStts_CULL_e | fopAcStts_UNK40000_e, /* Group */ fopAc_ACTOR_e, /* CullType */ fopAc_CULLBOX_CUSTOM_e, };