diff --git a/config/SOUE01/rels/d_t_sound_area_mgrNP/splits.txt b/config/SOUE01/rels/d_t_sound_area_mgrNP/splits.txt index 0f8b5ef0..2bef2260 100644 --- a/config/SOUE01/rels/d_t_sound_area_mgrNP/splits.txt +++ b/config/SOUE01/rels/d_t_sound_area_mgrNP/splits.txt @@ -2,7 +2,7 @@ Sections: .text type:code align:16 .ctors type:rodata align:4 .dtors type:rodata align:4 - .rodata type:rodata align:16 + .data type:data align:16 .bss type:bss align:8 REL/executor.c: @@ -10,3 +10,4 @@ REL/executor.c: REL/d/t/d_t_sound_area_mgr.cpp: .text start:0x00000070 end:0x000001D8 + .data start:0x00000000 end:0x00000084 diff --git a/config/SOUE01/rels/d_t_sound_area_mgrNP/symbols.txt b/config/SOUE01/rels/d_t_sound_area_mgrNP/symbols.txt index bbdc27f7..37fecae0 100644 --- a/config/SOUE01/rels/d_t_sound_area_mgrNP/symbols.txt +++ b/config/SOUE01/rels/d_t_sound_area_mgrNP/symbols.txt @@ -1,13 +1,13 @@ _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_498_70 = .text:0x00000070; // type:function size:0x54 -fn_498_D0 = .text:0x000000D0; // type:function size:0x44 -fn_498_120 = .text:0x00000120; // type:function size:0x8 -fn_498_130 = .text:0x00000130; // type:function size:0x28 -fn_498_160 = .text:0x00000160; // type:function size:0x8 -fn_498_170 = .text:0x00000170; // type:function size:0x68 +dTgSndMg_c_classInit__Fv = .text:0x00000070; // type:function size:0x54 +create__10dTgSndMg_cFv = .text:0x000000D0; // type:function size:0x44 +doDelete__10dTgSndMg_cFv = .text:0x00000120; // type:function size:0x8 +actorExecute__10dTgSndMg_cFv = .text:0x00000130; // type:function size:0x28 +draw__10dTgSndMg_cFv = .text:0x00000160; // type:function size:0x8 +__dt__10dTgSndMg_cFv = .text:0x00000170; // type:function size:0x68 _ctors = .ctors:0x00000000; // type:label scope:global _dtors = .dtors:0x00000000; // type:label scope:global -lbl_498_section4_0 = .rodata:0x00000000; // type:object size:0x10 -lbl_498_section4_10 = .rodata:0x00000010; // type:object size:0x74 +g_profile_SOUND_AREA_MGR = .data:0x00000000; // type:object size:0x10 +__vt__10dTgSndMg_c = .data:0x00000010; // type:object size:0x74 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 0f0ef210..268e77c7 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -40014,7 +40014,7 @@ lbl_805756E0 = .sbss:0x805756E0; // type:object size:0x4 data:4byte lbl_805756E4 = .sbss:0x805756E4; // type:object size:0x4 data:4byte lbl_805756E8 = .sbss:0x805756E8; // type:object size:0x1 data:byte lbl_805756E9 = .sbss:0x805756E9; // type:object size:0x1 data:byte -lbl_805756EC = .sbss:0x805756EC; // type:object size:0x4 data:4byte +sInstance__10dTgSndMg_c = .sbss:0x805756EC; // type:object size:0x4 data:4byte lbl_805756F0 = .sbss:0x805756F0; // type:object size:0x8 data:4byte lbl_805756F8 = .sbss:0x805756F8; // type:object size:0x4 data:4byte lbl_805756FC = .sbss:0x805756FC; // type:object size:0x1 data:byte diff --git a/configure.py b/configure.py index 64820df5..e963e0fa 100644 --- a/configure.py +++ b/configure.py @@ -1096,7 +1096,7 @@ config.libs = [ Rel(NonMatching, "d_t_skyEnemy", "REL/d/t/d_t_skyEnemy.cpp"), Rel(NonMatching, "d_t_sound", "REL/d/t/d_t_sound.cpp"), Rel(Matching, "d_t_sound_area", "REL/d/t/d_t_sound_area.cpp"), - Rel(NonMatching, "d_t_sound_area_mgr", "REL/d/t/d_t_sound_area_mgr.cpp"), + Rel(Matching, "d_t_sound_area_mgr", "REL/d/t/d_t_sound_area_mgr.cpp"), Rel(NonMatching, "d_t_sparks2", "REL/d/t/d_t_sparks2.cpp"), Rel(NonMatching, "d_t_sparks", "REL/d/t/d_t_sparks.cpp"), Rel(NonMatching, "d_t_spore", "REL/d/t/d_t_spore.cpp"), diff --git a/include/d/tg/d_t_sound_area_mgr.h b/include/d/tg/d_t_sound_area_mgr.h new file mode 100644 index 00000000..a6047864 --- /dev/null +++ b/include/d/tg/d_t_sound_area_mgr.h @@ -0,0 +1,30 @@ +#ifndef D_T_SOUND_AREA_MGR_H +#define D_T_SOUND_AREA_MGR_H + +#include + +class dTgSndMg_c : public dTg_c { +public: + dTgSndMg_c() { + sInstance = this; + } + virtual ~dTgSndMg_c() { + sInstance = nullptr; + } + virtual int draw() override; + virtual int actorExecute() override; + virtual int doDelete() override; + virtual int create() override; + + + static dTgSndMg_c *sInstance; + + void setBgmFlag(int flag) { + mBgmFlags |= 1 << flag; + } + +private: + u32 mBgmFlags; +}; + +#endif diff --git a/src/REL/d/t/d_t_sound_area.cpp b/src/REL/d/t/d_t_sound_area.cpp index a4165a6c..83aa1907 100644 --- a/src/REL/d/t/d_t_sound_area.cpp +++ b/src/REL/d/t/d_t_sound_area.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include SPECIAL_ACTOR_PROFILE(TAG_SOUND_AREA, dTgSndAr_c, fProfile::TAG_SOUND_AREA, 0x0146, 0, 0); @@ -10,16 +11,10 @@ void float_ordering() { 0.01f; } -struct SoundAreaManager { - u8 unk[0xFC]; - u32 bgmFlags; -}; - -extern SoundAreaManager *lbl_805756EC; int dTgSndAr_c::create() { scale *= 0.01f; - if (lbl_805756EC == nullptr) { + if (dTgSndMg_c::sInstance == nullptr) { dAcObjBase_c::createActorUnkGroup3(fProfile::SOUND_AREA_MGR, roomid, 0, nullptr, nullptr, nullptr, -1); } @@ -66,8 +61,8 @@ int dTgSndAr_c::actorExecute() { } if (lbl_80575D58 != nullptr) { mVec3_c pos = lbl_80575D58->v; - if (checkPosInArea(pos) && lbl_805756EC != nullptr) { - lbl_805756EC->bgmFlags |= 1 << (params & 0xFF); + if (checkPosInArea(pos) && dTgSndMg_c::sInstance != nullptr) { + dTgSndMg_c::sInstance->setBgmFlag(params & 0xFF); } } return 1; diff --git a/src/REL/d/t/d_t_sound_area_mgr.cpp b/src/REL/d/t/d_t_sound_area_mgr.cpp index e69de29b..26da7f90 100644 --- a/src/REL/d/t/d_t_sound_area_mgr.cpp +++ b/src/REL/d/t/d_t_sound_area_mgr.cpp @@ -0,0 +1,27 @@ +#include +#include + +SPECIAL_ACTOR_PROFILE(SOUND_AREA_MGR, dTgSndMg_c, fProfile::SOUND_AREA_MGR, 0x0145, 0, 0); + +int dTgSndMg_c::create() { + s8 tmpRoomId = roomid; + addActorToRoom(-1); + roomid = tmpRoomId; + return 1; +} + +int dTgSndMg_c::doDelete() { + return 1; +} + +int dTgSndMg_c::actorExecute() { + if (dPlayer::LINK != nullptr) { + dPlayer::LINK->field_0xe8 = 0; + } + mBgmFlags = 0; + return 1; +} + +int dTgSndMg_c::draw() { + return 1; +}