diff options
Diffstat (limited to 'src/00_Core')
| -rw-r--r-- | src/00_Core/Actor/Actor.cpp | 3 | ||||
| -rw-r--r-- | src/00_Core/Actor/ActorManager.cpp | 38 | ||||
| -rw-r--r-- | src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp | 178 | ||||
| -rw-r--r-- | src/00_Core/Map/Course.cpp | 2 | ||||
| -rw-r--r-- | src/00_Core/Map/MapBase.cpp | 18 | ||||
| -rw-r--r-- | src/00_Core/Map/MapManager.cpp | 169 | ||||
| -rw-r--r-- | src/00_Core/Player/LinkStateMove.cpp | 6 | ||||
| -rw-r--r-- | src/00_Core/Player/PlayerControl.cpp | 21 |
8 files changed, 287 insertions, 148 deletions
diff --git a/src/00_Core/Actor/Actor.cpp b/src/00_Core/Actor/Actor.cpp index 7b15d166..47d5e3d6 100644 --- a/src/00_Core/Actor/Actor.cpp +++ b/src/00_Core/Actor/Actor.cpp @@ -1004,8 +1004,7 @@ ARM void Actor::GetLinkPos(Vec3p *result) { } ARM void Actor::GetLinkDummyPos(Vec3p *result) { - ActorRef dummyRef; - ActorManager::FindActorByType(&dummyRef, gActorManager, ActorTypeId_PlayerDummy); + ActorRef dummyRef = gActorManager->FindActorByType(ActorTypeId_PlayerDummy); ActorPlayerDummy *dummy = (ActorPlayerDummy *) gActorManager->GetActor(&dummyRef); if (dummy != NULL && dummy->mUnk_16e == 0) { *result = dummy->mPos; diff --git a/src/00_Core/Actor/ActorManager.cpp b/src/00_Core/Actor/ActorManager.cpp index 32983645..a881355e 100644 --- a/src/00_Core/Actor/ActorManager.cpp +++ b/src/00_Core/Actor/ActorManager.cpp @@ -45,17 +45,17 @@ ARM void ActorManager::DeleteActor(u32 index, bool param2) { return; } -ARM void ActorManager::func_ov00_020c3484(ActorRef *ref, ActorManager *actorMgr, unk32 param3) { - ref->Reset(); +ARM ActorRef ActorManager::func_ov00_020c3484(unk32 param3) { + ActorRef ref; if (data_027e103c->mUnk_24 == 0) { - return; + return ref; } q20 minDistance = 0x7fffffff; - Actor **actorIter = actorMgr->mActorTable; + Actor **actorIter = this->mActorTable; u8 unkByte = data_02056be4[data_027e077c.GetUnk0()]; bool unk1 = (unkByte & 1) != 0; - Actor **actorTableEnd = actorIter + actorMgr->mMaxActorIndex; + Actor **actorTableEnd = actorIter + this->mMaxActorIndex; for (; actorIter < actorTableEnd; actorIter++) { Actor *actor = *actorIter; @@ -65,7 +65,7 @@ ARM void ActorManager::func_ov00_020c3484(ActorRef *ref, ActorManager *actorMgr, if ((*actorIter)->IsHitboxTouched(false)) { q20 distance = (*actorIter)->DistanceToLink(); if (distance < minDistance) { - *ref = (*actorIter)->mRef; + ref = (*actorIter)->mRef; minDistance = distance; } } @@ -73,6 +73,7 @@ ARM void ActorManager::func_ov00_020c3484(ActorRef *ref, ActorManager *actorMgr, } } } + return ref; } ARM void ActorManager::Actor_vfunc_10(u32 param1) { @@ -217,39 +218,42 @@ ARM s32 ActorManager::FilterActors(FilterActorBase *filter, ActorList *filteredA return numApplied; } -ARM void ActorManager::FindActorByType(ActorRef *ref, ActorManager *actorMgr, ActorTypeId type) { - ref->Reset(); +ARM ActorRef ActorManager::FindActorByType(ActorTypeId type) { + ActorRef ref; - Actor **actorIter = actorMgr->mActorTable; - Actor **actorTableEnd = actorIter + actorMgr->mMaxActorIndex; + Actor **actorIter = this->mActorTable; + Actor **actorTableEnd = actorIter + this->mMaxActorIndex; for (; actorIter < actorTableEnd; actorIter++) { Actor *actor = *actorIter; if (actor != NULL && actor->mAlive && type == actor->mType) { - *ref = actor->mRef; - return; + ref = actor->mRef; + return ref; } } + return ref; } -ARM void ActorManager::FindNearestActorOfType(ActorRef *ref, ActorManager *actorMgr, ActorTypeId type, Vec3p *pos) { - ref->Reset(); +ARM ActorRef ActorManager::FindNearestActorOfType(ActorTypeId type, Vec3p *pos) { + ActorRef ref; q20 minDistance = 0x7fffffff; - Actor **actorIter = actorMgr->mActorTable; - Actor **actorTableEnd = actorIter + actorMgr->mMaxActorIndex; + Actor **actorIter = this->mActorTable; + Actor **actorTableEnd = actorIter + this->mMaxActorIndex; for (; actorIter < actorTableEnd; actorIter++) { Actor *actor = *actorIter; if (actor != NULL && actor->mAlive && type == actor->mType) { q20 distance = Vec3p_Distance(&actor->mPos, pos); if (distance < minDistance) { - *ref = (*actorIter)->mRef; + ref = (*actorIter)->mRef; minDistance = distance; } } } + + return ref; } ARM bool ActorManager::func_ov00_020c398c(u32 index) { diff --git a/src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp b/src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp index d69fc611..a773cbd2 100644 --- a/src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp +++ b/src/00_Core/Actor/Dungeon/ActorSwitchObject.cpp @@ -1,22 +1,34 @@ #include "Actor/Dungeon/ActorSwitchObject.hpp" +#include "Actor/ActorManager.hpp" +#include "Actor/ActorSpawner.hpp" #include "Map/MapManager.hpp" +#include "Player/PlayerBase.hpp" +#include "System/Random.hpp" +#include "Unknown/UnkStruct_020eec9c.hpp" +#include <nds/math.h> + +#pragma section sbss begin ActorType ActorSwitchObject::gType = ActorType(ActorTypeId_SwitchObject, (ActorCreateFunc) ActorSwitchObject::Create, NULL); +#pragma section sbss end -ActorSwitchObject *ActorSwitchObject::Create() {} +extern u32 **data_027e0fe0[]; +ARM ActorSwitchObject *ActorSwitchObject::Create() { + return new(*data_027e0fe0[0], 4) ActorSwitchObject(); +} -bool ActorSwitchObject::Init() { +ARM bool ActorSwitchObject::Init() { Actor::Init(); this->func_ov000_0208fc7c(); this->mUnk_130 = 0; return true; } -bool ActorSwitchObject::vfunc_0c() { +ARM 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) { +ARM void ActorSwitchObject::vfunc_14(u32 param1) { bool bVar1; u32 uVar2; u32 uVar3; @@ -69,11 +81,11 @@ void ActorSwitchObject::vfunc_14(u32 param1) { return; } -void ActorSwitchObject::vfunc_18(u32 param1) { +ARM void ActorSwitchObject::vfunc_18(u32 param1) { this->vfunc_14(param1); } -bool ActorSwitchObject::func_ov000_0208fc10(s32 param1) { +ARM bool ActorSwitchObject::func_ov000_0208fc10(s32 param1) { this->mUnk_130 = param1; switch (param1) { @@ -95,7 +107,7 @@ bool ActorSwitchObject::func_ov000_0208fc10(s32 param1) { return true; } -void ActorSwitchObject::func_ov000_0208fc7c() { +ARM 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]; @@ -104,14 +116,158 @@ void ActorSwitchObject::func_ov000_0208fc7c() { this->mUnk_160 = this->mUnk_164; } -bool ActorSwitchObject::func_ov000_0208fcb4() {} -void ActorSwitchObject::func_ov000_0208fef8() {} +ARM unk32 ActorSwitchObject::func_ov000_0208fcb4() { + switch (mUnk_15c) { + case 1: + if ((mUnk_160 > mUnk_164) && (mUnk_160 < mUnk_168)) { + for (s32 i = mUnk_164; i < mUnk_160; i++) { + if (!gMapManager->func_ov00_02084be0(i, mUnk_16c)) { + mUnk_160 = (s32) mUnk_164; + return 0; + } + } + } + if (gMapManager->func_ov00_02084be0(mUnk_160, mUnk_16c)) { + for (s32 i = mUnk_160 + 1; i < mUnk_168; i++) { + if (gMapManager->func_ov00_02084be0(i, mUnk_16c)) { + mUnk_160 = mUnk_164; + return 0; + } + } + if (mUnk_160 < mUnk_168) { + mUnk_160 += 1; + } + } + return mUnk_160 == mUnk_168; + case 2: + if (gMapManager->func_ov00_02084be0(mUnk_160, mUnk_16c) != 0) { + bool var_r8 = false; + for (s32 i = mUnk_160 + 1; i < mUnk_168; i++) { + if (gMapManager->func_ov00_02084be0(i, mUnk_16c)) { + mUnk_160 = mUnk_164; + var_r8 = true; + } + } + if (!var_r8) { + mUnk_160 += 1; + } + } + bool var_r6_3 = true; + for (s32 i = mUnk_164; i < mUnk_168; i++) { + if (gMapManager->func_ov00_02084be0(i, mUnk_16c) == 0) { + var_r6_3 = false; + break; + } + } + if (var_r6_3) { + return mUnk_160 == mUnk_168 ? 1 : 2; + } + return 0; + default: + for (s32 i = 0; i < mUnk_020.mUnk_00[0]; i++) { + if (gMapManager->func_ov00_02084be0(mUnk_164 + i, mUnk_16c) == 0) { + return 0; + } + } + return 1; + } +} + +ARM void ActorSwitchObject::func_ov000_0208fef8() { + if (mUnk_130 == 1) { + return; + } + switch (mUnk_020.mUnk_00[3]) { + case 1: + data_ov000_020eec9c.func_ov000_020d77e4(0xb); + return; + case 2: + data_ov000_020eec9c.func_ov000_020d77e4(0xb); + Vec3p playerPos = {gPlayerPos.x, gPlayerPos.y, gPlayerPos.z}; + Vec3p snakeSpawnCenter = {gPlayerPos.x, gPlayerPos.y + FLOAT_TO_Q20(3.0), gPlayerPos.z}; + Vec3p snakeSpawnPos; + ActorSpawnOptions spawnOptions; + s32 failedSpawns = 0; + for (u32 i = 0; i < ARRAY_LEN(mTrapActors); i++) { + if (mTrapActors[i].id != -1) { + Actor *temp_r0_2 = gActorManager->GetActor(&mTrapActors[i]); + if ((temp_r0_2 != NULL) && (temp_r0_2->mType == ActorTypeId_Rope)) { + continue; + } + mTrapActors[i].Reset(); + } + snakeSpawnPos.z = (gRandom.Next(0, 11) - 5) << 12; + snakeSpawnPos.y = 0; + snakeSpawnPos.x = (gRandom.Next(0, 11) - 5) << 12; + Vec3p_Add(&snakeSpawnPos, &snakeSpawnCenter, &snakeSpawnPos); + if (failedSpawns < 10) { + TilePos tilePos = gMapManager->func_ov00_02083a1c(&snakeSpawnPos); + // BUG: Should be Vec3p_Distance(&snakeSpawnCenter, &snakeSpawnPos) + if ((Vec3p_Distance(&playerPos, &snakeSpawnPos) < FLOAT_TO_Q20(2.0)) || + (gMapManager->func_ov00_02083e70(&tilePos) != 0)) { + i -= 1; + failedSpawns += 1; + continue; + } + if (gMapManager->MapData_vfunc_78(&tilePos) != NULL) { + continue; + } + if (gMapManager->func_ov00_02084164(&tilePos) == 0) { + i -= 1; + failedSpawns += 1; + continue; + } + switch (gMapManager->MapData_vfunc_54(&tilePos)) { + case 0x5: + case 0x6: + case 0x14: + case 0x17: + case 0x1b: + case 0x1c: + case 0x1d: + case 0x1e: + case 0x1f: + case 0x2b: + case 0x37: + case 0x46: + case 0x47: + case 0x48: + case 0x4e: + case 0x4f: + i -= 1; + failedSpawns += 1; + continue; + + default: + ActorRef ref = gActorManager->FindNearestActorOfType(ActorTypeId_PushBlock, &snakeSpawnPos); + if (ref.id == -1) { + break; + } + Actor *temp_r0_5 = gActorManager->GetActor(&ref); + if (temp_r0_5 == NULL) { + break; + } + Vec3p sp24 = {temp_r0_5->mPos.x, temp_r0_5->mPos.y, temp_r0_5->mPos.z}; + sp24.y = snakeSpawnPos.y; + if (Vec3p_Distance(&sp24, &snakeSpawnPos) < FLOAT_TO_Q20(1.5)) { + i -= 1; + failedSpawns += 1; + continue; + } + break; + } + } + gActorSpawner->Spawn(ActorTypeId_Rope, &snakeSpawnPos, &spawnOptions, &mTrapActors[i]); + } + return; + } +} -void ActorSwitchObject::func_ov000_0209032c() { +ARM 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() {} +ARM ActorSwitchObject::~ActorSwitchObject() {} diff --git a/src/00_Core/Map/Course.cpp b/src/00_Core/Map/Course.cpp index fed9a442..f31005e0 100644 --- a/src/00_Core/Map/Course.cpp +++ b/src/00_Core/Map/Course.cpp @@ -6,7 +6,7 @@ char *Course::SetCourseName(char *src) {} void Course::func_ov00_0207ca78(unk32 param_2, unk8 param_3, unk32 param_4) {} bool Course::func_ov00_0207caa8(s32 param_2, unk32 *param_3, unk8 *param_4) {} unk32 Course::func_ov00_0207cb30(s32 param_2) {} -void Course::FindMapGridPos(Vec2b *pos, Course *param_2, u32 map) {} +TilePos Course::FindMapGridPos(u32 map) {} Vec3p *Course::FindMapCenter(unk32 map) {} void Course::func_ov00_0207cbe8(s32 param_2) {} unk8 Course::func_ov00_0207cc24(s32 param_2) {} diff --git a/src/00_Core/Map/MapBase.cpp b/src/00_Core/Map/MapBase.cpp index 1e8a1cce..555024bc 100644 --- a/src/00_Core/Map/MapBase.cpp +++ b/src/00_Core/Map/MapBase.cpp @@ -18,10 +18,10 @@ s32 MapBase::func_ov00_0207e28c(s32 param_2) {} void MapBase::vfunc_b4() {} void MapBase::vfunc_48() {} unk32 MapBase::vfunc_50() {} -unk32 MapBase::vfunc_54(Vec2b *param_1) {} -unk32 MapBase::vfunc_58(Vec2b *param_1, int param_2) {} +unk32 MapBase::vfunc_54(TilePos *param_1) {} +unk32 MapBase::vfunc_58(TilePos *param_1, int param_2) {} unk32 MapBase::vfunc_5c() {} -unk32 MapBase::vfunc_60(Vec2b *param_1) {} +unk32 MapBase::vfunc_60(TilePos *param_1) {} unk32 MapBase::vfunc_64() {} unk32 MapBase::vfunc_68(Vec3p *param_1, bool param_2) {} unk8 MapBase::func_ov00_0207e940(unk8 *param_1) {} @@ -40,22 +40,22 @@ void MapBase::vfunc_a0() {} unk32 MapBase::vfunc_a4(unk8 *param_1) {} void MapBase::vfunc_a8() {} void MapBase::vfunc_ac() {} -unk32 *MapBase::vfunc_78(Vec2b *param_1) {} +unk32 *MapBase::vfunc_78(TilePos *param_1) {} s32 MapBase::vfunc_7c(s32 param_1, unk32 *param_2, s32 param_3, short param_4[4]) {} unk32 MapBase::vfunc_80() {} void MapBase::vfunc_84(unk32 param_2) {} bool MapBase::func_ov00_0207f38c(s32 *param_2) {} -unk8 MapBase::vfunc_90(Vec2b *param_2, unk32 param_3) {} +unk8 MapBase::vfunc_90(TilePos *param_2, unk32 param_3) {} void MapBase::vfunc_94() {} void MapBase::func_ov00_0207f4a4(Vec2s *param_2, unk32 param_3) {} void MapBase::func_ov00_0207f53c(Vec2s *param_1, MapBase *param_2, Vec3p *param_3) {} -void MapBase::func_ov00_0207f588(Vec2s *param_1, MapBase *param_2, Vec2b *param_3, unk32 param_4) {} +void MapBase::func_ov00_0207f588(Vec2s *param_1, MapBase *param_2, TilePos *param_3, unk32 param_4) {} void MapBase::func_ov00_0207f630(Vec2s *param_2, Vec3p *param_3) {} unk8 MapBase::GetTileStartX(unk32 x) {} unk8 MapBase::GetTileStartZ(unk32 z) {} s32 MapBase::GetTileEndX(unk32 x) {} s32 MapBase::GetTileEndZ(unk32 z) {} -void MapBase::GetTileBounds(Vec2b *tilePos, AABB *bounds) {} +void MapBase::GetTileBounds(TilePos *tilePos, AABB *bounds) {} s32 MapBase::GetClampedTileX(s32 worldX) {} s32 MapBase::GetClampedTileY(s32 worldZ) {} unk8 MapBase::GetTileX(s32 worldX) {} @@ -100,8 +100,8 @@ bool MapBase::AddUnk_130(s32 param_2) {} bool MapBase::func_ov00_020809b8(s32 param_2) {} unk8 MapBase::func_ov00_02080a78(Vec3p *param_2) {} void MapBase_Unk2::func_ov00_02080ad0(TriggerBase **param_2, TriggerBase **param_3) {} -unk8 MapBase::func_ov00_02080b24(Vec2b *param_2) {} -void MapBase::func_ov00_02080d08(Vec2b *param_2) {} +unk8 MapBase::func_ov00_02080b24(TilePos *param_2) {} +void MapBase::func_ov00_02080d08(TilePos *param_2) {} void MapBase::vfunc_bc() {} void MapBase::vfunc_98(unk32 param_2, unk32 param_3, unk32 param_4) {} void MapBase::vfunc_c0() {} diff --git a/src/00_Core/Map/MapManager.cpp b/src/00_Core/Map/MapManager.cpp index 22f15cf8..f2c38569 100644 --- a/src/00_Core/Map/MapManager.cpp +++ b/src/00_Core/Map/MapManager.cpp @@ -20,7 +20,8 @@ #include "Save/AdventureFlags.hpp" #include "Unknown/UnkStruct_02037750.hpp" #include "Unknown/UnkStruct_020eec68.hpp" -#include "stdio.h" + +#include <stdio.h> extern bool func_01ffbe78(Vec3p *param1, Vec3p *param2, Vec3p *param3, Vec4p *param4); @@ -46,7 +47,6 @@ extern void func_ov000_0208ed74(AABB *param_1, Vec3p *param_2); extern void func_ov000_02093a1c(u32 *param_1, unk32 *param_2, unk32 param_3); extern void func_ov000_02096324(unk32 *param_1, unk32 *param_2); extern s32 *func_ov000_02096418(s32 *param_1); -extern void func_ov000_020c3348(ActorSpawnOptions *param_1); extern void func_ov015_021849a4(unk32 *param_1); // extern MapBase *func_ov018_0215b4a0(MapBase *param_1, unk32 param_2, unk32 param_3); @@ -135,14 +135,10 @@ extern UnkStruct_0202e894 *data_027e0ce4; extern unk32 *data_027e0d3c; extern UnkStruct_027e0f68 *data_027e0f68; extern unk32 *data_027e0f70; -extern unk32 data_ov000_020e24a4; extern unk32 data_ov000_020e24b4; -extern unk32 data_ov000_020e24c4; -extern MapManager_Unk2 data_ov000_020e24c8[]; -extern MapManager_Unk2 data_ov000_020e24e8[]; extern unk32 data_ov015_02190458; -// static char *gShipParts[8] = {"anc", "bow", "hul", "can", "dco", "pdl", "fnl", "brg"}; +static char *sShipParts[8] = {"anc", "bow", "hul", "can", "dco", "pdl", "fnl", "brg"}; MapManager::MapManager() { /*MapManager_Unk1 *object; @@ -189,6 +185,20 @@ MapManager::MapManager() { return;*/ } +static const MapManager_Unk3 data_ov000_020e24c4(0x5fff); +static const MapManager_Unk1 data_ov000_020e24c8[4] = { + MapManager_Unk1(0, 0x60), + MapManager_Unk1(0, 0), + MapManager_Unk1(0x80, 0x60), + MapManager_Unk1(0x80, 0), +}; +static const MapManager_Unk2 data_ov000_020e24e8[4] = { + MapManager_Unk2(-FLOAT_TO_Q20(128.0), -FLOAT_TO_Q20(96.0)), + MapManager_Unk2(-FLOAT_TO_Q20(128.0), -FLOAT_TO_Q20(96.0)), + MapManager_Unk2(-FLOAT_TO_Q20(128.0), -FLOAT_TO_Q20(96.0)), + MapManager_Unk2(-FLOAT_TO_Q20(128.0), -FLOAT_TO_Q20(96.0)), +}; + MapManager::~MapManager() {} ARM void MapManager::GetCourseDungeonProgress(CourseProgress *param_2) { @@ -560,14 +570,13 @@ ARM void MapManager::func_ov00_02082af4() { } ARM bool MapManager::func_ov00_02082b3c(FlagsUnk2 *param_2) { - Vec2b mapGridPos; u8 entranceId; bool cmp; ActorManager *actorManager; u16 var1; u32 var2; - Course::FindMapGridPos(&mapGridPos, this->mCourse, param_2->mUnk_04.mUnk_0e); + TilePos mapGridPos = this->mCourse->FindMapGridPos(param_2->mUnk_04.mUnk_0e); if (mapGridPos.x != this->GetCurrentMapPosX() || mapGridPos.y != this->GetCurrentMapPosY() || (param_2->mUnk_04.mUnk_00.y == 1 && data_027e0d38->mUnk_14 == 1) || param_2->mUnk_04.mUnk_11 != 0) { @@ -629,7 +638,7 @@ ARM u32 MapManager::func_ov00_02082d74(unk32 param_2) { return func_ov000_02078bc4(param_2); } -ARM void MapManager::func_ov00_02082d84(Vec2b *param_2, s32 *param_3, s32 *param_4) { +ARM void MapManager::func_ov00_02082d84(TilePos *param_2, s32 *param_3, s32 *param_4) { s32 mapWidth = this->GetMapWidth(); u32 uVar3 = CoDivide64By32(0x100000, mapWidth << 0xc); s32 mapHeight = this->GetMapHeight(); @@ -646,7 +655,6 @@ ARM bool MapManager::func_ov00_02082e1c(s32 *param_2, s32 *param_3) { Vec2p mapScreenPos; u8 uVar8; Vec3p local_28; - Vec2b local_4a; Vec3p local_4c; Course *course; bool bVar1; @@ -678,10 +686,10 @@ ARM bool MapManager::func_ov00_02082e1c(s32 *param_2, s32 *param_3) { if (!this->mCourse->GetMapScreenPos(bVar1, &mapScreenPos.x, &mapScreenPos.y)) { this->mCourse->GetMapScreenPos(uVar8, &mapScreenPos.x, &mapScreenPos.y); - Course::FindMapGridPos(&local_4a, this->mCourse, uVar8); - MapManager::func_ov00_02083a54(&local_4a, this, &local_28, local_4a.x, local_4a.y); - uVar8 = this->mCourse->GetScreenMapCellSizeX(); - lVar3 = (int) ((u32) local_4c.x << 0xc) * (int) uVar8 + 0x800; + TilePos local_4a = this->mCourse->FindMapGridPos(uVar8); + local_4a = this->func_ov00_02083a54(&local_28, local_4a.x, local_4a.y); + uVar8 = this->mCourse->GetScreenMapCellSizeX(); + lVar3 = (int) ((u32) local_4c.x << 0xc) * (int) uVar8 + 0x800; *param_2 = mapScreenPos.y + ((int) (((u32) lVar3 >> 0xc | (int) (lVar3 >> 0x20) * 0x100000) + 0x800) >> 0xc); uVar8 = this->mCourse->GetScreenMapCellSizeY(); } else { @@ -713,7 +721,7 @@ ARM bool MapManager::func_ov00_02082e1c(s32 *param_2, s32 *param_3) { } ARM void MapManager::func_ov00_0208306c(s32 *param_2, s32 *param_3) { - Vec2b auStack_2c[18]; + TilePos auStack_2c[18]; Vec3p local_1c; Vec3p local_28; unk32 pMVar1; @@ -726,8 +734,8 @@ ARM void MapManager::func_ov00_0208306c(s32 *param_2, s32 *param_3) { pMVar1 = -2; } - local_1c = gPlayerPos; - this->func_ov00_02083a1c(auStack_2c, this, &local_1c); + local_1c = gPlayerPos; + auStack_2c[0] = this->func_ov00_02083a1c(&local_1c); this->func_ov00_02082d84(auStack_2c, param_2, param_3); if (pMVar3 == -3 || pMVar3 == pMVar1) { @@ -916,8 +924,8 @@ ARM void MapManager::func_ov00_02083524(Vec3p *param_2, unk32 param_3, unk32 par param_2->z = mapCenter->z; } -ARM void MapManager::func_ov00_02083560(Vec2b *param_1, MapManager *param_2, u32 param_3) { - param_2->mCourse->FindMapGridPos(param_1, param_2->mCourse, param_3); +ARM TilePos MapManager::func_ov00_02083560(u32 param_3) { + return this->mCourse->FindMapGridPos(param_3); } ARM u8 MapManager::func_ov00_02083570(u8 param_2, u8 param_3) { @@ -1120,47 +1128,31 @@ ARM s32 MapManager::func_ov00_020839f8(s32 param_2) { return this->mMap->GetClampedTileY(param_2 - this->GetMapCenterZ()); } -ARM void MapManager::func_ov00_02083a1c(Vec2b *param_1, MapManager *param_2, Vec3p *param_3) { - s8 x = param_2->func_ov00_020839f8(param_3->z); - s8 y = param_2->func_ov00_020839d4(param_3->x); - param_1->x = y; - param_1->y = x; +ARM TilePos MapManager::func_ov00_02083a1c(Vec3p *param_3) { + s8 y = this->func_ov00_020839f8(param_3->z); + s8 x = this->func_ov00_020839d4(param_3->x); + return TilePos(x, y); } -ARM void MapManager::func_ov00_02083a54(Vec2b *param_1, MapManager *param_2, Vec3p *param_3, s32 param_4, unk32 param_5) { - unk8 uVar2; - unk8 uVar3; - s32 iVar4; +ARM TilePos MapManager::func_ov00_02083a54(Vec3p *param_3, s32 param_4, unk32 param_5) { Vec3p VStack_20; u32 uVar5; - Vec3p *piVar6; Vec3p local_2c; Vec3p local_38; - if (param_2->GetCourseData_Unk_25c() != 0) { - uVar5 = (param_4 == -1 || param_5 == 0xffffffff) ? param_2->func_ov00_02082d08() - : uVar5 = param_2->mCourse->mMapGrid[param_4][param_5]; + if (this->GetCourseData_Unk_25c() != 0) { + uVar5 = (param_4 == -1 || param_5 == 0xffffffff) ? this->func_ov00_02082d08() + : uVar5 = this->mCourse->mMapGrid[param_4][param_5]; - if (param_2->IsMapInMainGrid(uVar5)) { - param_2->func_ov00_02083524(&VStack_20, param_4, param_5); + if (this->IsMapInMainGrid(uVar5)) { + this->func_ov00_02083524(&VStack_20, param_4, param_5); local_38 = *param_3; Vec3p_Sub(&local_38, &VStack_20, &local_2c); - uVar2 = param_2->mMap->GetClampedTileY(local_2c.z); - uVar3 = param_2->mMap->GetClampedTileX(local_2c.x); - param_1->x = uVar3; - param_1->y = uVar2; - return; + return TilePos(this->mMap->GetClampedTileX(local_2c.x), this->mMap->GetClampedTileY(local_2c.z)); } - uVar2 = param_2->func_ov00_020839f8(param_3->z); - uVar3 = param_2->func_ov00_020839d4(param_3->x); - param_1->x = uVar3; - param_1->y = uVar2; - return; + return TilePos(this->func_ov00_020839d4(param_3->x), this->func_ov00_020839f8(param_3->z)); } - uVar2 = param_2->func_ov00_020839f8(param_3->z); - uVar3 = param_2->func_ov00_020839d4(param_3->x); - param_1->x = uVar3; - param_1->y = uVar2; + return TilePos(this->func_ov00_020839d4(param_3->x), this->func_ov00_020839f8(param_3->z)); } ARM s32 MapManager::GetTileStartX(unk32 x) { @@ -1187,7 +1179,7 @@ ARM s32 MapManager::func_ov00_02083c50(unk32 z) { return this->GetMapCenterZ() + this->mMap->GetTileStartZ(z) + 0x800; } -ARM void MapManager::func_ov00_02083c7c(Vec3p *param_2, Vec2b param_3) { +ARM void MapManager::func_ov00_02083c7c(Vec3p *param_2, TilePos param_3) { Vec3p local_28; param_2->x = this->func_ov00_02083c24(param_3.x); @@ -1196,13 +1188,13 @@ ARM void MapManager::func_ov00_02083c7c(Vec3p *param_2, Vec2b param_3) { param_2->y = this->MapData_vfunc_68(&local_28, true); } -ARM void MapManager::func_ov00_02083ce8(Vec3p *param_2, Vec2b param_3, s32 param_4, u32 param_5) { +ARM void MapManager::func_ov00_02083ce8(Vec3p *param_2, TilePos param_3, s32 param_4, u32 param_5) { u32 uVar2; u8 uVar3; u8 uVar4; Vec3p local_2c; Vec3p local_38; - Vec2b local_8; + TilePos local_8; if (GetCourseData_Unk_25c()) { if (param_4 == -1 || param_5 == -1) { @@ -1229,17 +1221,17 @@ ARM void MapManager::func_ov00_02083ce8(Vec3p *param_2, Vec2b param_3, s32 param } ARM s32 MapManager::func_ov00_02083e34(unk8 param_2, unk8 param_3, unk32 param_4) { - Vec2b local_8; + TilePos local_8; local_8.x = param_2; local_8.y = param_3; return this->mMap->vfunc_60(&local_8); } -ARM unk32 MapManager::MapData_vfunc_60(Vec2b *param_1) { +ARM unk32 MapManager::MapData_vfunc_60(TilePos *param_1) { return this->mMap->vfunc_60(param_1); } -ARM bool MapManager::func_ov00_02083e70(Vec2b *param_2) { +ARM bool MapManager::func_ov00_02083e70(TilePos *param_2) { switch (this->MapData_vfunc_54(param_2)) { case 0x1b: case 0x2b: @@ -1268,7 +1260,7 @@ ARM s32 MapManager::func_ov00_02083ef8(Vec3p *param_2, Vec3p *param_3, bool para ARM unk32 MapManager::func_ov00_02083f44(Vec3p *param_2, bool param_3) { q20 x = param_2->x; q20 z = param_2->z; - Vec3p local_18 = {x, data_ov000_020e24a4, z}; + Vec3p local_18 = {x, data_ov000_020e24c4.mUnk_0, z}; return this->func_ov00_02083ef8(param_2, &local_18, param_3); } @@ -1299,7 +1291,7 @@ ARM void MapManager::func_ov00_02083fb0(u32 *param_1, MapManager *param_2, Vec3p *param_1 = 0; } -void MapManager::GetTileWorldBounds(Vec2b *tile, AABB *tileBounds) { +void MapManager::GetTileWorldBounds(TilePos *tile, AABB *tileBounds) { int iVar1; Vec3p local_20; @@ -1312,24 +1304,24 @@ void MapManager::GetTileWorldBounds(Vec2b *tile, AABB *tileBounds) { Vec3p_Add(&tileBounds->max, &local_20, &tileBounds->max); } -unk32 MapManager::MapData_vfunc_54(Vec2b *param_1) { +unk32 MapManager::MapData_vfunc_54(TilePos *param_1) { return this->mMap->vfunc_54(param_1); } ARM unk32 MapManager::func_ov00_020840a0(u8 param_2, u8 param_3) { // Correct param types? - Vec2b vec; + TilePos vec; vec.x = param_2; vec.y = param_3; return this->mMap->vfunc_54(&vec); } // Returns UnkStruct_02085594* -unk32 *MapManager::MapData_vfunc_78(Vec2b *param_1) { +unk32 *MapManager::MapData_vfunc_78(TilePos *param_1) { return this->mMap->vfunc_78(param_1); } -unk32 MapManager::func_ov00_020840dc(Vec2b *param_1) { +unk32 MapManager::func_ov00_020840dc(TilePos *param_1) { UnkStruct_02037750 *piVar1; // placeholder struct until I can find the real struct piVar1 = (UnkStruct_02037750 *) this->MapData_vfunc_78(param_1); @@ -1362,11 +1354,11 @@ void MapManager::func_ov00_0208413c(unk32 param_2) { this->mMap->func_ov00_0207f948(param_2); } -unk8 MapManager::MapData_vfunc_58(Vec2b *param_1, int param_2) { +unk8 MapManager::MapData_vfunc_58(TilePos *param_1, int param_2) { this->mMap->vfunc_58(param_1, param_2); } -ARM s32 MapManager::func_ov00_02084164(Vec2b *param_2) { +ARM s32 MapManager::func_ov00_02084164(TilePos *param_2) { if (this->mMap->vfunc_58(param_2, 7) != 0) { return 0; } @@ -1802,9 +1794,6 @@ u8 MapManager::func_ov00_02084a50() { void MapManager::SpawnNPC(Vec3p *pos, unk32 param_3, unk32 param_4) { ActorSpawnOptions actorSpawnOptions; - actorSpawnOptions.mUnk_1c.id = -1; - actorSpawnOptions.mUnk_1c.index = -1; - func_ov000_020c3348(&actorSpawnOptions); actorSpawnOptions.mUnk_24 = param_3; actorSpawnOptions.mUnk_28 = param_4; gActorSpawner->Spawn(ActorTypeId_EVIC, pos, &actorSpawnOptions, NULL); @@ -1954,9 +1943,9 @@ u8 MapManager::GetMapData_Unk_09() { ARM void MapManager::func_ov00_02084d24(unk8 param_2, unk8 param_3, unk16 param_4) { // Matches, but param types unsure. - // param_2 and param_3 aren't both part of a Vec2b * + // param_2 and param_3 aren't both part of a TilePos * // param_4 short or int? - Vec2b vec; + TilePos vec; vec.x = param_2; vec.y = param_3; this->mMap->vfunc_90(&vec, param_4); @@ -2021,11 +2010,11 @@ unk32 MapManager::func_ov00_02084ebc(Vec3p *param_2) { int *piVar1; int iVar2; unk32 dVar3; // dword - Vec2b auStack_18[4]; // undefined type + TilePos auStack_18[4]; // undefined type u32 uStack_14; - this->func_ov00_02083a1c(auStack_18, this, param_2); - piVar1 = (int *) this->MapData_vfunc_78(auStack_18); + auStack_18[0] = this->func_ov00_02083a1c(param_2); + piVar1 = (int *) this->MapData_vfunc_78(auStack_18); if (piVar1 != (int *) 0x0) { // iVar2 = (**(code **) (*piVar1 + 0x1c))(); if (iVar2 < 0x39) { @@ -2288,13 +2277,12 @@ ARM unk32 MapManager::func_ov00_02085594(Vec3p *param_2) { unk32 dVar3; unk32 uVar4; bool bVar5; - Vec2b local_28; u32 uStack_24; Vec3p VStack_20; - this->func_ov00_02083a1c(&local_28, this, param_2); - piVar1 = (UnkStruct_02085594 *) this->MapData_vfunc_78(&local_28); - bVar5 = true; + TilePos local_28 = this->func_ov00_02083a1c(param_2); + piVar1 = (UnkStruct_02085594 *) this->MapData_vfunc_78(&local_28); + bVar5 = true; if (piVar1 != NULL) { *param_2 = piVar1->mUnk_14; switch (piVar1->vfunc_1c()) { @@ -2359,10 +2347,9 @@ ARM unk32 MapManager::func_ov00_02085594(Vec3p *param_2) { ARM unk32 MapManager::func_ov00_0208583c(MapManager *param_1, Vec3p *param_2, unk32 param_3) { UnkStruct_02085594 *piVar1; - Vec2b auStack_10; - param_1->func_ov00_02083a1c(&auStack_10, param_1, param_2); - piVar1 = (UnkStruct_02085594 *) param_1->MapData_vfunc_78(&auStack_10); + TilePos auStack_10 = param_1->func_ov00_02083a1c(param_2); + piVar1 = (UnkStruct_02085594 *) param_1->MapData_vfunc_78(&auStack_10); if (piVar1 == NULL) { return -1; } @@ -2382,17 +2369,17 @@ unk32 MapManager::func_ov00_020858b0(MapManager *param_1, Vec3p *param_2, unk32 UnkStruct_02085594 *piVar5; int playerPosY; unk32 local_38; - Vec2b local_28; + TilePos local_28; if (param_3 == 1) { func_ov000_02088000(data_027e0f64->mUnk_4, 7); } else { func_ov000_02088000(data_027e0f64->mUnk_4, 6); } - mapWidth = param_1->GetMapWidth(); - mapHeight = param_1->GetMapHeight(); - local_38 = -1; - param_1->func_ov00_02083a1c(&local_28, param_1, param_2); + mapWidth = param_1->GetMapWidth(); + mapHeight = param_1->GetMapHeight(); + local_38 = -1; + local_28 = param_1->func_ov00_02083a1c(param_2); playerPosY = gPlayerPos.y; for (u8 x = local_28.x - 1; x <= (int) (local_28.x + 1); x++) { if ((x > -1) && (x < mapWidth)) { @@ -2420,9 +2407,9 @@ s32 MapManager::func_ov00_02085a34(Vec3p *param_2, s32 param_3) { u32 uVar4; u32 uVar5; u32 uVar6; - Vec2b uStack_2c; - Vec2b auStack_2a[2]; - Vec2b aVStack_28[2]; + TilePos uStack_2c; + TilePos auStack_2a[2]; + TilePos aVStack_28[2]; unk16 auStack_24[4]; unk32 auStack_1c[4]; unk32 uStack_18; @@ -2433,8 +2420,8 @@ s32 MapManager::func_ov00_02085a34(Vec3p *param_2, s32 param_3) { if (param_3 != 2 && param_3 != 3) { return -1; } - this->func_ov00_02083a1c(auStack_2a, this, param_2); - piVar1 = (UnkStruct_02085594 *) this->MapData_vfunc_78(auStack_2a); + auStack_2a[0] = this->func_ov00_02083a1c(param_2); + piVar1 = (UnkStruct_02085594 *) this->MapData_vfunc_78(auStack_2a); if (piVar1 == NULL) { return -1; } @@ -2448,8 +2435,8 @@ s32 MapManager::func_ov00_02085a34(Vec3p *param_2, s32 param_3) { iVar2 = piVar1->vfunc_38(param_3); return iVar2; } - this->func_ov00_02083a1c(aVStack_28, this, param_2); - iVar2 = this->func_ov00_02084ebc(param_2); + aVStack_28[0] = this->func_ov00_02083a1c(param_2); + iVar2 = this->func_ov00_02084ebc(param_2); if (iVar2 == 0) { return -1; } @@ -2658,7 +2645,7 @@ unk8 MapManager::func_ov00_02086044(Vec3p *param_2, Vec3p *param_3, unk32 param_ int *piVar9; Vec3p *pVVar10; int iVar11; - Vec2b local_c6; + TilePos local_c6; unk32 auStack_c4[4]; Vec3p iStack_c0; Vec3p local_b0; diff --git a/src/00_Core/Player/LinkStateMove.cpp b/src/00_Core/Player/LinkStateMove.cpp index a0980773..a7e64be0 100644 --- a/src/00_Core/Player/LinkStateMove.cpp +++ b/src/00_Core/Player/LinkStateMove.cpp @@ -1,4 +1,5 @@ #include "Player/LinkStateMove.hpp" +#include "Unknown/UnkStruct_020eec9c.hpp" unk32 LinkStateMove::data_ov000_020e56f0 = 0x800; @@ -19,9 +20,6 @@ THUMB void LinkStateMove::CreateDebugHierarchy() { 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; @@ -36,7 +34,7 @@ ARM void LinkStateMove::OnStateEnter() { shield->UpdateInUse(1); PlayerBase::GetEquipSword()->func_ov000_020c06b0(-1); - func_ov000_020d77e4(&data_ov000_020eec9c, 0xD); + data_ov000_020eec9c.func_ov000_020d77e4(0xD); } ARM void LinkStateMove::OnStateLeave(s32 param1) { diff --git a/src/00_Core/Player/PlayerControl.cpp b/src/00_Core/Player/PlayerControl.cpp index 5476834e..1e5f5d98 100644 --- a/src/00_Core/Player/PlayerControl.cpp +++ b/src/00_Core/Player/PlayerControl.cpp @@ -14,6 +14,7 @@ #include "Player/PlayerBase.hpp" #include "Player/PlayerLinkBase.hpp" #include "Save/AdventureFlags.hpp" +#include "Unknown/UnkStruct_020eec9c.hpp" static char *sShipTypes[] = {"brg", "anc", "pdl", "hul", "can", "dco", "bow", "fnl"}; @@ -66,7 +67,7 @@ ARM Actor *PlayerControl::GetFollowActor() { return gActorManager->GetActor(&mFollowRef); } -ARM bool PlayerControl::func_ov00_020af01c(Vec2b *param1) { +ARM bool PlayerControl::func_ov00_020af01c(TilePos *param1) { if (mFollowing) { *param1 = mUnk_9c; return true; @@ -300,8 +301,7 @@ ARM void PlayerControl::func_ov00_020af6e4(Vec3p *param1, s32 param3, s32 param4 mFollowRef.Reset(); } - Vec2b unk; - MapManager::func_ov00_02083a1c(&unk, gMapManager, param1); + TilePos unk = gMapManager->func_ov00_02083a1c(param1); mUnk_9c = unk; mFollowing = true; mUnk_80 = false; @@ -376,8 +376,7 @@ ARM bool PlayerControl::func_ov00_020af778() { } } } else { - ActorRef ref; - ActorManager::func_ov00_020c3484(&ref, gActorManager, 0); + ActorRef ref = gActorManager->func_ov00_020c3484(0); mNextFollowRef = ref; if (mTouchDuration == 0) { mLastFollowRef = mNextFollowRef; @@ -475,9 +474,8 @@ ARM void PlayerControl::func_ov00_020afb6c() { iVar7 = 2; } } else { - local_3c.y = gPlayerPos.y; - Vec2b local_44 = mUnk_9c; - gMapManager->func_ov00_02083c7c(&local_3c, local_44); + local_3c.y = gPlayerPos.y; + gMapManager->func_ov00_02083c7c(&local_3c, mUnk_9c); iVar2 = 2; iVar7 = 3; } @@ -721,8 +719,7 @@ ARM bool PlayerControl::func_ov00_020b05e8(Vec3p *param1) { VStack_1c.z += MUL_Q20(COS(gPlayerAngle), FLOAT_TO_Q20(0.25)); } - Vec2b VStack_20; - MapManager::func_ov00_02083a1c(&VStack_20, gMapManager, &VStack_1c); + TilePos VStack_20 = gMapManager->func_ov00_02083a1c(&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); @@ -1032,11 +1029,9 @@ 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); + data_ov000_020eec9c.func_ov000_020d77e4(0x17); return true; } return false; |
