diff --git a/configure.py b/configure.py index 3f91c4e8..23b56cd3 100644 --- a/configure.py +++ b/configure.py @@ -1326,7 +1326,7 @@ def JSystemLib(lib_name, objects): ActorRel(NonMatching, "d_a_obj_otble"), ActorRel(Matching, "d_a_obj_pbco"), ActorRel(NonMatching, "d_a_obj_pirateship"), - ActorRel(NonMatching, "d_a_obj_quake"), + ActorRel(Matching, "d_a_obj_quake"), ActorRel(NonMatching, "d_a_obj_rcloud"), ActorRel(Matching, "d_a_obj_roten", extra_cflags=['-pragma "nosyminline on"']), ActorRel(NonMatching, "d_a_obj_shelf"), diff --git a/include/d/actor/d_a_obj_quake.h b/include/d/actor/d_a_obj_quake.h index db74865d..d0f346a7 100644 --- a/include/d/actor/d_a_obj_quake.h +++ b/include/d/actor/d_a_obj_quake.h @@ -2,27 +2,54 @@ #define D_A_OBJ_QUAKE_H #include "f_op/f_op_actor.h" +#include "m_Do/m_Do_hostIO.h" class daObjQuake_c : public fopAc_ac_c { public: + enum Prm_e { + PRM_SCH_W = 0x8, + PRM_SCH_S = 0x0, + + PRM_TYPE_W = 0x3, + PRM_TYPE_S = 0x8, + + PRM_POWER_W = 0x3, + PRM_POWER_S = 0xB, + }; + s32 _create(); BOOL _delete(); - void _is_delete(); + BOOL _is_delete(); BOOL _execute(); - void getPrmType(); - void getPrmSch(); - void getPrmPower(); + u8 getPrmType(); + u8 getPrmSch(); + s32 getPrmPower(); public: - /* Place member variables here */ + /* 0x290 */ f32 m290; + /* 0x294 */ f32 m294; + /* 0x298 */ f32 m298; + /* 0x29C */ f32 m29C; + /* 0x2A0 */ u8 mType; + /* 0x2A1 */ bool m2A1; }; -class daObjQuake_HIO_c { +class daObjQuake_HIO_c : public JORReflexible { public: daObjQuake_HIO_c(); + virtual ~daObjQuake_HIO_c() {} public: - /* Place member variables here */ + /* 0x04 */ s8 mChildID; + /* 0x08 */ s32 field_0x08; + /* 0x0C */ u8 field_0x0C; + /* 0x0D */ u8 field_0x0D; + /* 0x0E */ u8 field_0x0E; + /* 0x0F */ u8 field_0x0F; + /* 0x10 */ u8 field_0x10; + /* 0x11 */ u8 field_0x11; + /* 0x12 */ u8 field_0x12; + /* 0x13 */ u8 field_0x13; }; #endif /* D_A_OBJ_QUAKE_H */ diff --git a/include/d/d_kankyo.h b/include/d/d_kankyo.h index d395af67..414ddddf 100644 --- a/include/d/d_kankyo.h +++ b/include/d/d_kankyo.h @@ -452,6 +452,7 @@ cXyz dKy_get_orion_pos(); cXyz dKy_get_hokuto_pos(); void dKy_DayProc(); u8 dKy_get_schbit(); +int dKy_get_schbit_timer(); int dKy_rain_check(); void dKy_setLight_mine(dKy_tevstr_c* pTevStr); BOOL dKy_daynighttact_stop_chk(); diff --git a/include/d/d_stage.h b/include/d/d_stage.h index 651be67c..6a8aad36 100644 --- a/include/d/d_stage.h +++ b/include/d/d_stage.h @@ -1026,10 +1026,12 @@ inline s8 dStage_stagInfo_GetTimeH(stage_stag_info_class* p_info) { inline u8 dStage_stagInfo_getStartSch(stage_stag_info_class* p_info) { return (p_info->field_0x10 >> 0x10) & 0xFF; } +inline u8 dStage_stagInfo_GetSchSec(stage_stag_info_class* p_info) { + return p_info->field_0x0c & 0xFF; +} // TODO: // dStage_stagInfo_GetAgbCon__FP21stage_stag_info_class -// dStage_stagInfo_GetSchSec__FP21stage_stag_info_class - field_0x0c & 0xFF // dStage_stagInfo_DefaultCameraType__FP21stage_stag_info_class // dStage_stagInfo_GetCullPoint__FP21stage_stag_info_class // dStage_stagInfo_GetUpButton__FP21stage_stag_info_class diff --git a/src/d/actor/d_a_obj_quake.cpp b/src/d/actor/d_a_obj_quake.cpp index 2dc407aa..0cacdd7d 100644 --- a/src/d/actor/d_a_obj_quake.cpp +++ b/src/d/actor/d_a_obj_quake.cpp @@ -5,70 +5,213 @@ #include "d/actor/d_a_obj_quake.h" #include "d/d_procname.h" +#include "d/d_a_obj.h" +#include "d/d_com_inf_game.h" + +static daObjQuake_HIO_c l_HIO; /* 000000EC-00000134 .text __ct__16daObjQuake_HIO_cFv */ daObjQuake_HIO_c::daObjQuake_HIO_c() { - /* Nonmatching */ + mChildID = -1; + field_0x08 = 0; + field_0x0C = 0; + field_0x0D = 0; + field_0x0E = 3; + field_0x0F = 3; + field_0x10 = 1; + field_0x11 = 1; + field_0x12 = 1; + field_0x13 = 0; } /* 00000134-000002C4 .text _create__12daObjQuake_cFv */ s32 daObjQuake_c::_create() { - /* Nonmatching */ + fopAcM_SetupActor(this, daObjQuake_c); + + if (dComIfGs_isSymbol(1)) { + return cPhs_UNK3_e; + } + + if (getPrmType() < 3) { + fopAcM_offDraw(this); + mType = getPrmType(); + m2A1 = false; + m290 = 30.0f * dStage_stagInfo_GetSchSec(dComIfGp_getStageStagInfo()); + + switch (mType) { + case 0: + case 2: + m298 = 4.0f; + m29C = 6.0f; + break; + case 1: + m298 = 0.0f; + m29C = 6.0f; + break; + } + + if (l_HIO.mChildID < 0) { + l_HIO.mChildID = mDoHIO_root.mDoHIO_createChild("振動効果", &l_HIO); + } + + l_HIO.field_0x08 += 1; + return cPhs_COMPLEATE_e; + } + + return cPhs_ERROR_e; } /* 000002C4-000002CC .text _delete__12daObjQuake_cFv */ BOOL daObjQuake_c::_delete() { - /* Nonmatching */ + return TRUE; } /* 000002CC-00000390 .text _is_delete__12daObjQuake_cFv */ -void daObjQuake_c::_is_delete() { - /* Nonmatching */ +BOOL daObjQuake_c::_is_delete() { + if (m2A1) { + switch (mType) { + case 0: + dComIfGp_getVibration().StopQuake(0x3E); + break; + case 2: + dComIfGp_getVibration().StopQuake(1); + break; + } + } + + if (l_HIO.mChildID >= 0) { + l_HIO.field_0x08 -= 1; + if (l_HIO.field_0x08 == 0) { + mDoHIO_root.mDoHIO_deleteChild(l_HIO.mChildID); + l_HIO.mChildID = -1; + } + } + + return TRUE; } /* 00000390-00000674 .text _execute__12daObjQuake_cFv */ BOOL daObjQuake_c::_execute() { - /* Nonmatching */ + // Required for match + const char* unused[] = {"camera", "sound", "motor"}; // Has to be in a function after _create and before getPrmType + + m294 = dKy_get_schbit_timer(); + s32 var_r30 = 0x2E; + s32 var_r29 = getPrmPower(); + s32 var_r28 = getPrmPower(); + + if (l_HIO.field_0x0C != 0) { + var_r29 = l_HIO.field_0x0E + 1; + } + + if (l_HIO.field_0x0D != 0) { + var_r28 = l_HIO.field_0x0F + 1; + + if (l_HIO.field_0x10 != 0) { + var_r30 = var_r30 | 2; + } else { + var_r30 = var_r30 & ~2; + } + + if (l_HIO.field_0x11 != 0) { + var_r30 = var_r30 | 4; + } else { + var_r30 = var_r30 & ~4; + } + + if (l_HIO.field_0x12 != 0) { + var_r30 = var_r30 | 8; + } else { + var_r30 = var_r30 & ~8; + } + + if (l_HIO.field_0x13 != 0) { + var_r30 = var_r30 | 0x10; + } else { + var_r30 = var_r30 & ~0x10; + } + } + + u8 sch = getPrmSch(); + bool var_r27 = false; + if (sch & dKy_get_schbit() && !dComIfGp_event_chkEventFlag(dEvtFlag_TALK_e)) { + f32 a = (m29C / 6.0f) * m290; + f32 b = (m298 / 6.0f) * m290; + if (m294 >= b && m294 < a) { + var_r27 = true; + } + } + + if (m2A1) { + if (mType == 1) { + mDoAud_seStart(JA_SE_ATM_JINARI); + } + + if (!var_r27) { + switch (mType) { + case 0: + dComIfGp_getVibration().StopQuake(var_r30); + break; + case 2: + dComIfGp_getVibration().StopQuake(1); + break; + } + m2A1 = false; + } + } else if (var_r27) { + switch (mType) { + case 0: + dComIfGp_getVibration().StartQuake(var_r28, var_r30, cXyz(0.0f, 1.0f, 0.0f)); + break; + case 2: + dComIfGp_getVibration().StartQuake(var_r29, 1, cXyz(0.0f, 1.0f, 0.0f)); + break; + } + + m2A1 = true; + } + + return TRUE; } /* 00000674-000006A0 .text getPrmType__12daObjQuake_cFv */ -void daObjQuake_c::getPrmType() { - /* Nonmatching */ +u8 daObjQuake_c::getPrmType() { + return daObj::PrmAbstract(this, PRM_TYPE_W, PRM_TYPE_S); } /* 000006A0-000006CC .text getPrmSch__12daObjQuake_cFv */ -void daObjQuake_c::getPrmSch() { - /* Nonmatching */ +u8 daObjQuake_c::getPrmSch() { + return daObj::PrmAbstract(this, PRM_SCH_W, PRM_SCH_S); } /* 000006CC-000006F8 .text getPrmPower__12daObjQuake_cFv */ -void daObjQuake_c::getPrmPower() { - /* Nonmatching */ +s32 daObjQuake_c::getPrmPower() { + return daObj::PrmAbstract(this, PRM_POWER_W, PRM_POWER_S) + 1; } /* 000006F8-00000718 .text daObjQuakeCreate__FPv */ -static s32 daObjQuakeCreate(void*) { - /* Nonmatching */ +static s32 daObjQuakeCreate(void* i_this) { + return static_cast(i_this)->_create(); } /* 00000718-00000738 .text daObjQuakeDelete__FPv */ -static BOOL daObjQuakeDelete(void*) { - /* Nonmatching */ +static BOOL daObjQuakeDelete(void* i_this) { + return static_cast(i_this)->_delete(); } /* 00000738-00000758 .text daObjQuakeExecute__FPv */ -static BOOL daObjQuakeExecute(void*) { - /* Nonmatching */ +static BOOL daObjQuakeExecute(void* i_this) { + return static_cast(i_this)->_execute(); } /* 00000758-00000760 .text daObjQuakeDraw__FPv */ -static BOOL daObjQuakeDraw(void*) { - /* Nonmatching */ +static BOOL daObjQuakeDraw(void* i_this) { + return TRUE; } /* 00000760-00000780 .text daObjQuakeIsDelete__FPv */ -static BOOL daObjQuakeIsDelete(void*) { - /* Nonmatching */ +static BOOL daObjQuakeIsDelete(void* i_this) { + return static_cast(i_this)->_is_delete(); } static actor_method_class daObjQuakeMethodTable = { diff --git a/src/d/d_kankyo.cpp b/src/d/d_kankyo.cpp index fcdf2521..5ed21b74 100644 --- a/src/d/d_kankyo.cpp +++ b/src/d/d_kankyo.cpp @@ -553,7 +553,7 @@ s32 dStage_roomControl_c::GetTimePass() { */ void dScnKy_env_light_c::SetSchbit() { stage_stag_info_class* pstag = dComIfGp_getStageStagInfo(); - int uvar1 = pstag->field_0x0c & 0xFF; + int uvar1 = dStage_stagInfo_GetSchSec(pstag); if (dStage_stagInfo_getStartSch(pstag) != 0) { if (mSchbit == 0) {