From cf50f63c42ae805a6fbde397364298e8f2575242 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sun, 20 Sep 2026 19:56:00 -0700 Subject: [PATCH] Match d_a_tag_ba1 (#1211) * Match d_a_tag_ba1 * Don't link against D44J01 * Format nits --- configure.py | 2 +- include/d/actor/d_a_tag_ba1.h | 20 ++++++--- src/d/actor/d_a_tag_ba1.cpp | 84 ++++++++++++++++++++++++++++------- 3 files changed, 83 insertions(+), 23 deletions(-) diff --git a/configure.py b/configure.py index b861a2e79..35cef2d8e 100755 --- a/configure.py +++ b/configure.py @@ -1530,7 +1530,7 @@ config.libs = [ ActorRel(Matching, "d_a_swhit0"), ActorRel(Matching, "d_a_swtdoor"), ActorRel(Matching, "d_a_tag_attention"), - ActorRel(NonMatching, "d_a_tag_ba1"), + ActorRel(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d_a_tag_ba1"), ActorRel(Matching, "d_a_tag_event"), ActorRel(Matching, "d_a_tag_evsw"), ActorRel(Matching, "d_a_tag_ghostship"), diff --git a/include/d/actor/d_a_tag_ba1.h b/include/d/actor/d_a_tag_ba1.h index e5395f720..044708429 100644 --- a/include/d/actor/d_a_tag_ba1.h +++ b/include/d/actor/d_a_tag_ba1.h @@ -5,24 +5,32 @@ class daTag_Ba1_c : public fopAc_ac_c { public: - void XyCheck_cB(int); - void XyEvent_cB(int); - void createInit(); + s16 XyCheck_cB(int); + s16 XyEvent_cB(int); + bool createInit(); BOOL _draw(); BOOL _execute(); BOOL _delete(); cPhs_State _create(); public: - /* Place member variables here */ + /* 0x290 */ s16 mEventIds[1]; + /* 0x292 */ s16 mEventIdx; }; -class daTag_Ba1_HIO_c { +class daTag_Ba1_HIO_c : public JORReflexible { public: + struct hio_prm_c { + /* 0x0 */ u8 field_0x0; + }; + daTag_Ba1_HIO_c(); + virtual ~daTag_Ba1_HIO_c() {} public: - /* Place member variables here */ + /* 0x04 */ s8 mNo; + /* 0x08 */ s32 mRefCount; + /* 0x0C */ hio_prm_c mPrm; }; #endif /* D_A_TAG_BA1_H */ diff --git a/src/d/actor/d_a_tag_ba1.cpp b/src/d/actor/d_a_tag_ba1.cpp index 9263c4e03..163dc20d6 100644 --- a/src/d/actor/d_a_tag_ba1.cpp +++ b/src/d/actor/d_a_tag_ba1.cpp @@ -5,55 +5,107 @@ #include "d/dolzel_rel.h" // IWYU pragma: keep #include "d/actor/d_a_tag_ba1.h" +#include "d/d_item_data.h" +#include "m_Do/m_Do_hostIO.h" + +static daTag_Ba1_HIO_c l_HIO; /* 000000EC-00000144 .text __ct__15daTag_Ba1_HIO_cFv */ -daTag_Ba1_HIO_c::daTag_Ba1_HIO_c() { - /* Nonmatching */ +daTag_Ba1_HIO_c::daTag_Ba1_HIO_c() + : mPrm() { + static hio_prm_c a_prm_tbl = {0}; + memcpy(&mPrm, &a_prm_tbl, sizeof(hio_prm_c)); + mNo = -1; + mRefCount = -1; } /* 00000144-00000164 .text daTag_Ba1_XyCheck_cB__FPvi */ -static void daTag_Ba1_XyCheck_cB(void*, int) { - /* Nonmatching */ +static s16 daTag_Ba1_XyCheck_cB(void* i_this, int i_itemBtn) { + return static_cast(i_this)->XyCheck_cB(i_itemBtn); } /* 00000164-00000184 .text XyCheck_cB__11daTag_Ba1_cFi */ -void daTag_Ba1_c::XyCheck_cB(int) { - /* Nonmatching */ +s16 daTag_Ba1_c::XyCheck_cB(int i_itemBtn) { + return dComIfGp_getSelectItem(i_itemBtn) == dItemNo_FAIRY_BOTTLE_e; } /* 00000184-000001A4 .text daTag_Ba1_XyEvent_cB__FPvi */ -static void daTag_Ba1_XyEvent_cB(void*, int) { - /* Nonmatching */ +static s16 daTag_Ba1_XyEvent_cB(void* i_this, int i_itemBtn) { + return static_cast(i_this)->XyEvent_cB(i_itemBtn); } /* 000001A4-000001C0 .text XyEvent_cB__11daTag_Ba1_cFi */ -void daTag_Ba1_c::XyEvent_cB(int) { - /* Nonmatching */ +s16 daTag_Ba1_c::XyEvent_cB(int /* i_itemBtn */) { + mEventIdx = 0; + return mEventIds[this->mEventIdx]; } +static const char* l_evn_tbl[1] = {"Use_Fairy"}; + /* 000001C0-00000288 .text createInit__11daTag_Ba1_cFv */ -void daTag_Ba1_c::createInit() { - /* Nonmatching */ +bool daTag_Ba1_c::createInit() { + bool needsInit = dComIfGs_isEventBit(dSv_event_flag_c::UNK_0520); + if (!needsInit) { + return needsInit; + } + + needsInit = !dComIfGs_isEventBit(dSv_event_flag_c::GRANDMA_HEALED); + if (needsInit) { + attention_info.flags = fopAc_Attn_ACTION_SPEAK_e; + attention_info.distances[fopAc_Attn_TYPE_SPEAK_e] = 0x1a; + mEventIds[0] = dComIfGp_evmng_getEventIdx(l_evn_tbl[0], 0xff); + eventInfo.setXyCheckCB(daTag_Ba1_XyCheck_cB); + eventInfo.setXyEventCB(daTag_Ba1_XyEvent_cB); + } + + return needsInit; } /* 00000288-00000290 .text _draw__11daTag_Ba1_cFv */ BOOL daTag_Ba1_c::_draw() { - /* Nonmatching */ + return TRUE; } /* 00000290-00000340 .text _execute__11daTag_Ba1_cFv */ BOOL daTag_Ba1_c::_execute() { - /* Nonmatching */ + int staffId = -1; + if (dComIfGp_event_runCheck()) { + if (eventInfo.getCommand() != dEvtCmd_INTALK_e) { + staffId = dComIfGp_evmng_getMyStaffId("TagBa1", NULL, 0); + } + } + + if (staffId >= 0) { + if (dComIfGp_evmng_endCheck(mEventIds[mEventIdx]) != 0) { + dComIfGp_event_onEventFlag(dEvtFlag_UNK8_e); + fopAcM_delete(this); + } + } + + return TRUE; } /* 00000340-00000394 .text _delete__11daTag_Ba1_cFv */ BOOL daTag_Ba1_c::_delete() { - /* Nonmatching */ + if (l_HIO.mRefCount >= 0 && --l_HIO.mRefCount < 0) { + mDoHIO_deleteChild(l_HIO.mNo); + } + + return TRUE; } /* 00000394-00000454 .text _create__11daTag_Ba1_cFv */ cPhs_State daTag_Ba1_c::_create() { - /* Nonmatching */ + if (l_HIO.mRefCount < 0) { + l_HIO.mNo = mDoHIO_createChild("おばあちゃんタグ", &l_HIO); + } + + l_HIO.mRefCount++; + fopAcM_SetupActor(this, daTag_Ba1_c); + if (!createInit()) { + return cPhs_ERROR_e; + } + return cPhs_COMPLEATE_e; } /* 00000454-00000474 .text daTag_Ba1_Create__FP10fopAc_ac_c */