diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 0738826f..9ef4c36b 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -72,6 +72,7 @@ d/d_base.cpp: d/d_cc.cpp: .text start:0x80050A20 end:0x800520F0 + .data start:0x805033D0 end:0x805033F0 d/d_dvd.cpp: .text start:0x800520F0 end:0x800522FC @@ -804,7 +805,7 @@ DynamicLink.cpp: .sbss start:0x80575B80 end:0x80575BA0 c/c_list.cpp: - .text start:0x802E08C0 end:0x802E0A10 + .text start:0x802E08C0 end:0x802E0A50 c/c_tree.cpp: .text start:0x802E0E70 end:0x802E1140 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index f9eb3290..18acb3b2 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -2115,30 +2115,30 @@ fn_800515D0 = .text:0x800515D0; // type:function size:0x60 fn_800051630__13dAcObjRef_unkFv = .text:0x80051630; // type:function size:0x144 fn_80051780__13dAcObjRef_unkFRC8cCcD_Obj = .text:0x80051780; // type:function size:0x464 fn_80051BF0 = .text:0x80051BF0; // type:function size:0x8 -fn_80051C00 = .text:0x80051C00; // type:function size:0x4C -InitColliderAndAddToFront = .text:0x80051C50; // type:function size:0x5C -fn_80051CB0 = .text:0x80051CB0; // type:function size:0x5C -InitCollider2AndAddToFront = .text:0x80051D10; // type:function size:0x5C -addCc__18ColliderLinkedListFR14LinkedColliderRC11dCcD_SrcUnk = .text:0x80051D70; // type:function size:0x5C -fn_80051DD0 = .text:0x80051DD0; // type:function size:0x64 -fn_80051E40 = .text:0x80051E40; // type:function size:0x64 -ColliderManager__staticAddCollider = .text:0x80051EB0; // type:function size:0x34 +postInit__18ColliderLinkedListFR8cCcD_Obj = .text:0x80051C00; // type:function size:0x4C +addCc__18ColliderLinkedListFR17LinkedColliderCylRC11dCcD_SrcCyl = .text:0x80051C50; // type:function size:0x5C +addCc__18ColliderLinkedListFR17LinkedColliderSphRC11dCcD_SrcSph = .text:0x80051CB0; // type:function size:0x5C +addCc__18ColliderLinkedListFR17LinkedColliderCpsRC11dCcD_SrcCps = .text:0x80051D10; // type:function size:0x5C +addCc__18ColliderLinkedListFR17LinkedColliderUnkRC11dCcD_SrcUnk = .text:0x80051D70; // type:function size:0x5C +foreachCc__18ColliderLinkedListCFPFP8cCcD_ObjPv_vPv = .text:0x80051DD0; // type:function size:0x64 +foreachCc2__18ColliderLinkedListCFPFP8cCcD_ObjPv_vPv = .text:0x80051E40; // type:function size:0x64 +Set__18ColliderLinkedListFP8cCcD_ObjPv = .text:0x80051EB0; // type:function size:0x34 registerColliders__18ColliderLinkedListFv = .text:0x80051EF0; // type:function size:0x10 -fn_80051F00 = .text:0x80051F00; // type:function size:0x8 +SetStts__18ColliderLinkedListFP8cCcD_ObjPv = .text:0x80051F00; // type:function size:0x8 SetStts__18ColliderLinkedListFR9cCcD_Stts = .text:0x80051F10; // type:function size:0x10 -ColliderLinkedList__search = .text:0x80051F20; // type:function size:0x74 -fn_80051FA0 = .text:0x80051FA0; // type:function size:0x1C -fn_80051FC0 = .text:0x80051FC0; // type:function size:0x10 -fn_80051FD0 = .text:0x80051FD0; // type:function size:0x10 -fn_80051FE0 = .text:0x80051FE0; // type:function size:0x10 -fn_80051FF0 = .text:0x80051FF0; // type:function size:0x1C -fn_80052010 = .text:0x80052010; // type:function size:0x10 -fn_80052020 = .text:0x80052020; // type:function size:0x10 -fn_80052030 = .text:0x80052030; // type:function size:0x10 -fn_80052040 = .text:0x80052040; // type:function size:0x1C -fn_80052060 = .text:0x80052060; // type:function size:0x10 -fn_80052070 = .text:0x80052070; // type:function size:0x10 -fn_80052080 = .text:0x80052080; // type:function size:0x10 +find__18ColliderLinkedListCFM8cCcD_ObjFPCvPv_b = .text:0x80051F20; // type:function size:0x74 +AtSet__18ColliderLinkedListFP8cCcD_ObjPv = .text:0x80051FA0; // type:function size:0x1C +AtSet__18ColliderLinkedListFv = .text:0x80051FC0; // type:function size:0x10 +ClrAt__18ColliderLinkedListFP8cCcD_ObjPv = .text:0x80051FD0; // type:function size:0x10 +ClrAt__18ColliderLinkedListFv = .text:0x80051FE0; // type:function size:0x10 +TgSet__18ColliderLinkedListFP8cCcD_ObjPv = .text:0x80051FF0; // type:function size:0x1C +TgSet__18ColliderLinkedListFv = .text:0x80052010; // type:function size:0x10 +ClrTg__18ColliderLinkedListFP8cCcD_ObjPv = .text:0x80052020; // type:function size:0x10 +ClrTg__18ColliderLinkedListFv = .text:0x80052030; // type:function size:0x10 +CoSet__18ColliderLinkedListFP8cCcD_ObjPv = .text:0x80052040; // type:function size:0x1C +CoSet__18ColliderLinkedListFv = .text:0x80052060; // type:function size:0x10 +ClrCo__18ColliderLinkedListFP8cCcD_ObjPv = .text:0x80052070; // type:function size:0x10 +ClrCo__18ColliderLinkedListFv = .text:0x80052080; // type:function size:0x10 __dt__18ColliderLinkedListFv = .text:0x80052090; // type:function size:0x60 create__4dDvdFlPQ23EGG4HeapPQ23EGG4HeapPQ23EGG4Heap = .text:0x800520F0; // type:function size:0x4 __ct__Q24dDvd8loader_cFv = .text:0x80052100; // type:function size:0x28 @@ -14245,7 +14245,7 @@ hasCollectedAllTears__9dAcTbox_cFv = .text:0x80268680; // type:function size:0x1 getGroundHeight__9dAcTbox_cFPfRC7mVec3_c = .text:0x802686A0; // type:function size:0x50 isBelowGroundAtPos__9dAcTbox_cFfRC7mVec3_c = .text:0x802686F0; // type:function size:0x5C __ct__9dAcTbox_cFv = .text:0x80268750; // type:function size:0x2EC -__dt__14LinkedColliderFv = .text:0x80268A40; // type:function size:0x98 +__dt__17LinkedColliderUnkFv = .text:0x80268A40; // type:function size:0x98 __dt__21sFState_c<9dAcTbox_c>Fv = .text:0x80268AE0; // type:function size:0x58 __dt__24sFStateFct_c<9dAcTbox_c>Fv = .text:0x80268B40; // type:function size:0x6C __dt__77sStateMgr_c<9dAcTbox_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x80268BB0; // type:function size:0xA0 @@ -14367,8 +14367,8 @@ initializeState__23sFStateID_c<9dAcTbox_c>CFR9dAcTbox_c = .text:0x8026E8D0; // t __sinit_\d_a_obj_tbox_cpp = .text:0x8026E900; // type:function size:0xA7C scope:local __dt__23sFStateID_c<9dAcTbox_c>Fv = .text:0x8026F380; // type:function size:0x58 isSameName__23sFStateID_c<9dAcTbox_c>CFPCc = .text:0x8026F3E0; // type:function size:0x88 -@316@__dt__14LinkedColliderFv = .text:0x8026F470; // type:function size:0x8 -@272@__dt__14LinkedColliderFv = .text:0x8026F480; // type:function size:0x8 +@316@__dt__17LinkedColliderUnkFv = .text:0x8026F470; // type:function size:0x8 +@272@__dt__17LinkedColliderUnkFv = .text:0x8026F480; // type:function size:0x8 AcTimeArea__ctor = .text:0x8026F490; // type:function size:0x1A8 fn_8026F640 = .text:0x8026F640; // type:function size:0x58 fn_8026F6A0 = .text:0x8026F6A0; // type:function size:0x6C @@ -17284,7 +17284,7 @@ insertAfter__9cListMg_cFP9cListNd_cP9cListNd_c = .text:0x802E08C0; // type:funct remove__9cListMg_cFP9cListNd_c = .text:0x802E0900; // type:function size:0xAC append__9cListMg_cFP9cListNd_c = .text:0x802E09B0; // type:function size:0x30 prepend__9cListMg_cFP9cListNd_c = .text:0x802E09E0; // type:function size:0x30 -ListLink__clear = .text:0x802E0A10; // type:function size:0x40 +clear__9cListMg_cFv = .text:0x802E0A10; // type:function size:0x40 cM__rad2s = .text:0x802E0A50; // type:function size:0x5C cM__U_GetAtanTable = .text:0x802E0AB0; // type:function size:0x34 atan2s__2cMFff = .text:0x802E0AF0; // type:function size:0x1BC @@ -30060,7 +30060,7 @@ lbl_80503278 = .data:0x80503278; // type:object size:0x9C lbl_80503314 = .data:0x80503314; // type:object size:0x6C __vt__7dBase_c = .data:0x80503380; // type:object size:0x4C lbl_805033D0 = .data:0x805033D0; // type:object size:0x10 -__vt__18ColliderLinkedList = .data:0x805033E0; // type:object size:0x10 +__vt__18ColliderLinkedList = .data:0x805033E0; // type:object size:0xC __vt__Q24dDvd8loader_c = .data:0x805033F0; // type:object size:0x10 lbl_80503400 = .data:0x80503400; // type:object size:0x40 lbl_80503440 = .data:0x80503440; // type:object size:0x6DF8 @@ -34484,7 +34484,7 @@ __vt__47sFStateMgr_c<9dAcTbox_c,20sStateMethodUsr_FI_c> = .data:0x80535540; // t __vt__77sStateMgr_c<9dAcTbox_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x80535570; // type:object size:0x30 __vt__24sFStateFct_c<9dAcTbox_c> = .data:0x805355A0; // type:object size:0x14 __vt__21sFState_c<9dAcTbox_c> = .data:0x805355B8; // type:object size:0x18 -__vt__14LinkedCollider = .data:0x805355D0; // type:object size:0x7C +__vt__17LinkedColliderUnk = .data:0x805355D0; // type:object size:0x7C __vt__23sFStateID_c<9dAcTbox_c> = .data:0x805359E0; // type:object size:0x34 g_profile_TIME_AREA = .data:0x80535A18; // type:object size:0x10 lbl_80535A28 = .data:0x80535A28; // type:object size:0x68 diff --git a/configure.py b/configure.py index fb777b61..9044d9bd 100644 --- a/configure.py +++ b/configure.py @@ -314,6 +314,7 @@ config.libs = [ Object(Matching, "d/flag/flag_managers.cpp"), Object(NonMatching, "toBeSorted/special_item_drop_mgr.cpp"), Object(Matching, "d/d_base.cpp"), + Object(NonMatching, "d/d_cc.cpp"), Object(Matching, "d/d_dvd.cpp"), Object(NonMatching, "d/d_dvd_unk.cpp"), Object(NonMatching, "d/d_dylink.cpp"), diff --git a/include/c/c_list.h b/include/c/c_list.h index 8fdba626..2c45d27d 100644 --- a/include/c/c_list.h +++ b/include/c/c_list.h @@ -57,6 +57,8 @@ public: */ void prepend(cListNd_c *node); + void clear(); + cListNd_c *getFirst() const { return mpFirst; } diff --git a/include/d/a/obj/d_a_obj_tbox.h b/include/d/a/obj/d_a_obj_tbox.h index 255d868b..eaccca94 100644 --- a/include/d/a/obj/d_a_obj_tbox.h +++ b/include/d/a/obj/d_a_obj_tbox.h @@ -148,8 +148,8 @@ private: s32 field_0x4F4; /* 0x04F8 */ dBgW mBgWs[2]; - /* 0x0918 */ LinkedCollider mCcD1; - /* 0x0B30 */ LinkedCollider mCcD2; + /* 0x0918 */ LinkedColliderUnk mCcD1; + /* 0x0B30 */ LinkedColliderUnk mCcD2; /* 0x0D48 */ ColliderLinkedList field_0x0D48; /* 0x0D54 */ dCcD_Unk mCcD3; /* 0x0F5C */ dCcD_Cyl mCcD4; diff --git a/include/d/col/c/c_cc_d.h b/include/d/col/c/c_cc_d.h index 49791e31..b9d9daa4 100644 --- a/include/d/col/c/c_cc_d.h +++ b/include/d/col/c/c_cc_d.h @@ -883,6 +883,12 @@ public: u32 ChkAtNoGaurd() const { return mAt.MskSPrm(0x200000); } + void SetAt_0x40000000() { + mAt.OnSPrm(0x40000000); + } + u32 ChkAt_0x40000000() { + return mAt.MskSPrm(0x40000000); + } // Tg @@ -908,6 +914,12 @@ public: void SetTgInfo_0x2(u16 val) { mTg.SetInfo_0x2(val); } + void SetTg_0x40000000() { + mTg.OnSPrm(0x40000000); + } + u32 ChkTg_0x40000000() { + return mTg.MskSPrm(0x40000000); + } // Co @@ -929,6 +941,12 @@ public: void SetCo_0x400() { mCo.OnSPrm(0x400); } + void SetCo_0x40000000() { + mCo.OnSPrm(0x40000000); + } + u32 ChkCo_0x40000000() { + return mCo.MskSPrm(0x40000000); + } /** * SET HIT diff --git a/include/d/d_cc.h b/include/d/d_cc.h index e150555f..2d2f39a4 100644 --- a/include/d/d_cc.h +++ b/include/d/d_cc.h @@ -5,28 +5,97 @@ #include "d/col/c/c_cc_d.h" #include "d/col/cc/d_cc_d.h" -// Somewhere in d_cc -class LinkedCollider : public dCcD_Unk { +class LinkedColliderNode : public cListNd_c { public: - LinkedCollider() : mpList(nullptr), field_0x210(this) {} - virtual ~LinkedCollider() { + LinkedColliderNode(cCcD_Obj *obj) : mpList(nullptr), mpCcDObj(obj) {} + void remove() { if (mpList != nullptr) { - mpList->remove(&mNode); + mpList->remove(this); mpList = nullptr; } } - /* 0x208 */ cListNd_c mNode; - /* 0x210 */ dCcD_Unk *field_0x210; - /* 0x214 */ cListMg_c *mpList; + /* 0x08 */ cCcD_Obj *mpCcDObj; + /* 0x0C */ cListMg_c *mpList; }; -struct ColliderLinkedList { +class LinkedColliderUnk : public dCcD_Unk { +public: + LinkedColliderUnk() : mNode(this) {} + virtual ~LinkedColliderUnk() { + mNode.remove(); + } + /* 0x210 */ LinkedColliderNode mNode; +}; + +class LinkedColliderCyl : public dCcD_Cyl { +public: + LinkedColliderCyl() : mNode(this) {} + virtual ~LinkedColliderCyl() { + mNode.remove(); + } + /* 0x150 */ LinkedColliderNode mNode; +}; + +class LinkedColliderSph : public dCcD_Sph { +public: + LinkedColliderSph() : mNode(this) {} + virtual ~LinkedColliderSph() { + mNode.remove(); + } + /* 0x150 */ LinkedColliderNode mNode; +}; + +class LinkedColliderCps : public dCcD_Cps { +public: + LinkedColliderCps() : mNode(this) {} + virtual ~LinkedColliderCps() { + mNode.remove(); + } + /* 0x170 */ LinkedColliderNode mNode; +}; + +class ColliderLinkedList { +private: cListMg_c mList; + static void Set(cCcD_Obj *obj, void *cbArg); + static void SetStts(cCcD_Obj *obj, void *cbArg); + static void AtSet(cCcD_Obj *obj, void *cbArg); + static void ClrAt(cCcD_Obj *obj, void *cbArg); + static void TgSet(cCcD_Obj *obj, void *cbArg); + static void ClrTg(cCcD_Obj *obj, void *cbArg); + static void CoSet(cCcD_Obj *obj, void *cbArg); + static void ClrCo(cCcD_Obj *obj, void *cbArg); + +public: virtual ~ColliderLinkedList(); - void addCc(LinkedCollider &ccD, const dCcD_SrcUnk &src); + void postInit(cCcD_Obj &ccD); + void addCc(LinkedColliderCyl &ccD, const dCcD_SrcCyl &src); + void addCc(LinkedColliderSph &ccD, const dCcD_SrcSph &src); + void addCc(LinkedColliderCps &ccD, const dCcD_SrcCps &src); + void addCc(LinkedColliderUnk &ccD, const dCcD_SrcUnk &src); void SetStts(cCcD_Stts &stts); void registerColliders(); + + typedef void (*ccCbFunc)(cCcD_Obj *obj, void *cbArg); + void foreachCc(ccCbFunc f, void *cbArg) const; + void foreachCc2(ccCbFunc f, void *cbArg) const; + + // This find function is used by a lot of other + // TUs, all of which own the function passed as + // a ptmf. It's not immediately clear how this works, + // does every actor subclass the LinkedCollider___, + // or are the functions all added here for the other + // files to implement? + typedef bool (cCcD_Obj::*ccPtmf)(); + cCcD_Obj *find(ccPtmf f) const; + + void AtSet(); + void ClrAt(); + void TgSet(); + void ClrTg(); + void CoSet(); + void ClrCo(); }; #endif diff --git a/src/c/c_list.cpp b/src/c/c_list.cpp index 61929a5f..fe0330e9 100644 --- a/src/c/c_list.cpp +++ b/src/c/c_list.cpp @@ -74,3 +74,9 @@ void cListMg_c::prepend(cListNd_c *node) { } this->mpFirst = node; } + +void cListMg_c::clear() { + while (mpFirst != nullptr) { + remove(mpFirst); + } +} diff --git a/src/d/d_cc.cpp b/src/d/d_cc.cpp new file mode 100644 index 00000000..01218cf5 --- /dev/null +++ b/src/d/d_cc.cpp @@ -0,0 +1,157 @@ +#include "d/d_cc.h" + +#include "common.h" +#include "d/col/c/c_cc_d.h" +#include "d/col/cc/d_cc_d.h" +#include "d/col/cc/d_cc_s.h" + + +void ColliderLinkedList::postInit(cCcD_Obj &ccD) { + if (ccD.ChkAtSet()) { + ccD.SetAt_0x40000000(); + } + if (ccD.ChkTgSet()) { + ccD.SetTg_0x40000000(); + } + if (ccD.ChkCoSet()) { + ccD.SetCo_0x40000000(); + } +} + +void ColliderLinkedList::addCc(LinkedColliderCyl &ccD, const dCcD_SrcCyl &src) { + ccD.Set(src); + mList.append(&ccD.mNode); + ccD.mNode.mpList = &mList; + postInit(ccD); +} + +void ColliderLinkedList::addCc(LinkedColliderSph &ccD, const dCcD_SrcSph &src) { + ccD.Set(src); + mList.append(&ccD.mNode); + ccD.mNode.mpList = &mList; + postInit(ccD); +} + +void ColliderLinkedList::addCc(LinkedColliderCps &ccD, const dCcD_SrcCps &src) { + ccD.Set(src); + mList.append(&ccD.mNode); + ccD.mNode.mpList = &mList; + postInit(ccD); +} + +void ColliderLinkedList::addCc(LinkedColliderUnk &ccD, const dCcD_SrcUnk &src) { + ccD.Set(src); + mList.append(&ccD.mNode); + ccD.mNode.mpList = &mList; + postInit(ccD); +} + +void ColliderLinkedList::foreachCc(ccCbFunc f, void *cbArg) const { + LinkedColliderNode *nd = static_cast(mList.getFirst()); + while (nd != nullptr) { + f(nd->mpCcDObj, cbArg); + nd = static_cast(nd->getNext()); + } +} + +// What's the difference between these two? +void ColliderLinkedList::foreachCc2(ccCbFunc f, void *cbArg) const { + LinkedColliderNode *nd = static_cast(mList.getFirst()); + while (nd != nullptr) { + f(nd->mpCcDObj, cbArg); + nd = static_cast(nd->getNext()); + } +} + +void ColliderLinkedList::Set(cCcD_Obj *obj, void *cbArg) { + dCcS::GetInstance()->Set(obj); +} + +void ColliderLinkedList::registerColliders() { + foreachCc(Set, nullptr); +} + +void ColliderLinkedList::SetStts(cCcD_Obj *obj, void *cbArg) { + obj->SetStts(*static_cast(cbArg)); +} + +void ColliderLinkedList::SetStts(cCcD_Stts &stts) { + foreachCc(SetStts, &stts); +} + +cCcD_Obj *ColliderLinkedList::find(ccPtmf f) const { + cCcD_Obj *o; + LinkedColliderNode *nd = static_cast(mList.getFirst()); + while (nd != nullptr) { + o = nd->mpCcDObj; + if ((o->*f)()) { + return o; + } + nd = static_cast(nd->getNext()); + } + return nullptr; +} + +void ColliderLinkedList::AtSet(cCcD_Obj *obj, void *cbArg) { + if (!obj->ChkAt_0x40000000()) { + return; + } + obj->OnAtSet(); +} + +void ColliderLinkedList::AtSet() { + foreachCc(AtSet, nullptr); +} + +void ColliderLinkedList::ClrAt(cCcD_Obj *obj, void *cbArg) { + obj->ClrAtSet(); + obj->ClrAtHit(); +} + +void ColliderLinkedList::ClrAt() { + foreachCc(ClrAt, nullptr); +} + +void ColliderLinkedList::TgSet(cCcD_Obj *obj, void *cbArg) { + if (!obj->ChkTg_0x40000000()) { + return; + } + obj->OnTgSet(); +} + +void ColliderLinkedList::TgSet() { + foreachCc(TgSet, nullptr); +} + +void ColliderLinkedList::ClrTg(cCcD_Obj *obj, void *cbArg) { + obj->ClrTgSet(); + obj->ClrTgHit(); +} + +void ColliderLinkedList::ClrTg() { + foreachCc(ClrTg, nullptr); +} + +void ColliderLinkedList::CoSet(cCcD_Obj *obj, void *cbArg) { + if (!obj->ChkCo_0x40000000()) { + return; + } + obj->OnCoSet(); +} + +void ColliderLinkedList::CoSet() { + foreachCc(CoSet, nullptr); +} + +void ColliderLinkedList::ClrCo(cCcD_Obj *obj, void *cbArg) { + obj->ClrCoSet(); + obj->ClrCoHit(); +} + +void ColliderLinkedList::ClrCo() { + foreachCc(ClrCo, nullptr); +} + +ColliderLinkedList::~ColliderLinkedList() { + mList.clear(); +}