diff --git a/config/eur/arm9/overlays/ov000/symbols.txt b/config/eur/arm9/overlays/ov000/symbols.txt index 0cd78ba5..d33d3aa1 100644 --- a/config/eur/arm9/overlays/ov000/symbols.txt +++ b/config/eur/arm9/overlays/ov000/symbols.txt @@ -2315,7 +2315,7 @@ _ZN5ActorC2Ev kind:function(arm,size=0xe8) addr:0x02098388 _ZN5ActorD1Ev kind:function(arm,size=0x4) addr:0x02098470 _ZN5ActorD0Ev kind:function(arm,size=0x14) addr:0x02098474 _ZN5ActorD2Ev kind:function(arm,size=0x4) addr:0x02098488 -_ZN5Actor19func_ov000_0209848cEP27UnkStruct_ov000_020b539c_30 kind:function(arm,size=0x1c) addr:0x0209848c +_ZN5Actor19func_ov000_0209848cEP9ActorType kind:function(arm,size=0x1c) addr:0x0209848c _ZN5Actor8vfunc_18Ev kind:function(arm,size=0x8) addr:0x020984a8 _ZN5Actor8vfunc_1cEv kind:function(arm,size=0x4) addr:0x020984b0 _ZN5Actor8vfunc_20Ev kind:function(arm,size=0x4) addr:0x020984b4 @@ -3033,7 +3033,7 @@ _ZN23ActorUnk_ov000_020a8bb08vfunc_54Ei kind:function(arm,size=0x4) addr:0x020a8 _ZN23ActorUnk_ov000_020a8bb08vfunc_1cEv kind:function(arm,size=0xc) addr:0x020a8da4 _ZN23ActorUnk_ov000_020a8bb019func_ov000_020a8db0Ev kind:function(arm,size=0x20) addr:0x020a8db0 _ZN23ActorUnk_ov000_020a8bb019func_ov000_020a8dd0Ev kind:function(arm,size=0x20) addr:0x020a8dd0 -_ZN23ActorUnk_ov000_020a8bb019func_ov000_020a8df0Eii kind:function(arm,size=0x94) addr:0x020a8df0 +_ZN23ActorUnk_ov000_020a8bb019func_ov000_020a8df0E8ActorRefi kind:function(arm,size=0x94) addr:0x020a8df0 _ZN23ActorUnk_ov000_020a8bb08vfunc_b4Ev kind:function(arm,size=0x18) addr:0x020a8e84 _ZN23ActorUnk_ov000_020a8bb019func_ov000_020a8e9cEP5Vec3p kind:function(arm,size=0x24) addr:0x020a8e9c _ZN23ActorUnk_ov000_020a8bb08vfunc_b0Ev kind:function(arm,size=0x94) addr:0x020a8ec0 diff --git a/config/jp/arm9/overlays/ov000/symbols.txt b/config/jp/arm9/overlays/ov000/symbols.txt index e3d06c2a..4b1634dd 100644 --- a/config/jp/arm9/overlays/ov000/symbols.txt +++ b/config/jp/arm9/overlays/ov000/symbols.txt @@ -2312,7 +2312,7 @@ _ZN5ActorC2Ev kind:function(arm,size=0xe8) addr:0x02099b30 _ZN5ActorD1Ev kind:function(arm,size=0x4) addr:0x02099c18 _ZN5ActorD0Ev kind:function(arm,size=0x14) addr:0x02099c1c _ZN5ActorD2Ev kind:function(arm,size=0x4) addr:0x02099c30 -_ZN5Actor19func_ov000_0209848cEP27UnkStruct_ov000_020b539c_30 kind:function(arm,size=0x1c) addr:0x02099c34 +_ZN5Actor19func_ov000_0209848cEP9ActorType kind:function(arm,size=0x1c) addr:0x02099c34 _ZN5Actor8vfunc_18Ev kind:function(arm,size=0x8) addr:0x02099c50 _ZN5Actor8vfunc_1cEv kind:function(arm,size=0x4) addr:0x02099c58 _ZN5Actor8vfunc_20Ev kind:function(arm,size=0x4) addr:0x02099c5c @@ -3032,7 +3032,7 @@ _ZN23ActorUnk_ov000_020a8bb08vfunc_54Ei kind:function(arm,size=0x4) addr:0x020aa _ZN23ActorUnk_ov000_020a8bb08vfunc_1cEv kind:function(arm,size=0xc) addr:0x020aa5a4 _ZN23ActorUnk_ov000_020a8bb019func_ov000_020a8db0Ev kind:function(arm,size=0x20) addr:0x020aa5b0 _ZN23ActorUnk_ov000_020a8bb019func_ov000_020a8dd0Ev kind:function(arm,size=0x20) addr:0x020aa5d0 -_ZN23ActorUnk_ov000_020a8bb019func_ov000_020a8df0Eii kind:function(arm,size=0x94) addr:0x020aa5f0 +_ZN23ActorUnk_ov000_020a8bb019func_ov000_020a8df0E8ActorRefi kind:function(arm,size=0x94) addr:0x020aa5f0 _ZN23ActorUnk_ov000_020a8bb08vfunc_b4Ev kind:function(arm,size=0x18) addr:0x020aa684 _ZN23ActorUnk_ov000_020a8bb019func_ov000_020a8e9cEP5Vec3p kind:function(arm,size=0x24) addr:0x020aa69c _ZN23ActorUnk_ov000_020a8bb08vfunc_b0Ev kind:function(arm,size=0x94) addr:0x020aa6c0 diff --git a/include/Actor/Actor.hpp b/include/Actor/Actor.hpp index 0c8758f3..cb7a30d3 100644 --- a/include/Actor/Actor.hpp +++ b/include/Actor/Actor.hpp @@ -1,7 +1,9 @@ #pragma once #include "Actor/ActorId.hpp" +#include "Actor/ActorRef.hpp" #include "Actor/ActorType.hpp" +#include "Physics/Cylinder.hpp" #include "System/SysNew.hpp" #include "global.h" #include "nitro/math.h" @@ -18,23 +20,10 @@ public: void func_ov000_020975f8(); }; -class UnkStruct_ov000_020b539c_30 { -public: - /* 00 */ unk32 mUnk_00; - /* 04 */ unk32 mUnk_04; - /* 08 */ unk8 mUnk_08[0x18 - 0x08]; - /* 1c */ unk8 mUnk_18; - /* 1c */ unk8 mUnk_19; - /* 1c */ unk16 mUnk_1a; - /* 1c */ unk16 mUnk_1c; - /* 1e */ u16 mUnk_1e; - /* 20 */ -}; - class UnkStruct_ov000_020b539c { public: /* 00 */ unk8 mUnk_00[0x30]; - /* 30 */ UnkStruct_ov000_020b539c_30 *mUnk_30; + /* 30 */ ActorType *mUnk_30; /* 34 */ void func_02028cdc(Actor_5c *param1, unk32 param2); @@ -50,7 +39,7 @@ enum ActorFlag_ { ActorFlag_5, ActorFlag_6, ActorFlag_7, - ActorFlag_8, + ActorFlag_Grabbed, ActorFlag_9, ActorFlag_Interacting, // set when player interacts with actor ActorFlag_11, @@ -85,8 +74,8 @@ public: /* 28 */ u16 mAngle; /* 2a */ unk16 mUnk_2a; /* 2c */ unk32 mUnk_2c; // gravity? - /* 30 */ unk32 *mUnk_30; - /* 34 */ ActorTypeData *mUnk_34; + /* 30 */ Cylinder *mUnk_30; + /* 34 */ Cylinder *mUnk_34; /* 38 */ unk32 *mUnk_38; /* 3c */ unk32 mUnk_3c; /* 40 */ void *mUnk_40; // pointer to `Actor_c4` @@ -116,8 +105,8 @@ public: /* 80 */ unk16 mUnk_82; /* 84 */ unk32 mUnk_84; /* 88 */ unk32 mUnk_88; - /* 8c */ unk32 mUnk_8c; - /* 90 */ UnkStruct_ov000_020b539c_30 *mUnk_90; + /* 8c */ ActorRef mRef; + /* 90 */ ActorType *mType; /* 94 */ /* 00 */ virtual void vfunc_00(Vec3p *param1); @@ -145,7 +134,7 @@ public: unk32 func_01fff5d0(unk32 param1, unk32 param2); Actor(); - void func_ov000_0209848c(UnkStruct_ov000_020b539c_30 *param1); + void func_ov000_0209848c(ActorType *param1); void func_ov000_020984b0(); void func_ov000_020984b4(); void func_ov000_020984b8(); diff --git a/include/Actor/ActorRef.hpp b/include/Actor/ActorRef.hpp new file mode 100644 index 00000000..446cc47f --- /dev/null +++ b/include/Actor/ActorRef.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include "types.h" + +#define ACTOR_INDEX_MASK 0x3fff + +struct ActorRef { + /* 0 */ s16 index; + /* 2 */ s16 id; + /* 4 */ + + inline void Reset() { + *(u32 *) this = 0; + } + + inline bool operator==(const ActorRef &other) const { + return this->index == other.index && this->id == other.id; + } + + inline bool operator!=(const ActorRef &other) const { + return !(*this == other); + } +}; diff --git a/include/Actor/ActorType.hpp b/include/Actor/ActorType.hpp index 48f0c54d..f6c9e983 100644 --- a/include/Actor/ActorType.hpp +++ b/include/Actor/ActorType.hpp @@ -1,34 +1,30 @@ #pragma once #include "Actor/ActorId.hpp" +#include "Physics/Cylinder.hpp" #include "System/SysNew.hpp" #include "types.h" -struct ActorTypeData { - /* 00 */ unk32 mUnk_00; - /* 04 */ unk32 mUnk_04; - /* 08 */ unk32 mUnk_08; - /* 0c */ unk32 mUnk_0c; - /* 10 */ unk8 mUnk_10[0x16 - 0x10]; - /* 16 */ unk16 mUnk_16; - /* 18 */ unk16 mUnk_18; - /* 1a */ unk16 mUnk_1a; - /* 1c */ ActorId mActorId; - /* 20 */ unk32 mUnk_20; - /* 24 */ unk32 mUnk_24; - /* 28 */ unk32 mUnk_28; - /* 2c */ unk32 mUnk_2c; - /* 30 */ unk32 mUnk_30; - /* 34 */ unk8 mUnk_34; - /* 35 */ unk8 mUnk_35; -}; - class Actor; class ActorType : public SysObject { public: /* 00 (vtable) */ - /* 04 */ ActorTypeData mData; + /* 04 */ Cylinder mUnk_04; + /* 14 */ unk8 mUnk_14[0x18 - 0x14]; + /* 18 */ unk8 mUnk_18; + /* 19 */ unk8 mUnk_19; + /* 1a */ unk16 mUnk_1a; + /* 1c */ unk16 mUnk_1c; + /* 1e */ u16 mUnk_1e; + /* 20 */ ActorId mActorId; + /* 24 */ unk32 mUnk_24; + /* 28 */ unk32 mUnk_28; + /* 2c */ unk32 mUnk_2c; + /* 30 */ unk32 mUnk_30; + /* 34 */ unk32 mUnk_34; + /* 38 */ unk8 mUnk_38; + /* 39 */ unk8 mUnk_39; /* 3a */ ActorType(ActorId actorId); diff --git a/include/Actor/ActorUnk_ov000_020a8bb0.hpp b/include/Actor/ActorUnk_ov000_020a8bb0.hpp index b5d01dcb..d19fc978 100644 --- a/include/Actor/ActorUnk_ov000_020a8bb0.hpp +++ b/include/Actor/ActorUnk_ov000_020a8bb0.hpp @@ -79,7 +79,7 @@ public: /* 0b0 */ u16 mUnk_0b0; /* 0b4 */ unk32 mUnk_0b4; /* 0b8 */ unk32 mUnk_0b8; - /* 0bc */ unk32 mUnk_0bc; + /* 0bc */ ActorRef mUnk_0bc; /* 0c0 */ Vec3p mUnk_0c0; /* 0cc */ unk16 mUnk_0cc; /* 0cc */ unk16 mUnk_0ce; @@ -152,7 +152,7 @@ public: ActorUnk_ov000_020a8bb0(ActorUnk_ov000_020a8bb0_a4_00 *param1, unk32 param2); unk32 func_ov000_020a8db0(); unk32 func_ov000_020a8dd0(); - void func_ov000_020a8df0(unk32 param1, unk32 param2); + void func_ov000_020a8df0(ActorRef param1, unk32 param2); void func_ov000_020a8e9c(Vec3p *param1); void func_ov000_020a8ff4(); void func_ov000_020a91b8(Vec3p *param1, unk32 param2); diff --git a/include/Physics/Cylinder.hpp b/include/Physics/Cylinder.hpp new file mode 100644 index 00000000..f2467697 --- /dev/null +++ b/include/Physics/Cylinder.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include "types.h" + +#include "nitro/math.h" + +struct Cylinder { + Vec3p pos; + q20 size; // height and radius + + inline Cylinder() {} + inline Cylinder(q20 size) { + pos.x = 0; + pos.y = size; + pos.z = 0; + + this->size = size; + } + + inline void MakeEmpty() { + pos = gVec3p_ZERO; + size = -1; + } +}; diff --git a/src/000_Second/Actor/Actor.cpp b/src/000_Second/Actor/Actor.cpp index a7185aff..d2a0a6c0 100644 --- a/src/000_Second/Actor/Actor.cpp +++ b/src/000_Second/Actor/Actor.cpp @@ -18,8 +18,8 @@ ARM Actor::Actor() { this->mFlags = 0; this->mUnk_84 = 0; this->mUnk_5c.func_ov000_020975f8(); - this->mUnk_8c = 0; - this->mUnk_90 = 0; + this->mRef.Reset(); + this->mType = NULL; data_ov000_020b539c.func_02028cdc(&this->mUnk_5c, 0x30); this->mPrevPos = this->mPos = this->mUnk_5c.mUnk_00; this->mAngle = this->mUnk_5c.mUnk_0c; @@ -33,16 +33,16 @@ ARM Actor::Actor() { ARM Actor::~Actor() {} // non-matching (equivalent) -ARM void Actor::func_ov000_0209848c(UnkStruct_ov000_020b539c_30 *param1) { +ARM void Actor::func_ov000_0209848c(ActorType *param1) { s16 unk_1c; - unk32 *temp_r3; + Cylinder *temp_r3; unk_1c = param1->mUnk_1c; temp_r3 = ¶m1->mUnk_04; - this->mUnk_90 = param1; - this->mUnk_30 = (unk32 *) this->mUnk_34 = temp_r3; - this->mUnk_4e = unk_1c; + this->mType = param1; + this->mUnk_30 = this->mUnk_34 = temp_r3; + this->mUnk_4e = unk_1c; } ARM unk32 Actor::vfunc_18(unk32 param1) { @@ -97,15 +97,15 @@ ARM void Actor::func_ov000_0209853c(void) { } ARM bool Actor::vfunc_04() { - return this->mUnk_90->mUnk_1e & 1; + return this->mType->mUnk_1e & 1; } ARM unk16 Actor::vfunc_08() { - return this->mUnk_90->mUnk_1a; + return this->mType->mUnk_1a; } ARM unk8 Actor::vfunc_0c() { - return this->mUnk_90->mUnk_18; + return this->mType->mUnk_18; } // non-matching @@ -115,11 +115,11 @@ ARM unk32 Actor::vfunc_38(unk32 param1) { var_r3 = param1 >> 16; - if (GET_FLAG(&this->mFlags, ActorFlag_8)) { + if (GET_FLAG(&this->mFlags, ActorFlag_Grabbed)) { return 0; } - SET_FLAG(&this->mFlags, ActorFlag_8); + SET_FLAG(&this->mFlags, ActorFlag_Grabbed); stack_c = this->mFlags; switch (stack_c) { @@ -141,12 +141,12 @@ ARM unk32 Actor::vfunc_38(unk32 param1) { // non-matching ARM bool Actor::vfunc_3c(unk32 param2, Vec3p *param3) { - if (!GET_FLAG(&this->mFlags, ActorFlag_8)) { + if (!GET_FLAG(&this->mFlags, ActorFlag_Grabbed)) { return false; } this->mVel = *param3; - UNSET_FLAG(&this->mFlags, ActorFlag_8); + UNSET_FLAG(&this->mFlags, ActorFlag_Grabbed); return true; } diff --git a/src/000_Second/Actor/ActorUnk_ov000_020a8bb0.cpp b/src/000_Second/Actor/ActorUnk_ov000_020a8bb0.cpp index 857bb623..659ced0e 100644 --- a/src/000_Second/Actor/ActorUnk_ov000_020a8bb0.cpp +++ b/src/000_Second/Actor/ActorUnk_ov000_020a8bb0.cpp @@ -24,24 +24,24 @@ ARM ActorUnk_ov000_020a8bb0::ActorUnk_ov000_020a8bb0(ActorUnk_ov000_020a8bb0_a4_ this->mUnk_0a4.mUnk_08 = 0; this->mUnk_0b4 = -1; this->mUnk_0b8 = 0; - this->mUnk_0bc = 0; - this->mUnk_0c0.x = 0; - this->mUnk_0c0.y = 0; - this->mUnk_0c0.z = 0; - this->mUnk_0cc = 0; - this->mUnk_0ce = 0; - this->mUnk_0d0 = 0; - this->mUnk_0d4 = 0; - this->mUnk_0d8 = 0; - this->mUnk_0da = 0; - this->mUnk_0dc = 0x2AAB; - this->mUnk_0de = 0xEAAB; - this->mUnk_0e0 = 0x1555; - this->mUnk_0e4 = 0; - this->mUnk_0e8 = 0; - this->mUnk_0ea = 0; + this->mUnk_0bc.Reset(); + this->mUnk_0c0.x = 0; + this->mUnk_0c0.y = 0; + this->mUnk_0c0.z = 0; + this->mUnk_0cc = 0; + this->mUnk_0ce = 0; + this->mUnk_0d0 = 0; + this->mUnk_0d4 = 0; + this->mUnk_0d8 = 0; + this->mUnk_0da = 0; + this->mUnk_0dc = 0x2AAB; + this->mUnk_0de = 0xEAAB; + this->mUnk_0e0 = 0x1555; + this->mUnk_0e4 = 0; + this->mUnk_0e8 = 0; + this->mUnk_0ea = 0; this->mUnk_0ec.func_ov024_020d6668(); - uVar2 = this->mUnk_34->mUnk_0c; + uVar2 = this->mUnk_34->size; this->mUnk_114 = -1; this->mUnk_118 = 0x1000; this->mUnk_11c = 0x019A; @@ -49,7 +49,7 @@ ARM ActorUnk_ov000_020a8bb0::ActorUnk_ov000_020a8bb0(ActorUnk_ov000_020a8bb0_a4_ this->mUnk_108 = uVar2; this->mUnk_10c = 0; this->mUnk_110 = uVar2; - this->mUnk_30 = &this->mUnk_104; + this->mUnk_30 = (Cylinder *) &this->mUnk_104; this->mUnk_4a = 5; this->mUnk_44 = 0x1F; this->mUnk_094.mUnk_08 = 3; @@ -88,14 +88,14 @@ ARM unk32 ActorUnk_ov000_020a8bb0::func_ov000_020a8dd0() { } // non-matching -ARM void ActorUnk_ov000_020a8bb0::func_ov000_020a8df0(unk32 param1, unk32 param2) { +ARM void ActorUnk_ov000_020a8bb0::func_ov000_020a8df0(ActorRef param1, unk32 param2) { if (!((u32) (((param2 + 8) - param2) / 2) < 2)) { this->mUnk_0b0 |= 2; } else { this->mUnk_0b0 &= ~2; } - if (this->mUnk_8c != param1) { + if (this->mRef != param1) { this->vfunc_b4(); this->mUnk_0bc = param1; this->mUnk_0c0.x = 0; @@ -118,7 +118,7 @@ ARM void ActorUnk_ov000_020a8bb0::func_ov000_020a8e9c(Vec3p *param1) { this->mUnk_0c0.x = x; this->mUnk_0c0.y = y; this->mUnk_0c0.z = x; - this->mUnk_0bc = 0; + this->mUnk_0bc.Reset(); } ARM void ActorUnk_ov000_020a8bb0::vfunc_b0() { diff --git a/src/031_Land/Actor/ActorRupee.cpp b/src/031_Land/Actor/ActorRupee.cpp index 8e7c22d0..0c122e76 100644 --- a/src/031_Land/Actor/ActorRupee.cpp +++ b/src/031_Land/Actor/ActorRupee.cpp @@ -29,10 +29,10 @@ ARM Actor *ActorTypeRupee::Create() { ARM ActorTypeRupee::ActorTypeRupee() : ActorType(ActorId_Rupee) { - this->mData.mUnk_00 = 0; - this->mData.mUnk_04 = 0x556; - this->mData.mUnk_08 = 0; - this->mData.mUnk_0c = 0x556; + this->mUnk_04.pos.x = 0; + this->mUnk_04.pos.y = 0x556; + this->mUnk_04.pos.z = 0; + this->mUnk_04.size = 0x556; } // non-matching @@ -755,7 +755,7 @@ ARM bool ActorRupee::func_ov031_020e9e5c() { #define GET_ACTOR_RUPEE(pActor) ((ActorRupee *) (pActor)) ARM Actor_c4::Actor_c4(Actor *param1) : - Actor_c4_Base(¶m1->mUnk_8c, 0) { + Actor_c4_Base(¶m1->mRef, 0) { this->mUnk_20 = param1; this->mUnk_04 = 1; }