Skip to content

Commit

Permalink
d_a_e_hb_leaf OK
Browse files Browse the repository at this point in the history
  • Loading branch information
robojumper committed Jun 28, 2024
1 parent f9fc4f0 commit ef5aaf8
Show file tree
Hide file tree
Showing 10 changed files with 205 additions and 24 deletions.
2 changes: 2 additions & 0 deletions config/SOUE01/rels/d_a_e_hb_leafNP/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ REL/executor.c:

REL/d/a/e/d_a_e_hb_leaf.cpp:
.text start:0x00000070 end:0x000005E4
.rodata start:0x00000000 end:0x00000024
.data start:0x00000000 end:0x000000D0
30 changes: 17 additions & 13 deletions config/SOUE01/rels/d_a_e_hb_leafNP/symbols.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
_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_157_70 = .text:0x00000070; // type:function size:0xD4
fn_157_150 = .text:0x00000150; // type:function size:0xE8
fn_157_240 = .text:0x00000240; // type:function size:0x1A0
fn_157_3E0 = .text:0x000003E0; // type:function size:0x8
fn_157_3F0 = .text:0x000003F0; // type:function size:0xF0
fn_157_4E0 = .text:0x000004E0; // type:function size:0x6C
fn_157_550 = .text:0x00000550; // type:function size:0x14
fn_157_570 = .text:0x00000570; // type:function size:0x74
dAcEhb_leaf_c_classInit__Fv = .text:0x00000070; // type:function size:0xD4
createHeap__13dAcEhb_leaf_cFv = .text:0x00000150; // type:function size:0xE8
create__13dAcEhb_leaf_cFv = .text:0x00000240; // type:function size:0x1A0
doDelete__13dAcEhb_leaf_cFv = .text:0x000003E0; // type:function size:0x8
actorExecute__13dAcEhb_leaf_cFv = .text:0x000003F0; // type:function size:0xF0
draw__13dAcEhb_leaf_cFv = .text:0x000004E0; // type:function size:0x6C
setAnm__13dAcEhb_leaf_cFPCcf = .text:0x00000550; // type:function size:0x14
__dt__13dAcEhb_leaf_cFv = .text:0x00000570; // type:function size:0x74
_ctors = .ctors:0x00000000; // type:label scope:global
_dtors = .dtors:0x00000000; // type:label scope:global
lbl_157_rodata_0 = .rodata:0x00000000; // type:object size:0x20 data:float
lbl_157_rodata_20 = .rodata:0x00000020; // type:object size:0x4 data:float
lbl_157_data_0 = .data:0x00000000; // type:object size:0x34
lbl_157_data_34 = .data:0x00000034; // type:object size:0x1C
lbl_157_data_50 = .data:0x00000050; // type:object size:0x80
unkFloat0__13dAcEhb_leaf_c = .rodata:0x00000000; // type:object size:0x4 data:float
unkFloat1__13dAcEhb_leaf_c = .rodata:0x00000004; // type:object size:0x4 data:float
lbl_157_rodata_20 = .rodata:0x00000020; // type:object size:0x4 scope:local data:float
g_profile_E_HB_LEAF = .data:0x00000000; // type:object size:0x10
lbl_157_data_10 = .data:0x00000010; // type:object size:0x9 scope:local data:string
lbl_157_data_1C = .data:0x0000001C; // type:object size:0x7 scope:local data:string
lbl_157_data_24 = .data:0x00000024; // type:object size:0xE scope:local data:string
lbl_157_data_34 = .data:0x00000034; // type:object size:0x1B scope:local data:string
__vt__13dAcEhb_leaf_c = .data:0x00000050; // type:object size:0x80
4 changes: 2 additions & 2 deletions config/SOUE01/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17290,7 +17290,7 @@ fn_802E0CB0 = .text:0x802E0CB0; // type:function size:0x48
fn_802E0D00 = .text:0x802E0D00; // type:function size:0x8
rnd__2cMFv = .text:0x802E0D10; // type:function size:0x8
fn_802E0D20 = .text:0x802E0D20; // type:function size:0x58
fn_802E0D80 = .text:0x802E0D80; // type:function size:0x38
rndF__2cMFf = .text:0x802E0D80; // type:function size:0x38
fn_802E0DC0 = .text:0x802E0DC0; // type:function size:0x48
fn_802E0E10 = .text:0x802E0E10; // type:function size:0xC
fn_802E0E20 = .text:0x802E0E20; // type:function size:0x44
Expand Down Expand Up @@ -22197,7 +22197,7 @@ fn_803B8640 = .text:0x803B8640; // type:function size:0xB0
fn_803B86F0 = .text:0x803B86F0; // type:function size:0x7C
PSMTXTrans = .text:0x803B8770; // type:function size:0x34
fn_803B87B0 = .text:0x803B87B0; // type:function size:0x4C
fn_803B8800 = .text:0x803B8800; // type:function size:0x28
PSMTXScale = .text:0x803B8800; // type:function size:0x28
fn_803B8830 = .text:0x803B8830; // type:function size:0x58
PSMTXQuat = .text:0x803B8890; // type:function size:0xA4
fn_803B8940 = .text:0x803B8940; // type:function size:0x174
Expand Down
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ def nw4rLib(lib_name, objects, extra_cflags=[]):
Rel(NonMatching, "d_a_e_gunhob", "REL/d/a/e/d_a_e_gunhob.cpp"),
Rel(NonMatching, "d_a_e_gunho", "REL/d/a/e/d_a_e_gunho.cpp"),
Rel(NonMatching, "d_a_e_hb", "REL/d/a/e/d_a_e_hb.cpp"),
Rel(NonMatching, "d_a_e_hb_leaf", "REL/d/a/e/d_a_e_hb_leaf.cpp"),
Rel(Matching, "d_a_e_hb_leaf", "REL/d/a/e/d_a_e_hb_leaf.cpp"),
Rel(NonMatching, "d_a_e_hidokari", "REL/d/a/e/d_a_e_hidokari.cpp"),
Rel(NonMatching, "d_a_e_hidokaris", "REL/d/a/e/d_a_e_hidokaris.cpp"),
Rel(NonMatching, "d_a_e_hidory", "REL/d/a/e/d_a_e_hidory.cpp"),
Expand Down
59 changes: 59 additions & 0 deletions include/d/a/e/d_a_e_hb_leaf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef D_A_E_HB_LEAF_H
#define D_A_E_HB_LEAF_H

