Skip to content

Commit

Permalink
d_a_lwood work
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Aug 3, 2024
1 parent c99b5bd commit caff8a8
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 25 deletions.
20 changes: 15 additions & 5 deletions include/d/actor/d_a_lwood.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,33 @@
#define D_A_LWOOD_H

#include "f_op/f_op_actor.h"
#include "SSystem/SComponent/c_phase.h"

class dBgW;

class daLwood_c : public fopAc_ac_c {
public:
inline s32 _create();
inline BOOL _delete();
inline BOOL _draw();
inline BOOL _execute();
void getYureScale() const {}
void getYureTimer() const {}
f32 getYureScale() const { return mScale; }
s16 getYureTimer() const { return mTimer; }
void setMoveBGMtx(); // weak but not inlined?
void set_mtx(); // weak but not inlined?

void CreateHeap();
void CreateInit();
BOOL CreateHeap();
BOOL CreateInit();

static const char m_arcname[];

public:
/* Place member variables here */
/* 0x290 */ request_of_phase_process_class mPhs;
/* 0x298 */ J3DModel* mModel;
/* 0x29C */ dBgW* mpBgW;
/* 0x2A0 */ Mtx mtx;
/* 0x2D0 */ s16 mTimer;
/* 0x2D4 */ f32 mScale;
};

#endif /* D_A_LWOOD_H */
2 changes: 1 addition & 1 deletion include/d/d_a_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace daObj {
}

void make_land_effect(fopAc_ac_c*, dBgS_GndChk*, float);
void get_wind_spd(fopAc_ac_c*, float);
cXyz& get_wind_spd(fopAc_ac_c*, float);
cXyz& get_path_spd(cBgS_PolyInfo&, float);
void posMoveF_stream(fopAc_ac_c*, const cXyz*, const cXyz*, float, float);
void posMoveF_grade(fopAc_ac_c*, const cXyz*, const cXyz*, float, float, const cXyz*, float, float, const cXyz*);
Expand Down
147 changes: 129 additions & 18 deletions src/d/actor/d_a_lwood.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,173 @@
//

#include "d/actor/d_a_lwood.h"
#include "m_Do/m_Do_ext.h"
#include "d/d_a_obj.h"
#include "d/d_com_inf_game.h"
#include "d/d_procname.h"
#include "d/res/res_lwood.h"
#include "m_Do/m_Do_ext.h"
#include "m_Do/m_Do_graphic.h"

const char daLwood_c::m_arcname[6] = "Lwood";

