diff options
| author | Aetias <144526980+AetiasHax@users.noreply.github.com> | 2025-07-01 00:37:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-01 00:37:52 +0200 |
| commit | cfb0123c4a582a7cd28e1a49e7642cba0260cc6f (patch) | |
| tree | f5e88a237371e2f30a7694df7fdb13d8ba14814c /src | |
| parent | 3fe49695b4936ea29526eb8b7d07250a69a06c38 (diff) | |
| parent | d5ee59ebf71787a0c6a8ac9c5f5890e79407c60d (diff) | |
Merge pull request #60 from Yanis002/bmg
Decomp functions related to BMG files
Diffstat (limited to 'src')
| -rw-r--r-- | src/00_Core/Actor/ActorManager.cpp | 4 | ||||
| -rw-r--r-- | src/00_Core/DTCM/UnkStruct_027e103c.cpp | 4 | ||||
| -rw-r--r-- | src/05/Player/LinkStateCutscene.cpp | 2 | ||||
| -rw-r--r-- | src/Main/Message/BMG.cpp | 211 | ||||
| -rw-r--r-- | src/Main/Message/BmgRelatedFunctions.cpp | 68 | ||||
| -rw-r--r-- | src/Main/Message/MessageManager.cpp | 576 | ||||
| -rw-r--r-- | src/Main/Message/func_0203c358.cpp | 76 | ||||
| -rw-r--r-- | src/Main/Message/func_0203c72c.cpp | 36 | ||||
| -rw-r--r-- | src/Main/Unknown/UnkStruct_02032f0c.cpp | 139 | ||||
| -rw-r--r-- | src/Main/Unknown/UnkStruct_02035064.cpp | 47 | ||||
| -rw-r--r-- | src/Main/Unknown/UnkStruct_02037750.cpp | 245 | ||||
| -rw-r--r-- | src/Main/Unknown/UnkStruct_02038aa0.cpp | 272 | ||||
| -rw-r--r-- | src/Main/Unknown/UnkStruct_020397f8.cpp | 1035 | ||||
| -rw-r--r-- | src/Main/Unknown/UnkStruct_0203dae0.cpp | 213 |
14 files changed, 2759 insertions, 169 deletions
diff --git a/src/00_Core/Actor/ActorManager.cpp b/src/00_Core/Actor/ActorManager.cpp index 955c447d..d9dbe8b1 100644 --- a/src/00_Core/Actor/ActorManager.cpp +++ b/src/00_Core/Actor/ActorManager.cpp @@ -312,7 +312,7 @@ ARM s32 ActorManager::func_ov00_020c3bb0(unk32 param1, s32 *param2) { if (param2 != NULL) *param2 = 0; AABB boxes[8]; - s32 numBoxes = gMapManager->GetTriggerBoundingBoxes(param1, boxes, ARRAY_LEN(boxes)); + s32 numBoxes = gMapManager->GetTriggerBoundingBoxes(param1, boxes, ARRAY_LEN_U(boxes)); if (numBoxes <= 0) return 0; s32 i; @@ -349,7 +349,7 @@ ARM s32 ActorManager::func_ov00_020c3bb0(unk32 param1, s32 *param2) { ARM void ActorManager::func_ov00_020c3ce8(unk32 param1, bool param2) { AABB boxes[8]; - s32 numBoxes = gMapManager->GetTriggerBoundingBoxes(param1, boxes, ARRAY_LEN(boxes)); + s32 numBoxes = gMapManager->GetTriggerBoundingBoxes(param1, boxes, ARRAY_LEN_U(boxes)); if (numBoxes <= 0) return; s32 i; diff --git a/src/00_Core/DTCM/UnkStruct_027e103c.cpp b/src/00_Core/DTCM/UnkStruct_027e103c.cpp index 53f72d35..e455c9c9 100644 --- a/src/00_Core/DTCM/UnkStruct_027e103c.cpp +++ b/src/00_Core/DTCM/UnkStruct_027e103c.cpp @@ -36,7 +36,7 @@ void UnkStruct_027e103c::func_ov000_020cf3dc() {} void UnkStruct_027e103c::func_ov000_020cf3f0() {} void UnkStruct_027e103c::func_ov000_020cf404() {} void UnkStruct_027e103c::func_ov000_020cf414() {} -void UnkStruct_027e103c::func_ov000_020cf42c() {} +bool UnkStruct_027e103c::func_ov000_020cf42c() {} bool UnkStruct_027e103c::func_ov000_020cf444() {} bool UnkStruct_027e103c::func_ov000_020cf488() {} bool UnkStruct_027e103c::func_ov000_020cf4bc() {} @@ -59,7 +59,7 @@ void UnkStruct_027e103c::func_ov000_020cfa70(s32 param1, s32 param2) {} unk8 UnkStruct_027e103c::func_ov000_020cfab0() {} void UnkStruct_027e103c::func_ov000_020cfabc(s32 param1, s32 param2) {} void UnkStruct_027e103c::func_ov000_020cfae8(s32 param1, s32 param2) {} -void UnkStruct_027e103c::func_ov000_020cfb20(unk32 param1) {} +void UnkStruct_027e103c::func_ov000_020cfb20(void *param1) {} void UnkStruct_027e103c::func_ov000_020cfb38() {} void UnkStruct_027e103c::func_ov000_020cfb48() {} void UnkStruct_027e103c::func_ov000_020cfb58() {} diff --git a/src/05/Player/LinkStateCutscene.cpp b/src/05/Player/LinkStateCutscene.cpp index 7eaf872c..6875d229 100644 --- a/src/05/Player/LinkStateCutscene.cpp +++ b/src/05/Player/LinkStateCutscene.cpp @@ -1,7 +1,7 @@ #include "Player/LinkStateCutscene.hpp" unk32 UnkStruct_ov004_0210abb8::vfunc_2c(s32 param1) {} -void UnkStruct_ov004_0210abb8::vfunc_24(unk32 param1) {} +bool UnkStruct_ov004_0210abb8::vfunc_24(unk32 param1) {} void LinkStateCutscene::func_ov005_021089c0() {} void LinkStateCutscene::func_ov005_021089f4() {} void LinkStateCutscene::func_ov005_02108d08() {} diff --git a/src/Main/Message/BMG.cpp b/src/Main/Message/BMG.cpp new file mode 100644 index 00000000..cb9deac8 --- /dev/null +++ b/src/Main/Message/BMG.cpp @@ -0,0 +1,211 @@ +extern "C" { +#include <string.h> +} +#include "Message/BMG.hpp" + +char *func_0202ab38(u32 *lang); +u32 *func_0202d550(int, u32 *, char *path, int, int, int); +void func_0202d590(BMGHeader *); + +extern u32 *data_027e0ce0[]; +extern u32 data_027e05f4; // language +extern u32 *data_ov002_0210016c; + +static char *sBMGFileNames[BMG_FILE_INDEX_MAX] = { + "system", // BMG_FILE_INDEX_SYSTEM + "regular", // BMG_FILE_INDEX_REGULAR + "battle", // BMG_FILE_INDEX_BATTLE + "test", // BMG_FILE_INDEX_TEST + "default", // BMG_FILE_INDEX_DEFAULT + "sea", // BMG_FILE_INDEX_SEA + "kaitei", // BMG_FILE_INDEX_KAITEI + "main_isl", // BMG_FILE_INDEX_MAIN_ISL + "brave", // BMG_FILE_INDEX_BRAVE + "flame", // BMG_FILE_INDEX_FLAME + "wind", // BMG_FILE_INDEX_WIND + "frost", // BMG_FILE_INDEX_FROST + "power", // BMG_FILE_INDEX_POWER + "wisdom", // BMG_FILE_INDEX_WISDOM + "ghost", // BMG_FILE_INDEX_GHOST + "hidari", // BMG_FILE_INDEX_HIDARI + "sennin", // BMG_FILE_INDEX_SENNIN + "ship", // BMG_FILE_INDEX_SHIP + "collect", // BMG_FILE_INDEX_COLLECT + "mainselect", // BMG_FILE_INDEX_MAINSELECT + "field", // BMG_FILE_INDEX_FIELD + "wisdom_dngn", // BMG_FILE_INDEX_WISDOM_DNGN + "demo", // BMG_FILE_INDEX_DEMO + "battleCommon", // BMG_FILE_INDEX_BATTLECOMMON + "bossLast1", // BMG_FILE_INDEX_BOSSLAST1 + "bossLast3", // BMG_FILE_INDEX_BOSSLAST3 + "torii", // BMG_FILE_INDEX_TORII + "myou", // BMG_FILE_INDEX_MYOU + "kojima1", // BMG_FILE_INDEX_KOJIMA1 + "kojima2", // BMG_FILE_INDEX_KOJIMA2 + "kojima5", // BMG_FILE_INDEX_KOJIMA5 + "kojima3", // BMG_FILE_INDEX_KOJIMA3 + "staff", // BMG_FILE_INDEX_STAFF + "kaitei_F", // BMG_FILE_INDEX_KAITEI_F +}; + +THUMB void BMGFileInfo::func_020371b4() { + this->pHeader = NULL; + this->pINF1 = NULL; + this->pFLW1 = NULL; + this->pFLI1 = NULL; + this->pDAT1 = NULL; + this->mUnk_14 = NULL; + this->mUnk_18 = 0; +} + +// non-matching (equivalent) +THUMB u16 BMGFileInfo::func_020371c8(u32 *pFile, s16 unk_18) { + SectionBase *pSection; + u16 groupId; + u32 i; + BMGHeader *pHeader = (BMGHeader *) pFile; + + groupId = -1; + this->mUnk_14 = pHeader; + this->mUnk_18 = unk_18; + this->pHeader = pHeader; + pSection = (SectionBase *) ((u8 *) pFile + sizeof(BMGHeader)); + + for (i = 0; i < this->mUnk_14->numSections; i++) { + switch (pSection->tag) { + case BMG_TAG_MID1: + // unused + break; + case BMG_TAG_STR1: + // unused + break; + case BMG_TAG_INF1: + this->pINF1 = (SectionINF1 *) pSection; + groupId = this->pINF1->groupId; + break; + case BMG_TAG_DAT1: + //! TODO: fake? + this->pDAT1 = (SectionDAT1 *) (pSection + 1); + break; + case BMG_TAG_FLW1: this->pFLW1 = (SectionFLW1 *) pSection; break; + case BMG_TAG_FLI1: this->pFLI1 = (SectionFLI1 *) pSection; break; + } + + pSection = (SectionBase *) ((u8 *) pSection + pSection->size); + } + + return groupId; +} + +ARM EntryINF1 *BMGFileInfo::func_02037258(u16 param_2) { + if (this->pINF1 != NULL) { + if (param_2 < this->pINF1->numEntries) { + return (EntryINF1 *) ((u32) & this->pINF1->entries + this->pINF1->entrySize * param_2); + } + + return NULL; + } + + return NULL; +} + +// non-matching +ARM u16 BMGFileInfo::func_0203728c(unk32 param_2) { + SectionFLI1 *pFLI1; + EntryFLI1 *entry; + u32 i; + u16 j; + + pFLI1 = this->pFLI1; + + if (pFLI1 == NULL) { + return -1; + } + + i = 0; + do { + entry = &pFLI1->entries[i]; + + if (param_2 > entry->msgFlowID) { + return entry->msgFlowNodeIndex; + } + + // i++; + j = i + 1; + i = j & 0xFFFF; + } while (j < pFLI1->numEntries); + + // for (i = 0; (u16)i < pFLI1->numEntries; i++) { + // if (param_2 == pFLI1->entries[i].msgFlowID) { + // return pFLI1->entries[i].msgFlowNodeIndex; + // } + // } + + return -1; +} + +THUMB void BMGGroups::func_020372f0(BMGFileIndex eIndex, s16 unk_18) { + char bmgPath[64]; + BMGFileInfo bmgFile; + u32 *pFile; + u16 groupId; + + // path to the bmg file for the current language (i.e.: "English/Message/battle.bmg") + strcpy(bmgPath, func_0202ab38(&data_027e05f4)); + strcat(bmgPath, "/Message/"); + strcat(bmgPath, sBMGFileNames[eIndex]); + strcat(bmgPath, ".bmg"); + + pFile = data_027e0ce0[1]; + + if (unk_18 != 1) { + if (unk_18 != 4) { + pFile = data_027e0ce0[0]; + } else { + pFile = data_ov002_0210016c; + } + } else { + // pFile = data_027e0ce0[0]; + } + + // get file data + pFile = func_0202d550(0xC4, pFile, bmgPath, 0, 0x10, 0); + + // initialize file info + bmgFile.groupId = 0; + bmgFile.func_020371b4(); + + // assign sections and set the file info in the groups entries + groupId = bmgFile.func_020371c8(pFile, unk_18); + this->entries[groupId] = bmgFile; + this->entries[groupId].groupId = groupId; +} + +THUMB void BMGGroups::func_020373b4(s16 unk_18) { + s32 i; + + for (i = 0; i < this->numEntries; i++) { + if (this->entries[i].mUnk_18 == unk_18) { + func_0202d590(this->entries[i].mUnk_14); + this->entries[i].func_020371b4(); + } + } +} + +ARM u32 BMGGroups::func_020373ec(unk32 param_2) { + u16 dVar1; + u16 uVar2; + s32 i; + + dVar1 = -1; + + for (i = 0; i < this->numEntries; i++) { + uVar2 = this->entries[i].func_0203728c(param_2); + + if (uVar2 != dVar1) { + return uVar2 | i << 0x10; + } + } + + return -1; +} diff --git a/src/Main/Message/BmgRelatedFunctions.cpp b/src/Main/Message/BmgRelatedFunctions.cpp new file mode 100644 index 00000000..dcb3d255 --- /dev/null +++ b/src/Main/Message/BmgRelatedFunctions.cpp @@ -0,0 +1,68 @@ +extern "C" { +#include <string.h> +} + +#include "global.h" +#include "types.h" + +THUMB void func_0202d3bc(int param_1, unsigned int *param_2, char *path, int param_4, int param_5, bool param_6, int param_7, + int param_8) { + // bool bVar1; + // dword dVar2; + // int iVar3; + // dword *pdVar4; + // uint uVar5; + // dword local_64; + // astruct_3 aStack_60; + // dword *pdStack_18; + + // pdVar4 = (dword *)(uint)param_4; + // *(char **)PTR_DWORD_0202d46c = path; + // local_64 = DWORD_0202d470; + // if (pdVar4 != (dword *)0x0) { + // *pdVar4 = DWORD_0202d470; + // } + // pdStack_18 = pdVar4; + // astruct_3(&aStack_60); + // bVar1 = FUN_02041e7c(&aStack_60,path); + // if (bVar1) { + // uVar5 = aStack_60._40_4_ - aStack_60._36_4_; + // if (uVar5 != 0) { + // if (param_6) { + // local_64 = FUN_0202d23c(&aStack_60,param_1,param_2,param_5,0,uVar5,pdVar4,param_7,param_8); + // } + // else { + // if (param_7 == 0) { + // dVar2 = FUN_0202d1c4(param_1,param_2,uVar5,param_5); + // } + // else { + // dVar2 = 0; + // if (uVar5 <= param_8) { + // dVar2 = param_7; + // } + // } + // if (dVar2 != 0) { + // iVar3 = astruct_3::FUN_02041fa4(&aStack_60,dVar2,uVar5); + // if (iVar3 == -1) { + // if (param_7 == 0) { + // FUN_0202d21c(dVar2); + // } + // } + // else { + // local_64 = dVar2; + // if (pdVar4 != (dword *)0x0) { + // *pdVar4 = uVar5; + // } + // } + // } + // } + // } + // astruct_3::FUN_02041ea8(&aStack_60); + // } + + // return local_64; +} + +THUMB void func_0202d550(int param_1, unsigned int *param_2, char *path, int param_4, int param_5, bool param_6) { + func_0202d3bc(param_1, param_2, path, param_4, param_5, param_6, 0, 0); +} diff --git a/src/Main/Message/MessageManager.cpp b/src/Main/Message/MessageManager.cpp new file mode 100644 index 00000000..812a9b2a --- /dev/null +++ b/src/Main/Message/MessageManager.cpp @@ -0,0 +1,576 @@ +#include "Message/MessageManager.hpp" +#include "Actor/ActorManager.hpp" +#include "Player/TouchControl.hpp" +#include "System/SysNew.hpp" + +extern ARM unk32 func_ov000_020d7f18(u32 *, unk32); +extern ARM unk32 func_02037628(u8 *); + +extern u32 *data_027e0ce0[]; +extern u32 data_02056924[]; +extern UnkStruct_MsgProc_Base_unk_2C *data_02068e6c; +extern UnkStruct_MsgProc_Base_unk_2C *data_02068e8c; +extern u16 data_02056918[]; +extern ActorTypeId data_0205691c[]; + +struct UnkStruct_027e0ffc { + void func_ov000_020cec60(u16, Vec3p *, Actor *, unk32); +}; +extern UnkStruct_027e0ffc *data_027e0ffc; + +extern u32 data_027e0618[]; + +// non-matching +ARM void MessageManager::func_0203643c(u32 *param_1, MessageManager *param_2, u32 param_3) { + BMGGroups *pBVar2 = param_2->pGroups; + + *param_1 = ((u32) pBVar2->entries[param_3 >> 0x10].pDAT1 + + (pBVar2->entries[param_3 >> 0x10].func_02037258(param_3 & 0xFFFF)->offset & ~1)); +} + +// non-matching +THUMB void MessageManager::func_02036490(unk32 param_2, unk32 param_3, unk32 param_4) { + this->mUnk_03 = 0; + this->mUnk_0c = 0; + + this->pGroups->func_020372f0(BMG_FILE_INDEX_SYSTEM, 2); + + switch (*data_027e0618) { + case 3: + this->pGroups->func_020372f0(BMG_FILE_INDEX_MAINSELECT, 2); + this->pGroups->func_020372f0(BMG_FILE_INDEX_BATTLE, 2); + break; + case 5: + this->pGroups->func_020372f0(BMG_FILE_INDEX_BATTLE, 2); + this->pGroups->func_020372f0(BMG_FILE_INDEX_BATTLECOMMON, 2); + break; + case 6: + this->pGroups->func_020372f0(BMG_FILE_INDEX_BATTLE, 2); + this->pGroups->func_020372f0(BMG_FILE_INDEX_BATTLECOMMON, 2); + break; + case 7: this->pGroups->func_020372f0(BMG_FILE_INDEX_MAINSELECT, 2); break; + default: break; + } + + for (s32 i = 0; i < ARRAY_LEN(this->mUnk_18); i++) { + this->mUnk_18[i] = NULL; + } + + for (s32 i = 0; i < ARRAY_LEN(this->mUnk_28); i++) { + this->mUnk_28[i] = NULL; + } + + for (s32 i = 0; i < ARRAY_LEN(this->mUnk_18); i++) { + this->mUnk_18[i] = new(data_027e0ce0[1], 4) UnkStruct_020386d8(); + } + + this->mUnk_18[0]->mUnk_39 = 0; + this->mUnk_18[1]->mUnk_39 = 1; + + if (*data_027e0618 == 2 || *data_027e0618 == 3 || *data_027e0618 == 6) { + for (s32 i = 0; i < ARRAY_LEN(this->mUnk_28); i++) { + switch (data_02056924[i + 1]) { + case 0: + if (*data_027e0618 != 2) { + this->mUnk_28[i] = new(data_027e0ce0[1], 4) UnkStruct_020397f8(); + this->mUnk_28[i]->func_0203dc74(0xE0, 0x40); + this->mUnk_28[i]->mUnk_2c = &data_02068e6c; + this->mUnk_28[i]->mUnk_50 = i != 0; + } + break; + case 1: + this->mUnk_28[i] = new(data_027e0ce0[1], 4) MsgProc_Type3(); + this->mUnk_28[i]->func_0203dc74(0x50, 0x60); + this->mUnk_28[i]->mUnk_2c = &data_02068e6c; + break; + case 2: this->mUnk_28[i] = NULL; break; + case 3: + if (func_0202ab48() == 0) { + this->mUnk_28[i] = new(data_027e0ce0[1], 4) MsgProc_Type2(); + this->mUnk_28[i]->func_0203dc74(0xC0, 0x20); + this->mUnk_28[i]->mUnk_2c = &data_02068e8c; + } else { + this->mUnk_28[i] = NULL; + } + break; + default: break; + } + + if (this->mUnk_28[i] != NULL) { + this->mUnk_28[i]->vfunc_4C(); + } + } + } +} + +THUMB void MessageManager::func_0203665c(void) { + for (s32 i = 0; i < ARRAY_LEN(this->mUnk_28); i++) { + if (this->mUnk_28[i] != NULL) { + delete this->mUnk_28[i]; + + this->mUnk_28[i] = NULL; + } + } + + for (s32 i = 0; i < ARRAY_LEN(this->mUnk_18); i++) { + if (this->mUnk_18[i] != NULL) { + delete this->mUnk_18[i]; + + this->mUnk_18[i] = NULL; + } + } + + this->pGroups->func_020373b4(2); +} + +// non-matching +ARM UnkStruct_020397f8 *MessageManager::func_020366c4(void) { + if ((data_02056be4[data_027e077c.mUnk_0] & 1) && !(data_02056be4[data_027e077c.mUnk_0] & 2)) { + return (UnkStruct_020397f8 *) this->mUnk_28[2]; + } + + return (UnkStruct_020397f8 *) this->mUnk_28[0]; +} + +// non-matching +ARM UnkStruct_020397f8 *MessageManager::func_02036700(void) { + if ((data_02056be4[data_027e077c.mUnk_0] & 1) && !(data_02056be4[data_027e077c.mUnk_0] & 2)) { + return (UnkStruct_020397f8 *) this->mUnk_28[0]; + } + + return (UnkStruct_020397f8 *) this->mUnk_28[2]; +} + +ARM UnkStruct_020386d8 *MessageManager::func_0203673c(void) { + bool iVar1 = this->func_02036824(); + bool iVar2 = this->func_02036850(); + + if (iVar1) { + return this->mUnk_18[0]; + } + + if (iVar2) { + return this->mUnk_18[1]; + } + + return NULL; +} + +ARM bool MessageManager::func_02036770(u32 param_2) { + return (this->mUnk_18[param_2]->mUnk_18 & ~0xFFFF) == (0x100 << 0x10); +} + +ARM unk32 MessageManager::func_02036798(void) { + unk32 uVar2 = 1; + + if (this->mUnk_04 == 0) { + bool bVar1 = false; + + if (this->mUnk_18[1] != NULL && (this->mUnk_18[1]->mUnk_18 & 0xFFFF0000) != (1 << 24)) { + bVar1 = true; + } + + if (!bVar1) { + uVar2 = 0; + } + } + + return uVar2; +} + +ARM bool MessageManager::func_020367dc(int param_2) { + return param_2 == 0; +} + +ARM bool MessageManager::func_020367ec(void) { + return ((UnkStruct_020397f8 *) this->mUnk_28[0])->mUnk_15c > 0; +} + +ARM bool MessageManager::func_02036808(void) { + return ((UnkStruct_020397f8 *) this->mUnk_28[2])->mUnk_15c > 0; +} + +ARM bool MessageManager::func_02036824(void) { + switch (data_027e077c.mUnk_0) { + case 0x01: + case 0x37: + case 0x3B: return true; + default: break; + } + + return false; +} + +// non-matching +ARM bool MessageManager::func_02036850(void) { + return !(data_02056be4[data_027e077c.mUnk_0] & 2) && (data_02056be4[data_027e077c.mUnk_0] & 1); +} + +ARM void MessageManager::func_02036888(UnkStruct_020386d8 *param_2) { + if ((param_2->mUnk_18 & ~0xFFFF) != (0x100 << 0x10)) { + UnkStruct_020397f8 *iVar1 = this->func_020366c4(); + + if (iVar1->mUnk_15c <= 0) { + param_2->vfunc_10(); + } else { + param_2->vfunc_0c(this->func_020366c4()); + } + } +} + +ARM bool MessageManager::func_020368f4(UnkStruct_02037750 *param_2) { + if (this->mUnk_20[1] != NULL) { + return false; + } + + this->mUnk_20[1] = param_2; + return true; +} + +// non-matching +ARM void MessageManager::func_0203690c(unk32 param_2, unk32 param_3, unk32 param_4) { + UnkStruct_020397f8 *unk_28_0; + UnkStruct_020397f8 *unk_28_2; + UnkStruct_02038aa0 *pSVar4; + ActorRef actorRef; + Actor *pActor; + bool iVar1; + bool iVar2; + s32 i; + + if (!this->func_020367dc(param_2)) { + return; + } + + this->mUnk_40[1] = this->mUnk_40[0]; + + unk_28_0 = (UnkStruct_020397f8 *) this->mUnk_28[0]; + + if (unk_28_0 != NULL && unk_28_0->mUnk_15c > 0) { + unk_28_2 = (UnkStruct_020397f8 *) this->mUnk_28[2]; + + if (unk_28_2 != NULL && unk_28_2->mUnk_15c > 0) { + this->mUnk_40[0] = this->func_020366c4(); + } else { + this->mUnk_40[0] = unk_28_2; + } + } else { + unk_28_2 = (UnkStruct_020397f8 *) this->mUnk_28[2]; + + if (unk_28_2 != NULL && unk_28_2->mUnk_15c > 0) { + this->mUnk_40[0] = unk_28_0; + } else { + this->mUnk_40[0] = NULL; + } + } + + iVar1 = this->func_02036824(); + iVar2 = this->func_02036850(); + + if (this->mUnk_20[1] != NULL && ((this->mUnk_20[1]->mUnk_18 & ~0xFFFF) != (0x100 << 0x10))) { + this->mUnk_20[1]->vfunc_10(); + this->mUnk_20[1] = NULL; + } + + if (iVar1) { + this->func_02036888(this->mUnk_18[0]); + } else if (iVar2) { + this->func_02036888(this->mUnk_18[1]); + } + + for (i = 0; i < ARRAY_LEN(this->mUnk_28); i++) { + if (this->mUnk_28[i] != NULL) { + this->mUnk_28[i]->vfunc_2C(); + } + } + + this->mUnk_04 = 0; + + if (this->mUnk_20[0] != NULL) { + if ((this->mUnk_20[0]->mUnk_18 & ~0xFFFF) == (0x100 << 0x10)) { + this->mUnk_20[0] = NULL; + } else { + this->mUnk_04 = 1; + } + } + + if ((this->mUnk_18[0] != NULL) && ((this->mUnk_18[0]->mUnk_18 & ~0xFFFF) != (0x100 << 0x10))) { + this->mUnk_04 = 1; + + //! TODO: fake? + pSVar4 = this->func_02037178((UnkSubClass1_02256FF8 *) this->mUnk_18[0]); + + if (data_027e0c54 != 0 && pSVar4 != NULL && pSVar4->mUnk_50 != ((data_02056be4[data_027e077c.mUnk_0] & 1) != 0)) { + this->mUnk_04 = 0; + } + } + + if (this->mUnk_08 != NULL && this->mUnk_08->mUnk_15c > 0) { + this->mUnk_04 = 1; + } else { + this->mUnk_08 = NULL; + } + + this->func_02036bbc(); + + if (this->mUnk_10 != 0) { + ActorManager::FindActorByType(&actorRef, gActorManager, data_0205691c[this->mUnk_10]); + pActor = gActorManager->GetActor(&actorRef); + + if (pActor != NULL) { + data_027e0ffc->func_ov000_020cec60(data_02056918[this->mUnk_10], &pActor->mPos, pActor, 0); + } + } +} + +ARM void MessageManager::func_02036bbc(void) { + UnkStruct_02038aa0 *pSVar3; + bool bVar2; + bool bVar4; + s32 i; + + if (data_027e0d04.mUnk_00 > 0) { + return; + } + + bVar2 = this->func_02036824(); + bVar4 = this->func_02036850(); + + for (i = 0; i < ARRAY_LEN(this->mUnk_28); i++) { + pSVar3 = this->mUnk_28[i]; + + if (pSVar3 != NULL && ((bVar2 && pSVar3->mUnk_50 == 0) || (bVar4 && pSVar3->mUnk_50 != 0))) { + pSVar3->vfunc_44(gTouchControl.mTouchLastX, gTouchControl.mTouchLastY); + } + } +} + +ARM void MessageManager::func_02036c50(unk32 param_2) { + s32 i; + + for (i = 0; i < ARRAY_LEN(this->mUnk_28); i++) { + if (this->mUnk_28[i] != NULL && this->mUnk_28[i]->func_0203de14(param_2) != 0) { + this->mUnk_28[i]->vfunc_28(); + } + } +} + +ARM void MessageManager::func_02036ca4(unk32 param_2) { + s32 i; + + for (i = 0; i < ARRAY_LEN(this->mUnk_28); i++) { + UnkStruct_02038aa0 *pSVar1 = this->mUnk_28[i]; + + if (pSVar1 != NULL) { + pSVar1->vfunc_3C(param_2); + } + } +} + +ARM bool MessageManager::func_02036ce4(UnkStruct_020386d8 *param_2, unk32 param_3) { + u32 uVar1; + + if (param_3 == 0) { + return false; + } + + uVar1 = this->pGroups->func_020373ec(param_3); + + if (uVar1 != -1) { + param_2->vfunc_08(uVar1); + return true; + } + + return false; +} + +ARM bool MessageManager::func_02036d30(UnkStruct_02037750 *param_2) { + if (this->mUnk_20[0] != NULL && this->mUnk_20[0] != param_2) { + return false; + } + + this->mUnk_20[0] = param_2; + return true; +} + +ARM bool MessageManager::func_02036d4c(UnkStruct_02037750 *param_2) { + if (this->mUnk_20[0] == param_2) { + this->mUnk_20[0] = NULL; + return true; + } + + return false; +} + +ARM void MessageManager::func_02036d6c(void) { + s32 i; + + for (i = 0; i < ARRAY_LEN(this->mUnk_28); i++) { + if (func_0202ab48() == 0 || i != 5) { + this->mUnk_28[i]->UnkStruct_02038aa0::vfunc_10(); + } + } +} + +// non-matching +ARM UnkStruct_02038aa0 *MessageManager::func_02036da8(u32 param_2, s16 *param_3) { + EntryINF1 *pEVar1; + EntryINF1 *pEVar2; + UnkStruct_02038aa0 *pSVar4; + BMGGroups *pBVar5; + bool bVar6; + s16 iStack_38; + int iStack_34; + int iStack_30; + + pEVar1 = this->pGroups->entries[param_2 >> 0x10].func_02037258(param_2 & 0xFFFF); + + if (pEVar1 == NULL) { + return NULL; + } + + if ((data_02056be4[data_027e077c.mUnk_0] & 1) == 0) { + pSVar4 = this->mUnk_28[4]; + func_02037628((u8 *) &iStack_38); + + // ??? + bVar6 = (data_02056be4[data_027e077c.mUnk_0] & 1) == 0; + if (bVar6) { + data_02056be4[0] = 1; + } + if (!bVar6) { + data_02056be4[0] = 0; + } + + iStack_38 = *param_3; + // iStack_34 = param_3[1]; + // iStack_30 = param_3[2]; + pBVar5 = this->pGroups; + // pSVar4->vfunc_50(pEVar1, BMG_GET_MSG_ADDR(pBVar5, param_2), (s16*)&iStack_38, 1); + BMGFileInfo *entry = &(pBVar5)->entries[(param_2) >> 0x10]; + // pSVar4->vfunc_50(pEVar1, + // ((u32)entry->pDAT1 + (((entry.func_02037258((((param_2))) & 0xFFFF))->offset) & ~1)), + // // BMG_GET_MSG_ADDR(pBVar5, param_2), + // (s16*)&iStack_38, 1); + + data_ov000_020eec9c.func_ov000_020d77e4(0x1C); + return pSVar4; + } + + return NULL; +} + +// non-matching +ARM void MessageManager::func_02036edc(u32 param_2, u8 param_3) { + UnkStruct_020397f8 *pSVar1; + u8 auStack_28[24]; + u8 local_13; + + func_02037628(auStack_28); + local_13 = 0; + + if ((data_02056be4[data_027e077c.mUnk_0] & 1) != 0 && (data_02056be4[data_027e077c.mUnk_0] & 2) == 0) { + local_13 = 1; + } + + auStack_28[21] = local_13; + auStack_28[20] = param_3; + pSVar1 = this->func_02036f68(param_2, auStack_28); + + if (pSVar1 != NULL) { + if (this->mUnk_04 == 0) { + this->mUnk_08 = pSVar1; + } + } +} + +// non-matching +ARM UnkStruct_020397f8 *MessageManager::func_02036f68(u32 param_2, u8 *param_3) { + EntryINF1 *pEVar1; + UnkStruct_02038aa0 *pSVar2; + EntryINF1 *pEVar3; + int iVar4; + UnkStruct_020397f8 *pSVar5; + + pEVar1 = this->pGroups->entries[param_2 >> 0x10].func_02037258(param_2 & 0xffff); + + if (pEVar1 == NULL) { + return NULL; + } + + if (param_3[21] != 0) { + pSVar5 = (UnkStruct_020397f8 *) this->mUnk_28[2]; + pSVar2 = this->mUnk_28[3]; + } else { + pSVar5 = (UnkStruct_020397f8 *) this->mUnk_28[0]; + pSVar2 = this->mUnk_28[1]; + } + + //! TODO: fake? + pSVar5->mUnk_164 = (UnkStruct_020397f8 *) pSVar2; + pSVar5->mUnk_418 = this->mUnk_28[5]; + + pSVar5->vfunc_50(pEVar1, BMG_GET_MSG_ADDR(this->pGroups, param_2), (s32 *) param_3, 0); + + if (data_ov000_020eec9c.func_ov000_020d7f18(0x19) == 0 && data_ov000_020eec9c.func_ov000_020d7f18(0x18) == 0 && + data_ov000_020eec9c.func_ov000_020d7f18(0x34) == 0 && data_ov000_020eec9c.func_ov000_020d7f18(0x35) == 0 && + data_ov000_020eec9c.func_ov000_020d7f18(0x1A) == 0 && data_ov000_020eec9c.func_ov000_020d7f18(0x1B) == 0 && + (param_3[12]) != 7) + { + data_ov000_020eec9c.func_ov000_020d77e4(0x1C); + } + + return pSVar5; +} + +ARM UnkStruct_020386d8 *MessageManager::func_020370d0(unk32 param_2, unk32 param_3) { + return this->func_020370e8(param_2, -1, -1, param_3); +} + +ARM UnkStruct_020386d8 *MessageManager::func_020370e8(unk32 param_2, unk16 param_3, unk16 param_4, unk32 param_5) { + UnkStruct_020386d8 *puVar2; + + if (this->func_02036824()) { + puVar2 = this->mUnk_18[0]; + } else { + if (this->func_02036850()) { + puVar2 = this->mUnk_18[1]; + } else { + return NULL; + } + } + + puVar2->mUnk_30 = param_5; + puVar2->mUnk_34 = param_3; + puVar2->mUnk_36 = param_4; + + if (this->func_02036ce4(puVar2, param_2)) { + return puVar2; + } + + return NULL; +} + +ARM void MessageManager::func_02037158(UnkSubClass1_02256FF8 *param_2) { + UnkStruct_02038aa0 *pSVar1; + + pSVar1 = this->func_02037178(param_2); + + if (pSVar1 != NULL) { + pSVar1->vfunc_58(); + } +} + +ARM UnkStruct_02038aa0 *MessageManager::func_02037178(UnkSubClass1_02256FF8 *param_2) { + s32 i; + + for (i = 0; i < ARRAY_LEN(this->mUnk_28); i++) { + if (this->mUnk_28[i] != NULL && this->mUnk_28[i]->mUnk_08 == param_2) { + return this->mUnk_28[i]; + } + } + + return NULL; +} + +ARM MessageManager::~MessageManager() {} diff --git a/src/Main/Message/func_0203c358.cpp b/src/Main/Message/func_0203c358.cpp new file mode 100644 index 00000000..ee80f15e --- /dev/null +++ b/src/Main/Message/func_0203c358.cpp @@ -0,0 +1,76 @@ +#include "DTCM/UnkStruct_027e103c.hpp" +#include "Item/ItemManager.hpp" +#include "Message/MessageManager.hpp" +#include "Message/MsgProc.hpp" +#include "Player/TouchControl.hpp" +#include "Save/AdventureFlags.hpp" +#include "System/SysNew.hpp" +#include "global.h" + +extern "C" void func_0203fc78(unk32 *, unk32 *); + +THUMB MsgProc_Type2::MsgProc_Type2(unk32 param_2, unk16 param_3, unk32 param_4) : + UnkStruct_02038aa0(0, 0) { + this->mUnk_162 = 4; + this->mUnk_164 = 1; + this->mUnk_166 = 0; + this->mUnk_168 = -1; + this->mUnk_16a = 0; + this->mUnk_16c = 1; + this->mUnk_16e = 0; +} + +// non-matching +THUMB void MsgProc_Type2::func_0203c39c(unk32 param_2, unk32 param_3) { + u16 uVar1; + unk32 uVar2; + s16 uVar3; + s32 iVar4; + s32 local_20; + s32 local_1c[2]; + + this->func_02038b28(); + uVar3 = 0; + + for (iVar4 = 0; iVar4 < 2; iVar4++) { + local_1c[0] = 0xC0; + local_20 = 0x10; + + if (iVar4 != 0) { + func_0203fc78(local_1c, &local_20); + } + + uVar1 = this->func_0203d318((s32) (local_1c[0] + 7 + ((u32) (local_1c[0] + 7 >> 2) >> 0x1D)) >> 3, + (s32) (local_20 + 7 + ((u32) (local_20 + 7 >> 2) >> 0x1D)) >> 3); + + if (uVar3 < uVar1) { + uVar3 = uVar1; + } + } + + if (this->mUnk_114->vfunc_08(this) != 0) { + this->mUnk_10 = this->mUnk_114->func_0203d1b4(); + } +} + +ARM void MsgProc_Type2::vfunc_3C(unk32 param_2) { + if (this->mUnk_15c > 0 && this->mUnk_122 != 1) { + if (this->func_0203de14(param_2) != 0) { + this->vfunc_40(0, 0); + } + } +} + +ARM void MsgProc_Type2::vfunc_40(unk32 param_2, unk32 param_3) { + param_2 += this->mUnk_166; + param_3 += this->mUnk_168; + + this->func_0203c4ac(param_2 + this->mUnk_16a, param_3 + this->mUnk_16c); + this->UnkStruct_02038aa0::vfunc_30(param_2, param_3); +} + +ARM bool MsgProc_Type2::vfunc_14(unk32 param_2, unk32 param_3) { + return this->UnkStruct_0203dae0::vfunc_14(param_2 + this->mUnk_162, param_3); +} + +ARM MsgProc_Type2::~MsgProc_Type2() {} diff --git a/src/Main/Message/func_0203c72c.cpp b/src/Main/Message/func_0203c72c.cpp new file mode 100644 index 00000000..b61c35be --- /dev/null +++ b/src/Main/Message/func_0203c72c.cpp @@ -0,0 +1,36 @@ +#include "DTCM/UnkStruct_027e103c.hpp" +#include "Item/ItemManager.hpp" +#include "Message/MessageManager.hpp" +#include "Message/MsgProc.hpp" +#include "Player/TouchControl.hpp" +#include "Save/AdventureFlags.hpp" +#include "System/SysNew.hpp" +#include "global.h" + +extern "C" void func_0204f614(UnkClass_func_ov000_020d0644 *, unk32, unk32, void *, void *); + +// non-matching +ARM MsgProc_Type3::MsgProc_Type3(unk32 param_2, unk16 param_3, unk32 param_4) : + UnkStruct_02038aa0(1, 0) { + this->mUnk_162 = 1; + this->mUnk_164 = 0x1A; + this->mUnk_166 = 0xA6; + this->mUnk_168 = 0x1D; + this->mUnk_16a = 0; + this->mUnk_16c = 1; + this->mUnk_170 = -1; + this->mUnk_172 = -1; + this->mUnk_174 = -1; + + func_0204f614(this->mUnk_180, ARRAY_LEN(this->mUnk_180), sizeof(UnkClass_func_ov000_020d0644), + UnkClass_func_ov000_020d0644::func_020d060c, this->func_0203c83c); + + this->mUnk_180[0].func_ov000_020d0644(0x1E, 0, 0x8A, 0, 0); + this->mUnk_180[1].func_ov000_020d0644(0x1E, 1, 0x8B, 0, 0); + this->mUnk_180[2].func_ov000_020d0644(0x1E, 2, 0x8C, 0, 0); + this->mUnk_180[3].func_ov000_020d0644(0x1E, 3, 0x8D, 0, 0); +} + +ARM void MsgProc_Type3::func_0203c83c(void) {} + +ARM MsgProc_Type3::~MsgProc_Type3() {} diff --git a/src/Main/Unknown/UnkStruct_02032f0c.cpp b/src/Main/Unknown/UnkStruct_02032f0c.cpp index 6a03a93a..16e22b29 100644 --- a/src/Main/Unknown/UnkStruct_02032f0c.cpp +++ b/src/Main/Unknown/UnkStruct_02032f0c.cpp @@ -1,34 +1,109 @@ #include "Unknown/UnkStruct_02032f0c.hpp" +#include "Unknown/UnkStruct_02035064.hpp" -UnkStruct_02032e7c::UnkStruct_02032e7c() {} -UnkStruct_02032f0c::UnkStruct_02032f0c() {} -UnkStruct_02032f0c::~UnkStruct_02032f0c() {} -void UnkStruct_02032f0c::func_02032f94() {} -u16 **UnkStruct_02032f0c::SetUnk_0c(u16 *value) {} -u8 UnkStruct_02032f0c::func_02032fa4() {} -s32 UnkStruct_02032f0c::func_02032fb4() {} -bool UnkStruct_02032f0c::vfunc_14(s32 param1, s32 param2) {} -void UnkStruct_02032f0c::vfunc_08(s32 param1, unk32 param2, s16 *param3, unk32 param4) {} -void UnkStruct_02032f0c::vfunc_0c(unk32 param1, unk32 param2, unk32 param3, unk32 param4) {} -void UnkStruct_02032f0c::vfunc_10(u32 param1, unk32 param2) {} -void UnkStruct_02032f0c::func_02033214(unk32 param1, unk32 param2, unk32 param3, u8 param4, unk32 param5) {} -unk32 UnkStruct_02032f0c::vfunc_18(s32 param1) {} -unk32 UnkStruct_02032f0c::vfunc_1c(s32 param1, unk32 *param2, unk32 param3, unk32 param4) {} -unk32 UnkStruct_02032f0c::vfunc_20(s32 param1, s32 *param2) {} -void UnkStruct_02032f0c::func_020334b4(u32 param1, s32 param2, s32 param3, s32 param4) {} -void UnkStruct_02032f0c::func_02033628(unk32 param1, u16 *param2) {} -u32 UnkStruct_02032f0c::func_0203369c(u16 *param1, s32 param2) {} -void UnkStruct_02032f0c::func_02033780(s32 param1) {} -s32 UnkStruct_02032f0c::func_020337d8(s32 param1) {} -s32 UnkStruct_02032f0c::func_020337fc(s16 *param1, s32 param2) {} -void UnkStruct_02032f0c::func_020338a8(s32 param1, unk32 param2) {} -void UnkStruct_02032f0c::func_020338d0(unk32 *param1, unk32 param2) {} -s32 UnkStruct_02032f0c::func_02033904(unk32 param1, unk32 param2) {} -s32 UnkStruct_02032f0c::func_02033938(unk32 param1) {} -s32 UnkStruct_02032f0c::func_0203396c(u16 *param1) {} -bool UnkStruct_02032f0c::vfunc_24(s16 **param1) {} -u16 *UnkStruct_02032f0c::func_02033b0c(s32 param1) {} -bool UnkStruct_02032f0c::func_02033c6c() {} -unk32 UnkStruct_02032f0c::func_02033c88(u32 param1) {} -s32 UnkStruct_02032f0c::func_02033cbc(s16 *param1) {} -UnkStruct_02032e7c::~UnkStruct_02032e7c() {} +extern "C" void Fill32(unk32, void *, unk32); +extern "C" void Fill16(unk32, void *, unk32); +extern "C" void func_020296e0(unk32 **, UnkStruct_MsgProc_Base_unk_2C **, unk32, unk32, unk32, unk32); +extern THUMB unk32 func_0202ab48(void); + +ARM UnkStruct_02032e7c::UnkStruct_02032e7c() { + this->mUnk_04 = NULL; + this->mUnk_08 = 0; + this->mUnk_0a = 0; + this->mUnk_0c = 0; + this->mUnk_0e = 0; + + if (func_0202ab48() == 0) { + this->mUnk_10 = 2; + } else { + this->mUnk_10 = 3; + } +} + +THUMB UnkStruct_02032f0c::UnkStruct_02032f0c() { + this->mUnk_04 = 0; + this->mUnk_08 = 0; + this->mUnk_0c = NULL; + this->mUnk_38 = 0; + this->mUnk_3c = 0; + this->mUnk_4a = 0; + this->mUnk_4c = 0; + this->mUnk_4d = 0; + this->mUnk_4e = 0; + this->mUnk_4f = 0; + this->mUnk_50 = 0; + this->mUnk_51 = 0; + Fill32(0, &this->mUnk_10, 0x18); + Fill32(0, &this->mUnk_28, 0x10); + Fill16(0, &this->mUnk_3e, 0xC); + this->mUnk_10 = NULL; + this->mUnk_2c = NULL; + this->mUnk_30 = 2; + this->mUnk_34 = 3; +} + +THUMB UnkStruct_02032f0c::~UnkStruct_02032f0c() {} + +ARM void UnkStruct_02032f0c::func_02032f94() {} + +ARM u16 **UnkStruct_02032f0c::SetUnk_0c(u16 *value) { + this->mUnk_0c = value; + return &this->mUnk_0c; +} + +ARM u8 UnkStruct_02032f0c::func_02032fa4() { + return UnkStruct_02035064::func_02035428(this->mUnk_50); +} + +ARM s32 UnkStruct_02032f0c::func_02032fb4() { + return this->mUnk_2c[0]->mUnk_01 + this->mUnk_34; +} + +// non-matching +ARM bool UnkStruct_02032f0c::vfunc_14(s32 param1, s32 param2) { + s16 iVar1; + s16 iVar2; + + iVar1 = ((param1 + 0x7 + ((param1 + 0x7) >> 0x1D))) * 0x8; + iVar2 = ((param2 + 0x7 + ((param2 + 0x7) >> 0x1D))) * 0x8; + this->mUnk_4a = param1; + this->mUnk_4c = param2; + this->mUnk_14 = (iVar1 + (iVar1 >> 0x1D)) * 0x2000 >> 0x10; + this->mUnk_18 = (iVar2 + (iVar2 >> 0x1D)) * 0x2000 >> 0x10; + + return true; +} + +ARM void UnkStruct_02032f0c::vfunc_08(s32 param1, unk32 param2, s16 *param3, unk32 param4) {} + +ARM void UnkStruct_02032f0c::vfunc_0c(unk32 param1, unk32 param2, unk32 param3, unk32 param4) { + func_020296e0(&this->mUnk_10, this->mUnk_2c, param1, param2, param4, param3); +} + +ARM void UnkStruct_02032f0c::vfunc_10(u32 param1, unk32 param2) {} +ARM void UnkStruct_02032f0c::func_02033214(unk32 param1, unk32 param2, unk32 param3, u8 param4, unk32 param5) {} +ARM unk32 UnkStruct_02032f0c::vfunc_18(s32 param1) {} +ARM unk32 UnkStruct_02032f0c::vfunc_1c(s32 param1, unk32 *param2, unk32 param3, unk32 param4) {} +ARM unk32 UnkStruct_02032f0c::vfunc_20(s32 param1, s32 *param2) {} +ARM void UnkStruct_02032f0c::func_020334b4(u32 param1, s32 param2, s32 param3, s32 param4) {} +ARM void UnkStruct_02032f0c::func_02033628(unk32 param1, u16 *param2) {} +ARM u32 UnkStruct_02032f0c::func_0203369c(u16 *param1, s32 param2) {} +ARM void UnkStruct_02032f0c::func_02033780(s32 param1) {} + +ARM s32 UnkStruct_02032f0c::func_020337d8(s32 param1) { + return this->mUnk_2c[0]->mUnk_08[1] * param1 + (param1 - 1) * this->mUnk_34; +} + +ARM s32 UnkStruct_02032f0c::func_020337fc(s16 *param1, s32 param2) {} +ARM void UnkStruct_02032f0c::func_020338a8(s32 param1, unk32 param2) {} +ARM void UnkStruct_02032f0c::func_020338d0(unk32 *param1, unk32 param2) {} +ARM s32 UnkStruct_02032f0c::func_02033904(unk32 param1, unk32 param2) {} +ARM s32 UnkStruct_02032f0c::func_02033938(unk32 param1) {} +ARM s32 UnkStruct_02032f0c::func_0203396c(u16 *param1) {} +ARM bool UnkStruct_02032f0c::vfunc_24(s16 **param1) {} +ARM u16 *UnkStruct_02032f0c::func_02033b0c(s32 param1) {} +ARM bool UnkStruct_02032f0c::func_02033c6c() {} +ARM unk32 UnkStruct_02032f0c::func_02033c88(u32 param1) {} +ARM s32 UnkStruct_02032f0c::func_02033cbc(s16 *param1) {} + +ARM UnkStruct_02032e7c::~UnkStruct_02032e7c() {} diff --git a/src/Main/Unknown/UnkStruct_02035064.cpp b/src/Main/Unknown/UnkStruct_02035064.cpp index 4c3562ab..7a9646f4 100644 --- a/src/Main/Unknown/UnkStruct_02035064.cpp +++ b/src/Main/Unknown/UnkStruct_02035064.cpp @@ -1,11 +1,40 @@ #include "Unknown/UnkStruct_02035064.hpp" -UnkStruct_02035064::UnkStruct_02035064() {} -UnkStruct_02035064::~UnkStruct_02035064() {} -void UnkStruct_02035064::func_020350b0() {} -void UnkStruct_02035064::func_020350b4(s32 param1, unk32 param2, unk8 param3, unk16 param4, unk16 param5) {} -void UnkStruct_02035064::func_0203516c() {} -s32 UnkStruct_02035064::vfunc_0() {} -s32 UnkStruct_02035064::vfunc_4() {} -void UnkStruct_02035064::func_020351b8(bool param1, bool param2, bool param3, bool param4) {} -void UnkStruct_02035064::func_020352d8() {} +ARM UnkStruct_02035064::UnkStruct_02035064() { + this->mUnk_74 = NULL; + this->mUnk_78 = NULL; + this->mUnk_7c = 0; + this->mUnk_80 = 0; + this->mUnk_82 = 0; + this->mUnk_84 = 0; + this->mUnk_86 = 0; + this->mUnk_87 = 0; +} + +ARM UnkStruct_02035064::~UnkStruct_02035064() {} + +ARM void UnkStruct_02035064::func_020350b0() {} + +ARM void UnkStruct_02035064::func_020350b4(s32 param1, unk32 param2, unk8 param3, unk16 param4, unk16 param5) {} + +ARM void UnkStruct_02035064::func_0203516c() { + if (this->mUnk_78 != 0x0) { + if (this->mUnk_86 == false) { + this->mUnk_5c.func_0202e1e8(); + this->func_020352d8(); + } else { + this->mUnk_86 = false; + } + } +} + +ARM s32 UnkStruct_02035064::vfunc_00() { + return this->mUnk_4c; +} + +ARM s32 UnkStruct_02035064::vfunc_04() { + return this->mUnk_4e; +} + +ARM void UnkStruct_02035064::func_020351b8(bool param1, bool param2, bool param3, bool param4) {} +ARM void UnkStruct_02035064::func_020352d8() {} diff --git a/src/Main/Unknown/UnkStruct_02037750.cpp b/src/Main/Unknown/UnkStruct_02037750.cpp index cefbb0cc..0fa56bfb 100644 --- a/src/Main/Unknown/UnkStruct_02037750.cpp +++ b/src/Main/Unknown/UnkStruct_02037750.cpp @@ -1,25 +1,224 @@ #include "Unknown/UnkStruct_02037750.hpp" +#include "Actor/ActorManager.hpp" +#include "Item/ItemManager.hpp" +#include "Message/MessageManager.hpp" +#include "Save/AdventureFlags.hpp" +#include "System/Random.hpp" -UnkStruct_02037750::UnkStruct_02037750(unk32 param1, unk32 param2) {} -UnkStruct_02037750::~UnkStruct_02037750() {} -void UnkStruct_02037750::vfunc_08(unk32 param1) {} -void UnkStruct_02037750::vfunc_0c(s32 param1) {} -void UnkStruct_02037750::vfunc_10() {} -void UnkStruct_02037750::vfunc_24(unk32 param1) {} -void UnkStruct_02037750::vfunc_28(s32 param1) {} -unk32 UnkStruct_02037750::vfunc_2c(s32 param1) {} -LinkStateInteract *UnkStruct_02037750::GetLinkStateInteract() {} -unk32 UnkStruct_02037750::vfunc_30() {} -void UnkStruct_02037750::func_020385d0(s32 param1, unk32 *param2) {} -void UnkStruct_02037750::vfunc_14() {} -void UnkStruct_02037750::vfunc_18() {} -unk32 UnkStruct_02037750::vfunc_1c() {} -void UnkStruct_02037750::vfunc_20() {} - -UnkStruct_020386d8::UnkStruct_020386d8() : - UnkStruct_02037750(0x1000000, 0) {} -void UnkStruct_020386d8::vfunc_08(unk32 param1) {} -void UnkStruct_020386d8::vfunc_24(unk32 param1) {} -void UnkStruct_020386d8::vfunc_28() {} -unk32 UnkStruct_020386d8::vfunc_30() {} -UnkStruct_020386d8::~UnkStruct_020386d8() {} +extern "C" ARM unk32 func_02037628(u8 *); +extern u8 *data_027e0d54; +extern unk32 *data_027e0cb4; + +ARM UnkStruct_02037750::UnkStruct_02037750(unk32 param1, unk32 param2) { + s32 i; + + this->mUnk_14 = param2; + this->mUnk_18 = param1; + this->mUnk_1c = 0; + this->mUnk_1d = 0xFF; + this->mUnk_1e = 0; + + for (i = 0; i < ARRAY_LEN(this->mUnk_04); i++) { + this->mUnk_04[i] = 0; + } +} + +ARM UnkStruct_02037750::~UnkStruct_02037750() { + if (gMessageManager.mUnk_20[0] == this) { + gMessageManager.func_02036d4c(this); + } +} + +ARM void UnkStruct_02037750::vfunc_08(u32 param1) { + this->mUnk_18 = param1; + this->mUnk_1c = 0; +} + +ARM void UnkStruct_02037750::vfunc_0c(UnkStruct_020397f8 *param1) {} +ARM void UnkStruct_02037750::vfunc_10() {} + +ARM bool UnkStruct_02037750::vfunc_24(unk32 param1) { + u8 auStack_28[0x18]; + + func_02037628(auStack_28); + return this->func_020385d0(param1, auStack_28) != 0; +} + +// non-matching +ARM unk32 UnkStruct_02037750::vfunc_28(s32 param1) { + u16 uVar1; + s64 lVar2; + char cVar4; + u16 uVar5; + int iVar6; + u32 uVar7; + UnkStruct_02037750_Callback1 pcVar8; + int iVar9; + u32 uVar10; + u32 uVar11; + bool bVar12; + + uVar7 = (u32) * (u16 *) (param1 + 0x2); + + if (uVar7 >= 0xF && uVar7 <= 0x2E) { + pcVar8 = this->mUnk_04[((uVar7 - 0xF) << 0x1E) >> 0x1C]; + iVar9 = 0; + + if (pcVar8 != NULL) { + iVar9 = pcVar8(this->mUnk_14); + } + + return iVar9; + } + + if ((s32) uVar7 <= 0) { + switch (uVar7) { + case 0x0: + case 0x2f: break; + case 0x7: + if (data_027e0d54[0xd] != 0) { + return -0x1; + } + + return (data_027e0d54[0xf] != 0); + case 0x1: + case 0x2: + case 0x3: + UnkStruct_020397f8 *ret_3 = gMessageManager.func_020366c4(); + + if (0x0 < ret_3->mUnk_15c) { + return -0x1; + } + + uVar7 = (param1 + 0x1); + + if (ret_3->mUnk_576 < uVar7) { + return ret_3->mUnk_576; + } + + if (uVar7 == 0x0) { + uVar10 = 0x0; + } else { + lVar2 = gRandom.mRandomValue * gRandom.mFactor; + uVar10 = gRandom.Next(lVar2); + // uVar10 = *(int *)((int)&gRandom.mAddend + 0x4) + + // *(int *)((int)&gRandom.mFactor + 0x4) * + // *(uint *)&gRandom.mRandomValue + *(uint *)&gRandom.mFactor * + // *(int *)((int)&gRandom.mRandomValue + 0x4) + + // (lVar2 >> 0x20) + (gRandom.mAddend << uVar11); // CARRY4 + + // part of the inline? + // *(uint *)&gRandom.mRandomValue = *(uint *)&gRandom.mAddend + uVar11; + // *(uint *)((int)&gRandom.mRandomValue + 0x4) = uVar10; + + if (uVar7 != 0x0) { + uVar10 = (uVar7 * uVar10 >> 0x20); + } + } + + return uVar10; + case 0x4: return gAdventureFlags->Get(param1 + 0x4) != false; + case 0x5: return gActorManager->func_ov00_020c3b2c(NULL) != 0; + case 0x6: break; + case 0x8: return (((data_027e0cb4[(param1 + 0x4) >> 5]) & 1) << ((param1 + 0x4) & 0x1f)) == 0x0; + case 0x9: break; + case 0xa: break; + case 0xb: + lVar2 = gRandom.mRandomValue * gRandom.mFactor; + uVar7 = lVar2; + uVar10 = gRandom.Next(uVar7); + + return (int) (uVar10 * 0x64 >> 0x20) < (param1 + 0x4); + case 0xc: + uVar7 = (param1 + 0x1); + if (uVar7 == 0x0) { + uVar10 = 0x0; + } else { + lVar2 = gRandom.mRandomValue * gRandom.mFactor; + uVar11 = lVar2; + uVar10 = gRandom.Next(uVar11); + + if (uVar7 != 0x0) { + uVar10 = (uVar7 * uVar10 >> 0x20); + } + } + return (int) (char) uVar10; + case 0xd: return gItemManager->GetNumRupees() != 0; + case 0xe: return gItemManager->HasItem(param1 + 0x4) != 0; + default: + if (uVar7 == 0x2f) { + return gItemManager->HasItem((param1 + 0x4) + 0x60) != 0; + } + break; + } + } + + uVar7 = (param1 + 0x1); + if (uVar7 == 0x0) { + uVar10 = 0x0; + } else { + lVar2 = gRandom.mRandomValue * gRandom.mFactor; + uVar11 = lVar2; + uVar10 = gRandom.Next(uVar11); + + if (uVar7 != 0x0) { + uVar10 = (uVar7 * uVar10 >> 0x20); + } + } + + return (int) (char) uVar10; +} + +ARM unk32 UnkStruct_02037750::vfunc_2c(s32 param1) {} + +ARM LinkStateInteract *UnkStruct_02037750::GetLinkStateInteract() { + return (LinkStateInteract *) GetLinkState(2); +} + +ARM bool UnkStruct_02037750::vfunc_30() { + return true; +} + +ARM unk32 UnkStruct_02037750::func_020385d0(s32 param1, u8 *param2) {} + +ARM void UnkStruct_02037750::vfunc_14() {} + +// non-matching +ARM void UnkStruct_02037750::vfunc_18(unk32 *param1) { + param1[0] = 0; +} + +ARM bool UnkStruct_02037750::vfunc_1c() { + return false; +} + +ARM void UnkStruct_02037750::vfunc_20() { + this->mUnk_18 = 1 << 24; +} + +// non-matching +ARM UnkStruct_020386d8::UnkStruct_020386d8() : + UnkStruct_02037750(1 << 24, 0) { + this->mUnk_20 = -1; + this->mUnk_24.func_020376c0(&gVec3p_ZERO); +} + +ARM void UnkStruct_020386d8::vfunc_08(u32 param1) { + this->UnkStruct_02037750::vfunc_08(param1); + this->mUnk_20 = 0xff; +} + +ARM bool UnkStruct_020386d8::vfunc_24(unk32 param1) { + return this->func_020385d0(param1, &this->mUnk_24.mUnk_00) != 0; +} + +ARM unk32 UnkStruct_020386d8::vfunc_28(s32 param1) { + this->mUnk_20 = this->UnkStruct_02037750::vfunc_28(param1); + return this->mUnk_20; +} + +ARM bool UnkStruct_020386d8::vfunc_30() { + return gMessageManager.func_020366c4()->mUnk_15c <= 0; +} + +ARM UnkStruct_020386d8::~UnkStruct_020386d8() {} diff --git a/src/Main/Unknown/UnkStruct_02038aa0.cpp b/src/Main/Unknown/UnkStruct_02038aa0.cpp index 19380f4f..038d25b6 100644 --- a/src/Main/Unknown/UnkStruct_02038aa0.cpp +++ b/src/Main/Unknown/UnkStruct_02038aa0.cpp @@ -1,42 +1,234 @@ #include "Unknown/UnkStruct_02038aa0.hpp" +#include "DTCM/UnkStruct_027e103c.hpp" +#include "Message/MessageManager.hpp" -UnkStruct_0203881c::UnkStruct_0203881c() {} -void UnkStruct_0203881c::func_02038858(unk32 param1) {} -void UnkStruct_0203881c::func_02038888() {} -void UnkStruct_0203881c::func_02038950(UnkStruct_02038aa0 *param1, s32 param2) {} -void UnkStruct_0203881c::func_02038a80(s32 param1) {} -UnkStruct_0203881c::~UnkStruct_0203881c() {} - -UnkStruct_02038aa0::UnkStruct_02038aa0(u8 param1, u8 param2) : - UnkStruct_0203dae0(param1) {} -UnkStruct_02038aa0::~UnkStruct_02038aa0() {} -void UnkStruct_02038aa0::vfunc_4c() {} -void UnkStruct_02038aa0::vfunc_10(unk32 param1) {} -void UnkStruct_02038aa0::func_02038b40() {} -void UnkStruct_02038aa0::vfunc_48() {} -bool UnkStruct_02038aa0::func_02038b78() {} -unk32 UnkStruct_02038aa0::vfunc_34(s32 param1) {} -s32 UnkStruct_02038aa0::func_02038cb8(s32 param1) {} -s32 UnkStruct_02038aa0::func_02038cf4() {} -s32 UnkStruct_02038aa0::func_02038d10() {} -void UnkStruct_02038aa0::vfunc_2c() {} -void UnkStruct_02038aa0::vfunc_30() {} -bool UnkStruct_02038aa0::func_02038ef4(s32 param1, s32 param2) {} -void UnkStruct_02038aa0::vfunc_44() {} -void UnkStruct_02038aa0::vfunc_50(unk32 param1, unk32 param2, s32 param3, unk32 param4) {} -void UnkStruct_02038aa0::vfunc_5c() {} -unk32 UnkStruct_02038aa0::vfunc_1c(s32 param1, unk32 *param2, unk32 param3, unk32 param4) {} -unk32 UnkStruct_02038aa0::vfunc_20(s32 param1, s32 *param2) {} -void UnkStruct_02038aa0::func_02039208(unk16 param1) {} -void UnkStruct_02038aa0::vfunc_08(s32 param1, unk32 param2, s16 *param3, unk32 param4) {} -unk32 UnkStruct_02038aa0::func_02039250() {} -void UnkStruct_02038aa0::vfunc_54() {} -void UnkStruct_02038aa0::vfunc_58() {} -void UnkStruct_02038aa0::vfunc_60() {} -void UnkStruct_02038aa0::vfunc_64() {} -s32 UnkStruct_02038aa0::vfunc_68(unk32 param1) {} -void UnkStruct_02038aa0::func_02039440(unk32 param1, unk32 param2) {} -void UnkStruct_02038aa0::vfunc_6c(s32 *param1, s32 *param2) {} -void UnkStruct_02038aa0::vfunc_70(s32 *param1, s32 *param2) {} -bool UnkStruct_02038aa0::func_0203951c() {} -unk32 UnkStruct_02038aa0::vfunc_38() {} +extern u32 data_027e0618[]; + +ARM UnkStruct_0203881c::UnkStruct_0203881c() { + this->mUnk_14 = 0x1000; + this->mUnk_18 = 0; + this->mUnk_1c = 0; + this->mUnk_20 = 0; + this->mUnk_24 = 0; +} + +ARM void UnkStruct_0203881c::func_02038858(unk32 param1) {} +ARM void UnkStruct_0203881c::func_02038888() {} +ARM void UnkStruct_0203881c::func_02038950(UnkStruct_02038aa0 *param1, s32 param2) {} +ARM void UnkStruct_0203881c::func_02038a80(s32 param1) {} +ARM UnkStruct_0203881c::~UnkStruct_0203881c() {} + +THUMB UnkStruct_02038aa0::UnkStruct_02038aa0(u8 param1, u8 param2) : + UnkStruct_0203dae0(param1), + mUnk_124(0) { + this->func_020387e0(this->mUnk_150); + this->pInfoEntry = 0; + this->mUnk_158.y = 0; + this->mUnk_15c = 0; + this->mUnk_15e = 0xFF; + this->mUnk_15f = 0xFF; + this->mUnk_160 = 1; + this->mUnk_11e = param2; +} + +THUMB UnkStruct_02038aa0::~UnkStruct_02038aa0() {} + +THUMB void UnkStruct_02038aa0::func_02038b28(void) { + this->mUnk_114->mUnk_04 = NULL; +} + +ARM void UnkStruct_02038aa0::vfunc_4c(u32 param1, unk32 param2) { + this->UnkStruct_0203dae0::vfunc_10(param1, param2); +} + +ARM void UnkStruct_02038aa0::vfunc_10() {} + +ARM void UnkStruct_02038aa0::func_02038b40() { + this->mUnk_15c = -1; + this->mUnk_128.mUnk_04 = NULL; + this->func_0203dc10(0); + this->vfunc_48(); +} + +ARM void UnkStruct_02038aa0::vfunc_48() {} + +ARM void UnkStruct_02038aa0::func_02038b74(void) {} + +// non-matching +ARM bool UnkStruct_02038aa0::func_02038b78() { + if (data_027e0c54 == 0) { + if ((this->mUnk_50 != 0 && gMessageManager.func_02036850() != 0) || + (this->mUnk_50 == 0 && gMessageManager.func_02036824() != 0)) + { + return true; + } + + return false; + } else { + bool ret = CHECK_UNK_FLAGS(1); + + if ((this->mUnk_50 == 0 || ret)) { + return (this->mUnk_50 != 0 && ret); + } + + return false; + } +} + +ARM unk32 UnkStruct_02038aa0::vfunc_34(s32 param1) { + s16 iVar1; + unk32 iVar2; + unk32 iVar3; + unk32 uVar4; + + iVar2 = this->func_02038cf4(); + iVar3 = this->func_02038d10(); + iVar1 = ((this->mUnk_158.y - (this->mUnk_18 << 3) / 2)); + + if ((param1 < iVar2 + iVar1) || (iVar2 + iVar3 + iVar1 <= param1)) { + return -1; + } + + iVar3 = this->mUnk_34; + uVar4 = this->func_02032fb4(); + iVar2 = (param1 - iVar1) - iVar2; + + return func_01ff9b4c(iVar2 + iVar3 / 2, uVar4); +} + +ARM s32 UnkStruct_02038aa0::func_02038cb8(s32 param1) { + u8 bVar1 = this->mUnk_2c[0]->mUnk_08[1]; + unk32 iVar2 = this->func_02038cf4(); + unk32 iVar1 = this->func_020337d8(param1 + 1); + return iVar2 + iVar1 - bVar1; +} + +ARM s32 UnkStruct_02038aa0::func_02038cf4() { + unk32 iVar1; + unk32 iVar2; + + iVar2 = this->mUnk_18; + iVar1 = this->func_02038d10(); + return (iVar2 * 8 - iVar1) / 2; +} + +ARM s32 UnkStruct_02038aa0::func_02038d10() { + return this->func_020337d8(this->mUnk_150[0]); +} + +ARM void UnkStruct_02038aa0::vfunc_2c() {} + +ARM void UnkStruct_02038aa0::vfunc_30(unk32 param_2, unk32 param_3) { + if (this->mUnk_15c > 0) { + this->func_0203e090(); + } else { + this->mUnk_118 = -1; + } +} + +ARM bool UnkStruct_02038aa0::func_02038ef4(s32 param1, s32 param2) { + unk32 local_14; + unk32 local_18; + + this->vfunc_70(&local_14, &local_18); + this->func_0203e1b0(local_14 + param1, local_18 + param2, 0); +} + +ARM void UnkStruct_02038aa0::func_02038f40(void) {} + +ARM void UnkStruct_02038aa0::vfunc_44(s32 touchLastX, s32 touchLastY) {} + +// non-matching +ARM void UnkStruct_02038aa0::vfunc_50(EntryINF1 *param1, u32 param2, s16 *param3, UnkSubClass1_02256FF8 *param4) { + int iVar1; + + this->pInfoEntry = param1; + this->mUnk_08 = param4; + this->mUnk_15f = -1; + this->mUnk_15c = 0x78; + this->mUnk_15e = param4->mUnk_0c; + this->func_0203dcfc(0, 0, this->mUnk_11e, 2); + this->mUnk_128.func_02038858(param2); + this->mUnk_30 = this->mUnk_150[4] + 5; + + this->vfunc_54(); + // this->vfunc_60(0, 0, (unk32)param3); + // this->vfunc_64(param3); + + if (*(unk32 *) data_027e0618 == 2) { + if (this->func_02032fa4() == 0) { + data_027e103c->func_ov000_020cfc9c(1, 0); + } else { + data_027e103c->func_ov000_020cfc9c(0, 1); + } + } + + this->vfunc_5C(); +} + +// non-matching +ARM void UnkStruct_02038aa0::vfunc_5c(u16 *param_2, UnkStruct_0203b264 *param_3, unk8 param_4, unk32 param_5) { + u16 sVar1; + bool bVar5; + + sVar1 = param_2[0]; + bVar5 = (sVar1 == 0xA || sVar1 == 0x20) || sVar1 == 0x3000; + + if (bVar5 && this->mUnk_150[2] != 0) { + this->mUnk_150[2] = 1; + } else { + this->mUnk_150[2] = 0; + } + + // this->mUnk_150[2] = bVar5; + + // return? + this->func_02033360(); +} + +ARM unk32 UnkStruct_02038aa0::vfunc_1c(s32 param1, unk32 *param2, unk32 param3, unk32 param4) {} +ARM unk32 UnkStruct_02038aa0::vfunc_20(s32 param1, s32 *param2) {} +ARM void UnkStruct_02038aa0::func_02039208(unk16 param1) {} + +// non-matching +ARM void UnkStruct_02038aa0::vfunc_08(s32 param1, unk32 *param2, s16 *param3, unk32 param4) { + this->mUnk_15c = 10; + this->mUnk_150[2] = 1; + this->func_0203e2ac(param2); +} + +ARM unk32 UnkStruct_02038aa0::func_02039250() {} +ARM void UnkStruct_02038aa0::vfunc_54() {} +ARM void UnkStruct_02038aa0::vfunc_58() {} +ARM void UnkStruct_02038aa0::vfunc_60() {} +ARM void UnkStruct_02038aa0::vfunc_64() {} + +ARM s32 UnkStruct_02038aa0::vfunc_68(unk32 param1) { + switch (param1) { + case 0: break; + case 1: this->mUnk_34 = 4; break; + case 2: this->mUnk_34 = 6; break; + case 3: this->mUnk_34 = 1; break; + case 4: this->mUnk_34 = 0; break; + default: break; + } + + return ((this->mUnk_18 << 3) - this->func_020337d8(param1)) / 2; +} + +ARM void UnkStruct_02038aa0::func_02039440(unk32 param1, unk32 param2) {} +ARM void UnkStruct_02038aa0::vfunc_6c(s32 *param1, s32 *param2) {} + +ARM void UnkStruct_02038aa0::vfunc_70(s32 *param1, s32 *param2) { + this->vfunc_6C(param1, param2); + *param1 += this->mUnk_158.x; + *param2 += this->mUnk_158.y; +} + +ARM bool UnkStruct_02038aa0::func_0203951c() {} +ARM bool UnkStruct_02038aa0::vfunc_38() {} + +ARM void UnkStruct_02038aa0::vfunc_0c(u8 param_2, u8 param_3, u8 param_4, unk32 param_5) { + this->func_0203dc10(1, param_3); + this->func_02033190(param_2, param_3, param_4, param_5); +} diff --git a/src/Main/Unknown/UnkStruct_020397f8.cpp b/src/Main/Unknown/UnkStruct_020397f8.cpp index 3bd676db..dba982d6 100644 --- a/src/Main/Unknown/UnkStruct_020397f8.cpp +++ b/src/Main/Unknown/UnkStruct_020397f8.cpp @@ -1,39 +1,1000 @@ #include "Unknown/UnkStruct_020397f8.hpp" +#include "DTCM/UnkStruct_027e103c.hpp" +#include "Message/MessageManager.hpp" +#include "Message/MsgProc.hpp" +#include "Player/TouchControl.hpp" +#include "Save/AdventureFlags.hpp" -UnkStruct_020397f8::UnkStruct_020397f8() : - UnkStruct_02038aa0(0, 0) {} -void UnkStruct_020397f8::vfunc_4c() {} -void UnkStruct_020397f8::vfunc_2c() {} -void UnkStruct_020397f8::func_02039ca8() {} -void UnkStruct_020397f8::vfunc_3c() {} -void UnkStruct_020397f8::vfunc_40(s32 param1, s32 param2) {} -void UnkStruct_020397f8::func_0203a188(s32 param1, s32 param2) {} -bool UnkStruct_020397f8::func_0203a2c0() {} -unk32 UnkStruct_020397f8::func_0203a30c() {} -void UnkStruct_020397f8::vfunc_48() {} -void UnkStruct_020397f8::func_0203a35c() {} -bool UnkStruct_020397f8::func_0203a3e0() {} -void UnkStruct_020397f8::vfunc_44(s32 param1, s32 param2) {} -bool UnkStruct_020397f8::func_0203a6d0(unk32 param1) {} -void UnkStruct_020397f8::vfunc_50(unk32 param1, unk32 param2, s32 param3, unk32 param4) {} -void UnkStruct_020397f8::vfunc_54() {} -void UnkStruct_020397f8::vfunc_5c() {} -void UnkStruct_020397f8::vfunc_58() {} -bool UnkStruct_020397f8::func_0203b0bc() {} -s32 UnkStruct_020397f8::func_0203b0ec(u32 param1) {} -unk32 UnkStruct_020397f8::vfunc_18(s32 param1) {} -unk32 UnkStruct_020397f8::vfunc_1c(s32 param1, unk32 *param2, unk32 param3, unk32 param4) {} -void UnkStruct_020397f8::vfunc_60(s32 param1) {} -void UnkStruct_020397f8::vfunc_64(unk32 param1) {} -void UnkStruct_020397f8::func_0203b764() {} -unk32 UnkStruct_020397f8::vfunc_20(s32 param1, s32 *param2) {} -void UnkStruct_020397f8::func_0203bd8c(s32 param1) {} -void UnkStruct_020397f8::vfunc_6c(s32 *param1, s32 *param2) {} -void UnkStruct_020397f8::func_0203be08() {} -void UnkStruct_020397f8::func_0203be64() {} -bool UnkStruct_020397f8::func_0203c084() {} -bool UnkStruct_020397f8::func_0203c13c() {} -bool UnkStruct_020397f8::func_0203c1a0() {} -bool UnkStruct_020397f8::func_0203c25c() {} -UnkStruct_020397f8::~UnkStruct_020397f8() {} -unk32 UnkStruct_020397f8::vfunc_38() {} +extern "C" void func_ov000_020d0460(void *); +extern "C" void func_0203efd8(void *, void *); +extern "C" void func_0203ee48(void *); +extern "C" void func_ov018_02169634(UnkStruct_020397f8 *); + +extern unk16 data_02056a0e[]; +extern u8 data_02056a08[]; +extern u32 data_027e0618[]; + +THUMB UnkStruct_020397f8::UnkStruct_020397f8() : + UnkStruct_02038aa0(0, 0), + mUnk_164(NULL) { + UnknownMsgChoiceStruct *puVar3; + + this->mUnk_410.mUnk_00 = this; + this->mUnk_414 = 0; + this->mUnk_418 = NULL; + this->mUnk_41c = 0; + this->mUnk_41e = 0; + this->mUnk_420 = 0; + this->mUnk_424.mUnk_00 = this; + + // ??? + puVar3 = this->mUnk_428; + do { + puVar3->mUnk_00 = NULL; + puVar3 += 1; + } while ((unk32 *) puVar3 < (unk32 *) this->mUnk_528); + + func_0203ee48(&this->mUnk_424); + func_ov000_020d0460(&this->mUnk_534); + this->mUnk_53c = 0; + this->mUnk_540 = ~0x7FFF; + this->mUnk_544 = 3; + func_ov000_020d0460(&this->mUnk_548); + this->mUnk_550 = 0; + this->mUnk_554 = 0x00016000; + this->mUnk_558 = 3; + this->mUnk_55c = -1; + this->mUnk_560 = -1; + this->mUnk_56c = 0; + this->mUnk_56e = 0; + this->mUnk_570 = 0; + this->mUnk_572 = 0; + this->mUnk_574 = 0; + this->mUnk_576 = 0; + this->mUnk_578 = 3; + this->mUnk_57a = 0; + this->mUnk_57b = -1; + this->mUnk_57c = 0; + this->mUnk_57d = 0; + this->mUnk_57e = 0; + this->mUnk_57f = 0; + this->mUnk_580 = 0; + this->mUnk_581 = 0; + this->mUnk_582 = 0; + this->mUnk_583 = 0; + this->mUnk_585 = 0; + this->mUnk_586 = 0; + func_0203efd8(&this->mUnk_588, this); + this->mUnk_124 = (UnkSubClass1_unk_124 *) &this->mUnk_588; + this->func_02039ca8(); + + if (this->func_02032fa4() != 0) { + this->mUnk_168.func_020350b4(0x39, 0, 2, 0, 0); + this->mUnk_1f0.func_020350b4(0x33, 0, 2, 0, 0); + this->mUnk_278.func_020350b4(0x33, 1, 2, 0, 0); + } else { + this->mUnk_168.func_020350b4(0x34, 0, 2, 0, 0); + this->mUnk_1f0.func_020350b4(0x32, 0, 2, 0, 0); + this->mUnk_278.func_020350b4(0x32, 1, 2, 0, 0); + } + + this->mUnk_168.func_020351b8(true, false, false, false); + this->mUnk_1f0.func_020351b8(false, false, false, false); + this->mUnk_278.func_020351b8(false, false, false, false); +} + +THUMB void UnkStruct_020397f8::vfunc_4c() { + this->func_02038b28(); + this->func_0203dcfc(this->mUnk_50, 0, 0, 2); +} + +// non-matching +ARM void UnkStruct_020397f8::vfunc_2c() { + if (data_027e0618[0x101] != 0) { + if (((data_02056be4[data_027e077c.mUnk_0] & 1) != 0) != this->mUnk_50) { + return; + } + } + + this->func_02038d20(); + + if (this->mUnk_56c > 0) { + this->mUnk_56c--; + } + + if (this->mUnk_50 != ((data_02056be4[data_027e077c.mUnk_0] & 1) != 0)) { + this->mUnk_57f = 0; + } + + if (this->mUnk_15c > 0) { + if ((this->mUnk_128.mUnk_04 == NULL || this->mUnk_128.mUnk_04[0] == 0) != 0) { + this->mUnk_424.func_0203ef78(this->mUnk_128.mUnk_08); + } + + this->func_0203be64(); + this->func_0203a35c(); + + if (this->mUnk_580 != 0) { + this->mUnk_168.func_0203516c(); + } + + if (this->mUnk_584 != 0) { + this->mUnk_300.func_0203516c(); + } + + if (this->mUnk_585 != 0) { + this->mUnk_388.func_0203516c(); + } + + if ((this->func_0203a2c0() != 0 && this->mUnk_57f == 0) && this->mUnk_56c <= 0) { + this->mUnk_1f0.func_0203516c(); + } + + if (this->mUnk_08 != NULL) { + bool value = this->mUnk_08->mUnk_1c; + + if ((value == 1) || (value == 2)) { + this->mUnk_278.func_0203516c(); + } + } + + if (this->mUnk_15e == 6) { + func_ov018_02169634(this); + } else { + this->mUnk_410.func_0203ebf8(); + } + } + + if (this->mUnk_15c == 1) { + if (this->mUnk_586 == ((data_02056be4[data_027e077c.mUnk_0] & 1) != 0)) { + switch (this->mUnk_150[1]) { + case 0: this->func_0203b0ec(1); break; + case 2: + case 3: + if (this->func_0203a3e0() != 0) { + this->func_0203bd8c(this->mUnk_572); + } else { + this->func_0203b0ec(1); + } + break; + } + } + } +} + +ARM void UnkStruct_020397f8::func_02039ca8() { + s32 i; + + for (i = 0; i < ARRAY_LEN(this->mUnk_564); i++) { + this->mUnk_564[i] = 0x1A; + } +} + +ARM void UnkStruct_020397f8::vfunc_3c(unk32 param1) { + if (this->mUnk_15c > 0 && this->func_0203de14(param1) != 0) { + if (this->mUnk_124->mUnk_29 != 3) { + if ((this->mUnk_50 == 0) && func_ov000_02079e04() != 0) { + return; + } + + if (data_027e0618[0x101] != 0) { + if (((data_02056be4[data_027e077c.mUnk_0] & 1) != 0) != this->mUnk_50) { + return; + } + } + + this->vfunc_40(0, 0); + } + } +} + +// non-matching +ARM void UnkStruct_020397f8::vfunc_40(s32 param1, s32 param2) { + UnkStruct_02038aa0 *bVar1; + s8 cVar2; + unk32 iVar4; + unk32 iVar6; + unk32 iVar7; + unk32 iVar8; + unk32 uVar9; + unk32 iStack_a8; + unk32 iStack_a4; + unk32 local_a0; + unk32 local_9c; + unk32 local_98; + unk32 local_94; + unk32 local_90; + unk32 local_8c; + unk32 iVar5; + UnkStruct_01ffbe34 aStack_88; + UnkStruct_01ffbe34 aStack_68; + UnkStruct_01ffbe34 aStack_48; + + local_8c = 0; + local_90 = 0; + bVar1 = gMessageManager.mUnk_28[this->mUnk_50]; + + this->vfunc_6C(&local_8c, &local_90); + this->func_0203a188(local_8c + param1, local_90 + param2); + this->func_0203e1b0(param1 + local_8c + (this->mUnk_158.x - (this->mUnk_14 << 3) / 2), + param2 + local_90 + (this->mUnk_158.y - (this->mUnk_18 << 3) / 2), 0); + + if (this->mUnk_584 != 0) { + iVar5 = this->mUnk_18 << 3; + + if (this->mUnk_580 != 0) { + iVar5 = -0xC; + } else { + iVar5 = 0; + } + + this->mUnk_300.func_02034a1c(param1 + local_8c + this->mUnk_55c + (this->mUnk_158.x - (this->mUnk_14 << 3) / 2), + iVar5 + param2 + local_90 + this->mUnk_560 + ((this->mUnk_158.y - (iVar5 / 2))), 0); + } + + if (this->mUnk_585 != 0 && ((data_02056be4[data_027e077c.mUnk_0] & 1) == 0)) { + switch (data_027e0618[0]) { + case 2: + if (data_027e0cbc.func_0203d7e0(3) != 0) { + this->mUnk_388.func_02034b0c(0xBE, 0, 0, 0, 0); + } + break; + case 6: + if (data_027e0cbc.func_0203d7e0(0x58) != 0) { + this->mUnk_388.func_02034b0c(0x013B, 0, 0, 0, 0); + } + break; + } + } + + iVar5 = this->func_02032fa4(); + iVar8 = bVar1->mUnk_18; + uVar9 = data_02056a04[iVar8]; + // func_0203489c(uVar9, data_02056a16[iVar8], &local_94, &local_98); + iVar6 = this->mUnk_158.x - local_94; + iVar7 = this->mUnk_158.y - local_98; + + if ((this->mUnk_15e != 7) && (this->func_0203a2c0() != 0)) { + func_01ffbe34(&aStack_48); + func_020347b0(uVar9, data_02056a10[iVar8], &local_9c, &local_a0, 4, 4); + local_9c += param1 + local_8c + iVar6; + local_a0 += param2 + local_90 + iVar7; + + if (data_027e0c38[5] == 1) { + iVar8 = func_0202ab48(); + + if (iVar8 == 0) { + iVar8 = 0; + } else { + iVar8 = -3; + } + + local_9c = (0x108 - local_9c) + iVar8; + } + + if ((this->mUnk_57f == 0) && (this->mUnk_56c <= 0)) { + func_01ffbe34(&aStack_68); + aStack_68.mUnk_0a = 1; + this->mUnk_1f0.func_02034a1c(local_9c, local_a0, &aStack_68); + } else { + // func_02034984(iVar5 != 0 ? 0x11F : 0x18, 0, local_9c, local_a0 + 2, 0); + } + } + + if (this->mUnk_08 != 0) { + if ((this->mUnk_08->mUnk_1c == 1 || this->mUnk_08->mUnk_1c == 2) == 0) { + return; + } + + func_01ffbe34(&aStack_88); + aStack_88.mUnk_0a = 1; + func_02034698(iVar5 != 0 ? 0x11F : 0x18, 2, &iStack_a4, &iStack_a8); + iStack_a4 += param1 + local_8c + iVar6; + iStack_a8 += param2 + local_90 + iVar7; + this->mUnk_278.func_02034a1c(iStack_a4, iStack_a8, &aStack_88); + } +} + +ARM void UnkStruct_020397f8::func_0203a188(s32 param1, s32 param2) { + unk16 sVar1; + unk16 sVar2; + unk32 iVar3; + unk32 iVar4; + unk32 uVar5; + unk32 iVar6; + unk32 iStack_54; + unk32 iStack_50; + unk32 iStack_4c; + unk32 iStack_48; + UnkStruct_01ffbe34 aStack_44; + unk32 uStack_24; + + if (this->mUnk_15e == 7) { + return; + } + + // (short)(ushort)*(byte *)((int)gMessageManager.mUnk_28[(this->mUnk_50 - 0x28) * 0x18]; + + iVar6 = gMessageManager.mUnk_10 + this->mUnk_50; + // uStack_24 = param_4; + + if (data_027e0cbc.func_0203d7e0(data_02056a00[iVar6]) != 0) { + uVar5 = data_02056a04[iVar6]; + + func_0203489c(uVar5, data_02056a16[iVar6], &iStack_48, &iStack_4c); + iVar3 = iStack_50 + (this->mUnk_158.x - iStack_48); + + func_02034698(uVar5, data_02056a0e[iVar6], &iStack_50, &iStack_54); + iVar4 = iStack_54 + (this->mUnk_158.y - iStack_4c); + + func_01ffbe34(&aStack_44); + aStack_44.mUnk_0a = 1; + + if (this->mUnk_580 != 0) { + this->mUnk_168.func_02034a1c(param1 + iVar3, param2 + iVar4, &aStack_44); + } else { + func_02034984(uVar5, data_02056a08[iVar6], param1 + iVar3, param2 + iVar4); + } + } +} + +// non-matching +ARM bool UnkStruct_020397f8::func_0203a2c0() { + if ((this->mUnk_150[1] != 1 && this->mUnk_150[1] != 2) && (this->func_02039250() != 0 && this->func_02038b78() != 0)) { + return true; + } + + return false; +} + +ARM unk32 UnkStruct_020397f8::func_0203a30c() { + return this->mUnk_574 / this->pInfoEntry->mUnk_06; +} + +// non-matching (regalloc) +ARM void UnkStruct_020397f8::vfunc_48() { + if (this->mUnk_164 != NULL && this->mUnk_164->mUnk_15c > 0) { + this->func_02038b40(); + } + + this->mUnk_410.func_0203ec34(); +} + +ARM void UnkStruct_020397f8::func_0203a35c() { + if ((this->mUnk_57c == 1 || this->mUnk_150[3] != 0) || + (this->mUnk_128.mUnk_04 == NULL || this->mUnk_128.mUnk_04[0] == 0) != 0) + { + if (this->func_0203a3e0()) { + s16 mUnk_56e = this->mUnk_56e; + s16 mUnk_570 = this->mUnk_570; + UnkStruct_020397f8 *mUnk_164 = this->mUnk_164; + + mUnk_164->mUnk_168.mUnk_10 = mUnk_56e; + mUnk_164->mUnk_168.mUnk_14 = mUnk_570; + this->mUnk_164->func_02039208(4); + } + } else { + this->mUnk_164->func_02038b40(); + } +} + +ARM bool UnkStruct_020397f8::func_0203a3e0() { + return this->mUnk_164->mUnk_168.mUnk_06 > 0; +} + +// non-matching +ARM void UnkStruct_020397f8::vfunc_44(s32 touchLastX, s32 touchLastY) { + unk32 iVar2; + unk32 iVar5; + unk32 iStack_14; + unk32 iStack_18; + + if (this->mUnk_15c <= 0 || this->func_0203951c() == 0) { + return; + } + + iStack_14 = 0; + iStack_18 = 0; + + this->vfunc_6C(&iStack_14, &iStack_18); + + iVar5 = touchLastX - iStack_14; + iVar2 = touchLastY - iStack_18; + + if ((data_027e103c != 0 && data_027e103c->mUnk_1c == 0x8F) || (data_027e077c.mUnk_0 != data_027e077c.mUnk_4)) { + return; + } + + if ((data_02056be4[data_027e077c.mUnk_0] & 2) == 0) { + if ((gTouchControl.mFlags & 1) != 0) { + if (this->mUnk_50 == 0 && data_027e0d38 != 0) { + if (func_ov000_02079e04() == 0 && data_027e0e28->func_ov000_0207bc48() == 0) { + if (data_027e0618[0x101] == 0 && data_027e103c->mUnk_24 == 0) { + return; + } + } + } + + if (this->func_0203a6d0(iVar5, iVar2) == 0 && this->func_0203a2c0() != 0) { + this->mUnk_57f = 1; + } + } else { + if (gTouchControl.mTouch != 0) { + this->func_0203a6d0(iVar5, iVar2); + return; + } + + if (gTouchControl.mTouch == 0) { + switch (this->mUnk_150[1]) { + case 3: + case 4: break; + case 5: + if (data_027e103c->mUnk_20 == 3) { + this->func_0203b0ec(1); + } + break; + case 6: + if (data_027e103c->mUnk_20 == 5) { + this->func_0203b0ec(1); + } + break; + case 7: break; + case 2: + //! TODO: fixme + // if (this->mUnk_164->mUnk_168.mUnk_06 <= 0) { + // if ((gTouchControl.mFlags & 2) != 0) { + // this->mUnk_128.mUnk_14 = 0; + + // if (this->func_0203b0bc() != 0) { + // this->func_0203b0ec(1); + // } + + // this->mUnk_1f0.mUnk_5c.mUnk_08 = 0; + // this->mUnk_1f0.func_020352d8(); + // } + // } + break; + case 0: + case 1: + default: + if ((gTouchControl.mFlags & 2) != 0) { + this->mUnk_128.mUnk_14 = 0; + + if (this->func_0203b0bc() != 0) { + this->func_0203b0ec(1); + } + + this->mUnk_1f0.mUnk_5c.mUnk_08 = 0; + this->mUnk_1f0.func_020352d8(); + } + break; + } + } + } + } +} + +ARM bool UnkStruct_020397f8::func_0203a6d0(unk32 param1, unk32 param2) { + unk32 iVar1; + unk32 uVar2; + UnkStruct_0203b264 *piVar3; + + if (this->mUnk_164->mUnk_168.mUnk_06 > 0 && this->mUnk_164->mUnk_15c <= 0) { + return false; + } + + iVar1 = this->vfunc_34(param2); + piVar3 = NULL; + + if (!(iVar1 < 0) && iVar1 < 4) { + piVar3 = this->mUnk_424.func_0203eeb0(iVar1, param1); + } + + if (piVar3 != NULL && ((piVar3->mUnk_0[3] << 0x10) | ((u16 *) piVar3->mUnk_0)[2]) == 0x00FF0002) { + uVar2 = this->func_02038cb8(iVar1); + this->mUnk_410.func_0203ec4c(piVar3, uVar2, + (s16) (this->mUnk_158.x - ((this->mUnk_14 << 3) / 2)) + iVar1 + this->mUnk_56e, + (s16) (this->mUnk_158.y - ((this->mUnk_18 << 3) / 2)) + iVar1 + this->mUnk_570); + + this->mUnk_57f = 0; + return true; + } + + return false; +} + +// non-matching +ARM void UnkStruct_020397f8::vfunc_50(EntryINF1 *param1, unk32 param2, s32 *param3, unk32 param4) { + bool bVar5; + bool bVar2; + int iVar4; + int iVar6; + s16 temp; + + iVar6 = param3[0]; + + if (data_027e0c54 != 0) { + UnkStruct_020397f8 *pVar4 = gMessageManager.func_02036700(); + + if (pVar4 != NULL && pVar4->mUnk_15c > 0) { + this->func_02038b40(); + } + } + + if (*((s32 *) data_027e0618) == 2 && data_027e0d38->func_ov000_02078b40() == 2 && + func_ov003_020f3f94(data_ov009_0211f5b4) == 0) + { + UnkStruct_020397f8 *pVar4 = (UnkStruct_020397f8 *) gMessageManager.mUnk_28[4]; + + if (pVar4 != NULL && pVar4->mUnk_15c > 0) { + this->func_02038b40(); + } + } + + this->mUnk_586 = (data_02056be4[data_027e077c.mUnk_0] & 1) != 0; + temp = param3[8]; + + if (temp >= 0 && param3[9] >= 0) { + temp = param3[10]; + } + + if (temp < 0) { + this->mUnk_57b = temp; + } else { + this->mUnk_57b = 0; + } + + // this->func_02038f44(param1, param2, param3, param4, iVar6); + this->mUnk_574 = 0; + + if (data_027e0d38 != 0 && (data_02056be4[data_027e077c.mUnk_0] & 1) != 0 && (param3[11])) { + data_027e103c->func_ov000_020cf284(0x80, 0); + } +} + +// switch decomp issue +ARM void UnkStruct_020397f8::vfunc_54() {} + +ARM void UnkStruct_020397f8::vfunc_5c() { + if (this->mUnk_15f == 0 || this->pInfoEntry->mUnk_06 <= 2) { + this->mUnk_168.mUnk_5c.mUnk_08 = this->mUnk_168.mUnk_7c; + this->mUnk_168.func_020352d8(); + } else { + this->mUnk_168.mUnk_5c.mUnk_08 = 0; + this->mUnk_168.func_020352d8(); + this->mUnk_168.func_020351b8(1, 0, 0, 0); + } +} + +// non-matching +ARM void UnkStruct_020397f8::vfunc_58() { + bool bVar1; + s8 *puVar2; + int iVar3; + char *pcVar4; + + if (this->mUnk_160 != 0) { + if (data_027e103c != NULL) { + if (data_027e103c->func_ov000_020cf4bc() != 0) { + puVar2 = (s8 *) data_027e103c->func_ov000_020cef9c(); + + if ((puVar2 + 0x244) != NULL || (puVar2[0x250] == '\x02')) { + puVar2 = (s8 *) data_027e103c->func_ov000_020cef9c(); + + if ((UnkStruct_020397f8 *) (puVar2 + 0x244) == this) { + data_027e103c->func_ov000_020cfb38(); + } + } + } + + if (this->mUnk_581 != 0 && data_027e103c->func_ov000_020cf488() != 0) { + data_027e103c->func_ov000_020cfa24(0, 0); + this->mUnk_581 = 0; + } + + if (this->mUnk_582 != 0) { + data_027e103c->func_ov000_020cfe40(0, 2); + this->mUnk_582 = 0; + } + + if (this->mUnk_583 != 0) { + data_027e103c->func_ov005_02104028(0); + this->mUnk_583 = 0; + } + } + + // if (data_027e0618[0] == 2 && func_ov000_02079e04() && (data_027e1054.mUnk_04 + 0x99) != 0 && + // (data_027e077c.mUnk_0 != 0x39 || data_027e103c->func_ov000_020cf0bc())) { + // data_027e1054.func_ov003_020f4874(); + // data_027e103c->func_ov005_02103f8c(data_02057ed4); + // } + } + + this->func_02039398(); +} + +ARM bool UnkStruct_020397f8::func_0203b0bc() { + return this->mUnk_57f != 0 && data_027e077c.mUnk_0 == data_027e077c.mUnk_4; +} + +// non-matching +ARM s32 UnkStruct_020397f8::func_0203b0ec(u32 param1) { + s32 iVar4; + u16 *puVar2; + u32 uVar3; + s32 unaff_r6; + bool bVar1; + + iVar4 = 0; + bVar1 = false; + + uVar3 = param1; + + if (((data_02056be4[data_027e077c.mUnk_0] & 1) == 0)) { + uVar3 = 0; + } else { + uVar3 = 1; + } + + unaff_r6 = this->mUnk_50 == uVar3; + + this->mUnk_410.func_0203ec34(); + this->mUnk_585 = 0; + this->mUnk_584 = 0; + + if (this->mUnk_150[3] != 0) { + iVar4 = 1; + this->mUnk_56c = this->mUnk_578; + bVar1 = true; + this->mUnk_15c = 0x78; + } else { + if ((this->mUnk_128.mUnk_04 == NULL || this->mUnk_128.mUnk_04[0] == 0) != 0) { + this->func_02038b40(); + + if (data_027e0d38 != 0) { + data_027e103c->func_ov000_020cf224(1); + data_027e103c->func_ov000_020cf2a0(1); + } + + if (this->mUnk_08 == NULL) { + this->vfunc_58(); + } + + iVar4 = 1; + } + } + + if (iVar4 != 0) { + if (bVar1) { + this->vfunc_54(); + } + + if (unaff_r6 != 0) { + data_027e0d04.func_0203fe60(0); + } + } + + if (((param1 != 0 && iVar4 != 0) && unaff_r6 != 0) && this->mUnk_15e != 7) { + data_ov000_020eec9c.func_ov000_020d77e4(0x19); + } + + return iVar4; +} + +// non-matching (regalloc) +ARM unk32 UnkStruct_020397f8::vfunc_18(UnkStruct_0203b264 *param1, unk32 param2, unk32 param3) { + u16 sVar1; + u32 uVar4; + s32 unaff_r4; + bool bVar5; + + if (this->func_0203951c() == 0) { + return 1; + } + + if (this->mUnk_580 != 0) { + unaff_r4 = -0xC; + } else { + unaff_r4 = 0; + } + + sVar1 = param1->mUnk_4[0]; + + if (sVar1 != 0x1A || sVar1 == 0x1A) { + bVar5 = true; + + if (sVar1 == 0x1A) { + uVar4 = (param1->mUnk_0[3] << 0x10) | ((u16 *) param1->mUnk_0)[2]; + + if (((uVar4 == 0x0001000A || uVar4 == 0x00020000) || uVar4 == 0x00FF0000)) { + bVar5 = false; + } + } + + if (bVar5) { + this->mUnk_424.func_0203ee80(this->mUnk_128.mUnk_08); + } + } + + return this->func_0203e284(param1, param2, param3 + unaff_r4); +} + +// non-matching +ARM unk32 UnkStruct_020397f8::vfunc_1c(u16 *param1, UnkStruct_0203b264 *param2, unk8 param3, unk32 param4) { + int iVar1; + u16 *psVar3; + + psVar3 = param2->mUnk_4; + + if (psVar3[0] == 10) { + this->mUnk_424.func_0203ef78(this->mUnk_128.mUnk_08, psVar3[0], param3); + this->mUnk_574++; + + if (this->func_0203a30c() == 0) { + this->mUnk_150[3] = 1; + } + } + + if (this->mUnk_15e == 6) { + return 1; + } + + switch (this->mUnk_57a) { + case 0: return this->func_0203905c(param1, param2, param3, param4); + case 1: + UnknownMsgChoiceStruct *pChoiceData; + s32 i = this->func_0203a30c(); + pChoiceData = &this->mUnk_428[this->mUnk_528[i]]; + return this->mUnk_164->func_0203cb5c( + *param1, (((pChoiceData->mUnk_00->mUnk_0[3] << 0x10) | ((u16 *) pChoiceData->mUnk_00->mUnk_0)[2]) + ~0xFFFE)); + default: break; + } + + return 0; +} + +// non-matching +ARM void UnkStruct_020397f8::vfunc_60(func_0203b410_param1 *param1, unk32 param2, unk32 param3) { + unk16 sVar1; + unk16 uVar2; + unk32 iVar3; + unk32 iVar4; + unk32 uVar5; + u32 uVar6; + + uVar6 = 0; + + if (this->func_02032fa4() == 0) { + switch (param1->mUnk_0c) { + case 0: + case 1: uVar6 = this->mUnk_580 != 0; break; + case 2: uVar6 = 2; break; + case 3: uVar6 = 3; break; + case 5: uVar6 = 4; break; + case 6: uVar6 = 5; break; + default: + // why??? + switch (param1->mUnk_0c) { + case 4: uVar6 = 8; break; + case 7: uVar6 = 9; break; + default: + if (this->mUnk_580 != 0) { + uVar6 = 7; + } else { + uVar6 = 6; + } + break; + } + break; + } + } + + // PTR_PTR_0203b5ac[(byte)param_1[0x50]] = (char)uVar6; + gMessageManager.mUnk_28[this->mUnk_50]->mUnk_50 = uVar6; + + if (this->mUnk_15e == 7) { + uVar5 = func_0202d5b4(data_02057f08, data_02057eec, data_020691a0, 0xCC00, 1); + func_02032304(data_02068894, data_02057ed8, data_02056af0, 1, param3); + iVar3 = func_02016fcc(uVar5); + } else { + if (this->func_02032fa4() != 0) { + uVar5 = 0x33; + } else { + uVar5 = 0x32; + } + + data_027e0cbc.func_0203d77c(uVar5, 1, 1); + iVar3 = data_027e0cbc.func_0203d77c(data_02056a00[uVar6 * 0x18] - 2, 1, 1); + } + + if (param1->mUnk_10 < 0) { + iVar3 = param1->mUnk_12; + } + + if (param1->mUnk_10 <= 0 && iVar3 > 0) { + uVar2 = param1->mUnk_12; + this->mUnk_158.x = param1->mUnk_10; + this->mUnk_158.y = uVar2; + } else { + this->func_0203b764(); + } +} + +// non-matching (regalloc) +ARM void UnkStruct_020397f8::vfunc_64(s16 *param1) { + unk32 uVar2; + + if (this->mUnk_50 != 0 || data_027e0db0.mUnk_04 > 0 || func_0203c084() != 0 || + (gAdventureFlags->Exists() && gAdventureFlags->func_ov00_02097738())) + { + uVar2 = 0x16; + } else { + uVar2 = 0; + } + + this->mUnk_124->func_0203f020(param1, uVar2); + this->func_0203be08(); + + if (this->func_02032fa4()) { + this->mUnk_168.func_020350b4(0x39, 0, 2, 0, 0); + this->mUnk_1f0.func_020350b4(0x33, 0, 2, 0, 0); + this->mUnk_278.func_020350b4(0x33, 1, 2, 0, 0); + } else { + this->mUnk_168.func_020350b4(0x34, 0, 2, 0, 0); + this->mUnk_1f0.func_020350b4(0x32, 0, 2, 0, 0); + this->mUnk_278.func_020350b4(0x32, 1, 2, 0, 0); + } + + this->mUnk_168.func_020351b8(1, 0, 0, 0); + this->mUnk_1f0.func_020351b8(0, 0, 0, 0); + this->mUnk_278.func_020351b8(0, 0, 0, 0); + this->func_020393a8(param1); +} + +// non-matching +ARM void UnkStruct_020397f8::func_0203b764() { + s32 i = gMessageManager.mUnk_00[this->mUnk_50]; + + this->func_02039440(data_02056a04[i * 0x18], data_02056a16[i]); + + switch (this->mUnk_57b) { + case 1: this->mUnk_158.y -= 38; break; + case 2: + switch (this->pInfoEntry->mUnk_06) { + case 2: this->mUnk_158.y -= 111; break; + case 3: this->mUnk_158.y -= 98; break; + default: break; + } + break; + default: break; + } +} + +// switch decomp issue +ARM unk32 UnkStruct_020397f8::vfunc_20(s32 param1, s32 *param2) {} + +ARM void UnkStruct_020397f8::func_0203bd8c(s32 param1) { + this->mUnk_576 = param1; + + if (this->func_0203b0ec(0) != 0) { + data_ov000_020eec9c.func_ov000_020d77e4(this->mUnk_564[param1]); + } +} + +ARM void UnkStruct_020397f8::vfunc_6c(s32 *param1, s32 *param2) { + this->func_0203947c(); + *param1 += this->mUnk_56e; + *param2 += this->mUnk_570; +} + +ARM void UnkStruct_020397f8::func_0203be08() { + if (data_027e0d38 != 0) { + if (data_027e103c->func_ov000_020cf42c() != 0) { + this->mUnk_534 = this->mUnk_538; + } else { + this->mUnk_534 = this->mUnk_536; + } + + if (this->func_0203c084() != 0) { + this->mUnk_548 = this->mUnk_54c; + } + } +} + +ARM void UnkStruct_020397f8::func_0203be64() {} + +// non-matching +ARM bool UnkStruct_020397f8::func_0203c084() { + unk32 uVar4; + bool bVar2; + bool bVar1; + bool bVar3; + + uVar4 = 0; + + if (this->mUnk_50 == 0) { + bVar2 = true; + bVar1 = true; + + if ((data_02056be4[data_027e077c.mUnk_0] & 1) == 0 && data_027e103c->func_ov000_020cf8fc(0x8F) == 0) { + bVar1 = false; + } + + if (!bVar1 && data_027e0618[0x101] == 0) { + if ((data_027e0d38 != NULL && data_027e0d38->mUnk_14 == 1) == 0) { + bVar2 = false; + } + } + + if (bVar2) { + uVar4 = 1; + } + } + + return uVar4; +} + +ARM bool UnkStruct_020397f8::func_0203c13c() { + if (this->func_02032fa4() == 0) { + data_ov000_020eec9c.func_ov000_020d77e4(6); + data_027e103c->func_ov000_020cfb20(this); + this->mUnk_585 = 1; + this->mUnk_584 = 1; + this->mUnk_128.mUnk_18 = 0x00016000; + this->mUnk_128.mUnk_1c = NULL; + this->mUnk_128.mUnk_20 = 0; + this->mUnk_128.mUnk_24 = 0; + + return true; + } + + return false; +} + +// non-matching +ARM bool UnkStruct_020397f8::func_0203c1a0() { + s8 *pVar1; + u8 *iVar3; + + if ((data_02056be4[data_027e077c.mUnk_0] & 1) == 0) { + this->mUnk_584 = 1; + + pVar1 = (s8 *) data_027e103c->func_ov000_020cef9c(); + iVar3 = data_027e0f7c.func_ov000_0209d90c(pVar1[0x24F], 0); + data_027e1054.func_ov003_020f4760(iVar3[1], 0); + data_ov000_020eec9c.func_ov000_020d77e4(6); + data_027e103c->func_ov000_020cfb58(); + + this->mUnk_128.mUnk_18 = 0x0000A000; + this->mUnk_128.mUnk_1c = this->func_0203c25c; + this->mUnk_128.mUnk_20 = this; + this->mUnk_128.mUnk_24 = 0; + + return 0; + } + + return 0; +} + +ARM bool UnkStruct_020397f8::func_0203c25c(UnkStruct_020397f8 *param1) { + if (data_027e1054.mUnk_00->mUnk_00->mUnk_95 != 0) { + return false; + } + + if ((data_02056be4[data_027e077c.mUnk_0] & 1) == 0) { + param1->mUnk_585 = 1; + param1->mUnk_128.mUnk_18 = 0x00016000; + param1->mUnk_128.mUnk_1c = NULL; + param1->mUnk_128.mUnk_20 = 0; + param1->mUnk_128.mUnk_24 = 0; + return true; + } + + return false; +} + +ARM UnkStruct_020397f8::~UnkStruct_020397f8() {} + +ARM bool UnkStruct_020397f8::vfunc_38() { + return true; +} diff --git a/src/Main/Unknown/UnkStruct_0203dae0.cpp b/src/Main/Unknown/UnkStruct_0203dae0.cpp index 5d19b0b3..880511ae 100644 --- a/src/Main/Unknown/UnkStruct_0203dae0.cpp +++ b/src/Main/Unknown/UnkStruct_0203dae0.cpp @@ -1,25 +1,192 @@ #include "Unknown/UnkStruct_0203dae0.hpp" +#include "System/SysNew.hpp" -UnkStruct_0203dae0::UnkStruct_0203dae0(u8 param1) {} -UnkStruct_0203dae0::~UnkStruct_0203dae0() {} -void UnkStruct_0203dae0::func_0203dc10(s32 param1) {} -bool UnkStruct_0203dae0::func_0203dc74(s32 param1, s32 param2) {} -bool UnkStruct_0203dae0::vfunc_14(s32 param1, s32 param2) {} -void UnkStruct_0203dae0::func_0203dcfc(u8 param1, unk32 param2, unk32 param3, s32 param4) {} -void UnkStruct_0203dae0::func_0203ddec() {} -void UnkStruct_0203dae0::func_0203ddfc() {} -void UnkStruct_0203dae0::func_0203de14() {} -s32 UnkStruct_0203dae0::func_0203de24() {} -bool UnkStruct_0203dae0::func_0203de58(s32 param1) {} -void UnkStruct_0203dae0::vfunc_10(u32 param1, unk32 param2) {} -void UnkStruct_0203dae0::vfunc_30() {} -bool UnkStruct_0203dae0::vfunc_28() {} -bool UnkStruct_0203dae0::func_0203e0f8(unk32 param1, s32 param2) {} -void UnkStruct_0203dae0::vfunc_2c() {} -bool UnkStruct_0203dae0::func_0203e1b0(unk32 param1, unk32 param2, s32 param3) {} -unk32 UnkStruct_0203dae0::vfunc_18(s32 param1) {} -void UnkStruct_0203dae0::vfunc_08(s32 param1, unk32 param2, s16 *param3, unk32 param4) {} -void UnkStruct_0203dae0::func_0203e2e8(s32 param1, s32 param2, unk32 param3, u32 param4) {} -void UnkStruct_0203dae0::func_0203e510(s32 *param1, s32 param2, s32 param3) {} -void UnkStruct_0203dae0::func_0203e62c(s32 *param1, s32 param2) {} -bool UnkStruct_0203dae0::func_0203e6e4(u32 param1, u32 param2, s32 param3) {} +extern u32 *data_027e0ce0[]; +extern "C" void Fill256(unk32, unk16 *, unk32, unk32); +extern "C" void func_0203fc78(u8, unk32 *, unk32 *); +extern "C" u16 func_0203d318(unk32, unk32); +extern "C" void func_020298b8(unk32 *, unk32, unk32, unk32, unk32); +extern "C" void func_02029830(unk32 *, unk32, unk32, unk32, unk32); +extern "C" unk32 func_0203d400(u8); +extern "C" void func_02035440(u8); + +class UnkStruct_02075dac { +public: + unk32 func_0203f9b8(void *); +}; +extern UnkStruct_02075dac data_02075dac; + +// non-matching +THUMB UnkStruct_0203dae0::UnkStruct_0203dae0(u8 param1) { + this->mUnk_114 = NULL; + this->mUnk_118 = -1; + this->mUnk_11c = 0; + this->mUnk_11e = 0; + this->mUnk_11f = 0; + this->mUnk_120 = 1; + this->mUnk_121 = param1; + this->mUnk_122 = 0; + + Fill256(0, &this->mUnk_54, 0xC0, 1); + + if (this->mUnk_121 == 0) { + this->mUnk_114 = new(data_027e0ce0[1], 4) UnkStruct_0203dae0_114(); + } else { + this->mUnk_114 = new(data_027e0ce0[1], 4) UnkStruct_0203dae0_114(); + } +} + +THUMB UnkStruct_0203dae0::~UnkStruct_0203dae0() { + if (this->mUnk_114 != NULL) { + delete this->mUnk_114; + this->mUnk_114 = NULL; + } +} + +// non-matching (regalloc) +ARM void UnkStruct_0203dae0::func_0203dc10(s32 param1) { + if (param1 != 0) { + if (this->mUnk_11c == 0x0) { + return; + } + + if (this->mUnk_114->vfunc_08(this) != 0) { + this->mUnk_10 = this->mUnk_114->func_0203d1b4(); + } + } else { + this->mUnk_114->vfunc_0c(); + } + + this->mUnk_122 = param1; +} + +ARM bool UnkStruct_0203dae0::func_0203dc74(s32 param1, s32 param2) { + this->func_0203ddfc(); + this->vfunc_14(param1, param2); + this->mUnk_11c = 0; + return true; +} + +ARM bool UnkStruct_0203dae0::vfunc_14(s32 param1, s32 param2) { + unk32 local_c; + unk32 local_10; + + local_c = param1; + local_10 = param2; + + func_0203fc78(this->func_02032fa4(), &local_c, &local_10); + this->UnkStruct_02032f0c::vfunc_14(local_c, local_10); + this->mUnk_10 = 0; + return true; +} + +// non-matching +ARM void UnkStruct_0203dae0::func_0203dcfc(u8 param1, unk32 param2, unk32 param3, s32 param4) { + unk32 *uVar5; + + this->mUnk_50 = param1; + this->vfunc_14(this->mUnk_4a, this->mUnk_4c); + this->mUnk_11c = func_0203d318(this->mUnk_10[0x1], this->mUnk_10[0x2]); + this->func_0203dc10(1); + + if (func_0203d400(this->UnkStruct_02032f0c::func_02032fa4()) != 0x0) { + uVar5 = this->func_0203ddec(); + func_020298b8(this->mUnk_10, *uVar5, this->mUnk_10[0x1], this->mUnk_10[0x2], 0x4); + } else { + uVar5 = this->func_0203ddec(); + func_02029830(this->mUnk_10, *uVar5, this->mUnk_10[0x1], this->mUnk_10[0x2], 0x4); + } + + this->mUnk_28 = this->mUnk_10; + this->mUnk_2c = this->mUnk_2c; // this->mUnk_2c = &(UnkStruct_MsgProc_Base_unk_2C*)this->mUnk_10; + this->mUnk_30 = param4; + this->mUnk_34 = 3; + this->vfunc_10(param3, 3); + + this->func_0203de58(param2); +} + +ARM unk32 *UnkStruct_0203dae0::func_0203ddec() { + return this->mUnk_114->func_0203d1b4(); +} + +ARM void UnkStruct_0203dae0::func_0203ddfc() { + this->mUnk_114->mUnk_04 = 0; + this->mUnk_11c = 0; +} + +ARM void UnkStruct_0203dae0::func_0203de14() { + //! TODO: class? + func_02035440(this->mUnk_50); +} + +// non-matching +ARM s32 UnkStruct_0203dae0::func_0203de24() { + if (func_0203d400(this->UnkStruct_02032f0c::func_02032fa4()) == 0x0) { + return this->mUnk_10[5] * this->mUnk_10[6] * 0x20; + } + + return this->mUnk_10[6] << 0xa; +} + +ARM bool UnkStruct_0203dae0::func_0203de58(s32 param1) {} + +ARM void UnkStruct_0203dae0::vfunc_10(u32 param1, unk32 param2) { + this->func_0203dc10(1, param2); + this->mUnk_11e = param1; + this->mUnk_118 = -1; + this->UnkStruct_02032f0c::vfunc_10(param1, -1); +} + +ARM void UnkStruct_0203dae0::vfunc_30() { + unk32 iVar2; + + iVar2 = this->mUnk_118; + this->mUnk_118 = data_02075dac.func_0203f9b8(this); + + if (this->mUnk_118 == iVar2) { + return; + } + + this->func_0203dc10(1); +} + +ARM bool UnkStruct_0203dae0::vfunc_28() { + if (this->mUnk_122 != 0) { + this->func_0203e0f8(); + this->func_0203dc10(0); + return true; + } + + return false; +} + +ARM bool UnkStruct_0203dae0::func_0203e0f8() {} + +ARM void UnkStruct_0203dae0::vfunc_2c() { + this->vfunc_30(); +} + +ARM bool UnkStruct_0203dae0::func_0203e1b0(unk32 param1, unk32 param2, s32 param3) {} + +ARM unk32 UnkStruct_0203dae0::vfunc_18(s32 param1) { + unk32 iVar1; + + iVar1 = this->UnkStruct_02032f0c::vfunc_18(param1); + + if (iVar1 != 0) { + this->func_0203dc10(1); + } + + return iVar1; +} + +ARM void UnkStruct_0203dae0::vfunc_08(s32 param1, unk32 param2, s16 *param3, unk32 param4) { + this->func_0203dc10(1); + this->UnkStruct_02032f0c::vfunc_08(param1, param2, param3, param4); +} + +ARM void UnkStruct_0203dae0::func_0203e2e8(s32 param1, s32 param2, unk32 param3, u32 param4) {} +ARM void UnkStruct_0203dae0::func_0203e510(s32 *param1, s32 param2, s32 param3) {} +ARM void UnkStruct_0203dae0::func_0203e62c(s32 *param1, s32 param2) {} +ARM bool UnkStruct_0203dae0::func_0203e6e4(u32 param1, u32 param2, s32 param3) {} |