#include <c/c_math.h>
#include <d/a/obj/d_a_obj_base.h>
#include <m/m3d/m_anmmdl.h>
#include <m/m3d/m_anmtexpat.h>

extern "C" bool fn_800B9D80(f32, f32, f32 *, int, const mVec3_c &, u32);

class dAcEhb_leaf_c : public dAcObjBase_c {
public:
dAcEhb_leaf_c() : someFloat(unkFloat0), field_0x3CC(0), field_0x3DE(0) {}
virtual ~dAcEhb_leaf_c() {}
virtual bool createHeap() override;
virtual int create() override;
virtual int actorExecute() override;
virtual int draw() override;
virtual int doDelete() override;

void setAnm(const char *anm, f32 pos);

private:
const static f32 unkFloat0;
const static f32 unkFloat1;

m3d::mdlAnmChr mModel; // 0x330
m3d::anmTexPat_c mAnm; // 0x398

f32 someFloat; // 0x3C4
UNKWORD field_0x3C8; // 0x3C8
u8 field_0x3CC; // 0x3CC
mVec3_c mStartingPos; // 0x3D0
u16 someRot; // 0x3DC
u8 field_0x3DE; // 0x3DE
u8 mType; // 0x3DF

bool isNearZero() {
return fabsf(someFloat) <= FLT_EPSILON;
}

bool isHidden() {
return mType != 0 && isNearZero() ? true : false;
}

void doCheck() {
fn_800B9D80(10.0f, 0.2f, &someFloat, roomid, mStartingPos, 0);
}

int getParam1() {
return params & 7;
}

int getParam2() {
return params >> 7 & 3;
}
};

