From e5a20e19c6db76751943310bc91935628e58ba6c Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 24 Nov 2024 17:06:40 +0100 Subject: [PATCH] Small progress --- config/SOUE01/splits.txt | 2 + config/SOUE01/symbols.txt | 14 +-- include/d/lyt/d_lyt_map.h | 69 +++++++++++---- src/d/lyt/d_lyt_map.cpp | 177 +++++++++++++++++++++++++++++++++++--- 4 files changed, 225 insertions(+), 37 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index d11ec110..749a890d 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -423,7 +423,9 @@ d/lyt/d_lyt_map_capture.cpp: d/lyt/d_lyt_map.cpp: .text start:0x8012DC30 end:0x80148DE8 .ctors start:0x804DB76C end:0x804DB770 + .rodata start:0x804E76A0 end:0x804E7F50 .data start:0x8051EAE0 end:0x805225E8 + .sdata2 start:0x80579F40 end:0x80579FB8 .bss start:0x805AF470 end:0x805B0830 d/lyt/d_lyt_note.cpp: diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index bc43e7bd..14896863 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -7547,12 +7547,12 @@ __dt__85sStateMgr_c<16dLytMapPinIcon_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13s __dt__32sFStateFct_c<16dLytMapPinIcon_c>Fv = .text:0x8012F050; // type:function size:0x6C __dt__29sFState_c<16dLytMapPinIcon_c>Fv = .text:0x8012F0C0; // type:function size:0x58 fn_8012F120 = .text:0x8012F120; // type:function size:0x8 -fn_8012F130 = .text:0x8012F130; // type:function size:0x17C +build__16dLytMapPinIcon_cFPQ23d2d10ResAccIf_c = .text:0x8012F130; // type:function size:0x17C fn_8012F2B0 = .text:0x8012F2B0; // type:function size:0x6C -fn_8012F320 = .text:0x8012F320; // type:function size:0x60 -fn_8012F380 = .text:0x8012F380; // type:function size:0xE4 +remove__16dLytMapPinIcon_cFv = .text:0x8012F320; // type:function size:0x60 +execute__16dLytMapPinIcon_cFv = .text:0x8012F380; // type:function size:0xE4 executeState__85sStateMgr_c<16dLytMapPinIcon_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x8012F470; // type:function size:0x10 -fn_8012F480 = .text:0x8012F480; // type:function size:0x34 +draw__16dLytMapPinIcon_cFv = .text:0x8012F480; // type:function size:0x34 initializeState_Wait__25dLytMapPinIconAggregate_cFv = .text:0x8012F4C0; // type:function size:0x4 executeState_Wait__25dLytMapPinIconAggregate_cFv = .text:0x8012F4D0; // type:function size:0xD8 getStateID__85sStateMgr_c<16dLytMapPinIcon_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x8012F5B0; // type:function size:0x10 @@ -7615,7 +7615,7 @@ __dt__56sFStateMgr_c<17dLytMapFloorBtn_c,20sStateMethodUsr_FI_c>Fv = .text:0x801 __dt__86sStateMgr_c<17dLytMapFloorBtn_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x80130800; // type:function size:0xA0 __dt__33sFStateFct_c<17dLytMapFloorBtn_c>Fv = .text:0x801308A0; // type:function size:0x6C __dt__30sFState_c<17dLytMapFloorBtn_c>Fv = .text:0x80130910; // type:function size:0x58 -fn_80130970 = .text:0x80130970; // type:function size:0xA0 +__dt__20LytMapFourAnimGroupsFv = .text:0x80130970; // type:function size:0xA0 __dt__59sFStateMgr_c<20dLytMapFloorBtnMgr_c,20sStateMethodUsr_FI_c>Fv = .text:0x80130A10; // type:function size:0xA4 __dt__89sStateMgr_c<20dLytMapFloorBtnMgr_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x80130AC0; // type:function size:0xA0 __dt__36sFStateFct_c<20dLytMapFloorBtnMgr_c>Fv = .text:0x80130B60; // type:function size:0x6C @@ -7748,7 +7748,7 @@ __dt__85sStateMgr_c<16dLytMapCapture_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13s __dt__55sFStateMgr_c<16dLytMapCapture_c,20sStateMethodUsr_FI_c>Fv = .text:0x80133F40; // type:function size:0xA4 __dt__16dLytMapCapture_cFv = .text:0x80133FF0; // type:function size:0xB4 __ct__20dLytMapFloorBtnMgr_cFPv = .text:0x801340B0; // type:function size:0x178 -fn_80134230 = .text:0x80134230; // type:function size:0x140 +__ct__20LytMapFourAnimGroupsFv = .text:0x80134230; // type:function size:0x140 __ct__Q23d2d11dLytStructDFv = .text:0x80134370; // type:function size:0x48 __ct__17dLytMapFloorBtn_cFv = .text:0x801343C0; // type:function size:0xAC __ct__25dLytMapPinIconAggregate_cFv = .text:0x80134470; // type:function size:0xF0 @@ -28298,7 +28298,7 @@ lbl_804E7620 = .rodata:0x804E7620; // type:object size:0x28 data:4byte lbl_804E7648 = .rodata:0x804E7648; // type:object size:0x20 data:4byte lbl_804E7668 = .rodata:0x804E7668; // type:object size:0x20 data:4byte lbl_804E7688 = .rodata:0x804E7688; // type:object size:0x18 data:4byte -lbl_804E76A0 = .rodata:0x804E76A0; // type:object size:0x18 data:4byte +sMapPinIconBrlanMap = .rodata:0x804E76A0; // type:object size:0x18 data:4byte lbl_804E76B8 = .rodata:0x804E76B8; // type:object size:0x18 data:4byte lbl_804E76D0 = .rodata:0x804E76D0; // type:object size:0x10 data:4byte lbl_804E76E0 = .rodata:0x804E76E0; // type:object size:0x28 data:4byte diff --git a/include/d/lyt/d_lyt_map.h b/include/d/lyt/d_lyt_map.h index 807bd2e7..1bfee8e2 100644 --- a/include/d/lyt/d_lyt_map.h +++ b/include/d/lyt/d_lyt_map.h @@ -8,20 +8,48 @@ #include "egg/core/eggColorFader.h" #include "m/m2d.h" #include "m/m_vec.h" +#include "nw4r/lyt/lyt_bounding.h" #include "s/s_State.hpp" +struct LytMap0x80520B5C { + LytMap0x80520B5C() : field_0x04(false), field_0x05(false) {} + virtual ~LytMap0x80520B5C() {} + + bool field_0x04; + bool field_0x05; +}; + +struct LytMapFourAnimGroups { + /* 0x00 */ d2d::AnmGroup_c mGroup1; + /* 0x40 */ d2d::AnmGroup_c mGroup2; + /* 0x80 */ d2d::AnmGroup_c mGroup3; + /* 0xC0 */ d2d::AnmGroup_c mGroup4; +}; + // Size 0x1E0 class dLytMapPinIcon_c { public: friend class dLytMapPinIconAggregate_c; dLytMapPinIcon_c() - : mStateMgr(*this, sStateID::null), field_0x1B8(0), field_0x1BC(0), field_0x1C0(0.0f, 0.0f, 0.0f), - field_0x1CC(0), field_0x1D0(0), field_0x1D4(0), mIndex(0), field_0x1DC(0) {} - virtual ~dLytMapPinIcon_c() { - if (d2d::dLytStructDList::sInstance->fn_80065A30(&mStructD)) { - d2d::dLytStructDList::sInstance->removeFromList2(&mStructD); - } + : mStateMgr(*this, sStateID::null), mpBounding(nullptr), field_0x1BC(0), field_0x1C0(0.0f, 0.0f, 0.0f), + field_0x1CC(0), field_0x1D0(nullptr), field_0x1D4(0), mIndex(0), field_0x1DC(0) {} + virtual ~dLytMapPinIcon_c(); + + bool build(d2d::ResAccIf_c *resAcc); + bool remove(); + bool draw(); + bool execute(); + + void fn_8012EC30(); + + bool isSelect() const { + return *mStateMgr.getStateID() == dLytMapPinIcon_c::StateID_ToSelect || + *mStateMgr.getStateID() == dLytMapPinIcon_c::StateID_Select; + } + + bool isRemove() const { + return *mStateMgr.getStateID() == dLytMapPinIcon_c::StateID_Remove; } STATE_FUNC_DECLARE(dLytMapPinIcon_c, Wait); @@ -33,13 +61,13 @@ class dLytMapPinIcon_c { private: /* 0x004 */ UI_STATE_MGR_DECLARE(dLytMapPinIcon_c); /* 0x040 */ d2d::LytBase_c mLyt; - /* 0x0D0 */ d2d::AnmGroup_c mAnm[3]; + /* 0x0D0 */ d2d::AnmGroup_c mAnmGroups[3]; /* 0x190 */ d2d::dLytStructD mStructD; - /* 0x1B8 */ UNKWORD field_0x1B8; + /* 0x1B8 */ nw4r::lyt::Bounding *mpBounding; /* 0x1BC */ UNKWORD field_0x1BC; /* 0x1C0 */ mVec3_c field_0x1C0; /* 0x1CC */ u8 field_0x1CC; - /* 0x1D0 */ UNKWORD field_0x1D0; + /* 0x1D0 */ LytMap0x80520B5C *field_0x1D0; /* 0x1D4 */ UNKWORD field_0x1D4; /* 0x1D8 */ s32 mIndex; /* 0x1DC */ UNKWORD field_0x1DC; @@ -48,7 +76,7 @@ class dLytMapPinIcon_c { class dLytMapPinIconAggregate_c { public: dLytMapPinIconAggregate_c() : mStateMgr(*this, sStateID::null) { - field_0x9A0 = 0; + field_0x9A0 = nullptr; field_0x9A4 = 0; field_0x9A8 = 0; for (int i = 0; i < 5; i++) { @@ -57,6 +85,8 @@ class dLytMapPinIconAggregate_c { } virtual ~dLytMapPinIconAggregate_c() {} + bool remove(); + STATE_FUNC_DECLARE(dLytMapPinIconAggregate_c, Wait); STATE_FUNC_DECLARE(dLytMapPinIconAggregate_c, Select); STATE_FUNC_DECLARE(dLytMapPinIconAggregate_c, Remove); @@ -65,7 +95,7 @@ class dLytMapPinIconAggregate_c { /* 0x004 */ UI_STATE_MGR_DECLARE(dLytMapPinIconAggregate_c); /* 0x040 */ dLytMapPinIcon_c mPins[5]; - /* 0x9A0 */ UNKWORD field_0x9A0; + /* 0x9A0 */ LytMap0x80520B5C *field_0x9A0; /* 0x9A4 */ UNKWORD field_0x9A4; /* 0x9A8 */ UNKWORD field_0x9A8; }; @@ -101,7 +131,7 @@ class dLytMapFloorBtn_c { class dLytMapFloorBtnMgr_c : public d2d::dSubPane { public: dLytMapFloorBtnMgr_c(void *arg) : field_0x008(arg), mStateMgr(*this, sStateID::null) {} - virtual ~dLytMapFloorBtnMgr_c() {} + virtual ~dLytMapFloorBtnMgr_c(); virtual bool build(d2d::ResAccIf_c *resAcc) override; virtual bool remove() override; @@ -123,8 +153,9 @@ class dLytMapFloorBtnMgr_c : public d2d::dSubPane { /* 0x008 */ void *field_0x008; /* 0x00C */ UI_STATE_MGR_DECLARE(dLytMapFloorBtnMgr_c); /* 0x048 */ d2d::dLytSub mLyt; - /* 0x0DC */ d2d::AnmGroup_c mAnm[1]; - /* 0x11C */ // unk array + /* 0x0DC */ d2d::AnmGroup_c mAnmGroups[1]; + /* 0x11C */ LytMapFourAnimGroups mMoreGroups[4]; + /* 0x51C */ u8 field_0x51C[0x520 - 0x51C]; /* 0x520 */ d2d::dLytStructD mStructDs[4]; /* 0x5C0 */ dLytMapFloorBtn_c mFloorBtns[4]; }; @@ -143,7 +174,7 @@ class dLytMapPopupInfo_c { private: /* 0x000 */ UI_STATE_MGR_DECLARE(dLytMapPopupInfo_c); /* 0x03C */ d2d::LytBase_c mLyt; - /* 0x0CC */ d2d::AnmGroup_c mAnm[3]; + /* 0x0CC */ d2d::AnmGroup_c mAnmGroups[3]; }; // Size 0x4C @@ -169,7 +200,7 @@ class dLytMapSavePopup_c { private: /* 0x000 */ d2d::LytBase_c mLyt; - /* 0x090 */ d2d::AnmGroup_c mAnm[2]; + /* 0x090 */ d2d::AnmGroup_c mAnmGroups[2]; /* 0x110 */ dLytMapSavePopupAction_c mActions[12]; }; @@ -185,7 +216,7 @@ class dLytMapSaveCaption_c { private: /* 0x000 */ UI_STATE_MGR_DECLARE(dLytMapSaveCaption_c); /* 0x03C */ d2d::LytBase_c mLyt; - /* 0x0CC */ d2d::AnmGroup_c mAnm[5]; + /* 0x0CC */ d2d::AnmGroup_c mAnmGroups[5]; }; // Size 0x190 @@ -202,7 +233,7 @@ class dLytMapSaveObj_c { private: /* 0x000 */ UI_STATE_MGR_DECLARE(dLytMapSaveObj_c); /* 0x03C */ d2d::LytBase_c mLyt; - /* 0x0CC */ d2d::AnmGroup_c mAnm[3]; + /* 0x0CC */ d2d::AnmGroup_c mAnmGroups[3]; /* 0x18C */ u8 field_0x18C; /* 0x18D */ u8 field_0x18D; /* 0x18E */ u8 field_0x18E; @@ -264,7 +295,7 @@ class dLytMapMain_c : public m2d::Base_c { /* 0x00A4 */ u8 field_0x00A4[0x010C - 0x00A4]; /* 0x010C */ d2d::LytBase_c mLyt; /* 0x019C */ d2d::AnmGroup_c mAnmGroups[54]; - /* 0x0F1C */ u8 field_0x0F1C[0x0F24 - 0x0F1C]; + /* 0x0F1C */ LytMap0x80520B5C field_0xF1C; /* 0x0F24 */ dLytMapCapture_c mMapCapture; /* 0x0FA0 */ dLytMapFloorBtnMgr_c mFloorBtnMgr; /* 0x16B4 */ dLytMapPinIconAggregate_c mPinIconAggregate; diff --git a/src/d/lyt/d_lyt_map.cpp b/src/d/lyt/d_lyt_map.cpp index 855a3639..0de1ef91 100644 --- a/src/d/lyt/d_lyt_map.cpp +++ b/src/d/lyt/d_lyt_map.cpp @@ -1,5 +1,8 @@ #include "d/lyt/d_lyt_map.h" +#include "common.h" +#include "d/lyt/d2d.h" +#include "d/lyt/d_structd.h" #include "egg/core/eggColorFader.h" #include "m/m_video.h" #include "sized_string.h" @@ -174,36 +177,178 @@ void dLytMapFader_c::draw() { mFader.draw(); } -void dLytMapPinIcon_c::initializeState_Wait() {} -void dLytMapPinIcon_c::executeState_Wait() {} +#define LYT_MAP_PIN_ICON_ANIM_SCALE 0 +#define LYT_MAP_PIN_ICON_ANIM_ERASE 1 +#define LYT_MAP_PIN_ICON_ANIM_LOOP 2 + +void dLytMapPinIcon_c::initializeState_Wait() { + mLyt.calc(); +} +void dLytMapPinIcon_c::executeState_Wait() { + bool keepGoing = false; + if (field_0x1D0 != nullptr) { + keepGoing = !field_0x1D0->field_0x04; + } + if (!keepGoing) { + return; + } + + if (field_0x1CC == 0) { + return; + } + + if (field_0x1BC == 0) { + return; + } + + mStateMgr.changeState(StateID_ToSelect); +} void dLytMapPinIcon_c::finalizeState_Wait() {} -void dLytMapPinIcon_c::initializeState_ToSelect() {} -void dLytMapPinIcon_c::executeState_ToSelect() {} -void dLytMapPinIcon_c::finalizeState_ToSelect() {} +void dLytMapPinIcon_c::initializeState_ToSelect() { + d2d::AnmGroup_c *m = &mAnmGroups[1]; + m->setDirection(false); + m->setFrame(0.0f); +} +void dLytMapPinIcon_c::executeState_ToSelect() { + mStateMgr.changeState(StateID_Select); +} +void dLytMapPinIcon_c::finalizeState_ToSelect() { + field_0x1D0->field_0x04 = true; +} void dLytMapPinIcon_c::initializeState_Select() {} void dLytMapPinIcon_c::executeState_Select() {} void dLytMapPinIcon_c::finalizeState_Select() {} void dLytMapPinIcon_c::initializeState_ToUnselect() {} -void dLytMapPinIcon_c::executeState_ToUnselect() {} -void dLytMapPinIcon_c::finalizeState_ToUnselect() {} +void dLytMapPinIcon_c::executeState_ToUnselect() { + mStateMgr.changeState(StateID_Wait); +} +void dLytMapPinIcon_c::finalizeState_ToUnselect() { + field_0x1D0->field_0x04 = false; +} void dLytMapPinIcon_c::initializeState_Remove() {} -void dLytMapPinIcon_c::executeState_Remove() {} +void dLytMapPinIcon_c::executeState_Remove() { + mStateMgr.changeState(StateID_Wait); +} void dLytMapPinIcon_c::finalizeState_Remove() {} +dLytMapPinIcon_c::~dLytMapPinIcon_c() { + if (d2d::dLytStructDList::sInstance->fn_80065A30(&mStructD)) { + d2d::dLytStructDList::sInstance->removeFromList2(&mStructD); + } +} + +static const d2d::LytBrlanMapping sMapPinIconBrlanMap[] = { + {"mapPutIcon_00_scale.brlan", "G_scale_00"}, + {"mapPutIcon_00_erase.brlan", "G_scale_00"}, + { "mapPutIcon_00_loop.brlan", "G_scale_00"}, +}; + +bool dLytMapPinIcon_c::build(d2d::ResAccIf_c *resAcc) { + mLyt.setResAcc(resAcc); + mLyt.build("mapPutIcon_00.brlyt", nullptr); + + d2d::AnmGroup_c *pAnmGroups = mAnmGroups; + + for (int i = 0; i < 3; i++) { + pAnmGroups[i].init(sMapPinIconBrlanMap[i].mFile, resAcc, mLyt.getLayout(), sMapPinIconBrlanMap[i].mName); + pAnmGroups[i].setDirection(false); + pAnmGroups[i].setFrame(0.0f); + } + + mLyt.calc(); + + for (int i = 0; i < 3; i++) { + pAnmGroups[i].unbind(); + } + + mpBounding = mLyt.findBounding("B_mark_00"); + mStructD.fn_80065E70(mpBounding, 2, 1, 0); + d2d::dLytStructDList::sInstance->appendToList2(&mStructD); + + mAnmGroups[LYT_MAP_PIN_ICON_ANIM_SCALE].setDirection(false); + mAnmGroups[LYT_MAP_PIN_ICON_ANIM_LOOP].setDirection(false); + + mLyt.calc(); + + mStateMgr.changeState(StateID_Wait); + field_0x1BC = 0; + field_0x1CC = 0; + field_0x1DC = 0; + return true; +} + +bool dLytMapPinIcon_c::remove() { + d2d::dLytStructDList::sInstance->removeFromList2(&mStructD); + for (int i = 0; i < 3; i++) { + mAnmGroups[i].afterUnbind(); + } + return true; +} + +bool dLytMapPinIcon_c::execute() { + fn_8012EC30(); + mStateMgr.executeState(); + field_0x1BC = 0; + mAnmGroups[2].setFrame(field_0x1DC); + // TODO something MapCapture + mLyt.calc(); + mStructD.field_0x22 = 0; + mStructD.fn_80065F70(); + return true; +} + +bool dLytMapPinIcon_c::draw() { + mLyt.draw(); + return true; +} + void dLytMapPinIconAggregate_c::initializeState_Wait() {} -void dLytMapPinIconAggregate_c::executeState_Wait() {} +void dLytMapPinIconAggregate_c::executeState_Wait() { + for (int i = 0; i < 5; i++) { + if (mPins[i].isSelect()) { + mStateMgr.changeState(StateID_Select); + } + } +} void dLytMapPinIconAggregate_c::finalizeState_Wait() {} void dLytMapPinIconAggregate_c::initializeState_Select() {} -void dLytMapPinIconAggregate_c::executeState_Select() {} +void dLytMapPinIconAggregate_c::executeState_Select() { + bool anyRemove = false; + for (int i = 0; i < 5; i++) { + if (mPins[i].isRemove()) { + mStateMgr.changeState(StateID_Remove); + anyRemove = true; + // a bit convoluted, an early return would've done the trick + break; + } + } + + if (!anyRemove) { + bool allSelect = true; + for (int i = 0; i < 5; i++) { + if (mPins[i].isSelect()) { + allSelect = false; + break; + } + } + + if (allSelect) { + mStateMgr.changeState(StateID_Wait); + } + } +} void dLytMapPinIconAggregate_c::finalizeState_Select() {} void dLytMapPinIconAggregate_c::initializeState_Remove() {} -void dLytMapPinIconAggregate_c::executeState_Remove() {} +void dLytMapPinIconAggregate_c::executeState_Remove() { + field_0x9A0->field_0x04 = false; + mStateMgr.changeState(StateID_Wait); +} void dLytMapPinIconAggregate_c::finalizeState_Remove() {} void dLytMapFloorBtn_c::initializeState_Wait() {} @@ -250,6 +395,16 @@ void dLytMapFloorBtnMgr_c::initializeState_Wait() {} void dLytMapFloorBtnMgr_c::executeState_Wait() {} void dLytMapFloorBtnMgr_c::finalizeState_Wait() {} +extern "C" void fn_801942F0(int, int); +dLytMapFloorBtnMgr_c::~dLytMapFloorBtnMgr_c() { + for (int i = 0; i < 4; i++) { + if (d2d::dLytStructDList::sInstance->fn_80065A30(&mStructDs[i])) { + d2d::dLytStructDList::sInstance->removeFromList2(&mStructDs[i]); + } + } + fn_801942F0(0, 0); +} + void dLytMapPopupInfo_c::initializeState_Invisible() {} void dLytMapPopupInfo_c::executeState_Invisible() {} void dLytMapPopupInfo_c::finalizeState_Invisible() {}