From 57de07939724a1a1762422c915814ca2f9dc760c Mon Sep 17 00:00:00 2001 From: Aetias Date: Sun, 9 Feb 2025 09:38:23 +0100 Subject: [PATCH] PlayerControl: Decomp 27% --- config/eur/arm9/overlays/ov000/symbols.txt | 10 +- config/usa/arm9/overlays/ov000/symbols.txt | 10 +- include/Actor/ActorRef.hpp | 4 +- include/Actor/Navi/ActorNaviBase.hpp | 1 + include/DTCM/UnkStruct_027e0d38.hpp | 8 +- include/DTCM/UnkStruct_027e0e2c.hpp | 22 ++ include/DTCM/UnkStruct_027e0ffc.hpp | 26 ++ include/Map/MapManager.hpp | 10 +- include/Player/EquipItem.hpp | 2 +- include/Player/PlayerControl.hpp | 15 +- libs/nds/include/nds/math.h | 4 +- src/00_Core/Map/MapManager.cpp | 10 +- src/00_Core/Player/EquipItem.cpp | 2 +- src/00_Core/Player/PlayerControl.cpp | 292 ++++++++++++++++++++- 14 files changed, 366 insertions(+), 50 deletions(-) create mode 100644 include/DTCM/UnkStruct_027e0e2c.hpp create mode 100644 include/DTCM/UnkStruct_027e0ffc.hpp diff --git a/config/eur/arm9/overlays/ov000/symbols.txt b/config/eur/arm9/overlays/ov000/symbols.txt index 84310c71..33405289 100644 --- a/config/eur/arm9/overlays/ov000/symbols.txt +++ b/config/eur/arm9/overlays/ov000/symbols.txt @@ -601,7 +601,7 @@ _ZN10MapManager18func_ov00_020839b4Ei kind:function(arm,size=0x10) addr:0x20839b _ZN10MapManager18func_ov00_020839c4Ei kind:function(arm,size=0x10) addr:0x20839c4 _ZN10MapManager18func_ov00_020839d4Ev kind:function(arm,size=0x24) addr:0x20839d4 _ZN10MapManager18func_ov00_020839f8Ev kind:function(arm,size=0x24) addr:0x20839f8 -_ZN10MapManager18func_ov00_02083a1cEiPS_P5Vec3p kind:function(arm,size=0x38) addr:0x2083a1c +_ZN10MapManager18func_ov00_02083a1cEP5Vec2bPS_P5Vec3p kind:function(arm,size=0x38) addr:0x2083a1c _ZN10MapManager18func_ov00_02083a54EiPS_iii kind:function(arm,size=0x130) addr:0x2083a54 _ZN10MapManager18func_ov00_02083b84Ev kind:function(arm,size=0x28) addr:0x2083b84 _ZN10MapManager18func_ov00_02083bacEv kind:function(arm,size=0x28) addr:0x2083bac @@ -675,10 +675,10 @@ _ZN10MapManager17GetMapData_Unk_09Ev kind:function(arm,size=0xc) addr:0x2084d18 _ZN10MapManager18func_ov00_02084d24Ecci kind:function(arm,size=0x28) addr:0x2084d24 _ZN10MapManager18func_ov00_02084d4cEiiP5Vec3p kind:function(arm,size=0x170) addr:0x2084d4c _ZN10MapManager18func_ov00_02084ebcEi kind:function(arm,size=0x24c) addr:0x2084ebc -_ZN10MapManager18func_ov00_02085108EPi kind:function(arm,size=0x174) addr:0x2085108 +_ZN10MapManager18func_ov00_02085108EP5Vec3p kind:function(arm,size=0x174) addr:0x2085108 _ZN10MapManager18func_ov00_0208527cEv kind:function(arm,size=0x180) addr:0x208527c _ZN10MapManager18func_ov00_020853fcEv kind:function(arm,size=0x198) addr:0x20853fc -_ZN10MapManager18func_ov00_02085594Ev kind:function(arm,size=0x2a8) addr:0x2085594 +_ZN10MapManager18func_ov00_02085594EP5Vec3p kind:function(arm,size=0x2a8) addr:0x2085594 _ZN10MapManager18func_ov00_0208583cEiP5Vec3pi kind:function(arm,size=0x74) addr:0x208583c _ZN10MapManager18func_ov00_020858b0Ev kind:function(arm,size=0x184) addr:0x20858b0 _ZN10MapManager18func_ov00_02085a34Eii kind:function(arm,size=0x22c) addr:0x2085a34 @@ -2195,7 +2195,7 @@ _ZN13PlayerControl17CheckUntouchedNowEj kind:function(arm,size=0x30) addr:0x20af _ZN13PlayerControl13CheckTouchingEj kind:function(arm,size=0x28) addr:0x20af42c _ZN13PlayerControl14CheckTouchFastEj kind:function(arm,size=0x50) addr:0x20af454 _ZN13PlayerControl18func_ov00_020af4a4Ev kind:function(arm,size=0x94) addr:0x20af4a4 -_ZN13PlayerControl18func_ov00_020af538Ev kind:function(arm,size=0x1ac) addr:0x20af538 +_ZN13PlayerControl18func_ov00_020af538Ebh kind:function(arm,size=0x1ac) addr:0x20af538 _ZN13PlayerControl18func_ov00_020af6e4EP5Vec3pii kind:function(arm,size=0x94) addr:0x20af6e4 _ZN13PlayerControl18func_ov00_020af778Ev kind:function(arm,size=0x360) addr:0x20af778 _ZN13PlayerControl18func_ov00_020afad8EP5Vec3p kind:function(arm,size=0x94) addr:0x20afad8 @@ -3320,7 +3320,7 @@ func_ov000_020cea3c kind:function(arm,size=0x44) addr:0x20cea3c func_ov000_020cea80 kind:function(arm,size=0x4c) addr:0x20cea80 func_ov000_020ceacc kind:function(arm,size=0x58) addr:0x20ceacc func_ov000_020ceb24 kind:function(arm,size=0xa8) addr:0x20ceb24 -func_ov000_020cebcc kind:function(arm,size=0x3c) addr:0x20cebcc +_ZN18UnkStruct_027e0ffc19func_ov000_020cebccEjsi kind:function(arm,size=0x3c) addr:0x20cebcc func_ov000_020cec08 kind:function(arm,size=0x58) addr:0x20cec08 func_ov000_020cec60 kind:function(arm,size=0x78) addr:0x20cec60 func_ov000_020cecd8 kind:function(arm,size=0x8c) addr:0x20cecd8 diff --git a/config/usa/arm9/overlays/ov000/symbols.txt b/config/usa/arm9/overlays/ov000/symbols.txt index 6a5f320f..d1eca585 100644 --- a/config/usa/arm9/overlays/ov000/symbols.txt +++ b/config/usa/arm9/overlays/ov000/symbols.txt @@ -601,7 +601,7 @@ _ZN10MapManager18func_ov00_020839b4Ei kind:function(arm,size=0x10) addr:0x208395 _ZN10MapManager18func_ov00_020839c4Ei kind:function(arm,size=0x10) addr:0x2083964 _ZN10MapManager18func_ov00_020839d4Ev kind:function(arm,size=0x24) addr:0x2083974 _ZN10MapManager18func_ov00_020839f8Ev kind:function(arm,size=0x24) addr:0x2083998 -_ZN10MapManager18func_ov00_02083a1cEiPS_P5Vec3p kind:function(arm,size=0x38) addr:0x20839bc +_ZN10MapManager18func_ov00_02083a1cEP5Vec2bPS_P5Vec3p kind:function(arm,size=0x38) addr:0x20839bc _ZN10MapManager18func_ov00_02083a54EiPS_iii kind:function(arm,size=0x130) addr:0x20839f4 _ZN10MapManager18func_ov00_02083b84Ev kind:function(arm,size=0x28) addr:0x2083b24 _ZN10MapManager18func_ov00_02083bacEv kind:function(arm,size=0x28) addr:0x2083b4c @@ -675,10 +675,10 @@ _ZN10MapManager17GetMapData_Unk_09Ev kind:function(arm,size=0xc) addr:0x2084cb8 _ZN10MapManager18func_ov00_02084d24Ecci kind:function(arm,size=0x28) addr:0x2084cc4 _ZN10MapManager18func_ov00_02084d4cEiiP5Vec3p kind:function(arm,size=0x170) addr:0x2084cec _ZN10MapManager18func_ov00_02084ebcEi kind:function(arm,size=0x24c) addr:0x2084e5c -_ZN10MapManager18func_ov00_02085108EPi kind:function(arm,size=0x174) addr:0x20850a8 +_ZN10MapManager18func_ov00_02085108EP5Vec3p kind:function(arm,size=0x174) addr:0x20850a8 _ZN10MapManager18func_ov00_0208527cEv kind:function(arm,size=0x180) addr:0x208521c _ZN10MapManager18func_ov00_020853fcEv kind:function(arm,size=0x198) addr:0x208539c -_ZN10MapManager18func_ov00_02085594Ev kind:function(arm,size=0x2a8) addr:0x2085534 +_ZN10MapManager18func_ov00_02085594EP5Vec3p kind:function(arm,size=0x2a8) addr:0x2085534 _ZN10MapManager18func_ov00_0208583cEiP5Vec3pi kind:function(arm,size=0x74) addr:0x20857dc _ZN10MapManager18func_ov00_020858b0Ev kind:function(arm,size=0x184) addr:0x2085850 _ZN10MapManager18func_ov00_02085a34Eii kind:function(arm,size=0x22c) addr:0x20859d4 @@ -2195,7 +2195,7 @@ _ZN13PlayerControl17CheckUntouchedNowEj kind:function(arm,size=0x30) addr:0x20af _ZN13PlayerControl13CheckTouchingEj kind:function(arm,size=0x28) addr:0x20af3cc _ZN13PlayerControl14CheckTouchFastEj kind:function(arm,size=0x50) addr:0x20af3f4 _ZN13PlayerControl18func_ov00_020af4a4Ev kind:function(arm,size=0x94) addr:0x20af444 -_ZN13PlayerControl18func_ov00_020af538Ev kind:function(arm,size=0x1ac) addr:0x20af4d8 +_ZN13PlayerControl18func_ov00_020af538Ebh kind:function(arm,size=0x1ac) addr:0x20af4d8 _ZN13PlayerControl18func_ov00_020af6e4EP5Vec3pii kind:function(arm,size=0x94) addr:0x20af684 _ZN13PlayerControl18func_ov00_020af778Ev kind:function(arm,size=0x360) addr:0x20af718 _ZN13PlayerControl18func_ov00_020afad8EP5Vec3p kind:function(arm,size=0x94) addr:0x20afa78 @@ -3222,7 +3222,7 @@ func_ov000_020cea3c kind:function(arm,size=0x44) addr:0x20ce9dc func_ov000_020cea80 kind:function(arm,size=0x4c) addr:0x20cea20 func_ov000_020ceacc kind:function(arm,size=0x58) addr:0x20cea6c func_ov000_020ceb24 kind:function(arm,size=0xa8) addr:0x20ceac4 -func_ov000_020cebcc kind:function(arm,size=0x3c) addr:0x20ceb6c +_ZN18UnkStruct_027e0ffc19func_ov000_020cebccEjsi kind:function(arm,size=0x3c) addr:0x20ceb6c func_ov000_020cec08 kind:function(arm,size=0x58) addr:0x20ceba8 func_ov000_020cec60 kind:function(arm,size=0x78) addr:0x20cec00 func_ov000_020cecd8 kind:function(arm,size=0x8c) addr:0x20cec78 diff --git a/include/Actor/ActorRef.hpp b/include/Actor/ActorRef.hpp index 5ef03f2c..eeace571 100644 --- a/include/Actor/ActorRef.hpp +++ b/include/Actor/ActorRef.hpp @@ -8,9 +8,7 @@ struct ActorRef { /* 4 */ s32 index; /* 8 */ - inline ActorRef() { - Reset(); - } + inline ActorRef() {} inline ActorRef(s32 id, s32 index) : id(id), index(index) {} diff --git a/include/Actor/Navi/ActorNaviBase.hpp b/include/Actor/Navi/ActorNaviBase.hpp index c98bf84f..95a34c6c 100644 --- a/include/Actor/Navi/ActorNaviBase.hpp +++ b/include/Actor/Navi/ActorNaviBase.hpp @@ -10,6 +10,7 @@ class ActorNaviBase_Unk1 {}; class ActorNaviBase : public Actor { +public: /* 000 (base) */ /* 158 */ Vec3p mOffsetPos; /* 164 */ unk32 mUnk_164; diff --git a/include/DTCM/UnkStruct_027e0d38.hpp b/include/DTCM/UnkStruct_027e0d38.hpp index fd616496..b2e50a89 100644 --- a/include/DTCM/UnkStruct_027e0d38.hpp +++ b/include/DTCM/UnkStruct_027e0d38.hpp @@ -3,6 +3,12 @@ #include "global.h" #include "types.h" +struct UnkStruct_027e0d38_Unk28 { + /* 00 */ unk8 mUnk_00[0x34]; + /* 34 */ bool mUnk_34; + /* 35 */ +}; + struct UnkStruct_027e0d38 { /* 00 */ unk8 mUnk_00; /* 01 */ unk8 mUnk_01[3]; // padding? @@ -19,7 +25,7 @@ struct UnkStruct_027e0d38 { /* 21 */ unk8 mUnk_21; /* 22 */ unk8 mUnk_22[2]; // padding? /* 24 */ void *mUnk_24; - /* 28 */ void *mUnk_28; + /* 28 */ UnkStruct_027e0d38_Unk28 *mUnk_28; /* 2c */ s32 func_ov000_02078b40(); diff --git a/include/DTCM/UnkStruct_027e0e2c.hpp b/include/DTCM/UnkStruct_027e0e2c.hpp new file mode 100644 index 00000000..b8923bde --- /dev/null +++ b/include/DTCM/UnkStruct_027e0e2c.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include "global.h" +#include "types.h" + +struct UnkStruct_027e0e2c { + /* 00 */ unk32 mUnk_00; + /* 04 */ unk32 mUnk_04; + /* 08 */ unk32 mUnk_08; + /* 0c */ unk32 mUnk_0c; + /* 10 */ unk32 mUnk_10; + /* 14 */ unk16 mUnk_14; + /* 16 */ unk16 mUnk_16; + /* 18 */ unk32 mUnk_18; + /* 1c */ unk32 mUnk_1c; + /* 20 */ unk32 mUnk_20; + /* 24 */ unk32 mUnk_24; + /* 28 */ unk32 mUnk_28; + /* 2c */ +}; + +extern UnkStruct_027e0e2c data_027e0e2c; diff --git a/include/DTCM/UnkStruct_027e0ffc.hpp b/include/DTCM/UnkStruct_027e0ffc.hpp new file mode 100644 index 00000000..d422ae19 --- /dev/null +++ b/include/DTCM/UnkStruct_027e0ffc.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include "global.h" +#include "types.h" + +struct UnkStruct_027e0ffc { + /* 00 */ unk32 mUnk_00; + /* 04 */ unk32 mUnk_04[0x4]; + /* 14 */ unk32 mUnk_14; + /* 18 */ unk32 mUnk_18; + /* 1c */ unk32 mUnk_1c; + /* 20 */ unk32 mUnk_20; + /* 24 */ unk8 mUnk_24; + /* 25 */ unk8 mUnk_25[0x3]; + /* 28 */ unk32 mUnk_28; + /* 2c */ unk32 mUnk_2c; + /* 30 */ unk32 mUnk_30; + /* 34 */ unk32 mUnk_34; + /* 38 */ unk8 mUnk_38; + /* 39 */ + + void func_ov000_020cebcc(u32 param1, unk16 param2, unk32 param3); + void func_ov000_020ced64(Cylinder *param1, u32 param2); +}; + +extern UnkStruct_027e0ffc data_027e0ffc; diff --git a/include/Map/MapManager.hpp b/include/Map/MapManager.hpp index 13ca4348..f597a37a 100644 --- a/include/Map/MapManager.hpp +++ b/include/Map/MapManager.hpp @@ -158,7 +158,7 @@ public: bool func_ov00_020839c4(s32 param_2); static unk8 func_ov00_020839d4(); static unk8 func_ov00_020839f8(); - static void func_ov00_02083a1c(unk32 param_1, MapManager *param_2, Vec3p *param_3); + static void func_ov00_02083a1c(Vec2b *param_1, MapManager *param_2, Vec3p *param_3); static unk8 func_ov00_02083a54(unk32 param_1, MapManager *param_2, unk32 param_3, unk32 param_4, unk32 param_5); static unk8 func_ov00_02083b84(); static unk8 func_ov00_02083bac(); @@ -166,7 +166,7 @@ public: static unk8 func_ov00_02083bfc(); unk8 func_ov00_02083c24(unk32 param_2); unk8 func_ov00_02083c50(unk32 param_2); - unk8 func_ov00_02083c7c(Vec3p *param_2, unk32 param_3); + unk8 func_ov00_02083c7c(Vec3p *param_2, Vec2b param_3); static unk8 func_ov00_02083ce8(unk8 param_1, unk8 param_2, unk8 param_3, unk8 param_4, unk32 param_5); unk8 func_ov00_02083e34(unk8 param_2, unk8 param_3, unk32 param_4); unk8 MapData_vfunc_60(); @@ -180,7 +180,7 @@ public: void GetTileWorldBounds(Vec2b *tile, AABB *tileBounds); unk8 MapData_vfunc_54(); unk8 func_ov00_020840a0(unk8 param_2, unk8 param_3, unk32 param_4); - unk8 MapData_vfunc_78(); + unk32 MapData_vfunc_78(); static unk8 func_ov00_020840dc(); static unk8 func_ov00_02084100(unk32 param_1, MapManager *param_2); unk8 GetMapData_Unk_48(); @@ -232,10 +232,10 @@ public: unk8 func_ov00_02084d24(unk8 param_2, unk8 param_3, unk32 param_4); s32 func_ov00_02084d4c(unk32 param_2, unk32 param_3, Vec3p *param_4); unk8 func_ov00_02084ebc(unk32 param_2); - s32 func_ov00_02085108(s32 *param_2); + s32 func_ov00_02085108(Vec3p *param_2); static unk8 func_ov00_0208527c(); static unk8 func_ov00_020853fc(); - static unk8 func_ov00_02085594(); + unk8 func_ov00_02085594(Vec3p *param_1); static void func_ov00_0208583c(unk32 param_1, Vec3p *param_2, unk32 param_3); static unk8 func_ov00_020858b0(); s32 func_ov00_02085a34(unk32 param_2, unk32 param_3); diff --git a/include/Player/EquipItem.hpp b/include/Player/EquipItem.hpp index 6702bc48..21f114da 100644 --- a/include/Player/EquipItem.hpp +++ b/include/Player/EquipItem.hpp @@ -34,7 +34,7 @@ public: /* 3c */ virtual bool GetHitbox(Cylinder *hitbox) const; /* 40 */ virtual unk32 vfunc_40() const; /* 44 */ virtual unk32 vfunc_44(unk32 param1) const; - /* 48 */ virtual unk32 vfunc_48(unk32 param1) const; + /* 48 */ virtual unk32 vfunc_48() const; /* 4c */ virtual s32 vfunc_4c() const; /* 50 */ diff --git a/include/Player/PlayerControl.hpp b/include/Player/PlayerControl.hpp index 39e118da..1bfdd833 100644 --- a/include/Player/PlayerControl.hpp +++ b/include/Player/PlayerControl.hpp @@ -28,7 +28,7 @@ public: /* 50 */ q20 mTouchSpeedX; // how fast the stylus moves /* 54 */ q20 mTouchSpeedY; /* 58 */ q20 mTouchDist; // pixel distance from touch to link, deadzone is 20 pixels - /* 5c */ unk32 mUnk_5c; + /* 5c */ q20 mTouchSpeed; /* 60 */ s16 mTouchDuration; /* 62 */ s16 mTouchSlowDuration; // resets to 0 if stylus is fast enough /* 64 */ s16 mTouchFastTime; // gets set to mTouchDuration if stylus is fast enough @@ -57,13 +57,12 @@ public: /* 84 */ ActorRef mFollowRef; /* 8c */ ActorRef mNextFollowRef; /* 94 */ ActorRef mLastFollowRef; - /* 9c */ u8 mUnk_9c; - /* 9d */ u8 mUnk_9d; + /* 9c */ Vec2b mUnk_9c; /* 9e */ unk8 mUnk_9e[2]; /* a0 */ void *mFollowActor; /* a4 */ q20 mFollowDist; /* a8 */ u16 mFollowStuckTimer; - /* aa */ u16 mCutsceneEndTimer; + /* aa */ s16 mCutsceneEndTimer; /* ac */ s16 mUnk_ac; /* ae */ unk16 mUnk_ae; /* b0 */ Vec3p mAim; // used by boomerang, bow and rope @@ -75,11 +74,11 @@ public: /* d8 */ static bool func_ov00_020aeeac(); - bool func_ov00_020aeef8(); + static bool func_ov00_020aeef8(); void func_ov00_020aef30(); void UpdateAim(); Actor *GetFollowActor(); - bool func_ov00_020af01c(unk8 *param1); + bool func_ov00_020af01c(Vec2b *param1); void SetUnk_80(); void StopFollowing(); void func_ov00_020af06c(); @@ -90,14 +89,14 @@ public: bool CheckTouching(u32 param1); bool CheckTouchFast(u32 param1); bool func_ov00_020af4a4(); - void func_ov00_020af538(); + void func_ov00_020af538(bool param1, u8 param2); void func_ov00_020af6e4(Vec3p *param1, s32 param3, s32 param4); bool func_ov00_020af778(); bool func_ov00_020afad8(Vec3p *param1); void func_ov00_020afb6c(); bool func_ov00_020afe88(s32 param1, bool param2); bool func_ov00_020afeec(unk32 param1, bool param2); - void func_ov00_020aff90(unk32 param1, unk32 param2); + void func_ov00_020aff90(Cylinder *param1, unk32 param2); void func_ov00_020affec(Vec3p *param1, s32 y, s32 param3, Vec3p *param4); void func_ov00_020b014c(); void SetAim(); diff --git a/libs/nds/include/nds/math.h b/libs/nds/include/nds/math.h index 517cbde2..aaaf52fe 100644 --- a/libs/nds/include/nds/math.h +++ b/libs/nds/include/nds/math.h @@ -49,8 +49,8 @@ bool Approach_thunk(unk32 *src, unk32 dest, unk32 step); extern q4 gSinCosTable[]; typedef struct { - /* 0 */ s8 x; - /* 1 */ s8 y; + /* 0 */ u8 x; + /* 1 */ u8 y; /* 2 */ } Vec2b; diff --git a/src/00_Core/Map/MapManager.cpp b/src/00_Core/Map/MapManager.cpp index 9c23a95b..c40f60cd 100644 --- a/src/00_Core/Map/MapManager.cpp +++ b/src/00_Core/Map/MapManager.cpp @@ -113,7 +113,7 @@ bool MapManager::func_ov00_020839b4(s32 param_2) {} bool MapManager::func_ov00_020839c4(s32 param_2) {} unk8 MapManager::func_ov00_020839d4() {} unk8 MapManager::func_ov00_020839f8() {} -void MapManager::func_ov00_02083a1c(unk32 param_1, MapManager *param_2, Vec3p *param_3) {} +void MapManager::func_ov00_02083a1c(Vec2b *param_1, MapManager *param_2, Vec3p *param_3) {} unk8 MapManager::func_ov00_02083a54(unk32 param_1, MapManager *param_2, unk32 param_3, unk32 param_4, unk32 param_5) {} unk8 MapManager::func_ov00_02083b84() {} unk8 MapManager::func_ov00_02083bac() {} @@ -121,7 +121,7 @@ unk8 MapManager::func_ov00_02083bd4() {} unk8 MapManager::func_ov00_02083bfc() {} unk8 MapManager::func_ov00_02083c24(unk32 param_2) {} unk8 MapManager::func_ov00_02083c50(unk32 param_2) {} -unk8 MapManager::func_ov00_02083c7c(Vec3p *param_2, unk32 param_3) {} +unk8 MapManager::func_ov00_02083c7c(Vec3p *param_2, Vec2b param_3) {} unk8 MapManager::func_ov00_02083ce8(unk8 param_1, unk8 param_2, unk8 param_3, unk8 param_4, unk32 param_5) {} unk8 MapManager::func_ov00_02083e34(unk8 param_2, unk8 param_3, unk32 param_4) {} unk8 MapManager::MapData_vfunc_60() {} @@ -135,7 +135,7 @@ unk8 MapManager::func_ov00_02083fb0(u32 *param_1, MapManager *param_2, Vec3p *pa void MapManager::GetTileWorldBounds(Vec2b *tile, AABB *tileBounds) {} unk8 MapManager::MapData_vfunc_54() {} unk8 MapManager::func_ov00_020840a0(unk8 param_2, unk8 param_3, unk32 param_4) {} -unk8 MapManager::MapData_vfunc_78() {} +unk32 MapManager::MapData_vfunc_78() {} unk8 MapManager::func_ov00_020840dc() {} unk8 MapManager::func_ov00_02084100(unk32 param_1, MapManager *param_2) {} unk8 MapManager::GetMapData_Unk_48() {} @@ -187,10 +187,10 @@ unk8 MapManager::GetMapData_Unk_09() {} unk8 MapManager::func_ov00_02084d24(unk8 param_2, unk8 param_3, unk32 param_4) {} s32 MapManager::func_ov00_02084d4c(unk32 param_2, unk32 param_3, Vec3p *param_4) {} unk8 MapManager::func_ov00_02084ebc(unk32 param_2) {} -s32 MapManager::func_ov00_02085108(s32 *param_2) {} +s32 MapManager::func_ov00_02085108(Vec3p *param_2) {} unk8 MapManager::func_ov00_0208527c() {} unk8 MapManager::func_ov00_020853fc() {} -unk8 MapManager::func_ov00_02085594() {} +unk8 MapManager::func_ov00_02085594(Vec3p *param_1) {} void MapManager::func_ov00_0208583c(unk32 param_1, Vec3p *param_2, unk32 param_3) {} unk8 MapManager::func_ov00_020858b0() {} s32 MapManager::func_ov00_02085a34(unk32 param_2, unk32 param_3) {} diff --git a/src/00_Core/Player/EquipItem.cpp b/src/00_Core/Player/EquipItem.cpp index 9256b13a..50afc0ab 100644 --- a/src/00_Core/Player/EquipItem.cpp +++ b/src/00_Core/Player/EquipItem.cpp @@ -9,7 +9,7 @@ u32 EquipItem::vfunc_2c() {} void EquipItem::vfunc_34(unk16 *param1) {} unk32 EquipItem::vfunc_40() const {} unk32 EquipItem::vfunc_44(unk32 param1) const {} -unk32 EquipItem::vfunc_48(unk32 param1) const {} +unk32 EquipItem::vfunc_48() const {} s32 EquipItem::vfunc_4c() const {} Vec3p *EquipItem::GetPlayerPos() {} void EquipItem::func_ov000_020be99c(Vec3p *param1) {} diff --git a/src/00_Core/Player/PlayerControl.cpp b/src/00_Core/Player/PlayerControl.cpp index d8b677f9..79b0b4ef 100644 --- a/src/00_Core/Player/PlayerControl.cpp +++ b/src/00_Core/Player/PlayerControl.cpp @@ -5,9 +5,13 @@ #include "DTCM/UnkStruct_027e077c.hpp" #include "DTCM/UnkStruct_027e0c68.hpp" #include "DTCM/UnkStruct_027e0d38.hpp" +#include "DTCM/UnkStruct_027e0e2c.hpp" +#include "DTCM/UnkStruct_027e0ffc.hpp" #include "DTCM/UnkStruct_027e103c.hpp" #include "Item/ItemManager.hpp" +#include "Map/MapManager.hpp" #include "Player/PlayerBase.hpp" +#include "Player/PlayerLinkBase.hpp" #include "Save/AdventureFlags.hpp" ARM bool PlayerControl::func_ov00_020aeeac() { @@ -60,10 +64,9 @@ ARM Actor *PlayerControl::GetFollowActor() { return gActorManager->GetActor(&mFollowRef); } -ARM bool PlayerControl::func_ov00_020af01c(unk8 *param1) { +ARM bool PlayerControl::func_ov00_020af01c(Vec2b *param1) { if (mFollowing) { - param1[0] = mUnk_9c; - param1[1] = mUnk_9d; + *param1 = mUnk_9c; return true; } return false; @@ -185,19 +188,280 @@ bool PlayerControl::func_ov00_020af2d4(u32 param1, bool param2) { } } -bool PlayerControl::CheckTouchedNow(u32 param1) {} -bool PlayerControl::CheckUntouchedNow(u32 param1) {} -bool PlayerControl::CheckTouching(u32 param1) {} -bool PlayerControl::CheckTouchFast(u32 param1) {} -bool PlayerControl::func_ov00_020af4a4() {} -void PlayerControl::func_ov00_020af538() {} -void PlayerControl::func_ov00_020af6e4(Vec3p *param1, s32 param3, s32 param4) {} -bool PlayerControl::func_ov00_020af778() {} -bool PlayerControl::func_ov00_020afad8(Vec3p *param1) {} -void PlayerControl::func_ov00_020afb6c() {} +ARM bool PlayerControl::CheckTouchedNow(u32 param1) { + bool result = false; + if (this->func_ov00_020af2d4(param1, true)) { + result = (mFlags & TouchFlag_TouchedNow) != 0; + } + return result; +} + +ARM bool PlayerControl::CheckUntouchedNow(u32 param1) { + bool result = false; + if (this->func_ov00_020af2d4(param1, true)) { + result = (mFlags & TouchFlag_UntouchedNow) != 0; + } + return result; +} + +ARM bool PlayerControl::CheckTouching(u32 param1) { + return this->func_ov00_020af2d4(param1, true) && mTouch; +} + +ARM bool PlayerControl::CheckTouchFast(u32 param1) { + if (this->func_ov00_020af2d4(param1, true)) { + if (mTouchSpeed > FLOAT_TO_Q20(0.5) && mTouchFastTime > 0) { + if (mTouchFastTime <= mTouchDuration) { + if (mTouchDuration < mTouchFastTime + 15) { + return true; + } + } + } + } + return false; +} + +ARM bool PlayerControl::func_ov00_020af4a4() { + if (!data_027e0d38->mUnk_28->mUnk_34 && data_027e0e2c.mUnk_04 == -1 && !data_027e103c->func_ov005_02103f4c()) { + if (this->func_ov00_020aeeac()) { + return true; + } + switch (data_027e077c.mUnk_0) { + case 0x1a: + case 0x1b: + case 0x1c: return true; + default: return false; + } + } + return false; +} + +ARM void PlayerControl::func_ov00_020af538(bool param1, u8 param2) { + mUnk_7c = param1; + mUnk_7e = param2; + mUnk_7d = param1; + if (mUnk_78) { + bool unk = gAdventureFlags->func_ov00_02097738() || data_027e0c68->mUnk_04 ? false : true; + if (unk) { + if (!this->func_ov00_020af4a4()) { + mUnk_7c = false; + } + } + if (!unk && this->func_ov00_020aeef8()) { + mUnk_7d = false; + } + } + + this->func_ov000_020b7924(mUnk_7c); + if (mUnk_7c) { + if (mTouchDuration == 0) { + if (this->GetFollowActor() != NULL || mFollowing) { + data_027e0ffc.func_ov000_020cebcc(0x10a, gPlayerAngle, 0); + this->StopFollowing(); + } + + Vec3p vec; + s32 unk = gMapManager->func_ov00_02085108(&vec); + mUnk_82 = unk == 0x3 || unk == 0x7; + } + } + + bool usingEquipBefore = mUsingEquipItem; + this->func_ov00_020af06c(); + if (usingEquipBefore && !mUsingEquipItem) { + data_027e103c->func_ov000_020cf20c(); + } + + for (s32 i = 0; i < 2; ++i) { + if (mTouchGesture[i] != NULL) { + mTouchGesture[i]->Update(this); + } + } + + mUnk_7f = false; + mUnk_83 = data_027e05f8.mUnk_0 & 0x300; +} + +ARM void PlayerControl::func_ov00_020af6e4(Vec3p *param1, s32 param3, s32 param4) { + if (param4 == 4) { + return; + } + if (param3 > 0) { + q20 distance = Vec3p_Distance(&gPlayerPos, param1); + if (distance >= param3) { + return; + } + mFollowRef.Reset(); + } + + Vec2b unk; + MapManager::func_ov00_02083a1c(&unk, gMapManager, param1); + mUnk_9c = unk; + mFollowing = true; + mUnk_80 = false; + mFollowStuckTimer = 15; +} + +ARM bool PlayerControl::func_ov00_020af778() { + if (!mUnk_78 || gAdventureFlags->func_ov00_02097738() || gAdventureFlags->func_ov00_02097750()) { + mCutsceneEndTimer = 15; + return false; + } + if (mCutsceneEndTimer > 0) { + mCutsceneEndTimer -= 1; + return false; + } + if (!this->func_ov00_020aeef8()) { + mNextFollowRef.Reset(); + return false; + } + + bool bVar1 = false; + EquipItem *equipItem; + if ((mFlags & TouchFlag_UntouchedNow) != 0 && mTouchDuration < 21) { + s32 dx = mTouchLastX - mTouchFastX; + s32 dy = mTouchLastY - mTouchFastY; + if (dx * dx + dy * dy < 100) { + bVar1 = !this->func_ov00_020af2d4(7, true); + if (!bVar1 && mUsingEquipItem) { + ItemFlag equipId = gPlayer->GetEquipId(); + if (equipId != ItemFlag_None) { + equipItem = gItemManager->GetEquipItem(equipId); + } + } + } + } + + bool isGrabbing = gPlayerLink != NULL && gActorManager->GetActor(&gPlayerLink->mGrabActor) != NULL; + q20 followDistance = 0; + if (bVar1) { + Actor *nextFollowActor = gActorManager->GetActor(&mNextFollowRef); + unk32 uVar4 = 0; + if (nextFollowActor != NULL) { + uVar4 = nextFollowActor->mUnk_12c; + if (this->func_ov00_020afe88(uVar4, isGrabbing) && (equipItem == NULL || equipItem->vfunc_44(uVar4))) { + mFollowRef = mNextFollowRef; + mNextFollowRef.Reset(); + mUnk_80 = false; + mFollowStuckTimer = 15; + followDistance = nextFollowActor->XzDistanceToLink(); + } + } + + Vec3p vec; + s32 iVar4 = gMapManager->func_ov00_02085108(&vec); + vec.y = gPlayerPos.y; + if (equipItem == NULL) { + if (iVar4 != 0 && this->func_ov00_020afeec(iVar4, isGrabbing)) { + this->func_ov00_020af6e4(&vec, followDistance, uVar4); + return true; + } + } else { + if (equipItem->vfunc_48()) { + this->func_ov00_020af6e4(&vec, followDistance, uVar4); + return true; + } + if (followDistance == 0 && equipItem->vfunc_40()) { + this->ApplyTouchWorld(&vec, 0); + this->func_ov00_020af6e4(&vec, 0, uVar4); + return true; + } + } + } else { + ActorRef ref; + ActorManager::func_ov00_020c3484(&ref, gActorManager, 0); + mNextFollowRef = ref; + if (mTouchDuration == 0) { + mLastFollowRef = mNextFollowRef; + } + } + return followDistance > 0; +} + +ARM bool PlayerControl::func_ov00_020afad8(Vec3p *param1) { + if (param1->y >= gPlayerPos.y) { + return false; + } + if (mUsingEquipItem) { + if (gPlayer->GetEquipId() == ItemFlag_Shovel) { + Vec3p vec; + return gMapManager->func_ov00_02085594(&vec); + } + return false; + } + return false; +} + +ARM void PlayerControl::func_ov00_020afb6c() { + bool iVar1 = this->func_ov00_020af778(); + Actor *followActor = gActorManager->GetActor(&mFollowRef); + FairyId fairyId = gItemManager->GetEquippedFairy(); + ActorNaviBase *fairy = gItemManager->GetFairy(fairyId); + + if (followActor == NULL && fairy != NULL) { + fairy->func_ov000_020bad18(); + } + + q20 followDist = mFollowDist; + if (followActor == NULL) { + mFollowRef.Reset(); + } else { + followDist = Vec3p_Distance(&gPlayerPos, &followActor->mPos); + Cylinder followHitbox; + followActor->GetHitbox(&followHitbox); + followHitbox.pos.y += FLOAT_TO_Q20(0.4); + + s32 iVar8 = 0; + u32 uVar9 = 3; + switch (followActor->mUnk_12c) { + case 0: mFollowRef.Reset(); break; + case 1: iVar8 = 1; break; + case 2: + iVar8 = 3; + followHitbox.pos.y += followHitbox.size; + uVar9 = 0; + break; + case 3: + case 4: + iVar8 = 2; + followHitbox.pos.y += followHitbox.size; + uVar9 = 2; + break; + case 5: + iVar8 = 2; + uVar9 = 1; + followHitbox.pos.y += followActor->mYOffset; + break; + } + if (iVar8 != 0 && gPlayerLink->GetCurrentCharacter() == PlayerCharacter_Link) { + this->func_ov00_020aff90(&followHitbox, iVar8); + if (iVar1) { + data_027e0ffc.func_ov000_020ced64(&followHitbox, followActor->mRef.id); + } + } + } + + if (!mFollowing) { + mFollowActor = NULL; + } else { + mFollowActor = (void *) gMapManager->MapData_vfunc_78(); + Vec3p local_3c; + s32 iVar2; + s32 iVar7; + if (mFollowActor == NULL) { + local_3c.y = gPlayerPos.y; + Vec2b local_44 = mUnk_9c; + gMapManager->func_ov00_02083c7c(&local_3c, local_44); + iVar2 = 2; + iVar7 = 3; + } else { + } + } +} + bool PlayerControl::func_ov00_020afe88(s32 param1, bool param2) {} bool PlayerControl::func_ov00_020afeec(unk32 param1, bool param2) {} -void PlayerControl::func_ov00_020aff90(unk32 param1, unk32 param2) {} +void PlayerControl::func_ov00_020aff90(Cylinder *param1, unk32 param2) {} void PlayerControl::func_ov00_020affec(Vec3p *param1, s32 y, s32 param3, Vec3p *param4) {} void PlayerControl::func_ov00_020b014c() {} void PlayerControl::SetAim() {}