#endif
File renamed without changes.
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 @@ -62,7 +62,7 @@ class dAcObjBase_c : public dAcBase_c {
// could be their own thing?
/* 8002de40 */ static void *getOarcFile(const char *oarcName, const char *fileName);
/* 8002de60 */ static void *getOarcSubEntry(const char *oarcName, const char *fileName);
/* 8002de80 */ static nw4r::g3d::ResFile getOarcResFile(const char *oarcName);
/* 8002de80 */ static void *getOarcResFile(const char *oarcName);
/* 8002de90 */ static void *getOarcModelFile(const char *oarcName);
/* 8002dea0 */ static void *getOarcZev(const char *oarcName);
/* 8002deb0 */ static void *getOarcDZB(const char *dzbName);
Expand Down
20 changes: 14 additions & 6 deletions include/m/m3d/m_anmmdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ namespace m3d {
class mdlAnmChr {
public:
mdlAnmChr() {}
virtual ~mdlAnmChr();
virtual ~mdlAnmChr(); // 0x08

virtual void play();
virtual void setFrame(f32);
virtual void setAnm(const char *name, playMode_e mode, f32);
virtual void setAnm(const char *name, playMode_e mode);
virtual void setRate(f32);
virtual void play(); // 0x0C
virtual void setFrame(f32); // 0x10
virtual void setAnm(const char *name, playMode_e mode, f32); // 0x14
virtual void setAnm(const char *name, playMode_e mode); // 0x18
virtual void setRate(f32); // 0x20

bool create(void *mdlFile, void *anmFile, const char *mdlName, const char *anmName, mAllocator_c *alloc,
u32 bufferOption, int nView, u32 *pSize);
Expand All @@ -29,6 +29,14 @@ class mdlAnmChr {
bool create(void *mdlFile, void *anmFile, const char *mdlName, const char *anmName, mdl_c::mdlCallback_c *callback,
mAllocator_c *alloc, u32 bufferOption, int nView, u32 *pSize);

inline bool create(void *resFile, const char *mdlName, const char *anmName, mAllocator_c *alloc, u32 bufferOption) {
return create(resFile, mdlName, anmName, alloc, bufferOption, 1, nullptr);
}

inline mdl_c &getModel() {
return mMdl;
}

private:
nw4r::g3d::ResFile mMdlFile;
nw4r::g3d::ResFile mAnmFile;
Expand Down
109 changes: 109 additions & 0 deletions src/REL/d/a/e/d_a_e_hb_leaf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#include <d/a/e/d_a_e_hb_leaf.h>

const f32 dAcEhb_leaf_c::unkFloat0 = 0.0f;
const f32 dAcEhb_leaf_c::unkFloat1 = -0.0f;

SPECIAL_ACTOR_PROFILE(E_HB_LEAF, dAcEhb_leaf_c, fProfile::E_HB_LEAF, 0x100, 0, 3);

bool dAcEhb_leaf_c::createHeap() {
// This is ever so slightly weird but our m_anmMdl really doesn't take ResFile by value
// but only ever a single pointer.
void *fp = getOarcResFile("Degubaba");
TRY_CREATE(mModel.create(fp, "degubaba_leaf", "shake2", &heap_allocator, 0x123));
nw4r::g3d::ResFile f = fp;
nw4r::g3d::ResMdl mdl = f.GetResMdl("degubaba_leaf");
nw4r::g3d::ResAnmTexPat anm = f.GetResAnmTexPat("degubaba_leaf");
TRY_CREATE(mAnm.create(mdl, anm, &heap_allocator, nullptr, 1));
mModel.getModel().setAnm(mAnm);
return true;
}

int dAcEhb_leaf_c::create() {
if (!initAllocatorWork1Heap(-1, "dAcEhb_leaf_c::m_allocator", 0x20)) {
return FAILED;
}

setBoundingBox(mVec3_c(-100.0f, -100.0f, -100.0f), mVec3_c(100.0f, 100.0f, 100.0f));

rotation.y = cM::rndF(65535.0f);
someRot = rotation.y.mVal;

switch (getParam1()) {
case 0:
case 7:
mType = 0;
break;
case 1:
mType = 1;
break;
case 2:
mType = 2;
break;
case 3:
case 4:
case 5:
rotation.z = -0x8000;
break;
default:
break;
}

if (mType == 0) {
u32 param2 = getParam2();
if (param2 == 1) {
mType = 1;
} else if (param2 == 2) {
mType = 2;
}
}

if (mType == 2) {
field_0x3CC = 1;
someFloat = 1.0f;
}

if (mType != 0) {
actor_properties &= ~1;
}

mStartingPos = position;

return SUCCEEDED;
}

int dAcEhb_leaf_c::doDelete() {
return 1;
}

int dAcEhb_leaf_c::actorExecute() {
if (mType != 0) {
doCheck();
if (isNearZero()) {
return 1;
}
}

updateMatrix();
if (mType != 0) {
Mtx m;
PSMTXScale(m, someFloat, someFloat, someFloat);
PSMTXConcat(worldMatrix.m, m, worldMatrix.m);
}
mModel.getModel().setLocalMtx(worldMatrix);
mModel.getModel().calc(false);
someRot++;

return 1;
}

int dAcEhb_leaf_c::draw() {
if (!isHidden()) {
drawModelType1(&mModel.getModel());
}

return 1;
}

void dAcEhb_leaf_c::setAnm(const char *anm, f32 pos) {
mModel.setAnm(anm, m3d::PLAY_MODE_4, pos);
}
1 change: 0 additions & 1 deletion tools/rel_sieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
['fn_80353F30', 'UnkCollider::ctor2'],
['fn_80353FF0', 'UnkCollider::init'],
['fn_800C3EC0', 'ActorEventFlowManagerRelated::checkEventFinished'],
['fn_802E6000', 'mdlAnmChr_c::create'],
['fn_800275C0', 'EffectsStruct::ctor'],
['fn_80027610', 'EffectsStruct::ctor'],
['fn_803465D0', 'ActorCollision::ctor'],
Expand Down

0 comments on commit ef5aaf8

Please sign in to comment.