From 4e77023d7bba2fb0a1eebd7d5131c89800f0ccee Mon Sep 17 00:00:00 2001 From: robojumper Date: Sun, 9 Jun 2024 00:07:28 +0200 Subject: [PATCH 1/6] 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) {} From e7a7f794d44a6533afcacc95ff99783691419964 Mon Sep 17 00:00:00 2001 From: elijah-thomas774 Date: Sun, 9 Jun 2024 23:46:43 -0400 Subject: [PATCH 2/6] Progress --- .../SOUE01/rels/d_t_sound_areaNP/symbols.txt | 8 ++-- include/d/tg/d_t_sound_area.h | 11 +++-- include/egg/math/eggVector.h | 2 +- include/m/m_vec.h | 9 +--- src/REL/d/t/d_t_sound_area.cpp | 46 +++++++++++-------- 5 files changed, 40 insertions(+), 36 deletions(-) diff --git a/config/SOUE01/rels/d_t_sound_areaNP/symbols.txt b/config/SOUE01/rels/d_t_sound_areaNP/symbols.txt index 78bf8f1e..cdc4ffe7 100644 --- a/config/SOUE01/rels/d_t_sound_areaNP/symbols.txt +++ b/config/SOUE01/rels/d_t_sound_areaNP/symbols.txt @@ -7,10 +7,10 @@ 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 +checkAlg0__10dTgSndAr_cFRC7mVec3_c = .text:0x00000350; // type:function size:0xF0 +checkAlg1__10dTgSndAr_cFRC7mVec3_c = .text:0x00000440; // type:function size:0x54 +checkAlg2__10dTgSndAr_cFRC7mVec3_c = .text:0x000004A0; // type:function size:0x98 +checkAlg3__10dTgSndAr_cFRC7mVec3_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 diff --git a/include/d/tg/d_t_sound_area.h b/include/d/tg/d_t_sound_area.h index 949249c7..67c6fbfd 100644 --- a/include/d/tg/d_t_sound_area.h +++ b/include/d/tg/d_t_sound_area.h @@ -2,10 +2,11 @@ #define D_T_SOUND_AREA_H #include -#include #include +#include #include + class dTgSndAr_c : public dTg_c { public: dTgSndAr_c() {} @@ -21,10 +22,10 @@ private: } 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); + bool checkAlg0(const mVec3_c &pos); + bool checkAlg1(const mVec3_c &pos); + bool checkAlg2(const mVec3_c &pos); + bool checkAlg3(const mVec3_c &pos); mMtx_c mtx; ActorOnRail mRail; diff --git a/include/egg/math/eggVector.h b/include/egg/math/eggVector.h index 2090b5b7..9aa50ae8 100644 --- a/include/egg/math/eggVector.h +++ b/include/egg/math/eggVector.h @@ -111,7 +111,7 @@ struct Vector3f : public nw4r::math::VEC3 { struct Vector2f : nw4r::math::VEC2 { inline Vector2f() {} Vector2f(f32 fx, f32 fy) : VEC2(fx, fy) {} - inline ~Vector2f() {} + inline ~Vector2f() {} public: /* 805767c0 */ static const Vector2f zero; diff --git a/include/m/m_vec.h b/include/m/m_vec.h index 2f0e6c78..d58a0ab8 100644 --- a/include/m/m_vec.h +++ b/include/m/m_vec.h @@ -19,16 +19,11 @@ public: } mVec3_c(const mVec3_c &other) { - x = other.x; - y = other.y; - z = other.z; + set(other.x, other.y, other.z); } - /// @brief Constructs a vector from three floating point values. mVec3_c(f32 fx, f32 fy, f32 fz) { - x = fx; - y = fy; - z = fz; + set(fx, fy, fz); } mVec3_c &operator=(const mVec3_c &r) { diff --git a/src/REL/d/t/d_t_sound_area.cpp b/src/REL/d/t/d_t_sound_area.cpp index fd625825..1f1f9cd6 100644 --- a/src/REL/d/t/d_t_sound_area.cpp +++ b/src/REL/d/t/d_t_sound_area.cpp @@ -5,6 +5,11 @@ SPECIAL_ACTOR_PROFILE(TAG_SOUND_AREA, dTgSndAr_c, fProfile::TAG_SOUND_AREA, 0x0146, 0, 0); +void float_ordering() { + f32 arr[6] = {0, 100, 100, 100, 100, 100}; + 0.01f; +} + struct SoundAreaManager { u8 unk[0xFC]; u32 bgmFlags; @@ -49,9 +54,7 @@ int dTgSndAr_c::doDelete() { struct Unk { u8 unk[0x144]; - f32 x; - f32 y; - f32 z; + mVec3_c v; }; extern Unk *lbl_80575D58; @@ -63,7 +66,7 @@ int dTgSndAr_c::actorExecute() { } if (lbl_80575D58 != nullptr) { // Halp - mVec3_c pos(lbl_80575D58->x, lbl_80575D58->y, lbl_80575D58->z); + mVec3_c pos = lbl_80575D58->v; if (checkPosInArea(pos) && lbl_805756EC != nullptr) { lbl_805756EC->bgmFlags |= 1 << (params & 0xFF); } @@ -90,39 +93,44 @@ bool dTgSndAr_c::checkPosInArea(mVec3_c &pos) { return false; } +inline bool inRange(f32 val, f32 tolerance) { + return (-tolerance <= val && val <= tolerance); +} // Box -bool dTgSndAr_c::checkAlg0(mVec3_c &pos) { +bool dTgSndAr_c::checkAlg0(const 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) { + f32 sxLower = -50.0f * scale.x; + f32 sxUpper = 50.0f * scale.x; + f32 syLower = 0.0f; + f32 syUpper = 100.0f * scale.y; + f32 szLower = -50.0f * scale.z; + f32 szUpper = 50.0f * scale.z; + + if (sxLower <= c2.x && c2.x <= sxUpper && syLower <= c2.y && c2.y <= syUpper && szLower <= c2.z && + c2.z <= szUpper) { return true; } - return false; } // Sphere -bool dTgSndAr_c::checkAlg1(mVec3_c &pos) { +bool dTgSndAr_c::checkAlg1(const 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)) { +bool dTgSndAr_c::checkAlg2(const mVec3_c &pos) { + if (pos.y < position.y || pos.y > (position.y + 100.0f * scale.y)) { return false; } - f32 f1 = position.z; - f32 f2 = position.x; - f3 = scale.x * 100.0f; - return f2 * f2 + f1 * f1 <= f3 * f3; + mVec3_c diff(pos.x - position.x, pos.z - position.z, scale.x * 100.0f); + + return diff.x * diff.x + diff.y * diff.y <= diff.x * diff.z; } // ??? -bool dTgSndAr_c::checkAlg3(mVec3_c &pos) {} +bool dTgSndAr_c::checkAlg3(const mVec3_c &pos) {} From f80927177a5a32b12ae5aed021f6d3bd86d8af36 Mon Sep 17 00:00:00 2001 From: robojumper Date: Thu, 13 Jun 2024 18:18:40 +0200 Subject: [PATCH 3/6] Maybe --- config/SOUE01/symbols.txt | 2 +- include/m/m_mtx.h | 2 +- include/toBeSorted/actor_on_rail.h | 2 ++ src/REL/d/t/d_t_sound_area.cpp | 44 ++++++++++++++++++++++++++++-- 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 75db02dc..7d2fa499 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -3677,7 +3677,7 @@ __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 -fn_800A68B0 = .text:0x800A68B0; // type:function size:0x58 +getPntPosForIndex__11ActorOnRailFi = .text:0x800A68B0; // type:function size:0x58 fn_800A6910 = .text:0x800A6910; // type:function size:0x2B4 fn_800A6BD0 = .text:0x800A6BD0; // type:function size:0x74 fn_800A6C50 = .text:0x800A6C50; // type:function size:0x110 diff --git a/include/m/m_mtx.h b/include/m/m_mtx.h index f7095930..f68c58ab 100644 --- a/include/m/m_mtx.h +++ b/include/m/m_mtx.h @@ -17,7 +17,7 @@ public: /* 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. + /* 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. diff --git a/include/toBeSorted/actor_on_rail.h b/include/toBeSorted/actor_on_rail.h index 47f8460d..a57d2753 100644 --- a/include/toBeSorted/actor_on_rail.h +++ b/include/toBeSorted/actor_on_rail.h @@ -17,6 +17,8 @@ public: /* 800A6D90 */ bool init(int pathIndex, int roomId, int pathSubtype); + /* 800A68B0 */ + mVec3_c *getPntPosForIndex(int index); }; #endif diff --git a/src/REL/d/t/d_t_sound_area.cpp b/src/REL/d/t/d_t_sound_area.cpp index 1f1f9cd6..63611a2f 100644 --- a/src/REL/d/t/d_t_sound_area.cpp +++ b/src/REL/d/t/d_t_sound_area.cpp @@ -65,7 +65,6 @@ int dTgSndAr_c::actorExecute() { link->setBit_field_0xE8(params & 0xFF); } if (lbl_80575D58 != nullptr) { - // Halp mVec3_c pos = lbl_80575D58->v; if (checkPosInArea(pos) && lbl_805756EC != nullptr) { lbl_805756EC->bgmFlags |= 1 << (params & 0xFF); @@ -96,6 +95,7 @@ bool dTgSndAr_c::checkPosInArea(mVec3_c &pos) { inline bool inRange(f32 val, f32 tolerance) { return (-tolerance <= val && val <= tolerance); } + // Box bool dTgSndAr_c::checkAlg0(const mVec3_c &pos) { mVec3_c c2 = pos; @@ -129,8 +129,46 @@ bool dTgSndAr_c::checkAlg2(const mVec3_c &pos) { mVec3_c diff(pos.x - position.x, pos.z - position.z, scale.x * 100.0f); - return diff.x * diff.x + diff.y * diff.y <= diff.x * diff.z; + return diff.x * diff.x + diff.y * diff.y <= diff.z * diff.z; } +struct UnkStruct { + /* 0x00 */ mVec3_c vec; + /* 0x0C */ mVec3_c vec2; + /* 0x18 */ u32 unk; + /* 0x1C */ f32 field_0x1C; + /* 0x20 */ u8 field_0x20; + /* 0x24 */ u32 field_0x24; +}; + +extern "C" void fn_80337EA0(UnkStruct *); +extern "C" void fn_80337EF0(UnkStruct *, mVec3_c&, mVec3_c&, f32); +extern "C" int fn_8032BFB0(UnkStruct *, mVec3_c&, f32*, f32&, int); + // ??? -bool dTgSndAr_c::checkAlg3(const mVec3_c &pos) {} +bool dTgSndAr_c::checkAlg3(const mVec3_c &pos) { + f32 q[4]; + UnkStruct unk; + + f32 radius = scale.x * 100.0f; + radius = radius * radius; + mVec3_c a = pos; + fn_80337EA0(&unk); + + mVec3_c b = *mRail.getPntPosForIndex(0); + mVec3_c c = *mRail.getPntPosForIndex(1); + + fn_80337EF0(&unk, b, c, scale.x * 100.0f); + f32 d; + if (fn_8032BFB0(&unk, a, q, d, 0)) { + return d < radius; + } else { + f32 distSq = PSVECSquareDistance(unk.vec, pos); + if (distSq < radius) { + return true; + } else { + distSq = PSVECSquareDistance(unk.vec2, pos); + return distSq < radius; + } + } +} From 061181b32cf62f7f99962617fc0871d131a687b4 Mon Sep 17 00:00:00 2001 From: robojumper Date: Thu, 13 Jun 2024 18:36:56 +0200 Subject: [PATCH 4/6] Awkward --- include/m/m_vec.h | 4 ++++ src/REL/d/t/d_t_sound_area.cpp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/m/m_vec.h b/include/m/m_vec.h index d58a0ab8..f7ba025d 100644 --- a/include/m/m_vec.h +++ b/include/m/m_vec.h @@ -60,6 +60,10 @@ public: return (Vec *)&x; } + operator EGG::Vector3f *() { + return (EGG::Vector3f *)&x; + } + /// @brief Const Vec cast operator. operator const Vec *() const { return (const Vec *)&x; diff --git a/src/REL/d/t/d_t_sound_area.cpp b/src/REL/d/t/d_t_sound_area.cpp index 63611a2f..5a62bad7 100644 --- a/src/REL/d/t/d_t_sound_area.cpp +++ b/src/REL/d/t/d_t_sound_area.cpp @@ -143,7 +143,7 @@ struct UnkStruct { extern "C" void fn_80337EA0(UnkStruct *); extern "C" void fn_80337EF0(UnkStruct *, mVec3_c&, mVec3_c&, f32); -extern "C" int fn_8032BFB0(UnkStruct *, mVec3_c&, f32*, f32&, int); +extern "C" int fn_8032BFB0(UnkStruct *, EGG::Vector3f&, f32*, f32&, int); // ??? bool dTgSndAr_c::checkAlg3(const mVec3_c &pos) { @@ -152,7 +152,7 @@ bool dTgSndAr_c::checkAlg3(const mVec3_c &pos) { f32 radius = scale.x * 100.0f; radius = radius * radius; - mVec3_c a = pos; + EGG::Vector3f a = pos; fn_80337EA0(&unk); mVec3_c b = *mRail.getPntPosForIndex(0); From a35bedafc6004412d1af4c987c9c2dce4ea42d89 Mon Sep 17 00:00:00 2001 From: robojumper Date: Thu, 13 Jun 2024 18:50:18 +0200 Subject: [PATCH 5/6] Closer --- src/REL/d/t/d_t_sound_area.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/REL/d/t/d_t_sound_area.cpp b/src/REL/d/t/d_t_sound_area.cpp index 5a62bad7..6e74d26e 100644 --- a/src/REL/d/t/d_t_sound_area.cpp +++ b/src/REL/d/t/d_t_sound_area.cpp @@ -127,9 +127,10 @@ bool dTgSndAr_c::checkAlg2(const mVec3_c &pos) { return false; } - mVec3_c diff(pos.x - position.x, pos.z - position.z, scale.x * 100.0f); + mVec3_c diff = pos - position; + f32 radius = scale.x * 100.0f; - return diff.x * diff.x + diff.y * diff.y <= diff.z * diff.z; + return diff.x * diff.x + diff.z * diff.z < radius * radius; } struct UnkStruct { From 69a9c3b68ef6700e39bf9f0110db65d5ea270e38 Mon Sep 17 00:00:00 2001 From: elijah-thomas774 Date: Fri, 14 Jun 2024 18:59:06 -0400 Subject: [PATCH 6/6] matched --- configure.py | 2 +- include/m/m_angle.h | 3 ++- include/m/m_mtx.h | 14 +++++++------- src/REL/d/t/d_t_sound_area.cpp | 11 +++++++---- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/configure.py b/configure.py index 7782d9dd..2a889345 100644 --- a/configure.py +++ b/configure.py @@ -1063,7 +1063,7 @@ config.libs = [ Rel(NonMatching, "d_t_siren_time_attack", "REL/d/t/d_t_siren_time_attack.cpp"), 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(NonMatching, "d_t_sound_area", "REL/d/t/d_t_sound_area.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(NonMatching, "d_t_sparks2", "REL/d/t/d_t_sparks2.cpp"), Rel(NonMatching, "d_t_sparks", "REL/d/t/d_t_sparks.cpp"), diff --git a/include/m/m_angle.h b/include/m/m_angle.h index 832800a8..52c2408c 100644 --- a/include/m/m_angle.h +++ b/include/m/m_angle.h @@ -16,7 +16,6 @@ class mAng3_c { public: mAng3_c() {} - s16 x, y, z; mAng3_c(s16 fx, s16 fy, s16 fz) : x(fx), y(fy), z(fz) {} void set(s16 fx, s16 fy, s16 fz) { @@ -25,6 +24,8 @@ public: z = fz; } + mAng x, y, z; + static mAng3_c Zero; }; diff --git a/include/m/m_mtx.h b/include/m/m_mtx.h index f68c58ab..ee60b72d 100644 --- a/include/m/m_mtx.h +++ b/include/m/m_mtx.h @@ -10,16 +10,16 @@ class mMtx_c { public: - mMtx_c() {}; + 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(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. + /* 802f16b0 */ void XrotS(const mAng &angle); ///< Generates a rotation matrix for the X axis with the given angle. + /* 802f1770 */ void XrotM(const mAng &angle); ///< Rotates the matrix on the X axis by the given angle. + /* 802f17c0 */ void YrotS(const mAng &angle); ///< Generates a rotation matrix for the Y axis with the given angle. + /* 802f1880 */ void YrotM(const mAng &angle); ///< Rotates the matrix on the Y axis by the given angle. + /* 802f18d0 */ void ZrotS(const mAng &angle); ///< Generates a rotation matrix for the Z axis with the given angle. + /* 802f1990 */ void ZrotM(const 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/src/REL/d/t/d_t_sound_area.cpp b/src/REL/d/t/d_t_sound_area.cpp index 6e74d26e..a4165a6c 100644 --- a/src/REL/d/t/d_t_sound_area.cpp +++ b/src/REL/d/t/d_t_sound_area.cpp @@ -127,10 +127,13 @@ bool dTgSndAr_c::checkAlg2(const mVec3_c &pos) { return false; } - mVec3_c diff = pos - position; f32 radius = scale.x * 100.0f; + mVec3_c diff = pos - position; - return diff.x * diff.x + diff.z * diff.z < radius * radius; + f32 dist = diff.x * diff.x + diff.z * diff.z; + f32 r2 = radius * radius; + + return !(dist > r2); } struct UnkStruct { @@ -143,8 +146,8 @@ struct UnkStruct { }; extern "C" void fn_80337EA0(UnkStruct *); -extern "C" void fn_80337EF0(UnkStruct *, mVec3_c&, mVec3_c&, f32); -extern "C" int fn_8032BFB0(UnkStruct *, EGG::Vector3f&, f32*, f32&, int); +extern "C" void fn_80337EF0(UnkStruct *, mVec3_c &, mVec3_c &, f32); +extern "C" int fn_8032BFB0(UnkStruct *, EGG::Vector3f &, f32 *, f32 &, int); // ??? bool dTgSndAr_c::checkAlg3(const mVec3_c &pos) {