Skip to content

Commit

Permalink
d_a_demo00 work
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Dec 27, 2024
1 parent c7e3e7f commit 4470b7d
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 41 deletions.
70 changes: 59 additions & 11 deletions include/d/actor/d_a_demo00.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,88 @@
#include "f_op/f_op_actor.h"

class dDemo_actor_c;
class mDoExt_McaMorf;
class J3DModel;
class mDoExt_invisibleModel;
class mDoExt_btpAnm;
class mDoExt_btkAnm;
class mDoExt_brkAnm;
struct DEMO_PLIGHT;
class dBgS_GndChk;

class daDemo00_model_c {
class daDemo00_shadow_c {
public:
/* 0x00 */ u32 shadowID;
/* 0x04 */ cXyz pos;
/* 0x10 */ f32 field_0x10;
/* 0x14 */ f32 field_0x14;
};

class daDemo00_resID_c {
public:
void reset();

public:
/* Place member variables here */
/* 0x00 */ s32 modelID;
/* 0x04 */ s32 bckID;
/* 0x08 */ s32 field_0x08;
/* 0x0C */ s32 btpID;
/* 0x10 */ s32 btkID;
/* 0x14 */ s32 brkID;
/* 0x18 */ s32 field_0x18;
/* 0x1C */ s32 field_0x1C;
/* 0x20 */ s32 plightID;
/* 0x24 */ s32 shadowID;
};

class daDemo00_resID_c {
class daDemo00_model_c {
public:
void reset();

public:
/* Place member variables here */
/* 0x00 */ daDemo00_resID_c resID;
/* 0x28 */ mDoExt_McaMorf* morf;
/* 0x2C */ J3DModel* model;
/* 0x30 */ mDoExt_invisibleModel* invisibleModel;
/* 0x34 */ mDoExt_btpAnm* btpAnm;
/* 0x38 */ mDoExt_btkAnm* btkAnm;
/* 0x3C */ mDoExt_brkAnm* brkAnm;
/* 0x40 */ void * field_0x40;
/* 0x44 */ daDemo00_shadow_c* shadow;
/* 0x48 */ DEMO_PLIGHT* plight;
};

class daDemo00_bgc_c {
};

class daDemo00_c : public fopAc_ac_c {
public:
void action(dDemo_actor_c*) {}
void setAction(int (daDemo00_c::*)(dDemo_actor_c*)) {}
~daDemo00_c();

typedef BOOL (daDemo00_c::*ActionFunc)(dDemo_actor_c* act);

BOOL action(dDemo_actor_c* act) { return (this->*actionFunc)(act); }
void setAction(ActionFunc func) { actionFunc = func; }

void setBaseMtx();
void setShadowSize();
void createHeap();
void actStandby(dDemo_actor_c*);
void actPerformance(dDemo_actor_c*);
void actLeaving(dDemo_actor_c*);
BOOL createHeap();
BOOL actStandby(dDemo_actor_c*);
BOOL actPerformance(dDemo_actor_c*);
BOOL actLeaving(dDemo_actor_c*);
inline BOOL create();
BOOL draw();
BOOL execute();

public:
/* Place member variables here */
/* 0x290 */ ActionFunc actionFunc;
/* 0x29C */ u8 field_0x29c;
/* 0x29D */ s8 field_0x29d;
/* 0x29E */ u8 field_0x29e;
/* 0x29F */ u8 field_0x29f;
/* 0x2A0 */ daDemo00_resID_c nextRes;
/* 0x2C8 */ daDemo00_model_c model;
/* 0x314 */ dBgS_GndChk* chk;
};

#endif /* D_A_DEMO00_H */
4 changes: 2 additions & 2 deletions include/d/d_demo.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class dDemo_actor_c : public JStage::TActor {
void getScale() {}
void getTrans() {}
void onEnable(u16) {}
void setAnmFrameMax(f32) {}
void setModel(J3DModel*) {}
void setAnmFrameMax(f32 v) { mAnimationFrameMax = v; }
void setModel(J3DModel* model) { mModel = model; }
void setOldAnmId(u32) {}
void setOldScrId(u32) {}
void setOldTevId(u32) {}
Expand Down
6 changes: 0 additions & 6 deletions include/d/d_kankyo.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ struct WAVE_INFO {
/* 0x14 */ f32 field_0x14;
};

struct DEMO_PLIGHT {
/* 0x00 */ int field_0x00;
/* 0x04 */ int field_0x04;
/* 0x08 */ LIGHT_INFLUENCE mLightInfluence;
};

class dKy_tevstr_c {
public:
/* 0x00 */ J3DLightObj mLightObj;
Expand Down
18 changes: 18 additions & 0 deletions include/d/d_kankyo_demo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef D_KANKYO_DEMO_H
#define D_KANKYO_DEMO_H

#include "d/d_kankyo.h"

struct cXyz;

struct DEMO_PLIGHT {
/* 0x00 */ int field_0x00;
/* 0x04 */ int field_0x04;
/* 0x08 */ LIGHT_INFLUENCE mLightInfluence;
};

void dKydm_demo_plight_entry(DEMO_PLIGHT* i_plight, cXyz* i_pos, int param_2, u8 param_3);
void dKydm_demo_plight_delete(DEMO_PLIGHT* i_plight);
void dKydm_demo_plight_execute(DEMO_PLIGHT* i_plight);

#endif /* D_KANKYO_DEMO_H */
169 changes: 147 additions & 22 deletions src/d/actor/d_a_demo00.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,179 @@
//

#include "d/actor/d_a_demo00.h"
#include "JSystem/J3DGraphAnimator/J3DSkinDeform.h"
#include "JSystem/J3DGraphBase/J3DSys.h"
#include "JSystem/J3DGraphBase/J3DTexture.h"
#include "JSystem/JUtility/JUTNameTab.h"
#include "SSystem/SComponent/c_phase.h"
#include "d/d_com_inf_game.h"
#include "d/d_demo.h"
#include "d/d_kankyo.h"
#include "d/d_kankyo_demo.h"
#include "d/d_procname.h"
#include "f_op/f_op_actor_mng.h"
#include "m_Do/m_Do_ext.h"
#include "m_Do/m_Do_graphic.h"
#include "m_Do/m_Do_mtx.h"
#include "JSystem/J3DGraphAnimator/J3DModel.h"
#include "JSystem/J3DGraphAnimator/J3DModelData.h"
#include "string.h"

/* 800E595C-800E598C .text reset__16daDemo00_resID_cFv */
void daDemo00_resID_c::reset() {
/* Nonmatching */
modelID = -1;
bckID = -1;
field_0x08 = -1;
btpID = -1;
btkID = -1;
brkID = -1;
field_0x18 = -1;
field_0x1C = -1;
plightID = -1;
shadowID = -1;
}

/* 800E598C-800E59EC .text reset__16daDemo00_model_cFv */
void daDemo00_model_c::reset() {
/* Nonmatching */
resID.reset();
model = NULL;
btpAnm = NULL;
btkAnm = NULL;
brkAnm = NULL;
if (plight != NULL) {
dKydm_demo_plight_delete(plight);
plight = NULL;
}
shadow = NULL;
}

daDemo00_c::~daDemo00_c() {
if (heap != NULL && model.morf != NULL) {
model.morf->stopZelAnime();
}
}

/* 800E5A60-800E5AFC .text setBaseMtx__10daDemo00_cFv */
void daDemo00_c::setBaseMtx() {
/* Nonmatching */
mDoMtx_stack_c::transS(current.pos);
mDoMtx_stack_c::XYZrotM(shape_angle);
model.model->setBaseTRMtx(mDoMtx_stack_c::get());
model.model->setBaseScale(scale);
model.model->calc();
}

/* 800E5AFC-800E5DEC .text setShadowSize__10daDemo00_cFv */
void daDemo00_c::setShadowSize() {
/* Nonmatching */
J3DModelData* modelData = model.model->getModelData();

cXyz min(1000000000.0f, 1000000000.0f, 1000000000.0f);
cXyz max(-1000000000.0f, -1000000000.0f, -1000000000.0f);

for (u16 i = 0; i < modelData->getJointNum(); i++) {
J3DJoint* joint = modelData->getJointNodePointer(i);
if (joint->getKind() == 0) {
cXyz jntMin;
cXyz jntMax;

mDoMtx_multVec(model.model->getAnmMtx(i), joint->getMin(), &jntMin);
mDoMtx_multVec(model.model->getAnmMtx(i), joint->getMax(), &jntMax);
min.x = jntMin.x < min.x ? jntMin.x : min.x;
min.y = jntMin.y < min.y ? jntMin.y : min.y;
min.z = jntMin.z < min.z ? jntMin.z : min.z;
max.x = jntMax.x > max.x ? jntMax.x : max.x;
max.y = jntMax.y > max.y ? jntMax.y : max.y;
max.z = jntMax.z > max.z ? jntMax.z : max.z;
}
}

model.shadow->pos.x = (max.x + min.x) * 0.5f;
model.shadow->pos.y = (max.y + min.y) * 0.5f;
model.shadow->pos.z = (max.z + min.z) * 0.5f;

cXyz extents = max - min;
model.shadow->field_0x10 = extents.abs() * 3.0f;
model.shadow->field_0x14 = extents.absXZ() * 0.25f;
}

/* 800E5DEC-800E5FF4 .text awaCheck__FP8J3DModel */
void awaCheck(J3DModel*) {
/* Nonmatching */
BOOL awaCheck(J3DModel* model) {
J3DModelData* modelData = model->getModelData();
J3DTexture* tex = modelData->getTexture();
if (tex != NULL) {
JUTNameTab* texName = modelData->getTextureName();
if (texName != NULL) {
for (u16 i = 0; i < tex->getNum(); i++) {
const char* name = texName->getName(i);
if (strcmp(name, "B_dummy") == 0 || strcmp(name, "cy_kankyo") == 0) {
J3DSkinDeform* deform = new J3DSkinDeform();
if (deform == NULL)
return FALSE;

if (model->setSkinDeform(deform, 1) != J3DErrType_Success)
return FALSE;

if (strcmp(name, "B_dummy") == 0) {
tex->setResTIMG(i, *mDoGph_gInf_c::getFrameBufferTimg());
mDoExt_modelTexturePatch(modelData);
}
}
}
}
}
return TRUE;
}

/* 800E5FF4-800E6014 .text createHeapCallBack__FP10fopAc_ac_c */
static BOOL createHeapCallBack(fopAc_ac_c*) {
/* Nonmatching */
static BOOL createHeapCallBack(fopAc_ac_c* i_this) {
return ((daDemo00_c*)i_this)->createHeap();
}

/* 800E6014-800E6620 .text createHeap__10daDemo00_cFv */
void daDemo00_c::createHeap() {
BOOL daDemo00_c::createHeap() {
/* Nonmatching */
}

/* 800E6620-800E6758 .text actStandby__10daDemo00_cFP13dDemo_actor_c */
void daDemo00_c::actStandby(dDemo_actor_c*) {
BOOL daDemo00_c::actStandby(dDemo_actor_c* act) {
/* Nonmatching */
if (nextRes.modelID != 0xFFFF || nextRes.plightID != 0xFFFF) {
model.resID = nextRes;
if (fopAcM_entrySolidHeap(this, createHeapCallBack, 0x4000) != 0) {
if (model.model != NULL) {
setBaseMtx();
fopAcM_SetMtx(this, model.model->getBaseTRMtx());
act->setModel(model.model);
if (model.morf != NULL)
act->setAnmFrameMax(model.morf->getEndFrame());
}

setAction(&daDemo00_c::actPerformance);
}
}

return TRUE;
}

/* 800E6758-800E6E2C .text actPerformance__10daDemo00_cFP13dDemo_actor_c */
void daDemo00_c::actPerformance(dDemo_actor_c*) {
BOOL daDemo00_c::actPerformance(dDemo_actor_c*) {
/* Nonmatching */
}

/* 800E6E2C-800E6E90 .text actLeaving__10daDemo00_cFP13dDemo_actor_c */
void daDemo00_c::actLeaving(dDemo_actor_c*) {
BOOL daDemo00_c::actLeaving(dDemo_actor_c* act) {
/* Nonmatching */
if (model.morf != NULL) {
model.morf->stopZelAnime();
}

fopAcM_DeleteHeap(this);
setAction(&daDemo00_c::actStandby);
return TRUE;
}

/* 800E6E90-800E6EB0 .text daDemo00_Draw__FP10daDemo00_c */
static BOOL daDemo00_Draw(daDemo00_c*) {
/* Nonmatching */
static BOOL daDemo00_Draw(daDemo00_c* i_this) {
return i_this->draw();
}

/* 800E6EB0-800E7204 .text draw__10daDemo00_cFv */
Expand All @@ -67,8 +185,8 @@ BOOL daDemo00_c::draw() {
}

/* 800E7204-800E7224 .text daDemo00_Execute__FP10daDemo00_c */
static BOOL daDemo00_Execute(daDemo00_c*) {
/* Nonmatching */
static BOOL daDemo00_Execute(daDemo00_c* i_this) {
return i_this->execute();
}

/* 800E7224-800E78A0 .text execute__10daDemo00_cFv */
Expand All @@ -77,18 +195,25 @@ BOOL daDemo00_c::execute() {
}

/* 800E78A0-800E78A8 .text daDemo00_IsDelete__FP10daDemo00_c */
static BOOL daDemo00_IsDelete(daDemo00_c*) {
/* Nonmatching */
static BOOL daDemo00_IsDelete(daDemo00_c* i_this) {
return TRUE;
}

/* 800E78A8-800E78D0 .text daDemo00_Delete__FP10daDemo00_c */
static BOOL daDemo00_Delete(daDemo00_c*) {
/* Nonmatching */
static BOOL daDemo00_Delete(daDemo00_c* i_this) {
i_this->~daDemo00_c();
return TRUE;
}

/* 800E78D0-800E7964 .text daDemo00_Create__FP10fopAc_ac_c */
static s32 daDemo00_Create(fopAc_ac_c*) {
/* Nonmatching */
static s32 daDemo00_Create(fopAc_ac_c* i_ac) {
daDemo00_c* i_this = (daDemo00_c*)i_ac;
fopAcM_SetupActor(i_this, daDemo00_c);
dKy_tevstr_init(&i_this->tevStr, dComIfGp_roomControl_getStayNo(), 0xFF);
i_this->setAction(&daDemo00_c::actStandby);
i_this->nextRes.reset();
i_this->field_0x29d = -1;
return cPhs_COMPLEATE_e;
}

static actor_method_class l_daDemo00_Method = {
Expand Down
1 change: 1 addition & 0 deletions src/d/d_kankyo_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

#include "d/d_kankyo.h"
#include "d/d_kankyo_demo.h"

/* 8009BE64-8009BF6C .text dKydm_demo_plight_entry__FP11DEMO_PLIGHTP4cXyziUc */
void dKydm_demo_plight_entry(DEMO_PLIGHT* i_plight, cXyz* i_pos, int param_2, u8 param_3) {
Expand Down

0 comments on commit 4470b7d

Please sign in to comment.