diff --git a/include/d/actor/d_a_tag_volcano.h b/include/d/actor/d_a_tag_volcano.h index 60dbc9832..057d5648c 100644 --- a/include/d/actor/d_a_tag_volcano.h +++ b/include/d/actor/d_a_tag_volcano.h @@ -2,23 +2,41 @@ #define D_A_TAG_VOLCANO_H #include "f_op/f_op_actor.h" +#include "d/d_a_obj.h" namespace daTagvolcano { class Act_c : public fopAc_ac_c { public: - void prm_get_bitTRB() const {} - void prm_get_swSave() const {} - void prm_get_timer() const {} - void prm_get_type() const {} + enum Prm_e { + PRM_TRB_W = 0x06, + PRM_TRB_S = 0x00, + PRM_TYPE_W = 0x02, + PRM_TYPE_S = 0x06, + PRM_SWSAVE_W = 0x08, + PRM_SWSAVE_S = 0x08, + PRM_TIMER_W = 0x08, + PRM_TIMER_S = 0x10, + }; + + u32 prm_get_bitTRB() const { return daObj::PrmAbstract(this, PRM_TRB_W, PRM_TRB_S); } + u32 prm_get_swSave() const { return daObj::PrmAbstract(this, PRM_SWSAVE_W, PRM_SWSAVE_S); } + u32 prm_get_timer() const { return daObj::PrmAbstract(this, PRM_TIMER_W, PRM_TIMER_S); } + u32 prm_get_type() const { return daObj::PrmAbstract(this, PRM_TYPE_W, PRM_TYPE_S); } s32 _create(); - void check_timer_clear(); - BOOL _delete(); - BOOL _execute(); - BOOL _draw(); + bool check_timer_clear(); + bool _delete(); + bool _execute(); + bool _draw(); public: - /* Place member variables here */ + /* 0x290 */ u32 field_0x290; + /* 0x294 */ u32 field_0x294; + /* 0x298 */ u8 field_0x298; + /* 0x299 */ u8 field_0x299; + /* 0x29C */ s32 mType; + /* 0x2A0 */ s32 field_0x2a0; + /* 0x2A4 */ u8 field_0x2a4; }; }; diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index 002295c5f..13eed3a2f 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -988,6 +988,10 @@ inline void dComIfGs_offTmpBit(u16 id) { g_dComIfG_gameInfo.save.getTmp().offEventBit(id); } +inline s16 dComIfGs_getStartPoint() { + return g_dComIfG_gameInfo.save.getRestart().getStartPoint(); +} + inline void dComIfGs_setRestartRoomParam(u32 i_param) { g_dComIfG_gameInfo.save.getRestart().setRoomParam(i_param); } @@ -3148,9 +3152,27 @@ inline u32 dComIfG_getTimerNowTimeMs() { return g_dComIfG_gameInfo.play.getTimer inline void dComIfGp_setWaveFrame(u16 frame) { g_dComIfG_gameInfo.play.setWaveFrame(frame); } inline u16 dComIfGp_getWaveFrame() { return g_dComIfG_gameInfo.play.getWaveFrame(); } -inline u32 dComIfG_getTimerRestTimeMs() { return g_dComIfG_gameInfo.play.getTimerLimitTimeMs() - g_dComIfG_gameInfo.play.getTimerNowTimeMs(); } +inline s32 dComIfG_getTimerRestTimeMs() { return g_dComIfG_gameInfo.play.getTimerLimitTimeMs() - g_dComIfG_gameInfo.play.getTimerNowTimeMs(); } -inline void dComIfG_TimerDeleteRequest() { dComIfG_getTimerPtr()->deleteRequest(); } +inline void dComIfG_TimerDeleteRequest() { + if (dComIfG_getTimerPtr() != NULL) + dComIfG_getTimerPtr()->deleteRequest(); +} +inline bool dComIfG_TimerStart(s32 timer, s16 mode) { + if (dComIfG_getTimerMode() == mode && dComIfG_getTimerPtr() != NULL) + if (timer != 0) + dComIfG_getTimerPtr()->start(timer); + else + dComIfG_getTimerPtr()->start(); +} +inline void dComIfG_TimerReStart(s32 timer) { + if (dComIfG_getTimerPtr() != NULL) + dComIfG_getTimerPtr()->restart(timer); +} +inline void dComIfG_TimerStop(s32 timer) { + if (dComIfG_getTimerPtr() != NULL) + dComIfG_getTimerPtr()->stop(timer); +} inline u8 dComIfG_getBrightness() { return g_dComIfG_gameInfo.mBrightness; } inline void dComIfG_setBrightness(u8 v) { g_dComIfG_gameInfo.mBrightness = v; } diff --git a/include/f_op/f_op_actor_mng.h b/include/f_op/f_op_actor_mng.h index 6c523de7c..73117321f 100644 --- a/include/f_op/f_op_actor_mng.h +++ b/include/f_op/f_op_actor_mng.h @@ -637,6 +637,8 @@ inline void fopAcM_offDraw(fopAc_ac_c* actor) { inline void fopAcM_monsSeStart(fopAc_ac_c*, unsigned long, Vec*, unsigned long) {} inline void fopAcM_getNameString(fopAc_ac_c*, char*) {} -inline void fopAcM_orderOtherEvent(fopAc_ac_c*, char*, unsigned short) {} +inline void fopAcM_orderOtherEvent(fopAc_ac_c* ac, char* event, u16 flag) { + fopAcM_orderOtherEvent2(ac, event, flag); +} #endif diff --git a/src/d/actor/d_a_npc_ji1.cpp b/src/d/actor/d_a_npc_ji1.cpp index 2ec3f21ef..da95bddfd 100644 --- a/src/d/actor/d_a_npc_ji1.cpp +++ b/src/d/actor/d_a_npc_ji1.cpp @@ -2120,7 +2120,7 @@ BOOL daNpc_Ji1_c::battleGuardCheck() { dComIfGp_setMessageCountNumber(field_0xD70); field_0x2C8 = &normalAction; - if(dComIfG_getTimerPtr()) { + if (dComIfG_getTimerPtr()) { dComIfG_TimerDeleteRequest(); setClearRecord(field_0xD70); } @@ -2140,9 +2140,7 @@ BOOL daNpc_Ji1_c::battleGuardCheck() { if(field_0xC3C > 2) { Func_t temp = &battleAction; if(field_0x2B0 == temp) { - if(dComIfG_getTimerPtr()) { - dComIfG_TimerDeleteRequest(); - } + dComIfG_TimerDeleteRequest(); if(isClearRecord(field_0xD70)) { setClearRecord(field_0xD70); diff --git a/src/d/actor/d_a_tag_volcano.cpp b/src/d/actor/d_a_tag_volcano.cpp index 6edbac9ae..29648a48f 100644 --- a/src/d/actor/d_a_tag_volcano.cpp +++ b/src/d/actor/d_a_tag_volcano.cpp @@ -4,29 +4,232 @@ // #include "d/actor/d_a_tag_volcano.h" -#include "dolphin/types.h" +#include "d/d_com_inf_game.h" +#include "d/d_procname.h" + +namespace daTagvolcano { + namespace { + struct Attr_c { + /* 0x00 */ u32 field_0x00; + }; + + static const Attr_c L_attr = { + 0, + }; + + inline const Attr_c & attr() { return L_attr; } + } +} /* 00000078-000002B4 .text _create__Q212daTagvolcano5Act_cFv */ s32 daTagvolcano::Act_c::_create() { - /* Nonmatching */ + fopAcM_SetupActor(this, Act_c); + + field_0x298 = 0; + field_0x299 = 0; + mType = prm_get_type(); + field_0x2a0 = 0; + + if (mType == 0) { + if (current.roomNo == 20) { + if (dComIfGs_isEventBit(0x1902)) { + fopAcM_onSwitch(this, prm_get_swSave()); + } else if (dComIfGs_getStartPoint() == 2 && current.roomNo == dComIfGs_getRestartRoomNo()) { + field_0x2a0 = 10; + fopAcM_onSwitch(this, prm_get_swSave()); + } else { + fopAcM_offSwitch(this, prm_get_swSave()); + } + } else { + if (dComIfGs_isEventBit(0x1901)) { + fopAcM_onSwitch(this, prm_get_swSave()); + } else if (dComIfGs_getStartPoint() == 2 && current.roomNo == dComIfGs_getRestartRoomNo()) { + field_0x2a0 = 10; + fopAcM_onSwitch(this, prm_get_swSave()); + } else { + fopAcM_offSwitch(this, prm_get_swSave()); + } + } + } + + field_0x2a4 = 0; + return cPhs_COMPLEATE_e; } /* 000002B4-00000338 .text check_timer_clear__Q212daTagvolcano5Act_cFv */ -void daTagvolcano::Act_c::check_timer_clear() { - /* Nonmatching */ +bool daTagvolcano::Act_c::check_timer_clear() { + if (dComIfGp_isEnableNextStage()) { + if (strcmp(dComIfGp_getNextStageName(), "MiniKaz") == 0 || strcmp(dComIfGp_getNextStageName(), "MiniHyo") == 0) + return false; + else + return true; + } else { + return true; + } } /* 00000338-000003BC .text _delete__Q212daTagvolcano5Act_cFv */ -BOOL daTagvolcano::Act_c::_delete() { - /* Nonmatching */ +bool daTagvolcano::Act_c::_delete() { + if (check_timer_clear() && dComIfG_getTimerMode() == 3) + dComIfG_TimerDeleteRequest(); + fopAcM_offSwitch(this, prm_get_swSave()); + return true; } /* 000003BC-00000998 .text _execute__Q212daTagvolcano5Act_cFv */ -BOOL daTagvolcano::Act_c::_execute() { +bool daTagvolcano::Act_c::_execute() { /* Nonmatching */ + const Attr_c& a = attr(); + + if (mType == 0) { + if (fopAcM_isSwitch(this, prm_get_swSave())) { + if (field_0x2a0 > 0) { + field_0x2a0--; + if (field_0x2a0 == 0) + fopAcM_offSwitch(this, prm_get_swSave()); + } else { + if (field_0x298 == 1) { + if (dComIfG_getTimerPtr() != NULL) { + if (field_0x299 == 0) { + dComIfG_TimerStart(0, 3); + field_0x299 = 1; + } else { + if (dComIfGp_event_runCheck()) { + if (dComIfG_getTimerMode() == 3) + dComIfG_TimerStop(2); + } else { + if (dComIfG_getTimerMode() == 3) + dComIfG_TimerReStart(2); + } + + if (dComIfG_getTimerRestTimeMs() <= 0) { + mDoAud_seStart(JA_SE_ISLE_TIMER_0); + dComIfGp_getVibration().StartShock(6, -33, cXyz(0.0f, 1.0f, 0.0f)); + fopAcM_offSwitch(this, prm_get_swSave()); + if (dComIfG_getTimerMode() == 3) + dComIfG_TimerDeleteRequest(); + + field_0x298 = 0; + field_0x299 = 0; + } + } + } + } else { + u16 timer = prm_get_timer() * 10; + if (current.roomNo == 20) { + if (dComIfGp_evmng_endCheck("FREEZE_VOLCANO")) { + dTimer_createTimer(3, timer, 1, 0, 221.0f, 439.0f, 32.0f, 419.0f); + field_0x298 = 1; + } + } else { + if (dComIfGp_evmng_endCheck("MELT_ICE")) { + dTimer_createTimer(3, timer, 1, 0, 221.0f, 439.0f, 32.0f, 419.0f); + field_0x298 = 1; + } + } + } + } + } + } else { + if (dComIfGs_isTbox(prm_get_bitTRB())) { + if (dComIfG_getTimerPtr() != NULL && dComIfG_getTimerMode() == 3) + dComIfG_TimerDeleteRequest(); + if (mType == 1) + dComIfGs_onEventBit(0x1902); + else + dComIfGs_onEventBit(0x1901); + field_0x2a4 = 0; + } else if (dComIfG_getTimerPtr() != NULL) { + if (dComIfGp_event_runCheck()) { + if (dComIfG_getTimerMode() == 3) + dComIfG_TimerStop(2); + } else { + if (dComIfG_getTimerMode() == 3) + dComIfG_TimerReStart(2); + } + + if (dComIfG_getTimerRestTimeMs() <= 0) { + mDoAud_seStart(JA_SE_ISLE_TIMER_0); + dComIfGp_getVibration().StartShock(6, -33, cXyz(0.0f, 1.0f, 0.0f)); + if (dComIfG_getTimerMode() == 3) + dComIfG_TimerDeleteRequest(); + + field_0x2a4 = 1; + fopAcM_orderOtherEvent(this, "TAG_VOLCANO", dEvtFlag_NOPARTNER_e); + } + } else { + mDoAud_seStart(JA_SE_ISLE_TIMER_0); + dComIfGp_getVibration().StartShock(6, -33, cXyz(0.0f, 1.0f, 0.0f)); + field_0x2a4 = 1; + fopAcM_orderOtherEvent(this, "TAG_VOLCANO", dEvtFlag_NOPARTNER_e); + } + + if (field_0x2a4 == 1) { + if (mEvtInfo.checkCommandDemoAccrpt()) { + if (mType == 1) { + dComIfGp_setNextStage("sea", 2, 20); + } else { + dComIfGp_setNextStage("sea", 2, 40); + } + } else { + fopAcM_orderOtherEvent(this, "TAG_VOLCANO", dEvtFlag_NOPARTNER_e); + } + } + } + + return true; } /* 00000998-000009A0 .text _draw__Q212daTagvolcano5Act_cFv */ -BOOL daTagvolcano::Act_c::_draw() { - /* Nonmatching */ +bool daTagvolcano::Act_c::_draw() { + return true; } + +namespace daTagvolcano { + namespace { + s32 Mthd_Create(void* i_this) { + return ((Act_c*)i_this)->_create(); + } + + BOOL Mthd_Delete(void* i_this) { + return ((Act_c*)i_this)->_delete(); + } + + BOOL Mthd_Execute(void* i_this) { + return ((Act_c*)i_this)->_execute(); + } + + BOOL Mthd_Draw(void* i_this) { + return ((Act_c*)i_this)->_draw(); + } + + BOOL Mthd_IsDelete(void* i_this) { + return TRUE; + } + + static actor_method_class Mthd_Table = { + (process_method_func)Mthd_Create, + (process_method_func)Mthd_Delete, + (process_method_func)Mthd_Execute, + (process_method_func)Mthd_IsDelete, + (process_method_func)Mthd_Draw, + }; + } +} + +actor_process_profile_definition g_profile_Tag_Volcano = { + /* LayerID */ fpcLy_CURRENT_e, + /* ListID */ 2, + /* ListPrio */ fpcPi_CURRENT_e, + /* ProcName */ PROC_Tag_Volcano, + /* Proc SubMtd */ &g_fpcLf_Method.mBase, + /* Size */ sizeof(daTagvolcano::Act_c), + /* SizeOther */ 0, + /* Parameters */ 0, + /* Leaf SubMtd */ &g_fopAc_Method.base, + /* Priority */ 0x0061, + /* Actor SubMtd */ &daTagvolcano::Mthd_Table, + /* Status */ fopAcStts_UNK40000_e | fopAcStts_UNK4000_e, + /* Group */ fopAc_ACTOR_e, + /* CullType */ fopAc_CULLBOX_0_e, +}; diff --git a/src/d/d_stage.cpp b/src/d/d_stage.cpp index e459332bd..76376d4f6 100644 --- a/src/d/d_stage.cpp +++ b/src/d/d_stage.cpp @@ -2341,7 +2341,7 @@ void dStage_escapeRestart() { dComIfGs_setTurnRestart(player_p->current.pos, player_p->shape_angle.y, fopAcM_GetRoomNo(player_p), player_p->getDayNightParamData()); - if (dComIfG_getTimerMode() == 3 && dComIfG_getTimerPtr() != NULL) { + if (dComIfG_getTimerMode() == 3) { dComIfG_TimerDeleteRequest(); }