From 40e01ec9ed9a839f182c02d8144bb12ea268ec15 Mon Sep 17 00:00:00 2001 From: robojumper Date: Fri, 27 Sep 2024 23:59:40 +0200 Subject: [PATCH 1/2] d_t_fairytag OK --- config/SOUE01/rels/d_t_fairytagNP/splits.txt | 2 + config/SOUE01/rels/d_t_fairytagNP/symbols.txt | 44 +++++------ config/SOUE01/symbols.txt | 4 +- configure.py | 2 +- include/d/a/d_a_base.h | 2 +- include/d/a/obj/d_a_obj_base.h | 2 +- include/d/tg/d_t_fairytag.h | 27 +++++++ src/REL/d/t/d_t_fairytag.cpp | 77 +++++++++++++++++++ 8 files changed, 133 insertions(+), 27 deletions(-) create mode 100644 include/d/tg/d_t_fairytag.h diff --git a/config/SOUE01/rels/d_t_fairytagNP/splits.txt b/config/SOUE01/rels/d_t_fairytagNP/splits.txt index 967cdad1..11d16f7c 100644 --- a/config/SOUE01/rels/d_t_fairytagNP/splits.txt +++ b/config/SOUE01/rels/d_t_fairytagNP/splits.txt @@ -11,3 +11,5 @@ REL/executor.c: REL/d/t/d_t_fairytag.cpp: .text start:0x00000070 end:0x0000056C + .rodata start:0x00000000 end:0x00000018 + .data start:0x00000000 end:0x000000AC diff --git a/config/SOUE01/rels/d_t_fairytagNP/symbols.txt b/config/SOUE01/rels/d_t_fairytagNP/symbols.txt index e6cbb0f7..d8dbdc49 100644 --- a/config/SOUE01/rels/d_t_fairytagNP/symbols.txt +++ b/config/SOUE01/rels/d_t_fairytagNP/symbols.txt @@ -1,27 +1,27 @@ _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_301_70 = .text:0x00000070; // type:function size:0x4C -fn_301_C0 = .text:0x000000C0; // type:function size:0x6C -fn_301_130 = .text:0x00000130; // type:function size:0x14 -fn_301_150 = .text:0x00000150; // type:function size:0x58 -fn_301_1B0 = .text:0x000001B0; // type:function size:0x7C -fn_301_230 = .text:0x00000230; // type:function size:0x50 -fn_301_280 = .text:0x00000280; // type:function size:0x8 -fn_301_290 = .text:0x00000290; // type:function size:0x8 -fn_301_2A0 = .text:0x000002A0; // type:function size:0x128 -fn_301_3D0 = .text:0x000003D0; // type:function size:0xCC -fn_301_4A0 = .text:0x000004A0; // type:function size:0x6C -fn_301_510 = .text:0x00000510; // type:function size:0x5C +dTgFairy_c_classInit__Fv = .text:0x00000070; // type:function size:0x4C +createHeap__10dTgFairy_cFv = .text:0x000000C0; // type:function size:0x6C +__ct__25dAcRef_c<13dAcObjFairy_c>Fv = .text:0x00000130; // type:function size:0x14 +__dt__25dAcRef_c<13dAcObjFairy_c>Fv = .text:0x00000150; // type:function size:0x58 +create__10dTgFairy_cFv = .text:0x000001B0; // type:function size:0x7C +doDelete__10dTgFairy_cFv = .text:0x00000230; // type:function size:0x50 +actorExecute__10dTgFairy_cFv = .text:0x00000280; // type:function size:0x8 +draw__10dTgFairy_cFv = .text:0x00000290; // type:function size:0x8 +createFairies__10dTgFairy_cFv = .text:0x000002A0; // type:function size:0x128 +calcLocation__10dTgFairy_cFRCf = .text:0x000003D0; // type:function size:0xCC +calcRnd__10dTgFairy_cFRCfRCf = .text:0x000004A0; // type:function size:0x6C +__dt__10dTgFairy_cFv = .text:0x00000510; // type:function size:0x5C _ctors = .ctors:0x00000000; // type:label scope:global _dtors = .dtors:0x00000000; // type:label scope:global -lbl_301_rodata_0 = .rodata:0x00000000; // type:object size:0x4 data:float -lbl_301_rodata_8 = .rodata:0x00000008; // type:object size:0x8 data:double -lbl_301_rodata_10 = .rodata:0x00000010; // type:object size:0x4 data:float -lbl_301_rodata_14 = .rodata:0x00000014; // type:object size:0x4 data:float -lbl_301_data_0 = .data:0x00000000; // type:object size:0x10 -lbl_301_data_10 = .data:0x00000010; // type:object size:0x18 data:string -lbl_301_data_28 = .data:0x00000028; // type:object size:0x8 -lbl_301_data_30 = .data:0x00000030; // type:object size:0x4 -lbl_301_data_34 = .data:0x00000034; // type:object size:0x4 -lbl_301_data_38 = .data:0x00000038; // type:object size:0x74 +lbl_301_rodata_0 = .rodata:0x00000000; // type:object size:0x4 scope:local data:float +lbl_301_rodata_8 = .rodata:0x00000008; // type:object size:0x8 scope:local data:double +lbl_301_rodata_10 = .rodata:0x00000010; // type:object size:0x4 scope:local data:float +lbl_301_rodata_14 = .rodata:0x00000014; // type:object size:0x4 scope:local data:float +g_profile_T_FAIRY = .data:0x00000000; // type:object size:0x10 +lbl_301_data_10 = .data:0x00000010; // type:object size:0x18 scope:local data:string +lbl_301_data_28 = .data:0x00000028; // type:object size:0x8 scope:local +lbl_301_data_30 = .data:0x00000030; // type:object size:0x4 scope:local +lbl_301_data_34 = .data:0x00000034; // type:object size:0x4 scope:local +__vt__10dTgFairy_c = .data:0x00000038; // type:object size:0x74 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index d04c946a..94df09cb 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -1119,7 +1119,7 @@ preDraw__12dAcObjBase_cFv = .text:0x8002E330; // type:function size:0x27C getObjectListEntry__12dAcObjBase_cFv = .text:0x8002E5B0; // type:function size:0x8 restorePosRotFromCopy__12dAcObjBase_cFv = .text:0x8002E5C0; // type:function size:0x70 create__12dAcObjBase_cFQ28fProfile14PROFILE_NAME_eScUlP7mVec3_cP7mAng3_cP7mVec3_cUl = .text:0x8002E630; // type:function size:0x98 -fn_8002E6D0 = .text:0x8002E6D0; // type:function size:0xA0 +create__12dAcObjBase_cFPcUlUlP7mVec3_cP7mAng3_cP7mVec3_cUlUsSc = .text:0x8002E6D0; // type:function size:0xA0 fn_8002E770 = .text:0x8002E770; // type:function size:0x7C fn_8002E7F0 = .text:0x8002E7F0; // type:function size:0x58 fn_8002E850 = .text:0x8002E850; // type:function size:0x14 @@ -17292,7 +17292,7 @@ fn_802E0D00 = .text:0x802E0D00; // type:function size:0x8 rnd__2cMFv = .text:0x802E0D10; // type:function size:0x8 fn_802E0D20 = .text:0x802E0D20; // type:function size:0x58 rndF__2cMFf = .text:0x802E0D80; // type:function size:0x38 -fn_802E0DC0 = .text:0x802E0DC0; // type:function size:0x48 +rndFX__2cMFf = .text:0x802E0DC0; // type:function size:0x48 fn_802E0E10 = .text:0x802E0E10; // type:function size:0xC fn_802E0E20 = .text:0x802E0E20; // type:function size:0x44 __ct__9cTreeNd_cFv = .text:0x802E0E70; // type:function size:0x30 diff --git a/configure.py b/configure.py index 1b98f6cc..757c6bfe 100644 --- a/configure.py +++ b/configure.py @@ -1303,7 +1303,7 @@ def nw4rLib(lib_name, objects, extra_cflags=[]): Rel(NonMatching, "d_t_drum", "REL/d/t/d_t_drum.cpp"), Rel(NonMatching, "d_t_dungeon_start", "REL/d/t/d_t_dungeon_start.cpp"), Rel(NonMatching, "d_t_effect_gen", "REL/d/t/d_t_effect_gen.cpp"), - Rel(NonMatching, "d_t_fairytag", "REL/d/t/d_t_fairytag.cpp"), + Rel(Matching, "d_t_fairytag", "REL/d/t/d_t_fairytag.cpp"), Rel(NonMatching, "d_t_fence_synchronizer", "REL/d/t/d_t_fence_synchronizer.cpp"), Rel(NonMatching, "d_t_gate_to_ground", "REL/d/t/d_t_gate_to_ground.cpp"), Rel(NonMatching, "d_t_gekotag", "REL/d/t/d_t_gekotag.cpp"), diff --git a/include/d/a/d_a_base.h b/include/d/a/d_a_base.h index 10ba7e2d..3ba983e5 100644 --- a/include/d/a/d_a_base.h +++ b/include/d/a/d_a_base.h @@ -76,7 +76,7 @@ class dAcBase_c : public dBase_c { /* 0xAC */ mAng3_c rot_copy; /* 0xB2 */ u16 obj_id; // enemydefeat flag / id on obj-map /* 0xB4 */ s8 room_id_copy; - /* 0xB5 */ u8 viewclip_index; + /* 0xB5 */ s8 viewclip_index; /* 0xB6 */ u8 subtype; /* 0xB8 */ mAng3_c rotation; /* 0xC0 */ mVec3_c position; diff --git a/include/d/a/obj/d_a_obj_base.h b/include/d/a/obj/d_a_obj_base.h index a5a8666c..e22f5683 100644 --- a/include/d/a/obj/d_a_obj_base.h +++ b/include/d/a/obj/d_a_obj_base.h @@ -93,7 +93,7 @@ class dAcObjBase_c : public dAcBase_c { /* 8002e630 */ static dAcObjBase_c *create(fProfile::PROFILE_NAME_e actorId, s8 roomId, u32 params1, mVec3_c *pos, mAng3_c *rot, mVec3_c *scale, u32 params2); /* 8002e6d0 */ static dAcObjBase_c *create(char *name, u32 roomId, u32 params1, mVec3_c *pos, mAng3_c *rot, - mVec3_c *scale, u32 params2, u16 id, u8 viewclipId); + mVec3_c *scale, u32 params2, u16 id, s8 viewclipId); /* 8002e770 */ static dAcObjBase_c *findObject(fProfile::PROFILE_NAME_e actorId, fLiNdBa_c *refList, dAcObjBase_c *parent); /* 8002e7f0 */ static dAcObjBase_c *getNextObject(fLiNdBa_c *ref, dAcObjBase_c *parent); diff --git a/include/d/tg/d_t_fairytag.h b/include/d/tg/d_t_fairytag.h new file mode 100644 index 00000000..7a91b16b --- /dev/null +++ b/include/d/tg/d_t_fairytag.h @@ -0,0 +1,27 @@ +#ifndef D_T_GENKI_DWS_TGT_H +#define D_T_GENKI_DWS_TGT_H + +#include +#include + +class dTgFairy_c : public dTg_c { +public: + dTgFairy_c() {} + virtual ~dTgFairy_c() {} + + virtual bool createHeap() override; + virtual int create() override; + virtual int doDelete() override; + virtual int actorExecute() override; + virtual int draw() override; + +private: + void createFairies(); + mVec3_c calcLocation(const f32 &); + f32 calcRnd(const f32 &, const f32 &); + + dAcRef_c *mpFairyRefs; + s32 mCount; +}; + +#endif diff --git a/src/REL/d/t/d_t_fairytag.cpp b/src/REL/d/t/d_t_fairytag.cpp index e69de29b..b95105ee 100644 --- a/src/REL/d/t/d_t_fairytag.cpp +++ b/src/REL/d/t/d_t_fairytag.cpp @@ -0,0 +1,77 @@ +#include +#include + +SPECIAL_ACTOR_PROFILE(T_FAIRY, dTgFairy_c, fProfile::T_FAIRY, 0x0296, 0, 0); + +bool dTgFairy_c::createHeap() { + mpFairyRefs = new dAcRef_c[mCount](); + return static_cast(mpFairyRefs); +} + +int dTgFairy_c::create() { + mCount = params & 0x3F; + if (mCount == 0 || mCount == 7) { + mCount = 1; + } + + CREATE_ALLOCATOR(dTgFairy_c); + createFairies(); + return SUCCEEDED; +} + +int dTgFairy_c::doDelete() { + if (mpFairyRefs != nullptr) { + delete[] mpFairyRefs; + mpFairyRefs = nullptr; + } + return SUCCEEDED; +} + +int dTgFairy_c::actorExecute() { + return SUCCEEDED; +} + +int dTgFairy_c::draw() { + return SUCCEEDED; +} + +void dTgFairy_c::createFairies() { + u32 parms = params; + u32 someNum = (parms >> 6) & 0xFF; + u32 fairyParams1 = (parms >> 14) & 0x3F; + if (someNum > 100) { + someNum = 100; + } + + f32 f = 0.01f * someNum; + + for (int i = 0; i < mCount; i++) { + if (mpFairyRefs[i].get() == nullptr) { + // ? + mVec3_c v2; + mVec3_c v = calcLocation(f); + v2 = v; + dAcObjFairy_c *ac = static_cast( + dAcObjBase_c::create("Fairy", roomid, fairyParams1, &v2, nullptr, nullptr, -1, -1, viewclip_index)); + if (ac != nullptr) { + mpFairyRefs[i].link(ac); + } + } + } +} + +mVec3_c dTgFairy_c::calcLocation(const f32 &offset) { + mVec3_c v; + v.y = scale.y * 0.5f; + v.x = scale.x * calcRnd(0.5f, offset); + v.z = scale.z * calcRnd(0.5f, offset); + v.rotY(rotation.y); + return position + v; +} + +float dTgFairy_c::calcRnd(const f32 &a, const f32 &b) { + f32 f1 = 1.0f - (1.0f - b) * cM::rnd(); + f32 f2 = cM::rndFX(a); + f2 *= f1; + return f2; +} From 2c73ed7530fdb191a34a199c6e3aa71fd6045749 Mon Sep 17 00:00:00 2001 From: elijah-thomas774 Date: Fri, 27 Sep 2024 20:13:31 -0400 Subject: [PATCH 2/2] fixup header guard --- include/d/tg/d_t_fairytag.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/d/tg/d_t_fairytag.h b/include/d/tg/d_t_fairytag.h index 7a91b16b..60891e11 100644 --- a/include/d/tg/d_t_fairytag.h +++ b/include/d/tg/d_t_fairytag.h @@ -1,5 +1,5 @@ -#ifndef D_T_GENKI_DWS_TGT_H -#define D_T_GENKI_DWS_TGT_H +#ifndef D_T_OBJ_FAIRY_H +#define D_T_OBJ_FAIRY_H #include #include