Skip to content

Commit

Permalink
d_t_fairytag OK (#39)
Browse files Browse the repository at this point in the history
* d_t_fairytag OK

* fixup header guard

---------

Co-authored-by: elijah-thomas774 <[email protected]>
  • Loading branch information
robojumper and elijah-thomas774 authored Sep 28, 2024
1 parent ec8f5be commit 1039b3b
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 27 deletions.
2 changes: 2 additions & 0 deletions config/SOUE01/rels/d_t_fairytagNP/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
44 changes: 22 additions & 22 deletions config/SOUE01/rels/d_t_fairytagNP/symbols.txt
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions config/SOUE01/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -17293,7 +17293,7 @@ fn_802E0D00 = .text:0x802E0D00; // type:function size:0x8
rnd__2cMFv = .text:0x802E0D10; // type:function size:0x8
rndInt__2cMFi = .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
Expand Down
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,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"),
Expand Down
2 changes: 1 addition & 1 deletion include/d/a/d_a_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion include/d/a/obj/d_a_obj_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,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);
Expand Down
27 changes: 27 additions & 0 deletions include/d/tg/d_t_fairytag.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef D_T_OBJ_FAIRY_H
#define D_T_OBJ_FAIRY_H

#include <d/a/obj/d_a_obj_fairy.h>
#include <d/tg/d_tg.h>

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<dAcObjFairy_c> *mpFairyRefs;
s32 mCount;
};

#endif
77 changes: 77 additions & 0 deletions src/REL/d/t/d_t_fairytag.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include <c/c_math.h>
#include <d/tg/d_t_fairytag.h>

SPECIAL_ACTOR_PROFILE(T_FAIRY, dTgFairy_c, fProfile::T_FAIRY, 0x0296, 0, 0);

bool dTgFairy_c::createHeap() {
mpFairyRefs = new dAcRef_c<dAcObjFairy_c>[mCount]();
return static_cast<bool>(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<dAcObjFairy_c *>(
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;
}

0 comments on commit 1039b3b

Please sign in to comment.