From fa2cbbadf71dd2402abb69651753629c71e45dd3 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Thu, 30 Nov 2023 23:30:10 -0500 Subject: [PATCH] d_a_obj_mtest 100%, no match --- include/SSystem/SComponent/c_bg_w.h | 40 ++- include/d/actor/d_a_obj_mtest.h | 70 ++++- src/d/actor/d_a_obj_akabe.cpp | 2 +- src/d/actor/d_a_obj_movebox.cpp | 2 +- src/d/actor/d_a_obj_mtest.cpp | 408 ++++++++++++++++++++++++++-- 5 files changed, 484 insertions(+), 38 deletions(-) diff --git a/include/SSystem/SComponent/c_bg_w.h b/include/SSystem/SComponent/c_bg_w.h index 5436a2142..fff910c2e 100644 --- a/include/SSystem/SComponent/c_bg_w.h +++ b/include/SSystem/SComponent/c_bg_w.h @@ -121,6 +121,10 @@ public: LOCK_e = 0x80, }; + enum PRIORITY { + + }; + cBgW(); void FreeArea(); @@ -154,22 +158,50 @@ public: void GetTriPnt(int, cXyz*, cXyz*, cXyz*) const; void GetTopUnder(f32*, f32*) const; - s32 GetGrpInf(s32 grp_id) { + s32 GetGrpInf(int grp_id) const { JUT_ASSERT(0x2e1, 0 <= grp_id && grp_id < pm_bgd->m_g_num); return pm_bgd->m_g_tbl[grp_id].m_info; } - s32 GetTriGrp(s32 poly_index) { + s32 GetTriGrp(int poly_index) const { JUT_ASSERT(0x2a2, 0 <= poly_index && poly_index < pm_bgd->m_t_num); return pm_bgd->m_t_tbl[poly_index].grp; } - cM3dGPla * GetTriPla(s32 poly_index) { + cM3dGPla * GetTriPla(int poly_index) { JUT_ASSERT(0x2af, 0 <= poly_index && poly_index < pm_bgd->m_t_num); return &pm_tri[poly_index].m_plane; } - void SetPriority(u8 priority) { mWallCorrectPriority = priority; } + void SetPriority(PRIORITY priority) { mWallCorrectPriority = priority; } + void SetLock() { mFlags |= 0x80; } + + void ChkFlush() {} + void ChkGroundRegist() {} + void ChkLock() {} + void ChkMoveBg() {} + void ChkNoCalcVtx() {} + void ChkPriority(int) {} + void ChkRoofRegist() {} + void ChkThrough() {} + void ChkWallRegist() {} + void ClrNoCalcVtx() {} + void GetBaseMtxP() {} + void GetOldInvMtx(float(*)[4]) const {} + void GetPolyInf0(int) const {} + void GetPolyInf1(int) const {} + void GetPolyInf2(int) const {} + void GetPolyInf3(int) const {} + void GetPolyInfId(int) const {} + void GetVtxNum() const {} + void GetVtxTbl() const {} + void GroundCross(cBgS_GndChk*) {} + void LineCheck(cBgS_LinChk*) {} + void OffRoofRegist() {} + void SetBaseMtxP(float(*)[3][4]) {} + void SetNoCalcVtx() {} + void SetVtxTbl(Vec*) {} + void ShdwDraw(cBgS_ShdwDraw*) {} virtual ~cBgW(); virtual u32 GetGrpToRoomIndex(int) const; diff --git a/include/d/actor/d_a_obj_mtest.h b/include/d/actor/d_a_obj_mtest.h index 3e624092e..225af7798 100644 --- a/include/d/actor/d_a_obj_mtest.h +++ b/include/d/actor/d_a_obj_mtest.h @@ -2,28 +2,68 @@ #define D_A_OBJ_MTEST_H #include "f_op/f_op_actor.h" +#include "d/d_bg_s_movebg_actor.h" +#include "d/d_cc_d.h" +#include "d/d_a_obj.h" namespace daObjMtest { - class Act_c : public fopAc_ac_c { + class Act_c : public dBgS_MoveBgActor { public: - void prm_get_arg0() const {} - void prm_get_arg1() const {} - void prm_get_swSave() const {} - void prm_get_type() const {} - - void chk_appear(); - void CreateHeap(); - s32 Create(); - void Mthd_Create(); - BOOL Delete(); - void Mthd_Delete(); + enum Type { + Type_0 = 0, + Type_1 = 1, + Type_2 = 2, + Type_3 = 3, + Type_4 = 4, + Type_5 = 5, + Type_6 = 6, + Type_7 = 7, + Type_Max, + }; + + enum Prm_e { + PRM_ARG0_W = 0x04, + PRM_ARG0_S = 0x10, + + PRM_ARG1_W = 0x04, + PRM_ARG1_S = 0x18, + + PRM_SWSAVE_W = 0x08, + PRM_SWSAVE_S = 0x08, + + PRM_TYPE_W = 0x03, + PRM_TYPE_S = 0x00, + }; + + s32 prm_get_arg0() const { return daObj::PrmAbstract(this, PRM_ARG0_W, PRM_ARG0_S); } + s32 prm_get_arg1() const { return daObj::PrmAbstract(this, PRM_ARG1_W, PRM_ARG1_S); } + s32 prm_get_swSave() const { return daObj::PrmAbstract(this, PRM_SWSAVE_W, PRM_SWSAVE_S); } + s32 prm_get_type() const { return daObj::PrmAbstract(this, PRM_TYPE_W, PRM_TYPE_S); } + + static char* M_arcname[]; + static const dCcD_SrcCyl M_cyl_src; + static cXyz M_scl_mult[]; + + virtual BOOL CreateHeap(); + virtual BOOL Create(); + virtual BOOL Delete(); + virtual BOOL Execute(Mtx** pMtx); + virtual BOOL Draw(); + + bool chk_appear(); + s32 Mthd_Create(); + BOOL Mthd_Delete(); void set_mtx(); void init_mtx(); - void Execute(float(**)[3][4]); - BOOL Draw(); public: - /* Place member variables here */ + /* 0x2C8 */ Mtx mMtx; + /* 0x2F8 */ request_of_phase_process_class mPhs; + /* 0x300 */ J3DModel* mpModel; + /* 0x304 */ dCcD_Stts mStts; + /* 0x340 */ dCcD_Cyl mCyl; + /* 0x470 */ int M_type; + /* 0x474 */ bool mbAppear; }; }; diff --git a/src/d/actor/d_a_obj_akabe.cpp b/src/d/actor/d_a_obj_akabe.cpp index 16c7505cf..8f7df41ef 100644 --- a/src/d/actor/d_a_obj_akabe.cpp +++ b/src/d/actor/d_a_obj_akabe.cpp @@ -71,7 +71,7 @@ namespace daObjAkabe { if (fopAcM_entrySolidHeap(this, solidHeapCB, heap_size[mType])) { dComIfG_Bgsp()->Regist(mpBgW, this); mpBgW->SetCrrFunc(NULL); - mpBgW->SetPriority(1); + mpBgW->SetPriority((cBgW::PRIORITY)1); fopAcM_SetMtx(this, mMtx); if (mType == 3) { fopAcM_setCullSizeBox(this, -51.0f, -1.0f, -51.0f, 51.0f, 101.0f, 51.0f); diff --git a/src/d/actor/d_a_obj_movebox.cpp b/src/d/actor/d_a_obj_movebox.cpp index 200779451..af161b3ea 100644 --- a/src/d/actor/d_a_obj_movebox.cpp +++ b/src/d/actor/d_a_obj_movebox.cpp @@ -1404,7 +1404,7 @@ namespace daObjMovebox { mStts.Init(0xFF, 0xFF, this); mCyl.Set(M_cyl_src); mCyl.SetStts(&mStts); - mCyl.SetTgVec(*(cXyz*)&cXyz::Zero); // TODO: this doesn't seem right, but it does match + mCyl.SetTgVec((cXyz&)cXyz::Zero); mCyl.OnTgNoHitMark(); mCyl.OffCoSetBit(); diff --git a/src/d/actor/d_a_obj_mtest.cpp b/src/d/actor/d_a_obj_mtest.cpp index 8ebb63547..e6857ebec 100644 --- a/src/d/actor/d_a_obj_mtest.cpp +++ b/src/d/actor/d_a_obj_mtest.cpp @@ -4,54 +4,428 @@ // #include "d/actor/d_a_obj_mtest.h" -#include "dolphin/types.h" +#include "d/d_procname.h" +#include "JSystem/JKernel/JKRHeap.h" +#include "JSystem/J3DGraphAnimator/J3DModel.h" +#include "d/d_com_inf_game.h" +#include "m_Do/m_Do_mtx.h" + +// Needed for the .data and .bss sections to match. +static f32 dummy1[3] = {1.0f, 1.0f, 1.0f}; +static f32 dummy2[3] = {1.0f, 1.0f, 1.0f}; +static u8 dummy3[4] = {0x02, 0x00, 0x02, 0x01}; +static f64 dummy4[2] = {3.0, 0.5}; +u8 dummy5[0x4C]; + +char* daObjMtest::Act_c::M_arcname[Type_Max] = { + "Mtest", + "Mtest", + "Mtest", + "Mtest", + "Mtest", + "Mtest", + "Owater", + "Astop", +}; + +enum MTEST_RES_FILE_ID { // IDs and indexes are synced + /* BMDC */ + MTEST_BMD_MCUBE=0x4, + MTEST_BMD_MCYLN=0x5, + + /* DZB */ + MTEST_DZB_MCUBE=0x8, + MTEST_DZB_MCUBEHG=0x9, + MTEST_DZB_MCUBELK=0xA, + MTEST_DZB_MCUBENC=0xB, + MTEST_DZB_MCYLN=0xC, + MTEST_DZB_MCYLNHG=0xD, + MTEST_DZB_MCYLNNC=0xE, + MTEST_DZB_MWTRSB=0xF, + MTEST_DZB_MYGNSB=0x10, +}; + +enum OWATER_RES_FILE_ID { // IDs and indexes are synced + /* DZB */ + OWATER_DZB_OWATER=0x3, +}; + +enum ASTOP_RES_FILE_ID { // IDs and indexes are synced + /* DZB */ + ASTOP_DZB_A00=0x3, + ASTOP_DZB_ASLOW=0x4, + ASTOP_DZB_ASLOW00=0x5, + ASTOP_DZB_ASTOP=0x6, + ASTOP_DZB_ASTOP00=0x7, +}; + +const dCcD_SrcCyl daObjMtest::Act_c::M_cyl_src = { + // dCcD_SrcGObjInf + { + /* Flags */ 0, + /* SrcObjAt Type */ 0, + /* SrcObjAt Atp */ 0, + /* SrcObjAt SPrm */ 0, + /* SrcObjTg Type */ AT_TYPE_BOMB, + /* SrcObjTg SPrm */ 0x09, + /* SrcObjCo SPrm */ 0, + /* SrcGObjAt Se */ 0, + /* SrcGObjAt HitMark */ 0, + /* SrcGObjAt Spl */ 0, + /* SrcGObjAt Mtrl */ 0, + /* SrcGObjAt GFlag */ 0, + /* SrcGObjTg Se */ 0, + /* SrcGObjTg HitMark */ 0, + /* SrcGObjTg Spl */ 0, + /* SrcGObjTg Mtrl */ 0, + /* SrcGObjTg GFlag */ 0, + /* SrcGObjCo GFlag */ 0, + }, + // cM3dGCylS + { + /* Center */ 0.0f, 0.0f, 0.0f, + /* Radius */ 50.0f, + /* Height */ 100.0f, + }, +}; + +cXyz daObjMtest::Act_c::M_scl_mult[Type_Max] = { + cXyz(1.0f, 1.0f, 1.0f), + cXyz(1.0f, 0.5f, 1.0f), + cXyz(10.0f, 10.0f, 10.0f), + cXyz(10.0f, 5.0f, 10.0f), + cXyz(0.2f, 0.2f, 0.2f), + cXyz(0.2f, 0.2f, 0.2f), + cXyz(1.0f, 1.0f, 1.0f), + cXyz(40.0f, 1.0f, 40.0f), +}; /* 000000EC-00000198 .text chk_appear__Q210daObjMtest5Act_cFv */ -void daObjMtest::Act_c::chk_appear() { - /* Nonmatching */ +bool daObjMtest::Act_c::chk_appear() { + s32 swSave = prm_get_swSave(); + s32 arg0 = prm_get_arg0(); + if (arg0 == 0) { + return fopAcM_isSwitch(this, swSave) ? true : false; + } else if (arg0 == 1) { + return !fopAcM_isSwitch(this, swSave) ? true : false; + } else { + return true; + } } /* 00000198-00000284 .text CreateHeap__Q210daObjMtest5Act_cFv */ -void daObjMtest::Act_c::CreateHeap() { - /* Nonmatching */ +BOOL daObjMtest::Act_c::CreateHeap() { + static s16 bmd_data[Type_Max] = { + MTEST_BMD_MCUBE, + MTEST_BMD_MCYLN, + MTEST_BMD_MCUBE, + MTEST_BMD_MCYLN, + -1, + -1, + -1, + -1, + }; + + s16 bmdIdx = bmd_data[M_type]; + if (bmdIdx >= 0) { + J3DModelData* model_data = (J3DModelData*)dComIfG_getObjectRes(M_arcname[M_type], bmdIdx); + JUT_ASSERT(257, model_data != 0); + + mpModel = mDoExt_J3DModel__create(model_data, 0, 0x11020203); + return !!mpModel; + } else { + mpModel = NULL; + return TRUE; + } } /* 00000284-000003E8 .text Create__Q210daObjMtest5Act_cFv */ -s32 daObjMtest::Act_c::Create() { - /* Nonmatching */ +BOOL daObjMtest::Act_c::Create() { + fopAcM_SetMtx(this, mMtx); + init_mtx(); + + if (M_type == 4 || M_type == 5) { + fopAcM_setCullSizeBox(this, -3000.0f, -10.0f, -3000.0f, 3000.0f, 10.0f, 3000.0f); + } else if (M_type != 6) { + fopAcM_setCullSizeBox(this, -51.0f, -1.0f, -51.0f, 51.0f, 101.0f, 51.0f); + } + + if (M_type == 7) { + fopAcM_OnStatus(this, fopAcStts_NOCULLEXEC_e); + } + + if (prm_get_arg1() == 0) { + mStts.Init(0xFF, 0xFF, this); + mCyl.Set(M_cyl_src); + mCyl.SetStts(&mStts); + mCyl.SetTgVec((cXyz&)cXyz::Zero); + mCyl.OnTgNoHitMark(); + f32 scale = mScale.x < mScale.z ? mScale.x : mScale.z; + mCyl.SetR(scale * 50.0f); + mCyl.SetH(mScale.y * 100.0f); + } + + return TRUE; } /* 000003E8-00000708 .text Mthd_Create__Q210daObjMtest5Act_cFv */ -void daObjMtest::Act_c::Mthd_Create() { - /* Nonmatching */ +s32 daObjMtest::Act_c::Mthd_Create() { + static s16 dzb_data[5][Type_Max] = { + { + MTEST_DZB_MCUBE, + MTEST_DZB_MCYLN, + MTEST_DZB_MCUBE, + MTEST_DZB_MCYLN, + MTEST_DZB_MWTRSB, + MTEST_DZB_MYGNSB, + OWATER_DZB_OWATER, + ASTOP_DZB_ASLOW, + }, + { + MTEST_DZB_MCUBEHG, + MTEST_DZB_MCYLNHG, + MTEST_DZB_MCUBEHG, + MTEST_DZB_MCYLNHG, + MTEST_DZB_MWTRSB, + MTEST_DZB_MYGNSB, + OWATER_DZB_OWATER, + ASTOP_DZB_ASLOW00, + }, + { + MTEST_DZB_MCUBENC, + MTEST_DZB_MCYLNNC, + MTEST_DZB_MCUBENC, + MTEST_DZB_MCYLNNC, + MTEST_DZB_MWTRSB, + MTEST_DZB_MYGNSB, + OWATER_DZB_OWATER, + ASTOP_DZB_ASTOP, + }, + { + MTEST_DZB_MCUBELK, + MTEST_DZB_MCYLN, + MTEST_DZB_MCUBELK, + MTEST_DZB_MCYLN, + MTEST_DZB_MWTRSB, + MTEST_DZB_MYGNSB, + OWATER_DZB_OWATER, + ASTOP_DZB_ASTOP00, + }, + { + MTEST_DZB_MCUBE, + MTEST_DZB_MCYLN, + MTEST_DZB_MCUBE, + MTEST_DZB_MCYLN, + MTEST_DZB_MWTRSB, + MTEST_DZB_MYGNSB, + OWATER_DZB_OWATER, + ASTOP_DZB_A00, + }, + }; + static u32 heap_size[5][Type_Max] = { + { + 0x1620, + 0x20A0, + 0x1620, + 0x20A0, + 0x0200, + 0x0200, + 0x4000, + 0x4000, + }, + { + 0x1620, + 0x20A0, + 0x1620, + 0x20A0, + 0x0200, + 0x0200, + 0x4000, + 0x4000, + }, + { + 0x1620, + 0x20A0, + 0x1620, + 0x20A0, + 0x0200, + 0x0200, + 0x4000, + 0x4000, + }, + { + 0x1620, + 0x20A0, + 0x1620, + 0x20A0, + 0x0200, + 0x0200, + 0x4000, + 0x4000, + }, + { + 0x1620, + 0x20A0, + 0x1620, + 0x20A0, + 0x0200, + 0x0200, + 0x4000, + 0x4000, + }, + }; + + fopAcM_SetupActor(this, Act_c); + + M_type = prm_get_type(); + JUT_ASSERT(327, M_type < Type_Max); + + s32 phase_state = dComIfG_resLoad(&mPhs, M_arcname[M_type]); + if (phase_state == cPhs_COMPLEATE_e) { + s32 dzb_idx = 0; + if (prm_get_arg1() == 1) { + dzb_idx = 1; + } else if (prm_get_arg1() == 2) { + dzb_idx = 2; + } else if (prm_get_arg1() == 3) { + dzb_idx = 3; + } else if (prm_get_arg1() == 4) { + dzb_idx = 4; + } + + mbAppear = chk_appear(); + + cXyz& scl_mult = M_scl_mult[M_type]; + mScale.x *= scl_mult.x; + mScale.y *= scl_mult.y; + mScale.z *= scl_mult.z; + + phase_state = MoveBGCreate(M_arcname[M_type], dzb_data[dzb_idx][M_type], NULL, heap_size[dzb_idx][M_type]); + + JUT_ASSERT(451, (phase_state == cPhs_COMPLEATE_e) || (phase_state == cPhs_ERROR_e)); + + if (phase_state == cPhs_COMPLEATE_e) { + mpBgW->SetLock(); + if (mbAppear == 0) { + dComIfG_Bgsp()->Release(mpBgW); + } + } + } + + return phase_state; } /* 00000958-00000960 .text Delete__Q210daObjMtest5Act_cFv */ BOOL daObjMtest::Act_c::Delete() { - /* Nonmatching */ + return TRUE; } /* 00000960-000009B8 .text Mthd_Delete__Q210daObjMtest5Act_cFv */ -void daObjMtest::Act_c::Mthd_Delete() { - /* Nonmatching */ +BOOL daObjMtest::Act_c::Mthd_Delete() { + s32 result = MoveBGDelete(); + dComIfG_resDelete(&mPhs, M_arcname[M_type]); + return result; } /* 000009B8-00000A4C .text set_mtx__Q210daObjMtest5Act_cFv */ void daObjMtest::Act_c::set_mtx() { - /* Nonmatching */ + mDoMtx_stack_c::transS(current.pos); + mDoMtx_stack_c::ZXYrotM(shape_angle); + if (mpModel) { + mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); + } + mDoMtx_stack_c::scaleM(mScale); + mDoMtx_copy(mDoMtx_stack_c::get(), mMtx); } /* 00000A4C-00000A90 .text init_mtx__Q210daObjMtest5Act_cFv */ void daObjMtest::Act_c::init_mtx() { - /* Nonmatching */ + if (mpModel) { + mpModel->setBaseScale(mScale); + } + set_mtx(); } /* 00000A90-00000B80 .text Execute__Q210daObjMtest5Act_cFPPA3_A4_f */ -void daObjMtest::Act_c::Execute(float(**)[3][4]) { - /* Nonmatching */ +BOOL daObjMtest::Act_c::Execute(Mtx** pMtx) { + bool appear = chk_appear(); + + if (mCyl.ChkTgHit()) { + fopAcM_delete(this); + } else if (appear) { + if (!mbAppear) { + dComIfG_Bgsp()->Regist(mpBgW, this); + } + if (prm_get_arg1() == 0) { + mCyl.MoveCAtTg(current.pos); + dComIfG_Ccsp()->Set(&mCyl); + } + } else if (mbAppear) { + dComIfG_Bgsp()->Release(mpBgW); + } + + *pMtx = &mMtx; + mbAppear = appear; + return TRUE; } /* 00000B80-00000C64 .text Draw__Q210daObjMtest5Act_cFv */ BOOL daObjMtest::Act_c::Draw() { - /* Nonmatching */ + if (mbAppear && mpModel && prm_get_arg1() != 3 && prm_get_arg1() != 4) { + g_env_light.settingTevStruct(TEV_TYPE_BG0, ¤t.pos, &mTevStr); + g_env_light.setLightTevColorType(mpModel, &mTevStr); + dComIfGd_setListBG(); + mDoExt_modelUpdateDL(mpModel); + dComIfGd_setList(); + } + return TRUE; } + +namespace daObjMtest { + namespace { + s32 Mthd_Create(void* i_this) { + return ((Act_c*)i_this)->Mthd_Create(); + } + + BOOL Mthd_Delete(void* i_this) { + return ((Act_c*)i_this)->Mthd_Delete(); + } + + BOOL Mthd_Execute(void* i_this) { + return ((Act_c*)i_this)->MoveBGExecute(); + } + + BOOL Mthd_Draw(void* i_this) { + return ((Act_c*)i_this)->MoveBGDraw(); + } + + BOOL Mthd_IsDelete(void* i_this) { + return ((Act_c*)i_this)->MoveBGIsDelete(); + } + + static actor_method_class Mthd_Table = { + (process_method_func)Mthd_Create, + (process_method_func)Mthd_Delete, + (process_method_func)Mthd_Execute, + (process_method_func)Mthd_IsDelete, + (process_method_func)Mthd_Draw, + }; + } +} + +actor_process_profile_definition g_profile_Obj_Mtest = { + /* LayerID */ fpcLy_CURRENT_e, + /* ListID */ 3, + /* ListPrio */ fpcLy_CURRENT_e, + /* ProcName */ PROC_Obj_Mtest, + /* Proc SubMtd */ &g_fpcLf_Method.mBase, + /* Size */ sizeof(daObjMtest::Act_c), + /* SizeOther */ 0, + /* Parameters */ 0, + /* Leaf SubMtd */ &g_fopAc_Method.base, + /* Priority */ 0x002B, + /* Actor SubMtd */ &daObjMtest::Mthd_Table, + /* Status */ fopAcStts_CULL_e | fopAcStts_UNK40000_e, + /* Group */ fopAc_ACTOR_e, + /* CullType */ fopAc_CULLBOX_CUSTOM_e, +};