From 4e77023d7bba2fb0a1eebd7d5131c89800f0ccee Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 9 Jun 2024 00:07:28 +0200 Subject: [PATCH] Basically give up on d_t_sound_area --- .../SOUE01/rels/d_t_sound_areaNP/splits.txt | 2 + .../SOUE01/rels/d_t_sound_areaNP/symbols.txt | 26 ++-- config/SOUE01/symbols.txt | 12 +- include/d/a/obj/d_a_obj_base.h | 4 +- include/d/tg/d_t_sound_area.h | 33 +++++ include/m/m_mtx.h | 15 +- include/m/m_vec.h | 2 +- include/toBeSorted/actor_on_rail.h | 22 +++ src/REL/d/t/d_t_sound_area.cpp | 128 ++++++++++++++++++ 9 files changed, 215 insertions(+), 29 deletions(-) create mode 100644 include/d/tg/d_t_sound_area.h create mode 100644 include/toBeSorted/actor_on_rail.h diff --git a/config/SOUE01/rels/d_t_sound_areaNP/splits.txt b/config/SOUE01/rels/d_t_sound_areaNP/splits.txt index 7acbb71c..5204477d 100644 --- a/config/SOUE01/rels/d_t_sound_areaNP/splits.txt +++ b/config/SOUE01/rels/d_t_sound_areaNP/splits.txt @@ -11,3 +11,5 @@ REL/executor.c: REL/d/t/d_t_sound_area.cpp: .text start:0x00000070 end:0x00000700 + .rodata start:0x00000000 end:0x0000002C + .data start:0x00000000 end:0x00000084 diff --git a/config/SOUE01/rels/d_t_sound_areaNP/symbols.txt b/config/SOUE01/rels/d_t_sound_areaNP/symbols.txt index d5bd8fe6..78bf8f1e 100644 --- a/config/SOUE01/rels/d_t_sound_areaNP/symbols.txt +++ b/config/SOUE01/rels/d_t_sound_areaNP/symbols.txt @@ -1,21 +1,21 @@ _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_497_70 = .text:0x00000070; // type:function size:0x54 -fn_497_D0 = .text:0x000000D0; // type:function size:0x144 -fn_497_220 = .text:0x00000220; // type:function size:0x8 -fn_497_230 = .text:0x00000230; // type:function size:0xCC -fn_497_300 = .text:0x00000300; // type:function size:0x8 -fn_497_310 = .text:0x00000310; // type:function size:0x40 -fn_497_350 = .text:0x00000350; // type:function size:0xF0 -fn_497_440 = .text:0x00000440; // type:function size:0x54 -fn_497_4A0 = .text:0x000004A0; // type:function size:0x98 -fn_497_540 = .text:0x00000540; // type:function size:0x14C -fn_497_690 = .text:0x00000690; // type:function size:0x70 +dTgSndAr_c_classInit__Fv = .text:0x00000070; // type:function size:0x54 +create__10dTgSndAr_cFv = .text:0x000000D0; // type:function size:0x144 +doDelete__10dTgSndAr_cFv = .text:0x00000220; // type:function size:0x8 +actorExecute__10dTgSndAr_cFv = .text:0x00000230; // type:function size:0xCC +draw__10dTgSndAr_cFv = .text:0x00000300; // type:function size:0x8 +checkPosInArea__10dTgSndAr_cFR7mVec3_c = .text:0x00000310; // type:function size:0x40 +checkAlg0__10dTgSndAr_cFR7mVec3_c = .text:0x00000350; // type:function size:0xF0 +checkAlg1__10dTgSndAr_cFR7mVec3_c = .text:0x00000440; // type:function size:0x54 +checkAlg2__10dTgSndAr_cFR7mVec3_c = .text:0x000004A0; // type:function size:0x98 +checkAlg3__10dTgSndAr_cFR7mVec3_c = .text:0x00000540; // type:function size:0x14C +__dt__10dTgSndAr_cFv = .text:0x00000690; // type:function size:0x70 _ctors = .ctors:0x00000000; // type:label scope:global _dtors = .dtors:0x00000000; // type:label scope:global lbl_497_rodata_0 = .rodata:0x00000000; // type:object size:0x18 data:float lbl_497_rodata_18 = .rodata:0x00000018; // type:object size:0x10 data:float lbl_497_rodata_28 = .rodata:0x00000028; // type:object size:0x4 data:float -lbl_497_data_0 = .data:0x00000000; // type:object size:0x10 -lbl_497_data_10 = .data:0x00000010; // type:object size:0x74 +g_profile_TAG_SOUND_AREA = .data:0x00000000; // type:object size:0x10 +__vt__10dTgSndAr_c = .data:0x00000010; // type:object size:0x74 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 0570fe6b..75db02dc 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -1143,7 +1143,7 @@ fn_8002EF70 = .text:0x8002EF70; // type:function size:0x28 fn_8002EFA0 = .text:0x8002EFA0; // type:function size:0x50 fn_8002EFF0 = .text:0x8002EFF0; // type:function size:0x194 fn_8002F190 = .text:0x8002F190; // type:function size:0x24 -fn_8002F1C0 = .text:0x8002F1C0; // type:function size:0x98 +createActorUnkGroup3__12dAcObjBase_cFQ28fProfile14PROFILE_NAME_eUlUlP7mVec3_cP7mAng3_cP7mVec3_cUl = .text:0x8002F1C0; // type:function size:0x98 fn_8002F260 = .text:0x8002F260; // type:function size:0xA0 fn_8002F300 = .text:0x8002F300; // type:function size:0x74 fn_8002F380 = .text:0x8002F380; // type:function size:0x74 @@ -3672,8 +3672,8 @@ fn_800A61C0 = .text:0x800A61C0; // type:function size:0x9C fn_800A6260 = .text:0x800A6260; // type:function size:0x9C fn_800A6300 = .text:0x800A6300; // type:function size:0x368 fn_800A6670 = .text:0x800A6670; // type:function size:0x1C -fn_800A6690 = .text:0x800A6690; // type:function size:0x3C -fn_800A66D0 = .text:0x800A66D0; // type:function size:0x40 +__ct__11ActorOnRailFv = .text:0x800A6690; // type:function size:0x3C +__dt__11ActorOnRailFv = .text:0x800A66D0; // type:function size:0x40 fn_800A6710 = .text:0x800A6710; // type:function size:0x18 fn_800A6730 = .text:0x800A6730; // type:function size:0xBC fn_800A67F0 = .text:0x800A67F0; // type:function size:0xBC @@ -3683,7 +3683,7 @@ fn_800A6BD0 = .text:0x800A6BD0; // type:function size:0x74 fn_800A6C50 = .text:0x800A6C50; // type:function size:0x110 fn_800A6D60 = .text:0x800A6D60; // type:function size:0x10 fn_800A6D70 = .text:0x800A6D70; // type:function size:0x18 -fn_800A6D90 = .text:0x800A6D90; // type:function size:0xC4 +init__11ActorOnRailFiii = .text:0x800A6D90; // type:function size:0xC4 fn_800A6E60 = .text:0x800A6E60; // type:function size:0x68 fn_800A6ED0 = .text:0x800A6ED0; // type:function size:0xB4 fn_800A6F90 = .text:0x800A6F90; // type:function size:0x184 @@ -17840,7 +17840,7 @@ fn_802F1660 = .text:0x802F1660; // type:function size:0x44 fn_802F16B0 = .text:0x802F16B0; // type:function size:0xBC fn_802F1770 = .text:0x802F1770; // type:function size:0x4C fn_802F17C0 = .text:0x802F17C0; // type:function size:0xBC -fn_802F1880 = .text:0x802F1880; // type:function size:0x4C +YrotM__6mMtx_cFRC4mAng = .text:0x802F1880; // type:function size:0x4C fn_802F18D0 = .text:0x802F18D0; // type:function size:0xBC fn_802F1990 = .text:0x802F1990; // type:function size:0x4C fn_802F19E0 = .text:0x802F19E0; // type:function size:0x60 @@ -22195,7 +22195,7 @@ fn_803B8460 = .text:0x803B8460; // type:function size:0xB0 fn_803B8510 = .text:0x803B8510; // type:function size:0x12C fn_803B8640 = .text:0x803B8640; // type:function size:0xB0 fn_803B86F0 = .text:0x803B86F0; // type:function size:0x7C -fn_803B8770 = .text:0x803B8770; // type:function size:0x34 +PSMTXTrans = .text:0x803B8770; // type:function size:0x34 fn_803B87B0 = .text:0x803B87B0; // type:function size:0x4C fn_803B8800 = .text:0x803B8800; // type:function size:0x28 fn_803B8830 = .text:0x803B8830; // type:function size:0x58 diff --git a/include/d/a/obj/d_a_obj_base.h b/include/d/a/obj/d_a_obj_base.h index ed6d5abd..1f074499 100644 --- a/include/d/a/obj/d_a_obj_base.h +++ b/include/d/a/obj/d_a_obj_base.h @@ -81,9 +81,9 @@ public: /* 8002f190 */ void createChildAttached2(fProfile::PROFILE_NAME_e actorId, u32 params1, mVec3_c *pos, mAng3_c *rot, mVec3_c *scale, u32 params2, u32 roomId); // These may not belong here - /* 8002f1c0 */ static dAcBase_c createActorUnkGroup3(fProfile::PROFILE_NAME_e actorId, u32 roomId, u32 params1, + /* 8002f1c0 */ static dAcBase_c *createActorUnkGroup3(fProfile::PROFILE_NAME_e actorId, u32 roomId, u32 params1, mVec3_c *pos, mAng3_c *rot, mVec3_c *scale, u32 params2); - /* 8002f260 */ static dAcBase_c createActorUnkGroup3(char *name, u32 roomId, u32 params1, mVec3_c *pos, + /* 8002f260 */ static dAcBase_c *createActorUnkGroup3(char *name, u32 roomId, u32 params1, mVec3_c *pos, mAng3_c *rot, mVec3_c *scale, u32 params2, u16 id, u8 viewclipId); }; diff --git a/include/d/tg/d_t_sound_area.h b/include/d/tg/d_t_sound_area.h new file mode 100644 index 00000000..949249c7 --- /dev/null +++ b/include/d/tg/d_t_sound_area.h @@ -0,0 +1,33 @@ +#ifndef D_T_SOUND_AREA_H +#define D_T_SOUND_AREA_H + +#include +#include +#include +#include + +class dTgSndAr_c : public dTg_c { +public: + dTgSndAr_c() {} + virtual ~dTgSndAr_c() {} + virtual int draw() override; + virtual int actorExecute() override; + virtual int doDelete() override; + virtual int create() override; + +private: + int getTypeFromParams() { + return params >> 0x1C; + } + bool checkPosInArea(mVec3_c &pos); + + bool checkAlg0(mVec3_c &pos); + bool checkAlg1(mVec3_c &pos); + bool checkAlg2(mVec3_c &pos); + bool checkAlg3(mVec3_c &pos); + + mMtx_c mtx; + ActorOnRail mRail; +}; + +#endif diff --git a/include/m/m_mtx.h b/include/m/m_mtx.h index 512ede2d..f7095930 100644 --- a/include/m/m_mtx.h +++ b/include/m/m_mtx.h @@ -9,16 +9,17 @@ #include class mMtx_c { - mMtx_c(){}; +public: + mMtx_c() {}; /* 802f1660 */ mMtx_c(f32 xx, f32 xy, f32 xz, f32 xw, f32 yx, f32 yy, f32 yz, f32 yw, f32 zx, f32 zy, f32 zz, f32 zw); - /* 802f16b0 */ void XrotS(mAng angle); ///< Generates a rotation matrix for the X axis with the given angle. - /* 802f1770 */ void XrotM(mAng angle); ///< Rotates the matrix on the X axis by the given angle. - /* 802f17c0 */ void YrotS(mAng angle); ///< Generates a rotation matrix for the Y axis with the given angle. - /* 802f1880 */ void YrotM(mAng angle); ///< Rotates the matrix on the Y axis by the given angle. - /* 802f18d0 */ void ZrotS(mAng angle); ///< Generates a rotation matrix for the Z axis with the given angle. - /* 802f1990 */ void ZrotM(mAng angle); ///< Rotates the matrix on the Z axis by the given angle. + /* 802f16b0 */ void XrotS(mAng angle); ///< Generates a rotation matrix for the X axis with the given angle. + /* 802f1770 */ void XrotM(mAng angle); ///< Rotates the matrix on the X axis by the given angle. + /* 802f17c0 */ void YrotS(mAng angle); ///< Generates a rotation matrix for the Y axis with the given angle. + /* 802f1880 */ void YrotM(s16 &angle); ///< Rotates the matrix on the Y axis by the given angle. + /* 802f18d0 */ void ZrotS(mAng angle); ///< Generates a rotation matrix for the Z axis with the given angle. + /* 802f1990 */ void ZrotM(mAng angle); ///< Rotates the matrix on the Z axis by the given angle. /* 802f19e0 */ void ZXYrotS(mAng xRot, mAng yRot, mAng zRot); ///< Generates the matrix on the Y, X and Z axes by the given angles. diff --git a/include/m/m_vec.h b/include/m/m_vec.h index 1ea23afb..2f0e6c78 100644 --- a/include/m/m_vec.h +++ b/include/m/m_vec.h @@ -9,7 +9,7 @@ class mVec3_c : public EGG::Vector3f { public: /// @brief Constructs an empty vector. /* 80009ee0 */ mVec3_c() {} - // /* 80007460 */ ~mVec3_c() {} + /* 80007460 */ ~mVec3_c() {} /// @brief Constructs a vector from a float array. mVec3_c(const f32 *p) { diff --git a/include/toBeSorted/actor_on_rail.h b/include/toBeSorted/actor_on_rail.h new file mode 100644 index 00000000..47f8460d --- /dev/null +++ b/include/toBeSorted/actor_on_rail.h @@ -0,0 +1,22 @@ +#ifndef ACTOR_ON_RAIL_H +#define ACTOR_ON_RAIL_H + +#include + +class ActorOnRail { +private: + void *mpPathPtr; + int mRoomIndex; + u8 mPathSubtype; + +public: + /* 800A6690 */ + ActorOnRail(); + /* 800A66D0 */ + virtual ~ActorOnRail(); + + /* 800A6D90 */ + bool init(int pathIndex, int roomId, int pathSubtype); +}; + +#endif diff --git a/src/REL/d/t/d_t_sound_area.cpp b/src/REL/d/t/d_t_sound_area.cpp index e69de29b..fd625825 100644 --- a/src/REL/d/t/d_t_sound_area.cpp +++ b/src/REL/d/t/d_t_sound_area.cpp @@ -0,0 +1,128 @@ +#include +#include +#include +#include + +SPECIAL_ACTOR_PROFILE(TAG_SOUND_AREA, dTgSndAr_c, fProfile::TAG_SOUND_AREA, 0x0146, 0, 0); + +struct SoundAreaManager { + u8 unk[0xFC]; + u32 bgmFlags; +}; + +extern SoundAreaManager *lbl_805756EC; + +int dTgSndAr_c::create() { + scale *= 0.01f; + if (lbl_805756EC == nullptr) { + dAcObjBase_c::createActorUnkGroup3(fProfile::SOUND_AREA_MGR, roomid, 0, nullptr, nullptr, nullptr, -1); + } + + switch (getTypeFromParams()) { + case 0: + PSMTXTrans(mtx.m, position.x, position.y, position.z); + mtx.YrotM(rotation.y); + PSMTXInverse(mtx.m, mtx.m); + break; + case 3: + mRail.init(params >> 8 & 0xFF, roomid, 0); + break; + } + + fBase_c *base = nullptr; + while (true) { + if ((base = fManager_c::searchBaseByGroupType(ACTOR, base)) == nullptr) { + break; + } + // This has got to be just a member function + dAcBase_c *ac = static_cast(base); + if (!dBase_c::isActorPlayer(*ac) && checkPosInArea(ac->position)) { + ac->setBit_field_0xE8(params & 0xFF); + } + } + return 1; +} + +int dTgSndAr_c::doDelete() { + return 1; +} + +struct Unk { + u8 unk[0x144]; + f32 x; + f32 y; + f32 z; +}; + +extern Unk *lbl_80575D58; + +int dTgSndAr_c::actorExecute() { + dAcBase_c *link = dPlayer::LINK; + if (link != nullptr && checkPosInArea(link->position)) { + link->setBit_field_0xE8(params & 0xFF); + } + if (lbl_80575D58 != nullptr) { + // Halp + mVec3_c pos(lbl_80575D58->x, lbl_80575D58->y, lbl_80575D58->z); + if (checkPosInArea(pos) && lbl_805756EC != nullptr) { + lbl_805756EC->bgmFlags |= 1 << (params & 0xFF); + } + } + return 1; +} + +int dTgSndAr_c::draw() { + return 1; +} + +bool dTgSndAr_c::checkPosInArea(mVec3_c &pos) { + switch (getTypeFromParams()) { + case 0: + return checkAlg0(pos); + case 1: + return checkAlg1(pos); + case 2: + return checkAlg2(pos); + case 3: + return checkAlg3(pos); + } + + return false; +} + +// Box +bool dTgSndAr_c::checkAlg0(mVec3_c &pos) { + mVec3_c c2 = pos; + PSMTXMultVec(mtx.m, c2, c2); + f32 scaleX = scale.x; + f32 scaleZ = scale.z; + if (c2.x >= scaleX * -50.0f && c2.x <= scaleX * 50.0f && c2.y >= 0.0f && c2.y <= scale.y * 100.0f && + c2.z >= scaleZ * -50.0f && c2.z <= scaleZ * 50.0f) { + return true; + } + + return false; +} + +// Sphere +bool dTgSndAr_c::checkAlg1(mVec3_c &pos) { + f32 tgtDist = scale.x * 100.0f; + f32 tgtDist2 = tgtDist * tgtDist; + return PSVECSquareDistance(position, pos) < tgtDist2; +} + +// Cylinder +bool dTgSndAr_c::checkAlg2(mVec3_c &pos) { + f32 f3 = position.x; + if (pos.y < f3 || (f3 + scale.y * 100.0f < pos.y)) { + return false; + } + + f32 f1 = position.z; + f32 f2 = position.x; + f3 = scale.x * 100.0f; + return f2 * f2 + f1 * f1 <= f3 * f3; +} + +// ??? +bool dTgSndAr_c::checkAlg3(mVec3_c &pos) {}