/* 00000078-00000098 .text CheckCreateHeap__FP10fopAc_ac_c */
static BOOL CheckCreateHeap(fopAc_ac_c*) {
/* Nonmatching */
static BOOL CheckCreateHeap(fopAc_ac_c* i_this) {
return ((daLwood_c*)i_this)->CreateHeap();
}

/* 00000098-00000194 .text CreateHeap__9daLwood_cFv */
void daLwood_c::CreateHeap() {
BOOL daLwood_c::CreateHeap() {
/* Nonmatching */
J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes(m_arcname, LWOOD_BDL_ALWD);
JUT_ASSERT(0xb9, modelData != NULL);
mModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000022);
if (mModel == NULL)
return FALSE;

mModel->setUserArea((u32)this);
setMoveBGMtx();
cBgD_t* bgp = (cBgD_t*)dComIfG_getObjectRes(m_arcname, LWOOD_DZB_ALWD);
mpBgW = dBgW_NewSet(bgp, dBgW::MOVE_BG_e, &mtx);
if (mpBgW == NULL)
return FALSE;

return TRUE;
}

static BOOL nodeCallBack(J3DNode*, int);

/* 00000194-000002E0 .text CreateInit__9daLwood_cFv */
void daLwood_c::CreateInit() {
BOOL daLwood_c::CreateInit() {
/* Nonmatching */
fopAcM_SetMtx(this, mModel->getBaseTRMtx());
fopAcM_setCullSizeBox(this, -600.0f, -0.0f, -600.0f, 600.0f, 900.0f, 600.0f);
fopAcM_setCullSizeFar(this, 2.37f);
mTimer = cM_rndF(32768.0f);
mScale = cM_rndF(0.4f) + 0.8f;
JUTNameTab* jointName = mModel->getModelData()->getJointName();
for (u16 i = 0; i < mModel->getModelData()->getJointNum(); i++) {
if (strcmp("J_Alwd_ha", jointName->getName(i)) == 0) {
mModel->getModelData()->getJointNodePointer(i)->setCallBack(&nodeCallBack);
break;
}
}

mModel->calc();
dComIfG_Bgsp()->Regist(mpBgW, this);
set_mtx();
mpBgW->Move();
}

/* 000002E0-000004D8 .text nodeCallBack__FP7J3DNodei */
static BOOL nodeCallBack(J3DNode*, int) {
static BOOL nodeCallBack(J3DNode* joint, int timing) {
/* Nonmatching */
if (mDoGph_gInf_c::isMonotone())
return TRUE;

if (timing == 0) {
u32 jntNo = ((J3DJoint*)joint)->getJntNo();
J3DModel* model = j3dSys.getModel();
daLwood_c* i_this = (daLwood_c*)model->getUserArea();
if (i_this != NULL) {
cXyz windSpeed = daObj::get_wind_spd(i_this, 100.0f);
f32 sy = cM_ssin(i_this->getYureTimer() * 300);
s16 r2 = windSpeed.x * sy * 10.0f;
f32 cy = cM_scos(i_this->getYureTimer() * 300);
s16 r0 = windSpeed.z * cy * 10.0f;

s16 r1 = fabs(sy + 1.0f) * 250.0f;

s16 p1 = i_this->getYureScale() * r1;
s16 p2 = i_this->getYureScale() * r0;
s16 p0 = i_this->getYureScale() * r2;

mDoMtx_stack_c::copy(model->getAnmMtx(jntNo));
mDoMtx_stack_c::ZXYrotM(p0, p1, p2);
model->setAnmMtx(jntNo, mDoMtx_stack_c::get());
mDoMtx_copy(mDoMtx_stack_c::get(), j3dSys.mCurrentMtx);
}
}

return TRUE;
}

/* 000004D8-00000560 .text set_mtx__9daLwood_cFv */
void daLwood_c::set_mtx() {
/* Nonmatching */
mModel->setBaseScale(scale);
mDoMtx_stack_c::transS(current.pos);
mDoMtx_stack_c::ZXYrotM(current.angle);
mModel->setBaseTRMtx(mDoMtx_stack_c::get());
}

/* 00000560-000005D8 .text setMoveBGMtx__9daLwood_cFv */
void daLwood_c::setMoveBGMtx() {
/* Nonmatching */
mDoMtx_stack_c::transS(current.pos);
mDoMtx_stack_c::ZXYrotM(current.angle);
mDoMtx_stack_c::scaleM(scale);
mDoMtx_copy(mDoMtx_stack_c::get(), mtx);
}

s32 daLwood_c::_create() {
fopAcM_SetupActor(this, daLwood_c);

s32 ret = dComIfG_resLoad(&mPhs, m_arcname);

if (ret == cPhs_COMPLEATE_e) {
if (fopAcM_entrySolidHeap(this, CheckCreateHeap, 0x0e40) == 0) {
ret = cPhs_ERROR_e;
} else {
CreateInit();
}
}

return ret;
}

BOOL daLwood_c::_delete() {
if (heap != NULL)
dComIfG_Bgsp()->Release(mpBgW);

dComIfG_resDelete(&mPhs, m_arcname);
return TRUE;
}

BOOL daLwood_c::_execute() {
mTimer++;
return TRUE;
}

BOOL daLwood_c::_draw() {
g_env_light.settingTevStruct(TEV_TYPE_BG0, &current.pos, &tevStr);
g_env_light.setLightTevColorType(mModel, &tevStr);
dComIfGd_setListBG();
mDoExt_modelUpdateDL(mModel);
dComIfGd_setList();
return TRUE;
}

/* 000005D8-00000678 .text daLwood_Create__FPv */
static s32 daLwood_Create(void*) {
/* Nonmatching */
static s32 daLwood_Create(void* i_this) {
return ((daLwood_c*)i_this)->_create();
}

/* 00000678-000006D4 .text daLwood_Delete__FPv */
static BOOL daLwood_Delete(void*) {
/* Nonmatching */
static BOOL daLwood_Delete(void* i_this) {
return ((daLwood_c*)i_this)->_delete();
}

/* 000006D4-00000778 .text daLwood_Draw__FPv */
static BOOL daLwood_Draw(void*) {
/* Nonmatching */
static BOOL daLwood_Draw(void* i_this) {
return ((daLwood_c*)i_this)->_draw();
}

/* 00000778-0000078C .text daLwood_Execute__FPv */
static BOOL daLwood_Execute(void*) {
/* Nonmatching */
static BOOL daLwood_Execute(void* i_this) {
return ((daLwood_c*)i_this)->_execute();
}

/* 0000078C-00000794 .text daLwood_IsDelete__FPv */
static BOOL daLwood_IsDelete(void*) {
/* Nonmatching */
static BOOL daLwood_IsDelete(void* i_this) {
return TRUE;
}

static actor_method_class daLwoodMethodTable = {
Expand Down
3 changes: 2 additions & 1 deletion src/d/d_a_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace daObj {
}

/* 800668BC-800669E8 .text get_wind_spd__5daObjFP10fopAc_ac_cf */
void get_wind_spd(fopAc_ac_c* param_1, f32 param_2) {
cXyz& get_wind_spd(fopAc_ac_c* param_1, f32 param_2) {
static cXyz total_spd(cXyz::Zero);

cXyz wind = *dKyw_get_wind_vec() * dKyw_get_wind_pow();
Expand All @@ -72,6 +72,7 @@ namespace daObj {
pntVec *= pntPow;

total_spd = (wind + pntVec) * (param_2 * 0.5f);
return total_spd;
}

/* 800669E8-80066B0C .text get_path_spd__5daObjFR13cBgS_PolyInfof */
Expand Down

0 comments on commit caff8a8

Please sign in to comment.