From dae37fdbbb757cbf42eb636816f01ef076e2c1aa Mon Sep 17 00:00:00 2001 From: TakaRikka Date: Wed, 28 Jun 2023 15:48:59 -0700 Subject: [PATCH] d_a_tag_mist OK --- .../rel/d/a/tag/d_a_tag_mist/d_a_tag_mist.h | 43 ++- rel/d/a/tag/d_a_tag_mist/d_a_tag_mist.cpp | 338 +++++++----------- 2 files changed, 180 insertions(+), 201 deletions(-) diff --git a/include/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist.h b/include/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist.h index a89312ecd4c..b924b54996c 100644 --- a/include/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist.h +++ b/include/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist.h @@ -1,6 +1,47 @@ #ifndef D_A_TAG_MIST_H #define D_A_TAG_MIST_H -#include "dolphin/types.h" +#include "f_op/f_op_actor_mng.h" + +class daTagMist_c : public fopAc_ac_c { +public: + /* 8048F258 */ void offSw(); + /* 8048F2C4 */ void onMySw(); + /* 8048F310 */ BOOL isMySw(); + /* 8048F370 */ int Create(); + /* 8048F444 */ int create(); + /* 8048F558 */ int execute(); + /* 8048F690 */ int _delete(); + + /* 80031CF0 */ static u8 getPlayerNo(); + static void setPlayerNo(u8 i_playerNo) { mPlayerNo = i_playerNo; } + + static u8 mPlayerNo; + + /* 0x568 */ u8 unused_0x568[0x570 - 0x568]; + /* 0x570 */ cXyz mVertices[4]; + /* 0x5A0 */ u8 mPlayerTouched; + /* 0x5A1 */ u8 mInitParams; + /* 0x5A2 */ u16 field_0x5a2; + /* 0x5A4 */ u16 field_0x5a4; +}; // Size: 0x5A8 + +namespace daTagMist_prm { +inline u8 getSwNoNum(daTagMist_c* i_this) { + return fopAcM_GetParam(i_this) >> 0x10; +} +inline u8 getMySwNo(daTagMist_c* i_this) { + return fopAcM_GetParam(i_this) >> 0x8; +} +inline u8 getTopSwNo(daTagMist_c* i_this) { + return fopAcM_GetParam(i_this); +} +inline u8 getExitNo(daTagMist_c* i_this) { + return (fopAcM_GetParam(i_this) >> 0x18) & 0x3F; +} +inline int getSwNo2(daTagMist_c* i_this) { + return i_this->field_0x5a2 & 0xFF; +} +} // namespace daTagMist_prm #endif /* D_A_TAG_MIST_H */ diff --git a/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist.cpp b/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist.cpp index d870cfe1888..ba3f17a6fdb 100644 --- a/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist.cpp +++ b/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist.cpp @@ -1,243 +1,181 @@ -// -// Generated By: dol2asm -// Translation Unit: d_a_tag_mist -// +/** + * d_a_tag_mist.cpp + * + */ #include "rel/d/a/tag/d_a_tag_mist/d_a_tag_mist.h" -#include "dol2asm.h" -#include "dolphin/types.h" - -// -// Types: -// - -struct mDoMtx_stack_c { - static u8 now[48]; -}; - -struct fopAc_ac_c { - /* 80018B64 */ fopAc_ac_c(); -}; - -struct daTagMist_c { - /* 8048F258 */ void offSw(); - /* 8048F2C4 */ void onMySw(); - /* 8048F310 */ void isMySw(); - /* 8048F370 */ void Create(); - /* 8048F444 */ void create(); - /* 8048F558 */ void execute(); - /* 8048F690 */ bool _delete(); -}; - -struct dSv_info_c { - /* 80035200 */ void onSwitch(int, int); - /* 800352B0 */ void offSwitch(int, int); - /* 80035360 */ void isSwitch(int, int) const; -}; - -struct cXyz { - /* 8048F518 */ ~cXyz(); - /* 8048F554 */ cXyz(); -}; - -// -// Forward References: -// - -extern "C" void offSw__11daTagMist_cFv(); -extern "C" void onMySw__11daTagMist_cFv(); -extern "C" void isMySw__11daTagMist_cFv(); -extern "C" void Create__11daTagMist_cFv(); -extern "C" void create__11daTagMist_cFv(); -extern "C" void __dt__4cXyzFv(); -extern "C" void __ct__4cXyzFv(); -extern "C" void execute__11daTagMist_cFv(); -extern "C" bool _delete__11daTagMist_cFv(); -extern "C" static void daTagMist_Execute__FP11daTagMist_c(); -extern "C" static void daTagMist_Delete__FP11daTagMist_c(); -extern "C" static void daTagMist_Create__FP10fopAc_ac_c(); -extern "C" extern void* g_profile_Tag_Mist[12]; - -// -// External References: -// - -extern "C" void mDoMtx_YrotS__FPA4_fs(); -extern "C" void __ct__10fopAc_ac_cFv(); -extern "C" void onSwitch__10dSv_info_cFii(); -extern "C" void offSwitch__10dSv_info_cFii(); -extern "C" void isSwitch__10dSv_info_cCFii(); -extern "C" void __dl__FPv(); -extern "C" void PSMTXMultVec(); -extern "C" void PSVECSubtract(); -extern "C" void __construct_array(); -extern "C" void _savegpr_27(); -extern "C" void _restgpr_27(); -extern "C" extern void* g_fopAc_Method[8]; -extern "C" extern void* g_fpcLf_Method[5 + 1 /* padding */]; -extern "C" u8 now__14mDoMtx_stack_c[48]; -extern "C" extern u8 g_dComIfG_gameInfo[122384]; -extern "C" extern u8 mPlayerNo__11daTagMist_c[4]; - -// -// Declarations: -// +#include "JSystem/JKernel/JKRHeap.h" +#include "d/com/d_com_inf_game.h" +#include "d/d_procname.h" /* 8048F258-8048F2C4 000078 006C+00 1/1 0/0 0/0 .text offSw__11daTagMist_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daTagMist_c::offSw() { - nofralloc -#include "asm/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist/offSw__11daTagMist_cFv.s" +void daTagMist_c::offSw() { + u8 sw_no_num; + u8 top_sw_no; + + top_sw_no = daTagMist_prm::getTopSwNo(this); + sw_no_num = daTagMist_prm::getSwNoNum(this); + + for (int i = 0; i < sw_no_num; i++) { + i_fopAcM_offSwitch(this, top_sw_no + i); + } } -#pragma pop /* 8048F2C4-8048F310 0000E4 004C+00 1/1 0/0 0/0 .text onMySw__11daTagMist_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daTagMist_c::onMySw() { - nofralloc -#include "asm/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist/onMySw__11daTagMist_cFv.s" +void daTagMist_c::onMySw() { + u32 my_sw_no; + u32 top_sw_no; + + top_sw_no = daTagMist_prm::getTopSwNo(this); + my_sw_no = daTagMist_prm::getMySwNo(this); + + if (my_sw_no != 0xFF) { + i_fopAcM_onSwitch(this, top_sw_no + my_sw_no); + } } -#pragma pop /* 8048F310-8048F370 000130 0060+00 1/1 0/0 0/0 .text isMySw__11daTagMist_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daTagMist_c::isMySw() { - nofralloc -#include "asm/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist/isMySw__11daTagMist_cFv.s" +BOOL daTagMist_c::isMySw() { + u32 my_sw_no; + u32 top_sw_no; + + top_sw_no = daTagMist_prm::getTopSwNo(this); + my_sw_no = daTagMist_prm::getMySwNo(this); + + if (my_sw_no != 0xFF && i_fopAcM_isSwitch(this, top_sw_no + my_sw_no)) { + return TRUE; + } else { + return FALSE; + } } -#pragma pop - -/* ############################################################################################## */ -/* 8048F700-8048F704 000000 0004+00 1/1 0/0 0/0 .rodata @3678 */ -SECTION_RODATA static f32 const lit_3678 = -50.0f; -COMPILER_STRIP_GATE(0x8048F700, &lit_3678); - -/* 8048F704-8048F708 000004 0004+00 0/1 0/0 0/0 .rodata @3679 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3679 = 50.0f; -COMPILER_STRIP_GATE(0x8048F704, &lit_3679); -#pragma pop - -/* 8048F708-8048F70C 000008 0004+00 0/1 0/0 0/0 .rodata @3680 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const lit_3680[4] = { - 0x00, - 0x00, - 0x00, - 0x00, -}; -COMPILER_STRIP_GATE(0x8048F708, &lit_3680); -#pragma pop /* 8048F370-8048F444 000190 00D4+00 1/1 0/0 0/0 .text Create__11daTagMist_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daTagMist_c::Create() { - nofralloc -#include "asm/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist/Create__11daTagMist_cFv.s" +int daTagMist_c::Create() { + mVertices[0].x = mScale.x * -50.0f; + mVertices[0].z = mScale.z * -50.0f; + + mVertices[1].x = mScale.x * 50.0f; + mVertices[1].z = mScale.z * -50.0f; + + mVertices[2].x = mScale.x * 50.0f; + mVertices[2].z = mScale.z * 50.0f; + + mVertices[3].x = mScale.x * -50.0f; + mVertices[3].z = mScale.z * 50.0f; + + mVertices[3].y = 0.0f; + mVertices[2].y = 0.0f; + mVertices[1].y = 0.0f; + mVertices[0].y = 0.0f; + + if (isMySw()) { + setPlayerNo(daTagMist_prm::getExitNo(this)); + } + + mPlayerTouched = false; + return 1; } -#pragma pop /* 8048F444-8048F518 000264 00D4+00 1/1 0/0 0/0 .text create__11daTagMist_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daTagMist_c::create() { - nofralloc -#include "asm/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist/func_8048F444.s" -} -#pragma pop +int daTagMist_c::create() { + if (!fopAcM_CheckCondition(this, 8)) { + new (this) daTagMist_c(); + fopAcM_OnCondition(this, 8); + } -/* 8048F518-8048F554 000338 003C+00 1/1 0/0 0/0 .text __dt__4cXyzFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm cXyz::~cXyz() { - nofralloc -#include "asm/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist/__dt__4cXyzFv.s" -} -#pragma pop + if (!mInitParams) { + mInitParams = true; -/* 8048F554-8048F558 000374 0004+00 1/1 0/0 0/0 .text __ct__4cXyzFv */ -cXyz::cXyz() { - /* empty function */ + field_0x5a2 = orig.angle.x; + field_0x5a4 = orig.angle.z; + + orig.angle.z = 0; + orig.angle.x = 0; + current.angle.z = 0; + current.angle.x = 0; + shape_angle.z = 0; + shape_angle.x = 0; + } + + if (!Create()) { + return cPhs_ERROR_e; + } + + return cPhs_COMPLEATE_e; } /* 8048F558-8048F690 000378 0138+00 1/1 0/0 0/0 .text execute__11daTagMist_cFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daTagMist_c::execute() { - nofralloc -#include "asm/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist/execute__11daTagMist_cFv.s" +int daTagMist_c::execute() { + if (i_fopAcM_isSwitch(this, daTagMist_prm::getSwNo2(this))) { + return 1; + } + + fopAc_ac_c* player_p = dComIfGp_getPlayer(0); + cXyz player_dist(player_p->current.pos); + player_dist -= orig.pos; + + mDoMtx_stack_c::YrotS(-current.angle.y); + mDoMtx_stack_c::multVec(&player_dist, &player_dist); + + u8 player_inside = (mVertices[0].x < player_dist.x && mVertices[0].z < player_dist.z) && + (mVertices[2].x > player_dist.x && mVertices[2].z > player_dist.z); + + if (player_inside && !mPlayerTouched) { + offSw(); + onMySw(); + mPlayerNo = daTagMist_prm::getExitNo(this); + } + + mPlayerTouched = player_inside; + return 1; } -#pragma pop /* 8048F690-8048F698 0004B0 0008+00 1/1 0/0 0/0 .text _delete__11daTagMist_cFv */ -bool daTagMist_c::_delete() { - return true; +int daTagMist_c::_delete() { + return 1; } /* 8048F698-8048F6B8 0004B8 0020+00 1/0 0/0 0/0 .text daTagMist_Execute__FP11daTagMist_c */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void daTagMist_Execute(daTagMist_c* param_0) { - nofralloc -#include "asm/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist/daTagMist_Execute__FP11daTagMist_c.s" +static int daTagMist_Execute(daTagMist_c* i_this) { + return i_this->execute(); } -#pragma pop /* 8048F6B8-8048F6D8 0004D8 0020+00 1/0 0/0 0/0 .text daTagMist_Delete__FP11daTagMist_c */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void daTagMist_Delete(daTagMist_c* param_0) { - nofralloc -#include "asm/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist/daTagMist_Delete__FP11daTagMist_c.s" +static int daTagMist_Delete(daTagMist_c* i_this) { + return i_this->_delete(); } -#pragma pop /* 8048F6D8-8048F6F8 0004F8 0020+00 1/0 0/0 0/0 .text daTagMist_Create__FP10fopAc_ac_c */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void daTagMist_Create(fopAc_ac_c* param_0) { - nofralloc -#include "asm/rel/d/a/tag/d_a_tag_mist/d_a_tag_mist/daTagMist_Create__FP10fopAc_ac_c.s" +static int daTagMist_Create(fopAc_ac_c* i_this) { + return static_cast(i_this)->create(); } -#pragma pop /* ############################################################################################## */ /* 8048F70C-8048F72C -00001 0020+00 1/0 0/0 0/0 .data l_daTagMist_Method */ -SECTION_DATA static void* l_daTagMist_Method[8] = { - (void*)daTagMist_Create__FP10fopAc_ac_c, - (void*)daTagMist_Delete__FP11daTagMist_c, - (void*)daTagMist_Execute__FP11daTagMist_c, - (void*)NULL, - (void*)NULL, - (void*)NULL, - (void*)NULL, - (void*)NULL, +static actor_method_class l_daTagMist_Method = { + (process_method_func)daTagMist_Create, + (process_method_func)daTagMist_Delete, + (process_method_func)daTagMist_Execute, + (process_method_func)NULL, + (process_method_func)NULL, }; /* 8048F72C-8048F75C -00001 0030+00 0/0 0/0 1/0 .data g_profile_Tag_Mist */ -SECTION_DATA extern void* g_profile_Tag_Mist[12] = { - (void*)0xFFFFFFFD, (void*)0x0007FFFD, - (void*)0x02D70000, (void*)&g_fpcLf_Method, - (void*)0x000005A8, (void*)NULL, - (void*)NULL, (void*)&g_fopAc_Method, - (void*)0x01240000, (void*)&l_daTagMist_Method, - (void*)0x00040000, (void*)0x000E0000, +extern actor_process_profile_definition g_profile_Tag_Mist = { + -3, + 7, + -3, + PROC_Tag_Mist, + &g_fpcLf_Method.mBase, + sizeof(daTagMist_c), + 0, + 0, + &g_fopAc_Method.base, + 292, + &l_daTagMist_Method, + 0x40000, + 0, + 14, };