mirror of https://github.com/zeldaret/tp
Fix const loop invariant issues (#2921)
* Fix const loop invariant issues by defining explicit operator= for structs * Fix J2DMatBlock weak func order
This commit is contained in:
parent
136f6b3f40
commit
7ac2c38caf
|
|
@ -691,7 +691,7 @@ config.libs = [
|
|||
Object(MatchingFor(ALL_GCN), "d/d_a_horse_static.cpp"),
|
||||
Object(MatchingFor(ALL_GCN), "d/d_demo.cpp"),
|
||||
Object(MatchingFor(ALL_GCN, "Shield"), "d/d_door_param2.cpp"), # debug weak func order
|
||||
Object(NonMatching, "d/d_resorce.cpp"),
|
||||
Object(MatchingFor(ALL_GCN), "d/d_resorce.cpp"),
|
||||
Object(MatchingFor(ALL_GCN), "d/d_map_path.cpp"),
|
||||
Object(MatchingFor(ALL_GCN), "d/d_map_path_fmap.cpp"),
|
||||
Object(MatchingFor(ALL_GCN), "d/d_map_path_dmap.cpp"),
|
||||
|
|
@ -1209,7 +1209,7 @@ config.libs = [
|
|||
Object(MatchingFor(ALL_GCN), "JSystem/J2DGraph/J2DOrthoGraph.cpp"),
|
||||
Object(MatchingFor(ALL_GCN), "JSystem/J2DGraph/J2DTevs.cpp"),
|
||||
Object(Equivalent, "JSystem/J2DGraph/J2DMaterial.cpp"), # weak func order
|
||||
Object(NonMatching, "JSystem/J2DGraph/J2DMatBlock.cpp"), # weak func order (J3DTevBlock)
|
||||
Object(MatchingFor(ALL_GCN), "JSystem/J2DGraph/J2DMatBlock.cpp"),
|
||||
Object(MatchingFor(ALL_GCN), "JSystem/J2DGraph/J2DMaterialFactory.cpp"),
|
||||
Object(MatchingFor(ALL_GCN), "JSystem/J2DGraph/J2DPrint.cpp"),
|
||||
Object(MatchingFor(ALL_GCN), "JSystem/J2DGraph/J2DPane.cpp"),
|
||||
|
|
@ -1238,7 +1238,7 @@ config.libs = [
|
|||
Object(MatchingFor(ALL_GCN, "ShieldD"), "JSystem/J3DGraphBase/J3DShapeDraw.cpp"),
|
||||
Object(MatchingFor(ALL_GCN), "JSystem/J3DGraphBase/J3DShape.cpp"),
|
||||
Object(MatchingFor(ALL_GCN), "JSystem/J3DGraphBase/J3DMaterial.cpp"),
|
||||
Object(Equivalent, "JSystem/J3DGraphBase/J3DMatBlock.cpp"), # virtual function order
|
||||
Object(Equivalent, "JSystem/J3DGraphBase/J3DMatBlock.cpp"), # weak func order (J3DTevBlock)
|
||||
Object(MatchingFor(ALL_GCN), "JSystem/J3DGraphBase/J3DTevs.cpp"),
|
||||
Object(MatchingFor(ALL_GCN), "JSystem/J3DGraphBase/J3DDrawBuffer.cpp"),
|
||||
Object(MatchingFor(ALL_GCN), "JSystem/J3DGraphBase/J3DStruct.cpp"),
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <dolphin/gx.h>
|
||||
#include "dolphin/mtx.h"
|
||||
#include "global.h"
|
||||
|
||||
/**
|
||||
* @ingroup jsystem-j2d
|
||||
|
|
@ -213,6 +214,19 @@ struct J2DIndTevStageInfo {
|
|||
/* 0x9 */ u8 field_0x9;
|
||||
/* 0xa */ u8 field_0xa;
|
||||
/* 0xb */ u8 field_0xb;
|
||||
|
||||
J2DIndTevStageInfo& operator=(const J2DIndTevStageInfo& other) {
|
||||
mIndStage = other.mIndStage;
|
||||
mIndFormat = other.mIndFormat;
|
||||
mBiasSel = other.mBiasSel;
|
||||
mMtxSel = other.mMtxSel;
|
||||
mWrapS = other.mWrapS;
|
||||
mWrapT = other.mWrapT;
|
||||
mPrev = other.mPrev;
|
||||
mLod = other.mLod;
|
||||
mAlphaSel = other.mAlphaSel;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
inline u32 J2DCalcIndTevStage(J2DIndTevStageInfo info) {
|
||||
|
|
@ -264,9 +278,9 @@ struct J2DTexCoordInfo {
|
|||
u8 padding; // ?
|
||||
|
||||
J2DTexCoordInfo& operator=(const J2DTexCoordInfo& other) {
|
||||
this->mTexGenType = other.mTexGenType;
|
||||
this->mTexGenSrc = other.mTexGenSrc;
|
||||
this->mTexGenMtx = other.mTexGenMtx;
|
||||
mTexGenType = other.mTexGenType;
|
||||
mTexGenSrc = other.mTexGenSrc;
|
||||
mTexGenMtx = other.mTexGenMtx;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
|
@ -386,9 +400,20 @@ extern const J2DTevSwapModeInfo j2dDefaultTevSwapMode;
|
|||
*/
|
||||
class J2DTevStage {
|
||||
public:
|
||||
J2DTevStage(J2DTevStageInfo const&);
|
||||
J2DTevStage();
|
||||
void setTevStageInfo(J2DTevStageInfo const&);
|
||||
J2DTevStage(J2DTevStageInfo const& param_0) {
|
||||
setTevStageInfo(param_0);
|
||||
setTevSwapModeInfo(j2dDefaultTevSwapMode);
|
||||
}
|
||||
J2DTevStage() {
|
||||
setTevStageInfo(j2dDefaultTevStageInfo);
|
||||
setTevSwapModeInfo(j2dDefaultTevSwapMode);
|
||||
}
|
||||
void setTevStageInfo(J2DTevStageInfo const& info) {
|
||||
setColorABCD(info.mColorA, info.mColorB, info.mColorC, info.mColorD);
|
||||
setTevColorOp(info.mCOp, info.mCBias, info.mCScale, info.mCClamp, info.mCReg);
|
||||
setAlphaABCD(info.mAlphaA, info.mAlphaB, info.mAlphaC, info.mAlphaD);
|
||||
setTevAlphaOp(info.mAOp, info.mABias, info.mAScale, info.mAClamp, info.mAReg);
|
||||
}
|
||||
|
||||
void setStageNo(u32 param_0) {
|
||||
field_0x0 = (param_0 << 1) + 0xc0;
|
||||
|
|
@ -522,6 +547,14 @@ struct J2DTevSwapModeTableInfo {
|
|||
/* 0x1 */ u8 field_0x1;
|
||||
/* 0x2 */ u8 field_0x2;
|
||||
/* 0x3 */ u8 field_0x3;
|
||||
|
||||
J2DTevSwapModeTableInfo& operator=(const J2DTevSwapModeTableInfo& other) {
|
||||
field_0x0 = other.field_0x0;
|
||||
field_0x1 = other.field_0x1;
|
||||
field_0x2 = other.field_0x2;
|
||||
field_0x3 = other.field_0x3;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
inline u8 J2DCalcTevSwapTable(u8 param_0, u8 param_1, u8 param_2, u8 param_3) {
|
||||
|
|
@ -564,6 +597,14 @@ struct J2DColorChanInfo {
|
|||
/* 0x0 */ u8 field_0x1;
|
||||
/* 0x0 */ u8 field_0x2;
|
||||
/* 0x0 */ u8 field_0x3;
|
||||
|
||||
J2DColorChanInfo& operator=(const J2DColorChanInfo& other) {
|
||||
field_0x0 = other.field_0x0;
|
||||
field_0x1 = other.field_0x1;
|
||||
field_0x2 = other.field_0x2;
|
||||
field_0x3 = other.field_0x3;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
inline u16 J2DCalcColorChanID(u8 param_0) { return param_0; }
|
||||
|
|
|
|||
|
|
@ -1543,6 +1543,15 @@ struct J3DAlphaCompInfo {
|
|||
/* 0x5 */ u8 field_0x5;
|
||||
/* 0x6 */ u8 field_0x6;
|
||||
/* 0x7 */ u8 field_0x7;
|
||||
|
||||
J3DAlphaCompInfo& operator=(const J3DAlphaCompInfo& other) {
|
||||
mComp0 = other.mComp0;
|
||||
mRef0 = other.mRef0;
|
||||
mOp = other.mOp;
|
||||
mComp1 = other.mComp1;
|
||||
mRef1 = other.mRef1;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
extern const u16 j3dDefaultAlphaCmpID;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "JSystem/J3DGraphBase/J3DStruct.h"
|
||||
#include "JSystem/J3DAssert.h"
|
||||
#include "JSystem/JUtility/JUTTexture.h"
|
||||
#include "global.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
|
|
@ -79,6 +80,14 @@ struct J3DTexCoordInfo {
|
|||
/* 0x1 */ u8 mTexGenSrc;
|
||||
/* 0x2 */ u8 mTexGenMtx;
|
||||
/* 0x3 */ u8 pad;
|
||||
|
||||
J3DTexCoordInfo& operator=(const J3DTexCoordInfo& other) {
|
||||
mTexGenType = other.mTexGenType;
|
||||
mTexGenSrc = other.mTexGenSrc;
|
||||
mTexGenMtx = other.mTexGenMtx;
|
||||
pad = other.pad;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
extern J3DTexCoordInfo const j3dDefaultTexCoordInfo[8];
|
||||
|
|
@ -108,7 +117,7 @@ struct J3DTexCoord : public J3DTexCoordInfo {
|
|||
void setTexMtxReg(u16 reg) { mTexMtxReg = reg; }
|
||||
J3DTexCoord& operator=(const J3DTexCoord& other) {
|
||||
// Fake match (__memcpy or = doesn't match)
|
||||
*(uintptr_t*)this = *(uintptr_t*)&other;
|
||||
*(u32*)this = *(u32*)&other;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
#include "JSystem/JUtility/JUTTexture.h"
|
||||
#include "dolphin/gx.h"
|
||||
|
||||
// NONMATCHING - instruction order. matches if const is removed from j2dDefaultColorChanInfo, but then it's in the wrong section
|
||||
void J2DColorBlock::initialize() {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
mMatColor[i] = JUtility::TColor(j2dDefaultColInfo);
|
||||
|
|
@ -848,7 +847,6 @@ J2DTevBlock4::~J2DTevBlock4() {
|
|||
}
|
||||
}
|
||||
|
||||
// NONMATCHING - inlines
|
||||
void J2DTevBlock4::initialize() {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
mTexNo[i] = -1;
|
||||
|
|
@ -1292,7 +1290,6 @@ J2DTevBlock8::~J2DTevBlock8() {
|
|||
}
|
||||
}
|
||||
|
||||
// NONMATCHING - inlines
|
||||
void J2DTevBlock8::initialize() {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
mTexNo[i] = 0xffff;
|
||||
|
|
@ -1732,7 +1729,6 @@ J2DTevBlock16::~J2DTevBlock16() {
|
|||
}
|
||||
}
|
||||
|
||||
// NONMATCHING - inlines
|
||||
void J2DTevBlock16::initialize() {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
mTexNo[i] = 0xffff;
|
||||
|
|
@ -2187,15 +2183,3 @@ void J2DPEBlock::setGX() {
|
|||
GXSetBlendMode(GXBlendMode(mBlend.getType()), GXBlendFactor(mBlend.getSrcFactor()), GXBlendFactor(mBlend.getDstFactor()), GXLogicOp(mBlend.getOp()));
|
||||
GXSetDither(mDither);
|
||||
}
|
||||
|
||||
J2DTevStage::J2DTevStage() {
|
||||
setTevStageInfo(j2dDefaultTevStageInfo);
|
||||
setTevSwapModeInfo(j2dDefaultTevSwapMode);
|
||||
}
|
||||
|
||||
void J2DTevStage::setTevStageInfo(J2DTevStageInfo const& info) {
|
||||
setColorABCD(info.mColorA, info.mColorB, info.mColorC, info.mColorD);
|
||||
setTevColorOp(info.mCOp, info.mCBias, info.mCScale, info.mCClamp, info.mCReg);
|
||||
setAlphaABCD(info.mAlphaA, info.mAlphaB, info.mAlphaC, info.mAlphaD);
|
||||
setTevAlphaOp(info.mAOp, info.mABias, info.mAScale, info.mAClamp, info.mAReg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -396,8 +396,3 @@ u8 J2DMaterialFactory::newDither(int param_0) const {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
J2DTevStage::J2DTevStage(J2DTevStageInfo const& param_0) {
|
||||
setTevStageInfo(param_0);
|
||||
setTevSwapModeInfo(j2dDefaultTevSwapMode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11652,11 +11652,11 @@ static J3DZModeInfo l_zmodeUpEnable = {1, 3, 1};
|
|||
static J3DZModeInfo l_zmodeUpDisable = {1, 3, 0};
|
||||
|
||||
static J3DAlphaCompInfo l_alphaCompInfoOPA = {
|
||||
0x07, 0x00, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0x07, 0x00, 0x01, 0x07, 0x00,
|
||||
};
|
||||
|
||||
static J3DAlphaCompInfo l_alphaCompInfo = {
|
||||
0x04, 0x80, 0x00, 0x03, 0xFF, 0x00, 0x00, 0x00,
|
||||
0x04, 0x80, 0x00, 0x03, 0xFF,
|
||||
};
|
||||
|
||||
void dKy_bg_MAxx_proc(void* bg_model_p) {
|
||||
|
|
|
|||
|
|
@ -116,8 +116,6 @@ static const J3DTexMtxInfo l_texMtxInfo = {
|
|||
},
|
||||
};
|
||||
|
||||
// NONMATCHING l_alphaCompInfo needs to be placed in .sdata2, but the function breaks if it is declared const
|
||||
// Also see J3DAlphaComp::setAlphaCompInfo in J3DMatBlock.h
|
||||
static void addWarpMaterial(J3DModelData* i_modelData) {
|
||||
static J3DTevStageInfo const l_tevStageInfo = {
|
||||
0x05, 0x0F, 0x08, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x01, 0x00,
|
||||
|
|
@ -125,6 +123,7 @@ static void addWarpMaterial(J3DModelData* i_modelData) {
|
|||
};
|
||||
static J3DTexCoordInfo l_texCoordInfo = {0x00, 0x00, 0x27};
|
||||
static J3DTevOrderInfo l_tevOrderInfo = {0x00, 0x03, 0xFF, 0x00};
|
||||
static J3DAlphaCompInfo const l_alphaCompInfo = {0x04, 0x80, 0x00, 0x03, 0xFF};
|
||||
|
||||
ResTIMG* resTimg = (ResTIMG*)dComIfG_getObjectRes("Always", 0x5d);
|
||||
JUT_ASSERT(279, resTimg != NULL);
|
||||
|
|
@ -166,7 +165,6 @@ static void addWarpMaterial(J3DModelData* i_modelData) {
|
|||
|
||||
J3DPEBlock* peBlock = material->getPEBlock();
|
||||
J3DAlphaComp* alphaComp = peBlock->getAlphaComp();
|
||||
static J3DAlphaCompInfo l_alphaCompInfo = {0x04, 0x80, 0x00, 0x03, 0xFF, 0, 0, 0};
|
||||
alphaComp->setAlphaCompInfo(l_alphaCompInfo);
|
||||
peBlock->setZCompLoc((u8)0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue