Match mknjd::draw and mknjd::setMaterial

This commit is contained in:
Dylan Ascencio
2023-09-28 22:38:16 -04:00
parent 2001db31bc
commit f2d748da3e
5 changed files with 105 additions and 10 deletions
+23 -1
View File
@@ -528,7 +528,7 @@ private:
extern const u16 j3dDefaultZModeID;
inline u16 calcZModeID(u8 param_0, u8 param_1, u8 param_2) {
return ((param_1 * 2) & 0x1FE) + (param_0 * 0x10) + param_2;
return (param_1 * 2) + (param_0 * 0x10) + param_2;
}
struct J3DZModeInfo {
@@ -537,6 +537,8 @@ struct J3DZModeInfo {
/* 0x2 */ u8 field_0x2;
};
extern J3DZModeInfo j3dZModeTable[2];
struct J3DZMode {
J3DZMode() {
mZModeID = j3dDefaultZModeID;
@@ -546,6 +548,14 @@ struct J3DZMode {
mZModeID = calcZModeID(info.field_0x0, info.field_0x1, info.field_0x2);
}
void setCompareEnable(u8 i_compare) {
mZModeID = calcZModeID(i_compare, j3dZModeTable[mZModeID].field_0x1, j3dZModeTable[mZModeID].field_0x2);
}
void setUpdateEnable(u8 i_enable) {
mZModeID = calcZModeID(j3dZModeTable[mZModeID].field_0x0, j3dZModeTable[mZModeID].field_0x1, i_enable);
}
/* 0x0 */ u16 mZModeID;
};
@@ -562,6 +572,18 @@ struct J3DBlend : public J3DBlendInfo {
J3DBlend() {
*(J3DBlendInfo*)this = j3dDefaultBlendInfo;
}
void setType(u8 i_type) {
mType = i_type;
}
void setSrcFactor(u8 i_src) {
mSrcFactor = i_src;
}
void setDstFactor(u8 i_dst) {
mDstFactor = i_dst;
}
};
extern const J3DFogInfo j3dDefaultFogInfo;
@@ -74,6 +74,7 @@ public:
void setTevKColor(u32 i, const J3DGXColor* i_color) { mTevBlock->setTevKColor(i, i_color); }
void setMaterialAnm(J3DMaterialAnm* i_anm) { mMaterialAnm = i_anm; }
void setCullMode(u8 i_mode) { mColorBlock->setCullMode(i_mode); }
void setMaterialMode(u32 i_mode) { mMaterialMode = i_mode; }
public:
/* 0x04 */ J3DMaterial* mNext;
+1
View File
@@ -1354,6 +1354,7 @@ inline void dComIfGd_setListP1() {
inline void dComIfGd_setListBG() {
g_dComIfG_gameInfo.drawlist.setOpaListBG();
g_dComIfG_gameInfo.drawlist.setXluListBG();
}
inline void dComIfGd_setXluListBG() {
+4 -4
View File
@@ -214,8 +214,8 @@ public:
void setXluDrawList(J3DDrawBuffer* buffer) { j3dSys.setDrawBuffer(buffer, XLU_BUFFER); }
void setOpaDrawList(J3DDrawBuffer* buffer) { j3dSys.setDrawBuffer(buffer, OPA_BUFFER); }
void setOpaList() { setOpaDrawList(mpBufInvisibleModelOpa); }
void setXluList() { setXluDrawList(mpBufInvisibleModelXlu); }
void setOpaList() { setOpaDrawList(mpBufWorldOpa); }
void setXluList() { setXluDrawList(mpBufWorldXlu); }
void setOpaListMaskOff() { setOpaDrawList(mpBufInvisibleModelMaskOffOpa); }
void setXluListMaskOff() { setXluDrawList(mpBufInvisibleModelMaskOffXlu); }
void setOpaListSky() { setOpaDrawList(mpBufSkyOpa); }
@@ -224,8 +224,8 @@ public:
void setXluListP0() { setXluDrawList(mpLinkBuf); }
void setOpaListP1() { setOpaDrawList(field_0x0000c); }
void setXluListP1() { setXluDrawList(field_0x00010); }
void setOpaListBG() { setOpaDrawList(mpBufWorldOpa); }
void setXluListBG() { setXluDrawList(mpBufWorldXlu); }
void setOpaListBG() { setOpaDrawList(mpBufInvisibleModelOpa); }
void setXluListBG() { setXluDrawList(mpBufInvisibleModelXlu); }
void setOpaListFilter() { setOpaDrawList(mpWetherFxBuffer); }
void setXluListFilter() { setXluDrawList(mpWetherFxBuffer); }
void setOpaList2D() { setOpaDrawList(field_0x00038); }
+76 -5
View File
@@ -6,6 +6,7 @@
#include "f_op/f_op_actor_mng.h"
#include "JSystem/JKernel/JKRHeap.h"
#include "JSystem/JUtility/JUTAssert.h"
#include "JSystem/J3DGraphBase/J3DSys.h"
#include "d/d_procname.h"
#include "d/d_com_inf_game.h"
#include "d/d_bg_s_movebg_actor.h"
@@ -79,14 +80,33 @@ namespace daObjMknjD {
static const char M_arcname[];
/* 0x02C8 */ cXyz m02C8;
/* 0x02D4 */ cXyz m02D4;
/* 0x02E0 */ cXyz m02E0[0x14];
/* 0x03D0 */ float m03D0[0x14];
/* 0x0420 */ request_of_phase_process_class mPhs;
/* 0x0428 */ J3DModel* mModel0;
/* 0x042C */ J3DModel* mModel1;
/* 0x0430 */ u16 m0430;
/* 0x0432 */ u16 m0432;
/* 0x0434 */ u16 m0434;
/* 0x0438 */ u32 m0438;
/* 0x043C */ u8 m043C;
/* 0x043D */ bool m043D;
/* 0x043E */ u8 m043E;
/* 0x043F */ u8 m043F;
/* 0x04E2 */ s16 m04E2;
};
const char Act_c::M_arcname[] = "MknjD";
static void manage_friend_draw(int);
static void setMaterial(J3DMaterial*, unsigned char);
static void setMaterial(J3DMaterial*, u8);
}
/* 00000078-0000012C .text nodeCallBackL__FP7J3DNodei */
@@ -208,14 +228,65 @@ int daObjMknjD::Act_c::Execute(float(**)[3][4]) {
}
/* 000020E0-000022FC .text setMaterial__10daObjMknjDFP11J3DMaterialUc */
void daObjMknjD::setMaterial(J3DMaterial*, unsigned char) {
/* Nonmatching */
void daObjMknjD::setMaterial(J3DMaterial* i_mat, u8 i_alpha) {
for (; i_mat != NULL; i_mat = i_mat->getNext()) {
if (i_alpha == 0) {
i_mat->getShape()->hide();
}
else {
i_mat->getShape()->show();
if (i_alpha == 0xFF) {
i_mat->setMaterialMode(1);
i_mat->getPEBlock()->getZMode()->setUpdateEnable(1);
i_mat->getPEBlock()->getZMode()->setCompareEnable(1);
i_mat->getPEBlock()->getBlend()->setType(0);
}
else {
i_mat->setMaterialMode(1);
i_mat->getPEBlock()->getZMode()->setUpdateEnable(0);
i_mat->getPEBlock()->getZMode()->setCompareEnable(0);
i_mat->getPEBlock()->getBlend()->setType(1);
i_mat->getPEBlock()->getBlend()->setSrcFactor(4);
i_mat->getPEBlock()->getBlend()->setDstFactor(5);
}
GXColor* tevKColor = i_mat->getTevKColor(3);
tevKColor->a = i_alpha;
}
}
}
/* 000022FC-00002430 .text Draw__Q210daObjMknjD5Act_cFv */
int daObjMknjD::Act_c::Draw() {
/* Nonmatching */
return 0;
g_env_light.settingTevStruct(TEV_TYPE_BG0, getPositionP(), &mTevStr);
g_env_light.setLightTevColorType(mModel1, &mTevStr);
g_env_light.settingTevStruct(TEV_TYPE_BG0, getPositionP(), &mTevStr);
g_env_light.setLightTevColorType(mModel0, &mTevStr);
dComIfGd_setList();
J3DModelData* mdlData = mModel0->getModelData();
u16 jointCount = mdlData->getJointNum();
for (u16 i = 0; i < jointCount; i++) {
setMaterial(mdlData->getJointNodePointer(i)->getMesh(), m043C);
}
dComIfGd_setListSky();
mDoExt_modelUpdateDL(mModel0);
if (m043D == true) {
mDoExt_modelUpdateDL(mModel1);
}
dComIfGd_setListBG();
return 1;
}
namespace daObjMknjD {