From ad57f227babca1b47de7b02c8ce7d782f3b14279 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 14 Sep 2024 20:51:59 +0200 Subject: [PATCH] d_t_time_area_check OK (and some dTimeAreaMgr) --- .../rels/d_t_time_area_checkNP/splits.txt | 2 + .../rels/d_t_time_area_checkNP/symbols.txt | 20 +++--- config/SOUE01/splits.txt | 3 + config/SOUE01/symbols.txt | 26 ++++---- configure.py | 3 +- include/d/tg/d_t_time_area_check.h | 21 +++++++ include/toBeSorted/scgame.h | 2 + include/toBeSorted/time_area_mgr.h | 56 +++++++++++++++++ src/REL/d/t/d_t_time_area_check.cpp | 39 ++++++++++++ src/toBeSorted/time_area_mgr.cpp | 61 +++++++++++++++++++ tools/rel_sieve.py | 1 - 11 files changed, 209 insertions(+), 25 deletions(-) create mode 100644 include/d/tg/d_t_time_area_check.h create mode 100644 include/toBeSorted/time_area_mgr.h create mode 100644 src/toBeSorted/time_area_mgr.cpp diff --git a/config/SOUE01/rels/d_t_time_area_checkNP/splits.txt b/config/SOUE01/rels/d_t_time_area_checkNP/splits.txt index 99b07bfd..5d7f9bb8 100644 --- a/config/SOUE01/rels/d_t_time_area_checkNP/splits.txt +++ b/config/SOUE01/rels/d_t_time_area_checkNP/splits.txt @@ -11,3 +11,5 @@ REL/executor.c: REL/d/t/d_t_time_area_check.cpp: .text start:0x00000070 end:0x0000030C + .rodata start:0x00000000 end:0x00000008 + .data start:0x00000000 end:0x00000084 diff --git a/config/SOUE01/rels/d_t_time_area_checkNP/symbols.txt b/config/SOUE01/rels/d_t_time_area_checkNP/symbols.txt index 8a8ebc82..0086bf8f 100644 --- a/config/SOUE01/rels/d_t_time_area_checkNP/symbols.txt +++ b/config/SOUE01/rels/d_t_time_area_checkNP/symbols.txt @@ -1,15 +1,15 @@ _prolog = .text:0x00000000; // type:function size:0x2C scope:global _epilog = .text:0x00000030; // type:function size:0x2C scope:global _unresolved = .text:0x00000060; // type:function size:0x4 scope:global -fn_597_70 = .text:0x00000070; // type:function size:0x4C -fn_597_C0 = .text:0x000000C0; // type:function size:0x18 -fn_597_E0 = .text:0x000000E0; // type:function size:0x8 -fn_597_F0 = .text:0x000000F0; // type:function size:0x1AC -fn_597_2A0 = .text:0x000002A0; // type:function size:0x8 -fn_597_2B0 = .text:0x000002B0; // type:function size:0x5C +dTgTimeAreaCheck_c_classInit__Fv = .text:0x00000070; // type:function size:0x4C +create__18dTgTimeAreaCheck_cFv = .text:0x000000C0; // type:function size:0x18 +doDelete__18dTgTimeAreaCheck_cFv = .text:0x000000E0; // type:function size:0x8 +actorExecute__18dTgTimeAreaCheck_cFv = .text:0x000000F0; // type:function size:0x1AC +draw__18dTgTimeAreaCheck_cFv = .text:0x000002A0; // type:function size:0x8 +__dt__18dTgTimeAreaCheck_cFv = .text:0x000002B0; // type:function size:0x5C _ctors = .ctors:0x00000000; // type:label scope:global _dtors = .dtors:0x00000000; // type:label scope:global -lbl_597_rodata_0 = .rodata:0x00000000; // type:object size:0x4 data:float -lbl_597_rodata_4 = .rodata:0x00000004; // type:object size:0x4 data:float -lbl_597_data_0 = .data:0x00000000; // type:object size:0x10 -lbl_597_data_10 = .data:0x00000010; // type:object size:0x74 +lbl_597_rodata_0 = .rodata:0x00000000; // type:object size:0x4 scope:local data:float +lbl_597_rodata_4 = .rodata:0x00000004; // type:object size:0x4 scope:local data:float +g_profile_TAG_TIME_AREA_CHECK = .data:0x00000000; // type:object size:0x10 +__vt__18dTgTimeAreaCheck_c = .data:0x00000010; // type:object size:0x74 diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 45ac905e..8c2101d8 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -154,6 +154,9 @@ toBeSorted/dowsing_target.cpp: .sdata2 start:0x80579640 end:0x80579670 .bss start:0x805A2FB0 end:0x805A3010 +toBeSorted/time_area_mgr.cpp: + .text start:0x800B9280 end:0x800BB2A0 + toBeSorted/sceneflag_manager.cpp: .text start:0x800BD8C0 end:0x800BE7A8 .sbss start:0x805753E0 end:0x805753F0 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index a745d22e..e4c7e56a 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -3962,18 +3962,18 @@ fn_800B8B40 = .text:0x800B8B40; // type:function size:0x4C fn_800B8B90 = .text:0x800B8B90; // type:function size:0x4C fn_800B8BE0 = .text:0x800B8BE0; // type:function size:0x34 fn_800B8C20 = .text:0x800B8C20; // type:function size:0x654 -fn_800B9280 = .text:0x800B9280; // type:function size:0xF0 -fn_800B9370 = .text:0x800B9370; // type:function size:0x58 -fn_800B93D0 = .text:0x800B93D0; // type:function size:0x58 -fn_800B9430 = .text:0x800B9430; // type:function size:0x84 -fn_800B94C0 = .text:0x800B94C0; // type:function size:0xA0 +__ct__14dTimeAreaMgr_cFv = .text:0x800B9280; // type:function size:0xF0 +__dt__19dTimeAreaMgrProcA_cFv = .text:0x800B9370; // type:function size:0x58 +__dt__19dTimeAreaMgrProcB_cFv = .text:0x800B93D0; // type:function size:0x58 +__dt__14dTimeAreaMgr_cFv = .text:0x800B9430; // type:function size:0x84 +init__14dTimeAreaMgr_cFv = .text:0x800B94C0; // type:function size:0xA0 fn_800B9560 = .text:0x800B9560; // type:function size:0x1BC -fn_800B9720 = .text:0x800B9720; // type:function size:0x6C +draw__14dTimeAreaMgr_cFv = .text:0x800B9720; // type:function size:0x6C fn_800B9790 = .text:0x800B9790; // type:function size:0x58 fn_800B97F0 = .text:0x800B97F0; // type:function size:0x88 fn_800B9880 = .text:0x800B9880; // type:function size:0xFC fn_800B9980 = .text:0x800B9980; // type:function size:0xCC -fn_800B9A50 = .text:0x800B9A50; // type:function size:0x104 +checkPositionIsInPastState__14dTimeAreaMgr_cFlRC7mVec3_cPff = .text:0x800B9A50; // type:function size:0x104 fn_800B9B60 = .text:0x800B9B60; // type:function size:0xB4 fn_800B9C20 = .text:0x800B9C20; // type:function size:0xB4 fn_800B9CE0 = .text:0x800B9CE0; // type:function size:0xA0 @@ -3984,10 +3984,10 @@ fn_800BA1F0 = .text:0x800BA1F0; // type:function size:0x124 fn_800BA320 = .text:0x800BA320; // type:function size:0x50C fn_800BA830 = .text:0x800BA830; // type:function size:0xF8 fn_800BA930 = .text:0x800BA930; // type:function size:0x3BC -fn_800BACF0 = .text:0x800BACF0; // type:function size:0x244 -fn_800BAF40 = .text:0x800BAF40; // type:function size:0x64 -fn_800BAFB0 = .text:0x800BAFB0; // type:function size:0x26C -fn_800BB220 = .text:0x800BB220; // type:function size:0x80 +drawOpa__19dTimeAreaMgrProcA_cFv = .text:0x800BACF0; // type:function size:0x244 +create__19dTimeAreaMgrProcA_cFP16mHeapAllocator_c = .text:0x800BAF40; // type:function size:0x64 +drawOpa__19dTimeAreaMgrProcB_cFv = .text:0x800BAFB0; // type:function size:0x26C +create__19dTimeAreaMgrProcB_cFP16mHeapAllocator_c = .text:0x800BB220; // type:function size:0x80 fn_800BB2A0 = .text:0x800BB2A0; // type:function size:0x60 fn_800BB300 = .text:0x800BB300; // type:function size:0x64 fn_800BB370 = .text:0x800BB370; // type:function size:0x20 @@ -11186,7 +11186,7 @@ fn_801BB2D0 = .text:0x801BB2D0; // type:function size:0x8 fn_801BB2E0 = .text:0x801BB2E0; // type:function size:0xC fn_801BB2F0 = .text:0x801BB2F0; // type:function size:0x88 fn_801BB380 = .text:0x801BB380; // type:function size:0x34 -fn_801BB3C0 = .text:0x801BB3C0; // type:function size:0x10 +isCurrentStage__6ScGameFPCc = .text:0x801BB3C0; // type:function size:0x10 fn_801BB3D0 = .text:0x801BB3D0; // type:function size:0x54 fn_801BB430 = .text:0x801BB430; // type:function size:0x54 fn_801BB490 = .text:0x801BB490; // type:function size:0x78 @@ -39897,7 +39897,7 @@ lbl_805753AC = .sbss:0x805753AC; // type:object size:0x4 data:4byte lbl_805753B0 = .sbss:0x805753B0; // type:object size:0x8 data:4byte lbl_805753B8 = .sbss:0x805753B8; // type:object size:0x1 data:byte lbl_805753BC = .sbss:0x805753BC; // type:object size:0x4 data:4byte -lbl_805753C0 = .sbss:0x805753C0; // type:object size:0x4 data:4byte +sInstance__14dTimeAreaMgr_c = .sbss:0x805753C0; // type:object size:0x4 data:4byte lbl_805753C4 = .sbss:0x805753C4; // type:object size:0x1 data:byte lbl_805753C8 = .sbss:0x805753C8; // type:object size:0x8 data:4byte lbl_805753D0 = .sbss:0x805753D0; // type:object size:0x8 data:4byte diff --git a/configure.py b/configure.py index eca0c997..0d41dd05 100644 --- a/configure.py +++ b/configure.py @@ -316,6 +316,7 @@ def nw4rLib(lib_name, objects, extra_cflags=[]): Object(Matching, "toBeSorted/arc_managers/oarc_manager.cpp"), Object(Matching, "toBeSorted/arc_managers/layout_arc_manager.cpp"), Object(NonMatching, "toBeSorted/dowsing_target.cpp"), + Object(NonMatching, "toBeSorted/time_area_mgr.cpp"), Object(Matching, "toBeSorted/save_file.cpp"), Object(Matching, "toBeSorted/counters/counter.cpp"), Object(Matching, "toBeSorted/counters/rupee_counter.cpp"), @@ -1182,7 +1183,7 @@ def nw4rLib(lib_name, objects, extra_cflags=[]): Rel(Matching, "d_t_tackle", "REL/d/t/d_t_tackle.cpp"), Rel(NonMatching, "d_t_telop", "REL/d/t/d_t_telop.cpp"), Rel(Matching, "d_t_timer", "REL/d/t/d_t_timer.cpp"), - Rel(NonMatching, "d_t_time_area_check", "REL/d/t/d_t_time_area_check.cpp"), + Rel(Matching, "d_t_time_area_check", "REL/d/t/d_t_time_area_check.cpp"), Rel(NonMatching, "d_t_time_door_beam", "REL/d/t/d_t_time_door_beam.cpp"), Rel(NonMatching, "d_t_touch", "REL/d/t/d_t_touch.cpp"), Rel(NonMatching, "d_t_tumble_weed", "REL/d/t/d_t_tumble_weed.cpp"), diff --git a/include/d/tg/d_t_time_area_check.h b/include/d/tg/d_t_time_area_check.h new file mode 100644 index 00000000..1c890a51 --- /dev/null +++ b/include/d/tg/d_t_time_area_check.h @@ -0,0 +1,21 @@ +#ifndef D_T_TIME_AREA_CHECK_H +#define D_T_TIME_AREA_CHECK_H + +#include + +class dTgTimeAreaCheck_c : public dTg_c { +public: + dTgTimeAreaCheck_c() {} + virtual ~dTgTimeAreaCheck_c() {} + + virtual int create() override; + virtual int doDelete() override; + virtual int actorExecute() override; + virtual int draw() override; + +private: + u8 mPastSceneFlag; + u8 mPresentSceneFlag; +}; + +#endif diff --git a/include/toBeSorted/scgame.h b/include/toBeSorted/scgame.h index 32e9538b..8ac27782 100644 --- a/include/toBeSorted/scgame.h +++ b/include/toBeSorted/scgame.h @@ -24,6 +24,8 @@ class ScGame { static SpawnInfo currentSpawnInfo; static SpawnInfo nextSpawnInfo; static ScGame *sInstance; + + static bool isCurrentStage(const char *stageName); }; #endif diff --git a/include/toBeSorted/time_area_mgr.h b/include/toBeSorted/time_area_mgr.h new file mode 100644 index 00000000..ab160006 --- /dev/null +++ b/include/toBeSorted/time_area_mgr.h @@ -0,0 +1,56 @@ +#ifndef D_TIME_AREA_MGR_H +#define D_TIME_AREA_MGR_H + +#include +#include +#include + + +class dTimeAreaMgrProcA_c : public m3d::proc_c { +public: + dTimeAreaMgrProcA_c() {} + + bool create(mHeapAllocator_c *alloc); + + void drawOpa() override; +}; + +class dTimeAreaMgrProcB_c : public m3d::proc_c { +public: + dTimeAreaMgrProcB_c() {} + + bool create(mHeapAllocator_c *alloc); + + void drawOpa() override; + +private: + /* 0x18 */ u8 field_0x18; + /* 0x19 */ u8 field_0x19; + /* 0x1A */ u8 field_0x1A; + /* 0x1B */ u8 field_0x1B; +}; + +class dTimeAreaMgr_c { +public: + dTimeAreaMgr_c(); + virtual ~dTimeAreaMgr_c(); + + bool init(); + void draw(); + + f32 checkPositionIsInPastState(s32 roomId, const mVec3_c &position, float *, float); + + static dTimeAreaMgr_c *sInstance; + +private: + /* 0x04 */ u8 field_0x04[0x0C - 0x04]; + /* 0x0C */ mHeapAllocator_c mAllocator; + /* 0x28 */ dTimeAreaMgrProcA_c mProcA; + /* 0x40 */ dTimeAreaMgrProcB_c mProcB; + /* 0x5C */ u8 field_0x5C[0x64 - 0x5C]; + /* 0x64 */ s32 field_0x64; + /* 0x68 */ u8 field_0x68[0x7B - 0x68]; + /* 0x7B */ bool mIsInLanayruMiningFacility; +}; + +#endif diff --git a/src/REL/d/t/d_t_time_area_check.cpp b/src/REL/d/t/d_t_time_area_check.cpp index e69de29b..3030b53a 100644 --- a/src/REL/d/t/d_t_time_area_check.cpp +++ b/src/REL/d/t/d_t_time_area_check.cpp @@ -0,0 +1,39 @@ +#include +#include +#include + +SPECIAL_ACTOR_PROFILE(TAG_TIME_AREA_CHECK, dTgTimeAreaCheck_c, fProfile::TAG_TIME_AREA_CHECK, 0x01AC, 0, 0); + +int dTgTimeAreaCheck_c::create() { + mPastSceneFlag = params & 0xFF; + mPresentSceneFlag = (params >> 8) & 0xFF; + return SUCCEEDED; +} + +int dTgTimeAreaCheck_c::doDelete() { + return 1; +} + +int dTgTimeAreaCheck_c::actorExecute() { + f32 result = dTimeAreaMgr_c::sInstance->checkPositionIsInPastState(roomid, position, nullptr, 10.0f); + if (result > 0.0f) { + if (mPastSceneFlag < 0xFF && !SceneflagManager::sInstance->checkBoolFlag(roomid, mPastSceneFlag)) { + SceneflagManager::sInstance->setFlag(roomid, mPastSceneFlag); + } + if (mPresentSceneFlag < 0xFF && SceneflagManager::sInstance->checkBoolFlag(roomid, mPresentSceneFlag)) { + SceneflagManager::sInstance->unsetFlag(roomid, mPresentSceneFlag); + } + } else { + if (mPastSceneFlag < 0xFF && SceneflagManager::sInstance->checkBoolFlag(roomid, mPastSceneFlag)) { + SceneflagManager::sInstance->unsetFlag(roomid, mPastSceneFlag); + } + if (mPresentSceneFlag < 0xFF && !SceneflagManager::sInstance->checkBoolFlag(roomid, mPresentSceneFlag)) { + SceneflagManager::sInstance->setFlag(roomid, mPresentSceneFlag); + } + } + return 1; +} + +int dTgTimeAreaCheck_c::draw() { + return 1; +} diff --git a/src/toBeSorted/time_area_mgr.cpp b/src/toBeSorted/time_area_mgr.cpp new file mode 100644 index 00000000..609a9129 --- /dev/null +++ b/src/toBeSorted/time_area_mgr.cpp @@ -0,0 +1,61 @@ +#include +#include +#include +#include + + +dTimeAreaMgr_c::dTimeAreaMgr_c() { + sInstance = this; +} + +dTimeAreaMgr_c::~dTimeAreaMgr_c() { + sInstance = nullptr; +} + +bool dTimeAreaMgr_c::init() { + mAllocator.replaceWithNewFrmHeap(-1, dHeap::work1Heap.heap, "dTimeAreaMgr_c::m_allocator", 0x20, 0); + mProcA.create(&mAllocator); + mProcB.create(&mAllocator); + mAllocator.adjustFrmHeap(); + mIsInLanayruMiningFacility = ScGame::isCurrentStage("D300") || ScGame::isCurrentStage("D300_1"); + return true; +} + +void dTimeAreaMgr_c::draw() { + if (field_0x64 != 0 && dTimeAreaMgr_c::sInstance->field_0x68[0x10] == 0) { + mProcA.entry(); + mProcB.entry(); + } +} + +void dTimeAreaMgrProcA_c::drawOpa() { + // TODO +} + +bool dTimeAreaMgrProcA_c::create(mHeapAllocator_c *alloc) { + if (!m3d::proc_c::create(alloc, nullptr)) { + return false; + } + + setPriorityDraw(0x0C, 0); + setOption(/* DISABLE_DRAW_XLU */ 0x07, 1); + return true; +} + +void dTimeAreaMgrProcB_c::drawOpa() { + // TODO +} + +bool dTimeAreaMgrProcB_c::create(mHeapAllocator_c *alloc) { + if (!m3d::proc_c::create(alloc, nullptr)) { + return false; + } + + setPriorityDraw(0x13, 0); + setOption(/* DISABLE_DRAW_XLU */ 0x07, 1); + field_0x18 = 0x8C; + field_0x19 = 0x64; + field_0x1A = 0x3C; + field_0x1B = 0x64; + return true; +} diff --git a/tools/rel_sieve.py b/tools/rel_sieve.py index 316a5767..329c7f90 100644 --- a/tools/rel_sieve.py +++ b/tools/rel_sieve.py @@ -42,7 +42,6 @@ ['fn_801695F0', 'LytCommonTitle::ctor'], ['fn_80067020', 'matrixCreateFromPosRotYScale'], ['fn_800C43D0', 'ActorEventFlowManagerRelated *FUN_800c43d0'], - ['fn_801BB3C0', 'isCurrentStage'], ['fn_8037DCC0', 'EnemySoundMgr'], ['fn_800A6690', 'ActorOnRail::ctor'], ['fn_80355080', 'getColliderManager'],