From 6cc3cfaadcab3d1bb92496c081a92603ef1dd585 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 28 Sep 2025 01:33:33 +0200 Subject: [PATCH] d_lyt_map_global OK --- config/SOUE01/splits.txt | 10 ++-- config/SOUE01/symbols.txt | 20 +++---- configure.py | 1 + include/d/lyt/d2d.h | 4 ++ include/d/lyt/d_lyt_map.h | 8 ++- include/d/lyt/d_lyt_map_capture.h | 3 +- include/d/lyt/d_lyt_map_global.h | 53 +++++++++++++++++++ src/d/lyt/d_lyt_map.cpp | 41 +++++++++++--- src/d/lyt/d_lyt_map_global.cpp | 88 +++++++++++++++++++++++++++++++ 9 files changed, 206 insertions(+), 22 deletions(-) create mode 100644 include/d/lyt/d_lyt_map_global.h create mode 100644 src/d/lyt/d_lyt_map_global.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 56c714be..87539e84 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -908,12 +908,16 @@ d/lyt/d_lyt_auto_explain.cpp: .sdata2 start:0x80579F10 end:0x80579F28 .bss start:0x805AF2F0 end:0x805AF3F0 +d/lyt/d_lyt_map_global.cpp: + .text start:0x8012D190 end:0x8012D4A8 align:16 + .sbss start:0x805754A0 end:0x805754A8 + .sdata2 start:0x80579F28 end:0x80579F30 + d/lyt/d_lyt_map_capture.cpp: - .text start:0x8012D190 end:0x8012DC28 align:16 + .text start:0x8012D4B0 end:0x8012DC28 align:16 .ctors start:0x804DB768 end:0x804DB76C .data start:0x8051EA08 end:0x8051EAE0 - .sbss start:0x805754A0 end:0x805754A8 - .sdata2 start:0x80579F28 end:0x80579F40 + .sdata2 start:0x80579F30 end:0x80579F40 .bss start:0x805AF3F0 end:0x805AF470 d/lyt/d_lyt_map.cpp: diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index ff5d9b53..c55ae48b 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -7474,13 +7474,13 @@ getTextBox__17dLytAutoExplain_cFv = .text:0x8012CD50; // type:function size:0x8 __sinit_\d_lyt_auto_explain_cpp = .text:0x8012CD60; // type:function size:0x338 scope:local __dt__32sFStateID_c<17dLytAutoExplain_c>Fv = .text:0x8012D0A0; // type:function size:0x58 scope:weak isSameName__32sFStateID_c<17dLytAutoExplain_c>CFPCc = .text:0x8012D100; // type:function size:0x88 scope:weak -fn_8012D190 = .text:0x8012D190; // type:function size:0x68 -fn_8012D200 = .text:0x8012D200; // type:function size:0x108 -projectForMapMaybe = .text:0x8012D310; // type:function size:0x18 -fn_8012D330 = .text:0x8012D330; // type:function size:0x1C -fn_8012D350 = .text:0x8012D350; // type:function size:0x1C -fn_8012D370 = .text:0x8012D370; // type:function size:0x1C -fn_8012D390 = .text:0x8012D390; // type:function size:0x118 +__ct__15dLytMapGlobal_cFv = .text:0x8012D190; // type:function size:0x68 +projectOntoMap__15dLytMapGlobal_cCFR7mVec2_cRC7mVec3_cRC7mVec3_cRC7mVec3_cRC4mAngff = .text:0x8012D200; // type:function size:0x108 +projectOntoMap__15dLytMapGlobal_cCFR7mVec2_cRC7mVec3_c = .text:0x8012D310; // type:function size:0x18 +unprojectFromMap__15dLytMapGlobal_cCFR7mVec3_cRC7mVec2_c = .text:0x8012D330; // type:function size:0x1C +unprojectFromMap__15dLytMapGlobal_cCFR7mVec3_cRC7mVec2_cRC4mAng = .text:0x8012D350; // type:function size:0x1C +unprojectFromMap__15dLytMapGlobal_cCFR7mVec3_cRC7mVec2_cRC7mVec3_cRC4mAng = .text:0x8012D370; // type:function size:0x1C +unprojectFromMap__15dLytMapGlobal_cCFR7mVec3_cRC7mVec2_cRC7mVec2_cRC7mVec3_cRC7mVec3_cRC4mAngff = .text:0x8012D390; // type:function size:0x118 LytMapCapture__stateRenderingWaitEnter = .text:0x8012D4B0; // type:function size:0x4 LytMapCapture__stateRenderingWaitUpdate = .text:0x8012D4C0; // type:function size:0x70 changeState__85sStateMgr_c<16dLytMapCapture_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x8012D530; // type:function size:0x10 @@ -7541,7 +7541,7 @@ finalizeState_Remove__16dLytMapPinIcon_cFv = .text:0x8012EB20; // type:function fn_8012EB30 = .text:0x8012EB30; // type:function size:0xF8 fn_8012EC30 = .text:0x8012EC30; // type:function size:0x80 fn_8012ECB0 = .text:0x8012ECB0; // type:function size:0x10C -fn_8012EDC0 = .text:0x8012EDC0; // type:function size:0x2C +removeBeacon__16dLytMapPinIcon_cFv = .text:0x8012EDC0; // type:function size:0x2C __dt__16dLytMapPinIcon_cFv = .text:0x8012EDF0; // type:function size:0x110 __dt__55sFStateMgr_c<16dLytMapPinIcon_c,20sStateMethodUsr_FI_c>Fv = .text:0x8012EF00; // type:function size:0xA4 __dt__85sStateMgr_c<16dLytMapPinIcon_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x8012EFB0; // type:function size:0xA0 @@ -7750,7 +7750,7 @@ __dt__55sFStateMgr_c<16dLytMapCapture_c,20sStateMethodUsr_FI_c>Fv = .text:0x8013 __dt__16dLytMapCapture_cFv = .text:0x80133FF0; // type:function size:0xB4 __ct__20dLytMapFloorBtnMgr_cFPv = .text:0x801340B0; // type:function size:0x178 __ct__20LytMapFourAnimGroupsFv = .text:0x80134230; // type:function size:0x140 -__ct__Q23d2d11dLytStructDFv = .text:0x80134370; // type:function size:0x48 +__ct__20dCursorHitCheckLyt_cFv = .text:0x80134370; // type:function size:0x48 __ct__17dLytMapFloorBtn_cFv = .text:0x801343C0; // type:function size:0xAC __ct__25dLytMapPinIconAggregate_cFv = .text:0x80134470; // type:function size:0xF0 __dt__38sFState_c<25dLytMapPinIconAggregate_c>Fv = .text:0x80134560; // type:function size:0x58 @@ -41943,7 +41943,7 @@ sInstance__15dLytMsgWindow_c = .sbss:0x80575488; // type:object size:0x4 data:4b lbl_8057548C = .sbss:0x8057548C; // type:object size:0x4 data:4byte CURRENT_ACTOR_EVENT_FLOW_MANAGER = .sbss:0x80575490; // type:object size:0x8 data:4byte sInstance__18dLytSimpleWindow_c = .sbss:0x80575498; // type:object size:0x8 data:4byte -lbl_805754A0 = .sbss:0x805754A0; // type:object size:0x8 data:4byte +sInstance__15dLytMapGlobal_c = .sbss:0x805754A0; // type:object size:0x8 data:4byte sMapFaderColor = .sbss:0x805754A8; // type:object size:0x4 data:byte lbl_805754AC = .sbss:0x805754AC; // type:object size:0x1 data:byte sInstance__9dLytMap_c = .sbss:0x805754B0; // type:object size:0x8 data:4byte diff --git a/configure.py b/configure.py index 4c8acef2..3a0f39a0 100644 --- a/configure.py +++ b/configure.py @@ -534,6 +534,7 @@ config.libs = [ Object(NonMatching, "d/lyt/msg_window/d_lyt_simple_window.cpp"), Object(Matching, "d/lyt/d_lyt_auto_caption.cpp"), Object(Matching, "d/lyt/d_lyt_auto_explain.cpp"), + Object(Matching, "d/lyt/d_lyt_map_global.cpp"), Object(NonMatching, "d/lyt/d_lyt_map_capture.cpp"), Object(NonMatching, "d/lyt/d_lyt_map.cpp"), Object(Matching, "d/lyt/d_lyt_note.cpp"), diff --git a/include/d/lyt/d2d.h b/include/d/lyt/d2d.h index 14c92b78..6c057c22 100644 --- a/include/d/lyt/d2d.h +++ b/include/d/lyt/d2d.h @@ -252,6 +252,10 @@ struct AnmGroupBase_c { return mpFrameCtrl->getRate(); } + inline bool isBound() const { + return (mFlags & ANMGROUP_FLAG_BOUND) != 0; + } + inline bool isEnabled() const { return (mFlags & ANMGROUP_FLAG_ENABLE) != 0; } diff --git a/include/d/lyt/d_lyt_map.h b/include/d/lyt/d_lyt_map.h index 283a01e8..7032e4fb 100644 --- a/include/d/lyt/d_lyt_map.h +++ b/include/d/lyt/d_lyt_map.h @@ -3,6 +3,7 @@ #include "common.h" #include "d/d_cursor_hit_check.h" +#include "d/d_message.h" #include "d/lyt/d2d.h" #include "d/lyt/d_lyt_map_capture.h" #include "egg/core/eggColorFader.h" @@ -66,6 +67,8 @@ public: STATE_FUNC_DECLARE(dLytMapPinIcon_c, Remove); private: + void removeBeacon(); + /* 0x004 */ UI_STATE_MGR_DECLARE(dLytMapPinIcon_c); /* 0x040 */ d2d::LytBase_c mLyt; /* 0x0D0 */ d2d::AnmGroup_c mAnmGroups[3]; @@ -326,7 +329,8 @@ public: private: /* 0x0010 */ UI_STATE_MGR_DECLARE(dLytMapMain_c); /* 0x004C */ u8 field_0x004C[0x00A4 - 0x004C]; - /* 0x00A4 */ u8 field_0x00A4[0x010C - 0x00A4]; + /* 0x00A4 */ dFlow_c mFlow; + /* 0x0108 */ u8 _0x108[0x10C - 0x108]; /* 0x010C */ d2d::LytBase_c mLyt; /* 0x019C */ d2d::AnmGroup_c mAnmGroups[54]; /* 0x0F1C */ LytMap0x80520B5C field_0xF1C; @@ -349,7 +353,7 @@ private: /* 0x8930 */ mVec3_c field_0x8930; /* 0x893C */ mVec3_c field_0x893C; - /* 0x8948 */ u8 idkfixmelater[0x4BC0]; + /* 0x8948 */ u8 idkfixmelater[0x4BA0]; /* 0x8C94 */ s32 field_0x8C94; // ... diff --git a/include/d/lyt/d_lyt_map_capture.h b/include/d/lyt/d_lyt_map_capture.h index 92d533a5..974c095b 100644 --- a/include/d/lyt/d_lyt_map_capture.h +++ b/include/d/lyt/d_lyt_map_capture.h @@ -25,7 +25,8 @@ public: private: /* 0x004 */ UI_STATE_MGR_DECLARE(dLytMapCapture_c); - /* 0x040*/ UNKWORD field_0x040; + /* 0x040 */ UNKWORD field_0x040; + /* 0x044 */ u8 _0x040[0x064 - 0x044]; /* 0x064 */ f32 field_0x064; /* 0x068 */ f32 field_0x068; /* 0x06C */ f32 field_0x06C; diff --git a/include/d/lyt/d_lyt_map_global.h b/include/d/lyt/d_lyt_map_global.h new file mode 100644 index 00000000..2e214df9 --- /dev/null +++ b/include/d/lyt/d_lyt_map_global.h @@ -0,0 +1,53 @@ +#ifndef D_LYT_MAP_GLOBAL_H +#define D_LYT_MAP_GLOBAL_H + +#include "m/m_angle.h" +#include "m/m_vec.h" + +class dLytMapGlobal_c { +public: + dLytMapGlobal_c(); + + static dLytMapGlobal_c *GetInstance() { + return sInstance; + } + + void projectOntoMap(mVec2_c &result, const mVec3_c &position) const; + void unprojectFromMap(mVec3_c &result, const mVec2_c &position) const; + void unprojectFromMap(mVec3_c &result, const mVec2_c &position, const mAng &rot) const; + void unprojectFromMap(mVec3_c &result, const mVec2_c &position, const mVec3_c &v2, const mAng &rot) const; + +private: + static dLytMapGlobal_c *sInstance; + + void projectOntoMap( + mVec2_c &result, const mVec3_c &position, const mVec3_c &v1, const mVec3_c &mapRotationCenter, const mAng &rot, + f32 f1, f32 f2 + ) const; + + void unprojectFromMap( + mVec3_c &result, const mVec2_c &position, const mVec2_c &v1, const mVec3_c &v2, + const mVec3_c &mapRotationCenter, const mAng &rot, f32 f1, f32 f2 + ) const; + + /* 0x00 */ mVec3_c field_0x00; + /* 0x0C */ mVec2_c field_0x0C; + /* 0x14 */ mVec3_c mMapRotationCenter; + /* 0x20 */ mVec2_c field_0x20; + /* 0x28 */ f32 field_0x28; + /* 0x2C */ f32 field_0x2C; + /* 0x30 */ mVec3_c mPlayerPosition; + /* 0x3C */ mAng mMapRotation; + /* 0x40 */ f32 field_0x40; + /* 0x44 */ f32 field_0x44; + /* 0x48 */ UNKWORD field_0x48; + /* 0x4C */ u8 field_0x4C; + /* 0x4D */ u8 field_0x4D; + /* 0x4E */ u8 field_0x4E; + /* 0x4F */ u8 field_0x4F; + /* 0x50 */ UNKWORD field_0x50; + /* 0x54 */ u8 _0x54[0x64 - 0x54]; + /* 0x60 */ f32 field_0x64; +}; + +#endif diff --git a/src/d/lyt/d_lyt_map.cpp b/src/d/lyt/d_lyt_map.cpp index 6e008c36..0f05ed09 100644 --- a/src/d/lyt/d_lyt_map.cpp +++ b/src/d/lyt/d_lyt_map.cpp @@ -3,8 +3,10 @@ #include "common.h" #include "d/d_cursor_hit_check.h" #include "d/d_d2d.h" +#include "d/d_pad.h" #include "d/d_pad_nav.h" #include "d/lyt/d2d.h" +#include "d/snd/d_snd_small_effect_mgr.h" #include "egg/core/eggColorFader.h" #include "m/m_video.h" #include "sized_string.h" @@ -182,6 +184,7 @@ void dLytMapFader_c::draw() { #define LYT_MAP_PIN_ICON_ANIM_SCALE 0 #define LYT_MAP_PIN_ICON_ANIM_ERASE 1 #define LYT_MAP_PIN_ICON_ANIM_LOOP 2 +#define LYT_MAP_PIN_ICON_NUM_ANIMS 3 void dLytMapPinIcon_c::initializeState_Wait() { mLyt.calc(); @@ -208,7 +211,7 @@ void dLytMapPinIcon_c::executeState_Wait() { void dLytMapPinIcon_c::finalizeState_Wait() {} void dLytMapPinIcon_c::initializeState_ToSelect() { - d2d::AnmGroup_c *m = &mAnmGroups[1]; + d2d::AnmGroup_c *m = &mAnmGroups[LYT_MAP_PIN_ICON_ANIM_ERASE]; m->bind(false); m->setFrame(0.0f); } @@ -220,7 +223,33 @@ void dLytMapPinIcon_c::finalizeState_ToSelect() { } void dLytMapPinIcon_c::initializeState_Select() {} -void dLytMapPinIcon_c::executeState_Select() {} +void dLytMapPinIcon_c::executeState_Select() { + if (field_0x1D0->field_0x05 && dPad::getDownTrigC()) { + removeBeacon(); + field_0x1D0->field_0x04 = false; + d2d::AnmGroup_c *m = &mAnmGroups[LYT_MAP_PIN_ICON_ANIM_ERASE]; + if (m->isBound()) { + m->unbind(); + } + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MAP_BEACON_REMOVE); + mStateMgr.changeState(StateID_Remove); + return; + } + + if (field_0x1BC == 0) { + d2d::AnmGroup_c *m = &mAnmGroups[LYT_MAP_PIN_ICON_ANIM_ERASE]; + m->bind(false); + m->setFrame(0.0f); + mLyt.calc(); + m->unbind(); + mStateMgr.changeState(StateID_ToUnselect); + } else { + d2d::AnmGroup_c *m = &mAnmGroups[LYT_MAP_PIN_ICON_ANIM_ERASE]; + if (m->isBound()) { + m->play(); + } + } +} void dLytMapPinIcon_c::finalizeState_Select() {} void dLytMapPinIcon_c::initializeState_ToUnselect() {} @@ -255,7 +284,7 @@ bool dLytMapPinIcon_c::build(d2d::ResAccIf_c *resAcc) { d2d::AnmGroup_c *pAnmGroups = mAnmGroups; - for (int i = 0; i < 3; i++) { + for (int i = 0; i < LYT_MAP_PIN_ICON_NUM_ANIMS; i++) { pAnmGroups[i].init(sMapPinIconBrlanMap[i].mFile, resAcc, mLyt.getLayout(), sMapPinIconBrlanMap[i].mName); pAnmGroups[i].bind(false); pAnmGroups[i].setFrame(0.0f); @@ -263,7 +292,7 @@ bool dLytMapPinIcon_c::build(d2d::ResAccIf_c *resAcc) { mLyt.calc(); - for (int i = 0; i < 3; i++) { + for (int i = 0; i < LYT_MAP_PIN_ICON_NUM_ANIMS; i++) { pAnmGroups[i].unbind(); } @@ -285,7 +314,7 @@ bool dLytMapPinIcon_c::build(d2d::ResAccIf_c *resAcc) { bool dLytMapPinIcon_c::remove() { dCsMgr_c::GetInstance()->unregistCursorTarget(&mCsHitCheck); - for (int i = 0; i < 3; i++) { + for (int i = 0; i < LYT_MAP_PIN_ICON_NUM_ANIMS; i++) { mAnmGroups[i].remove(); } return true; @@ -295,7 +324,7 @@ bool dLytMapPinIcon_c::execute() { fn_8012EC30(); mStateMgr.executeState(); field_0x1BC = 0; - mAnmGroups[2].setFrame(field_0x1DC); + mAnmGroups[LYT_MAP_PIN_ICON_ANIM_LOOP].setFrame(field_0x1DC); // TODO something MapCapture mLyt.calc(); mCsHitCheck.resetCachedHitboxes(); diff --git a/src/d/lyt/d_lyt_map_global.cpp b/src/d/lyt/d_lyt_map_global.cpp new file mode 100644 index 00000000..8f0f349a --- /dev/null +++ b/src/d/lyt/d_lyt_map_global.cpp @@ -0,0 +1,88 @@ +#include "d/lyt/d_lyt_map_global.h" + +#include "m/m_vec.h" + +dLytMapGlobal_c *dLytMapGlobal_c::sInstance; + +dLytMapGlobal_c::dLytMapGlobal_c() + : field_0x00(0.0f, 0.0f, 0.0f), + field_0x0C(0.0f, 0.0f), + mMapRotationCenter(0.0f, 0.0f, 0.0f), + field_0x20(0.0f, 0.0f), + field_0x28(0.0f), + field_0x2C(0.0f), + mMapRotation(0), + field_0x40(1.0f), + field_0x44(1.0f), + field_0x48(0), + field_0x4C(0), + field_0x4D(0), + field_0x4E(0), + field_0x4F(0), + field_0x50(0) { + sInstance = this; +} + +void dLytMapGlobal_c::projectOntoMap( + mVec2_c &result, const mVec3_c &position, const mVec3_c &v1, const mVec3_c &mapRotationCenter, const mAng &rot, + f32 f1, f32 f2 +) const { + // Initializing like this fixes regswaps, even if it's not needed... + mVec3_c work(0.0f, 0.0f, 0.0f); + + work.x = position.x - mapRotationCenter.x; + work.z = position.z - mapRotationCenter.z; + work.y = 0.0f; + work.rotY(-rot); + + work.x += mapRotationCenter.x - v1.x; + work.z += mapRotationCenter.z - v1.z; + + work.x *= f2 * f1; + work.z *= f2 * f1; + work.x *= field_0x28; + + result.x = work.x; + result.y = -work.z; +} + +void dLytMapGlobal_c::projectOntoMap(mVec2_c &result, const mVec3_c &position) const { + projectOntoMap(result, position, field_0x00, mMapRotationCenter, mMapRotation, field_0x44, field_0x40); +} + +void dLytMapGlobal_c::unprojectFromMap(mVec3_c &result, const mVec2_c &position) const { + unprojectFromMap( + result, position, field_0x20, field_0x00, mMapRotationCenter, mMapRotation, field_0x44, field_0x40 + ); +} + +void dLytMapGlobal_c::unprojectFromMap(mVec3_c &result, const mVec2_c &position, const mAng &rot) const { + unprojectFromMap(result, position, field_0x20, field_0x00, mMapRotationCenter, rot, field_0x44, field_0x40); +} + +void dLytMapGlobal_c::unprojectFromMap(mVec3_c &result, const mVec2_c &position, const mVec3_c &v2, const mAng &rot) + const { + unprojectFromMap(result, position, field_0x20, v2, mMapRotationCenter, rot, field_0x44, field_0x40); +} + +void dLytMapGlobal_c::unprojectFromMap( + mVec3_c &result, const mVec2_c &position, const mVec2_c &v1, const mVec3_c &v2, const mVec3_c &mapRotationCenter, + const mAng &rot, f32 f1, f32 f2 +) const { + mVec3_c work(0.0f, 0.0f, 0.0f); + + f1 *= f2; + f32 tmp = 1.0f / f1; + mVec2_c diff = position - v1; + + work.x = diff.x * tmp * (1.0f / field_0x28); + work.z = -diff.y * tmp; + + work = work + v2; + + work = work - mapRotationCenter; + work.rotY(rot); + work += mapRotationCenter; + + result = work; +}