diff --git a/include/FileSelect/FileSelectOptions.hpp b/include/FileSelect/FileSelectOptions.hpp index a56ad418..91ccc5de 100644 --- a/include/FileSelect/FileSelectOptions.hpp +++ b/include/FileSelect/FileSelectOptions.hpp @@ -21,8 +21,8 @@ enum FSOptionsState_ { class UnkStruct_ov019_020d24c8_2C_24_FC3 { public: - /* 00 */ unk8 mUnk_00; - /* 01 */ unk8 mUnk_01; + /* 00 */ u8 mUnk_00; + /* 01 */ u8 mUnk_01; /* 02 */ UnkStruct_ov019_020d24c8_2C_24_FC3() {} @@ -75,7 +75,8 @@ public: /* 0FC0 */ u8 mUnk_FC0; /* 0FC1 */ u8 mUnk_FC1; /* 0FC2 */ u8 mUnk_FC2; - /* 0FC3 */ STRUCT_PAD(0xFC3, 0x103E); + /* 0FC3 */ UnkStruct_ov019_020d24c8_2C_24_FC3 mUnk_FC3[61]; + /* 103D */ unk8 mUnk_103D; // pad? /* 103E */ unk16 mUnk_103E; /* 1040 */ diff --git a/include/Save/SaveManager.hpp b/include/Save/SaveManager.hpp index 6265abc6..362e35bd 100644 --- a/include/Save/SaveManager.hpp +++ b/include/Save/SaveManager.hpp @@ -254,14 +254,19 @@ public: void func_ov019_020d15cc(); }; +struct SaveSub17_03 { + /* 00 */ u8 mUnk_00; + /* 01 */ u8 mUnk_01; + /* 02 */ +}; + class SaveSub17 { public: // /* 00 */ unk8 mUnk_00[0x7E]; /* 00 */ u8 mUnk_00; /* 01 */ u8 mUnk_01; /* 02 */ u8 mUnk_02; - /* 03 */ u8 mUnk_03; // bool? - /* 04 */ STRUCT_PAD(0x04, 0x7E); + /* 03 */ SaveSub17_03 mUnk_03[61]; /* 7E */ u16 mUnk_7E; }; diff --git a/include/Unknown/Common.hpp b/include/Unknown/Common.hpp index db9d2729..244064bb 100644 --- a/include/Unknown/Common.hpp +++ b/include/Unknown/Common.hpp @@ -470,6 +470,7 @@ public: class UnkSystem2_UnkSubSystem1_Base { public: + /* 00 (vtable) */ /* 04 */ GameModeLinkList mUnk_04; /* 0C */ void *mUnk_0C; /* 10 */ unk32 mButtonID; diff --git a/src/019_MainSelect/FileSelectMain.cpp b/src/019_MainSelect/FileSelectMain.cpp index 032256aa..f2e548f6 100644 --- a/src/019_MainSelect/FileSelectMain.cpp +++ b/src/019_MainSelect/FileSelectMain.cpp @@ -1544,20 +1544,22 @@ ARM void FileSelectMain::func_ov019_020cb2dc() { this->mUnk_0B24.func_ov000_02062f30(); } -struct struct_stack_020cb324 { - unk32 mUnk_00; - unk8 mUnk_04; - unk8 mUnk_05; - unk16 mUnk_06; +struct stack_struct { + /* 00 */ unk16 mUnk_00; + /* 02 */ unk16 mUnk_02; + /* 04 */ unk8 mUnk_04; + /* 05 */ unk8 mUnk_05; + /* 06 */ u16 mUnk_06; + /* 08 */ }; // non-matching ARM void FileSelectMain::func_ov019_020cb324() { Vec2s local_34; Vec2s local_30; - struct_stack_020cb324 auStack_24; - Vec2s sStack_1c; - Vec2s sStack_18; + stack_struct auStack_24; + volatile Vec2s sStack_1c; + volatile Vec2s sStack_18; this->mUnk_0160.func_ov000_02062f30(); this->GetUnk03E0().func_ov019_020cbc0c(); @@ -1582,17 +1584,17 @@ ARM void FileSelectMain::func_ov019_020cb324() { auStack_24.mUnk_06 = 0; MI_CpuFill32(0, &auStack_24, sizeof(auStack_24)); - auStack_24.mUnk_05 = 0xFF; + auStack_24.mUnk_05 = -1; auStack_24.mUnk_06 |= 0x04; local_30.x = this->mUnk_1144.mUnk_5C.x + sStack_18.x; local_30.y = this->mUnk_1144.mUnk_5C.y + sStack_18.y; - data_0204af1c.func_0201aad0(&this->mUnk_1144, &local_30, 0, &auStack_24); + data_0204af1c.func_0201aad0(&this->mUnk_1144, (void *) &local_30, 0, &auStack_24); // data_0204af1c.func_0201aad0(&this->mUnk_1144,&local_30,0, 0); local_34.x = this->mUnk_155C.mUnk_5C.x + sStack_1c.x; local_34.y = this->mUnk_155C.mUnk_5C.y + sStack_1c.y; - data_0204af1c.func_0201aad0(&this->mUnk_155C, &local_34, 0, &auStack_24); + data_0204af1c.func_0201aad0(&this->mUnk_155C, (void *) &local_34, 0, &auStack_24); // data_0204af1c.func_0201aad0(&this->mUnk_155C,&local_34,0, 0); } diff --git a/src/019_MainSelect/FileSelectMicTest.cpp b/src/019_MainSelect/FileSelectMicTest.cpp index ca4b42cc..f4f4c31b 100644 --- a/src/019_MainSelect/FileSelectMicTest.cpp +++ b/src/019_MainSelect/FileSelectMicTest.cpp @@ -9,13 +9,13 @@ extern "C" { unk32 func_01ffb428(unk32, unk32); -void func_ov000_02062e44(void *param1, void *param2); +void func_ov000_02062e44(Vec2s *param1, void *param2); unk8 func_ov000_02070164(void *); //! TODO: turn to a class }; class UnkStruct_ov019_020d2248 { public: - s16 mUnk_00; + u16 mUnk_00; Vec2s mUnk_02; Vec2s mUnk_06; Vec2s mUnk_0A; @@ -48,7 +48,6 @@ ARM OptionsManagerAssessor::~OptionsManagerAssessor() { gpFSOptionsManager = NULL; } -// non-matching ARM FileSelectMicTest::FileSelectMicTest() : mState(FSMicTestState_OptionsIdle), mUnk_020(0x8D, 0x00), @@ -61,16 +60,18 @@ ARM FileSelectMicTest::FileSelectMicTest() : this->mUnk_3F8.mUnk_14E = 1; this->mUnk_3F8.func_0201f730(0x00020043); - Vec2s local_1c; - Vec2s local_18; + volatile Vec2us result; + Vec2s fetch; + Vec2s *pFetch = (Vec2s *) &fetch; // yes the cast is required because why not after all... - func_ov000_02062e44(&local_1c, &this->mUnk_304.mUnk_044.mUnk_04); + func_ov000_02062e44(pFetch, &this->mUnk_304.mUnk_044); - local_18.x = local_1c.x + data_ov019_020d2248.mUnk_06.x; - local_18.y = local_1c.y + data_ov019_020d2248.mUnk_06.y; + result.x = pFetch->x + data_ov019_020d2248.mUnk_02.x; + result.y = pFetch->y + data_ov019_020d2248.mUnk_02.y; + + this->mUnk_304.mUnk_044.mPos.x = result.x; + this->mUnk_304.mUnk_044.mPos.y = result.y; - this->mUnk_304.mUnk_044.mPos.x = local_18.x; - this->mUnk_304.mUnk_044.mPos.y = local_18.y; this->func_ov019_020cea74(); } @@ -89,16 +90,16 @@ ARM void FileSelectMicTest::func_ov019_020cea74() { // non-matching ARM void FileSelectMicTest::func_ov019_020ceaac() { - Vec2s local_44; - Vec2s local_40; Vec2s local_34; Vec2s local_38; local_34.x = data_ov019_020d2248.mUnk_10.x; - local_34.y = data_ov019_020d2248.mUnk_10.y; local_38.x = 0; + + local_34.y = data_ov019_020d2248.mUnk_10.y; local_38.y = 0; - this->mUnk_304.func_0201e874(0x0C, &local_34, &local_38, 0); + + this->mUnk_304.func_0201e874(0x0C, (void *) &local_34, (void *) &local_38, 0); this->mUnk_304.mUnk_000.mUnk_0A = true; this->mUnk_304.mUnk_000.mUnk_0B = false; @@ -109,18 +110,27 @@ ARM void FileSelectMicTest::func_ov019_020ceaac() { this->mUnk_304.mUnk_000.mUnk_0C = true; } - UnkStruct_ov019_020d24c8_28_258 local_30(0x8D, 0x01); - func_0201e8d4(&local_40, &this->mUnk_304); - this->mUnk_270.mUnk_8E.x = local_30.mPos.x + local_40.x; - this->mUnk_270.mUnk_8E.y = local_30.mPos.y + local_40.y; + { + UnkStruct_ov019_020d24c8_28_258 local_30(0x8D, 0x01); + + volatile Vec2us result; + Vec2s fetch; + + func_0201e8d4(&fetch, &this->mUnk_304); + + result.x = local_30.mPos.x + fetch.x; + result.y = local_30.mPos.y + fetch.y; + + this->mUnk_270.mUnk_8E.x = result.x; + this->mUnk_270.mUnk_8E.y = result.y; + } + + Vec2s local_44; func_ov000_02062e44(&local_44, &this->mUnk_304.mUnk_044); this->mUnk_304.mUnk_0A4.func_ov000_0206415c(&local_44, 6, data_ov019_020d2248.mUnk_00, 0); } -// non-matching ARM void FileSelectMicTest::func_ov019_020cebcc() { - Vec2s local_10; - Vec2s local_14; this->mUnk_304.mUnk_000.mUnk_0A = false; this->mUnk_304.mUnk_000.mUnk_0B = true; @@ -132,10 +142,17 @@ ARM void FileSelectMicTest::func_ov019_020cebcc() { } this->mUnk_270.func_ov019_020cf130(); - func_ov000_02062e44(&local_14, &this->mUnk_304.mUnk_044); - local_10.y = local_14.y + data_ov019_020d2248.mUnk_02.y; - local_10.x = local_14.x + data_ov019_020d2248.mUnk_02.x; - this->mUnk_304.mUnk_0A4.func_ov000_0206415c(&local_10, 7, data_ov019_020d2248.mUnk_00, 0); + + volatile Vec2s result; // not necessary, here for consistency + Vec2s fetch; + Vec2s *pFetch = (Vec2s *) &fetch; + + func_ov000_02062e44(pFetch, &this->mUnk_304.mUnk_044); + + result.y = pFetch->y + data_ov019_020d2248.mUnk_02.y; + result.x = pFetch->x + data_ov019_020d2248.mUnk_02.x; + + this->mUnk_304.mUnk_0A4.func_ov000_0206415c((void *) &result, 7, data_ov019_020d2248.mUnk_00, 0); } ARM void FileSelectMicTest::vfunc_08(Input *pButtons, TouchControl *pTouchControl) { @@ -165,12 +182,18 @@ ARM void FileSelectMicTest::vfunc_08(Input *pButtons, TouchControl *pTouchContro if (this->mState - 1 <= FSMicTestState_OptionsToMicTest) { this->mUnk_304.mUnk_000.UnkOperations(NULL, false); - UnkStruct_ov019_020d24c8_28_258 local_30(0x8D, 0x01); - Vec2s local_5c; - Vec2s local_58; - func_0201e8d4(&local_58, &this->mUnk_304); - this->mUnk_270.mUnk_8E.x = local_58.x + local_30.mPos.x - local_5c.x; - this->mUnk_270.mUnk_8E.y = local_58.y + local_30.mPos.y - local_5c.y; + UnkStruct_ov019_020d24c8_28_258 local_2c(0x8D, 0x01); + + volatile Vec2us result; + Vec2s fetch; + func_0201e8d4(&fetch, &this->mUnk_304); + + result.x = local_2c.mPos.x + fetch.x; + result.y = local_2c.mPos.y + fetch.y; + + this->mUnk_270.mUnk_8E.x = result.x; + this->mUnk_270.mUnk_8E.y = result.y; + this->mUnk_304.mUnk_0A4.func_ov000_02063f64(); } diff --git a/src/019_MainSelect/FileSelectOptions.cpp b/src/019_MainSelect/FileSelectOptions.cpp index d7018dac..5a9a2324 100644 --- a/src/019_MainSelect/FileSelectOptions.cpp +++ b/src/019_MainSelect/FileSelectOptions.cpp @@ -617,11 +617,22 @@ ARM UnkStruct_ov019_020d24c8_2C_24::UnkStruct_ov019_020d24c8_2C_24(GameModeManag mUnk_FB8(NULL), mUnk_FBC(NULL) { - SaveSub17 *pSaveSub17 = gSaveManager.GetSaveSlot(this->mSaveSlotIndex)->Get2600Ptr(); + SaveSlot *pSlot = gSaveManager.GetSaveSlot(this->mSaveSlotIndex); + SaveSub17 *pSaveSub17 = pSlot->Get2600Ptr(); this->mUnk_FC0 = pSaveSub17->mUnk_00; this->mUnk_FC1 = pSaveSub17->mUnk_01; this->mUnk_FC2 = pSaveSub17->mUnk_02; - this->mUnk_103E = pSaveSub17[1].mUnk_00; + + u8 *src = (u8 *) pSaveSub17->mUnk_03; + u8 *dst = (u8 *) &this->mUnk_FC3[0]; + for (u32 i = ARRAY_LEN(this->mUnk_FC3); i != 0; i--) { + u8 b1 = *src++; + u8 b2 = *src++; + this->mUnk_FC3[i].mUnk_00 = b1; + this->mUnk_FC3[i].mUnk_01 = b2; + } + this->mUnk_FC3[0].mUnk_00 = *src; + this->mUnk_103E = pSaveSub17->mUnk_7E; param1->mList.func_020166cc(&this->mUnk_490.mUnk_04); param1->mList.func_020166cc(&this->mUnk_4F0.mUnk_04); @@ -738,6 +749,15 @@ ARM void UnkStruct_ov019_020d24c8_2C_24::func_ov019_020ce414() { } } +struct stack_struct { + /* 00 */ unk16 mUnk_00; + /* 02 */ unk16 mUnk_02; + /* 04 */ unk8 mUnk_04; + /* 05 */ unk8 mUnk_05; + /* 06 */ u16 mUnk_06; + /* 08 */ +}; + // non-matching ARM void UnkStruct_ov019_020d24c8_2C_24::func_ov019_020ce4dc() { for (int i = 0; i < ARRAY_LEN(this->mUnk_FB0->mUnk_00); i++) { @@ -761,24 +781,30 @@ ARM void UnkStruct_ov019_020d24c8_2C_24::func_ov019_020ce4dc() { for (int i = 0; i < ARRAY_LEN(this->mUnk_FB8->mUnk_00); i++) { UnkSystem2_UnkSubSystem1_Derived1 *ptr = this->mUnk_FB8->mUnk_00[i]; - Vec2s local_2c; - Vec2s local_30; - local_2c.x = this->mUnk_008.mPos.x; - local_2c.y = this->mUnk_008.mPos.y; + Vec2s sVar1_2; + sVar1_2.x = this->mUnk_008.mPos.x; + sVar1_2.y = this->mUnk_008.mPos.y; - func_ov000_02062e44(&local_30, ptr); + volatile Vec2s result; + Vec2s fetch; - ptr->mPos.x = this->mUnk_004.x + local_30.x + local_2c.x; - ptr->mPos.y = this->mUnk_004.y + local_30.y + local_2c.y; + func_ov000_02062e44(&fetch, ptr); + + result.x = this->mUnk_004.x; + result.y = this->mUnk_004.y; + + ptr->mPos.x = result.x + fetch.x - sVar1_2.x; + ptr->mPos.y = result.y + fetch.y - sVar1_2.y; } - u8 auStack_28[8]; - auStack_28[6] = 0; - MI_CpuFill32(0, auStack_28, 8); - auStack_28[7] = 0xFF; - auStack_28[6] |= 4; - data_0204af1c.func_0201aa44(&this->mUnk_008, &this->mUnk_004, 2, auStack_28); + stack_struct sp8; + sp8.mUnk_06 = 0x00; + MI_CpuFill32(0, &sp8, sizeof(sp8)); + sp8.mUnk_05 = -1; + sp8.mUnk_06 |= 0x04; + + data_0204af1c.func_0201aa44(&this->mUnk_008, &this->mUnk_004, 2, &sp8); } ARM void UnkStruct_ov019_020d24c8_2C_24::func_ov019_020ce61c(bool decrement) {