From 1778dea96cc227315609d303df59c909ba949583 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Sun, 12 Nov 2023 01:19:58 -0500 Subject: [PATCH] misc cleanup --- include/JSystem/J3DGraphBase/J3DMaterial.h | 2 ++ include/JSystem/J3DGraphBase/J3DStruct.h | 2 +- include/d/d_stage.h | 2 +- src/JSystem/J3DGraphBase/J3DTevs.cpp | 10 +++---- src/d/actor/d_a_hot_floor.cpp | 2 +- src/d/actor/d_a_obj_mknjd.cpp | 34 +++++++++++----------- src/d/actor/d_a_vrbox2.cpp | 10 +++---- src/d/d_shop.cpp | 5 ++-- 8 files changed, 35 insertions(+), 32 deletions(-) diff --git a/include/JSystem/J3DGraphBase/J3DMaterial.h b/include/JSystem/J3DGraphBase/J3DMaterial.h index 066571bfa..f12175432 100644 --- a/include/JSystem/J3DGraphBase/J3DMaterial.h +++ b/include/JSystem/J3DGraphBase/J3DMaterial.h @@ -67,6 +67,8 @@ public: J3DFog* getFog() { return mPEBlock->getFog(); } J3DZMode* getZMode() { return mPEBlock->getZMode(); } J3DBlend* getBlend() { return mPEBlock->getBlend(); } + J3DAlphaComp* getAlphaComp() { return mPEBlock->getAlphaComp(); } + u8 getZCompLoc() { return mPEBlock->getZCompLoc(); } J3DTexMtx* getTexMtx(u32 idx) { return mTexGenBlock->getTexMtx(idx); } u16 getIndex() { return mIndex; } bool isDrawModeOpaTexEdge() { return (mMaterialMode & 3) == 0; } diff --git a/include/JSystem/J3DGraphBase/J3DStruct.h b/include/JSystem/J3DGraphBase/J3DStruct.h index 1d2609ef8..4a604db07 100644 --- a/include/JSystem/J3DGraphBase/J3DStruct.h +++ b/include/JSystem/J3DGraphBase/J3DStruct.h @@ -233,7 +233,7 @@ struct J3DColorChanInfo { }; struct J3DZModeInfo { - /* 0x0 */ u8 mCompareEnable __attribute__((aligned(4))); + /* 0x0 */ u8 mCompareEnable; /* 0x1 */ u8 mFunc; /* 0x2 */ u8 mUpdateEnable; }; diff --git a/include/d/d_stage.h b/include/d/d_stage.h index 6894ddd73..3ea59f321 100644 --- a/include/d/d_stage.h +++ b/include/d/d_stage.h @@ -860,7 +860,7 @@ public: BOOL checkStatusFlag(int i_roomNo, u8 flag) const { return cLib_checkBit(mStatus[i_roomNo].mFlags, flag); } void offStatusFlag(int i_roomNo, u8 flag) { cLib_offBit(mStatus[i_roomNo].mFlags, flag); } - void onStatusFlag(int i_roomNo, u8 flag) { return cLib_onBit(mStatus[i_roomNo].mFlags, flag); } + void onStatusFlag(int i_roomNo, u8 flag) { cLib_onBit(mStatus[i_roomNo].mFlags, flag); } static JKRExpHeap* mMemoryBlock[16]; static dStage_roomStatus_c mStatus[64]; diff --git a/src/JSystem/J3DGraphBase/J3DTevs.cpp b/src/JSystem/J3DGraphBase/J3DTevs.cpp index 60d76748d..5a01822e0 100644 --- a/src/JSystem/J3DGraphBase/J3DTevs.cpp +++ b/src/JSystem/J3DGraphBase/J3DTevs.cpp @@ -262,18 +262,18 @@ void makeAlphaCmpTable() { } } -u8 j3dZModeTable[96]; +J3DZModeInfo j3dZModeTable[0x20]; /* 802EC69C-802EC708 .text makeZModeTable__Fv */ void makeZModeTable() { - u8* table = j3dZModeTable; + J3DZModeInfo* table = j3dZModeTable; for (int i = 0; i < 2; i++) { for (u32 j = 0; j < 8; j++) { for (int k = 0; k < 2; k++) { u32 idx = j * 2 + i * 16 + k; - table[idx * 3 + 0] = i; - table[idx * 3 + 1] = j; - table[idx * 3 + 2] = k; + table[idx].mCompareEnable = i; + table[idx].mFunc = j; + table[idx].mUpdateEnable = k; } } } diff --git a/src/d/actor/d_a_hot_floor.cpp b/src/d/actor/d_a_hot_floor.cpp index 765c500a6..1f158924c 100644 --- a/src/d/actor/d_a_hot_floor.cpp +++ b/src/d/actor/d_a_hot_floor.cpp @@ -42,7 +42,7 @@ public: /* 0x3D4 */ u32 field_0x3d4; }; -static const char daHot_Floor_c::M_arcname[8] = "Ylesr00"; +const char daHot_Floor_c::M_arcname[8] = "Ylesr00"; /* 00000078-00000108 .text set_mtx_init__13daHot_Floor_cFv */ void daHot_Floor_c::set_mtx_init() { diff --git a/src/d/actor/d_a_obj_mknjd.cpp b/src/d/actor/d_a_obj_mknjd.cpp index b59743771..ca420fa27 100644 --- a/src/d/actor/d_a_obj_mknjd.cpp +++ b/src/d/actor/d_a_obj_mknjd.cpp @@ -178,7 +178,7 @@ namespace daObjMknjD { Mtx daObjMknjD::Act_c::M_tmp_mtx; /* 00000078-0000012C .text nodeCallBackL__FP7J3DNodei */ -static u32 nodeCallBackL(J3DNode* i_node, int i_param2) { +static BOOL nodeCallBackL(J3DNode* i_node, int i_param2) { if (i_param2 == 0) { int jntNo = static_cast(i_node)->getJntNo(); @@ -195,11 +195,11 @@ static u32 nodeCallBackL(J3DNode* i_node, int i_param2) { } } - return 1; + return TRUE; } /* 0000012C-000001E0 .text nodeCallBackR__FP7J3DNodei */ -static u32 nodeCallBackR(J3DNode* i_node, int i_param2) { +static BOOL nodeCallBackR(J3DNode* i_node, int i_param2) { if (i_param2 == 0) { int jntNo = static_cast(i_node)->getJntNo(); @@ -216,11 +216,11 @@ static u32 nodeCallBackR(J3DNode* i_node, int i_param2) { } } - return 1; + return TRUE; } /* 000001E0-000002B0 .text nodeCallBack_Hahen__FP7J3DNodei */ -static s32 nodeCallBack_Hahen(J3DNode* i_node, int i_param2) { +static BOOL nodeCallBack_Hahen(J3DNode* i_node, int i_param2) { if (i_param2 == 0) { int jntNo = static_cast(i_node)->getJntNo(); u16 shardIdx = joint_number_table[jntNo - 1]; @@ -238,7 +238,7 @@ static s32 nodeCallBack_Hahen(J3DNode* i_node, int i_param2) { } } - return 1; + return TRUE; } /* 000002B0-000002D0 .text daObjMknjD_XyCheckCB__FPvi */ @@ -287,10 +287,10 @@ int daObjMknjD::Act_c::CreateHeap() { const char* jntName = nameTable->getName(i); if (strcmp("MknjL", jntName) == 0) { - mMainMdl->getModelData()->getJointNodePointer(i)->setCallBack((J3DNodeCallBack)nodeCallBackL); + mMainMdl->getModelData()->getJointNodePointer(i)->setCallBack(nodeCallBackL); } else if (strcmp("MknjR", jntName) == 0) { - mMainMdl->getModelData()->getJointNodePointer(i)->setCallBack((J3DNodeCallBack)nodeCallBackR); + mMainMdl->getModelData()->getJointNodePointer(i)->setCallBack(nodeCallBackR); } } @@ -304,7 +304,7 @@ int daObjMknjD::Act_c::CreateHeap() { for (u16 j = 0; j < 20; j++) { if (strcmp(daObjMknjD_jointName[j], jntName) == 0) { - mBreakMdl->getModelData()->getJointNodePointer(i)->setCallBack((J3DNodeCallBack)nodeCallBack_Hahen); + mBreakMdl->getModelData()->getJointNodePointer(i)->setCallBack(nodeCallBack_Hahen); joint_number_table[curTblIdx++] = j; break; @@ -1029,20 +1029,20 @@ void daObjMknjD::setMaterial(J3DMaterial* i_mat, u8 i_alpha) { if (i_alpha == 0xFF) { i_mat->setMaterialMode(1); - i_mat->getPEBlock()->getZMode()->setUpdateEnable(1); - i_mat->getPEBlock()->getZMode()->setCompareEnable(1); + i_mat->getZMode()->setUpdateEnable(1); + i_mat->getZMode()->setCompareEnable(1); - i_mat->getPEBlock()->getBlend()->setType(0); + i_mat->getBlend()->setType(0); } else { i_mat->setMaterialMode(1); - i_mat->getPEBlock()->getZMode()->setUpdateEnable(0); - i_mat->getPEBlock()->getZMode()->setCompareEnable(0); + i_mat->getZMode()->setUpdateEnable(0); + i_mat->getZMode()->setCompareEnable(0); - i_mat->getPEBlock()->getBlend()->setType(1); - i_mat->getPEBlock()->getBlend()->setSrcFactor(4); - i_mat->getPEBlock()->getBlend()->setDstFactor(5); + i_mat->getBlend()->setType(1); + i_mat->getBlend()->setSrcFactor(4); + i_mat->getBlend()->setDstFactor(5); } i_mat->getTevKColor(3)->mColor.a = i_alpha; diff --git a/src/d/actor/d_a_vrbox2.cpp b/src/d/actor/d_a_vrbox2.cpp index b4044670b..c38657a86 100644 --- a/src/d/actor/d_a_vrbox2.cpp +++ b/src/d/actor/d_a_vrbox2.cpp @@ -174,7 +174,7 @@ BOOL daVrbox2_color_set(vrbox2_class* i_this) { modelData = i_this->mpBackCloud->getModelData(); mat = modelData->getMaterialNodePointer(0); mat->setCullMode(GX_CULL_NONE); - mat->getPEBlock()->getZMode()->setZModeInfo(l_zmodeInfo); + mat->getZMode()->setZModeInfo(l_zmodeInfo); mat->change(); mtx = mat->getTexMtx(0); @@ -192,7 +192,7 @@ BOOL daVrbox2_color_set(vrbox2_class* i_this) { mat = modelData->getMaterialNodePointer(1); mat->setCullMode(GX_CULL_NONE); - mat->getPEBlock()->getZMode()->setZModeInfo(l_zmodeInfo); + mat->getZMode()->setZModeInfo(l_zmodeInfo); mat->change(); mtx = mat->getTexMtx(0); @@ -205,7 +205,7 @@ BOOL daVrbox2_color_set(vrbox2_class* i_this) { mat = modelData->getMaterialNodePointer(2); mat->setCullMode(GX_CULL_NONE); - mat->getPEBlock()->getZMode()->setZModeInfo(l_zmodeInfo); + mat->getZMode()->setZModeInfo(l_zmodeInfo); mat->change(); mtx = mat->getTexMtx(0); @@ -219,7 +219,7 @@ BOOL daVrbox2_color_set(vrbox2_class* i_this) { if (i_this->mpKasumiMae != NULL) { mat = i_this->mpKasumiMae->getModelData()->getMaterialNodePointer(0); - mat->getPEBlock()->getZMode()->setZModeInfo(l_zmodeInfo); + mat->getZMode()->setZModeInfo(l_zmodeInfo); mat->change(); c0.r = g_env_light.mVrKasumiMaeColor.r; @@ -235,7 +235,7 @@ BOOL daVrbox2_color_set(vrbox2_class* i_this) { if (i_this->mpUsoUmi != NULL) { mat = i_this->mpUsoUmi->getModelData()->getMaterialNodePointer(0); - mat->getPEBlock()->getZMode()->setZModeInfo(l_zmodeInfo); + mat->getZMode()->setZModeInfo(l_zmodeInfo); mat->change(); k0.r = g_env_light.mVrUsoUmiColor.r; diff --git a/src/d/d_shop.cpp b/src/d/d_shop.cpp index 91c64ff82..bea516211 100644 --- a/src/d/d_shop.cpp +++ b/src/d/d_shop.cpp @@ -1399,10 +1399,11 @@ u8 dShop_BoughtErrorStatus(ShopItems_c* shopItems, int param_2, int param_3) { /* 800606A8-80060830 .text __ct__12ShopCursor_cFP12J3DModelDataP15J3DAnmTevRegKeyf */ ShopCursor_c::ShopCursor_c(J3DModelData* modelData, J3DAnmTevRegKey* brkData, f32 param_2) { - static J3DZModeInfo ZModeInfo = {GX_TRUE, GX_ALWAYS, GX_TRUE}; + // TODO: this should be a J3DZModeInfo, but that's 3 bytes when inside arrays, while this is supposed to be 4 bytes, with 1-byte alignment. + static u8 ZModeInfo[4] = {GX_TRUE, GX_ALWAYS, GX_TRUE}; for (u16 i = 0; i < modelData->getMaterialNum(); i++) { J3DMaterial* mat = modelData->getMaterialNodePointer(i); - mat->getPEBlock()->getZMode()->setZModeInfo(ZModeInfo); + mat->getZMode()->setZModeInfo(*(J3DZModeInfo*)&ZModeInfo); } for (int i = 0; i < (int)ARRAY_SIZE(mpModels); i++) {