diff --git a/configure.py b/configure.py index 36972f469..111c94620 100755 --- a/configure.py +++ b/configure.py @@ -1715,7 +1715,7 @@ config.libs = [ ActorRel(NonMatching, "d_a_salvage_tbox"), ActorRel(Matching, "d_a_scene_change"), ActorRel(Matching, "d_a_shutter", extra_cflags=['-pragma "nosyminline on"']), - ActorRel(NonMatching, "d_a_shutter2"), + ActorRel(Matching, "d_a_shutter2"), ActorRel(NonMatching, "d_a_st"), ActorRel(Matching, "d_a_steam_tag", extra_cflags=['-pragma "nosyminline on"']), ActorRel(Matching, "d_a_swattack", extra_cflags=['-pragma "nosyminline on"']), diff --git a/include/d/actor/d_a_shutter2.h b/include/d/actor/d_a_shutter2.h index eec0c37a5..eb8bb6dc6 100644 --- a/include/d/actor/d_a_shutter2.h +++ b/include/d/actor/d_a_shutter2.h @@ -1,22 +1,54 @@ #ifndef D_A_SHUTTER2_H #define D_A_SHUTTER2_H -#include "f_op/f_op_actor.h" +#include "d/d_bg_s_movebg_actor.h" -class daShutter2_c : public fopAc_ac_c { +class daShutter2_c : public dBgS_MoveBgActor { public: BOOL Delete(); - void CreateHeap(); - s32 Create(); + int CreateHeap(); + int Create(); s32 _create(); void set_mtx(); - void Execute(float(**)[3][4]); + int Execute(Mtx**); void shutter_move(); void demo(); BOOL Draw(); + /* 0x00 */ static const float m_max_speed[1]; + /* 0x04 */ static const float m_min_speed[1]; + /* 0x08 */ static const float m_move_len[1]; + /* 0x0C */ static const float m_width[1]; + /* 0x10 */ static const float m_height[1]; + /* 0x14 */ static const s16 m_bdlidx[1]; + /* 0x16 */ static const s16 m_dzbidx[1]; + /* 0x18 */ static const s32 m_heapsize[1]; + /* 0x1C */ static const Vec m_cull_min[1]; + /* 0x28 */ static const Vec m_cull_max[1]; + + static char* m_arcname[1]; + static char* m_open_ev_name[1]; + static char* m_close_ev_name[1]; + static char* m_staff_name[1]; + public: - /* Place member variables here */ + /* 0x2C8 */ request_of_phase_process_class mPhs; + /* 0x2D0 */ J3DModel* mpModel; + /* 0x2D4 */ Mtx mMtx; + /* 0x304 */ s32 mActionIndex; + /* 0x308 */ s32 mSwitchNo; + /* 0x30C */ s32 m30C; + /* 0x310 */ s32 mStaffId; + /* 0x314 */ s16 mOpenEventIdx; + /* 0x316 */ s16 mCloseEventIdx; + /* 0x318 */ u8 m318; + /* 0x319 */ u8 mType; + /* 0x31A */ u8 mbIsSwitch; + /* 0x31B */ u8 mbIsNearEnemy; }; +namespace daShutter2_prm { + inline u8 getSwitchNo(daShutter2_c* item) { return (fopAcM_GetParam(item) >> 0) & 0xFF; } +} + #endif /* D_A_SHUTTER2_H */ diff --git a/src/d/actor/d_a_shutter2.cpp b/src/d/actor/d_a_shutter2.cpp index 127c7b13a..8b8bf223b 100644 --- a/src/d/actor/d_a_shutter2.cpp +++ b/src/d/actor/d_a_shutter2.cpp @@ -5,75 +5,226 @@ #include "d/actor/d_a_shutter2.h" #include "d/d_procname.h" +#include "d/d_com_inf_game.h" +#include "d/d_bg_s_movebg_actor.h" +#include "d/res/res_htobi3.h" + +const float daShutter2_c::m_max_speed[1] = {3.0f}; +const float daShutter2_c::m_min_speed[1] = {1.0f}; +const float daShutter2_c::m_move_len[1] = {350.0f}; +const float daShutter2_c::m_width[1] = {500.0f}; +const float daShutter2_c::m_height[1] = {400.0f}; +const s16 daShutter2_c::m_bdlidx[1] = {HTOBI3_BDL_HTOBI3}; +const s16 daShutter2_c::m_dzbidx[1] = {HTOBI3_DZB_HTOBI3}; +const s32 daShutter2_c::m_heapsize[1] = {0x0C00}; +const Vec daShutter2_c::m_cull_min[1] = {{-300.0f, -10.0f, -40.0f}}; +const Vec daShutter2_c::m_cull_max[1] = {{300.0f, 400.0f, 40.0f}}; + +char* daShutter2_c::m_arcname[1] = {"Htobi3"}; +char* daShutter2_c::m_open_ev_name[1] = {"R04DOOROPEN"}; +char* daShutter2_c::m_close_ev_name[1] = {"R04DOORCLOSE"}; +char* daShutter2_c::m_staff_name[1] = {"Htobi3"}; /* 00000078-000000B8 .text Delete__12daShutter2_cFv */ BOOL daShutter2_c::Delete() { - /* Nonmatching */ + dComIfG_resDelete(&mPhs, m_arcname[mType]); + return TRUE; } /* 000000B8-00000194 .text CreateHeap__12daShutter2_cFv */ -void daShutter2_c::CreateHeap() { - /* Nonmatching */ +int daShutter2_c::CreateHeap() { + J3DModelData* modelData = (J3DModelData *)dComIfG_getObjectRes(m_arcname[mType], m_bdlidx[mType]); + JUT_ASSERT(0xe0, modelData != 0); + mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000022); + if (!mpModel) { + return FALSE; + } + return TRUE; } /* 00000194-00000350 .text Create__12daShutter2_cFv */ -s32 daShutter2_c::Create() { - /* Nonmatching */ +int daShutter2_c::Create() { + fopAcM_SetMtx(this, mpModel->getBaseTRMtx()); + Vec cullMin = m_cull_min[mType]; + Vec cullMax = m_cull_max[mType]; + fopAcM_setCullSizeBox(this, cullMin.x, cullMin.y, cullMin.z, cullMax.x, cullMax.y, cullMax.z); + mSwitchNo = daShutter2_prm::getSwitchNo(this); + mbIsNearEnemy = fopAcM_myRoomSearchEnemy(fopAcM_GetRoomNo(this)) == NULL; + if (((mSwitchNo != 0xff) && (fopAcM_isSwitch(this, mSwitchNo))) || + ((mSwitchNo == 0xff) && (mbIsNearEnemy))) { + m30C = 1; + current.pos.y = home.pos.y + 350.0f; + } + else { + m30C = 2; + } + mbIsSwitch = fopAcM_isSwitch(this, mSwitchNo); + set_mtx(); + if (m_open_ev_name[mType] != NULL) { + mOpenEventIdx = dComIfGp_evmng_getEventIdx(m_open_ev_name[mType], 0xff); + } + if (m_close_ev_name[mType] != NULL) { + mCloseEventIdx = dComIfGp_evmng_getEventIdx(m_close_ev_name[mType], 0xff); + } + return TRUE; } /* 00000350-0000041C .text _create__12daShutter2_cFv */ s32 daShutter2_c::_create() { - /* Nonmatching */ + fopAcM_SetupActor(this, daShutter2_c); + mType = 0; + if ((dComIfG_resLoad(&mPhs, m_arcname[mType]) == cPhs_COMPLEATE_e) && + (MoveBGCreate(m_arcname[mType], m_dzbidx[mType], NULL, m_heapsize[mType]) == cPhs_ERROR_e)) { + return cPhs_ERROR_e; + } } /* 0000041C-000004AC .text set_mtx__12daShutter2_cFv */ void daShutter2_c::set_mtx() { - /* Nonmatching */ + mpModel->setBaseScale(scale); + mDoMtx_stack_c::transS(current.pos.x, current.pos.y, current.pos.z); + mDoMtx_stack_c::YrotM(current.angle.y); + mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); + MTXCopy(mDoMtx_stack_c::get(), mMtx); + return; } /* 000004AC-00000528 .text Execute__12daShutter2_cFPPA3_A4_f */ -void daShutter2_c::Execute(float(**)[3][4]) { - /* Nonmatching */ +BOOL daShutter2_c::Execute(Mtx** pMtx) { + demo(); + set_mtx(); + mbIsSwitch = fopAcM_isSwitch(this, mSwitchNo); + mbIsNearEnemy = fopAcM_myRoomSearchEnemy(fopAcM_GetRoomNo(this)) == NULL; + *pMtx = &mMtx; + return TRUE; } /* 00000528-00000698 .text shutter_move__12daShutter2_cFv */ void daShutter2_c::shutter_move() { - /* Nonmatching */ + float fVar3; + + static char* action_table[4] = {"WAIT", "OPEN", "CLOSE", "OPEN_INIT"}; + int actionIndex = dComIfGp_evmng_getMyActIdx(mStaffId, action_table, ARRAY_SIZE(action_table), FALSE, 0); + + float maxVel = m_max_speed[mType]; + float minVel = m_min_speed[mType]; + + switch (actionIndex) { + case 0: //WAIT + { + dComIfGp_evmng_cutEnd(mStaffId); + break; + } + case 3: //OPEN_INIT + { + fopAcM_seStart(this, JA_SE_OBJ_WDUN_R04_STR_OP, 0); + dComIfGp_evmng_cutEnd(mStaffId); + break; + } + case 1: //OPEN + { + fVar3 = cLib_addCalc(¤t.pos.y, home.pos.y + 350.0f, 0.1f, maxVel, minVel); + if (fVar3 == 0.0f){ + dComIfGp_evmng_cutEnd(mStaffId); + } + break; + + } + case 2: //CLOSE + { + fVar3 = cLib_addCalc(¤t.pos.y, home.pos.y, 0.1f, maxVel, minVel); + if (fVar3 == 0.0f){ + dComIfGp_evmng_cutEnd(mStaffId); + } + break; + } + default: + dComIfGp_evmng_cutEnd(mStaffId); + } + return; } /* 00000698-000008B0 .text demo__12daShutter2_cFv */ void daShutter2_c::demo() { - /* Nonmatching */ + u8 isSwitch = fopAcM_isSwitch(this, mSwitchNo); + u8 isNearEnemy = fopAcM_myRoomSearchEnemy(fopAcM_GetRoomNo(this)) == NULL; + if (mActionIndex == 0) { + if (mSwitchNo != 0xFF) { + if (isSwitch != (u8)mbIsSwitch) { + if (!isSwitch) { + mActionIndex = 2; + } + else { + mActionIndex = 1; + } + } + } + else if (isNearEnemy != mbIsNearEnemy) { + if (!isNearEnemy) { + mActionIndex = 2; + } + else { + mActionIndex = 1; + } + } + } + if (eventInfo.checkCommandDemoAccrpt()) { + if (dComIfGp_evmng_startCheck(mOpenEventIdx) && (mActionIndex == 1)) { + mActionIndex = 0; + } + if (dComIfGp_evmng_startCheck(mCloseEventIdx) && (mActionIndex == 2)) { + mActionIndex = 0; + } + if (dComIfGp_evmng_endCheck(mOpenEventIdx) || dComIfGp_evmng_endCheck(mCloseEventIdx)) { + dComIfGp_event_reset(); + } + mStaffId = dComIfGp_evmng_getMyStaffId(m_staff_name[mType], NULL, 0); + shutter_move(); + } + else if ((mActionIndex == 1) && (mOpenEventIdx != 0)) { + fopAcM_orderOtherEventId(this, mOpenEventIdx); + eventInfo.onCondition(dEvtCnd_UNK2_e); + } + else if ((mActionIndex == 2) && (mCloseEventIdx != 0)) { + fopAcM_orderOtherEventId(this, mCloseEventIdx); + eventInfo.onCondition(dEvtCnd_UNK2_e); + } + return; } /* 000008B0-00000950 .text Draw__12daShutter2_cFv */ BOOL daShutter2_c::Draw() { - /* Nonmatching */ + g_env_light.settingTevStruct(TEV_TYPE_BG0, ¤t.pos, &tevStr); + g_env_light.setLightTevColorType(mpModel, &tevStr); + dComIfGd_setListBG(); + mDoExt_modelUpdateDL(mpModel); + dComIfGd_setList(); + return TRUE; } /* 00000950-00000970 .text daShutter2_Create__FPv */ -static s32 daShutter2_Create(void*) { - /* Nonmatching */ +static s32 daShutter2_Create(void* i_this) { + return ((daShutter2_c*)i_this)->_create(); } /* 00000970-00000990 .text daShutter2_Delete__FPv */ -static BOOL daShutter2_Delete(void*) { - /* Nonmatching */ +static BOOL daShutter2_Delete(void* i_this) { + return ((daShutter2_c*)i_this)->MoveBGDelete(); } /* 00000990-000009BC .text daShutter2_Draw__FPv */ -static BOOL daShutter2_Draw(void*) { - /* Nonmatching */ +static BOOL daShutter2_Draw(void* i_this) { + return ((daShutter2_c*)i_this)->MoveBGDraw(); } /* 000009BC-000009DC .text daShutter2_Execute__FPv */ -static BOOL daShutter2_Execute(void*) { - /* Nonmatching */ +static BOOL daShutter2_Execute(void* i_this) { + return ((daShutter2_c*)i_this)->MoveBGExecute(); } /* 000009DC-000009E4 .text daShutter2_IsDelete__FPv */ static BOOL daShutter2_IsDelete(void*) { - /* Nonmatching */ + return TRUE; } static actor_method_class daShutter2MethodTable = {