From 6d7a7007c057a5fbbdc88f12f44aab6ec7a8d030 Mon Sep 17 00:00:00 2001 From: robojumper Date: Fri, 10 Oct 2025 01:05:19 +0200 Subject: [PATCH] more --- config/SOUE01/symbols.txt | 29 +- include/d/d_stage.h | 8 + include/d/flag/storyflag_map.h | 4 +- include/d/lyt/d_lyt_map.h | 52 +- include/d/lyt/d_lyt_map_global.h | 8 + include/d/lyt/d_lyt_map_markers.h | 4 + include/toBeSorted/d_flow_mgr.h | 3 + src/d/lyt/d_lyt_map.cpp | 585 +++++++++++++++--- src/d/lyt/d_lyt_map_markers.cpp | 2 +- src/d/lyt/msg_window/d_lyt_msg_window_get.cpp | 1 + .../lyt/msg_window/d_lyt_msg_window_link.cpp | 1 + .../lyt/msg_window/d_lyt_msg_window_talk.cpp | 1 + 12 files changed, 577 insertions(+), 121 deletions(-) diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index b0972835..776b8b0b 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -4271,7 +4271,7 @@ fn_800C38A0 = .text:0x800C38A0; // type:function size:0x58 fn_800C3900 = .text:0x800C3900; // type:function size:0xD0 fn_800C39D0 = .text:0x800C39D0; // type:function size:0x11C __ct__14dFlowMgrBase_cFP7dFlow_c = .text:0x800C3AF0; // type:function size:0x1C -ActorEventFlowManagerRelated__triggerEventEntryPoint = .text:0x800C3B10; // type:function size:0xF8 +triggerEntryPoint__14dFlowMgrBase_cFllUcUc = .text:0x800C3B10; // type:function size:0xF8 fn_800C3C10 = .text:0x800C3C10; // type:function size:0xE8 fn_800C3D00 = .text:0x800C3D00; // type:function size:0x78 fn_800C3D80 = .text:0x800C3D80; // type:function size:0xC @@ -7823,7 +7823,7 @@ canZoomIn__13dLytMapMain_cCFl = .text:0x80138510; // type:function size:0x140 canZoomOut__13dLytMapMain_cCFl = .text:0x80138650; // type:function size:0x1E0 canCenterCursor__13dLytMapMain_cCFl = .text:0x80138830; // type:function size:0x254 needsNav__13dLytMapMain_cCFl = .text:0x80138A90; // type:function size:0x8C -fn_80138B20 = .text:0x80138B20; // type:function size:0x110 +getSelectedSaveObjIdx__13dLytMapMain_cCFv = .text:0x80138B20; // type:function size:0x110 fn_80138C30 = .text:0x80138C30; // type:function size:0x38 fn_80138C70 = .text:0x80138C70; // type:function size:0xA4 fn_80138D20 = .text:0x80138D20; // type:function size:0x5C @@ -7849,7 +7849,7 @@ setButtonMessages__13dLytMapMain_cFlblb = .text:0x8013A170; // type:function siz canCenterCursor1__13dLytMapMain_cCFl = .text:0x8013AC00; // type:function size:0x4 setCursorType__13dLytMapMain_cFv = .text:0x8013AC10; // type:function size:0x138 fn_8013AD50 = .text:0x8013AD50; // type:function size:0x370 -fn_8013B0C0__13dLytMapMain_cFv = .text:0x8013B0C0; // type:function size:0x28C +calculateBoundingWorldHitboxes__13dLytMapMain_cFv = .text:0x8013B0C0; // type:function size:0x28C fn_8013B350 = .text:0x8013B350; // type:function size:0x10 initializeState_Invisible__13dLytMapMain_cFv = .text:0x8013B360; // type:function size:0x4 executeState_Invisible__13dLytMapMain_cFv = .text:0x8013B370; // type:function size:0x4 @@ -7921,8 +7921,7 @@ executeState_EventMapIntro_Step4__13dLytMapMain_cFv = .text:0x80140B40; // type: finalizeState_EventMapIntro_Step4__13dLytMapMain_cFv = .text:0x80140B80; // type:function size:0x4 fn_80140B90__13dLytMapMain_cFv = .text:0x80140B90; // type:function size:0xBC initializeState_EventDungeonMapGet_Step1__13dLytMapMain_cFv = .text:0x80140C50; // type:function size:0x18 -executeState_EventDungeonMapGet_Step1__13dLytMapMain_cFv = .text:0x80140C70; // type:function size:0x34 -fn_80140CA4 = .text:0x80140CA4; // type:function size:0x4 +executeState_EventDungeonMapGet_Step1__13dLytMapMain_cFv = .text:0x80140C70; // type:function size:0x38 finalizeState_EventDungeonMapGet_Step1__13dLytMapMain_cFv = .text:0x80140CB0; // type:function size:0x4 initializeState_EventDungeonMapGet_Step2__13dLytMapMain_cFv = .text:0x80140CC0; // type:function size:0x68 executeState_EventDungeonMapGet_Step2__13dLytMapMain_cFv = .text:0x80140D30; // type:function size:0x12C @@ -7931,22 +7930,19 @@ initializeState_EventDungeonMapGet_Step3__13dLytMapMain_cFv = .text:0x80140E70; executeState_EventDungeonMapGet_Step3__13dLytMapMain_cFv = .text:0x80140E90; // type:function size:0x28 finalizeState_EventDungeonMapGet_Step3__13dLytMapMain_cFv = .text:0x80140EC0; // type:function size:0x4 initializeState_EventFieldMapChange_Step1__13dLytMapMain_cFv = .text:0x80140ED0; // type:function size:0x18 -executeState_EventFieldMapChange_Step1__13dLytMapMain_cFv = .text:0x80140EF0; // type:function size:0x34 -fn_80140F24 = .text:0x80140F24; // type:function size:0x4 +executeState_EventFieldMapChange_Step1__13dLytMapMain_cFv = .text:0x80140EF0; // type:function size:0x38 finalizeState_EventFieldMapChange_Step1__13dLytMapMain_cFv = .text:0x80140F30; // type:function size:0x4 initializeState_EventFieldMapChange_Step2__13dLytMapMain_cFv = .text:0x80140F40; // type:function size:0x28 executeState_EventFieldMapChange_Step2__13dLytMapMain_cFv = .text:0x80140F70; // type:function size:0xBC finalizeState_EventFieldMapChange_Step2__13dLytMapMain_cFv = .text:0x80141030; // type:function size:0x4 initializeState_EventFieldMapChange_Step3__13dLytMapMain_cFv = .text:0x80141040; // type:function size:0x18 -executeState_EventFieldMapChange_Step3__13dLytMapMain_cFv = .text:0x80141060; // type:function size:0x58 -fn_801410B8 = .text:0x801410B8; // type:function size:0x4 +executeState_EventFieldMapChange_Step3__13dLytMapMain_cFv = .text:0x80141060; // type:function size:0x5C finalizeState_EventFieldMapChange_Step3__13dLytMapMain_cFv = .text:0x801410C0; // type:function size:0x4 initializeState_EventFieldMapChange_Step4__13dLytMapMain_cFv = .text:0x801410D0; // type:function size:0x4 executeState_EventFieldMapChange_Step4__13dLytMapMain_cFv = .text:0x801410E0; // type:function size:0x4 finalizeState_EventFieldMapChange_Step4__13dLytMapMain_cFv = .text:0x801410F0; // type:function size:0x4 initializeState_EventForestMapChange_Step1__13dLytMapMain_cFv = .text:0x80141100; // type:function size:0x18 -executeState_EventForestMapChange_Step1__13dLytMapMain_cFv = .text:0x80141120; // type:function size:0x34 -fn_80141154 = .text:0x80141154; // type:function size:0x4 +executeState_EventForestMapChange_Step1__13dLytMapMain_cFv = .text:0x80141120; // type:function size:0x38 finalizeState_EventForestMapChange_Step1__13dLytMapMain_cFv = .text:0x80141160; // type:function size:0x4 initializeState_EventForestMapChange_Step2__13dLytMapMain_cFv = .text:0x80141170; // type:function size:0x6C executeState_EventForestMapChange_Step2__13dLytMapMain_cFv = .text:0x801411E0; // type:function size:0x12C @@ -7961,11 +7957,10 @@ initializeState_EventSignalAdd_Step2__13dLytMapMain_cFv = .text:0x80141400; // t executeState_EventSignalAdd_Step2__13dLytMapMain_cFv = .text:0x80141420; // type:function size:0x90 finalizeState_EventSignalAdd_Step2__13dLytMapMain_cFv = .text:0x801414B0; // type:function size:0x4 initializeState_EventSignalAdd_Step3__13dLytMapMain_cFv = .text:0x801414C0; // type:function size:0x18 -executeState_EventSignalAdd_Step3__13dLytMapMain_cFv = .text:0x801414E0; // type:function size:0x34 -fn_80141514 = .text:0x80141514; // type:function size:0x4 +executeState_EventSignalAdd_Step3__13dLytMapMain_cFv = .text:0x801414E0; // type:function size:0x38 finalizeState_EventSignalAdd_Step3__13dLytMapMain_cFv = .text:0x80141520; // type:function size:0x4 fn_80141530__13dLytMapMain_cCFv = .text:0x80141530; // type:function size:0x48 -findGoddessChestWithStoryflag = .text:0x80141580; // type:function size:0x94 +findGoddessChestForStoryflag__13dLytMapMain_cCFl = .text:0x80141580; // type:function size:0x94 initializeState_EventGoddessCube_Step1__13dLytMapMain_cFv = .text:0x80141620; // type:function size:0x10 executeState_EventGoddessCube_Step1__13dLytMapMain_cFv = .text:0x80141630; // type:function size:0x44 finalizeState_EventGoddessCube_Step1__13dLytMapMain_cFv = .text:0x80141680; // type:function size:0x10 @@ -7975,16 +7970,16 @@ finalizeState_EventGoddessCube_Step2__13dLytMapMain_cFv = .text:0x80141E40; // t initializeState_EventGoddessCube_Step3__13dLytMapMain_cFv = .text:0x80141E50; // type:function size:0x4 executeState_EventGoddessCube_Step3__13dLytMapMain_cFv = .text:0x80141E60; // type:function size:0x18 finalizeState_EventGoddessCube_Step3__13dLytMapMain_cFv = .text:0x80141E80; // type:function size:0x4 -checkStoryflag = .text:0x80141E90; // type:function size:0x44 +checkStoryflag__13dLytMapMain_cCFl = .text:0x80141E90; // type:function size:0x44 initializeState_EventSaveObjMsgWindow__13dLytMapMain_cFv = .text:0x80141EE0; // type:function size:0x90 executeState_EventSaveObjMsgWindow__13dLytMapMain_cFv = .text:0x80141F70; // type:function size:0x54 finalizeState_EventSaveObjMsgWindow__13dLytMapMain_cFv = .text:0x80141FD0; // type:function size:0x4 -whatBirdStatuesToShow = .text:0x80141FE0; // type:function size:0x1D4 +displaySaveObjs__13dLytMapMain_cFv = .text:0x80141FE0; // type:function size:0x1D4 initializeState_EventSaveObjSelect__13dLytMapMain_cFv = .text:0x801421C0; // type:function size:0x4 executeState_EventSaveObjSelect__13dLytMapMain_cFv = .text:0x801421D0; // type:function size:0x278 getStateID__85sStateMgr_c<16dLytMapSaveObj_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x80142450; // type:function size:0x10 finalizeState_EventSaveObjSelect__13dLytMapMain_cFv = .text:0x80142460; // type:function size:0x4 -getStatueSelectDestinationStruct = .text:0x80142470; // type:function size:0xEC +getSaveObjDefinition__13dLytMapMain_cCFll = .text:0x80142470; // type:function size:0xEC initializeState_EventSaveObjConfirmMsgWindow__13dLytMapMain_cFv = .text:0x80142560; // type:function size:0x18 executeState_EventSaveObjConfirmMsgWindow__13dLytMapMain_cFv = .text:0x80142580; // type:function size:0x19C finalizeState_EventSaveObjConfirmMsgWindow__13dLytMapMain_cFv = .text:0x80142720; // type:function size:0x4 diff --git a/include/d/d_stage.h b/include/d/d_stage.h index 5d48f917..9608dd07 100644 --- a/include/d/d_stage.h +++ b/include/d/d_stage.h @@ -78,6 +78,14 @@ public: return field_0x1EE; } + void setField_0x1E8(u8 v) { + field_0x1E8 = v; + } + + void setField_0x1EF(u8 v) { + field_0x1EF = v; + } + void init(MapRelated *); void fn_801b4900(); void fn_801B4B80(u32 mapParams, const mVec3_c ¢er, const mVec3_c &size); diff --git a/include/d/flag/storyflag_map.h b/include/d/flag/storyflag_map.h index 759bf0ef..11c5a099 100644 --- a/include/d/flag/storyflag_map.h +++ b/include/d/flag/storyflag_map.h @@ -96,7 +96,7 @@ enum StoryFlags_e { * 3 / Water Dragon's Lair layer 3 / Behind The Temple layer 7)] Story Flag #16 (0x0010) - JP 805ACD5B 0x02 / US * 805A9ADB 0x02 */ - STORYFLAG_16, + STORYFLAG_WATER_DRAGON_SOTH_PART, /** [Triforce Completed] * Story Flag #17 (0x0011) - JP 805ACD5B 0x04 / US 805A9ADB 0x04 @@ -2657,7 +2657,7 @@ enum StoryFlags_e { /** [Flooded Faron Woods Introductory Cutscene] * Story Flag #527 (0x020F) - JP 805ACD94 0x10 / US 805A9B14 0x10 */ - STORYFLAG_527, + STORYFLAG_FLOODED_FARON_WOODS_DISCOVERED, /** [Finishing a Silent Realm for the First time] * Story Flag #528 (0x0210) - JP 805ACD94 0x20 / US 805A9B14 0x20 diff --git a/include/d/lyt/d_lyt_map.h b/include/d/lyt/d_lyt_map.h index f79e50d0..8a0551d6 100644 --- a/include/d/lyt/d_lyt_map.h +++ b/include/d/lyt/d_lyt_map.h @@ -20,13 +20,15 @@ #include "s/s_State.hpp" #include "toBeSorted/d_flow_mgr.h" +class dAcTbox_c; + /** Bird Statue Definition (StatueSelectDestination) */ struct dMapSaveObjDefinition { /* 0x00 */ const char *stageName; /* 0x04 */ u8 room; /* 0x05 */ u8 layer; - /* 0x06 */ u8 enrance; - /* 0x08 */ UNKWORD field_0x08; + /* 0x06 */ u8 entrance; + /* 0x08 */ s32 type; /* 0x0C */ const char *statueLabel; }; @@ -129,10 +131,9 @@ struct dLytMapFloorBtnAnmGroups { /* 0xC0 */ d2d::AnmGroup_c mOnOffLight; }; -// Ostensibly a bounding box for lyt elements -struct LytMapTwoVecs { - /* 0x00 */ mVec3_c field_0x00; - /* 0x0C */ mVec3_c field_0x0C; +struct dLytMapBoundingWorldBounds { + /* 0x00 */ mVec3_c min; + /* 0x0C */ mVec3_c max; }; /** 2D UI - Map - a placed down beacon */ @@ -405,6 +406,10 @@ public: void set(nw4r::lyt::Bounding **pStatueBoundings, s32 count); void hide(s32 statueIdx); + void setCurrentStatue(s32 idx) { + mCurrentlyInStatue = idx; + } + private: f32 setStatueLabel(const char *label); @@ -417,6 +422,8 @@ private: }; class dLytMapSaveCaption_c { + friend class dLytMapMain_c; + public: dLytMapSaveCaption_c() : mStateMgr(*this, sStateID::null) {} @@ -441,6 +448,8 @@ private: // Size 0x190 class dLytMapSaveObj_c { + friend class dLytMapMain_c; + public: dLytMapSaveObj_c() : mStateMgr(*this, sStateID::null), mSelectRequest(false), mDecideRequest(false), mDecideFinished(false) {} @@ -549,6 +558,13 @@ public: STATE_FUNC_DECLARE(dLytMapMain_c, EventSaveObjDecide); private: + // TODO - used elsewhere? + enum Province_e { + PROVINCE_FARON = 0, + PROVINCE_ELDIN = 1, + PROVINCE_LANAYRU = 2, + }; + dLytMapGlobal_c *getGlobal(); void checkScroll(); bool needsNav(s32 mapMode) const; @@ -561,6 +577,8 @@ private: bool canPlaceBeacons(s32 mapMode) const; bool isPointingAtMainMap() const; + s32 getSelectedSaveObjIdx() const; + f32 fn_80142D90(s32); void fn_80142F00(mVec3_c &, s32 mapMode, u8, const mVec3_c &, const mAng &); void fn_8013FB70(const mVec3_c &, f32); @@ -588,7 +606,11 @@ private: void checkCursorPointedAtMap(); - void fn_8013B0C0(); + void calculateBoundingWorldHitboxes(); + + dAcTbox_c *findGoddessChestForStoryflag(s32 flag) const; + bool checkStoryflag(s32 flag) const; + void displaySaveObjs(); static dMapSavedData sSavedMapData; static const dMapSavedData sDefaultMapData; @@ -624,7 +646,7 @@ private: /* 0x825C */ nw4r::lyt::Bounding *field_0x825C[12]; /* 0x828C */ mVec3_c field_0x828C[12]; /* 0x831C */ UNKWORD field_0x831C; - /* 0x8320 */ UNKWORD field_0x8320; + /* 0x8320 */ u32 field_0x8320; /* 0x8324 */ u8 _0x8324[0x8328 - 0x8324]; @@ -655,7 +677,7 @@ private: /* 0x8930 */ mVec3_c field_0x8930; /* 0x893C */ mVec3_c field_0x893C; - /* 0x8948 */ LytMapTwoVecs field_0x8948[33]; + /* 0x8948 */ dLytMapBoundingWorldBounds mBoundingWorldBounds[33]; /* 0x8C60 */ s32 mMaxBeaconCount; /* 0x8C64 */ s32 field_0x8C64; @@ -673,7 +695,7 @@ private: /* 0x8C93 */ u8 field_0x8C93; /* 0x8C94 */ s32 field_0x8C94; /* 0x8C98 */ UNKWORD field_0x8C98; - /* 0x8C9C */ UNKWORD field_0x8C9C; + /* 0x8C9C */ s32 mProvince; /* 0x8CA0 */ u8 _0x8CA0[0x8CA4 - 0x8CA0]; @@ -685,11 +707,9 @@ private: /* 0x8CAE */ u8 _0x8CAE[0x8CB0 - 0x8CAE]; - /* 0x8CB0 */ u32 field_0x8CB0; + /* 0x8CB0 */ u32 mEventTimer; /* 0x8CB4 */ UNKWORD field_0x8CB4; - - /* 0x8CB8 */ u8 _0x8CB8[0x8CBC - 0x8CB8]; - + /* 0x8CB8 */ u32 field_0x8CB8; /* 0x8CBC */ nw4r::lyt::Bounding *mpMapBounding; /* 0x8CC0 */ bool mPointerOnMap; /* 0x8CC1 */ bool mPointerCanPlaceBeacon; @@ -732,7 +752,7 @@ private: /* 0x8DB0 */ UNKWORD field_0x8DB0; /* 0x8DB4 */ bool mNavEnabled; /* 0x8DB5 */ bool mDrawScaleFrame; - /* 0x8DB8 */ UNKWORD field_0x8DB8; + /* 0x8DB8 */ s32 mDisplayedBeaconCount; /* 0x8DBC */ bool mShowIslandNames; /* 0x8DBD */ bool field_0x8DBD; /* 0x8DBE */ u8 field_0x8DBE; @@ -801,7 +821,7 @@ public: } const dMapSaveObjDefinition *getSaveObjDefinition(s32 statueIdx) const { - return mMapMain.getSaveObjDefinition(mMapMain.field_0x8C9C, statueIdx); + return mMapMain.getSaveObjDefinition(mMapMain.mProvince, statueIdx); } private: diff --git a/include/d/lyt/d_lyt_map_global.h b/include/d/lyt/d_lyt_map_global.h index bab821d0..63a464f7 100644 --- a/include/d/lyt/d_lyt_map_global.h +++ b/include/d/lyt/d_lyt_map_global.h @@ -128,6 +128,10 @@ public: return field_0x4C; } + void setField_0x4C(u8 v) { + field_0x4C = v; + } + u8 getField_0x4D() const { return field_0x4D; } @@ -136,6 +140,10 @@ public: return field_0x4F; } + void setField_0x4F(u8 v) { + field_0x4F = v; + } + UNKWORD getField_0x50() const { return field_0x50; } diff --git a/include/d/lyt/d_lyt_map_markers.h b/include/d/lyt/d_lyt_map_markers.h index b95d627b..35113431 100644 --- a/include/d/lyt/d_lyt_map_markers.h +++ b/include/d/lyt/d_lyt_map_markers.h @@ -480,6 +480,10 @@ public: field_0x06F4 = v; } + void setField_0x0702(u8 v) { + field_0x0702 = v; + } + void setField_0x0703(u8 v) { field_0x0703 = v; } diff --git a/include/toBeSorted/d_flow_mgr.h b/include/toBeSorted/d_flow_mgr.h index e1834154..25784a23 100644 --- a/include/toBeSorted/d_flow_mgr.h +++ b/include/toBeSorted/d_flow_mgr.h @@ -10,6 +10,9 @@ public: dFlowMgrBase_c(dFlow_c *flow); virtual ~dFlowMgrBase_c() {} + void triggerEntryPoint(s32 labelPart1, s32 labelPart2, u8 p4, u8 p5); + bool checkFinished(); + private: /* 0x04 */ dFlow_c *mpFlow; /* 0x08 */ u8 _0x08[0x14 - 0x08]; diff --git a/src/d/lyt/d_lyt_map.cpp b/src/d/lyt/d_lyt_map.cpp index 08a5fed3..488fd050 100644 --- a/src/d/lyt/d_lyt_map.cpp +++ b/src/d/lyt/d_lyt_map.cpp @@ -4,6 +4,7 @@ #include "c/c_lib.h" #include "common.h" #include "d/a/d_a_player.h" +#include "d/a/obj/d_a_obj_tbox.h" #include "d/d_base.h" #include "d/d_cs_base.h" #include "d/d_cs_game.h" @@ -16,6 +17,8 @@ #include "d/d_rumble.h" #include "d/d_sc_game.h" #include "d/d_stage.h" +#include "d/flag/sceneflag_manager.h" +#include "d/flag/storyflag_manager.h" #include "d/lyt/d2d.h" #include "d/lyt/d_lyt_control_game.h" #include "d/lyt/d_lyt_map_global.h" @@ -26,6 +29,9 @@ #include "d/lyt/msg_window/d_lyt_msg_window.h" #include "d/snd/d_snd_small_effect_mgr.h" #include "egg/core/eggColorFader.h" +#include "f/f_base.h" +#include "f/f_manager.h" +#include "f/f_profile_name.h" #include "m/m_vec.h" #include "m/m_video.h" #include "nw4r/lyt/lyt_bounding.h" @@ -1928,7 +1934,7 @@ dLytMapMain_c::dLytMapMain_c() field_0x8DB0(0), mNavEnabled(false), mDrawScaleFrame(false), - field_0x8DB8(0), + mDisplayedBeaconCount(0), mShowIslandNames(false), field_0x8DBD(0), field_0x8DBE(0), @@ -2329,7 +2335,7 @@ void dLytMapMain_c::build() { field_0x8C8C = mAnmGroups[MAP_MAIN_ANIM_OUT].getLastFrame(); mAnmGroups[MAP_MAIN_ANIM_OUT].unbind(); field_0x8CAC = 0; - field_0x8DB8 = getMaxBeaconCount(); + mDisplayedBeaconCount = getMaxBeaconCount(); mStateMgr.changeState(StateID_Invisible); getGlobal()->setFloor(0); mNavEnabled = false; @@ -2389,14 +2395,41 @@ void dLytMapMain_c::draw() { mSaveCaption.draw(); } -void dLytMap_c::build() { - d2d::setLytAllocator(); - void *data = LayoutArcManager::GetInstance()->getLoadedData("Map2D"); - mResAcc.attach(data, ""); - mMapMain.build(); - m2d::setLytAllocator(); - mMapMain.setPriority(0x86); - // TODO there's another thing here at 0x91C0 +s32 dLytMapMain_c::getSelectedSaveObjIdx() const { + bool has = false; + s32 start; + s32 end; + if (field_0x8C6C == 2) { + start = 5; + end = 14; + has = true; + } else if (field_0x8C6C == 3) { + start = 15; + end = 20; + has = true; + } else if (field_0x8C6C == 4) { + start = 21; + end = 32; + has = true; + } + + if (!has) { + // @bug this should probably return -1 but it doesn't matter + return 0; + } + + s32 idx = -1; + dCursorHitCheck_c *d = dCsGame_c::GetInstance()->getCursorHit(); + if (d != nullptr && d->getType() == 'lyt ') { + for (int i = start; i <= end; i++) { + if (d == &mHitChecks[i]) { + idx = i - start; + break; + } + } + } + + return idx; } void lytMapusesSizedWString() { @@ -2432,6 +2465,7 @@ void dLytMapMain_c::loadUnkMapData() { } void dLytMapMain_c::clearButtonMessages() { + // @bug this clears flags 16k times for (int i = 0; i <= METER_BTN_0x4000; i++) { dLytMeter_c::GetInstance()->clearFlags(i); } @@ -2630,26 +2664,26 @@ void dLytMapMain_c::setCursorType() { } } -void dLytMapMain_c::fn_8013B0C0() { +void dLytMapMain_c::calculateBoundingWorldHitboxes() { dLytMapGlobal_c *global = getGlobal(); - // TODO - FPR Regswaps + f32 sc = global->getField_0x28().x; f32 f1 = field_0x8D40 * global->getField_0x44(); - f32 f2 = f1 * global->getField_0x28().x; + f32 f2 = f1 * sc; mAng rot = global->getField_0x56(); for (int i = 0; i <= MAP_MAIN_NUM_BOUNDINGS_NORMAL - 1; i++) { mVec3_c v1; mVec3_c v2; - f32 v1x = (f32)mHitChecks[i].getBoundingData()->mMinX; - f32 v2x = (f32)mHitChecks[i].getBoundingData()->mMaxX; + f32 v1x = (f32)mHitChecks[i].getBoundingData()->mMinX; + f32 v2x = (f32)mHitChecks[i].getBoundingData()->mMaxX; f32 v1z = (f32)mHitChecks[i].getBoundingData()->mMaxY; f32 v2z = (f32)mHitChecks[i].getBoundingData()->mMinY; v1.x = v1x / f2; v1.y = 0.0f; v1.z = -v1z / f1; - + v2.x = v2x / f2; v2.y = 0.0f; v2.z = -v2z / f1; @@ -2662,31 +2696,31 @@ void dLytMapMain_c::fn_8013B0C0() { s16 v = rot.mVal; if (v == 0) { // 0° rotation - field_0x8948[i].field_0x00.x = field_0x8CC4.x + v1.x; - field_0x8948[i].field_0x00.y = 0.0f; - field_0x8948[i].field_0x00.z = field_0x8CC4.z + v1.z; + mBoundingWorldBounds[i].min.x = field_0x8CC4.x + v1.x; + mBoundingWorldBounds[i].min.y = 0.0f; + mBoundingWorldBounds[i].min.z = field_0x8CC4.z + v1.z; - field_0x8948[i].field_0x0C.x = field_0x8CC4.x + v2.x; - field_0x8948[i].field_0x0C.y = 0.0f; - field_0x8948[i].field_0x0C.z = field_0x8CC4.z + v2.z; + mBoundingWorldBounds[i].max.x = field_0x8CC4.x + v2.x; + mBoundingWorldBounds[i].max.y = 0.0f; + mBoundingWorldBounds[i].max.z = field_0x8CC4.z + v2.z; } else if (v == 0x4000) { // 90° rotation - field_0x8948[i].field_0x00.x = field_0x8CC4.x + v1.x; - field_0x8948[i].field_0x00.y = 0.0f; - field_0x8948[i].field_0x00.z = field_0x8CC4.z + v2.z; + mBoundingWorldBounds[i].min.x = field_0x8CC4.x + v1.x; + mBoundingWorldBounds[i].min.y = 0.0f; + mBoundingWorldBounds[i].min.z = field_0x8CC4.z + v2.z; - field_0x8948[i].field_0x0C.x = field_0x8CC4.x + v2.x; - field_0x8948[i].field_0x0C.y = 0.0f; - field_0x8948[i].field_0x0C.z = field_0x8CC4.z + v1.z; + mBoundingWorldBounds[i].max.x = field_0x8CC4.x + v2.x; + mBoundingWorldBounds[i].max.y = 0.0f; + mBoundingWorldBounds[i].max.z = field_0x8CC4.z + v1.z; } else if (v == -0x8000) { // 180° rotation - field_0x8948[i].field_0x00.x = field_0x8CC4.x + v2.x; - field_0x8948[i].field_0x00.y = 0.0f; - field_0x8948[i].field_0x00.z = field_0x8CC4.z + v2.z; + mBoundingWorldBounds[i].min.x = field_0x8CC4.x + v2.x; + mBoundingWorldBounds[i].min.y = 0.0f; + mBoundingWorldBounds[i].min.z = field_0x8CC4.z + v2.z; - field_0x8948[i].field_0x0C.x = field_0x8CC4.x + v1.x; - field_0x8948[i].field_0x0C.y = 0.0f; - field_0x8948[i].field_0x0C.z = field_0x8CC4.z + v1.z; + mBoundingWorldBounds[i].max.x = field_0x8CC4.x + v1.x; + mBoundingWorldBounds[i].max.y = 0.0f; + mBoundingWorldBounds[i].max.z = field_0x8CC4.z + v1.z; } } } @@ -3369,12 +3403,12 @@ void dLytMapMain_c::executeState_ResetPosWithFloorChange() { void dLytMapMain_c::finalizeState_ResetPosWithFloorChange() {} void dLytMapMain_c::initializeState_EventSwBankSmall_Step1() { - field_0x8CB0 = sHio.field_0x1D; + mEventTimer = sHio.field_0x1D; field_0x8CB4 = 0; } void dLytMapMain_c::executeState_EventSwBankSmall_Step1() { - if (field_0x8CB0 != 0) { - field_0x8CB0--; + if (mEventTimer != 0) { + mEventTimer--; return; } @@ -3384,11 +3418,11 @@ void dLytMapMain_c::executeState_EventSwBankSmall_Step1() { void dLytMapMain_c::finalizeState_EventSwBankSmall_Step1() {} void dLytMapMain_c::initializeState_EventSwBankSmall_Step2() { - field_0x8CB0 = mMarkers.getField_0x0704(); + mEventTimer = mMarkers.getField_0x0704(); } void dLytMapMain_c::executeState_EventSwBankSmall_Step2() { - if (field_0x8CB0 != 0) { - field_0x8CB0--; + if (mEventTimer != 0) { + mEventTimer--; return; } mStateMgr.changeState(StateID_EventSwBankSmall_Step3); @@ -3396,11 +3430,11 @@ void dLytMapMain_c::executeState_EventSwBankSmall_Step2() { void dLytMapMain_c::finalizeState_EventSwBankSmall_Step2() {} void dLytMapMain_c::initializeState_EventSwBankSmall_Step3() { - field_0x8CB0 = sHio.field_0x1E; + mEventTimer = sHio.field_0x1E; } void dLytMapMain_c::executeState_EventSwBankSmall_Step3() { - if (field_0x8CB0 != 0) { - field_0x8CB0--; + if (mEventTimer != 0) { + mEventTimer--; return; } @@ -3409,7 +3443,7 @@ void dLytMapMain_c::executeState_EventSwBankSmall_Step3() { void dLytMapMain_c::finalizeState_EventSwBankSmall_Step3() {} void dLytMapMain_c::initializeState_EventMapIntro_Step1() { - field_0x8CB0 = sHio.field_0x1F; + mEventTimer = sHio.field_0x1F; } void dLytMapMain_c::executeState_EventMapIntro_Step1() { if (field_0x8D6A) { @@ -3417,8 +3451,8 @@ void dLytMapMain_c::executeState_EventMapIntro_Step1() { return; } - if (field_0x8CB0 != 0) { - field_0x8CB0--; + if (mEventTimer != 0) { + mEventTimer--; } else { mStateMgr.changeState(StateID_EventMapIntro_Step2); } @@ -3456,7 +3490,7 @@ void dLytMapMain_c::executeState_EventMapIntro_Step2() { void dLytMapMain_c::finalizeState_EventMapIntro_Step2() {} void dLytMapMain_c::initializeState_EventMapIntro_Step3() { - field_0x8CB0 = 0; + mEventTimer = 0; } void dLytMapMain_c::executeState_EventMapIntro_Step3() { if (field_0x8D6A) { @@ -3464,8 +3498,8 @@ void dLytMapMain_c::executeState_EventMapIntro_Step3() { return; } - if (field_0x8CB0 != 0) { - field_0x8CB0--; + if (mEventTimer != 0) { + mEventTimer--; } else { dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MAP_ZOOMIN_TO_AREA); mNextMapMode = dLytMapGlobal_c::MAPMODE_PROVINCE; @@ -3477,7 +3511,7 @@ void dLytMapMain_c::executeState_EventMapIntro_Step3() { void dLytMapMain_c::finalizeState_EventMapIntro_Step3() {} void dLytMapMain_c::initializeState_EventMapIntro_Step4() { - field_0x8CB0 = sHio.field_0x21; + mEventTimer = sHio.field_0x21; } void dLytMapMain_c::executeState_EventMapIntro_Step4() { if (field_0x8D6A) { @@ -3485,8 +3519,8 @@ void dLytMapMain_c::executeState_EventMapIntro_Step4() { return; } - if (field_0x8CB0 != 0) { - field_0x8CB0--; + if (mEventTimer != 0) { + mEventTimer--; } else { field_0x8D6B = 1; } @@ -3506,79 +3540,450 @@ void dLytMapMain_c::fn_80140B90() { mStateMgr.changeState(StateID_Invisible); } -void dLytMapMain_c::initializeState_EventDungeonMapGet_Step1() {} -void dLytMapMain_c::executeState_EventDungeonMapGet_Step1() {} +void dLytMapMain_c::initializeState_EventDungeonMapGet_Step1() { + mEventTimer = sHio.field_0x22; +} +void dLytMapMain_c::executeState_EventDungeonMapGet_Step1() { + if (mEventTimer != 0) { + mEventTimer--; + } else { + mStateMgr.changeState(StateID_EventDungeonMapGet_Step2); + } +} void dLytMapMain_c::finalizeState_EventDungeonMapGet_Step1() {} -void dLytMapMain_c::initializeState_EventDungeonMapGet_Step2() {} -void dLytMapMain_c::executeState_EventDungeonMapGet_Step2() {} +void dLytMapMain_c::initializeState_EventDungeonMapGet_Step2() { + mEventTimer = sHio.field_0x23; + field_0x8CB4 = sHio.field_0x24; + field_0x8CB8 = mMarkers.getField_0x0704(); + field_0x8DBE = 0; + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MAP_EXTEND); +} +void dLytMapMain_c::executeState_EventDungeonMapGet_Step2() { + dLytMapGlobal_c *global = getGlobal(); + if (mEventTimer != 0 || field_0x8CB4 != 0 || field_0x8CB8 != 0) { + if (mEventTimer != 0) { + mEventTimer--; + } + u8 u1 = (1.0f - (f32)mEventTimer / sHio.field_0x23) * 255.0f; + global->setField_0x4F(u1); + field_0x8DBE = u1; + if (field_0x8CB4 != 0) { + field_0x8CB4--; + } else { + mMarkers.setField_0x0702(1); + if (field_0x8CB8 != 0) { + field_0x8CB8--; + } + } + } else { + global->setField_0x4C(0); + mStateMgr.changeState(StateID_EventDungeonMapGet_Step3); + } +} void dLytMapMain_c::finalizeState_EventDungeonMapGet_Step2() {} -void dLytMapMain_c::initializeState_EventDungeonMapGet_Step3() {} -void dLytMapMain_c::executeState_EventDungeonMapGet_Step3() {} +void dLytMapMain_c::initializeState_EventDungeonMapGet_Step3() { + mEventTimer = sHio.field_0x25; +} +void dLytMapMain_c::executeState_EventDungeonMapGet_Step3() { + if (mEventTimer != 0) { + mEventTimer--; + } else { + field_0x8D6B = 1; + } +} void dLytMapMain_c::finalizeState_EventDungeonMapGet_Step3() {} -void dLytMapMain_c::initializeState_EventFieldMapChange_Step1() {} -void dLytMapMain_c::executeState_EventFieldMapChange_Step1() {} +void dLytMapMain_c::initializeState_EventFieldMapChange_Step1() { + mEventTimer = sHio.field_0x26; +} +void dLytMapMain_c::executeState_EventFieldMapChange_Step1() { + if (mEventTimer != 0) { + mEventTimer--; + } else { + mStateMgr.changeState(StateID_EventFieldMapChange_Step2); + } +} void dLytMapMain_c::finalizeState_EventFieldMapChange_Step1() {} -void dLytMapMain_c::initializeState_EventFieldMapChange_Step2() {} -void dLytMapMain_c::executeState_EventFieldMapChange_Step2() {} +void dLytMapMain_c::initializeState_EventFieldMapChange_Step2() { + mEventTimer = sHio.field_0x27; + field_0x8DBE = 0; + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MAP_EXTEND); +} +void dLytMapMain_c::executeState_EventFieldMapChange_Step2() { + dStage_c *stage = dStage_c::GetInstance(); + u32 duration = sHio.field_0x27; + if (mEventTimer != 0) { + u8 u1 = (f32)(duration - mEventTimer) / (f32)duration * 255.0f; + stage->getMapRelated()->setField_0x1E8(u1); + mEventTimer--; + } else { + stage->getMapRelated()->setField_0x1E8(0); + stage->getMapRelated()->setField_0x1EF(1); + mStateMgr.changeState(StateID_EventFieldMapChange_Step3); + } +} void dLytMapMain_c::finalizeState_EventFieldMapChange_Step2() {} -void dLytMapMain_c::initializeState_EventFieldMapChange_Step3() {} -void dLytMapMain_c::executeState_EventFieldMapChange_Step3() {} +void dLytMapMain_c::initializeState_EventFieldMapChange_Step3() { + mEventTimer = sHio.field_0x28; +} +void dLytMapMain_c::executeState_EventFieldMapChange_Step3() { + if (mEventTimer != 0) { + mEventTimer--; + } else if (field_0x8C94 == 8) { + mStateMgr.changeState(StateID_Active); + } else { + mStateMgr.changeState(StateID_EventFieldMapChange_Step4); + } +} void dLytMapMain_c::finalizeState_EventFieldMapChange_Step3() {} void dLytMapMain_c::initializeState_EventFieldMapChange_Step4() {} void dLytMapMain_c::executeState_EventFieldMapChange_Step4() {} void dLytMapMain_c::finalizeState_EventFieldMapChange_Step4() {} -void dLytMapMain_c::initializeState_EventForestMapChange_Step1() {} -void dLytMapMain_c::executeState_EventForestMapChange_Step1() {} +void dLytMapMain_c::initializeState_EventForestMapChange_Step1() { + mEventTimer = sHio.field_0x22; +} +void dLytMapMain_c::executeState_EventForestMapChange_Step1() { + if (mEventTimer != 0) { + mEventTimer--; + } else { + mStateMgr.changeState(StateID_EventForestMapChange_Step2); + } +} void dLytMapMain_c::finalizeState_EventForestMapChange_Step1() {} -void dLytMapMain_c::initializeState_EventForestMapChange_Step2() {} -void dLytMapMain_c::executeState_EventForestMapChange_Step2() {} +void dLytMapMain_c::initializeState_EventForestMapChange_Step2() { + mEventTimer = sHio.field_0x23; + field_0x8CB4 = sHio.field_0x24; + field_0x8CB8 = mMarkers.getField_0x0704(); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MAP_EXTEND); + field_0x8DBE = 0; +} +void dLytMapMain_c::executeState_EventForestMapChange_Step2() { + dLytMapGlobal_c *global = getGlobal(); + if (mEventTimer != 0 || field_0x8CB4 != 0 || field_0x8CB8 != 0) { + if (mEventTimer != 0) { + mEventTimer--; + } + u8 u1 = (1.0f - (f32)mEventTimer / sHio.field_0x23) * 255.0f; + global->setField_0x4F(u1); + field_0x8DBE = u1; + if (field_0x8CB4 != 0) { + field_0x8CB4--; + } else { + mMarkers.setField_0x0702(1); + if (field_0x8CB8 != 0) { + field_0x8CB8--; + } + } + } else { + global->setField_0x4C(0); + mStateMgr.changeState(StateID_EventForestMapChange_Step3); + } +} void dLytMapMain_c::finalizeState_EventForestMapChange_Step2() {} -void dLytMapMain_c::initializeState_EventForestMapChange_Step3() {} -void dLytMapMain_c::executeState_EventForestMapChange_Step3() {} +void dLytMapMain_c::initializeState_EventForestMapChange_Step3() { + mEventTimer = sHio.field_0x25; +} +void dLytMapMain_c::executeState_EventForestMapChange_Step3() { + if (mEventTimer != 0) { + mEventTimer--; + } else { + field_0x8D6B = 1; + } +} void dLytMapMain_c::finalizeState_EventForestMapChange_Step3() {} void dLytMapMain_c::initializeState_EventSignalAdd_Step1() {} -void dLytMapMain_c::executeState_EventSignalAdd_Step1() {} +void dLytMapMain_c::executeState_EventSignalAdd_Step1() { + if (mDisplayedBeaconCount != getMaxBeaconCount()) { + mStateMgr.changeState(StateID_EventSignalAdd_Step2); + } +} void dLytMapMain_c::finalizeState_EventSignalAdd_Step1() {} -void dLytMapMain_c::initializeState_EventSignalAdd_Step2() {} -void dLytMapMain_c::executeState_EventSignalAdd_Step2() {} +void dLytMapMain_c::initializeState_EventSignalAdd_Step2() { + mEventTimer = sHio.field_0x29; +} +void dLytMapMain_c::executeState_EventSignalAdd_Step2() { + if (mDisplayedBeaconCount == getMaxBeaconCount()) { + mStateMgr.changeState(StateID_EventSignalAdd_Step3); + } else if (--mEventTimer == 0) { + mEventTimer = sHio.field_0x29; + mDisplayedBeaconCount++; + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_MAP_BEACON_COUNT_UP); + } +} void dLytMapMain_c::finalizeState_EventSignalAdd_Step2() {} -void dLytMapMain_c::initializeState_EventSignalAdd_Step3() {} -void dLytMapMain_c::executeState_EventSignalAdd_Step3() {} +void dLytMapMain_c::initializeState_EventSignalAdd_Step3() { + mEventTimer = sHio.field_0x25; +} +void dLytMapMain_c::executeState_EventSignalAdd_Step3() { + if (mEventTimer != 0) { + mEventTimer--; + } else { + mStateMgr.changeState(StateID_Active); + } +} void dLytMapMain_c::finalizeState_EventSignalAdd_Step3() {} -void dLytMapMain_c::initializeState_EventGoddessCube_Step1() {} -void dLytMapMain_c::executeState_EventGoddessCube_Step1() {} -void dLytMapMain_c::finalizeState_EventGoddessCube_Step1() {} +bool dLytMapMain_c::fn_80141530() const { + return EventManager::isInEvent() && field_0x8C94 != 11; +} + +dAcTbox_c *dLytMapMain_c::findGoddessChestForStoryflag(s32 flag) const { + dAcTbox_c *ret = nullptr; + fBase_c *it = nullptr; + while ((it = fManager_c::searchBaseByGroupType(fBase_c::ACTOR, it)) != nullptr) { + if (it->mProfileName == fProfile::TBOX) { + dAcTbox_c *box = static_cast(it); + if (box->getVariant() == dAcTbox_c::GODDESS) { + u16 boxFlag = box->getParams2Lower(); + if (flag == boxFlag) { + ret = box; + break; + } + } + } + } + return ret; +} + +void dLytMapMain_c::initializeState_EventGoddessCube_Step1() { + mEventTimer = 30; +} +void dLytMapMain_c::executeState_EventGoddessCube_Step1() { + if (mEventTimer != 0) { + mEventTimer--; + } + if (mEventTimer == 0) { + mStateMgr.changeState(StateID_Active); + } +} +void dLytMapMain_c::finalizeState_EventGoddessCube_Step1() { + mEventTimer = 50; +} void dLytMapMain_c::initializeState_EventGoddessCube_Step2() {} void dLytMapMain_c::executeState_EventGoddessCube_Step2() {} void dLytMapMain_c::finalizeState_EventGoddessCube_Step2() {} void dLytMapMain_c::initializeState_EventGoddessCube_Step3() {} -void dLytMapMain_c::executeState_EventGoddessCube_Step3() {} +void dLytMapMain_c::executeState_EventGoddessCube_Step3() { + mStateMgr.changeState(StateID_Active); +} void dLytMapMain_c::finalizeState_EventGoddessCube_Step3() {} -void dLytMapMain_c::initializeState_EventSaveObjMsgWindow() {} -void dLytMapMain_c::executeState_EventSaveObjMsgWindow() {} +bool dLytMapMain_c::checkStoryflag(s32 flag) const { + return StoryflagManager::sInstance->getFlag(flag); +} + +void dLytMapMain_c::initializeState_EventSaveObjMsgWindow() { + if (mProvince == PROVINCE_FARON && checkStoryflag(STORYFLAG_LEVIAS_FIGHT_DEFEATED) && + !checkStoryflag(STORYFLAG_FLOODED_FARON_WOODS_DISCOVERED)) { + // "A report, Master. An unusual phenomenon is taking place in Faron Woods, making it impossible to descend + // directly into them at the moment." + mFlowMgr.triggerEntryPoint(4, 18, 0, 0); + } else { + // "It is possible to descend to a specific..." / "Point to your preferred descent area..." + mFlowMgr.triggerEntryPoint(4, 19, 0, 0); + } +} +void dLytMapMain_c::executeState_EventSaveObjMsgWindow() { + if (mFlowMgr.checkFinished()) { + mStateMgr.changeState(StateID_EventSaveObjSelect); + } +} void dLytMapMain_c::finalizeState_EventSaveObjMsgWindow() {} +enum dLytMapSaveObjFlagKind { + SAVE_OBJ_FLAG_KIND_SCENEFLAG = 0, + SAVE_OBJ_FLAG_KIND_STORYFLAG = 1, +}; + +struct dLytMapSaveObjFlagDefinition { + /* 0x00 */ dLytMapSaveObjFlagKind flagType; + // I wanted designated initializers but MWCC doesn't have them... + /* 0x04 */ union { + struct { + /* 0x04 */ u16 flagArea; + /* 0x06 */ u16 sceneFlag; + }; + struct { + /* 0x04 */ s16 storyFlag; + /* 0x06 */ u16 _padding; + }; + }; +}; + +static const dLytMapSaveObjFlagDefinition sSaveObjFlagsFaron[] = { + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 10, 31}, + {SAVE_OBJ_FLAG_KIND_STORYFLAG, STORYFLAG_800}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, STORYFLAG_801}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, STORYFLAG_802}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, STORYFLAG_803}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 1, 104}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 1, 103}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 2, 32}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 2, 33}, + {SAVE_OBJ_FLAG_KIND_STORYFLAG, STORYFLAG_FARON_DISCOVERED}, +}; + +static const dLytMapSaveObjFlagDefinition sSaveObjFlagsEldin[] = { + {SAVE_OBJ_FLAG_KIND_STORYFLAG, STORYFLAG_804}, + {SAVE_OBJ_FLAG_KIND_STORYFLAG, STORYFLAG_805}, + {SAVE_OBJ_FLAG_KIND_STORYFLAG, STORYFLAG_806}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, STORYFLAG_807}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 5, 101}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 15, 114}, +}; + +static const dLytMapSaveObjFlagDefinition sSaveObjFlagsLanayru[] = { + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 7, 68}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 7, 66}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 7, 51}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 7, 67}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 7, 2}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 7, 77}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 7, 78}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 8, 10}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 8, 28}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 8, 85}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 8, 84}, + {SAVE_OBJ_FLAG_KIND_SCENEFLAG, 9, 12}, +}; + +void dLytMapMain_c::displaySaveObjs() { + for (int i = 0; i < field_0x8320; i++) { + mSaveObjs[i].init(); + } + + s32 numFlags = ARRAY_LENGTH(sSaveObjFlagsFaron); + nw4r::lyt::Bounding **pBoundings = field_0x821C; + const dLytMapSaveObjFlagDefinition *flagSet = sSaveObjFlagsFaron; + switch (mProvince) { + case PROVINCE_ELDIN: { + pBoundings = field_0x8244; + flagSet = sSaveObjFlagsEldin; + numFlags = ARRAY_LENGTH(sSaveObjFlagsEldin); + break; + } + case PROVINCE_LANAYRU: { + pBoundings = field_0x825C; + flagSet = sSaveObjFlagsLanayru; + numFlags = ARRAY_LENGTH(sSaveObjFlagsLanayru); + break; + } + } + + bool isInFaronSothMode = false; + bool isInFaronFloodedMode = false; + + if (mProvince == PROVINCE_FARON) { + if (checkStoryflag(STORYFLAG_LEVIAS_FIGHT_DEFEATED) && + !checkStoryflag(STORYFLAG_FLOODED_FARON_WOODS_DISCOVERED)) { + isInFaronSothMode = true; + } else if (checkStoryflag(STORYFLAG_FLOODED_FARON_WOODS_DISCOVERED) && + !checkStoryflag(STORYFLAG_WATER_DRAGON_SOTH_PART)) { + isInFaronFloodedMode = true; + } + } + + for (int i = 0; i < numFlags; i++) { + bool visible = false; + if (isInFaronSothMode) { + if (i == 0 || i == 9) { + visible = true; + } + } else if (isInFaronFloodedMode) { + if (i == 0 || i == 4 || i == 9) { + visible = true; + } + } else if (flagSet[i].flagType == SAVE_OBJ_FLAG_KIND_SCENEFLAG) { + visible = SceneflagManager::sInstance->checkSceneflagGlobal(flagSet[i].flagArea, flagSet[i].sceneFlag); + } else if (flagSet[i].flagType == SAVE_OBJ_FLAG_KIND_STORYFLAG) { + visible = checkStoryflag(flagSet[i].storyFlag); + } + // TODO - SetVisible clrlwi + pBoundings[i]->SetVisible(visible); + } +} + void dLytMapMain_c::initializeState_EventSaveObjSelect() {} -void dLytMapMain_c::executeState_EventSaveObjSelect() {} +void dLytMapMain_c::executeState_EventSaveObjSelect() { + mSavePopup.setCurrentStatue(-1); + s32 currentSelected = getSelectedSaveObjIdx(); + + bool anyDecide = false; + for (int i = 0; i < field_0x8320; i++) { + if (mSaveObjs[i].mStateMgr.isState(dLytMapSaveObj_c::StateID_Decide)) { + anyDecide = true; + } + } + + for (int i = 0; i < field_0x8320; i++) { + mSaveObjs[i].mSelectRequest = false; + if (currentSelected == i && !anyDecide) { + mSaveObjs[i].mSelectRequest = true; + if (!mSaveObjs[i].mDecideRequest) { + mSavePopup.setCurrentStatue(i); + } + } + mSaveObjs[i].execute(); + bool select = false; + if (mSaveObjs[i].mSelectRequest) { + if (*mSaveObjs[i].mStateMgr.getStateID() == dLytMapSaveObj_c::StateID_Select) { + select = true; + } + } + + if (select && dPad::getDownTrigA()) { + mSaveObjs[i].mDecideRequest = true; + mSavePopup.setCurrentStatue(-1); + mSavePopup.hide(i); + } + } + + field_0x8DC0 = currentSelected; + + bool found = false; + s32 statueIdx = 0; + for (int i = 0; i < field_0x8320; i++) { + if (mSaveObjs[i].mDecideFinished) { + found = true; + statueIdx = i; + break; + } + } + + if (found) { + const dMapSaveObjDefinition *def = getSaveObjDefinition(mProvince, statueIdx); + mSaveCaption.setLabel(def->statueLabel); + mSaveCaption.setType(def->type); + mSaveCaption.mStateMgr.changeState(dLytMapSaveCaption_c::StateID_In); + mStateMgr.changeState(StateID_EventSaveObjConfirmMsgWindow); + } else { + mSavePopup.execute(); + } + + for (int i = 0; i < (int)ARRAY_LENGTH(mHitChecks); i++) { + mHitChecks[i].resetCachedHitboxes(); + mHitChecks[i].execute(); + } +} void dLytMapMain_c::finalizeState_EventSaveObjSelect() {} -void dLytMapMain_c::initializeState_EventSaveObjConfirmMsgWindow() {} +void dLytMapMain_c::initializeState_EventSaveObjConfirmMsgWindow() { + // "Descend into this area? [1]Yes.[2-]No." + mFlowMgr.triggerEntryPoint(4, 17, 0, 0); +} void dLytMapMain_c::executeState_EventSaveObjConfirmMsgWindow() {} void dLytMapMain_c::finalizeState_EventSaveObjConfirmMsgWindow() {} @@ -3612,8 +4017,8 @@ void dLytMapMain_c::checkCursorPointedAtMap() { if (pointerOnMap) { for (int i = 0; i < MAP_MAIN_NUM_BOUNDINGS_NORMAL; i++) { - if (pos3d.x >= field_0x8948[i].field_0x00.x && pos3d.x <= field_0x8948[i].field_0x0C.x && - pos3d.z >= field_0x8948[i].field_0x00.z && pos3d.z <= field_0x8948[i].field_0x0C.z) { + if (pos3d.x >= mBoundingWorldBounds[i].min.x && pos3d.x <= mBoundingWorldBounds[i].max.x && + pos3d.z >= mBoundingWorldBounds[i].min.z && pos3d.z <= mBoundingWorldBounds[i].max.z) { // Cannot place beacon when hovering over UI element (remocon, ...) canPlaceBeacon = false; break; @@ -3624,3 +4029,13 @@ void dLytMapMain_c::checkCursorPointedAtMap() { mPointerOnMap = pointerOnMap; mPointerCanPlaceBeacon = canPlaceBeacon; } + +void dLytMap_c::build() { + d2d::setLytAllocator(); + void *data = LayoutArcManager::GetInstance()->getLoadedData("Map2D"); + mResAcc.attach(data, ""); + mMapMain.build(); + m2d::setLytAllocator(); + mMapMain.setPriority(0x86); + // TODO there's another thing here at 0x91C0 +} diff --git a/src/d/lyt/d_lyt_map_markers.cpp b/src/d/lyt/d_lyt_map_markers.cpp index 41863ddf..7db716a5 100644 --- a/src/d/lyt/d_lyt_map_markers.cpp +++ b/src/d/lyt/d_lyt_map_markers.cpp @@ -1181,7 +1181,7 @@ void dLytMapIcon01_c::setSaveObj(u32 color, nw4r::lyt::Pane *pane) { void dLytMapIcon01_c::setTerry(bool present) { // NONMATCHING - // Additional clrlwi here... + // TODO - SetVisible clrlwi // When you fix this, maybe also fix other instances of this problem // by searching for 91657b77 mpTerryOnOffPane->SetVisible(present); diff --git a/src/d/lyt/msg_window/d_lyt_msg_window_get.cpp b/src/d/lyt/msg_window/d_lyt_msg_window_get.cpp index d595badc..4274e323 100644 --- a/src/d/lyt/msg_window/d_lyt_msg_window_get.cpp +++ b/src/d/lyt/msg_window/d_lyt_msg_window_get.cpp @@ -177,6 +177,7 @@ bool dLytMsgWindowGet_c::execute() { void dLytMsgWindowGet_c::draw() { // NONMATCHING + // TODO - SetVisible clrlwi // The instruction patterns here are the same that EGG::StateGX::Scoped // generates, but there's no RAII to be found here. What's the missing // link that makes the compiler generate these? diff --git a/src/d/lyt/msg_window/d_lyt_msg_window_link.cpp b/src/d/lyt/msg_window/d_lyt_msg_window_link.cpp index 7b03ef4b..6564a7f3 100644 --- a/src/d/lyt/msg_window/d_lyt_msg_window_link.cpp +++ b/src/d/lyt/msg_window/d_lyt_msg_window_link.cpp @@ -240,6 +240,7 @@ bool dLytMsgWindowLink_c::execute() { void dLytMsgWindowLink_c::draw() { // NONMATCHING + // TODO - SetVisible clrlwi // The instruction patterns here are the same that EGG::StateGX::Scoped // generates, but there's no RAII to be found here. What's the missing // link that makes the compiler generate these? diff --git a/src/d/lyt/msg_window/d_lyt_msg_window_talk.cpp b/src/d/lyt/msg_window/d_lyt_msg_window_talk.cpp index 30adeeab..8f9cde37 100644 --- a/src/d/lyt/msg_window/d_lyt_msg_window_talk.cpp +++ b/src/d/lyt/msg_window/d_lyt_msg_window_talk.cpp @@ -240,6 +240,7 @@ bool dLytMsgWindowTalk_c::execute() { void dLytMsgWindowTalk_c::draw() { // NONMATCHING + // TODO - SetVisible clrlwi // The instruction patterns here are the same that EGG::StateGX::Scoped // generates, but there's no RAII to be found here. What's the missing // link that makes the compiler generate these?