Skip to content

Commit

Permalink
Merge pull request #22 from Sage-of-Mirrors/main
Browse files Browse the repository at this point in the history
Match d_a_magma, progress on d_a_branch
  • Loading branch information
magcius authored Sep 13, 2023
2 parents 1e69958 + 7a43b23 commit 4804a9e
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 41 deletions.
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def ActorRel(status, rel_name):
ActorRel(NonMatching, "d_a_lamp"),
ActorRel(NonMatching, "d_a_lod_bg"),
ActorRel(NonMatching, "d_a_lwood"),
ActorRel(NonMatching, "d_a_magma"),
ActorRel(Matching, "d_a_magma"),
ActorRel(NonMatching, "d_a_majuu_flag"),
ActorRel(NonMatching, "d_a_mdoor"),
ActorRel(NonMatching, "d_a_msw"),
Expand Down
1 change: 1 addition & 0 deletions include/m_Do/m_Do_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ class mDoExt_McaMorf /* : public J3DMtxCalcMaya */ {
void setFrame(f32 frame) { mFrameCtrl.setFrame(frame); }
void updateDL();
void play(Vec *, u32, u8);
void stopZelAnime();

u32 pad[0x50]; // J3DMtxCalcMaya
/* 0x50 */ J3DModel* mpModel;
Expand Down
150 changes: 117 additions & 33 deletions src/d/actor/d_a_branch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,27 @@
#include "f_op/f_op_actor_mng.h"
#include "d/d_procname.h"
#include "m_Do/m_Do_ext.h"
#include "m_Do/m_Do_mtx.h"
#include "d/d_com_inf_game.h"
#include "d/d_resorce.h"
#include "d/d_kankyo.h"
#include "JSystem/J3DGraphBase/J3DMaterial.h"
#include "dolphin/mtx/mtx.h"
#include "dolphin/types.h"


class daBranch_c : public fopAc_ac_c {
public:
~daBranch_c() {
for (int i = 0; i < 2; i++) {
mDoExt_McaMorf* anim = mAnims[i];
if (anim != 0) {
anim->stopZelAnime();
}
}

dComIfG_resDelete(&mPhs, m_arcname);
}

void set_mtx();
void set_anim(int, int, int);
void demoPlay(mDoExt_McaMorf*);
Expand All @@ -24,9 +38,13 @@ class daBranch_c : public fopAc_ac_c {
static s32 solidHeapCB(fopAc_ac_c*);

/* 0x0290 */ request_of_phase_process_class mPhs;
/* 0x0294 */ s8 dummy[0x10];
// ...
/* 0x02A8*/ mDoExt_McaMorf* mAnims[2];
/* 0x0298 */ J3DModel* mModels[2];
/* 0x02A0 */ u8 dummy2[0x08];
/* 0x02A8 */ mDoExt_McaMorf* mAnims[2];
/* 0x02B0 */ u8 dummy[0x08];
/* 0x02B8 */ u32 m02B8;
/* 0x02BC */ u8 m02BC;
/* 0x02BD */ u8 m02BD;

static char m_arcname[];
};
Expand All @@ -35,20 +53,29 @@ char daBranch_c::m_arcname[] = "Kwood_00";

/* 00000078-00000128 .text set_mtx__10daBranch_cFv */
void daBranch_c::set_mtx() {
/* Nonmatching */
//for (int i = 0; i < 2; i ++) {
J3DModel* pMdl;

for (int i = 0; i < 2; i ++) {
pMdl = mModels[i];

if (pMdl) {
pMdl->setBaseScale(mScale);

//}
mDoMtx_stack_c::transS(getPosition());
mDoMtx_stack_c::XYZrotM(getAngle().x, getAngle().y, getAngle().z);
pMdl->i_setBaseTRMtx(mDoMtx_stack_c::get());
}
}
}

/* 00000128-000001E4 .text set_anim__10daBranch_cFiii */
void daBranch_c::set_anim(int i_animIdx, int i_bckIdx, int i_basIdx) {
if (i_bckIdx > 0 && i_basIdx > 0) {
void* pSnd = dComIfG_getObjectIDRes(m_arcname, i_basIdx);
void* pAnm = dComIfG_getObjectIDRes(m_arcname, i_bckIdx);
J3DAnmTransform* pAnm = static_cast<J3DAnmTransform*>(dComIfG_getObjectIDRes(m_arcname, i_bckIdx));

mAnims[i_animIdx]->setAnm(
static_cast<J3DAnmTransform*>(pAnm),
pAnm,
-1,
0.0f,
1.0f,
Expand All @@ -73,31 +100,25 @@ s32 daBranch_c::solidHeapCB(fopAc_ac_c* i_this) {
/* 00000248-0000049C .text CreateHeap__10daBranch_cFv */
s32 daBranch_c::CreateHeap() {
/* Nonmatching */
int basIds[] = { 8, 0 };
int bckIds[] = { 7, 2 };
int bmdIds[] = { 6, 5 };
int t[] = {0, 0};

BOOL status = TRUE;

s32 ids[] = {
8, 0,
7, 2,
6, 5
};

for (int i = 0; i < 2; i++) {
void* modelRes = dRes_control_c::getIDRes(m_arcname, ids[i + 4], g_dComIfG_gameInfo.mResControl.mObjectInfo, 0x40);
void* bckRes = dRes_control_c::getIDRes(m_arcname, ids[i + 2], g_dComIfG_gameInfo.mResControl.mObjectInfo, 0x40);
J3DModelData* modelData = static_cast<J3DModelData*>(dComIfG_getObjectIDRes(m_arcname, bmdIds[i]));
J3DAnmTransformKey* bck = static_cast<J3DAnmTransformKey*>(dComIfG_getObjectIDRes(m_arcname, bckIds[i]));

if (!modelRes) {
JUT_ASSERT(0x1CC, "modelData != 0");
}
if (!bckRes) {
JUT_ASSERT(0x1CD, "bck != 0");
}
JUT_ASSERT(0x1CC, modelData != 0);
JUT_ASSERT(0x1CD, bck != 0);

mDoExt_McaMorf* newMorf = new mDoExt_McaMorf(
(J3DModelData*)dRes_control_c::getIDRes(m_arcname, ids[i + 4], g_dComIfG_gameInfo.mResControl.mObjectInfo, 0x40),
static_cast<J3DModelData*>(dComIfG_getObjectIDRes(m_arcname, bmdIds[i])),
0,
0,
(J3DAnmTransformKey*)dRes_control_c::getIDRes(m_arcname, ids[i + 2], g_dComIfG_gameInfo.mResControl.mObjectInfo, 0x40),
static_cast<J3DAnmTransformKey*>(dComIfG_getObjectIDRes(m_arcname, bckIds[i])),
0,
1.0f,
0,
Expand All @@ -109,35 +130,81 @@ s32 daBranch_c::CreateHeap() {
);

mAnims[i] = newMorf;
if (mAnims[i] == 0) {
if (!mAnims[i]) {
status = FALSE;
break;
}

mModels[i] = newMorf->mpModel;
if (!mModels[i]) {
status = FALSE;
break;
}

mAnims[i]->setFrame(0.0f);
set_anim(i, bckIds[i], basIds[i]);
}

return status;
}

/* 0000049C-00000524 .text daBranch_Draw__FP10daBranch_c */
void daBranch_Draw(daBranch_c*) {
/* Nonmatching */
BOOL daBranch_Draw(daBranch_c* i_this) {
int activeIdx = 0;
if (i_this->m02B8 == 5) {
activeIdx = 1;
}

g_env_light.settingTevStruct(TEV_TYPE_BG0, &i_this->current.pos, &i_this->mTevStr);
g_env_light.setLightTevColorType(i_this->mModels[activeIdx], &i_this->mTevStr);

i_this->mAnims[activeIdx]->updateDL();

return TRUE;
}

/* 00000524-0000060C .text daBranch_Execute__FP10daBranch_c */
void daBranch_Execute(daBranch_c*) {
void daBranch_Execute(daBranch_c* i_this) {
/* Nonmatching */
int demoId = i_this->mDemoActorId;

if (demoId == 0) {
if (i_this->m02B8 == 5) {
if (i_this->mAnims[1]) {
i_this->mAnims[1]->play(0, 0, 0);
}
}
else if (i_this->m02B8 == 6 && i_this->mAnims[0]) {
i_this->mAnims[0]->play(0, 0, 0);
}
}
else {
void* demoActor = g_dComIfG_gameInfo.play.mDemo;

if (demoActor) {
//i_this->m02B8 = demoActor->mShape;

if (i_this->m02B8 == 6) {
i_this->demoPlay(i_this->mAnims[0]);
}
else if (i_this->m02B8 == 5) {
i_this->demoPlay(i_this->mAnims[1]);
}
}
}

i_this->set_mtx();
}

/* 0000060C-00000614 .text daBranch_IsDelete__FP10daBranch_c */
BOOL daBranch_IsDelete(daBranch_c*) {
BOOL daBranch_IsDelete(daBranch_c* i_this) {
return TRUE;
}

/* 00000614-00000694 .text daBranch_Delete__FP10daBranch_c */
void daBranch_Delete(daBranch_c*) {
/* Nonmatching */
BOOL daBranch_Delete(daBranch_c* i_this) {
i_this->~daBranch_c();
return TRUE;
}

/* 00000694-0000080C .text daBranch_Create__FP10fopAc_ac_c */
Expand All @@ -153,13 +220,30 @@ s32 daBranch_Create(fopAc_ac_c* i_this) {

if (solidHeapResult & 0xFF == 0) {
for (int i = 0; i < 2; i++) {
//branch->mBase.m
branch->mAnims[i] = 0;
}

state = cPhs_ERROR_e;
}
else {
branch->mCullMtx = branch->mModels[0]->mBaseTransformMtx;
fopAcM_setCullSizeBox(i_this, 0.0f, 0.0f, -50.0f, 300.0f, 100.0f, 50.0f);

branch->m02B8 = 6;
branch->m02BC = 0;
branch->m02BD = 0;

for (int i = 0; i < 2; i++) {
J3DModelData* modelData = branch->mModels[i]->mModelData;

for (int j = 0; j < modelData->getMaterialNum(); j++) {
J3DMaterial* mat = modelData->getMaterialNodePointer(j);
if (mat) {
J3DFog* fog = mat->getPEBlock()->getFog();
fog->field_0x0 = 2;
}
}
}
}
}

Expand Down
71 changes: 64 additions & 7 deletions src/d/actor/d_a_magma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,78 @@
// Translation Unit: d_a_magma.cpp
//

#include "d_a_magma.h"
#include "JSystem/JKernel/JKRHeap.h"
#include "f_op/f_op_actor_mng.h"
#include "d/d_procname.h"
#include "d/d_com_inf_game.h"
#include "d/d_magma.h"
#include "dolphin/types.h"


class daMagma_c : public fopAc_ac_c {
public:
~daMagma_c() {
dComIfG_resDelete(&mPhs, "Magma");
}

request_of_phase_process_class mPhs;
};

/* 00000078-00000080 .text daMagma_IsDelete__FP9daMagma_c */
void daMagma_IsDelete(daMagma_c*) {
/* Nonmatching */
BOOL daMagma_IsDelete(daMagma_c* i_this) {
return TRUE;
}

/* 00000080-000000CC .text daMagma_Delete__FP9daMagma_c */
void daMagma_Delete(daMagma_c*) {
/* Nonmatching */
BOOL daMagma_Delete(daMagma_c* i_this) {
i_this->~daMagma_c();
return TRUE;
}

/* 000000CC-00000178 .text daMagma_Create__FP10fopAc_ac_c */
void daMagma_Create(fopAc_ac_c*) {
/* Nonmatching */
s32 daMagma_Create(fopAc_ac_c* i_this) {
daMagma_c* magma = static_cast<daMagma_c*>(i_this);

fopAcM_SetupActor(magma, daMagma_c);

int result = dComIfG_resLoad(&magma->mPhs, "Magma");
if (result != cPhs_COMPLEATE_e) {
return result;
}

if (g_dComIfG_gameInfo.play.createMagma()) {
g_dComIfG_gameInfo.play.mpMagmaPacket->newFloor(
magma->current.pos,
magma->mScale,
magma->getRoomNo(),
magma->mBase.mParameters
);
}

return cPhs_ERROR_e;
}

static actor_method_class l_daMagma_Method = {
(process_method_func)daMagma_Create,
(process_method_func)daMagma_Delete,
(process_method_func)0,
(process_method_func)daMagma_IsDelete,
(process_method_func)0,
};

extern actor_process_profile_definition g_profile_MAGMA = {
fpcLy_CURRENT_e,
7,
fpcPi_CURRENT_e,
PROC_MAGMA,
&g_fpcLf_Method.mBase,
sizeof(daMagma_c),
0,
0,
&g_fopAc_Method.base,
0x01BC,
&l_daMagma_Method,
0x00040180,
fopAc_ACTOR_e,
fopAc_CULLBOX_0_e
};

0 comments on commit 4804a9e

Please sign in to comment.