From bf5c15e70a6fcd4a8f385165af2b889485391feb Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Mon, 11 Sep 2023 20:41:42 -0700 Subject: [PATCH] f_op_kankyo_mng close --- configure.py | 4 +- include/d/d_com_inf_game.h | 28 +++++++++- include/d/d_event.h | 6 +- include/d/d_particle.h | 3 +- include/f_pc/f_pc_method.h | 5 -- src/d/actor/d_a_andsw0.cpp | 105 +++++++++++++++++++++++++++++------ src/d/actor/d_a_andsw2.cpp | 3 +- src/f_op/f_op_kankyo_mng.cpp | 3 +- 8 files changed, 126 insertions(+), 31 deletions(-) diff --git a/configure.py b/configure.py index 5524f5acd..28175cdce 100644 --- a/configure.py +++ b/configure.py @@ -341,7 +341,7 @@ def ActorRel(status, rel_name): Rel(Matching, "f_pc_profile_lst", "f_pc/f_pc_profile_lst.cpp"), ActorRel(NonMatching, "d_a_agbsw0"), ActorRel(NonMatching, "d_a_andsw0"), - ActorRel( Matching, "d_a_andsw2"), + ActorRel(Matching, "d_a_andsw2"), ActorRel(NonMatching, "d_a_att"), ActorRel(NonMatching, "d_a_bflower"), ActorRel(NonMatching, "d_a_bita"), @@ -723,7 +723,7 @@ def ActorRel(status, rel_name): ActorRel(NonMatching, "d_a_pz"), ActorRel(NonMatching, "d_a_sail"), ActorRel(NonMatching, "d_a_salvage_tbox"), - ActorRel(Matching, "d_a_scene_change"), + ActorRel(Matching, "d_a_scene_change"), ActorRel(NonMatching, "d_a_shutter"), ActorRel(NonMatching, "d_a_shutter2"), ActorRel(NonMatching, "d_a_st"), diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index 0318e26a0..46dc6be05 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -8,6 +8,7 @@ #include "d/d_drawlist.h" #include "d/d_event.h" #include "d/d_event_manager.h" +#include "d/d_particle.h" #include "d/d_resorce.h" #include "d/d_save.h" #include "d/d_stage.h" @@ -118,6 +119,7 @@ class dComIfG_play_c { dStage_stageDt_c& getStage() { return mStageData; } dEvt_control_c& getEvent() { return mEvtCtrl; } dEvent_manager_c& getEvtManager() { return mEvtManager; } + dPa_control_c* getParticle() { return mParticle; } const char* getStartStageName() { return mCurStage.getName(); } s8 getStartStageRoomNo() { return mCurStage.getRoomNo(); } @@ -506,8 +508,15 @@ inline daPy_lk_c* daPy_getPlayerLinkActorClass() { } /** - * === EVENT === - */ + * === EVENT ===*/ + +inline void dComIfGp_event_onEventFlag(s16 flag) { + return g_dComIfG_gameInfo.play.getEvent().onEventFlag(flag); +} + +inline void dComIfGp_event_offEventFlag(s16 flag) { + return g_dComIfG_gameInfo.play.getEvent().offEventFlag(flag); +} inline dEvent_manager_c& dComIfGp_getEventManager() { return g_dComIfG_gameInfo.play.getEvtManager(); @@ -580,4 +589,19 @@ inline void* dComIfG_getObjectRes(const char* arcName, int param_1) { return g_dComIfG_gameInfo.mResControl.getObjectRes(arcName, param_1); } +/** + * === PARTICLE === + */ + +void set(u8, u16, cXyz const*, csXyz const*, cXyz const*, u8, dPa_levelEcallBack*, s8, GXColor const*, GXColor const*, cXyz const*); + +inline JPABaseEmitter * dComIfGp_particle_set(u16 particleID, const cXyz* pos, const csXyz * angle, const cXyz * scale, u8 alpha, dPa_levelEcallBack * pCallBack, s8 setupInfo, const GXColor * pPrmColor, const GXColor * pEnvColor, const cXyz * pScale2D) { + dPa_control_c * pParticle = g_dComIfG_gameInfo.play.getParticle(); + return pParticle->set(0, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D); +} + +inline JPABaseEmitter * dComIfGp_particle_set(u16 particleID, const cXyz* pos, const csXyz * angle, const cXyz * scale) { + return dComIfGp_particle_set(particleID, pos, angle, scale, 0xFF, NULL, -1, NULL, NULL, NULL); +} + #endif /* D_COM_D_COM_INF_GAME_H */ diff --git a/include/d/d_event.h b/include/d/d_event.h index 3f867bfb4..2aa81d18d 100644 --- a/include/d/d_event.h +++ b/include/d/d_event.h @@ -59,6 +59,10 @@ class dEvt_control_c { void getTactFreeCStick(int); void giveItemCut(u8); + inline u16 chkEventFlag(u16 flag) { return flag & mEventFlag; } + inline void onEventFlag(u16 flag) { mEventFlag |= flag; } + inline void offEventFlag(u16 flag) { mEventFlag &= ~flag; } + /* 0x00 */ dEvt_order_c mOrder[8]; /* 0xC0 */ u8 mOrderCount; /* 0xC1 */ u8 mFirstOrderIdx; @@ -83,7 +87,7 @@ class dEvt_control_c { /* 0xE2 */ u8 mbInPhoto; /* 0xE3 */ u8 field_0xE3[0xE4 - 0xE3]; /* 0xE4 */ f32 mCullFarClipRatio; - /* 0xE8 */ u16 mStateFlags; + /* 0xE8 */ u16 mEventFlag; /* 0xEA */ u8 mTactFreeMStick[4]; /* 0xEE */ u8 mTactFreeCStick[4]; }; // Size = 0xF4 diff --git a/include/d/d_particle.h b/include/d/d_particle.h index d198ded57..eae5ceb03 100644 --- a/include/d/d_particle.h +++ b/include/d/d_particle.h @@ -12,6 +12,7 @@ class dPa_modelControl_c; class JKRHeap; class JPABaseEmitter; class JPAEmitterManager; +struct csXyz; class dPa_simpleData_c { public: @@ -61,7 +62,7 @@ class dPa_control_c { void calc2D(); void calcMenu(); void draw(JPADrawInfo*, u8); - void set(u8, u16, cXyz const*, csXyz const*, cXyz const*, u8, dPa_levelEcallBack*, s8, GXColor const*, GXColor const*, cXyz const*); + JPABaseEmitter * set(u8, u16, cXyz const*, csXyz const*, cXyz const*, u8, dPa_levelEcallBack*, s8, GXColor const*, GXColor const*, cXyz const*); void setBombSmoke(u16, cXyz const*, csXyz const*, cXyz const*, u8); void setSimpleLand(int, cXyz const*, csXyz const*, f32, f32, f32, dKy_tevstr_c*, int*, int); void setSimpleLand(cBgS_PolyInfo&, cXyz const*, csXyz const*, f32, f32, f32, dKy_tevstr_c*, int*, int); diff --git a/include/f_pc/f_pc_method.h b/include/f_pc/f_pc_method.h index aa7e98dda..eb34133fd 100644 --- a/include/f_pc/f_pc_method.h +++ b/include/f_pc/f_pc_method.h @@ -19,9 +19,4 @@ s32 fpcMtd_IsDelete(process_method_class* pMthd, void* pUserData); s32 fpcMtd_Delete(process_method_class* pMthd, void* pUserData); s32 fpcMtd_Create(process_method_class* pMthd, void* pUserData); -extern "C" { -void fpcMtd_Execute__FP20process_method_classPv(void); -void fpcMtd_Create__FP20process_method_classPv(void); -} - #endif diff --git a/src/d/actor/d_a_andsw0.cpp b/src/d/actor/d_a_andsw0.cpp index 89eaff1a3..a181d5038 100644 --- a/src/d/actor/d_a_andsw0.cpp +++ b/src/d/actor/d_a_andsw0.cpp @@ -3,12 +3,36 @@ // Translation Unit: d_a_andsw0.cpp // -#include "d_a_andsw0.h" -#include "dolphin/types.h" +#include "JSystem/JKernel/JKRHeap.h" +#include "f_op/f_op_actor_mng.h" +#include "d/d_com_inf_game.h" + +enum { + ACT_ON_ALL = 0, + ACT_OFF_ALL, + ACT_WAIT = 10, + ACT_TIMER = 20, + ACT_TIMER2, + ACT_TIMER_SET = 30, +}; + +struct andsw0_class : public fopAc_ac_c { +public: + /* 0x290 */ u32 _pad[2]; + /* 0x298 */ u8 mAction; + /* 0x299 */ u8 mNumSwitchesToCheck; + /* 0x29A */ u8 mBehaviorType; + /* 0x29B */ u8 mSwitchToSet; + /* 0x29C */ u8 mFirstSwitchToCheck; + /* 0x29E */ u16 mTimer; + /* 0x2A0 */ u16 mEventMapToolNo; + /* 0x292 */ u8 mEventIdx; + /* 0x293 */ u8 mEventState; +}; /* 00000078-00000080 .text daAndsw0_Draw__FP12andsw0_class */ -void daAndsw0_Draw(andsw0_class*) { - /* Nonmatching */ +s32 daAndsw0_Draw(andsw0_class*) { + return 1; } /* 00000080-000003C4 .text daAndsw0_check__FP12andsw0_class */ @@ -37,37 +61,84 @@ void bb_s_sub(void*, void*) { } /* 000005D4-000006AC .text hajimari_actor_entry__FP12andsw0_class */ -void hajimari_actor_entry(andsw0_class*) { +s32 hajimari_actor_entry(andsw0_class*) { /* Nonmatching */ } /* 000006AC-0000081C .text hajimarinomori_check__FP12andsw0_class */ -void hajimarinomori_check(andsw0_class*) { - /* Nonmatching */ +void hajimarinomori_check(andsw0_class* i_this) { + if (i_this->mBehaviorType == 0) { + if (hajimari_actor_entry(i_this)) + i_this->mBehaviorType = 1; + } else { + if (dComIfGs_isEventBit(4)) { + // + } + } } /* 0000081C-00000914 .text event_start_check__FP12andsw0_class */ -void event_start_check(andsw0_class*) { - /* Nonmatching */ +static void event_start_check(andsw0_class* i_this) { + switch (i_this->mEventState) { + case 0: + default: + if (i_this->mEventIdx != -1 && i_fopAcM_isSwitch(i_this, i_this->mSwitchToSet)) { + if (i_this->mEvtInfo.i_checkCommandDemoAccrpt()) { + i_this->mEventState++; + } else { + fopAcM_orderOtherEventId(i_this, i_this->mEventIdx, i_this->mEventMapToolNo, 0xFFFF, 0, 1); + } + } + case 1: + if (dComIfGp_evmng_endCheck(i_this->mEventIdx)) { + dComIfGp_event_onEventFlag(8); + i_this->mEventState++; + } + break; + } } /* 00000914-00000964 .text daAndsw0_Execute__FP12andsw0_class */ -void daAndsw0_Execute(andsw0_class*) { - /* Nonmatching */ +s32 daAndsw0_Execute(andsw0_class* i_this) { + event_start_check(i_this); + if (i_this->mNumSwitchesToCheck == 0xFF) + hajimarinomori_check(i_this); + else + daAndsw0_check(i_this); + return 1; } /* 00000964-0000096C .text daAndsw0_IsDelete__FP12andsw0_class */ -void daAndsw0_IsDelete(andsw0_class*) { - /* Nonmatching */ +s32 daAndsw0_IsDelete(andsw0_class*) { + return 1; } /* 0000096C-00000974 .text daAndsw0_Delete__FP12andsw0_class */ -void daAndsw0_Delete(andsw0_class*) { - /* Nonmatching */ +s32 daAndsw0_Delete(andsw0_class*) { + return 1; } /* 00000974-00000A64 .text daAndsw0_Create__FP10fopAc_ac_c */ -void daAndsw0_Create(fopAc_ac_c*) { - /* Nonmatching */ +s32 daAndsw0_Create(fopAc_ac_c* ac) { + fopAcM_SetupActor(ac, andsw0_class); + + andsw0_class * i_this = (andsw0_class *)ac; + i_this->mNumSwitchesToCheck = (fopAcM_GetParam(ac) >> 0) & 0xFF; + i_this->mBehaviorType = (fopAcM_GetParam(ac) >> 8) & 0xFF; + i_this->mSwitchToSet = (fopAcM_GetParam(ac) >> 24) & 0xFF; + i_this->mFirstSwitchToCheck = (fopAcM_GetParam(ac) >> 16) & 0xFF; + i_this->mTimer = (i_this->orig.angle.z & 0xFF) * 16; + i_this->mEventMapToolNo = i_this->orig.angle.x; + i_this->mEventIdx = dComIfGp_evmng_getEventIdx(NULL, i_this->mEventMapToolNo); + if (i_this->mBehaviorType == 2) + i_this->mAction = ACT_TIMER; + if (i_this->mFirstSwitchToCheck == 0xFF) + i_this->mFirstSwitchToCheck = 0; + if (i_this->mNumSwitchesToCheck == 0xFF) { + i_this->mSwitchToSet = 0; + i_this->mBehaviorType = 0; + } + + return cPhs_COMPLEATE_e; } diff --git a/src/d/actor/d_a_andsw2.cpp b/src/d/actor/d_a_andsw2.cpp index 2cd6acc34..8f910b540 100644 --- a/src/d/actor/d_a_andsw2.cpp +++ b/src/d/actor/d_a_andsw2.cpp @@ -164,14 +164,13 @@ static s32 daAndsw2_actionOrder(daAndsw2_c* i_this) { /* 00000438-000004BC .text daAndsw2_actionEvent__FP10daAndsw2_c */ static s32 daAndsw2_actionEvent(daAndsw2_c* i_this) { - dComIfG_play_c* play = &g_dComIfG_gameInfo.play; if (dComIfGp_evmng_endCheck(i_this->mEventIdx)) { if (i_this->getType() == TYPE_CONTINUOUS) { i_this->mAction = ACT_OFF; } else { i_this->mAction = ACT_WAIT; } - play->mEvtCtrl.mStateFlags |= 8; + dComIfGp_event_onEventFlag(8); } return 1; } diff --git a/src/f_op/f_op_kankyo_mng.cpp b/src/f_op/f_op_kankyo_mng.cpp index 02ce8953b..1ef8dc9d8 100644 --- a/src/f_op/f_op_kankyo_mng.cpp +++ b/src/f_op/f_op_kankyo_mng.cpp @@ -7,6 +7,7 @@ #include "f_op/f_op_kankyo.h" #include "f_pc/f_pc_executor.h" #include "d/d_procname.h" +#include "d/d_com_inf_game.h" #include "SSystem/SComponent/c_malloc.h" #include "SSystem/SComponent/c_lib.h" @@ -98,6 +99,6 @@ int fopKyM_createMpillar(cXyz const* i_pos, f32 i_size) { scale.x = i_size; scale.y = i_size; scale.z = i_size; - // dComIfGp_particle_set(0x80d5, i_pos, NULL, &scale); + dComIfGp_particle_set(0x80d5, i_pos, NULL, &scale); return -1; }