summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYanis002 <35189056+Yanis002@users.noreply.github.com>2025-02-08 02:12:17 +0100
committerYanis002 <35189056+Yanis002@users.noreply.github.com>2025-02-08 02:12:17 +0100
commita19141c1f0b8879a9caa2a5cb2eb4a3003e99f24 (patch)
tree46601cbce23c308efbb819c4eec2da4923ec8333
parent0c6f9f3a44aa18ac18913ba608b0b67682cc418c (diff)
small documentation
-rw-r--r--config/eur/arm9/overlays/ov059/symbols.txt2
-rw-r--r--config/usa/arm9/overlays/ov059/symbols.txt2
-rw-r--r--include/Player/EquipHammer.hpp36
-rw-r--r--src/59_Hammer/Player/EquipHammer.cpp65
4 files changed, 57 insertions, 48 deletions
diff --git a/config/eur/arm9/overlays/ov059/symbols.txt b/config/eur/arm9/overlays/ov059/symbols.txt
index 6375ea18..6e50d6e2 100644
--- a/config/eur/arm9/overlays/ov059/symbols.txt
+++ b/config/eur/arm9/overlays/ov059/symbols.txt
@@ -10,7 +10,7 @@ _ZN11EquipHammer19func_ov059_02198f10EP5Vec3pii kind:function(arm,size=0x98) add
_ZN11EquipHammer19func_ov059_02198fa8Ei kind:function(arm,size=0x20) addr:0x2198fa8
_ZN11EquipHammer8vfunc_38Ei kind:function(arm,size=0x4) addr:0x2198fc8
_ZN11EquipHammer8vfunc_2cEv kind:function(arm,size=0x14) addr:0x2198fcc
-_ZN11EquipHammer19func_ov059_02198fe0Ev kind:function(arm,size=0x1c) addr:0x2198fe0
+_ZN11EquipHammer15IsHammerChargedEv kind:function(arm,size=0x1c) addr:0x2198fe0
_ZN13LinkStateItem19func_ov059_02198ffcEv kind:function(arm,size=0x80) addr:0x2198ffc
_ZN13LinkStateItem19func_ov059_0219907cEv kind:function(arm,size=0x28) addr:0x219907c
_ZN13LinkStateItem19func_ov059_021990a4Ev kind:function(arm,size=0x268) addr:0x21990a4
diff --git a/config/usa/arm9/overlays/ov059/symbols.txt b/config/usa/arm9/overlays/ov059/symbols.txt
index 02aeeed4..246e951a 100644
--- a/config/usa/arm9/overlays/ov059/symbols.txt
+++ b/config/usa/arm9/overlays/ov059/symbols.txt
@@ -10,7 +10,7 @@ _ZN11EquipHammer19func_ov059_02198f10EP5Vec3pii kind:function(arm,size=0x98) add
_ZN11EquipHammer19func_ov059_02198fa8Ei kind:function(arm,size=0x20) addr:0x2198f08
_ZN11EquipHammer8vfunc_38Ei kind:function(arm,size=0x4) addr:0x2198f28
_ZN11EquipHammer8vfunc_2cEv kind:function(arm,size=0x14) addr:0x2198f2c
-_ZN11EquipHammer19func_ov059_02198fe0Ev kind:function(arm,size=0x1c) addr:0x2198f40
+_ZN11EquipHammer15IsHammerChargedEv kind:function(arm,size=0x1c) addr:0x2198f40
_ZN13LinkStateItem19func_ov059_02198ffcEv kind:function(arm,size=0x80) addr:0x2198f5c
_ZN13LinkStateItem19func_ov059_0219907cEv kind:function(arm,size=0x28) addr:0x2198fdc
_ZN13LinkStateItem19func_ov059_021990a4Ev kind:function(arm,size=0x268) addr:0x2199004
diff --git a/include/Player/EquipHammer.hpp b/include/Player/EquipHammer.hpp
index b65bbcbf..187100be 100644
--- a/include/Player/EquipHammer.hpp
+++ b/include/Player/EquipHammer.hpp
@@ -4,19 +4,27 @@
#include "Player/EquipItem.hpp"
-class LinkStateItem;
+// how long players should wait until the hammer is charged (aka bigger and more powerful)
+#define HAMMER_CHARGE_TIMER 40
+
+//! TODO: change "state" to "flags"? see `vfunc_2c`
+typedef enum EquipHammerState {
+ /* 0x00000 */ EQUIP_HAMMER_STATE_IDLE = (0 << 16),
+ /* 0x10000 */ EQUIP_HAMMER_STATE_CHARGING = (1 << 16),
+ /* 0x20000 */ EQUIP_HAMMER_STATE_CHARGED = (2 << 16),
+} EquipHammerState;
class EquipHammer : public EquipItem {
private:
/* 00 (base) */
/* 09 */ unk8 mUnk_09[3];
- /* 0c */ Vec3p mUnk_0c;
- /* 18 */ s32 mUnk_18;
- /* 1c */ u8 mUnk_1c;
- /* 1d */ u8 mUnk_1d;
- /* 1e */ unk8 mUnk_1e[2];
- /* 20 */ unk32 mUnk_20;
- /* 24 */ unk32 mUnk_24;
+ /* 0c */ Vec3p mUnk_0c; // hammer's position when it hits a surface? not updated if the hammer can't touch a surface
+ /* 18 */ EquipHammerState mState;
+ /* 1c */ bool mIsHeld; // holding the input from the touchscreen
+ /* 1d */ bool mIsReleased; // released the input from the touchscreen
+ /* 1e */ unk8 mUnk_1e[2]; // unused?
+ /* 20 */ s32 mChargeTimer; // charging timer to make it bigger, set to 40 frames by default
+ /* 24 */ unk32 mUnk_24; // timer that prevents the charge?
/* 28 */ unk32 mUnk_28;
/* 2c */
@@ -41,16 +49,18 @@ public:
bool func_ov059_02198ed4();
void func_ov059_02198f10(Vec3p *vec, unk32 param2, s32 param3);
void func_ov059_02198fa8(unk32 param1);
- bool func_ov059_02198fe0();
+ bool IsHammerCharged();
- inline s32 GetUnk_18(void) {
- return mUnk_18;
+ inline s32 GetState(void) {
+ return mState;
}
- inline unk32 GetUnk_20(void) {
- return mUnk_20;
+ inline unk32 GetChargeTimer(void) {
+ return mChargeTimer;
}
};
+class LinkStateItem;
+
extern LinkStateItem *GetLinkStateItem();
extern EquipHammer *GetEquipHammer();
diff --git a/src/59_Hammer/Player/EquipHammer.cpp b/src/59_Hammer/Player/EquipHammer.cpp
index 3438010e..74e36f77 100644
--- a/src/59_Hammer/Player/EquipHammer.cpp
+++ b/src/59_Hammer/Player/EquipHammer.cpp
@@ -8,7 +8,7 @@
#include "DTCM/UnkStruct_027e0d38.hpp"
extern "C" void ApproachAngle_thunk(s16* src, s16 dst, u32 param3);
-extern "C" void func_ov000_020b853c(void);
+extern "C" void func_ov000_020b853c(ActorNavi*);
struct EquipHammer_UnkStruct {
/* 00 */ unk8 mUnk_00[0x20];
@@ -77,16 +77,16 @@ ARM LinkStateItem *GetLinkStateItem() {
}
ARM void EquipHammer::vfunc_18() {
- this->mUnk_1c = 0;
- this->mUnk_1d = 0;
- this->mUnk_18 = 0;
+ this->mIsHeld = false;
+ this->mIsReleased = false;
+ this->mState = EQUIP_HAMMER_STATE_IDLE;
this->mUnk_28 = 0x1000;
}
ARM void EquipHammer::vfunc_1c() {
- this->mUnk_1c = 0;
- this->mUnk_1d = 0;
- this->mUnk_18 = 0;
+ this->mIsHeld = false;
+ this->mIsReleased = false;
+ this->mState = EQUIP_HAMMER_STATE_IDLE;
}
ARM void EquipHammer::vfunc_30() {
@@ -94,34 +94,34 @@ ARM void EquipHammer::vfunc_30() {
this->mUnk_24--;
if (this->mUnk_24 <= 1) {
- this->mUnk_18 = 0;
+ this->mState = EQUIP_HAMMER_STATE_IDLE;
}
}
}
ARM void EquipHammer::func_ov059_02198e90() {
- if (this->mUnk_24 <= 0 && this->mUnk_1c == 0) {
- this->mUnk_1c = 1;
- this->mUnk_20 = 0x28;
+ if (this->mUnk_24 <= 0 && !this->mIsHeld) {
+ this->mIsHeld = true;
+ this->mChargeTimer = HAMMER_CHARGE_TIMER;
}
}
ARM bool EquipHammer::func_ov059_02198ebc() {
if (this->mUnk_24 <= 0) {
- this->mUnk_1d = 1;
+ this->mIsReleased = true;
}
return true;
}
ARM bool EquipHammer::func_ov059_02198ed4() {
- if (this->mUnk_20 > 0) {
- this->mUnk_18 = 0x10000;
- this->mUnk_20--;
- return this->mUnk_20 == 0;
+ if (this->mChargeTimer > 0) {
+ this->mState = EQUIP_HAMMER_STATE_CHARGING;
+ this->mChargeTimer--;
+ return this->mChargeTimer == 0;
}
- this->mUnk_18 = 0x20000;
+ this->mState = EQUIP_HAMMER_STATE_CHARGED;
return false;
}
@@ -130,24 +130,24 @@ ARM void EquipHammer::func_ov059_02198f10(Vec3p *vec, unk32 param2, s32 param3)
this->mUnk_0c = *vec;
- if (this->mUnk_1d != 0) {
- this->mUnk_1d = 0;
+ if (this->mIsReleased) {
+ this->mIsReleased = false;
if (param3 == 0) {
local_18 = this->mUnk_0c;
- MapManager::func_ov00_020858b0(gMapManager, &local_18, this->mUnk_20 == 0x0);
+ MapManager::func_ov00_020858b0(gMapManager, &local_18, this->mChargeTimer == 0);
}
}
- this->mUnk_1c = 0;
+ this->mIsHeld = false;
this->mUnk_24 = 4;
this->mUnk_28 = param2;
}
ARM void EquipHammer::func_ov059_02198fa8(unk32 param1) {
- this->mUnk_1d = 0;
- this->mUnk_1c = 0;
- this->mUnk_18 = 0;
+ this->mIsReleased = false;
+ this->mIsHeld = false;
+ this->mState = EQUIP_HAMMER_STATE_IDLE;
this->mUnk_24 = 4;
this->mUnk_28 = param1;
}
@@ -157,11 +157,11 @@ ARM void EquipHammer::vfunc_38(unk32 param1) {
ARM u32 EquipHammer::vfunc_2c() {
//! TODO: fake?
- return (this->mUnk_18 + (s32)((u32)(this->mUnk_18 >> 0xB) >> 0x14)) >> 0xC;
+ return (this->mState + (s32)((u32)(this->mState >> 0xB) >> 0x14)) >> 0xC;
}
-ARM bool EquipHammer::func_ov059_02198fe0() {
- return this->mUnk_18 == 0x20000 && this->mUnk_20 == 0;
+ARM bool EquipHammer::IsHammerCharged() {
+ return this->mState == EQUIP_HAMMER_STATE_CHARGED && this->mChargeTimer == 0;
}
ARM void LinkStateItem::func_ov059_02198ffc() {
@@ -183,7 +183,7 @@ ARM void LinkStateItem::func_ov059_0219907c() {
this->mUnk_25[3] = 0;
}
-#define CHECK_0219b160(field) ((field) == this->Get_PlayerControlData_Unk100())
+#define CHECK_0219b160(value) ((value) == this->Get_PlayerControlData_Unk100())
ARM void LinkStateItem::func_ov059_021990a4() {
EquipHammer *pEVar4;
@@ -199,7 +199,7 @@ ARM void LinkStateItem::func_ov059_021990a4() {
if (CHECK_0219b160(data_ov059_0219b160.mUnk_20)) {
this->mUnk_38 = gPlayerControl->mAimWorld;
- if (pAVar5->mUnk_3c0[0] != 0 && gPlayerControl->UpdateAimWorld(&this->mUnk_38) && pEVar4->GetUnk_18() <= 0) {
+ if (pAVar5->mUnk_3c0[0] != 0 && gPlayerControl->UpdateAimWorld(&this->mUnk_38) && pEVar4->GetState() <= 0) {
pEVar4->func_ov059_02198e90();
if (this->mUnk_25[2] != 0 && this->mUnk_25[3] != 0) {
@@ -222,11 +222,11 @@ ARM void LinkStateItem::func_ov059_021990a4() {
}
if (gPlayerControl->CheckTouching(1) ? false : true) {
- if (pEVar4->GetUnk_18() > 0) {
+ if (pEVar4->GetState() > 0) {
pEVar4->func_ov059_02198ebc();
this->func_ov00_020a89bc(&data_ov059_0219b1b0, 1);
}
- } else if (!CHECK_0219b160(data_ov059_0219b160.mUnk_40) && pEVar4->GetUnk_20() <= 0) {
+ } else if (!CHECK_0219b160(data_ov059_0219b160.mUnk_40) && pEVar4->GetChargeTimer() <= 0) {
this->func_ov00_020a89bc(&data_ov059_0219b1a0, 1);
}
} else {
@@ -244,6 +244,5 @@ ARM EquipHammer *GetEquipHammer() {
}
ARM void LinkStateItem::StopUsingHammer() {
- gItemManager->GetFairy(FairyId_Courage);
- func_ov000_020b853c();
+ func_ov000_020b853c(gItemManager->GetFairy(FairyId_Courage));
}