diff --git a/configure.py b/configure.py index 642309aac..c3d73f8a1 100755 --- a/configure.py +++ b/configure.py @@ -1417,7 +1417,7 @@ config.libs = [ ActorRel(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d_a_obj_monument"), ActorRel(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d_a_obj_movebox", extra_cflags=['-pragma "nosyminline on"']), ActorRel(NonMatching, "d_a_obj_mshokki"), - ActorRel(NonMatching, "d_a_obj_ohatch"), + ActorRel(Matching, "d_a_obj_ohatch"), ActorRel(NonMatching, "d_a_obj_otble"), ActorRel(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d_a_obj_pbco"), ActorRel(NonMatching, "d_a_obj_pirateship"), diff --git a/include/d/actor/d_a_obj_ohatch.h b/include/d/actor/d_a_obj_ohatch.h index ba53fc305..a8d1b2cf5 100644 --- a/include/d/actor/d_a_obj_ohatch.h +++ b/include/d/actor/d_a_obj_ohatch.h @@ -2,15 +2,25 @@ #define D_A_OBJ_OHATCH_H #include "f_op/f_op_actor.h" +#include "d/d_a_obj.h" + +class dBgW; class daObjOhatch_c : public fopAc_ac_c { + typedef void (daObjOhatch_c::*ActionFunc)(); + + enum Param_e { + PRM_SWSAVE_W = 8, + PRM_SWSAVE_S = 0, + }; + public: - void param_get_swSave() const {} + s32 param_get_swSave() const { return daObj::PrmAbstract(this, PRM_SWSAVE_W, PRM_SWSAVE_S); } void set_mtx(); void init_mtx(); - void solidHeapCB(fopAc_ac_c*); - void create_heap(); + static BOOL solidHeapCB(fopAc_ac_c*); + bool create_heap(); cPhs_State _create(); bool _delete(); void close_wait_act_proc(); @@ -22,7 +32,18 @@ public: bool _draw(); public: - /* Place member variables here */ -}; + /* 0x290 */ request_of_phase_process_class mPhase; + /* 0x298 */ J3DModel* mModel; + /* 0x29C */ s32 m29C; + /* 0x2A0 */ dBgW* mBgW1; + /* 0x2A4 */ dBgW* mBgW2; + /* 0x2A8 */ Mtx m2A8; + /* 0x2D8 */ s16 m2D8; + /* 0x2DC */ ActionFunc mActionFunc; + /* 0x2E8 */ f32 m2E8; + /* 0x2EC */ s32 m2EC; + /* 0x2F0 */ s16 m2F0; + /* 0x2F2 */ s16 m2F2; +}; // size = 0x2F4 #endif /* D_A_OBJ_OHATCH_H */ diff --git a/include/m_Do/m_Do_hostIO.h b/include/m_Do/m_Do_hostIO.h index 40ff71882..b9660b4ee 100644 --- a/include/m_Do/m_Do_hostIO.h +++ b/include/m_Do/m_Do_hostIO.h @@ -12,6 +12,12 @@ class JORGenEvent; class JOREvent; class JORServer; +#if VERSION == VERSION_DEMO +#define HIO(name) l_HIO.##name +#else +#define HIO(name) L_HIO::##name +#endif + class JORMContext { public: void genCheckBox(const char* param_1, u8* param_2, u8 param_3, u32 param_4, JOREventListener* param_5, u16 param_6, u16 param_7, u16 param_8, u16 param_9) { diff --git a/src/d/actor/d_a_obj_ohatch.cpp b/src/d/actor/d_a_obj_ohatch.cpp index 39eb3726d..89c2dd176 100644 --- a/src/d/actor/d_a_obj_ohatch.cpp +++ b/src/d/actor/d_a_obj_ohatch.cpp @@ -4,72 +4,319 @@ */ #include "d/actor/d_a_obj_ohatch.h" +#include "d/res/res_ohatch.h" #include "d/d_procname.h" +#include "d/d_bg_w.h" #include "d/d_priority.h" +#include "d/d_com_inf_game.h" +#include "f_op/f_op_actor_mng.h" +#include "m_Do/m_Do_hostIO.h" + +namespace { +static const char l_arcname[] = "Ohatch"; +} + +#if VERSION == VERSION_DEMO +class daObjOhatch_HIO_c : public JORReflexible { +public: + daObjOhatch_HIO_c(); + virtual ~daObjOhatch_HIO_c() {} + + void genMessage(JORMContext*); + +public: + /* 0x04 */ s8 mNo; + /* 0x08 */ f32 m08; + /* 0x0C */ f32 m0C; + /* 0x10 */ f32 m10; + /* 0x14 */ f32 m14; + /* 0x18 */ f32 m18; + /* 0x1C */ f32 m1C; + /* 0x20 */ f32 m20; + /* 0x24 */ f32 m24; + /* 0x28 */ f32 m28; + /* 0x2C */ f32 m2C; + /* 0x30 */ f32 m30; + /* 0x34 */ f32 m34; + /* 0x38 */ u8 m38; +}; // size = 0x40 + +static daObjOhatch_HIO_c l_HIO; + +daObjOhatch_HIO_c::daObjOhatch_HIO_c() { + mNo = -1; + m08 = -4096.0f; + m0C = -16384.0f; + m10 = 0.0f; + m14 = -25.0f; + m18 = 190.0f; + m1C = 1.0f; + m20 = 8192.0f; + m24 = 131072.0f; + m28 = 6.0f; + m2C = -64.0f; + m30 = 1024.0f; + m34 = 8192.0f; + m38 = 0; +} +#else +namespace L_HIO { +static const f32 m08 = -4096.0f; +static const f32 m0C = -16384.0f; +static const f32 m10 = 0.0f; +static const f32 m14 = -25.0f; +static const f32 m18 = 190.0f; +static const f32 m1C = 1.0f; +static const f32 m20 = 8192.0f; +static const f32 m24 = 131072.0f; +static const f32 m28 = 6.0f; +static const f32 m2C = -64.0f; +static const f32 m30 = 1024.0f; +static const f32 m34 = 8192.0f; +static const u8 m38 = 0; +} // namespace L_HIO +#endif /* 00000078-0000018C .text set_mtx__13daObjOhatch_cFv */ void daObjOhatch_c::set_mtx() { - /* Nonmatching */ + s16 tmp = m2D8 + (s32)(m2F0 * cM_ssin(m2F2)); + + mDoMtx_stack_c::transS(current.pos.x, current.pos.y + m2E8, current.pos.z); + mDoMtx_stack_c::XYZrotM(shape_angle); + mDoMtx_stack_c::transM(0.0f, -HIO(m14), -HIO(m18)); + mDoMtx_stack_c::XrotM(tmp); + mDoMtx_stack_c::transM(0.0f, HIO(m14), HIO(m18)); + mModel->setBaseTRMtx(mDoMtx_stack_c::get()); } /* 0000018C-0000027C .text init_mtx__13daObjOhatch_cFv */ void daObjOhatch_c::init_mtx() { - /* Nonmatching */ + mModel->setBaseScale(scale); + mDoMtx_stack_c::transS(current.pos); + mDoMtx_stack_c::XYZrotM(shape_angle); + mDoMtx_stack_c::push(); + mDoMtx_stack_c::transM(0.0f, 25.0f, -190.0f); + mDoMtx_stack_c::XrotM(m2D8); + mDoMtx_stack_c::transM(0.0f, -25.0f, 190.0f); + mModel->setBaseTRMtx(mDoMtx_stack_c::get()); + mDoMtx_stack_c::pop(); + mDoMtx_stack_c::scaleM(scale); + cMtx_copy(mDoMtx_stack_c::get(), m2A8); } /* 0000027C-000002A0 .text solidHeapCB__13daObjOhatch_cFP10fopAc_ac_c */ -void daObjOhatch_c::solidHeapCB(fopAc_ac_c*) { - /* Nonmatching */ +BOOL daObjOhatch_c::solidHeapCB(fopAc_ac_c* a_this) { + return ((daObjOhatch_c*)a_this)->create_heap(); } /* 000002A0-000003CC .text create_heap__13daObjOhatch_cFv */ -void daObjOhatch_c::create_heap() { - /* Nonmatching */ +bool daObjOhatch_c::create_heap() { + bool uVar5 = true; + J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes(l_arcname, OHATCH_BDL_OHATCH); + if (modelData == NULL) { + JUT_ASSERT(DEMO_SELECT(308, 311), FALSE); + uVar5 = false; + } else { + mModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000022); + mBgW1 = dBgW_NewSet((cBgD_t*)dComIfG_getObjectRes(l_arcname, OHATCH_DZB_OH_CLS), cBgW::MOVE_BG_e, &m2A8); + mBgW2 = dBgW_NewSet((cBgD_t*)dComIfG_getObjectRes(l_arcname, OHATCH_DZB_OH_OPN), cBgW::MOVE_BG_e, &m2A8); + if (mModel == NULL || mBgW1 == NULL || mBgW2 == NULL) { + uVar5 = false; + } + } + return uVar5; } /* 000003CC-00000548 .text _create__13daObjOhatch_cFv */ cPhs_State daObjOhatch_c::_create() { - /* Nonmatching */ + fopAcM_SetupActor(this, daObjOhatch_c); + cPhs_State ret = dComIfG_resLoad(&mPhase, l_arcname); + if (ret == cPhs_COMPLEATE_e) { + if (fopAcM_entrySolidHeap(this, solidHeapCB, 0xB90)) { + fopAcM_SetMtx(this, mModel->getBaseTRMtx()); + m29C = param_get_swSave(); + if (m29C != 0xff && fopAcM_isSwitch(this, m29C) == TRUE) { + m2D8 = -0x4000; + mActionFunc = &daObjOhatch_c::open_wait_act_proc; + if (dComIfG_Bgsp()->Regist(mBgW2, this)) { + ret = cPhs_ERROR_e; + } + } else { + mActionFunc = &daObjOhatch_c::close_wait_act_proc; + if (dComIfG_Bgsp()->Regist(mBgW1, this)) { + ret = cPhs_ERROR_e; + } + } + init_mtx(); + } else { + ret = cPhs_ERROR_e; + } + } + +#if VERSION == VERSION_DEMO + if (l_HIO.mNo < 0) { + l_HIO.mNo = mDoHIO_createChild("フィギュア屋の入口", &l_HIO); + } +#endif + return ret; } /* 00000548-00000628 .text _delete__13daObjOhatch_cFv */ bool daObjOhatch_c::_delete() { - /* Nonmatching */ + dComIfG_resDelete(&mPhase, l_arcname); +#if VERSION > VERSION_DEMO + if (heap != NULL) +#endif + { + if (mBgW1 != NULL) { + if (mBgW1->ChkUsed()) { + dComIfG_Bgsp()->Release(mBgW1); + } +#if VERSION > VERSION_DEMO + mBgW1 = NULL; +#endif + } + + if (mBgW2 != NULL) { + if (mBgW2->ChkUsed()) { + dComIfG_Bgsp()->Release(mBgW2); + } +#if VERSION > VERSION_DEMO + mBgW2 = NULL; +#endif + } + } + +#if VERSION == VERSION_DEMO + if (l_HIO.mNo >= 0) { + mDoHIO_deleteChild(l_HIO.mNo); + l_HIO.mNo = -1; + } +#endif + return true; } /* 00000628-00000810 .text close_wait_act_proc__13daObjOhatch_cFv */ void daObjOhatch_c::close_wait_act_proc() { - /* Nonmatching */ + if (m29C != 0xff && fopAcM_isSwitch(this, m29C) == TRUE) { + if (dComIfGp_evmng_existence("FIGURE_HATCH_OPEN")) { + s32 staffIdx = dComIfGp_evmng_getMyStaffId("Ohatch"); + if (staffIdx != -1) { + if (strcmp(dComIfGp_getPEvtManager()->getMyNowCutName(staffIdx), "OPEN") == 0) { + fopAcM_seStartCurrent(this, JA_SE_OBJ_FIG_HATCH_OPEN, 0); + if (mBgW1 != NULL && mBgW1->ChkUsed()) { + dComIfG_Bgsp()->Release(mBgW1); + } + if (mBgW2 != NULL && !mBgW2->ChkUsed()) { + dComIfG_Bgsp()->Regist(mBgW2, this); + } + + dComIfGp_getVibration().StartShock(3, 1, cXyz(0.0f, 1.0f, 0.0f)); + mActionFunc = &daObjOhatch_c::tremor_act_proc; + } + } + } + } else if (HIO(m38) == 1) { + fopAcM_seStartCurrent(this, JA_SE_OBJ_FIG_HATCH_OPEN, 0); + if (mBgW1 != NULL && mBgW1->ChkUsed()) { + dComIfG_Bgsp()->Release(mBgW1); + } + if (mBgW2 != NULL && !mBgW2->ChkUsed()) { + dComIfG_Bgsp()->Regist(mBgW2, this); + } + dComIfGp_getVibration().StartShock(3, 1, cXyz(0.0f, 1.0f, 0.0f)); + mActionFunc = &daObjOhatch_c::tremor_act_proc; + } } /* 00000810-000008A4 .text tremor_act_proc__13daObjOhatch_cFv */ void daObjOhatch_c::tremor_act_proc() { - /* Nonmatching */ + m2EC += (s32)HIO(m20); + if (m2EC > (s32)HIO(m24)) { + m2E8 = 0.0f; + mActionFunc = &daObjOhatch_c::open_act_proc; + } else { + f32 fVar1 = cM_ssin(m2EC); + if (fVar1 < 0.0f) { + fVar1 *= -1.0f; + } + m2E8 = fVar1 * HIO(m28); + } } /* 000008A4-00000A00 .text open_act_proc__13daObjOhatch_cFv */ void daObjOhatch_c::open_act_proc() { - /* Nonmatching */ +#if VERSION == VERSION_DEMO + f32 uVar3 = (cM_ssin(m2D8 / HIO(m0C) * 32768.0f) + HIO(m1C)) / (HIO(m1C) + 1.0f); + s32 uVar2 = HIO(m08) * uVar3; +#else + f32 sin = m2D8 / HIO(m0C) * 32768.0f; + s32 uVar2 = (cM_ssin(sin) + HIO(m1C)) / (HIO(m1C) + 1.0f) * HIO(m08); +#endif + m2D8 += uVar2; + + if (m2D8 <= (s16)HIO(m0C)) { + m2D8 = (s16)HIO(m0C); + mDoAud_seStart(JA_SE_READ_RIDDLE_1); + m2F0 = (s16)HIO(m30); + dComIfGp_getVibration().StartShock(6, 1, cXyz(0.0f, 1.0f, 0.0f)); + mActionFunc = &daObjOhatch_c::vibrate_act_proc; + } } /* 00000A00-00000A4C .text vibrate_act_proc__13daObjOhatch_cFv */ void daObjOhatch_c::vibrate_act_proc() { - /* Nonmatching */ + m2F0 += (s32)HIO(m2C); + if (m2F0 < 0) { + mActionFunc = &daObjOhatch_c::open_wait_act_proc; + } else { + m2F2 += (s32)HIO(m34); + } } /* 00000A4C-00000A50 .text open_wait_act_proc__13daObjOhatch_cFv */ void daObjOhatch_c::open_wait_act_proc() { - /* Nonmatching */ +#if VERSION == VERSION_DEMO + if ((m29C == 0xff || fopAcM_isSwitch(this, m29C) != TRUE) && HIO(m38) == 0) { + m2D8 = 0; + m2E8 = 0.0f; + m2EC = 0; + m2F2 = 0; + m2F0 = 0; + if (mBgW2 != NULL && mBgW2->ChkUsed()) { + dComIfG_Bgsp()->Release(mBgW2); + } + + if (mBgW1 != NULL && !mBgW1->ChkUsed()) { + dComIfG_Bgsp()->Regist(mBgW1, this); + } + + mActionFunc = &daObjOhatch_c::close_wait_act_proc; + } +#endif } /* 00000A50-00000B04 .text _execute__13daObjOhatch_cFv */ bool daObjOhatch_c::_execute() { - /* Nonmatching */ + if (mBgW1 != NULL && mBgW1->ChkUsed()) { + mBgW1->Move(); + } + + if (mBgW2 != NULL && mBgW2->ChkUsed()) { + mBgW2->Move(); + } + + set_mtx(); + (this->*mActionFunc)(); + return true; } /* 00000B04-00000B64 .text _draw__13daObjOhatch_cFv */ bool daObjOhatch_c::_draw() { - /* Nonmatching */ + g_env_light.settingTevStruct(TEV_TYPE_BG0, ¤t.pos, &tevStr); + g_env_light.setLightTevColorType(mModel, &tevStr); + mDoExt_modelUpdateDL(mModel); + return true; } /* 00000B64-00000B84 .text daObjOhatch_Create__FP10fopAc_ac_c */