diff --git a/include/d/d_path.h b/include/d/d_path.h index e3c17df3b93..0ff854677dc 100644 --- a/include/d/d_path.h +++ b/include/d/d_path.h @@ -18,5 +18,6 @@ struct dPath { inline int dPath_ChkClose(dPath* i_path) { return (i_path->m_closed & 1); } dPath* dPath_GetRoomPath(int path_index, int room_no); +dStage_dPnt_c* dPath_GetPnt(dPath const* path, int pnt_index); #endif /* D_D_PATH_H */ diff --git a/include/rel/d/a/tag/d_a_tag_guard/d_a_tag_guard.h b/include/rel/d/a/tag/d_a_tag_guard/d_a_tag_guard.h index 324c4396708..f71874c8209 100644 --- a/include/rel/d/a/tag/d_a_tag_guard/d_a_tag_guard.h +++ b/include/rel/d/a/tag/d_a_tag_guard/d_a_tag_guard.h @@ -1,6 +1,19 @@ #ifndef D_A_TAG_GUARD_H #define D_A_TAG_GUARD_H -#include "dolphin/types.h" +#include "f_op/f_op_actor_mng.h" +#include "d/d_path.h" + +class daTagGuard_c : public fopAc_ac_c { +public: + /* 80D597F8 */ int getAppearPoint(Vec*); + /* 80D5985C */ void createGuard(u32); + + u8 getPathID() { return fopAcM_GetParam(this) >> 8; } + inline int create(); + inline void create_init(); + + /* 0x568 */ dPath* mPath; +}; // Size: 0x56C #endif /* D_A_TAG_GUARD_H */ diff --git a/rel/d/a/tag/d_a_tag_guard/d_a_tag_guard.cpp b/rel/d/a/tag/d_a_tag_guard/d_a_tag_guard.cpp index 112d0e08a94..055c5248d60 100644 --- a/rel/d/a/tag/d_a_tag_guard/d_a_tag_guard.cpp +++ b/rel/d/a/tag/d_a_tag_guard/d_a_tag_guard.cpp @@ -1,122 +1,97 @@ -// -// Generated By: dol2asm -// Translation Unit: d_a_tag_guard -// +/** + * d_a_tag_guard.cpp + * + */ #include "rel/d/a/tag/d_a_tag_guard/d_a_tag_guard.h" -#include "dol2asm.h" -#include "dolphin/types.h" +#include "d/d_procname.h" -// -// Types: -// - -struct fopAc_ac_c { - /* 80018B64 */ fopAc_ac_c(); - /* 80018C8C */ ~fopAc_ac_c(); -}; - -struct Vec {}; - -struct daTagGuard_c { - /* 80D597F8 */ void getAppearPoint(Vec*); - /* 80D5985C */ void createGuard(u32); -}; - -struct dPath {}; - -struct csXyz {}; - -struct cXyz {}; - -// -// Forward References: -// - -extern "C" void getAppearPoint__12daTagGuard_cFP3Vec(); -extern "C" void createGuard__12daTagGuard_cFUl(); -extern "C" static void daTagGuard_Create__FP10fopAc_ac_c(); -extern "C" static void daTagGuard_Delete__FP12daTagGuard_c(); -extern "C" extern void* g_profile_TAG_GUARD[12]; - -// -// External References: -// - -extern "C" void __ct__10fopAc_ac_cFv(); -extern "C" void __dt__10fopAc_ac_cFv(); -extern "C" void fopAcM_createChild__FsUiUlPC4cXyziPC5csXyzPC4cXyzScPFPv_i(); -extern "C" void dPath_GetPnt__FPC5dPathi(); -extern "C" void dPath_GetRoomPath__Fii(); -extern "C" void cLib_targetAngleY__FPC3VecPC3Vec(); -extern "C" extern void* g_fopAc_Method[8]; -extern "C" extern void* g_fpcLf_Method[5 + 1 /* padding */]; - -// -// Declarations: -// +extern "C" extern leafdraw_method_class g_fopAc_Method; /* 80D597F8-80D5985C 000078 0064+00 0/0 0/0 1/1 .text getAppearPoint__12daTagGuard_cFP3Vec */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daTagGuard_c::getAppearPoint(Vec* param_0) { - nofralloc -#include "asm/rel/d/a/tag/d_a_tag_guard/d_a_tag_guard/getAppearPoint__12daTagGuard_cFP3Vec.s" +int daTagGuard_c::getAppearPoint(Vec* i_appearPnt) { + if (mPath == NULL) { + return 0; + } + + *i_appearPnt = dPath_GetPnt(mPath, mPath->m_num - 1)->m_position; + return 1; } -#pragma pop /* 80D5985C-80D59928 0000DC 00CC+00 0/0 0/0 1/1 .text createGuard__12daTagGuard_cFUl */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void daTagGuard_c::createGuard(u32 param_0) { - nofralloc -#include "asm/rel/d/a/tag/d_a_tag_guard/d_a_tag_guard/createGuard__12daTagGuard_cFUl.s" +void daTagGuard_c::createGuard(u32 i_parameters) { + cXyz pos = current.pos; + + if (getPathID() != 0xFF) { + pos = dPath_GetPnt(mPath, 0)->m_position; + i_parameters |= (getPathID() << 0x10); + } + + fopAcM_createChild(PROC_NPC_GUARD, fopAcM_GetID(this), i_parameters, &pos, + fopAcM_GetRoomNo(this), ¤t.angle, NULL, -1, NULL); +} + +int daTagGuard_c::create() { + if (!fopAcM_CheckCondition(this, 8)) { + new (this) daTagGuard_c(); + fopAcM_OnCondition(this, 8); + } + + create_init(); + return cPhs_COMPLEATE_e; +} + +void daTagGuard_c::create_init() { + mPath = dPath_GetRoomPath(getPathID(), fopAcM_GetHomeRoomNo(this)); + + dStage_dPnt_c* pnt1 = dPath_GetPnt(mPath, 0); + dStage_dPnt_c* pnt2 = dPath_GetPnt(mPath, 1); + + current.pos.x = pnt1->m_position.x; + current.pos.y = pnt1->m_position.y; + current.pos.z = pnt1->m_position.z; + current.angle.y = cLib_targetAngleY(&pnt1->m_position, &pnt2->m_position); } -#pragma pop /* 80D59928-80D599E0 0001A8 00B8+00 1/0 0/0 0/0 .text daTagGuard_Create__FP10fopAc_ac_c */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void daTagGuard_Create(fopAc_ac_c* param_0) { - nofralloc -#include "asm/rel/d/a/tag/d_a_tag_guard/d_a_tag_guard/daTagGuard_Create__FP10fopAc_ac_c.s" +static int daTagGuard_Create(fopAc_ac_c* i_this) { + return static_cast(i_this)->create(); } -#pragma pop /* 80D599E0-80D59A10 000260 0030+00 1/0 0/0 0/0 .text daTagGuard_Delete__FP12daTagGuard_c */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -static asm void daTagGuard_Delete(daTagGuard_c* param_0) { - nofralloc -#include "asm/rel/d/a/tag/d_a_tag_guard/d_a_tag_guard/daTagGuard_Delete__FP12daTagGuard_c.s" +static int daTagGuard_Delete(daTagGuard_c* i_this) { + i_this->~daTagGuard_c(); + return 1; } -#pragma pop /* ############################################################################################## */ /* 80D59A18-80D59A38 -00001 0020+00 1/0 0/0 0/0 .data l_daTagGuard_Method */ -SECTION_DATA static void* l_daTagGuard_Method[8] = { - (void*)daTagGuard_Create__FP10fopAc_ac_c, - (void*)daTagGuard_Delete__FP12daTagGuard_c, - (void*)NULL, - (void*)NULL, - (void*)NULL, - (void*)NULL, - (void*)NULL, - (void*)NULL, +static actor_method_class l_daTagGuard_Method = { + (process_method_func)daTagGuard_Create, + (process_method_func)daTagGuard_Delete, }; /* 80D59A38-80D59A68 -00001 0030+00 0/0 0/0 1/0 .data g_profile_TAG_GUARD */ -SECTION_DATA extern void* g_profile_TAG_GUARD[12] = { - (void*)0xFFFFFFFD, (void*)0x0007FFFD, - (void*)0x02960000, (void*)&g_fpcLf_Method, - (void*)0x0000056C, (void*)NULL, - (void*)NULL, (void*)&g_fopAc_Method, - (void*)0x01980000, (void*)&l_daTagGuard_Method, - (void*)0x00040000, (void*)0x000E0000, +extern actor_process_profile_definition g_profile_TAG_GUARD = { + -3, + 7, + -3, + PROC_TAG_GUARD, + 0, + &g_fpcLf_Method.mBase, + sizeof(daTagGuard_c), + 0, + 0, + &g_fopAc_Method, + 0x0198, + 0, + 0, + &l_daTagGuard_Method, + 0x00040000, + 0x00, + 0x0E, + 0, + 0, };