From e71b447a5f03fb92388e8e102201975367b18118 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Thu, 14 Sep 2023 23:51:30 -0400 Subject: [PATCH 1/3] d_a_kaji OK --- configure.py | 4 +- include/d/actor/d_a_obj_pirateship.h | 15 +++ include/m_Do/m_Do_ext.h | 20 +++- src/d/actor/d_a_kaji.cpp | 160 ++++++++++++++++++++++++--- src/d/actor/d_a_obj_pirateship.cpp | 2 +- 5 files changed, 180 insertions(+), 21 deletions(-) create mode 100644 include/d/actor/d_a_obj_pirateship.h diff --git a/configure.py b/configure.py index 61342968e..056d39bdc 100644 --- a/configure.py +++ b/configure.py @@ -417,7 +417,7 @@ def ActorRel(status, rel_name): ActorRel(NonMatching, "d_a_hot_floor"), ActorRel(NonMatching, "d_a_ikari"), ActorRel(NonMatching, "d_a_jbo"), - ActorRel(NonMatching, "d_a_kaji"), + ActorRel(Matching, "d_a_kaji"), ActorRel(NonMatching, "d_a_kanban"), ActorRel(NonMatching, "d_a_ki"), ActorRel(NonMatching, "d_a_knob00"), @@ -499,7 +499,7 @@ def ActorRel(status, rel_name): ActorRel(NonMatching, "d_a_tag_evsw"), ActorRel(NonMatching, "d_a_tag_ghostship"), ActorRel(NonMatching, "d_a_tag_hint"), - ActorRel(Matching, "d_a_tag_kb_item"), + ActorRel(Matching, "d_a_tag_kb_item"), ActorRel(NonMatching, "d_a_tag_kk1"), ActorRel(NonMatching, "d_a_tag_light"), ActorRel(NonMatching, "d_a_tag_msg"), diff --git a/include/d/actor/d_a_obj_pirateship.h b/include/d/actor/d_a_obj_pirateship.h new file mode 100644 index 000000000..bd60ef977 --- /dev/null +++ b/include/d/actor/d_a_obj_pirateship.h @@ -0,0 +1,15 @@ +#ifndef D_A_OBJ_PIRATESHIP_H +#define D_A_OBJ_PIRATESHIP_H + +#include "f_op/f_op_actor_mng.h" + +namespace daObjPirateship { + class Act_c : public fopAc_ac_c { + public: + /* 0x290 */ u8 temp[0x2CC - 0x290]; + /* 0x2CC */ u8 unk2CC; + /* 0x2D0 */ J3DModel* mpModel; + }; +} + +#endif /* D_A_OBJ_PIRATESHIP_H */ diff --git a/include/m_Do/m_Do_ext.h b/include/m_Do/m_Do_ext.h index 133d2f317..6da1b8c98 100644 --- a/include/m_Do/m_Do_ext.h +++ b/include/m_Do/m_Do_ext.h @@ -233,7 +233,19 @@ class mDoExt_McaMorfCallBack2_c { class JAIAnimeSound; -class mDoExt_McaMorf /* : public J3DMtxCalcMaya */ { +class J3DMtxCalcBasic { // Placeholder to fix mDoExt_McaMorf inheritance +public: + virtual ~J3DMtxCalcBasic(); +}; + +class J3DMtxCalcMaya : virtual J3DMtxCalcBasic { // Placeholder to fix mDoExt_McaMorf inheritance +public: + virtual ~J3DMtxCalcMaya(); + + u8 pad[0x48]; +}; + +class mDoExt_McaMorf : public J3DMtxCalcMaya { public: mDoExt_McaMorf(J3DModelData*, mDoExt_McaMorfCallBack1_c*, mDoExt_McaMorfCallBack2_c*, J3DAnmTransform*, int, float, int, int, int, void*, unsigned long, unsigned long); virtual ~mDoExt_McaMorf(); @@ -241,11 +253,11 @@ class mDoExt_McaMorf /* : public J3DMtxCalcMaya */ { void setAnm(J3DAnmTransform*, int, f32, f32, f32, f32, void*); J3DModel* getModel() { return mpModel; } void setFrame(f32 frame) { mFrameCtrl.setFrame(frame); } + void update(); void updateDL(); - void play(Vec *, u32, u8); + void play(Vec *, u32, s8); void stopZelAnime(); - u8 pad[0x4C]; // J3DMtxCalcMaya /* 0x50 */ J3DModel* mpModel; /* 0x54 */ J3DAnmTransform* mpAnm; /* 0x58 */ J3DFrameCtrl mFrameCtrl; @@ -257,6 +269,8 @@ class mDoExt_McaMorf /* : public J3DMtxCalcMaya */ { /* 0x80 */ JAIAnimeSound * mpSound; /* 0x84 */ mDoExt_McaMorfCallBack1_c * mpCallBack1; /* 0x88 */ mDoExt_McaMorfCallBack2_c * mpCallBack2; + /* 0x8C */ /* virtual inheritance */ + /* 0x94 */ u8 pad2[0xB4 - 0x94]; }; class mDoExt_3DlineMat_c { diff --git a/src/d/actor/d_a_kaji.cpp b/src/d/actor/d_a_kaji.cpp index d3f850ee1..4b8355994 100644 --- a/src/d/actor/d_a_kaji.cpp +++ b/src/d/actor/d_a_kaji.cpp @@ -3,41 +3,171 @@ // Translation Unit: d_a_kaji.cpp // -#include "d_a_kaji.h" +#include "f_op/f_op_actor_mng.h" +#include "JSystem/JKernel/JKRHeap.h" +#include "JSystem/JUtility/JUTAssert.h" +#include "m_Do/m_Do_mtx.h" +#include "d/d_com_inf_game.h" +#include "d/d_s_play.h" +#include "d/actor/d_a_obj_pirateship.h" +#include "d/d_procname.h" #include "dolphin/types.h" +extern dScnPly_reg_HIO_c g_regHIO; + +struct daKaji_c : fopAc_ac_c { +public: + s32 CreateHeap(); + inline s32 _create(); + inline s32 _delete(); + inline s32 _execute(); + inline bool _draw(); + +public: + /* 0x290 */ request_of_phase_process_class mPhs; + /* 0x298 */ u8 pad[0x29C - 0x298]; + /* 0x29C */ mDoExt_McaMorf* mpMorf; + /* 0x2A0 */ Mtx mMtx; + + static const char M_arcname[]; +}; + +static daObjPirateship::Act_c* l_p_ship; + +const char daKaji_c::M_arcname[] = "Kaji"; + /* 00000078-00000098 .text CheckCreateHeap__FP10fopAc_ac_c */ -void CheckCreateHeap(fopAc_ac_c*) { - /* Nonmatching */ +static s32 CheckCreateHeap(fopAc_ac_c* i_this) { + return ((daKaji_c*)i_this)->CreateHeap(); } /* 00000098-000001F4 .text CreateHeap__8daKaji_cFv */ -void daKaji_c::CreateHeap() { - /* Nonmatching */ +s32 daKaji_c::CreateHeap() { + J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes(M_arcname, 0x11); // asoda.bdl + JUT_ASSERT(0x55, modelData != 0); + + mpMorf = new mDoExt_McaMorf( + modelData, + NULL, NULL, + (J3DAnmTransformKey*)dComIfG_getObjectRes("Kaji", 0xE), // kj_wait.bck + 2, 0.0f, 0, -1, 1, + dComIfG_getObjectRes("Kaji", 0x8), // kj_wait.bas + 0x00080000, + 0x11000002 + ); + + return mpMorf && mpMorf->getModel(); +} + +s32 daKaji_c::_create() { + fopAcM_SetupActor(this, daKaji_c); + + s32 phase_state = dComIfG_resLoad(&mPhs, M_arcname); + if (phase_state == cPhs_COMPLEATE_e) { + if (fopAcM_entrySolidHeap(this, (heapCallbackFunc)&CheckCreateHeap, 0x660)) { + mDoMtx_stack_c::transS(getPosition()); + mDoMtx_stack_c::YrotM(shape_angle.y); + mDoMtx_stack_c::scaleM(mScale.x, mScale.y, mScale.z); + MTXCopy(mDoMtx_stack_c::get(), mMtx); + + l_p_ship = (daObjPirateship::Act_c*)fopAcM_SearchByID(mParentPcId); + } else { + return cPhs_ERROR_e; + } + + fopAcM_SetMtx(this, mpMorf->getModel()->getBaseTRMtx()); + fopAcM_setCullSizeBox(this, -80.0f, -80.0f, -20.0f, 80.0f, 80.0f, 20.0f); + + MTXCopy(mpMorf->getModel()->getBaseTRMtx(), mMtx); + } + + return phase_state; +} + +s32 daKaji_c::_delete() { + dComIfG_resDelete(&mPhs, M_arcname); + return 1; +} + +s32 daKaji_c::_execute() { + // Copy the ship's transform (plus an offset) to the helm. + cXyz* offset = &cXyz(0.0f, 740.0f, -858.0f); + offset->y += g_regHIO.mChild[10].mFloatRegs[10]; + offset->z += g_regHIO.mChild[10].mFloatRegs[11]; + cMtx_multVec( l_p_ship->mpModel->getBaseTRMtx(), offset, ¤t.pos); + + daObjPirateship::Act_c* ship = l_p_ship; + shape_angle = ship->shape_angle; + current.angle = shape_angle; + + mpMorf->play(NULL, 0, 0); + + mpMorf->getModel()->setBaseScale(mScale); + PSMTXTrans(mDoMtx_stack_c::get(), current.pos.x, current.pos.y, current.pos.z); + mDoMtx_stack_c::ZXYrotM(shape_angle.x, shape_angle.y, shape_angle.z); + + mpMorf->getModel()->i_setBaseTRMtx(mDoMtx_stack_c::get()); + MTXCopy(mDoMtx_stack_c::get(), mMtx); + + return 0; +} + +bool daKaji_c::_draw() { + if (!l_p_ship->unk2CC) { + return 1; + } + g_env_light.settingTevStruct(TEV_TYPE_ACTOR, ¤t.pos, &mTevStr); + g_env_light.setLightTevColorType(mpMorf->getModel(), &mTevStr); + mpMorf->update(); + return 1; } /* 000001F4-00000344 .text daKajiCreate__FPv */ -void daKajiCreate(void*) { - /* Nonmatching */ +static s32 daKajiCreate(void* i_this) { + return ((daKaji_c*)i_this)->_create(); } /* 00000344-00000374 .text daKajiDelete__FPv */ -void daKajiDelete(void*) { - /* Nonmatching */ +static s32 daKajiDelete(void* i_this) { + return ((daKaji_c*)i_this)->_delete(); } /* 00000374-000004D4 .text daKajiExecute__FPv */ -void daKajiExecute(void*) { - /* Nonmatching */ +static s32 daKajiExecute(void* i_this) { + return ((daKaji_c*)i_this)->_execute(); } /* 000004D4-00000568 .text daKajiDraw__FPv */ -void daKajiDraw(void*) { - /* Nonmatching */ +static s32 daKajiDraw(void* i_this) { + return ((daKaji_c*)i_this)->_draw(); } /* 00000568-00000570 .text daKajiIsDelete__FPv */ -void daKajiIsDelete(void*) { - /* Nonmatching */ +static s32 daKajiIsDelete(void* actor) { + return 1; } +static actor_method_class daKajiMethodTable = { + (process_method_func)daKajiCreate, + (process_method_func)daKajiDelete, + (process_method_func)daKajiExecute, + (process_method_func)daKajiIsDelete, + (process_method_func)daKajiDraw, +}; + +extern actor_process_profile_definition g_profile_Kaji = { + fpcLy_CURRENT_e, + 3, + fpcLy_CURRENT_e, + PROC_Kaji, + &g_fpcLf_Method.mBase, + sizeof(daKaji_c), + 0, + 0, + &g_fopAc_Method.base, + 0x01AC, + &daKajiMethodTable, + 0x00040100, + fopAc_ACTOR_e, + fopAc_CULLBOX_CUSTOM_e, +}; diff --git a/src/d/actor/d_a_obj_pirateship.cpp b/src/d/actor/d_a_obj_pirateship.cpp index 5c381a31d..7e0dac199 100644 --- a/src/d/actor/d_a_obj_pirateship.cpp +++ b/src/d/actor/d_a_obj_pirateship.cpp @@ -3,7 +3,7 @@ // Translation Unit: d_a_obj_pirateship.cpp // -#include "d_a_obj_pirateship.h" +#include "d/actor/d_a_obj_pirateship.h" #include "dolphin/types.h" /* 000000EC-000000FC .text ride_call_back__FP4dBgWP10fopAc_ac_cP10fopAc_ac_c */ From 160fe267c49d41b9a2200b144bd8a90ec487298c Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Fri, 15 Sep 2023 00:08:27 -0400 Subject: [PATCH 2/3] Fix return types --- src/d/actor/d_a_kaji.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/d/actor/d_a_kaji.cpp b/src/d/actor/d_a_kaji.cpp index 4b8355994..438d6c528 100644 --- a/src/d/actor/d_a_kaji.cpp +++ b/src/d/actor/d_a_kaji.cpp @@ -17,10 +17,10 @@ extern dScnPly_reg_HIO_c g_regHIO; struct daKaji_c : fopAc_ac_c { public: - s32 CreateHeap(); + BOOL CreateHeap(); inline s32 _create(); - inline s32 _delete(); - inline s32 _execute(); + inline BOOL _delete(); + inline BOOL _execute(); inline bool _draw(); public: @@ -37,12 +37,12 @@ static daObjPirateship::Act_c* l_p_ship; const char daKaji_c::M_arcname[] = "Kaji"; /* 00000078-00000098 .text CheckCreateHeap__FP10fopAc_ac_c */ -static s32 CheckCreateHeap(fopAc_ac_c* i_this) { +static BOOL CheckCreateHeap(fopAc_ac_c* i_this) { return ((daKaji_c*)i_this)->CreateHeap(); } /* 00000098-000001F4 .text CreateHeap__8daKaji_cFv */ -s32 daKaji_c::CreateHeap() { +BOOL daKaji_c::CreateHeap() { J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes(M_arcname, 0x11); // asoda.bdl JUT_ASSERT(0x55, modelData != 0); @@ -84,12 +84,12 @@ s32 daKaji_c::_create() { return phase_state; } -s32 daKaji_c::_delete() { +BOOL daKaji_c::_delete() { dComIfG_resDelete(&mPhs, M_arcname); - return 1; + return TRUE; } -s32 daKaji_c::_execute() { +BOOL daKaji_c::_execute() { // Copy the ship's transform (plus an offset) to the helm. cXyz* offset = &cXyz(0.0f, 740.0f, -858.0f); offset->y += g_regHIO.mChild[10].mFloatRegs[10]; @@ -109,17 +109,17 @@ s32 daKaji_c::_execute() { mpMorf->getModel()->i_setBaseTRMtx(mDoMtx_stack_c::get()); MTXCopy(mDoMtx_stack_c::get(), mMtx); - return 0; + return FALSE; } bool daKaji_c::_draw() { if (!l_p_ship->unk2CC) { - return 1; + return TRUE; } g_env_light.settingTevStruct(TEV_TYPE_ACTOR, ¤t.pos, &mTevStr); g_env_light.setLightTevColorType(mpMorf->getModel(), &mTevStr); mpMorf->update(); - return 1; + return TRUE; } /* 000001F4-00000344 .text daKajiCreate__FPv */ @@ -128,23 +128,23 @@ static s32 daKajiCreate(void* i_this) { } /* 00000344-00000374 .text daKajiDelete__FPv */ -static s32 daKajiDelete(void* i_this) { +static BOOL daKajiDelete(void* i_this) { return ((daKaji_c*)i_this)->_delete(); } /* 00000374-000004D4 .text daKajiExecute__FPv */ -static s32 daKajiExecute(void* i_this) { +static BOOL daKajiExecute(void* i_this) { return ((daKaji_c*)i_this)->_execute(); } /* 000004D4-00000568 .text daKajiDraw__FPv */ -static s32 daKajiDraw(void* i_this) { +static BOOL daKajiDraw(void* i_this) { return ((daKaji_c*)i_this)->_draw(); } /* 00000568-00000570 .text daKajiIsDelete__FPv */ -static s32 daKajiIsDelete(void* actor) { - return 1; +static BOOL daKajiIsDelete(void* actor) { + return TRUE; } static actor_method_class daKajiMethodTable = { From b35558cf32da145edef845ebf7a58626b45d85a5 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Fri, 15 Sep 2023 00:10:09 -0400 Subject: [PATCH 3/3] Whoops, wrong bool for one --- src/d/actor/d_a_kaji.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d/actor/d_a_kaji.cpp b/src/d/actor/d_a_kaji.cpp index 438d6c528..c420f407e 100644 --- a/src/d/actor/d_a_kaji.cpp +++ b/src/d/actor/d_a_kaji.cpp @@ -114,12 +114,12 @@ BOOL daKaji_c::_execute() { bool daKaji_c::_draw() { if (!l_p_ship->unk2CC) { - return TRUE; + return true; } g_env_light.settingTevStruct(TEV_TYPE_ACTOR, ¤t.pos, &mTevStr); g_env_light.setLightTevColorType(mpMorf->getModel(), &mTevStr); mpMorf->update(); - return TRUE; + return true; } /* 000001F4-00000344 .text daKajiCreate__FPv */