From 8472920fda85dda422d6b1243d699ed8aaa27abf Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 7 Feb 2024 18:43:39 -0800 Subject: [PATCH] d_a_bita match --- configure.py | 2 +- include/d/actor/d_a_bita.h | 22 +++ include/d/actor/d_a_btd.h | 2 + src/d/actor/d_a_bita.cpp | 298 ++++++++++++++++++++++++++++++++++--- 4 files changed, 302 insertions(+), 22 deletions(-) diff --git a/configure.py b/configure.py index 6a66b859c..c196df4f9 100644 --- a/configure.py +++ b/configure.py @@ -1217,7 +1217,7 @@ config.libs = [ ActorRel(Matching, "d_a_andsw2"), ActorRel(NonMatching, "d_a_att"), ActorRel(NonMatching, "d_a_bflower"), - ActorRel(NonMatching, "d_a_bita"), + ActorRel(Matching, "d_a_bita", extra_cflags=['-pragma "nosyminline on"']), ActorRel(Matching, "d_a_branch"), ActorRel(NonMatching, "d_a_bridge"), ActorRel(NonMatching, "d_a_coming2"), diff --git a/include/d/actor/d_a_bita.h b/include/d/actor/d_a_bita.h index 397cb8dc7..6098e6d5b 100644 --- a/include/d/actor/d_a_bita.h +++ b/include/d/actor/d_a_bita.h @@ -2,10 +2,32 @@ #define D_A_BITA_H #include "f_op/f_op_actor.h" +#include "d/d_cc_d.h" +#include "SSystem/SComponent/c_phase.h" + +class J3DModel; +class mDoExt_brkAnm; +class dBgW; class bita_class : public fopAc_ac_c { public: /* Place member variables here */ + /* 0x290 */ request_of_phase_process_class mPhs; + /* 0x298 */ J3DModel* mpModel; + /* 0x29C */ J3DModel* mpModelEf; + /* 0x2A0 */ mDoExt_brkAnm* mpBrkAnm; + /* 0x2A4 */ u8 mType; + /* 0x2A5 */ u8 mPrmScale; + /* 0x2A6 */ u8 mTimer; + /* 0x2A7 */ u8 field_0x2a7; + /* 0x2A8 */ u8 mMode; + /* 0x2A9 */ u8 mSub; + /* 0x2AA */ u8 field_0x2aa; + /* 0x2AB */ u8 field_0x2ab; + /* 0x2AC */ dCcD_Stts mStts; + /* 0x2E8 */ dCcD_Cyl mCyl; + /* 0x418 */ Mtx mMtx; + /* 0x448 */ dBgW* mpBgW; }; #endif /* D_A_BITA_H */ diff --git a/include/d/actor/d_a_btd.h b/include/d/actor/d_a_btd.h index a03aa0a29..d310831f4 100644 --- a/include/d/actor/d_a_btd.h +++ b/include/d/actor/d_a_btd.h @@ -6,6 +6,8 @@ class btd_class : public fopAc_ac_c { public: /* Place member variables here */ + /* 0x0290 */ u8 field_0x290[0x6e16 - 0x290]; + /* 0x6E16 */ s16 field_0x6e16; }; class daBtd_HIO_c { diff --git a/src/d/actor/d_a_bita.cpp b/src/d/actor/d_a_bita.cpp index fe7f00529..1d34e7233 100644 --- a/src/d/actor/d_a_bita.cpp +++ b/src/d/actor/d_a_bita.cpp @@ -4,54 +4,310 @@ // #include "d/actor/d_a_bita.h" -#include "dolphin/types.h" +#include "f_op/f_op_actor_mng.h" +#include "f_op/f_op_camera.h" +#include "d/d_bg_s_movebg_actor.h" +#include "d/d_com_inf_game.h" +#include "d/d_kankyo.h" +#include "d/d_procname.h" +#include "d/actor/d_a_btd.h" +#include "m_Do/m_Do_ext.h" +#include "m_Do/m_Do_mtx.h" + +static f32 dummy[3] = {1.0f, 1.0f, 1.0f}; +static f32 dummy2[3] = {1.0f, 1.0f, 1.0f}; +// I suspect this is HIO data. +struct _dummy { + u8 field_0x00; + u8 field_0x01; + u8 field_0x02; + u8 field_0x03; + f32 field_0x04; + f32 field_0x08; + f32 field_0x0c; + f32 field_0x10; + f32 field_0x14; +} dummy3 = { + 0x02, 0x00, 0x02, 0x01, + 0.0f, 2.125f, 0.0f, 1.75f, 0.0f, +}; + +static btd_class* btd = NULL; + +static u32 ita_bmd[] = { 0x07, 0x08 }; +static u32 ita_dzb[] = { 0x0F, 0x10 }; +static u32 ita_Ef_bmd[] = { 0x05, 0x06 }; +static u32 ita_Ef[] = { 0x0B, 0x0C }; /* 00000078-000000C4 .text b_a_sub__FPvPv */ -void b_a_sub(void*, void*) { - /* Nonmatching */ +static void* b_a_sub(void* search, void* user) { + if (fopAc_IsActor(search) && fopAcM_GetName(search) == PROC_BTD) + return search; + return NULL; } /* 000000C4-0000018C .text daBita_Draw__FP10bita_class */ -static BOOL daBita_Draw(bita_class*) { - /* Nonmatching */ +static BOOL daBita_Draw(bita_class* i_this) { + dKy_getEnvlight().settingTevStruct(TEV_TYPE_BG0, &i_this->current.pos, &i_this->mTevStr); + if (i_this->mMode == 1 && i_this->mSub == 1) { + dKy_getEnvlight().setLightTevColorType(i_this->mpModelEf, &i_this->mTevStr); + i_this->mpBrkAnm->entry(i_this->mpModelEf->getModelData()); + mDoExt_modelUpdateDL(i_this->mpModelEf); + i_this->mpBrkAnm->remove(i_this->mpModelEf->getModelData()); + } else { + dKy_getEnvlight().setLightTevColorType(i_this->mpModel, &i_this->mTevStr); + mDoExt_modelUpdateDL(i_this->mpModel); + } + return TRUE; } /* 0000018C-000002D0 .text mode_normal__FP10bita_class */ -void mode_normal(bita_class*) { - /* Nonmatching */ +static void mode_normal(bita_class* i_this) { + if (btd != NULL) { + if (btd->field_0x6e16 >= 100) { + cXyz delta = dComIfGp_getCamera(0)->mLookat.mEye - i_this->current.pos; + if (delta.abs() < 1500.0f) { + fopAcM_delete(i_this); + } + } else { + if (i_this->mCyl.ChkTgHit() && i_this->mCyl.GetTgHitObj()->GetAtType() == AT_TYPE_FIRE) { + i_this->mMode = 1; + i_this->mSub = 0; + } + } + } } /* 000002D0-000004B4 .text mode_dead__FP10bita_class */ -void mode_dead(bita_class*) { - /* Nonmatching */ +static void mode_dead(bita_class* i_this) { + switch (i_this->mSub) { + case 0: + i_this->mTimer = 0; + i_this->field_0x2a7 = cM_rndF(4.0f); + i_this->mSub = 1; + break; + case 1: + i_this->mTimer++; + if (i_this->mTimer == 20) { + fopAcM_seStartCurrent(i_this, JA_SE_OBJ_BTD_BOARD_BURN, 0); + } + if (i_this->mTimer == 88) { + fopAcM_seStartCurrent(i_this, JA_SE_OBJ_BTD_BOARD_BRK, 0); + + s32 type = i_this->mType; + if (type > 1) + type = 1; + + if (type == 0) { + dComIfGp_particle_set(0x80e3, &i_this->current.pos, &i_this->shape_angle); + } else { + dComIfGp_particle_set(0x80e4, &i_this->current.pos, &i_this->shape_angle); + } + } + + if (i_this->mTimer >= 90) + fopAcM_delete(i_this); + break; + } } /* 000004B4-00000584 .text base_mtx_set__FP10bita_class */ -void base_mtx_set(bita_class*) { - /* Nonmatching */ +static void base_mtx_set(bita_class* i_this) { + MtxTrans(i_this->current.pos.x, i_this->current.pos.y, i_this->current.pos.z, false); + cMtx_YrotM(*calc_mtx, i_this->shape_angle.y); + cMtx_XrotM(*calc_mtx, i_this->shape_angle.x); + if (i_this->mMode == 1 && i_this->mSub >= 1) { + i_this->mpModelEf->setBaseTRMtx(*calc_mtx); + if (i_this->mTimer < 60) + i_this->mpBrkAnm->play(); + fopAcM_SetMtx(i_this, i_this->mpModelEf->getBaseTRMtx()); + } else { + i_this->mpModel->setBaseTRMtx(*calc_mtx); + } } /* 00000584-00000714 .text daBita_Execute__FP10bita_class */ -static BOOL daBita_Execute(bita_class*) { - /* Nonmatching */ +static BOOL daBita_Execute(bita_class* i_this) { + if (btd == NULL) + btd = (btd_class*)fpcM_Search(b_a_sub, i_this); + + if (dComIfGs_getLife() == 0) + fopAcM_OffStatus(i_this, fopAcStts_UNK4000_e); + + switch (i_this->mMode) { + case 0: + mode_normal(i_this); + break; + case 1: + mode_dead(i_this); + break; + } + + base_mtx_set(i_this); + cMtx_copy(*calc_mtx, i_this->mMtx); + i_this->mpBgW->Move(); + + if (btd != NULL && i_this->mMode == 0) { + cMtx_YrotS(*calc_mtx, i_this->shape_angle.y); + cMtx_XrotM(*calc_mtx, i_this->shape_angle.x); + cXyz offs(0.0f, -80.0f, 160.0f); + cXyz pos; + MtxPosition(&offs, &pos); + VECAdd(&pos, &i_this->current.pos, &pos); + i_this->mCyl.SetC(pos); + i_this->mCyl.SetH(60.0f); + i_this->mCyl.SetR(i_this->mScale.x * 400.0f); + dComIfG_Ccsp()->Set(&i_this->mCyl); + } + + return TRUE; } /* 00000714-0000071C .text daBita_IsDelete__FP10bita_class */ -static BOOL daBita_IsDelete(bita_class*) { - /* Nonmatching */ +static BOOL daBita_IsDelete(bita_class* i_this) { + return TRUE; } /* 0000071C-00000778 .text daBita_Delete__FP10bita_class */ -static BOOL daBita_Delete(bita_class*) { - /* Nonmatching */ +static BOOL daBita_Delete(bita_class* i_this) { + dComIfG_resDelete(&i_this->mPhs, "Bita"); + if (i_this->heap != NULL) + dComIfG_Bgsp()->Release(i_this->mpBgW); + return TRUE; } /* 00000778-00000A18 .text useHeapInit__FP10fopAc_ac_c */ -static BOOL useHeapInit(fopAc_ac_c*) { - /* Nonmatching */ +static BOOL useHeapInit(fopAc_ac_c* i_ac) { + bita_class* i_this = (bita_class*)i_ac; + + s32 type = i_this->mType; + if (type > 1) + type = 1; + + J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("Bita", ita_bmd[type]); + JUT_ASSERT(0x23b, modelData != 0); + J3DModel* model = mDoExt_J3DModel__create(modelData, 0, 0x11020203); + if (model == NULL) + return FALSE; + i_this->mpModel = model; + + modelData = (J3DModelData*)dComIfG_getObjectRes("Bita", ita_Ef_bmd[type]); + JUT_ASSERT(0x247, modelData != 0); + model = mDoExt_J3DModel__create(modelData, 0, 0x11020203); + if (model == NULL) + return FALSE; + i_this->mpModelEf = model; + + i_this->mpBrkAnm = new mDoExt_brkAnm(); + if (i_this->mpBrkAnm == NULL) + return FALSE; + J3DAnmTevRegKey* brk = (J3DAnmTevRegKey*)dComIfG_getObjectRes("Bita", ita_Ef[type]); + if (!i_this->mpBrkAnm->init(i_this->mpModelEf->getModelData(), brk, 1, J3DFrameCtrl::LOOP_ONCE_e, 1.0f, 0, -1, false, 0)) + return FALSE; + + i_this->mpBgW = new dBgW(); + if (i_this->mpBgW == NULL) + return FALSE; + cBgD_t* dzb = (cBgD_t*)dComIfG_getObjectRes("Bita", ita_dzb[type]); + if (i_this->mpBgW->Set(dzb, dBgW::MOVE_BG_e, &i_this->mMtx) == 1) + return FALSE; + + i_this->mpBgW->SetCrrFunc(dBgS_MoveBGProc_Typical); + return TRUE; } /* 00000A60-00000D24 .text daBita_Create__FP10fopAc_ac_c */ -static s32 daBita_Create(fopAc_ac_c*) { - /* Nonmatching */ +static s32 daBita_Create(fopAc_ac_c* i_ac) { + static dCcD_SrcCyl body_cyl_src = { + // dCcD_SrcGObjInf + { + /* Flags */ 0, + /* SrcObjAt Type */ 0, + /* SrcObjAt Atp */ 0, + /* SrcObjAt SPrm */ 0, + /* SrcObjTg Type */ AT_TYPE_FIRE, + /* SrcObjTg SPrm */ TG_SPRM_SET | TG_SPRM_IS_OTHER, + /* SrcObjCo SPrm */ 0, + /* SrcGObjAt Se */ dCcD_SE_UNK6, + /* SrcGObjAt HitMark */ 0, + /* SrcGObjAt Spl */ 0x01, + /* SrcGObjAt Mtrl */ 0, + /* SrcGObjAt SPrm */ 0, + /* SrcGObjTg Se */ 0, + /* SrcGObjTg HitMark */ 0, + /* SrcGObjTg Spl */ 0, + /* SrcGObjTg Mtrl */ 0, + /* SrcGObjTg SPrm */ 0, + /* SrcGObjCo SPrm */ 0, + }, + // cM3dGCylS + { + /* Center */ 0.0f, 0.0f, 0.0f, + /* Radius */ 50.0f, + /* Height */ 20.0f, + }, + }; + + fopAcM_SetupActor(i_ac, bita_class); + bita_class* i_this = (bita_class*)i_ac; + + s32 rt = dComIfG_resLoad(&i_this->mPhs, "Bita"); + if (rt == cPhs_COMPLEATE_e) { + btd = NULL; + i_this->mType = (fopAcM_GetParam(i_this) >> 0) & 0xFF; + i_this->mPrmScale = (fopAcM_GetParam(i_this) >> 8) & 0xFF; + if (i_this->mType == 0xFF) + i_this->mType = 0; + + if (!fopAcM_entrySolidHeap(i_this, useHeapInit, 0x30c0)) + return cPhs_ERROR_e; + + if (dComIfG_Bgsp()->Regist(i_this->mpBgW, i_this)) + return cPhs_ERROR_e; + + switch (i_this->mPrmScale) { + case 1: i_this->mScale.setall(1.5f); break; + case 2: i_this->mScale.setall(2.0f); break; + case 3: i_this->mScale.setall(3.0f); break; + default: i_this->mScale.y = i_this->mScale.z = i_this->mScale.x = 1.0f; break; + } + + fopAcM_SetMtx(i_this, i_this->mpModel->getBaseTRMtx()); + fopAcM_SetMin(i_this, i_this->mScale.x * -1000.0f, -500.0f, i_this->mScale.z * -1000.0f); + fopAcM_SetMax(i_this, i_this->mScale.x * 1000.0f, 500.0f, i_this->mScale.z * 1000.0f); + i_this->mpModel->setBaseScale(i_this->mScale); + i_this->mpModelEf->setBaseScale(i_this->mScale); + i_this->shape_angle = i_this->current.angle; + base_mtx_set(i_this); + i_this->mpBgW->Move(); + i_this->mCyl.Set(body_cyl_src); + i_this->mCyl.SetStts(&i_this->mStts); + } + + return rt; } + +static actor_method_class l_daBita_Method = { + (process_method_func)daBita_Create, + (process_method_func)daBita_Delete, + (process_method_func)daBita_Execute, + (process_method_func)daBita_IsDelete, + (process_method_func)daBita_Draw, +}; + +actor_process_profile_definition g_profile_BITA = { + /* LayerID */ fpcLy_CURRENT_e, + /* ListID */ 3, + /* ListPrio */ fpcPi_CURRENT_e, + /* ProcName */ PROC_BITA, + /* Proc SubMtd */ &g_fpcLf_Method.mBase, + /* Size */ sizeof(bita_class), + /* SizeOther */ 0, + /* Parameters */ 0, + /* Leaf SubMtd */ &g_fopAc_Method.base, + /* Priority */ 0x0096, + /* Actor SubMtd */ &l_daBita_Method, + /* Status */ fopAcStts_UNK40000_e | fopAcStts_UNK4000_e | fopAcStts_CULL_e, + /* Group */ fopAc_ENV_e, + /* CullType */ fopAc_CULLBOX_CUSTOM_e, +};