diff options
| author | Yanis002 <35189056+Yanis002@users.noreply.github.com> | 2025-06-29 21:57:44 +0200 |
|---|---|---|
| committer | Yanis002 <35189056+Yanis002@users.noreply.github.com> | 2025-06-29 21:57:44 +0200 |
| commit | f7c54542b9c2b3231c10992c80f775d4ccb1706b (patch) | |
| tree | 44545be8b43231411c967efd2289b4dd97e9e0dd /src | |
| parent | 7d783ffb12a59965f7a288ac9e5bfc4caccf3d1a (diff) | |
| parent | 3fe49695b4936ea29526eb8b7d07250a69a06c38 (diff) | |
Merge remote-tracking branch 'upstream/main' into hammer
Diffstat (limited to 'src')
33 files changed, 2449 insertions, 250 deletions
diff --git a/src/00_Core/Actor/Actor.cpp b/src/00_Core/Actor/Actor.cpp index f008064d..85f58869 100644 --- a/src/00_Core/Actor/Actor.cpp +++ b/src/00_Core/Actor/Actor.cpp @@ -5,6 +5,8 @@ extern "C" { #include "Actor/Actor.hpp" #include "Actor/ActorManager.hpp" #include "Actor/ActorPlayerDummy.hpp" +#include "DTCM/UnkStruct_027e077c.hpp" +#include "DTCM/UnkStruct_027e103c.hpp" #include "Item/ItemManager.hpp" #include "Map/MapManager.hpp" #include "Player/EquipSword.hpp" @@ -46,8 +48,7 @@ ARM Actor::Actor() : mUnk_010(0), mUnk_011(0), mUnk_012(0), - mUnk_034(-1), - mUnk_038(-1), + mUnk_034(-1, -1), mUnk_03c(-1), mUnk_040(-1, -1), mGravity(FLOAT_TO_Q20(0.0498)), @@ -111,11 +112,11 @@ ARM Actor::Actor() : ARM Actor::~Actor() {} -ARM bool Actor::vfunc_08() { +ARM bool Actor::Init() { return true; } -ARM void Actor::vfunc_0c() {} +ARM bool Actor::vfunc_0c() {} ARM void Actor::vfunc_10(u32 param1) {} ARM void Actor::vfunc_24() {} ARM void Actor::vfunc_28() {} @@ -255,20 +256,9 @@ ARM bool Actor::func_ov00_020c195c() { return true; } -struct UnkStruct2 { - /* 0 */ u32 mUnk_0; - /* 4 */ u32 mUnk_4; - /* 8 */ -}; -extern UnkStruct2 data_027e077c; -extern u8 data_02056be4[]; -extern "C" bool func_ov05_02103f4c(s32 param1); -extern s32 data_027e103c; ARM bool Actor::func_ov00_020c198c() { - u32 unk1 = data_027e077c.mUnk_0; - u32 unk2 = data_027e077c.mUnk_4; - if (data_027e077c.mUnk_0 != data_027e077c.mUnk_4 || (data_02056be4[unk1] & 1) != 0 || (data_02056be4[unk2] & 4) != 0 || - func_ov05_02103f4c(data_027e103c) || gPlayer->mHealth <= 0) + if (data_027e077c.GetUnk0() != data_027e077c.GetUnk4() || (data_02056be4[data_027e077c.GetUnk0()] & 1) != 0 || + (data_02056be4[data_027e077c.GetUnk4()] & 4) != 0 || data_027e103c->func_ov005_02103f4c() || gPlayer->mHealth <= 0) { return false; } @@ -318,8 +308,8 @@ ARM void Actor::SetTransform(Transform *transform) { ARM void Actor::vfunc_a8() {} -ARM void Actor::func_Ov00_020c1bfc(s32 param1) { - gMapManager->func_ov00_02084be0(mUnk_020.mUnk_0a[param1], mUnk_020.mUnk_08[param1]); +ARM bool Actor::func_ov00_020c1bfc(s32 param1) { + return gMapManager->func_ov00_02084be0(mUnk_020.mUnk_0a[param1], mUnk_020.mUnk_08[param1]); } ARM void Actor::func_ov00_020c1c20(s32 param1, unk32 param2) { diff --git a/src/00_Core/Actor/ActorManager.cpp b/src/00_Core/Actor/ActorManager.cpp index 73ab6bbb..955c447d 100644 --- a/src/00_Core/Actor/ActorManager.cpp +++ b/src/00_Core/Actor/ActorManager.cpp @@ -1,4 +1,5 @@ #include "Actor/ActorManager.hpp" +#include "DTCM/UnkStruct_027e077c.hpp" #include "DTCM/UnkStruct_027e103c.hpp" #include "Map/MapManager.hpp" @@ -8,8 +9,6 @@ extern "C" Cylinder *func_ov000_020c3ef0(void *, u32 index); extern "C" bool func_ov000_020c3f08(void *, u32 index); extern "C" void func_ov000_020c3f3c(void *, u32 index, Cylinder *cylinder); extern "C" void func_ov000_020c3f54(void *, u32 param2); -extern s32 data_027e077c; -extern u8 data_02056be4[]; ARM void ActorManager::DeleteActor(u32 index, bool param2) { if (!param2) { @@ -52,7 +51,7 @@ ARM void ActorManager::func_ov00_020c3484(ActorRef *ref, ActorManager *actorMgr, q20 minDistance = 0x7fffffff; Actor **actorIter = actorMgr->mActorTable; - u8 unkByte = data_02056be4[data_027e077c]; + u8 unkByte = data_02056be4[data_027e077c.GetUnk0()]; bool unk1 = (unkByte & 1) != 0; Actor **actorTableEnd = actorIter + actorMgr->mMaxActorIndex; @@ -155,7 +154,7 @@ ARM Actor *ActorManager::GetActor(ActorRef *ref) { ARM bool FilterActor::Filter(Actor *actor) { if (mType != actor->mType) return false; - if (mUnk_08 != -1 && mUnk_08 != actor->mUnk_034) return false; + if (mUnk_08 != -1 && mUnk_08 != actor->mUnk_034.id) return false; if (mExcludeRefs != NULL) { for (s32 i = 0; mExcludeRefs[i].id != -1; ++i) { ActorRef *ref = &mExcludeRefs[i]; diff --git a/src/00_Core/Actor/ActorSpawner.cpp b/src/00_Core/Actor/ActorSpawner.cpp index 76b4ae74..55cf1a57 100644 --- a/src/00_Core/Actor/ActorSpawner.cpp +++ b/src/00_Core/Actor/ActorSpawner.cpp @@ -1,10 +1,98 @@ #include "Actor/ActorSpawner.hpp" +#include "Actor/ActorManager.hpp" +#include "Map/MapManager.hpp" -ActorSpawner *ActorSpawner::Create() {} -void ActorSpawner::Destroy() {} -ActorSpawner::ActorSpawner() {} -ActorSpawner::~ActorSpawner() {} -void ActorSpawner::func_ov000_020c4014() {} -void ActorSpawner::func_ov000_020c4018() {} -Actor *ActorSpawner::CreateActor(ActorTypeId type) {} -s32 ActorSpawner::Spawn(ActorTypeId type, Vec3p *pos, void *param3, ActorRef *ref) {} +extern u32 *data_027e0ce0[]; +ARM ActorSpawner *ActorSpawner::Create() { + gActorSpawner = new(data_027e0ce0[1], 4) ActorSpawner(); +} + +ARM void ActorSpawner::Destroy() { + delete gActorSpawner; + gActorSpawner = NULL; +} + +ARM ActorSpawner::ActorSpawner() {} + +ARM ActorSpawner::~ActorSpawner() {} + +ARM void ActorSpawner::func_ov000_020c4014() {} + +ARM void ActorSpawner::func_ov000_020c4018() {} + +ARM Actor *ActorSpawner::CreateActor(ActorTypeId typeId) { + Actor *actor = NULL; + ActorType *type = ActorType::Find(typeId); + if (type != NULL) { + actor = type->create(); + } + return actor; +} + +extern "C" unk32 GetCardinal(s16 angle); +ARM s32 ActorSpawner::Spawn(ActorTypeId type, Vec3p *pos, ActorSpawnOptions *options, ActorRef *ref) { + ActorManager *actorManager = gActorManager; + u16 maxActors = actorManager->mMaxActors; + s32 id = -1; + s32 index; + Actor **actorSlot = actorManager->mActorTable; + for (index = 0; index < maxActors; index++, actorSlot++) { + if (*actorSlot != NULL) { + continue; + } + + Actor *actor = this->CreateActor(type); + *actorSlot = actor; + if (actor == NULL) { + if (ref != NULL) { + ref->Reset(); + } + return -1; + } + actor->mType = type; + (*actorSlot)->mRef.id = actorManager->mNextActorId; + (*actorSlot)->mRef.index = index; + (*actorSlot)->mUnk_014 = *pos; + (*actorSlot)->mUnk_020 = options->mUnk_00; + (*actorSlot)->mAngle = options->mAngle; + (*actorSlot)->mUnk_012 = options->mAngle; + (*actorSlot)->mUnk_074 = GetCardinal(options->mAngle); + if (options->mUnk_18 >= 0xffff) { + (*actorSlot)->mUnk_03c = -1; + } else { + (*actorSlot)->mUnk_03c = options->mUnk_18; + } + (*actorSlot)->mUnk_034 = options->mUnk_1c; + (*actorSlot)->mUnk_140 = options->mUnk_24; + (*actorSlot)->mUnk_144 = options->mUnk_28; + Actor *actor2 = *actorSlot; + actor2->mPos = *pos; + actor2->mPrevPos = *pos; + (*actorSlot)->mUnk_010 = gMapManager->GetCourseData_Unk_1c(); + (*actorSlot)->mUnk_011 = gMapManager->GetCourseData_Unk_1d(); + u16 nextIndex = index + 1; + if (actorManager->mMaxActorIndex < nextIndex) { + actorManager->mMaxActorIndex = nextIndex; + } + actorManager->mCacheEmptyActorIndex = index; + + id = actorManager->mNextActorId; + if (ref != NULL) { + *ref = ActorRef(id, index); + } + actorManager->mNextActorId += 1; + actorManager->mNumActors += 1; + if (!(*actorSlot)->Init()) { + (*actorSlot)->mAlive = false; + if (ref != NULL) { + ref->Reset(); + } + return -1; + } + break; + } + if ((id == -1) && (ref != NULL)) { + ref->Reset(); + } + return id; +} diff --git a/src/00_Core/Actor/Dungeon/ActorActionObject.cpp b/src/00_Core/Actor/Dungeon/ActorActionObject.cpp new file mode 100644 index 00000000..ea2dfec2 --- /dev/null +++ b/src/00_Core/Actor/Dungeon/ActorActionObject.cpp @@ -0,0 +1,85 @@ +#include "Actor/Dungeon/ActorActionObject.hpp" +#include "Map/MapManager.hpp" +#include "Player/LinkStateBase.hpp" +#include "Player/PlayerLinkBase.hpp" +#include "Save/AdventureFlags.hpp" + +#pragma section sbss begin +ActorType ActorActionObject::gType = ActorType(ActorTypeId_ActionObject, (ActorCreateFunc) ActorActionObject::Create, NULL); +#pragma section sbss end + +extern u32 **data_027e0fe0[]; +ARM ActorActionObject *ActorActionObject::Create() { + return new(*data_027e0fe0[0], 4) ActorActionObject(); +} + +ARM ActorActionObject::ActorActionObject() {} + +ARM ActorActionObject::~ActorActionObject() {} + +// non-matching +ARM bool ActorActionObject::Init() { + mGravity = 0; + mHitbox.pos = gVec3p_ZERO; + mHitbox.size = -1; + mUnk_08c.pos = mHitbox.pos; + mUnk_08c.size = mHitbox.size; + mUnk_0a4.mUnk_04 = gVec3p_ZERO; + mUnk_0a4.mUnk_10 = -1; + mVisible = false; + mUnk_130 = 0; + return true; +} + +ARM void ActorActionObject::vfunc_14(u32 param1) { + if (!this->func_ov00_020c313c(param1)) { + return; + } + + u32 flag = mUnk_020.mUnk_00[2]; + bool bVar3; + switch (mUnk_020.mUnk_00[0]) { + case 0: bVar3 = true; break; + case 1: + if (gPlayerLink->mGrabActor.id != -1 && gPlayerLink->GetStateId() == LinkStateId_Move) { + bVar3 = true; + } else { + bVar3 = false; + } + break; + case 2: + if (gPlayerLink->mGrabActor.id == -1 && gPlayerLink->GetStateId() == LinkStateId_Move) { + bVar3 = true; + } else { + bVar3 = false; + } + break; + default: bVar3 = false; break; + } + + if (!bVar3) { + return; + } + if (!gMapManager->func_ov00_020836dc((u32) mUnk_020.mUnk_00[1], 0)) { + return; + } + if (mUnk_020.mUnk_0a[0] != 0 && !this->func_ov00_020c1bfc(0)) { + return; + } + if (flag != 0 && !gAdventureFlags->Get(flag)) { + return; + } + + PlayerLinkBase *link = gPlayerLink; + if (link != NULL && link->vfunc_18(7)) { + if (mUnk_020.mUnk_00[3] == 1) { + link->func_ov000_020bcf50(&mPos, 0x800); + } + this->func_ov00_020c1c20(1, 1); + this->Kill(); + } +} + +ARM void ActorActionObject::vfunc_18(u32 param1) { + this->func_ov00_020c313c(param1); +} diff --git a/src/00_Core/Actor/Dungeon/ActorEventIcon.cpp b/src/00_Core/Actor/Dungeon/ActorEventIcon.cpp index 8e943095..22e35d8e 100644 --- a/src/00_Core/Actor/Dungeon/ActorEventIcon.cpp +++ b/src/00_Core/Actor/Dungeon/ActorEventIcon.cpp @@ -4,10 +4,10 @@ ActorType ActorEventIcon::gType = ActorType(ActorTypeId_EventIcon, (ActorCreateF ActorEventIcon *ActorEventIcon::Create() {} ActorEventIcon::ActorEventIcon() {} -bool ActorEventIcon::vfunc_08() {} +bool ActorEventIcon::Init() {} void ActorEventIcon::vfunc_14(u32 param1) {} void ActorEventIcon::vfunc_18(u32 param1) {} u32 ActorEventIcon::func_ov000_02090648(u32 param1) {} -bool func_ov000_02090774(u32 param1) {} +bool ActorEventIcon::func_ov000_02090774(u32 param1) {} void ActorEventIcon::vfunc_1c(u16 *param1) {} ActorEventIcon::~ActorEventIcon() {} diff --git a/src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp b/src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp index 37c4511c..78e229db 100644 --- a/src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp +++ b/src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp @@ -1,15 +1,110 @@ #include "Actor/Dungeon/ActorSwitchObject.hpp" +#include "Map/MapManager.hpp" ActorType ActorSwitchObject::gType = ActorType(ActorTypeId_SwitchObject, (ActorCreateFunc) ActorSwitchObject::Create, NULL); ActorSwitchObject *ActorSwitchObject::Create() {} -bool ActorSwitchObject::vfunc_08() {} -void ActorSwitchObject::vfunc_0c() {} -void ActorSwitchObject::vfunc_14(u32 param1) {} -void ActorSwitchObject::vfunc_18(u32 param1) {} -bool ActorSwitchObject::func_ov000_0208fc10(s32 param1) {} -void ActorSwitchObject::func_ov000_0208fc7c() {} + +bool ActorSwitchObject::Init() { + Actor::Init(); + this->func_ov000_0208fc7c(); + this->mUnk_130 = 0; + return true; +} + +bool ActorSwitchObject::vfunc_0c() { + return this->func_ov00_020c1bfc(0) ? this->func_ov000_0208fc10(1) : this->func_ov000_0208fc10(0); +} + +void ActorSwitchObject::vfunc_14(u32 param1) { + bool bVar1; + u32 uVar2; + u32 uVar3; + s32 iVar4; + s32 iVar5; + + bVar1 = this->func_ov00_020c313c(param1); + if (bVar1 == NULL) { + return; + } + uVar2 = this->mUnk_130; + switch (uVar2) { + default: + if (uVar2 == 2) { + break; + } + return; + case 0: + uVar3 = this->func_ov000_0208fcb4(); + switch (uVar3) { + case 1: this->func_ov000_0208fc10(1); return; + case 2: this->func_ov000_0208fc10(2); return; + default: return; + } + bVar1 = this->func_ov000_0208fc10(2); + return; + case 1: + iVar4 = this->func_ov000_0208fcb4(); + if (iVar4 == 1) { + return; + } + bVar1 = this->func_ov000_0208fc10(0); + return; + } + + iVar5 = this->mActiveFrames + 1; + this->mActiveFrames = iVar5; + if (iVar5 < 0x1e) { + return; + } + + this->func_ov000_0209032c(); + bVar1 = this->func_ov000_0208fc10(0); + + return; +} + +void ActorSwitchObject::vfunc_18(u32 param1) { + this->vfunc_14(param1); +} + +bool ActorSwitchObject::func_ov000_0208fc10(s32 param1) { + this->mUnk_130 = param1; + + switch (param1) { + case 0: this->func_ov00_020c1c20(0, 0); break; + case 1: + this->func_ov00_020c1c20(0, 1); + if (this->mUnk_158 == 0) { + this->mAlive = false; + } + break; + case 2: + this->func_ov000_0208fef8(); + this->mActiveFrames = 0; + break; + } + + return true; +} + +void ActorSwitchObject::func_ov000_0208fc7c() { + this->mUnk_158 = this->mUnk_020.mUnk_00[1]; + this->mUnk_15c = this->mUnk_020.mUnk_00[2]; + this->mUnk_164 = this->mUnk_020.mUnk_0a[1]; + this->mUnk_168 = this->mUnk_164 + this->mUnk_020.mUnk_00[0]; + this->mUnk_16c = this->mUnk_020.mUnk_08[1]; + this->mUnk_160 = this->mUnk_164; +} + bool ActorSwitchObject::func_ov000_0208fcb4() {} void ActorSwitchObject::func_ov000_0208fef8() {} -void ActorSwitchObject::func_ov000_0209032c() {} + +void ActorSwitchObject::func_ov000_0209032c() { + unk32 i; + for (i = this->mUnk_164; i < this->mUnk_168; i++) { + gMapManager->func_ov00_02084b38(i, this->mUnk_16c, 0); + } +} + ActorSwitchObject::~ActorSwitchObject() {} diff --git a/src/00_Core/Actor/Navi/ActorForceNavi.cpp b/src/00_Core/Actor/Navi/ActorForceNavi.cpp new file mode 100644 index 00000000..04b83c13 --- /dev/null +++ b/src/00_Core/Actor/Navi/ActorForceNavi.cpp @@ -0,0 +1,14 @@ +#include "Actor/Navi/ActorForceNavi.hpp" + +#pragma section sbss begin +ActorType ActorForceNavi::gType = ActorType(ActorTypeId_ForceNavi, (ActorCreateFunc) ActorForceNavi::Create, NULL); +#pragma section sbss end + +extern u32 **data_027e0fe0[]; +ActorForceNavi *ActorForceNavi::Create() { + return new(*data_027e0fe0[0], 4) ActorForceNavi(); +} + +ARM FairyId ActorForceNavi::GetFairyId() { + return FairyId_Power; +} diff --git a/src/00_Core/Actor/Navi/ActorNavi.cpp b/src/00_Core/Actor/Navi/ActorNavi.cpp new file mode 100644 index 00000000..7c195178 --- /dev/null +++ b/src/00_Core/Actor/Navi/ActorNavi.cpp @@ -0,0 +1,32 @@ +#include "Actor/Navi/ActorNavi.hpp" +#include "Player/EquipHammer.hpp" + +ActorType ActorNavi::gType = ActorType(ActorTypeId_Navi, (ActorCreateFunc) ActorNavi::Create, NULL); +UnkStruct_ov000_020b8110 data_ov000_020ee1cc; + +ActorNavi *ActorNavi::Create() {} +UnkStruct_ov000_020b8110::UnkStruct_ov000_020b8110() : + UnkStruct_ov000_020beba8(7) {} +UnkStruct_ov000_020b8110::~UnkStruct_ov000_020b8110() {} +void UnkStruct_ov000_020b8110::vfunc_08(unk16 *param1) {} +void UnkStruct_ov000_020b8110::vfunc_18(s32 *param1) {} +void UnkStruct_ov000_020b8110::vfunc_14(u16 *param1) {} +void ActorNavi::func_ov000_020b8200() {} +void ActorNavi::vfunc_c4() {} +void ActorNavi::vfunc_c8() {} +FairyId ActorNavi::GetFairyId() {} +s32 ActorNavi::vfunc_b8() {} +void ActorNavi::vfunc_d4() {} +void ActorNavi::vfunc_d0() {} +void ActorNavi::SetActive(bool active) {} +void ActorNavi::vfunc_e0() {} +void ActorNavi::vfunc_d8() {} +void ActorNavi::vfunc_20(bool param1) {} +bool ActorNavi::vfunc_cc(unk32 *param1) {} +bool ActorNavi::vfunc_c0(Vec3p *param1) {} +void ActorNavi::vfunc_e8() {} +bool ActorNavi::vfunc_8c() {} +void ActorNavi::vfunc_ec() {} +EquipHammer *GetEquipHammer() {} +void ActorNavi::func_ov000_020b853c() {} +ActorNavi::~ActorNavi() {} diff --git a/src/00_Core/Actor/Navi/ActorWisdomNavi.cpp b/src/00_Core/Actor/Navi/ActorWisdomNavi.cpp new file mode 100644 index 00000000..84c02e33 --- /dev/null +++ b/src/00_Core/Actor/Navi/ActorWisdomNavi.cpp @@ -0,0 +1,14 @@ +#include "Actor/Navi/ActorWisdomNavi.hpp" + +#pragma section sbss begin +ActorType ActorWisdomNavi::gType = ActorType(ActorTypeId_WisdomNavi, (ActorCreateFunc) ActorWisdomNavi::Create, NULL); +#pragma section sbss end + +extern u32 **data_027e0fe0[]; +ARM ActorWisdomNavi *ActorWisdomNavi::Create() { + return new(*data_027e0fe0[0], 4) ActorWisdomNavi(); +} + +ARM FairyId ActorWisdomNavi::GetFairyId() { + return FairyId_Wisdom; +} diff --git a/src/00_Core/Item/ItemManager.cpp b/src/00_Core/Item/ItemManager.cpp index 96fbad4c..3c77b0ab 100644 --- a/src/00_Core/Item/ItemManager.cpp +++ b/src/00_Core/Item/ItemManager.cpp @@ -1,6 +1,8 @@ #include "Item/ItemManager.hpp"
#include "DTCM/UnkStruct_027e0d38.hpp"
#include "DTCM/UnkStruct_027e0f78.hpp"
+#include "DTCM/UnkStruct_027e103c.hpp"
+#include "Item/ItemModelLoader.hpp"
#include "Map/MapManager.hpp"
#include "Player/PlayerLinkBase.hpp"
#include "Player/PlayerManager.hpp"
@@ -126,7 +128,7 @@ ARM FairyId ItemManager::GetEquippedFairy() const { return fairy;
}
-ARM ActorNavi *ItemManager::GetFairy(FairyId id) const {
+ARM ActorNaviBase *ItemManager::GetFairy(FairyId id) const {
return mFairies[id];
}
@@ -158,17 +160,15 @@ ARM ItemModel *ItemManager::GetItemModel(ItemModelId id) { return mItemModels[id];
}
-extern unk32 gItemModelLoader;
-extern "C" void *func_ov00_020bb3a8(unk32 param1, u32 index);
-extern "C" void func_ov00_020c0bdc(void *param1, unk32 param2);
+extern "C" void func_ov000_020c0bdc(unk32 param1, unk32 param2);
ARM void ItemManager::func_ov00_020ad538(unk32 param1) const {
- void *unk1 = func_ov00_020bb3a8(gItemModelLoader, 6);
- func_ov00_020c0bdc(unk1, param1);
+ unk32 unk1 = gItemModelLoader->func_ov000_020bb3a8(6);
+ func_ov000_020c0bdc(unk1, param1);
}
ARM void ItemManager::func_ov00_020ad560(unk32 param1) const {
- void *unk1 = func_ov00_020bb3a8(gItemModelLoader, 7);
- func_ov00_020c0bdc(unk1, param1);
+ unk32 unk1 = gItemModelLoader->func_ov000_020bb3a8(7);
+ func_ov000_020c0bdc(unk1, param1);
}
ARM ItemModel *ItemManager::GetDungeonItemModel(u32 index) {
@@ -176,8 +176,8 @@ ARM ItemModel *ItemManager::GetDungeonItemModel(u32 index) { }
ARM void ItemManager::func_ov00_020ad594(unk32 param1) const {
- void *unk1 = func_ov00_020bb3a8(gItemModelLoader, 11);
- func_ov00_020c0bdc(unk1, param1);
+ unk32 unk1 = gItemModelLoader->func_ov000_020bb3a8(11);
+ func_ov000_020c0bdc(unk1, param1);
}
ARM void ItemManager::Sword_vfunc_38(unk32 param1) {
@@ -231,30 +231,25 @@ ARM u16 ItemManager::GetAmmo(ItemFlag equipId) const { return (*mAmmo)[equipId];
}
-ARM void ItemManager::GiveAmmo(ItemFlag equipId, u16 amount) {
+ARM void ItemManager::GiveAmmo(ItemFlag equipId, u32 amount) {
(*mAmmo)[equipId] += amount;
if ((*mAmmo)[equipId] <= this->GetMaxAmmo(equipId)) return;
(*mAmmo)[equipId] = this->GetMaxAmmo(equipId);
}
-extern "C" unk32 func_ov00_02078b40(UnkStruct_027e0d38 *param1);
extern void *data_027e10a4;
-extern "C" bool func_ov15_02136670(void *param1);
-extern unk8 data_ov29_0217a4ac[];
-extern "C" bool _ZN14PlayerLinkBase18func_ov00_020bbd80Ei(unk32 param1, unk32 param2);
-extern "C" bool _ZNK11ItemManager7HasItemEi();
-extern "C" void _ZN11ItemManager12GetEquipItemEi();
+extern "C" bool func_ov015_02136670(void *param1);
+extern u8 data_ov022_0217a4ac[];
ARM bool ItemManager::func_ov00_020ad790(unk32 param1) {
- unk32 unk1 = func_ov00_02078b40(data_027e0d38);
- if (unk1 == 2) return func_ov15_02136670(data_027e10a4);
+ unk32 unk1 = data_027e0d38->func_ov000_02078b40();
+ if (unk1 == 2) return func_ov015_02136670(data_027e10a4);
if (data_027e0d38->mUnk_14 == 1) return false;
- // NONMATCH: OverlayId_29 should be in constant pool
- if (gOverlayManager.mLoadedOverlays[OverlayIndex_6] == OverlayId_29 && data_ov29_0217a4ac[0x54] != 0) {
+ if (gOverlayManager.mLoadedOverlays[OverlayIndex_6] == OverlayId_29 && data_ov022_0217a4ac[0x54] != 0) {
return false;
}
ItemFlag equipId = mForcedItem;
- bool unk2 = !gMapManager->func_ov00_020849f8(equipId);
+ bool unk2 = !gMapManager->func_ov00_020849f8();
if (mEquippedItem != ItemFlag_None && (unk2 || (u32) mEquippedItem - 9 <= 1) &&
(gPlayerLink == 0 || gPlayerLink->func_ov000_020bbd80(param1)) && this->HasItem(mEquippedItem))
{
@@ -320,7 +315,7 @@ THUMB void ItemManager::SetUnk_09e(u32 index, u16 value) { }
const u16 sQuiverSizes[] = {20, 20, 30, 50};
-const u16 sBombBagSizes[] = {10, 20, 30};
+const u16 sBombBagSizes[] = {10, 20, 30, 0};
THUMB u16 ItemManager::GetMaxAmmo(ItemFlag equipId) const {
switch (equipId) {
@@ -379,8 +374,8 @@ THUMB void ItemManager::RemoveItem(ItemFlag item) { extern ItemModel **data_027e1058;
extern ItemModel **data_027e105c;
-extern "C" ItemModel *func_ov00_02079ffc(void *, const char *modelName, const char *textureName, unk32 param4, unk8 param5,
- unk8 param6, bool param7);
+extern "C" ItemModel *LoadNsbTexturedModel(void *, const char *modelName, const char *textureName, unk32 param4, unk8 param5,
+ unk8 param6, bool param7);
extern "C" ItemModel *LoadTreasureItemFanfare(ItemModel **, s32 treasureType, bool, bool);
static char *sDefaultItemModel = "key";
static char *sItemModelNames[70] = {
@@ -391,47 +386,47 @@ static char *sItemModelNames[70] = { [ItemId_WoodenShield] = "shA",
[ItemId_Unk_5] = NULL,
[ItemId_Unk_6] = "force_y",
- [ItemId_BombBag] = "bomb\0\0\0",
+ [ItemId_BombBag] = "bomb",
[ItemId_Bow] = "bow",
[ItemId_BigGreenRupee] = "rupee_g",
- [ItemId_HeartContainer] = "heart_utu\0\0",
+ [ItemId_HeartContainer] = "heart_utu",
[ItemId_Unk_11] = NULL,
- [ItemId_Boomerang] = "boomerang\0\0",
+ [ItemId_Boomerang] = "boomerang",
[ItemId_Scoop] = "scp",
- [ItemId_BombchuBag] = "bomchu\0",
+ [ItemId_BombchuBag] = "bomchu",
[ItemId_BossKey] = "bosskey",
[ItemId_Unk_16] = "rev_bin",
[ItemId_Unk_17] = NULL,
[ItemId_PhantomHourglass] = NULL,
- [ItemId_SWSeaChart] = "mapSea\0",
- [ItemId_NWSeaChart] = "mapSea\0",
- [ItemId_SESeaChart] = "mapSea\0",
- [ItemId_NESeaChart] = "mapSea\0",
+ [ItemId_SWSeaChart] = "mapSea",
+ [ItemId_NWSeaChart] = "mapSea",
+ [ItemId_SESeaChart] = "mapSea",
+ [ItemId_NESeaChart] = "mapSea",
[ItemId_Unk_23] = NULL,
[ItemId_BlueRupee] = "rupee_b",
[ItemId_RedRupee] = "rupee_r",
[ItemId_BigRedRupee] = "rupee_r",
- [ItemId_GoldRupee] = "rupee_go\0\0\0",
+ [ItemId_GoldRupee] = "rupee_go",
[ItemId_Unk_28] = "force_y",
[ItemId_Unk_29] = "force_r",
[ItemId_Unk_30] = "force_b",
[ItemId_Hammer] = "ham",
- [ItemId_Rope] = "rope\0\0\0",
- [ItemId_SquareCrystal] = "cstl_c\0",
- [ItemId_RoundCrystal] = "cstl_s\0",
- [ItemId_TriangleCrystal] = "cstl_t\0",
- [ItemId_FishingRod] = "fp\0",
+ [ItemId_Rope] = "rope",
+ [ItemId_SquareCrystal] = "cstl_c",
+ [ItemId_RoundCrystal] = "cstl_s",
+ [ItemId_TriangleCrystal] = "cstl_t",
+ [ItemId_FishingRod] = "fp",
[ItemId_Cannon] = NULL,
- [ItemId_SunKey] = "key_su\0",
+ [ItemId_SunKey] = "key_su",
[ItemId_Unk_39] = NULL,
- [ItemId_Quiver] = "arrowpod\0\0\0",
- [ItemId_BigBombBag] = "bmbagM\0",
- [ItemId_BigBombchuBag] = "bcbagM\0",
+ [ItemId_Quiver] = "arrowpod",
+ [ItemId_BigBombBag] = "bmbagM",
+ [ItemId_BigBombchuBag] = "bcbagM",
[ItemId_Unk_43] = NULL,
- [ItemId_KingsKey] = "key_ki\0",
- [ItemId_PowerGem] = "minaP\0\0",
- [ItemId_WisdomGem] = "minaC\0\0",
- [ItemId_CourageGem] = "minaY\0\0",
+ [ItemId_KingsKey] = "key_ki",
+ [ItemId_PowerGem] = "minaP",
+ [ItemId_WisdomGem] = "minaC",
+ [ItemId_CourageGem] = "minaY",
[ItemId_PinkCoral] = NULL,
[ItemId_WhitePearlLoop] = NULL,
[ItemId_DarkPearlLoop] = NULL,
@@ -440,44 +435,40 @@ static char *sItemModelNames[70] = { [ItemId_RutoCrown] = NULL,
[ItemId_HelmarocPlume] = NULL,
[ItemId_RegalRing] = NULL,
- [ItemId_GhostKey] = "key_gh\0",
- [ItemId_FreebieCard] = "tic_tada\0\0\0",
- [ItemId_ComplimentCard] = "tic_ohome\0\0",
- [ItemId_ComplimentaryCard] = "tic_rare\0\0\0",
- [ItemId_RegalNecklace] = "neckl\0\0",
- [ItemId_SalvageArm] = "slvarm\0",
+ [ItemId_GhostKey] = "key_gh",
+ [ItemId_FreebieCard] = "tic_tada",
+ [ItemId_ComplimentCard] = "tic_ohome",
+ [ItemId_ComplimentaryCard] = "tic_rare",
+ [ItemId_RegalNecklace] = "neckl",
+ [ItemId_SalvageArm] = "slvarm",
[ItemId_HerosNewClothes] = NULL,
- [ItemId_Kaleidoscope] = "telescope\0\0",
- [ItemId_GuardNotebook] = "notebook\0\0\0",
- [ItemId_JolenesLetter] = "letter\0",
- [ItemId_PrizePostcard] = "card\0\0\0",
- [ItemId_WoodHeart] = "marron\0",
+ [ItemId_Kaleidoscope] = "telescope",
+ [ItemId_GuardNotebook] = "notebook",
+ [ItemId_JolenesLetter] = "letter",
+ [ItemId_PrizePostcard] = "card",
+ [ItemId_WoodHeart] = "marron",
[ItemId_PhantomSwordBlade] = "swBedge",
[ItemId_PhantomSword] = NULL,
};
static char *sItemModelNames2[8] = {
- [ItemId_SwordsmanScroll - ItemId_SwordsmanScroll] = "makimono\0\0\0",
- [ItemId_Crimsonine - ItemId_SwordsmanScroll] = "hagaH\0\0",
- [ItemId_Azurine - ItemId_SwordsmanScroll] = "hagaK\0\0",
- [ItemId_Aquanine - ItemId_SwordsmanScroll] = "hagaS\0\0",
+ [ItemId_SwordsmanScroll - ItemId_SwordsmanScroll] = "makimono",
+ [ItemId_Crimsonine - ItemId_SwordsmanScroll] = "hagaH",
+ [ItemId_Azurine - ItemId_SwordsmanScroll] = "hagaK",
+ [ItemId_Aquanine - ItemId_SwordsmanScroll] = "hagaS",
[ItemId_RedPotion - ItemId_SwordsmanScroll] = "rev_bin",
- [ItemId_PurplePotion - ItemId_SwordsmanScroll] = "rev_binP\0\0\0",
- [ItemId_YellowPotion - ItemId_SwordsmanScroll] = "rev_binY\0\0\0",
- [ItemId_SandOfHours - ItemId_SwordsmanScroll] = "sand_m\0",
+ [ItemId_PurplePotion - ItemId_SwordsmanScroll] = "rev_binP",
+ [ItemId_YellowPotion - ItemId_SwordsmanScroll] = "rev_binY",
+ [ItemId_SandOfHours - ItemId_SwordsmanScroll] = "sand_m",
};
static char *sItemModelNames3[9] = {
- [ItemId_CycloneSlate - ItemId_CycloneSlate] = "compass",
- [ItemId_Unk_128 - ItemId_CycloneSlate] = "lure\0\0\0",
- [ItemId_Rupoor10 - ItemId_CycloneSlate] = "rupee_bb\0\0\0",
- [ItemId_Rupoor50 - ItemId_CycloneSlate] = "rupee_bb\0\0\0",
- [ItemId_Unk_131 - ItemId_CycloneSlate] = NULL,
- [ItemId_Unk_132 - ItemId_CycloneSlate] = NULL,
- [ItemId_Unk_133 - ItemId_CycloneSlate] = NULL,
- [ItemId_Unk_134 - ItemId_CycloneSlate] = NULL,
- [ItemId_Unk_135 - ItemId_CycloneSlate] = NULL,
+ [ItemId_CycloneSlate - ItemId_CycloneSlate] = "compass", [ItemId_BigCatchLure - ItemId_CycloneSlate] = "lure",
+ [ItemId_Rupoor10 - ItemId_CycloneSlate] = "rupee_bb", [ItemId_Rupoor50 - ItemId_CycloneSlate] = "rupee_bb",
+ [ItemId_Unk_131 - ItemId_CycloneSlate] = NULL, [ItemId_Unk_132 - ItemId_CycloneSlate] = NULL,
+ [ItemId_Unk_133 - ItemId_CycloneSlate] = NULL, [ItemId_Unk_134 - ItemId_CycloneSlate] = NULL,
+ [ItemId_Unk_135 - ItemId_CycloneSlate] = NULL,
};
char *sSpecialItemModelNames[7] = {
- "mapTakara\0\0", "arrowpodL\0\0", "bmbagL\0", "bcbagL\0", "Player/get/gd_\0", ".nsbmd\0", ".nsbtx\0",
+ "mapTakara", "arrowpodL", "bmbagL", "bcbagL", "Player/get/gd_", ".nsbmd", ".nsbtx",
};
THUMB void ItemManager::LoadFanfareItem(ItemId id) {
mFanfareItem = id;
@@ -521,7 +512,7 @@ THUMB void ItemManager::LoadFanfareItem(ItemId id) { strcat(textureName, sSpecialItemModelNames[4]);
strcat(textureName, itemName);
strcat(textureName, sSpecialItemModelNames[6]);
- model = func_ov00_02079ffc(mFanfareItemModel, modelName, textureName, 0, 0, 0, true);
+ model = LoadNsbTexturedModel(mFanfareItemModel, modelName, textureName, 0, 0, 0, true);
}
mUnk_114->vfunc_0c(model);
}
@@ -787,8 +778,8 @@ THUMB void ItemManager::GiveItem(ItemId id) { SET_FLAG(mItemFlags.flags, ItemFlag_CycloneSlate);
} break;
- case ItemId_Unk_128: {
- SET_FLAG(mItemFlags.flags, ItemFlag_Unk_47);
+ case ItemId_BigCatchLure: {
+ SET_FLAG(mItemFlags.flags, ItemFlag_BigCatchLure);
} break;
case ItemId_Rupoor10: {
@@ -841,9 +832,6 @@ ARM s32 ItemManager::GetMaxRupees() const { return 9999;
}
-extern void *data_027e103c;
-extern "C" s32 func_ov00_020cf374(void *param1, bool param2);
-extern "C" void func_ov05_02104004(void *param1);
ARM void ItemManager::GiveRupees(s32 amount, bool param2) {
s32 newRupees = mNumRupees + amount;
if (newRupees > this->GetMaxRupees()) {
@@ -852,11 +840,11 @@ ARM void ItemManager::GiveRupees(s32 amount, bool param2) { newRupees = 0;
}
- s32 currRupees = func_ov00_020cf374(data_027e103c, true);
+ s32 currRupees = data_027e103c->func_ov000_020cf374(true);
if (param2) {
currRupees = mNumRupees;
if (currRupees != newRupees) {
- func_ov05_02104004(data_027e103c);
+ data_027e103c->WalletFull();
}
}
mNumRupees = newRupees;
@@ -994,7 +982,7 @@ THUMB void ItemManager::LoadDungeonItemModels() { }
}
-extern unk32 data_ov00_020eec68;
+extern unk32 data_ov000_020eec68;
extern "C" void PlaySoundEffect(void *param1, SfxId sfx);
THUMB void ItemManager::PlayItemFanfareSfx(ItemId item) {
if (gItemManager->mMuteNextFanfare == true) {
@@ -1043,7 +1031,7 @@ THUMB void ItemManager::PlayItemFanfareSfx(ItemId item) { gItemManager->mFanfareSfx = SfxId_None;
}
- PlaySoundEffect(&data_ov00_020eec68, sfx);
+ PlaySoundEffect(&data_ov000_020eec68, sfx);
}
THUMB bool ItemManager::HasShipPartPriceShown(ShipPart part, ShipType type) const {
diff --git a/src/00_Core/Map/MapManager.cpp b/src/00_Core/Map/MapManager.cpp index f3311bf5..46da8997 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(Vec2b *param1) {} unk8 MapManager::func_ov00_020840dc() {} unk8 MapManager::func_ov00_02084100(unk32 param_1, MapManager *param_2) {} unk8 MapManager::GetMapData_Unk_48() {} @@ -165,7 +165,7 @@ unk8 MapManager::GetMapData_Unk_07() {} unk8 MapManager::func_ov00_0208499c() {} unk8 MapManager::func_ov00_020849c0() {} unk8 MapManager::func_ov00_020849dc() {} -bool MapManager::func_ov00_020849f8(unk32 param_1) {} +bool MapManager::func_ov00_020849f8() {} unk8 MapManager::func_ov00_02084a50() {} void MapManager::SpawnNPC(Vec3p *param_2, unk32 param_3, unk32 param_4) {} bool MapManager::func_ov00_02084ac4(u32 actorId) {} @@ -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(MapManager *param_1, Vec3p *param_2, s32 param_3) {} s32 MapManager::func_ov00_02085a34(unk32 param_2, unk32 param_3) {} diff --git a/src/00_Core/Player/LinkStateBase.cpp b/src/00_Core/Player/LinkStateBase.cpp index dce6b0d5..5db80967 100644 --- a/src/00_Core/Player/LinkStateBase.cpp +++ b/src/00_Core/Player/LinkStateBase.cpp @@ -16,7 +16,7 @@ void LinkStateBase::UpdateSwordShieldInUse() {} void LinkStateBase::func_ov00_020a81b8(unk32 param1, unk32 param2) {} LinkStateItem *LinkStateBase::GetLinkItemState() {} void LinkStateBase::LookAt(Vec3p *target) {} -void LinkStateBase::func_ov00_020a81fc() {} +void LinkStateBase::func_ov00_020a81fc(Vec3p *param1, unk32 param2) {} void LinkStateBase::AddHealth(s16 amount) {} void LinkStateBase::func_ov00_020a8224(unk32 param1) {} void LinkStateBase::TurnTo(s16 angle, unk32 param2, unk32 speed) {} @@ -38,7 +38,7 @@ bool LinkStateBase::func_ov00_020a8638(unk32 param1) {} void LinkStateBase::Clear_PlayerLinkBase_Unk48(u16 flags) {} void LinkStateBase::func_ov00_020a8680(unk32 param1, unk16 param2, bool param3) {} void LinkStateBase::PlayerLinkBase_func_ov00_020bccc8() {} -bool LinkStateBase::PlayerLinkBase_vfunc_58() {} +bool LinkStateBase::PlayerLinkBase_vfunc_58(unk32 param1, ActorRef *param2) {} bool LinkStateBase::func_ov00_020a8704(s16 *pAngle) {} bool LinkStateBase::func_ov00_020a8774(Vec3p *param1, s32 angle) {} void LinkStateBase::func_ov00_020a8844(Vec3p *param1, bool param2, bool param3) {} @@ -46,7 +46,7 @@ void LinkStateBase::func_ov00_020a8954(bool param1, unk32 *param2) {} void LinkStateBase::func_ov00_020a8994() {} void LinkStateBase::func_ov00_020a89bc(unk32 *param1, unk32 param2) {} void LinkStateBase::func_ov00_020a8a08(unk32 param1) {} -void LinkStateBase::func_ov00_020a8a4c(unk32 param1, unk32 param2) {} +void LinkStateBase::func_ov00_020a8a4c(const void *param1, unk32 param2) {} void LinkStateBase::func_ov00_020a8a90(unk32 param1) {} void LinkStateBase::func_ov00_020a8ab0(unk32 param1) {} void LinkStateBase::func_ov00_020a8ad0(unk32 param1) {} diff --git a/src/00_Core/Player/LinkStateItem.cpp b/src/00_Core/Player/LinkStateItem.cpp index 240b94c8..9e42961f 100644 --- a/src/00_Core/Player/LinkStateItem.cpp +++ b/src/00_Core/Player/LinkStateItem.cpp @@ -1,5 +1,6 @@ #include "Player/LinkStateItem.hpp" #include "DTCM/UnkStruct_027e103c.hpp" +#include "DTCM/UnkStruct_027e1098.hpp" #include "Item/ItemManager.hpp" #include "Player/EquipBomb.hpp" #include "Player/EquipHammer.hpp" @@ -8,13 +9,8 @@ #include "Player/PlayerControl.hpp" #include "Save/AdventureFlags.hpp" -extern void func_ov000_020cf9dc(s32 param1, s32 param2, s32 param3); -extern void func_ov014_0213ec64(s32 param1); -extern void func_ov014_0211fd04(s32 *param1); extern void func_ov000_020b7e6c(s32 *param1); -extern s32 *data_027e1098; - THUMB void LinkStateItem::vfunc_00() {} ARM LinkStateId LinkStateItem::GetId() { @@ -42,7 +38,7 @@ ARM void LinkStateItem::OnStateLeave(s32 param1) { if (*(u8 *) (iVar3 + 0xe0) == '\0') { GetEquipBombchu()->func_ov014_0213ec64(); } - func_ov014_0211fd04(data_027e1098); + data_027e1098->func_ov014_0211fd04(); break; case ItemFlag_OshusSword: break; case ItemFlag_WoodenShield: break; diff --git a/src/00_Core/Player/LinkStateMove.cpp b/src/00_Core/Player/LinkStateMove.cpp index 918a92fe..5509be66 100644 --- a/src/00_Core/Player/LinkStateMove.cpp +++ b/src/00_Core/Player/LinkStateMove.cpp @@ -1,10 +1,71 @@ #include "Player/LinkStateMove.hpp" -void LinkStateMove::vfunc_00() {} -LinkStateId LinkStateMove::GetId() {} -void LinkStateMove::CreateDebugHierarchy() {} -void LinkStateMove::OnStateEnter() {} -void LinkStateMove::OnStateLeave(s32 param1) {} -bool LinkStateMove::vfunc_24(s32 param1) {} -bool LinkStateMove::func_ov00_020a8f2c() {} -bool LinkStateMove::func_ov00_020a8f4c() {} +unk32 LinkStateMove::data_ov000_020e56f0 = 0x800; + +THUMB void LinkStateMove::vfunc_00() {} + +ARM LinkStateId LinkStateMove::GetId() { + return LinkStateId_Move; +} + +THUMB void LinkStateMove::CreateDebugHierarchy() { + unk32 id = 'LMOV'; + // Breath volume decay rate "息吹きボリューム低下率" + const char *description = "\x91\xa7\x90\x81\x82\xab\x83{\x83\x8a\x83\x85\x81[\x83\x80\x92\xe1\x89\xba\x97\xa6"; + + DebugHierarchy *debugHierarchy = this->GetDebugHierarchy0(); + debugHierarchy->vfunc_3c(id, &data_ov000_020e56f0); + + debugHierarchy->GetChildNode(1, description, id, &data_ov000_020e56f0, 8, 0, 0x1000, 0); +} + +extern u32 data_ov000_020eec9c; +extern "C" void func_ov000_020d77e4(void *param1, s32 param2); + +ARM void LinkStateMove::OnStateEnter() { + this->mUnk_0c = 0; + this->mUnk_10 = 0; + this->mUnk_12 = 0; + if (this->mUnk_14 == 0) { + return; + } + + EquipItem *sword = this->GetEquipItem(ItemFlag_OshusSword); + sword->UpdateInUse(1); + EquipItem *shield = this->GetEquipItem(ItemFlag_WoodenShield); + shield->UpdateInUse(1); + + PlayerBase::GetEquipSword()->func_ov000_020c06b0(-1); + func_ov000_020d77e4(&data_ov000_020eec9c, 0xD); +} + +ARM void LinkStateMove::OnStateLeave(s32 param1) { + LinkStateBase::OnStateLeave(param1); + this->mUnk_14 = 0; + this->mUnk_15 = 0; + this->mUnk_16 = 0; +} + +ARM bool LinkStateMove::vfunc_24(s32 param1) { + if (this->GetHealth() > 0) { + return LinkStateBase::vfunc_24(param1); + } + switch (param1) { + case 2: return true; + default: return false; + } +} + +ARM bool LinkStateMove::func_ov00_020a8f2c() { + static unk32 data_ov000_020e56f4 = 0x100; + return this->mUnk_0c > data_ov000_020e56f4; +} + +ARM bool LinkStateMove::func_ov00_020a8f4c() { + if (this->mUnk_15) { + return false; + } + this->mUnk_15 = true; + this->mUnk_16 = false; + return true; +} diff --git a/src/00_Core/Player/PlayerControl.cpp b/src/00_Core/Player/PlayerControl.cpp index 6cf39bda..406fe1da 100644 --- a/src/00_Core/Player/PlayerControl.cpp +++ b/src/00_Core/Player/PlayerControl.cpp @@ -1,52 +1,1066 @@ #include "Player/PlayerControl.hpp" +#include "Actor/ActorManager.hpp" +#include "Actor/Navi/ActorNaviBase.hpp" +#include "DTCM/UnkStruct_027e05f8.hpp" +#include "DTCM/UnkStruct_027e077c.hpp" +#include "DTCM/UnkStruct_027e0c68.hpp" +#include "DTCM/UnkStruct_027e0d38.hpp" +#include "DTCM/UnkStruct_027e0e2c.hpp" +#include "DTCM/UnkStruct_027e0f64.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" -bool PlayerControl::func_ov00_020aeeac() {} -void PlayerControl::func_ov00_020aeef8() {} -void PlayerControl::func_ov00_020aef30() {} -void PlayerControl::UpdateAim() {} -Actor *PlayerControl::GetFollowActor() {} -bool PlayerControl::func_ov00_020af01c(unk8 *param1) {} -void PlayerControl::SetUnk_80() {} -void PlayerControl::StopFollowing() {} -void PlayerControl::func_ov00_020af06c() {} -void PlayerControl::UpdateUsingEquipItem() {} -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() {} -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_020affec(Vec3p *param1, s32 y, s32 param3, Vec3p *param4) {} -void PlayerControl::func_ov00_020b014c() {} -void PlayerControl::SetAim() {} -bool PlayerControl::UpdateAimWorld(Vec3p *param1) {} -s16 PlayerControl::GetTouchAngle() {} -u32 PlayerControl::func_ov00_020b034c() {} -s32 PlayerControl::func_ov00_020b0418() {} -bool PlayerControl::func_ov00_020b049c(Vec3p *param1, bool param2) {} -bool PlayerControl::func_ov00_020b05e8(Vec3p *param1) {} -bool PlayerControl::func_ov00_020b0778(Vec3p *param1, u32 param2, unk32 param3) {} -bool PlayerControl::CheckNotTouching() {} -bool PlayerControl::func_ov00_020b0ad0(Actor *actor) {} -bool PlayerControl::func_ov00_020b0b0c(s16 *pAngle, ItemFlag *pEquipId, unk32 *pCardinal, bool *pFast) {} -bool PlayerControl::func_ov00_020b0de8(Vec3p *param1) {} -bool PlayerControl::func_ov00_020b0e54(Vec3p *param1, Vec3p *param2) {} -bool PlayerControl::func_ov00_020b0f88(Vec3p *param1, unk32 param2, Vec3p *param3) {} -bool PlayerControl::func_ov00_020b1058(Vec3p *param1, unk32 param2, Vec3p *param3, Vec3p *param4) {} -bool PlayerControl::IsUntouchedNow() {} -bool PlayerControl::IsNotUntouchedNow() {} -bool PlayerControl::func_ov00_020b1248(unk32 *param1) {} -bool PlayerControl::func_ov00_020b129c() {} -bool PlayerControl::func_ov00_020b12d0(s16 *pAngle) {} -bool PlayerControl::IsNotTouching() {} -bool PlayerControl::IsTouchingFast() {} -bool PlayerControl::IsTappedNow() {} -bool PlayerControl::func_ov00_020b13c4() {} +static char *sShipTypes[] = {"brg", "anc", "pdl", "hul", "can", "dco", "bow", "fnl"}; + +ARM bool PlayerControl::func_ov00_020aeeac() { + if (((data_02056be4[data_027e077c.GetUnk0()] & 1) != 0) || ((data_02056be4[data_027e077c.GetUnk0()] & 4) != 0)) { + return false; + } + return data_027e077c.GetUnk0() == data_027e077c.GetUnk4(); +} + +ARM bool PlayerControl::func_ov00_020aeef8() { + if (data_027e077c.GetUnk0() == 0x37 || data_027e077c.GetUnk0() == 0x3b) { + return false; + } + if (data_027e077c.GetUnk0() == 0x3d) { + return true; + } + return func_ov00_020aeeac(); +} + +THUMB void PlayerControl::func_ov00_020aef30() { + this->ResetTouchWorld(); + if (mDebug) { + // 操作 = Operation + mDebug->vfunc_20(0, "\x91\x80\x8d\xec", 'PCTL', 'PLYR', 0, 0); + } +} + +// NONMATCH: Instruction ordering +THUMB void PlayerControl::UpdateAim() { + ResetTouchWorld(); + mAimWorld.x = 0; + mAimWorld.y = 0; + mAimWorld.z = 0; + mUnk_80 = false; + mUnk_82 = 0; + mFollowRef.Reset(); + mNextFollowRef.Reset(); + mFollowing = false; + mAim = gVec3p_ZERO; + s32 iVar2 = data_027e0d38->func_ov000_02078b40(); + if (iVar2 == 2) { + data_027e103c->func_ov000_020cf2b8(); + } + mUnk_c8 = -1; + mUnk_cc = -1; +} + +ARM Actor *PlayerControl::GetFollowActor() { + return gActorManager->GetActor(&mFollowRef); +} + +ARM bool PlayerControl::func_ov00_020af01c(Vec2b *param1) { + if (mFollowing) { + *param1 = mUnk_9c; + return true; + } + return false; +} + +ARM void PlayerControl::SetUnk_80() { + mUnk_80 = true; +} + +ARM void PlayerControl::StopFollowing() { + mFollowRef.Reset(); + mFollowing = false; + mFollowObject = NULL; +} + +ARM void PlayerControl::func_ov00_020af06c() { + if (!mUnk_78) { + mUsingEquipItem = false; + return; + } + ItemFlag equippedItem; + bool usingEquipItem = mUsingEquipItem; + if (mUnk_7a) { + mUnk_7b = usingEquipItem; + } + if (gAdventureFlags->func_ov00_02097738() || data_027e0c68.mUnk_04 != 0) { + if (data_027e0d38->func_ov000_02078b40() != 2) { + mUsingEquipItem = false; + } + return; + } + ItemManager *itemManager = gItemManager; + equippedItem = itemManager->mEquippedItem; + if (equippedItem == ItemFlag_PotionA) { + if (itemManager->HasPotion(0)) { + mUsingEquipItem = true; + return; + } + } else if (equippedItem == ItemFlag_PotionB) { + if (itemManager->HasPotion(1)) { + mUsingEquipItem = true; + return; + } + } + if (data_027e0d38->func_ov000_02078b40() == 2) { + mUnk_7b = true; + mUnk_7b = (mUnk_7b & gItemManager->func_ov00_020ad790(1)) != 0; + } else { + if (((data_027e05f8.mUnk_0 & 0x300) != 0) && mUnk_7e != 0 && func_ov00_020aeef8()) { + mUnk_7b = true; + } else { + if (((data_027e05f8.mUnk_0 & 0x300) == 0) && mUnk_83) { + mUnk_7b = false; + } else { + if (data_027e103c->mUnk_20 == 2 && !mTouch && func_ov00_020aeef8()) { + mUnk_7b = !mUnk_7b; + mUnk_7c = 0; + } + } + } + mUnk_7b = (mUnk_7b & gItemManager->func_ov00_020ad790(1)) != 0; + + if (equippedItem == ItemFlag_Hammer && !usingEquipItem && mUnk_7b == true) { + ActorNaviBase *courageFairy = gItemManager->GetFairy(FairyId_Courage); + if (courageFairy != NULL) { + q20 x = courageFairy->mPos.x; + q20 y = gPlayerPos.y + FLOAT_TO_Q20(0.5); + q20 z = courageFairy->mPos.z; + mAimWorld.x = x; + mAimWorld.y = y; + mAimWorld.z = z; + } + } + } + if (mUnk_7a) { + mUsingEquipItem = mUnk_7b; + } +} + +void PlayerControl::UpdateUsingEquipItem() { + if ((data_027e05f8.mUnk_0 & 0x300) != 0 && this->func_ov00_020aeef8()) { + mUsingEquipItem = true; + return; + } + mUsingEquipItem = false; +} + +struct UnkStruct_ov015_0213ce4c { + /* 00 */ unk8 mUnk_00[0x3d]; + /* 3d */ bool mUnk_3d; + /* 3e */ unk8 mUnk_3e[0x1]; + /* 3f */ bool mUnk_3f; + /* 40 */ bool mUnk_40; + /* 41 */ + + static UnkStruct_ov015_0213ce4c *GetInstance(); + + bool GetUnk3f(); + bool GetUnk40(); +}; + +bool PlayerControl::func_ov00_020af2d4(u32 param1, bool param2) { + if (data_027e0d38->func_ov000_02078b40() == 2 && param2) { + if (UnkStruct_ov015_0213ce4c::GetInstance()->mUnk_3d) { + return false; + } + if (UnkStruct_ov015_0213ce4c::GetInstance()->GetUnk3f() || UnkStruct_ov015_0213ce4c::GetInstance()->GetUnk40()) { + return false; + } + } + + if (mUnk_7c) { + bool unk1 = true; + bool unk2 = false; + if ((param1 & 0x2) != 0 && (data_02056be4[data_027e077c.GetUnk0()] & 0x1) != 0) { + unk2 = true; + } + if (!unk2 && ((param1 & 0x1) == 0 || !this->func_ov00_020aeef8() || !data_027e103c->mUnk_24)) { + unk1 = false; + } + return unk1; + } else { + return (param1 & 0x4) != 0; + } +} + +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.GetUnk0()) { + 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; + + bool unk = !mUnk_78 || gAdventureFlags->func_ov00_02097738() || data_027e0c68.mUnk_04; + if (unk || !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 = NULL; + if ((mFlags & TouchFlag_UntouchedNow) != 0 && mTouchDuration < 21) { + s32 dx = mTouchLastX - mTouchFastX; + s32 dy = mTouchLastY - mTouchFastY; + if (dx * dx + dy * dy < 100) { + if (this->func_ov00_020af2d4(7, true)) { + bVar1 = true; + if (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(iVar4)) { + this->func_ov00_020af6e4(&vec, followDistance, uVar4); + return true; + } + if (followDistance == 0 && equipItem->vfunc_40()) { + this->ApplyTouchWorld(&vec, 0); + this->func_ov00_020af6e4(&vec, followDistance, 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); + ItemManager *itemMgr = gItemManager; + FairyId fairyId = itemMgr->GetEquippedFairy(); + ActorNaviBase *fairy = itemMgr->GetFairy(fairyId); + + if (followActor == NULL && !mFollowing && fairy != NULL) { + fairy->func_ov000_020bad18(); + } + + q20 followDist = mFollowDist; + if (followActor != NULL) { + 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 5: + iVar8 = 2; + uVar9 = 1; + followHitbox.pos.y += followActor->mYOffset; + break; + case 2: + iVar8 = 3; + followHitbox.pos.y += followHitbox.size; + uVar9 = 0; + break; + default: + iVar8 = 2; + followHitbox.pos.y += followHitbox.size; + uVar9 = 2; + break; + } + if (iVar8 != 0 && gPlayerLink->GetCurrentCharacter() == PlayerCharacter_Link) { + this->func_ov00_020aff90(&followHitbox.pos, iVar8); + if (iVar1) { + data_027e0ffc.func_ov000_020ced64(&followHitbox, followActor->mRef.id, uVar9); + } + } + } else { + mFollowRef.Reset(); + } + + if (mFollowing) { + mFollowObject = (void *) gMapManager->MapData_vfunc_78(&mUnk_9c); + Vec3p local_3c; + s32 iVar2; + s32 iVar7; + if (mFollowObject != NULL) { + local_3c = *(Vec3p *) ((u32) mFollowObject + 0x18); + void *piVar4 = (*(void *(**) (void *) )((*(u32 *) mFollowObject) + 0x54))(mFollowObject); + if (piVar4 == NULL) { + iVar7 = 0; + } else { + iVar7 = (*(s32(**)(void *))((*(u32 *) piVar4) + 0x44))(piVar4); + } + local_3c.y += iVar7; + if (*(s8 *) ((u32) mFollowObject + 0x12) == 1) { + iVar2 = 1; + iVar7 = 3; + } else { + iVar2 = 2; + iVar7 = 2; + } + } else { + local_3c.y = gPlayerPos.y; + Vec2b local_44 = mUnk_9c; + gMapManager->func_ov00_02083c7c(&local_3c, local_44); + iVar2 = 2; + iVar7 = 3; + } + + if (iVar2 != 0 && gPlayerLink->GetCurrentCharacter() == PlayerCharacter_Link) { + this->func_ov00_020aff90(&local_3c, iVar2); + if (iVar1) { + data_027e0ffc.func_ov000_020ced7c(&local_3c, mUnk_9c.x, mUnk_9c.y, iVar7); + } + } + followDist = Vec3p_Distance(&gPlayerPos, &local_3c); + } else { + mFollowObject = NULL; + } + + if (mFollowStuckTimer > 0 && mFollowDist - followDist <= FLOAT_TO_Q20(0.01)) { + mFollowStuckTimer -= 1; + if (mFollowStuckTimer <= 0) { + this->StopFollowing(); + } + } + + mFollowDist = followDist; +} + +ARM bool PlayerControl::func_ov00_020afe88(s32 param1, bool param2) { + if (!mUnk_7d || !gPlayerControlData->vfunc_74(param1)) { + return false; + } + if (!param2) { + return true; + } + return param1 == 2 || param1 == 6; +} + +ARM bool PlayerControl::func_ov00_020afeec(unk32 param1, bool param2) { + if (!mUnk_7d) { + return false; + } + if (!gPlayerControlData->vfunc_78(param1)) { + return false; + } + switch (param1) { + case 1: + case 2: + case 7: + case 13: return true; + + case 10: + case 11: return param2; + + default: return !param2; + } +} + +ARM void PlayerControl::func_ov00_020aff90(Vec3p *param1, unk32 param2) { + if (data_027e0d38->func_ov000_02078b40() == 2) { + return; + } + ItemManager *itemMgr = gItemManager; + FairyId fairyId = itemMgr->GetEquippedFairy(); + ActorNaviBase *fairy = itemMgr->GetFairy(fairyId); + if (fairy == NULL) { + return; + } + fairy->func_ov000_020baca8(param1, param2); +} + +ARM void PlayerControl::func_ov00_020affec(Vec3p *param1, s32 y, s32 param3, Vec3p *param4) { + if (mUnk_44.x != 0 || mUnk_44.z != 0) { + Vec3p local_24; + Vec3p_Axpy(y, &mUnk_44, &mTouchWorld, &local_24); + + Vec3p local_30 = {param4->x - local_24.x, 0, param4->z - local_24.z}; + q20 iVar2 = Vec3p_Length(&local_30); + if (iVar2 <= param3) { + *param1 = local_24; + return; + } + + Vec3p local_3c = {mUnk_44.x, 0, mUnk_44.z}; + q20 lengthInv = CoReciprocal(Vec3p_Length(&local_3c)); + local_3c.x = MUL_Q20(local_3c.x, lengthInv); + local_3c.z = MUL_Q20(local_3c.z, lengthInv); + iVar2 = Vec3p_Dot(&local_30, &local_3c); + + Vec3p local_48 = local_3c; + local_48.y = lengthInv; + Vec3p_Axpy(iVar2 - param3, &local_48, &local_24, param1); + return; + } + + param1->x = mTouchWorld.x; + param1->y = y; + param1->z = mTouchWorld.z; +} + +#pragma section sbss begin +static u32 data_ov000_020ee198; +static u32 data_ov000_020ee19c; +#pragma section sbss end + +ARM void PlayerControl::func_ov00_020b014c(Vec3p *param1) { + if ((data_ov000_020ee198 & 1) == 0) { + data_ov000_020ee198 |= 1; + } + if (*(s32 *) ((s32) data_027e0f64->mUnk_4 + 0x15c) == 0x16) { + return; + } + if (!this->func_ov00_020aeef8()) { + return; + } + if (mTouchDuration > 0) { + ItemManager *itemMgr = gItemManager; + FairyId fairyId = itemMgr->GetEquippedFairy(); + ActorNaviBase *fairy = itemMgr->GetFairy(fairyId); + if (fairy != NULL) { + Vec3p auStack_1c; + this->func_ov00_020affec(&auStack_1c, FLOAT_TO_Q20(0.5), FLOAT_TO_Q20(8.0), param1); + fairy->func_ov000_020ba204(&auStack_1c, &mUnk_44, mTouchWorld.y + FLOAT_TO_Q20(4.2)); + } + } +} + +ARM void PlayerControl::ResetAim() { + mAim = gVec3p_ZERO; +} + +extern "C" s32 func_ov000_020a5e9c(unk32 *param1); + +ARM bool PlayerControl::UpdateAimWorld(Vec3p *param1) { + Vec3p pos = gPlayerPos; + + s32 iVar2 = func_ov000_020a5e9c(&data_027e0d38->mUnk_0c); + if (iVar2 == 0x2f && *(s32 *) (*(s32 *) ((s32) data_027e0f64 + 0x4) + 0x15c) == 0x31) { + return this->func_ov024_02178348(param1); + } + + if (this->CheckTouching(1)) { + this->func_ov00_020affec(param1, 0, FLOAT_TO_Q20(8.0), &pos); + mAimWorld = *param1; + return true; + } + *param1 = mAimWorld; + return false; +} + +ARM s16 PlayerControl::GetTouchAngle() { + if (mTouchDuration >= 0) { + return mTouchAngle; + } + if (!mUnk_7f) { + return 0; + } + return mUnk_ac; +} + +static q20 data_ov000_020e6144 = FLOAT_TO_Q20(80.0); + +ARM u32 PlayerControl::func_ov00_020b034c() { + if ((mTouchDuration >= 0) && (this->func_ov00_020af2d4(1, 1) != 0)) { + u64 temp_r0_r1 = func_01ff992c(data_ov000_020e6144); // 0x03333333 + s32 temp_r3 = (temp_r0_r1 * mTouchDist + 0x80000000) >> 32; + s32 temp_r1_r0 = MUL_Q20(temp_r3, temp_r3); + if (mTouchDuration < 4) { + s32 temp_r2_2 = (4 - mTouchDuration) << 0xc; + temp_r1_r0 -= (s32) (temp_r2_2 + ((u32) (temp_r2_2 >> 1) >> 0x1e)) >> 2; + } + if (temp_r1_r0 < 0) { + return 0; + } + if (temp_r1_r0 > FLOAT_TO_Q20(1.0)) { + temp_r1_r0 = FLOAT_TO_Q20(1.0); + } + return temp_r1_r0; + } + if ((mUnk_7f != 0) && (data_027e05f8.mUnk_0 & 0xf0)) { + return FLOAT_TO_Q20(1.0); + } + return 0; +} + +extern unk32 data_ov000_020eec60; +extern "C" unk32 func_ov000_020d6be4(unk32 *param1); + +ARM s32 PlayerControl::func_ov00_020b0418() { + unk32 unk = func_ov000_020d6be4(&data_ov000_020eec60); + if (unk < 10) { + return 0; + } + if (unk < 25) { + return (unk * FLOAT_TO_Q20(0.6666)) / 25; + } + if (unk < 150) { + return (unk - 25) * FLOAT_TO_Q20(0.3334) / 125 + FLOAT_TO_Q20(0.6666); + } + return FLOAT_TO_Q20(1.0); +} + +extern "C" void func_0202d95c(Vec3p *param1, q20 param2); +// NONMATCH: Register allocation, instruction ordering +ARM bool PlayerControl::func_ov00_020b049c(Vec3p *param1, bool param2) { + if (this->CheckUntouchedNow(1) && mTouchDuration >= 0 && mTouchDuration < 21) { + this->ApplyTouchWorld(param1, FLOAT_TO_Q20(0.25)); + Vec3p_Sub(param1, &gPlayerPos, param1); + q20 length = Vec3p_Length(param1); + if (length >= FLOAT_TO_Q20(1.25)) { + return true; + } + if (param2) { + if (length < FLOAT_TO_Q20(0.25)) { + *param1 = gVec3p_ZERO; + param1->x += MUL_Q20(SIN(gPlayerAngle), FLOAT_TO_Q20(1.25)); + param1->z += MUL_Q20(COS(gPlayerAngle), FLOAT_TO_Q20(1.25)); + } else { + func_0202d95c(param1, FLOAT_TO_Q20(1.25)); + } + return true; + } + } + return false; +} + +ARM bool PlayerControl::func_ov00_020b05e8(Vec3p *param1) { + if (this->CheckUntouchedNow(1) && mTouchDuration >= 0 && mTouchDuration < 21) { + Vec3p *playerPos = &gPlayerPos; + + Vec3p VStack_1c; + this->ApplyTouchWorld(&VStack_1c, FLOAT_TO_Q20(0.2)); + VStack_1c.y = gPlayerPos.y; + + q20 distance = Vec3p_Distance(&VStack_1c, playerPos); + if (distance > FLOAT_TO_Q20(1.25)) { + return false; + } + + if (distance < FLOAT_TO_Q20(0.25)) { + VStack_1c = *playerPos; + VStack_1c.x += MUL_Q20(SIN(gPlayerAngle), FLOAT_TO_Q20(0.25)); + VStack_1c.z += MUL_Q20(COS(gPlayerAngle), FLOAT_TO_Q20(0.25)); + } + + Vec2b VStack_20; + MapManager::func_ov00_02083a1c(&VStack_20, gMapManager, &VStack_1c); + VStack_1c.x += (gMapManager->func_ov00_02083c24(VStack_20.x) - VStack_1c.x) / 2; + VStack_1c.z += (gMapManager->func_ov00_02083c50(VStack_20.y) - VStack_1c.z) / 2; + Vec3p_Sub(&VStack_1c, playerPos, param1); + return true; + } + return false; +} + +extern "C" bool func_01ffe468(unk32 param1, Vec3p *param2, s32 *param3, s32 *param4, bool param5); + +ARM bool PlayerControl::func_ov00_020b0778(Vec3p *param1, u32 angle, unk32 *param3) { + Vec3p spC; + *param3 = 0; + spC = *param1; + + s32 sp8; + s32 sp4; + bool var_r0 = !func_01ffe468(data_027e0f64->func_ov000_0208b180(), &spC, &sp8, &sp4, 0); + if (var_r0) { + return 0; + } + + // NONMATCH: Register allocation + q20 temp_r2 = SIN((u16) angle) * 0x30; + q20 temp_r3 = COS((u16) angle) * 0x30; + s32 temp_r4; + s32 temp_r5; + q20 var_r6; + q20 var_r7; + var_r6 = (s32) (temp_r2 + ((u32) (temp_r2 >> 11) >> 20)) >> 0xC; + var_r7 = (s32) (temp_r3 + ((u32) (temp_r3 >> 11) >> 20)) >> 0xC; + temp_r4 = mTouchX - sp8; + temp_r5 = mTouchY - sp4; + if (this->CheckTouchedNow(1) != 0) { + if (((var_r6 - 0x18) <= temp_r4) && (temp_r4 <= (var_r6 + 0x18)) && ((var_r7 - 0x18) <= temp_r5) && + (temp_r5 <= (var_r7 + 0x18))) + { + *param3 = FLOAT_TO_Q20(1.0); + return true; + } + if (((-0x18 - var_r6) <= temp_r4) && (temp_r4 <= (0x18 - var_r6)) && ((-0x18 - var_r7) <= temp_r5) && + (temp_r5 <= (0x18 - var_r7))) + { + *param3 = -FLOAT_TO_Q20(1.0); + return true; + } + s32 temp_r1_2 = 0 - var_r6; + s32 var_r0_2 = var_r6 < temp_r1_2 ? var_r6 : temp_r1_2; + if (temp_r4 >= (var_r0_2 - 0x18)) { + if (var_r6 <= temp_r1_2) { + var_r6 = temp_r1_2; + } + if ((var_r6 + 0x18) >= temp_r4) { + s32 temp_r1_3 = 0 - var_r7; + s32 var_r0_3 = var_r7 < temp_r1_3 ? var_r7 : temp_r1_3; + if (temp_r5 >= (var_r0_3 - 0x18)) { + if (var_r7 <= temp_r1_3) { + var_r7 = temp_r1_3; + } + if ((var_r7 + 0x18) >= temp_r5) { + goto ret_true; + } + } + } + } + return false; + } + if (this->CheckTouching(1) != 0) { + if (((var_r6 < 0) && (temp_r4 < (var_r6 + 0x18))) || ((var_r6 > 0) && (temp_r4 > (var_r6 - 0x18))) || + ((var_r7 < 0) && (temp_r5 < (var_r7 + 0x18))) || ((var_r7 > 0) && (temp_r5 > (var_r7 - 0x18)))) + { + *param3 = FLOAT_TO_Q20(1.0); + return true; + } + if (((var_r6 > 0) && (temp_r4 < (0x18 - var_r6))) || ((var_r6 < 0) && (temp_r4 > (-0x18 - var_r6))) || + ((var_r7 > 0) && (temp_r5 < (0x18 - var_r7))) || ((var_r7 < 0) && (temp_r5 > (-0x18 - var_r7)))) + { + *param3 = -FLOAT_TO_Q20(1.0); + return true; + } + } else if (this->CheckUntouchedNow(1) != 0) { + if (var_r6 < 0) { + var_r6 = -var_r6; + } + if (var_r7 < 0) { + var_r7 = -var_r7; + } + s32 var_r2 = mTouchPrevX - sp8; + s32 var_r1 = mTouchPrevY - sp4; + // NONMATCH: Instruction ordering + if (var_r6 > 0x18) { + if (var_r2 < 0) { + var_r2 = -var_r2; + } + if (var_r2 > (var_r6 - 0x18)) { + goto ret_false; + } + } + if (var_r7 > 0x18) { + if (var_r1 < 0) { + var_r1 = -var_r1; + } + if (var_r1 > (var_r7 - 0x18)) { + ret_false: + return false; + } + } + } +ret_true: + return true; +} + +ARM bool PlayerControl::CheckNotTouching() { + return !this->CheckTouching(1); +} + +ARM bool PlayerControl::func_ov00_020b0ad0(Actor *actor) { + if (actor != NULL && actor->mRef.id == mLastFollowRef.id) { + return mTouchDuration >= 15 && mTouchDuration < 30; + } + return false; +} + +ARM bool PlayerControl::func_ov00_020b0b0c(s16 *pAngle, ItemFlag *pEquipId, unk32 *pCardinal, bool *pFast) { + if (mUsingEquipItem && gItemManager->func_ov00_020ad790(1)) { + ItemFlag equipId = gItemManager->GetEquippedItem(); + *pEquipId = equipId; + data_027e103c->func_ov000_020cf330(); + return *pEquipId != ItemFlag_None; + } + + *pEquipId = ItemFlag_OshusSword; + if (this->func_ov00_020b1248(pCardinal)) { + *pEquipId = ItemFlag_OshusSword; + return true; + } + + if ((this->CheckUntouchedNow(1) && mTouchDuration >= 0 && mTouchDuration < 21) || + (this->CheckTouchFast(1) && mTouchSlowDuration > 21)) + { + s32 dy = INT_TO_Q20(mTouchLastY - mTouchFastY); + s32 dx = INT_TO_Q20(mTouchLastX - mTouchFastX); + Vec3p local_20; + local_20.x = dx; + local_20.y = 0; + local_20.z = dy; + q20 length = Vec3p_Length(&local_20); + if (length < FLOAT_TO_Q20(10.0)) { + return false; + } + if (mUnk_82 && length < FLOAT_TO_Q20(20.0)) { + return false; + } + + *pEquipId = ItemFlag_OshusSword; + *pAngle = mTouchAngle + ((s16) (mTouchFastAngle - mTouchAngle)) / 2; + + if (mTouchSpeed > FLOAT_TO_Q20(0.5)) { + q4 touchMoveAngle = Atan2(mTouchSpeedX, mTouchSpeedY) - *pAngle; + if (pFast != NULL) { + *pFast = true; + } + *pCardinal = touchMoveAngle >= 0 ? 1 : 2; + return true; + } + + s32 unkAngle = Atan2(local_20.x, local_20.z); + + s32 unkAngle2 = (s16) ((s16) unkAngle - *pAngle); + Vec3p VStack_2c = {INT_TO_Q20(mTouchFastX), INT_TO_Q20(mTouchFastY), 0}; + Vec3p VStack_38 = {INT_TO_Q20(mTouchLastX), INT_TO_Q20(mTouchLastY), 0}; + + Vec3p_Sub(&VStack_38, &VStack_2c, &VStack_38); + if (mTouchDist <= FLOAT_TO_Q20(10.0)) { + *pCardinal = 0; + *pAngle = mTouchFastAngle; + return true; + } + if (unkAngle2 >= 0x6000 || unkAngle2 <= -0x6000) { + *pCardinal = 0; + } else if (unkAngle2 >= 0x2000) { + *pCardinal = 1; + } else if (unkAngle2 < -0x2000) { + *pCardinal = 2; + } else { + *pCardinal = 3; + } + return true; + } + return false; +} + +// NONMATCH: Instruction ordering +ARM bool PlayerControl::func_ov00_020b0de8(Vec3p *param1) { + if (!this->CheckTouching(1)) { + return false; + } + s32 z = (mTouchLastY - 96) * FLOAT_TO_Q20(10.625) / 192; + s32 x = (mTouchLastX - 128) * (FLOAT_TO_Q20(10.625) / 256); + param1->x = x; + param1->y = 0; + param1->z = z; + return true; +} + +ARM bool PlayerControl::func_ov00_020b0e54(Vec3p *param1, Vec3p *param2) { + Vec3p local_20; + if (mTouchDuration >= 16 && this->func_ov00_020b0de8(&local_20)) { + this->ApplyTouchWorld(param1, FLOAT_TO_Q20(0.5)); + q20 length = Vec3p_Length(&local_20); + if (length > FLOAT_TO_Q20(4.0)) { + local_20.x = DIV_Q20(local_20.x * 4, length); + local_20.z = DIV_Q20(local_20.z * 4, length); + } + mAim = local_20; + *param2 = local_20; + return true; + } + + if (mTouchDuration >= 0 && this->func_ov00_020af2d4(1, true)) { + if (mTouchDist > FLOAT_TO_Q20(24.0)) { + this->ApplyTouchWorld(param1, FLOAT_TO_Q20(0.5)); + } else { + *param1 = gPlayerPos; + } + return true; + } + + return false; +} + +extern "C" bool func_0202b2e8(Vec3p *param1, Vec3p *param2, q20 param3); +ARM bool PlayerControl::func_ov00_020b0f88(Vec3p *param1, unk32 scale, Vec3p *param3) { + Vec3p local_20; + if (this->func_ov00_020b0de8(&local_20)) { + this->ApplyTouchWorld(param1, scale); + q20 length = Vec3p_Length(&local_20); + if (length > FLOAT_TO_Q20(4.0)) { + local_20.x = DIV_Q20(local_20.x * 4, length); + local_20.z = DIV_Q20(local_20.z * 4, length); + } + q20 touchSpeed = CoSqrt((mTouchDiffX * mTouchDiffX + mTouchDiffY * mTouchDiffY + 4) * 0x10); + func_0202b2e8(param3, &local_20, touchSpeed); + mAim = local_20; + return true; + } + return false; +} + +ARM bool PlayerControl::func_ov00_020b1058(Vec3p *param1, unk32 param2, Vec3p *param3, Vec3p *param4) { + Vec3p local_24; + if (this->func_ov00_020b0de8(&local_24)) { + this->ApplyTouchWorld(param1, param2); + if (param4 != NULL) { + Vec3p local_30; + Vec3p_Sub(param4, &gPlayerPos, &local_30); + local_30.x = MUL_Q20(local_30.x, FLOAT_TO_Q20(0.5)); + local_30.y = MUL_Q20(local_30.y, FLOAT_TO_Q20(0.5)); + local_30.z = MUL_Q20(local_30.z, FLOAT_TO_Q20(0.5)); + func_0202b2e8(&local_30, &local_24, FLOAT_TO_Q20(2.5)); + local_24 = local_30; + } + q20 length = Vec3p_Length(&local_24); + if (length > FLOAT_TO_Q20(4.0)) { + local_24.x = DIV_Q20(local_24.x * 4, length); + local_24.z = DIV_Q20(local_24.z * 4, length); + } + q20 touchSpeed = CoSqrt((mTouchDiffX * mTouchDiffX + mTouchDiffY * mTouchDiffY + 4) * 0x10); + func_0202b2e8(param3, &local_24, touchSpeed); + mAim = *param3; + return true; + } + return false; +} + +ARM bool PlayerControl::IsUntouchedNow() { + return this->CheckUntouchedNow(7) && data_027e103c->mUnk_1c == 0; +} + +ARM bool PlayerControl::IsNotUntouchedNow() { + if (!this->CheckUntouchedNow(7)) { + return (data_027e05f8.mUnk_2 & 3) != 0; + } + return true; +} + +ARM bool PlayerControl::func_ov00_020b1248(unk32 *param1) { + if (*this->mTouchGesture != NULL && (*this->mTouchGesture)->mUnk_4) { + *param1 = (*this->mTouchGesture)->mUnk_08 == 0 ? 5 : 6; + (*this->mTouchGesture)->ResetTouchHistory(); + return true; + } + return false; +} + +ARM bool PlayerControl::func_ov00_020b129c() { + return mTouchDuration < 2 || mTouchDuration > 10 || mTouchDuration != mTimeSinceTouch; +} + +ARM bool PlayerControl::func_ov00_020b12d0(s16 *pAngle) { + if (!this->func_ov00_020af2d4(1, true)) { + return false; + } + if (mTouchSlowDuration <= 15 && this->func_ov000_020b7d6c() && mTouchEdge == mTouchLastEdge) { + *pAngle = mTouchAngle; + return true; + } + return false; +} + +ARM bool PlayerControl::IsNotTouching() { + return !mTouch; +} + +extern u32 data_ov000_020eec9c[]; +extern "C" void func_ov000_020d77e4(u32 *param1, u32 param2); +ARM bool PlayerControl::IsTouchingFast() { + if (this->CheckTouchFast(1)) { + func_ov000_020d77e4(data_ov000_020eec9c, 0x17); + return true; + } + return false; +} + +ARM bool PlayerControl::IsTappedNow() { + return mTouchDuration < 10 && this->func_ov00_020af2d4(1, true) && this->CheckUntouchedNow(1); +} + +ARM bool PlayerControl::func_ov00_020b13c4() { + if (!this->CheckTouching(1)) { + return false; + } + func_01ff992c(data_ov000_020e6144); + q20 touchDist = mTouchDist; + s32 iVar2 = mTouchDuration; + if (mTouchFastTime > 0 && mTouchFastTime < iVar2) { + iVar2 = (iVar2 - mTouchFastTime) << 16 >> 16; + } + if (touchDist >= FLOAT_TO_Q20(80.0)) { + return iVar2 >= 2; + } + if (mTouchDist < FLOAT_TO_Q20(16.0)) { + return false; + } + q20 uVar4 = CoReciprocal(FLOAT_TO_Q20(64.0)); + q20 unk1 = MUL_Q20(mTouchDist - FLOAT_TO_Q20(16.0), uVar4); + return iVar2 >= MUL_Q20(FLOAT_TO_Q20(1.0) - unk1, FLOAT_TO_Q20(0.0058)) + 2; +} diff --git a/src/00_Core/Player/PlayerControlData.cpp b/src/00_Core/Player/PlayerControlData.cpp index 50e6c853..1485048a 100644 --- a/src/00_Core/Player/PlayerControlData.cpp +++ b/src/00_Core/Player/PlayerControlData.cpp @@ -18,8 +18,8 @@ void PlayerControlData::vfunc_2c() {} void PlayerControlData::vfunc_30() {} void PlayerControlData::vfunc_34() {} unk32 PlayerControlData::vfunc_7c() {} -unk32 PlayerControlData::vfunc_74() {} -unk32 PlayerControlData::vfunc_78() {} +unk32 PlayerControlData::vfunc_74(s32 param1) {} +unk32 PlayerControlData::vfunc_78(s32 param1) {} void PlayerControlData::func_ov000_020b484c(s32 param1, s32 param2, s32 param3) {} void PlayerControlData::vfunc_6c(s32 param1, Vec3p *param2) {} void PlayerControlData::vfunc_5c() {} diff --git a/src/00_Core/Player/PlayerLinkBase.cpp b/src/00_Core/Player/PlayerLinkBase.cpp index 897932c8..bc248044 100644 --- a/src/00_Core/Player/PlayerLinkBase.cpp +++ b/src/00_Core/Player/PlayerLinkBase.cpp @@ -20,7 +20,7 @@ bool PlayerLinkBase::func_ov000_020bba00() {} bool PlayerLinkBase::func_ov000_020bba14() {} bool PlayerLinkBase::func_ov000_020bba28() {} void PlayerLinkBase::func_ov000_020bba48() {} -void PlayerLinkBase::vfunc_18(s32 param1) {} +bool PlayerLinkBase::vfunc_18(s32 param1) {} bool PlayerLinkBase::CanMove() {} bool PlayerLinkBase::vfunc_58() {} bool PlayerLinkBase::vfunc_5c() {} diff --git a/src/00_Core/Player/TouchControl.cpp b/src/00_Core/Player/TouchControl.cpp index 5cae75a5..9630de1a 100644 --- a/src/00_Core/Player/TouchControl.cpp +++ b/src/00_Core/Player/TouchControl.cpp @@ -1,11 +1,39 @@ #include "Player/TouchControl.hpp" TouchControl::TouchControl() {} -void TouchControl::IncreaseSpeed(s16 increase) {} + +void TouchControl::IncreaseSpeed(s16 increase) { + this->mFlags = 0; + this->mSpeed += increase; +} + void TouchControl::UpdateFlags(u16 speed) {} void TouchControl::UpdateWithStateFlags(TouchStateFlags *state, u16 speed) {} void TouchControl::Update(TouchState *state, u16 speed) {} -bool TouchControl::func_ov00_0207aeac() {} +bool TouchControl::func_ov00_0207aeac() { + return ((*data_0207aecc & 0x8000) >> 15) == 1; +} void TouchControl::UpdateConditionally(TouchState *state, u16 speed) {} -void TouchControl::func_ov00_0207af38(u16 speed, bool param2) {} + +void TouchControl::func_ov00_0207af38(u16 speedIncrease, bool shouldIncrease) { + TouchStateFlags touchState; + + if (shouldIncrease) { + IncreaseSpeed(speedIncrease); /* TODO: IncreaseSpeed expects an s16 variable, + while speedIncrease is a u16. As a result, the function + performs a conversion that is not present in the binary. */ + return; + } + + u32 result = TouchControl::func_ov00_0207aeac(); + if (result != 0) { + Fill16(0, &touchState.touchX, 8); + } else { + + GetTouchStateFlags(&touchState); + } + + UpdateWithStateFlags(&touchState, speedIncrease); +} + TouchControl::~TouchControl() {} diff --git a/src/00_Core/Save/AdventureFlags.cpp b/src/00_Core/Save/AdventureFlags.cpp index 7ba5f7c6..012e9efa 100644 --- a/src/00_Core/Save/AdventureFlags.cpp +++ b/src/00_Core/Save/AdventureFlags.cpp @@ -1,9 +1,34 @@ #include "Save/AdventureFlags.hpp" +#include "Cutscene/CutsceneHandler.hpp" + +extern void func_ov000_020980f8(CutsceneHandler *cutsceneHandler); +extern unk32 func_ov000_020980fc(CutsceneHandler *cutsceneHandler); +extern bool func_ov000_02098114(CutsceneHandler *cutsceneHandler); +extern u8 data_ov000_020e310c[]; +extern u8 data_ov000_020e313c[]; +extern u8 data_ov000_020e3140[]; +extern u8 data_ov000_020e3144[]; +extern u8 data_ov000_020e314c[]; +extern u8 data_ov000_020e314e[]; +extern u8 data_ov000_020e3150[]; +extern u8 data_ov000_020e3154[]; +extern u8 data_ov000_020e3155[]; +extern u8 data_ov000_020e3156[]; + +bool AdventureFlags::Exists() { + return gAdventureFlags != NULL; +} -bool AdventureFlags::Exists() {} void AdventureFlags::CopyTo(unk32 *flags) {} -void AdventureFlags::func_ov00_02097674() {} -s32 AdventureFlags::func_ov00_02097684() {} + +void AdventureFlags::func_ov00_02097674() { + func_ov000_020980f8(this->mCutsceneHandler); +} + +s32 AdventureFlags::func_ov00_02097684() { + return func_ov000_020980fc(this->mCutsceneHandler); +} + void AdventureFlags::Load() {} void AdventureFlags::func_ov00_020976c8() {} void AdventureFlags::func_ov00_02097700() {} @@ -20,22 +45,83 @@ bool AdventureFlags::func_ov00_02097bbc() {} bool AdventureFlags::func_ov00_02097bcc() {} bool AdventureFlags::func_ov00_02097bcc(s32 param2) {} s32 AdventureFlags::func_ov00_02097c08() {} -bool AdventureFlags::Get_FlagsUnk_30_Flag(int index) {} -unk8 AdventureFlags::Get_FlagsUnk_49(int index) {} -unk8 AdventureFlags::Get_FlagsUnk_48(int index) {} -unk8 AdventureFlags::Get_FlagsUnk_4a(int index) {} -unk16 AdventureFlags::Get_FlagsUnk_42(int index) {} -unk16 AdventureFlags::Get_FlagsUnk_40(int index) {} -unk32 AdventureFlags::Get_FlagsUnk_38(int index) {} -unk32 AdventureFlags::Get_FlagsUnk_34(int index) {} -unk32 AdventureFlags::Get_FlagsUnk_44(int index) {} -unk32 AdventureFlags::Get_FlagsUnk_30(int index) {} -bool AdventureFlags::Get_FlagsUnk_00(int index, FlagsUnk2 *result) {} -bool AdventureFlags::Get_FlagsUnk_18(int index, FlagsUnk2 *result) {} -FlagsUnk *AdventureFlags::Get_FlagsUnk(int index) {} -bool AdventureFlags::func_ov00_02097e6c() {} -bool AdventureFlags::func_ov00_02097e7c() {} -bool AdventureFlags::func_ov00_02097ea4() {} + +bool AdventureFlags::Get_FlagsUnk_30_Flag(s32 index) { + unk32 unk30 = this->Get_FlagsUnk_30(index); + + return this->Get(unk30); +} + +u8 AdventureFlags::Get_FlagsUnk_49(s32 index) { + return data_ov000_020e3155[index * 0x4C]; +} + +u8 AdventureFlags::Get_FlagsUnk_48(s32 index) { + return data_ov000_020e3154[index * 0x4C]; +} + +u8 AdventureFlags::Get_FlagsUnk_4a(s32 index) { + return data_ov000_020e3156[index * 0x4C]; +} + +u16 AdventureFlags::Get_FlagsUnk_42(s32 index) { + return *(u16 *) (data_ov000_020e314e + index * 0x4C); +} + +u16 AdventureFlags::Get_FlagsUnk_40(s32 index) { + return *(unk16 *) (data_ov000_020e314c + index * 0x4C); +} + +unk32 AdventureFlags::Get_FlagsUnk_38(s32 index) { + return *(unk32 *) (data_ov000_020e3144 + index * 0x4C); +} + +unk32 AdventureFlags::Get_FlagsUnk_34(s32 index) { + return *(unk32 *) (data_ov000_020e3140 + index * 0x4C); +} + +unk32 AdventureFlags::Get_FlagsUnk_44(s32 index) { + return *(unk32 *) (data_ov000_020e3150 + index * 0x4C); +} + +unk32 AdventureFlags::Get_FlagsUnk_30(s32 index) { + return *(unk32 *) (data_ov000_020e313c + index * 0x4C); +} + +bool AdventureFlags::Get_FlagsUnk_00(s32 index, FlagsUnk2 *result) {} +bool AdventureFlags::Get_FlagsUnk_18(s32 index, FlagsUnk2 *result) {} + +FlagsUnk *AdventureFlags::Get_FlagsUnk(s32 index) { + return (FlagsUnk *) (data_ov000_020e310c + index * 0x4C); +} + +bool AdventureFlags::func_ov00_02097e6c() { + return func_ov000_02098114(this->mCutsceneHandler); +} + +bool AdventureFlags::func_ov00_02097e7c() { + bool bVar1; + + bVar1 = this->func_ov00_02097e6c(); + if (bVar1) { + bVar1 = this->mCutsceneHandler->SkipCutscene(0); + return bVar1; + } + + return false; +} + +bool AdventureFlags::func_ov00_02097ea4() { + bool bVar1; + + bVar1 = this->func_ov00_02097e6c(); + if (bVar1) { + bVar1 = this->mCutsceneHandler->SkipCutscene(1); + return bVar1; + } + + return false; +} unk32 AdventureFlags::func_ov00_02097ecc() {} void *AdventureFlags::func_ov00_02097f8c() {} void *AdventureFlags::func_ov00_02097fac() {} diff --git a/src/04_Load/Actor/Navi/ActorNavi.cpp b/src/04_Load/Actor/Navi/ActorNavi.cpp new file mode 100644 index 00000000..12939c04 --- /dev/null +++ b/src/04_Load/Actor/Navi/ActorNavi.cpp @@ -0,0 +1,3 @@ +#include "Actor/Navi/ActorNavi.hpp" + +ActorNavi::ActorNavi() {} diff --git a/src/04_Load/Actor/Navi/ActorNaviBase.cpp b/src/04_Load/Actor/Navi/ActorNaviBase.cpp index c4f5a069..21d91459 100644 --- a/src/04_Load/Actor/Navi/ActorNaviBase.cpp +++ b/src/04_Load/Actor/Navi/ActorNaviBase.cpp @@ -3,4 +3,4 @@ ActorNaviBase::ActorNaviBase() {} ActorNaviBase::~ActorNaviBase() {} void func_ov004_021079d4(unk32 *param1) {} -bool ActorNaviBase::vfunc_08() {} +bool ActorNaviBase::Init() {} diff --git a/src/04_Load/Player/LinkStateMove.cpp b/src/04_Load/Player/LinkStateMove.cpp index ffd5c89e..a844ddd2 100644 --- a/src/04_Load/Player/LinkStateMove.cpp +++ b/src/04_Load/Player/LinkStateMove.cpp @@ -1,5 +1,10 @@ #include "Player/LinkStateMove.hpp" -LinkStateMove::LinkStateMove(PlayerLinkBase *link) : - LinkStateBase(link) {} -LinkStateMove::~LinkStateMove() {} +THUMB LinkStateMove::LinkStateMove(PlayerLinkBase *link) : + LinkStateBase(link), + mUnk_0c(0), + mUnk_14(false), + mUnk_15(false), + mUnk_16(false) {} + +THUMB LinkStateMove::~LinkStateMove() {} diff --git a/src/05/Player/LinkStateMove.cpp b/src/05/Player/LinkStateMove.cpp index 367fd3f9..0ca48089 100644 --- a/src/05/Player/LinkStateMove.cpp +++ b/src/05/Player/LinkStateMove.cpp @@ -1,5 +1,247 @@ #include "Player/LinkStateMove.hpp" +#include "DTCM/UnkStruct_027e0d38.hpp" +#include "Player/LinkStateDamage.hpp" +#include "Player/LinkStateFollow.hpp" +#include "Player/LinkStateInteract.hpp" +#include "Player/LinkStateItem.hpp" +#include "Player/LinkStateRoll.hpp" +#include "Player/PlayerControl.hpp" +#include "Save/AdventureFlags.hpp" +#include "Unknown/UnkStruct_02037750.hpp" -void LinkStateMove::func_ov005_021113d0() {} -void LinkStateMove::vfunc_1c() {} -bool LinkStateMove::vfunc_3c() {} +class UnkFilterActor : public FilterActorBase { +public: + /* 00 (base) */ + /* 04 */ Actor *mActor; + /* 08 */ q20 mUnk_08; + /* 0c */ Vec3p mPos; + /* 18 */ s16 mAngle; + /* 1a */ + + /* 0 */ virtual bool Filter(Actor *actor) override; + /* 4 */ +}; + +struct UnkStruct_ov005_021123ac { + /* 00 */ unk32 mUnk_00; + /* 04 */ unk32 mUnk_04; + /* 08 */ unk32 mUnk_08; + /* 0c */ unk32 mUnk_0c; + /* 10 */ +}; + +ARM void LinkStateMove::func_ov005_021113d0() { + mUnk_12 = 10; +} + +static q4 data_ov005_02112be4 = FLOAT_TO_Q20(16 / 15.0); +static q20 data_ov005_02112be8 = FLOAT_TO_Q20(1 / 64.0); +static q20 data_ov005_02112bec = FLOAT_TO_Q20(1 / 3.0); +static const Vec3p data_ov005_021123ac = { + FLOAT_TO_Q20(0.0122), + FLOAT_TO_Q20(1.0), + FLOAT_TO_Q20(0.0), +}; +static Vec3p data_ov005_02112bf0 = { + FLOAT_TO_Q20(0.3), + FLOAT_TO_Q20(0.25), + FLOAT_TO_Q20(0.01), +}; +static const volatile q20 data_ov005_021123b8 = FLOAT_TO_Q20(15.0); + +extern LinkStateFollow *GetLinkStateFollow(); +extern unk32 data_027e0618; +extern "C" bool Lerp(s32 *pValue, s32 dest, s32 factor, unk32 param4, u32 step); +extern unk32 data_027e0ffc; +extern "C" void func_ov000_020ceacc(unk32 *param1, unk32 param2, Vec3p *param3, unk32 param4); +ARM void LinkStateMove::vfunc_1c() { + Actor *grabActor = this->GetGrabActor(); + Vec3p sp4C; + s32 temp_r7 = GetLinkStateFollow()->func_ov00_020a9180(&sp4C); + s32 temp_r0 = UnkStruct_02037750::GetLinkStateInteract()->func_ov00_020ab770(&sp4C); + bool var_r9; + if ((temp_r0 == 0) && (temp_r7 == 0)) { + var_r9 = false; + } else { + var_r9 = true; + } + LinkStateDamage *damage = (LinkStateDamage *) GetLinkState(LinkStateId_Damage); + if (damage->vfunc_20(var_r9) != 0) { + this->ChangeLinkState(LinkStateId_Damage); + return; + } + if ((gAdventureFlags->func_ov00_02097738() == 0) && (data_027e0d38->mUnk_14 != 1)) { + LinkStateInteract *interact = (LinkStateInteract *) GetLinkState(LinkStateId_Interact); + if (interact->vfunc_20(var_r9) != 0) { + this->ChangeLinkState(LinkStateId_Interact); + return; + } + LinkStateFollow *follow = (LinkStateFollow *) GetLinkState(LinkStateId_Follow); + if (follow->vfunc_20(var_r9) != 0) { + this->ChangeLinkState(LinkStateId_Follow); + return; + } + LinkStateRoll *roll = (LinkStateRoll *) GetLinkState(LinkStateId_Roll); + if (roll->vfunc_20(var_r9) != 0) { + this->ChangeLinkState(LinkStateId_Roll); + return; + } + LinkStateItem *item = (LinkStateItem *) GetLinkState(LinkStateId_Item); + if (item->vfunc_20(var_r9) != 0) { + this->ChangeLinkState(LinkStateId_Item); + return; + } + } + if ((temp_r0 == 2) || (temp_r7 == 8)) { + this->UpdateSwordShieldInUse(); + } else { + if ((temp_r0 == 3) || (temp_r0 == 4) || (temp_r0 == 5) || (temp_r7 == 3) || (temp_r7 == 4) || (temp_r7 == 5) || + (temp_r7 == 9) || ((temp_r7 - 0xD) <= 1U)) + { + this->EquipItem_vfunc_28(); + } + } + if (data_027e0618 != 6) { + s32 temp_r7_2 = gPlayerControl->func_ov00_020b0418(); + if ((this->func_ov00_020a8f2c() == 0) && (temp_r7_2 > 0)) { + mUnk_0c = temp_r7_2; + } + if (mUnk_0c > 0) { + + q4 temp_r8 = data_ov005_02112be4; + s16 temp_r1 = *this->GetPlayerAngle() + this->Get_PlayerControlData_Unk32(); + this->TurnTo(temp_r1, temp_r1, temp_r8); + s32 temp_r1_2 = mUnk_0c; + if (temp_r7_2 > temp_r1_2) { + temp_r1_2 = temp_r7_2 - temp_r1_2; + Lerp(&mUnk_0c, temp_r7_2 + temp_r1_2, data_ov005_02112bec, MUL_Q20(data_ov005_02112be8, data_ov005_02112bec), + 0x7FFFFFFF); + if (mUnk_0c > FLOAT_TO_Q20(1.0)) { + mUnk_0c = FLOAT_TO_Q20(1.0); + } + } else { + Lerp(&mUnk_0c, temp_r7_2, data_ov000_020e56f0, MUL_Q20(data_ov005_02112be8, data_ov000_020e56f0), 0x7FFFFFFF); + } + } + } + s32 var_r4; + if (mUnk_16 != 1) { + if (var_r9 != 0) { + Vec3p sp40 = {0, 0, 0}; + sp40.x = sp4C.x - this->GetPlayerPos()->x; + sp40.z = sp4C.z - this->GetPlayerPos()->z; + if (Vec3p_Length(&sp40) > FLOAT_TO_Q20(0.2)) { + var_r4 = this->func_ov005_0210f808(FLOAT_TO_Q20(1.0), &sp4C, grabActor != NULL); + } else { + gPlayerControl->StopFollowing(); + } + } else { + s32 temp_r1_3 = gPlayerControl->func_ov00_020b034c(); + var_r4 = this->func_ov005_0210f808(temp_r1_3, NULL, grabActor != NULL); + if (gAdventureFlags->func_ov00_02097750() == 0) { + UnkFilterActor filter; + filter.mActor = NULL; + filter.mUnk_08 = FLOAT_TO_Q20(4.0); + Vec3p pos = *this->GetPlayerPos(); + filter.mPos = pos; + filter.mAngle = *this->GetPlayerAngle(); + if (gActorManager->FilterActors(&filter, NULL) > 0) { + q20 temp_r1_4 = FLOAT_TO_Q20(4.0) - filter.mUnk_08; + Vec3p spC = filter.mActor->mPos; + spC.y += filter.mActor->mYOffset; + q20 var_r2 = MUL_Q20(temp_r1_4, FLOAT_TO_Q20(0.25)) + FLOAT_TO_Q20(0.1); + if (var_r2 >= FLOAT_TO_Q20(1.0)) { + var_r2 = FLOAT_TO_Q20(1.0); + } + this->func_ov00_020a81fc(&spC, var_r2); + this->func_ov005_021113d0(); + } + } + if (mUnk_12 > 0) { + this->func_ov005_021107fc(); + mUnk_12 -= 1; + } else if ((this->Get_PlayerLinkBase_Unk5e() != 0) && (var_r4 == 0)) { + this->func_ov00_020a8294(0, FLOAT_TO_Q20(0.2)); + this->func_ov00_020a827c(0, FLOAT_TO_Q20(0.2)); + } + if ((grabActor != NULL) && (grabActor->mType == ActorTypeId_Cucco)) { + if (this->func_ov00_020a8b80() != 0) { + mUnk_10 = 0x19; + } else if (mUnk_10 > 0) { + *(unk16 *) ((u32) this->func_ov00_020a8d40() + 0xa8) = 0x4CD; + if (mUnk_10 == 0x19) { + func_ov000_020ceacc(&data_027e0ffc, 0x23D, this->GetPlayerPos(), 0); + } + mUnk_10 -= 1; + } else { + LinkStateInteract *interact = UnkStruct_02037750::GetLinkStateInteract(); + interact->SetGrabActorVelocity(this->GetPlayerVel()); + } + } + } + } + if (this->GetGrabActor() == NULL) { + if (var_r4 <= data_ov005_02112bf0.x) { + this->func_ov005_021112ec(); + } + if (mUnk_15) { + if (!mUnk_16) { + this->func_ov00_020a8a4c(&data_ov005_021123ac, 0); + this->func_ov00_020a8ad0(0); + mUnk_16 = true; + } else if (mUnk_0c > 0) { + q20 temp_r4 = data_ov005_021123b8; + if (this->func_ov00_020a8d6c() >= temp_r4) { + this->func_ov00_020a8ad0(this->func_ov00_020a8d6c() - (temp_r4 - FLOAT_TO_Q20(7.0))); + } + } else { + mUnk_15 = false; + mUnk_16 = false; + } + } + ActorRef sp4; + sp4.Reset(); + this->PlayerLinkBase_vfunc_58(0, &sp4); + return; + } + this->PlayerLinkBase_vfunc_58(1, this->GetGrabActorRef()); +} + +ARM bool LinkStateMove::vfunc_3c() { + if ((gPlayerControl->GetFollowActor() == NULL) && (gPlayerControl->mFollowObject == NULL) && + (this->Get_PlayerControlData_Unk120() != 2) && (this->Get_PlayerControlData_Unk120() != 3)) + { + return true; + } + return false; +} + +ARM bool UnkFilterActor::Filter(Actor *actor) { + if (!actor->mVisible) { + return false; + } + + s32 temp_r0 = actor->mUnk_12c; + if ((temp_r0 != 2) && (temp_r0 != 5)) { + return false; + } + + Vec3p sp0; + Vec3p_Sub(&actor->mPos, &mPos, &sp0); + s16 angle2 = mAngle; + s16 angle1 = (s16) Atan2(sp0.x, sp0.z); + s32 var_r6 = (s16) (angle1 - angle2) >> 3; + if (var_r6 < 0) { + var_r6 = -var_r6; + } + + q20 length = Vec3p_Length(&sp0); + s32 temp_r2 = length + MUL_Q20(var_r6, FLOAT_TO_Q20(4.0)); + if (temp_r2 < mUnk_08) { + mActor = actor; + mUnk_08 = temp_r2; + return true; + } + + return false; +} diff --git a/src/14_Land/Actor/ActorRupee.cpp b/src/14_Land/Actor/ActorRupee.cpp index 80857246..23ac82dc 100644 --- a/src/14_Land/Actor/ActorRupee.cpp +++ b/src/14_Land/Actor/ActorRupee.cpp @@ -5,7 +5,6 @@ #include "System/Random.hpp" extern "C" { -void func_ov000_0207a1c8(bool *param_1, unk32 param_2, Vec3p *param_3); void func_0202bc38(unk32 param_1, Vec3p *param_2, u32 param_3, Actor_UnkStruct_012 *param_4, bool); void func_ov005_02102c2c(u32 *param_1, int param_2, Vec3p *param_3, int param_4, int param_5, u32 param_6, int param_7, char param_8, char param_9, char param_10); @@ -37,7 +36,7 @@ ActorRupee::ActorRupee() { } // https://decomp.me/scratch/1qjCc -bool ActorRupee::vfunc_08() { +bool ActorRupee::Init() { u32 dVar5; u32 iVar7; @@ -71,9 +70,9 @@ bool ActorRupee::vfunc_08() { func_ov14_0213b204(0); break; case 1: - q20 x = gRandom->Next(FLOAT_TO_Q20(0.1335)); - q20 y = gRandom->Next(FLOAT_TO_Q20(0.2)); - q20 z = gRandom->Next(FLOAT_TO_Q20(0.1335)); + q20 x = gRandom.Next(FLOAT_TO_Q20(0.1335)); + q20 y = gRandom.Next(FLOAT_TO_Q20(0.2)); + q20 z = gRandom.Next(FLOAT_TO_Q20(0.1335)); mVel.x = x - FLOAT_TO_Q20(0.0666); mVel.y = y + FLOAT_TO_Q20(0.3333); @@ -263,14 +262,14 @@ void ActorRupee::vfunc_14(u32 param1) { if (func_ov00_020c313c(param1)) { Update(false); } - func_ov000_0207a1c8(&mUnk_0a4.mUnk_00, param1, &mPos); + mUnk_0a4.func_ov000_0207a1c8(param1, &mPos); } void ActorRupee::vfunc_18(u32 param1) { if (func_ov00_020c313c(param1)) { Update(true); } - func_ov000_0207a1c8(&mUnk_0a4.mUnk_00, param1, &mPos); + mUnk_0a4.func_ov000_0207a1c8(param1, &mPos); } #define VFUNC20_COND (param1 ? mUnk_0a4.mUnk_01 : mUnk_0a4.mUnk_00) diff --git a/src/14_Land/Actor/Player/ActorArrow.cpp b/src/14_Land/Actor/Player/ActorArrow.cpp index 48d27797..96529bf4 100644 --- a/src/14_Land/Actor/Player/ActorArrow.cpp +++ b/src/14_Land/Actor/Player/ActorArrow.cpp @@ -11,7 +11,7 @@ void ActorArrow::func_ov014_0211fd80(unk32 param1) {} void ActorArrow::func_ov014_0211fd90() {} ActorArrow::ActorArrow() {} ActorArrow::~ActorArrow() {} -bool ActorArrow::vfunc_08() {} +bool ActorArrow::Init() {} bool ActorArrow::CollidesWith(Actor *other) {} void ActorArrow::func_ov014_021200d4() {} void ActorArrow::func_ov014_02120118() {} diff --git a/src/14_Land/Actor/Player/ActorBlast.cpp b/src/14_Land/Actor/Player/ActorBlast.cpp index 0f892335..06f82f63 100644 --- a/src/14_Land/Actor/Player/ActorBlast.cpp +++ b/src/14_Land/Actor/Player/ActorBlast.cpp @@ -6,7 +6,7 @@ ActorBlast *ActorBlast::Create() {} void ActorBlast_Unk1::vfunc_10(s32 *param1) {} ActorBlast::ActorBlast() {} ActorBlast::~ActorBlast() {} -bool ActorBlast::vfunc_08() {} +bool ActorBlast::Init() {} void ActorBlast::vfunc_14(u32 param1) {} ActorBlast_Unk1::~ActorBlast_Unk1() {} void ActorBlast::vfunc_18(u32 param1) {} diff --git a/src/14_Land/Actor/Player/ActorBomb.cpp b/src/14_Land/Actor/Player/ActorBomb.cpp index 1ee7c1bc..91224f12 100644 --- a/src/14_Land/Actor/Player/ActorBomb.cpp +++ b/src/14_Land/Actor/Player/ActorBomb.cpp @@ -9,7 +9,7 @@ ActorBomb::ActorBomb() {} ActorBomb_Unk2::~ActorBomb_Unk2() {} ActorBomb::~ActorBomb() {} ActorBomb_Unk2::ActorBomb_Unk2() {} -bool ActorBomb::vfunc_08() {} +bool ActorBomb::Init() {} void ActorBomb::vfunc_14(u32 param1) {} ActorBomb_Unk1::~ActorBomb_Unk1() {} void ActorBomb::vfunc_18(u32 param1) {} diff --git a/src/14_Land/Actor/Player/ActorRefill.cpp b/src/14_Land/Actor/Player/ActorRefill.cpp new file mode 100644 index 00000000..91efd351 --- /dev/null +++ b/src/14_Land/Actor/Player/ActorRefill.cpp @@ -0,0 +1,340 @@ +#include "Actor/Player/ActorRefill.hpp" +#include "DTCM/UnkStruct_027e0d38.hpp" +#include "DTCM/UnkStruct_027e103c.hpp" +#include "Item/ItemManager.hpp" +#include "System/Random.hpp" + +static char *sShipTypes[8] = {"anc", "bow", "hul", "can", "dco", "pdl", "fnl", "brg"}; + +extern u32 **data_027e0fe0[]; +ARM ActorRefillBombs *ActorRefillBombs::Create() { + return new(*data_027e0fe0[0], 4) ActorRefillBombs(); +} +ActorType ActorRefillBombs::gType = ActorType(ActorTypeId_RefillBombs, (ActorCreateFunc) ActorRefillBombs::Create, NULL); + +ARM ActorRefillBombchus *ActorRefillBombchus::Create() { + return new(*data_027e0fe0[0], 4) ActorRefillBombchus(); +} +ActorType ActorRefillBombchus::gType = + ActorType(ActorTypeId_RefillBombchus, (ActorCreateFunc) ActorRefillBombchus::Create, NULL); + +ARM ActorRefillArrows *ActorRefillArrows::Create() { + return new(*data_027e0fe0[0], 4) ActorRefillArrows(); +} +ActorType ActorRefillArrows::gType = ActorType(ActorTypeId_RefillArrows, (ActorCreateFunc) ActorRefillArrows::Create, NULL); + +ARM ActorRefillTime *ActorRefillTime::Create() { + return new(*data_027e0fe0[0], 4) ActorRefillTime(); +} +ActorType ActorRefillTime::gType = ActorType(ActorTypeId_RefillTime, (ActorCreateFunc) ActorRefillTime::Create, NULL); + +ARM ActorLSTM *ActorLSTM::Create() { + return new(*data_027e0fe0[0], 4) ActorLSTM(); +} +ActorType ActorLSTM::gType = ActorType(ActorTypeId_LSTM, (ActorCreateFunc) ActorLSTM::Create, NULL); + +ARM ActorRefill::ActorRefill(unk32 param1) : + mUnk_158(0), + mUnk_15c(0x56), + mUnk_160(param1), + mUnk_164(0x1f) {} + +ARM ActorRefill::~ActorRefill() {} + +ARM bool ActorRefill::Init() { + ItemManager *itemManager; + + if (this->GetAmmoItem() == ItemFlag_None) { + if (data_027e0d38->func_ov000_02078b40() != 3) { + return false; + } + } else { + ItemManager *itemManager = gItemManager; + ItemFlag item = this->GetAmmoItem(); + if (!itemManager->HasItem(item)) { + return false; + } + } + mHitbox.pos.x = 0; + mHitbox.pos.y = FLOAT_TO_Q20(0.3); + mHitbox.pos.z = 0; + mHitbox.size = FLOAT_TO_Q20(0.3); + mUnk_08c.pos.x = mHitbox.pos.x; + mUnk_08c.pos.y = mHitbox.pos.y; + mUnk_08c.pos.z = mHitbox.pos.z; + mUnk_08c.size = mHitbox.size; + mUnk_0a4.mUnk_04.x = 0; + mUnk_0a4.mUnk_04.y = FLOAT_TO_Q20(0.3); + mUnk_0a4.mUnk_04.z = 0; + mUnk_0a4.mUnk_10 = FLOAT_TO_Q20(1.3); + mUnk_09c.mUnk_0 &= ~0xa4; + mUnk_09c.mUnk_3 = 1; + mMaxFall = mUnk_08c.size + -1; + this->func_ov014_02135364(0); + return true; +} + +extern unk32 data_ov000_020eec9c; +extern "C" void func_ov000_020d7ad4(unk32 *param1, unk32 param2); +ARM void ActorRefill::vfunc_14(u32 param1) { + s32 temp_r0_4; + s32 temp_r6; + s8 var_r0; + u32 temp_r0; + u32 temp_r0_3; + u32 temp_r1; + Vec3p *temp_r0_2; + + if (this->func_ov00_020c313c(param1) != 0) { + this->IncreaseActiveFrames(); + temp_r0 = mUnk_130; + switch (temp_r0) { + case 0: + this->ApplyGravity(); + temp_r0_2 = &mPos; + Vec3p_Add(temp_r0_2, &mVel, temp_r0_2); + this->func_01fffd04(0); + if (mUnk_110 || mUnk_112 || mUnk_113) { + mVel.x = 0; + mVel.z = 0; + } + if (mUnk_111) { + this->func_ov014_02135364(1); + } else if (this->func_ov00_020c2c0c()) { + this->func_ov014_02135364(4); + } else if (this->func_ov00_020c2d54()) { + this->func_ov014_02135364(5); + } + break; + case 1: + case 2: + case 4: + case 5: + if (this->CollidesWithPlayer(PlayerCollide_PickupFlags) != 0) { + if (this->GetAmmoItem() == -1) { + data_027e103c->func_ov000_020cfbf0(mUnk_158 * 60, 1, 0); + } else { + ItemManager *itemManager = gItemManager; + itemManager->GiveAmmo(this->GetAmmoItem(), mUnk_158); + } + func_ov000_020d7ad4(&data_ov000_020eec9c, 0x100); + this->func_ov014_02135364(3); + } else { + temp_r0_3 = mUnk_130; + switch (temp_r0_3) { + case 0: + case 3: break; + case 1: + if (this->func_ov00_020c2c0c()) { + this->func_ov014_02135364(4); + } else if (this->func_ov00_020c2d54()) { + this->func_ov014_02135364(5); + } else if (mActiveFrames >= 180) { + this->func_ov014_02135364(2); + } + break; + case 2: + if (mActiveFrames % 8 < 4) { + mUnk_164 = 0; + } else { + mUnk_164 = 31; + } + if (this->func_ov00_020c2c0c()) { + this->func_ov014_02135364(4); + } else if (this->func_ov00_020c2d54()) { + this->func_ov014_02135364(5); + } else if (mActiveFrames >= 60) { + this->func_ov014_02135364(3); + } + break; + case 4: + if (!this->func_ov00_020c2c70()) { + this->func_ov014_02135364(1); + } + break; + case 5: + if (!this->func_ov00_020c2de4()) { + this->func_ov014_02135364(1); + } + break; + } + } + break; + } + this->KillInBounds(); + } + mUnk_0a4.func_ov000_0207a1c8(param1, &mPos); +} + +ARM bool ActorRefill::func_ov014_02135364(unk32 param1) { + mUnk_130 = param1; + mUnk_164 = 31; + mActiveFrames = 0; + switch (mUnk_130) { + case 0: + case 2: break; + case 1: + mVel.x = 0; + mVel.y = 0; + mVel.z = 0; + break; + case 3: this->Kill(); break; + } + return true; +} + +extern "C" void func_0202bc38(bool param1, Vec3p *pos, unk32 param2, Actor_UnkStruct_012 *param3, unk32 param4); +extern u32 data_ov000_020e9370[]; +extern "C" void func_ov005_02102c2c(u32 *param_1, int param_2, Vec3p *param_3, int param_4, int param_5, u32 param_6, + int param_7, char param_8, char param_9, char param_10); +ARM void ActorRefill::vfunc_20(bool param1) { + bool var_r0; + + if (param1) { + var_r0 = mUnk_0a4.mUnk_01; + } else { + var_r0 = mUnk_0a4.mUnk_00; + } + if (var_r0 && mUnk_164 != 0) { + Actor_UnkStruct_012 sp18; + sp18.mUnk_04 = 5; + sp18.mUnk_08 = 2; + sp18.mUnk_0c = 2; + sp18.mUnk_14 = 0x800; + sp18.mUnk_18 = 0x1000; + sp18.mUnk_02 = mUnk_164; + func_0202bc38(param1, &mPos, mUnk_15c, &sp18, 0); + func_ov005_02102c2c(&data_ov000_020e9370[0], 0, &mPos, 0x400, 0x400, 0, mUnk_164, 0, 0, 1); + } +} + +extern unk32 *data_027e0e58; +extern "C" void func_ov000_0207c1b0(unk32 *param1, unk32 param2, Vec3p *param3, unk32 param4, unk32 param5, unk32 param6); +ARM void ActorRefill::func_ov014_02135474() { + s32 iVar1 = mUnk_130; + if (iVar1 != 4 && iVar1 != 5) { + func_ov000_0207c1b0(data_027e0e58, 0x241, &mPos, 2, 0, 0); + func_ov000_0207c1b0(data_027e0e58, 0x242, &mPos, 2, 0, 0); + mAlive = false; + } +} + +ARM ActorRefillBombs::ActorRefillBombs() : + ActorRefill(0) { + mUnk_158 = 3; + mUnk_15c = 0x2e; +} + +ARM ActorRefillBombs::~ActorRefillBombs() {} + +ARM ItemFlag ActorRefillBombs::GetAmmoItem() { + return ItemFlag_BombBag; +} + +ARM ActorRefillBombchus::ActorRefillBombchus() : + ActorRefill(1) { + mUnk_158 = 3; + mUnk_15c = 0x2f; +} + +ARM ActorRefillBombchus::~ActorRefillBombchus() {} + +ARM ItemFlag ActorRefillBombchus::GetAmmoItem() { + return ItemFlag_BombchuBag; +} + +ARM ActorRefillArrows::ActorRefillArrows() : + ActorRefill(2) { + mUnk_158 = 5; + mUnk_15c = 0x2d; +} + +ARM ActorRefillArrows::~ActorRefillArrows() {} + +ARM ItemFlag ActorRefillArrows::GetAmmoItem() { + return ItemFlag_Bow; +} + +ARM ActorRefillTime::ActorRefillTime() : + ActorRefill(3) { + mUnk_158 = 5; + mUnk_15c = 0x44; +} + +ARM ActorRefillTime::~ActorRefillTime() {} + +ARM bool ActorRefillTime::Init() { + if (!ActorRefill::Init()) { + return false; + } + switch (mUnk_020.mUnk_00[0]) { + case 2: mUnk_158 = 5; break; + case 4: mUnk_158 = 15; break; + case 5: mUnk_158 = 30; break; + default: + case 0: + case 1: + case 3: + s32 temp_ip = gRandom.Next(10); + if (temp_ip >= 9) { + mUnk_158 = 30; + } else if (temp_ip >= 6) { + mUnk_158 = 15; + } else { + mUnk_158 = 5; + } + break; + } + switch (mUnk_158) { + case 15: mUnk_15c = 0x45; break; + case 30: mUnk_15c = 0x46; break; + default: mUnk_15c = 0x44; break; + } + return true; +} + +ARM ItemFlag ActorRefillTime::GetAmmoItem() { + return ItemFlag_None; +} + +ARM ActorLSTM::ActorLSTM() : + ActorRefill(3) { + mUnk_158 = -5; + mUnk_15c = 0x47; +} + +ARM ActorLSTM::~ActorLSTM() {} + +ARM bool ActorLSTM::Init() { + if (!ActorRefill::Init()) { + return false; + } + switch (mUnk_020.mUnk_00[0]) { + case 2: mUnk_158 = -5; break; + case 4: mUnk_158 = -15; break; + case 5: mUnk_158 = -30; break; + default: + case 0: + case 1: + case 3: + s32 temp_ip = gRandom.Next(10); + if (temp_ip >= 9) { + mUnk_158 = -30; + } else if (temp_ip >= 6) { + mUnk_158 = -15; + } else { + mUnk_158 = -5; + } + break; + } + switch (mUnk_158) { + case -15: mUnk_15c = 0x48; break; + case -30: mUnk_15c = 0x49; break; + default: mUnk_15c = 0x47; break; + } + return true; +} + +ARM ItemFlag ActorLSTM::GetAmmoItem() { + return ItemFlag_None; +} diff --git a/src/18_Overworld/Map/MapOverworld.cpp b/src/18_Overworld/Map/MapOverworld.cpp new file mode 100644 index 00000000..5737ea54 --- /dev/null +++ b/src/18_Overworld/Map/MapOverworld.cpp @@ -0,0 +1,38 @@ +#include "Map/MapOverworld.hpp" + +MapOverworld::MapOverworld(u32 width, u32 height) : + MapBase(width, height) {} +MapOverworld::~MapOverworld() {} +void MapOverworld::vfunc_08(u32 param_2, u32 param_3, Course *param_4) {} +void MapOverworld::vfunc_14() {} +void MapOverworld::vfunc_1c(bool param_2) {} +void MapOverworld::func_ov018_0215bfc8() {} +void MapOverworld::vfunc_20(s32 param_2) {} +void MapOverworld::vfunc_2c() {} +void MapOverworld::vfunc_94() {} +unk32 MapOverworld::vfunc_a4() {} +unk32 MapOverworld::vfunc_54() {} +unk32 MapOverworld::vfunc_58() {} +unk32 MapOverworld::vfunc_5c() {} +unk32 MapOverworld::vfunc_60() {} +unk32 MapOverworld::vfunc_64() {} +u32 MapOverworld::func_ov018_0215c34c() {} +u32 MapOverworld::func_ov018_0215c368() {} +s32 MapOverworld::func_ov018_0215c380(u8 *param1) {} +void MapOverworld::vfunc_bc() {} +void MapOverworld::vfunc_98() {} +void MapOverworld::vfunc_c0() {} +unk32 MapOverworld::vfunc_78() {} +unk32 MapOverworld::vfunc_7c() {} +unk32 MapOverworld::vfunc_80() {} +unk8 MapOverworld::vfunc_b0(unk32 param_2, unk32 param_3) {} +void MapOverworld::func_ov018_0215c650() {} +void MapOverworld::func_ov018_0215c6ac() {} +void MapOverworld::func_ov018_0215c6d0() {} +MapOverworld_Unk1::MapOverworld_Unk1(u32 param1, u8 *param2, unk32 param3) : + UnkStruct_ov000_020c0c08(0, param2) {} +void MapOverworld::func_ov018_0215c9ac() {} +void func_ov018_0215ca24(s32 param1) {} +void func_ov018_0215ca3c(s32 param1, s32 param2, unk32 param3, unk32 param4) {} +void func_ov018_0215ca8c(s32 param1) {} +void MapOverworld::vfunc_4c() {} diff --git a/src/57_Rope/Actor/Player/ActorRope.cpp b/src/57_Rope/Actor/Player/ActorRope.cpp index 023f134b..40ab1aa4 100644 --- a/src/57_Rope/Actor/Player/ActorRope.cpp +++ b/src/57_Rope/Actor/Player/ActorRope.cpp @@ -5,7 +5,7 @@ ActorRope_Unk_0219a3b0 gUnk_0219a3b0; void ActorRope_Unk_0219a3b0::vfunc_08(unk16 *param1) {} void ActorRope_Unk_0219a3b0::vfunc_10(s32 *param1) {} ActorRope::ActorRope() {} -bool ActorRope::vfunc_08() {} +bool ActorRope::Init() {} q20 ActorRope::func_ov057_0219a5ac() {} void ActorRope::func_ov057_0219a6b8() {} void ActorRope::func_ov057_0219a850() {} diff --git a/src/Main/Debug/DebugHierarchyBase.cpp b/src/Main/Debug/DebugHierarchyBase.cpp index 75b2f444..cdcb1fb7 100644 --- a/src/Main/Debug/DebugHierarchyBase.cpp +++ b/src/Main/Debug/DebugHierarchyBase.cpp @@ -3,17 +3,18 @@ DebugHierarchyBase::DebugHierarchyBase() {} DebugHierarchyBase::~DebugHierarchyBase() {} DebugHierarchyNode *DebugHierarchyBase::FindNode(u32 id) {} -bool DebugHierarchyBase::GetChildNode(unk32 param1, const char *description, u32 parent, s32 *param4) {} +bool DebugHierarchyBase::GetChildNode(unk32 param1, const char *description, u32 parent, s32 *param4, unk32 param5, + unk32 param6, unk32 param7, unk32 param8) {} void DebugHierarchyBase::vfunc_08() {} void DebugHierarchyBase::vfunc_0c() {} void DebugHierarchyBase::vfunc_10() {} void DebugHierarchyBase::vfunc_14() {} void DebugHierarchyBase::vfunc_18() {} void DebugHierarchyBase::vfunc_1c() {} -void DebugHierarchyBase::vfunc_20() {} +void DebugHierarchyBase::vfunc_20(unk32 param1, const char *param2, unk32 param3, unk32 param4, unk32 param5, unk32 param6) {} void DebugHierarchyBase::vfunc_24() {} void DebugHierarchyBase::vfunc_28() {} void DebugHierarchyBase::vfunc_2c() {} void DebugHierarchyBase::vfunc_30() {} void DebugHierarchyBase::vfunc_38() {} -void DebugHierarchyBase::vfunc_3c() {} +void DebugHierarchyBase::vfunc_3c(unk32 param1, void *param2) {} diff --git a/src/Main/Player/LinkState.cpp b/src/Main/Player/LinkState.cpp index b5e5621e..940f126e 100644 --- a/src/Main/Player/LinkState.cpp +++ b/src/Main/Player/LinkState.cpp @@ -1,5 +1,5 @@ #include "Player/LinkStateBase.hpp" -LinkStateBase *GetLinkState(s32 index) { +LinkStateBase *GetLinkState(LinkStateId index) { return gLinkStates[index]; } diff --git a/src/Main/System/OverlayManager.cpp b/src/Main/System/OverlayManager.cpp index 9c50ebb6..5295fa2d 100644 --- a/src/Main/System/OverlayManager.cpp +++ b/src/Main/System/OverlayManager.cpp @@ -1,7 +1,88 @@ #include "System/OverlayManager.hpp" +#include "global.h" +#include "nds/overlay.h" -void OverlayManager::Load(OverlayIndex index, OverlayId id) {} -void OverlayManager::LoadIfNotLoaded(OverlayIndex index, OverlayId id) {} -void OverlayManager::Unload(OverlayIndex index) {} -void OverlayManager::LoadOverlaySetup(s32 index) {} -void OverlayManager::UnloadOverlaySetup() {} +struct UnkStruct_020ee698 { + /* 00 */ unk8 mUnk_00[0x2C]; + /* 2c */ unk32 mUnk_2c; + /* 30 */ +}; +extern UnkStruct_020ee698 data_ov000_020ee698; + +struct OverlaySetup { + /* 00 */ unk8 mUnk_00; + /* 01 */ unk8 mUnk_01; + /* 02 */ unk8 mUnk_02; + /* 03 */ unk8 mUnk_03; + /* 04 */ OverlayId slot1Overlay; + /* 08 */ OverlayId slot2Overlay; + /* 0c */ OverlayId slot3Overlay; + /* 10 */ OverlayId slot12Overlay; + /* 14 */ void *mUnk_14; + /* 18 */ void *mUnk_18; + /* 1c */ +}; +extern OverlaySetup gOverlaySetups[]; + +extern u32 *data_027e0ce0[]; +extern "C" void func_ov007_02102850(u32 **); +extern "C" void func_ov007_021028a0(u32 **); + +THUMB void OverlayManager::Load(OverlayIndex index, OverlayId id) { + if (id != OverlayId_None) { + Overlay_Load(NULL, id); + } + + this->mLoadedOverlays[index] = id; +} + +THUMB void OverlayManager::LoadIfNotLoaded(OverlayIndex index, OverlayId id) { + OverlayId loadedId = this->mLoadedOverlays[index]; + + if (loadedId != id) { + this->Unload(index); + this->Load(index, id); + } +} + +THUMB void OverlayManager::Unload(OverlayIndex index) { + if (this->mLoadedOverlays[index] != OverlayId_None) { + Overlay_Unload(NULL, this->mLoadedOverlays[index]); + this->mLoadedOverlays[index] = OverlayId_None; + } +} + +//! TODO: solve the .word issue with the overlay IDs +//! both functions should match otherwise +THUMB void OverlayManager::LoadOverlaySetup(s32 index) { + OverlayId overlayId; + OverlaySetup *pSetup; + + pSetup = &gOverlaySetups[index]; + + this->LoadIfNotLoaded(OverlayIndex_1, pSetup->slot1Overlay); + this->LoadIfNotLoaded(OverlayIndex_2, pSetup->slot2Overlay); + + if (index == 5) { + func_ov007_02102850(data_027e0ce0); + } else { + overlayId = pSetup->slot12Overlay; + + if (index == 6 && data_ov000_020ee698.mUnk_2c == 2) { + overlayId = OverlayId_61; + } + + this->Load(OverlayIndex_3, pSetup->slot3Overlay); + this->Load(OverlayIndex_12, overlayId); + } +} + +THUMB void OverlayManager::UnloadOverlaySetup() { + this->Unload(OverlayIndex_12); + this->Unload(OverlayIndex_3); + + if (this->mLoadedOverlays[2] == OverlayId_07) { + func_ov007_021028a0(data_027e0ce0); + this->Unload(OverlayIndex_2); + } +} |
