From 48f1d47690d0a43a77f7ae210b0cf21a6bc835bc Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Sun, 21 Dec 2025 07:13:21 -0500 Subject: [PATCH] Work on weak order (#2979) * JAUSectionHeap OK * Slightly improve d_camera weak func order (12 -> 10) * Minor d_a_alink fixes * weak_order_diff.py: Change to take source file as cli argument instead of .o file For cli autocompletion to work. * Reorganize J3D structs (no change in weak order) --- configure.py | 2 +- include/JSystem/J3DGraphBase/J3DMatBlock.h | 235 ++++-------------- include/JSystem/J3DGraphBase/J3DStruct.h | 216 ++++++++++++++-- include/JSystem/J3DGraphBase/J3DTevs.h | 152 +++++------ include/JSystem/J3DGraphBase/J3DTexture.h | 16 -- include/JSystem/JAudio2/JAUSectionHeap.h | 1 - include/d/actor/d_a_alink.h | 2 +- include/d/d_bg_s_sph_chk.h | 1 - src/JSystem/J3DGraphBase/J3DMatBlock.cpp | 10 - src/JSystem/JAudio2/JAUSectionHeap.cpp | 1 - .../MSL/MSL_C++/MSL_Common/Include/bitset.h | 4 +- src/d/actor/d_a_alink.cpp | 14 +- src/d/actor/d_a_alink_link.inc | 2 +- src/d/actor/d_a_alink_wolf.inc | 5 - tools/utilities/weak_order_diff.py | 13 +- 15 files changed, 332 insertions(+), 342 deletions(-) diff --git a/configure.py b/configure.py index a379aecd88d..5904a18b88b 100755 --- a/configure.py +++ b/configure.py @@ -1090,7 +1090,7 @@ config.libs = [ Object(MatchingFor(ALL_GCN, "ShieldD"), "JSystem/JAudio2/JAUBankTable.cpp"), Object(MatchingFor(ALL_GCN), "JSystem/JAudio2/JAUClusterSound.cpp"), Object(MatchingFor(ALL_GCN), "JSystem/JAudio2/JAUInitializer.cpp"), - Object(Equivalent, "JSystem/JAudio2/JAUSectionHeap.cpp"), # weak func order + Object(MatchingFor(ALL_GCN), "JSystem/JAudio2/JAUSectionHeap.cpp"), Object(MatchingFor(ALL_GCN), "JSystem/JAudio2/JAUSeqCollection.cpp"), Object(MatchingFor(ALL_GCN), "JSystem/JAudio2/JAUSeqDataBlockMgr.cpp"), Object(MatchingFor(ALL_GCN), "JSystem/JAudio2/JAUSoundAnimator.cpp"), diff --git a/include/JSystem/J3DGraphBase/J3DMatBlock.h b/include/JSystem/J3DGraphBase/J3DMatBlock.h index 4b082e193e4..256e95deb50 100644 --- a/include/JSystem/J3DGraphBase/J3DMatBlock.h +++ b/include/JSystem/J3DGraphBase/J3DMatBlock.h @@ -63,53 +63,6 @@ struct J3DGXColor : public GXColor { } }; -extern const J3DNBTScaleInfo j3dDefaultNBTScaleInfo; - -/** - * @ingroup jsystem-j3d - * - */ -struct J3DNBTScale : public J3DNBTScaleInfo { - J3DNBTScale() { - mbHasScale = j3dDefaultNBTScaleInfo.mbHasScale; - mScale.x = j3dDefaultNBTScaleInfo.mScale.x; - mScale.y = j3dDefaultNBTScaleInfo.mScale.y; - mScale.z = j3dDefaultNBTScaleInfo.mScale.z; - } - - J3DNBTScale(J3DNBTScaleInfo const& info) { - mbHasScale = info.mbHasScale; - mScale.x = info.mScale.x; - mScale.y = info.mScale.y; - mScale.z = info.mScale.z; - } - - Vec* getScale() { return &mScale; } -}; - -/** - * @ingroup jsystem-j3d - * - */ -struct J3DColorChanInfo { - /* 0x0 */ u8 mEnable; - /* 0x1 */ u8 mMatSrc; - /* 0x2 */ u8 mLightMask; - /* 0x3 */ u8 mDiffuseFn; - /* 0x4 */ u8 mAttnFn; - /* 0x5 */ u8 mAmbSrc; - /* 0x6 */ u8 pad[2]; -}; - -extern const J3DColorChanInfo j3dDefaultColorChanInfo; - -static inline u32 setChanCtrlMacro(u8 enable, GXColorSrc ambSrc, GXColorSrc matSrc, u32 lightMask, - GXDiffuseFn diffuseFn, GXAttnFn attnFn) { - return matSrc << 0 | enable << 1 | (lightMask & 0x0F) << 2 | ambSrc << 6 | - ((attnFn == GX_AF_SPEC) ? GX_DF_NONE : diffuseFn) << 7 | (attnFn != GX_AF_NONE) << 9 | - (attnFn != GX_AF_SPEC) << 10 | (lightMask >> 4 & 0x0F) << 11; -} - inline u16 calcColorChanID(u16 enable, u8 matSrc, u8 lightMask, u8 diffuseFn, u8 attnFn, u8 ambSrc) { u32 reg = 0; reg = (reg & ~0x0002) | enable << 1; @@ -129,6 +82,13 @@ inline u16 calcColorChanID(u16 enable, u8 matSrc, u8 lightMask, u8 diffuseFn, u8 return reg; } +static inline u32 setChanCtrlMacro(u8 enable, GXColorSrc ambSrc, GXColorSrc matSrc, u32 lightMask, + GXDiffuseFn diffuseFn, GXAttnFn attnFn) { + return matSrc << 0 | enable << 1 | (lightMask & 0x0F) << 2 | ambSrc << 6 | + ((attnFn == GX_AF_SPEC) ? GX_DF_NONE : diffuseFn) << 7 | (attnFn != GX_AF_NONE) << 9 | + (attnFn != GX_AF_SPEC) << 10 | (lightMask >> 4 & 0x0F) << 11; +} + #ifdef DECOMPCTX // Hack to mitigate fake mismatches when building from decompctx output - // see comment in sqrtf in math.h @@ -139,7 +99,8 @@ static u8 AttnArr[] = {2, 0, 2, 1}; * @ingroup jsystem-j3d * */ -struct J3DColorChan { +class J3DColorChan { +public: J3DColorChan() { setColorChanInfo(j3dDefaultColorChanInfo); } @@ -438,6 +399,16 @@ public: /* 0x48 */ u32 mColorChanOffset; }; // Size: 0x4C +/** + * @ingroup jsystem-j3d + * + */ +class J3DColorBlockNull : public J3DColorBlock { +public: + virtual u32 getType() { return 'CLNL'; } + virtual ~J3DColorBlockNull() {} +}; + /** * @ingroup jsystem-j3d * @@ -471,20 +442,6 @@ public: virtual ~J3DTexGenBlock() {} }; -struct J3DTexGenBlockNull : public J3DTexGenBlock { - virtual void calc(f32 const (*)[4]) {} - virtual void calcWithoutViewMtx(f32 const (*)[4]) {} - virtual void calcPostTexMtx(f32 const (*)[4]) {} - virtual void calcPostTexMtxWithoutViewMtx(f32 const (*)[4]) {} - virtual void load() {} - virtual void patch() {} - virtual void diff(u32) {} - virtual void diffTexMtx() {} - virtual void diffTexGen() {} - virtual u32 getType() { return 'TGNL'; } - virtual ~J3DTexGenBlockNull() {} -}; - /** * @ingroup jsystem-j3d * @@ -595,6 +552,21 @@ public: /* 0x5C */ J3DNBTScale mNBTScale; }; // Size: 0x6C +class J3DTexGenBlockNull : public J3DTexGenBlock { +public: + virtual void calc(f32 const (*)[4]) {} + virtual void calcWithoutViewMtx(f32 const (*)[4]) {} + virtual void calcPostTexMtx(f32 const (*)[4]) {} + virtual void calcPostTexMtxWithoutViewMtx(f32 const (*)[4]) {} + virtual void load() {} + virtual void patch() {} + virtual void diff(u32) {} + virtual void diffTexMtx() {} + virtual void diffTexGen() {} + virtual u32 getType() { return 'TGNL'; } + virtual ~J3DTexGenBlockNull() {} +}; + /** * @ingroup jsystem-j3d * @@ -604,11 +576,11 @@ public: virtual void reset(J3DTevBlock*) {} virtual void load() {} virtual void diff(u32); - virtual void diffTexNo(); - virtual void diffTevReg(); - virtual void diffTexCoordScale(); - virtual void diffTevStage(); - virtual void diffTevStageIndirect(); + virtual void diffTexNo() {} + virtual void diffTevReg() {} + virtual void diffTexCoordScale() {} + virtual void diffTevStage() {} + virtual void diffTevStageIndirect() {} virtual void patch() {} virtual void patchTexNo() {} virtual void patchTevReg() {} @@ -1436,23 +1408,10 @@ public: /* 0x170 */ u32 mTevRegOffset; }; // Size: 0x174 -extern const u16 j3dDefaultZModeID; - inline u16 calcZModeID(u8 param_0, u8 param_1, u8 param_2) { return param_1 * 2 + param_0 * 0x10 + param_2; } -/** - * @ingroup jsystem-j3d - * - */ -struct J3DZModeInfo { - /* 0x0 */ u8 field_0x0; - /* 0x1 */ u8 field_0x1; - /* 0x2 */ u8 field_0x2; - /* 0x3 */ u8 pad; -}; - extern u8 j3dZModeTable[96]; /** @@ -1499,22 +1458,6 @@ struct J3DZMode { /* 0x0 */ u16 mZModeID; }; -/** - * @ingroup jsystem-j3d - * - */ -struct J3DBlendInfo { - void operator=(J3DBlendInfo const& other) { - __memcpy(this, &other, sizeof(J3DBlendInfo)); - } - /* 0x0 */ u8 mType; - /* 0x1 */ u8 mSrcFactor; - /* 0x2 */ u8 mDstFactor; - /* 0x3 */ u8 mOp; -}; - -extern const J3DBlendInfo j3dDefaultBlendInfo; - /** * @ingroup jsystem-j3d * @@ -1543,8 +1486,6 @@ struct J3DBlend : public J3DBlendInfo { void setBlendInfo(const J3DBlendInfo& i_blendInfo) { *static_cast(this) = i_blendInfo; } }; -extern const J3DFogInfo j3dDefaultFogInfo; - /** * @ingroup jsystem-j3d * @@ -1562,32 +1503,6 @@ struct J3DFog : public J3DFogInfo { } }; -/** - * @ingroup jsystem-j3d - * - */ -struct J3DAlphaCompInfo { - /* 0x0 */ u8 mComp0; - /* 0x1 */ u8 mRef0; - /* 0x2 */ u8 mOp; - /* 0x3 */ u8 mComp1; - /* 0x4 */ u8 mRef1; - /* 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; - inline u16 calcAlphaCmpID(u8 comp0, u8 op, u8 comp1) { return (comp0 << 5) + (op << 3) + (comp1); } @@ -1643,23 +1558,6 @@ struct J3DAlphaComp { /* 0x03 */ u8 mRef1; }; // Size: 0x4 -/** - * @ingroup jsystem-j3d - * - */ -struct J3DIndTexOrderInfo { - /* 0x0 */ u8 mCoord; - /* 0x1 */ u8 mMap; - /* 0x2 */ u8 field_0x2; - /* 0x3 */ u8 field_0x3; - - void operator=(J3DIndTexOrderInfo const& other) { - __memcpy(this, &other, sizeof(J3DIndTexOrderInfo)); - } -}; // Size: 0x04 - -extern const J3DIndTexOrderInfo j3dDefaultIndTexOrderNull; - /** * @ingroup jsystem-j3d * @@ -1684,8 +1582,6 @@ struct J3DIndTexOrder : public J3DIndTexOrderInfo { u8 getCoord() const { return (GXTexCoordID)mCoord; } }; // Size: 0x04 -extern J3DIndTexMtxInfo const j3dDefaultIndTexMtxInfo; - /** * @ingroup jsystem-j3d * @@ -1702,24 +1598,6 @@ struct J3DIndTexMtx : public J3DIndTexMtxInfo { } }; // Size: 0x1C -/** - * @ingroup jsystem-j3d - * - */ -struct J3DIndTexCoordScaleInfo { - /* 0x0 */ u8 mScaleS; - /* 0x1 */ u8 mScaleT; - /* 0x2 */ u8 field_0x2; - /* 0x3 */ u8 field_0x3; - - J3DIndTexCoordScaleInfo& operator=(const J3DIndTexCoordScaleInfo& other) { - __memcpy(this, &other, sizeof(J3DIndTexCoordScaleInfo)); - return *this; - } -}; // Size: 0x4 - -extern const J3DIndTexCoordScaleInfo j3dDefaultIndTexCoordScaleInfo; - /** * @ingroup jsystem-j3d * @@ -1774,19 +1652,6 @@ public: virtual ~J3DIndBlock() {} }; -/** - * @ingroup jsystem-j3d - * - */ -class J3DIndBlockNull : public J3DIndBlock { -public: - virtual void diff(u32) {} - virtual void load() {} - virtual void reset(J3DIndBlock*) {} - virtual u32 getType() { return 'IBLN'; } - virtual ~J3DIndBlockNull() {} -}; - /** * @ingroup jsystem-j3d * @@ -1852,6 +1717,19 @@ public: /* 0x6C */ J3DIndTexCoordScale mIndTexCoordScale[4]; }; // Size: 0x7C +/** + * @ingroup jsystem-j3d + * + */ +class J3DIndBlockNull : public J3DIndBlock { +public: + virtual void diff(u32) {} + virtual void load() {} + virtual void reset(J3DIndBlock*) {} + virtual u32 getType() { return 'IBLN'; } + virtual ~J3DIndBlockNull() {} +}; + /** * @ingroup jsystem-j3d * @@ -2056,13 +1934,4 @@ public: /* 0x3C */ u32 mFogOffset; }; // Size: 0x40 -/** - * @ingroup jsystem-j3d - * - */ -struct J3DColorBlockNull : public J3DColorBlock { - virtual u32 getType() { return 'CLNL'; } - virtual ~J3DColorBlockNull() {} -}; - #endif /* J3DMATBLOCK_H */ diff --git a/include/JSystem/J3DGraphBase/J3DStruct.h b/include/JSystem/J3DGraphBase/J3DStruct.h index 24fdb5c265f..3f9bafe12ce 100644 --- a/include/JSystem/J3DGraphBase/J3DStruct.h +++ b/include/JSystem/J3DGraphBase/J3DStruct.h @@ -4,13 +4,13 @@ #include #include "dolphin/mtx.h" #include "dolphin/mtx.h" +#include "global.h" /** * @ingroup jsystem-j3d * */ -class J3DLightInfo { -public: +struct J3DLightInfo { J3DLightInfo& operator=(J3DLightInfo const&); /* 0x00 */ Vec mLightPosition; @@ -20,27 +20,6 @@ public: /* 0x28 */ Vec mDistAtten; }; // Size = 0x34 -extern "C" extern J3DLightInfo const j3dDefaultLightInfo; - -/** - * @ingroup jsystem-j3d - * - */ -class J3DLightObj { -public: - J3DLightObj() { mInfo = j3dDefaultLightInfo; } - void load(u32) const; - - J3DLightInfo* getLightInfo() { return &mInfo; } - J3DLightObj& operator=(J3DLightObj const& other) { - mInfo = other.mInfo; - return *this; - } - - /* 0x00 */ J3DLightInfo mInfo; - /* 0x34 */ GXLightObj mLightObj; -}; // Size = 0x74 - /** * @ingroup jsystem-j3d * @@ -146,4 +125,195 @@ struct J3DNBTScaleInfo { /* 0x4 */ Vec mScale; }; // Size: 0x10 +/** + * @ingroup jsystem-j3d + * + */ +struct J3DIndTexOrderInfo { + /* 0x0 */ u8 mCoord; + /* 0x1 */ u8 mMap; + /* 0x2 */ u8 field_0x2; + /* 0x3 */ u8 field_0x3; + + void operator=(J3DIndTexOrderInfo const& other) { + __memcpy(this, &other, sizeof(J3DIndTexOrderInfo)); + } +}; // Size: 0x04 + +/** + * @ingroup jsystem-j3d + * + */ +struct J3DTevSwapModeInfo { + /* 0x0 */ u8 mRasSel; + /* 0x1 */ u8 mTexSel; + /* 0x2 */ u8 field_0x2; + /* 0x3 */ u8 field_0x3; +}; // Size: 0x4 + +/** + * @ingroup jsystem-j3d + * + */ +struct J3DTevSwapModeTableInfo { + /* 0x0 */ u8 field_0x0; + /* 0x1 */ u8 field_0x1; + /* 0x2 */ u8 field_0x2; + /* 0x3 */ u8 field_0x3; +}; // Size: 0x4 + +/** + * @ingroup jsystem-j3d + * + */ +struct J3DTevStageInfo { + /* 0x0 */ u8 field_0x0; + /* 0x1 */ u8 mTevColorOp; + /* 0x2 */ u8 mTevColorAB; + /* 0x3 */ u8 mTevColorCD; + /* 0x4 */ u8 field_0x4; + /* 0x5 */ u8 mTevAlphaOp; + /* 0x6 */ u8 mTevAlphaAB; + /* 0x7 */ u8 mTevSwapModeInfo; + /* 0x8 */ u8 field_0x8; + /* 0x8 */ u8 field_0x9; + /* 0x8 */ u8 field_0xa; + /* 0x8 */ u8 field_0xb; + /* 0x8 */ u8 field_0xc; + /* 0x8 */ u8 field_0xd; + /* 0x8 */ u8 field_0xe; + /* 0x8 */ u8 field_0xf; + /* 0x8 */ u8 field_0x10; + /* 0x8 */ u8 field_0x11; + /* 0x8 */ u8 field_0x12; + /* 0x8 */ u8 field_0x13; +}; + +/** + * @ingroup jsystem-j3d + * + */ +struct J3DIndTevStageInfo { + /* 0x0 */ u8 mIndStage; + /* 0x1 */ u8 mIndFormat; + /* 0x2 */ u8 mBiasSel; + /* 0x3 */ u8 mMtxSel; + /* 0x4 */ u8 mWrapS; + /* 0x5 */ u8 mWrapT; + /* 0x6 */ u8 mPrev; + /* 0x7 */ u8 mLod; + /* 0x8 */ u8 mAlphaSel; + /* 0x9 */ u8 pad[3]; +}; + +/** + * @ingroup jsystem-j3d + * + */ +struct J3DTexCoordInfo { + /* 0x0 */ u8 mTexGenType; + /* 0x1 */ u8 mTexGenSrc; + /* 0x2 */ u8 mTexGenMtx; + /* 0x3 */ u8 pad; + + J3DTexCoordInfo& operator=(const J3DTexCoordInfo& other) { + __memcpy(this, &other, sizeof(J3DTexCoordInfo)); + return *this; + } +}; + +/** + * @ingroup jsystem-j3d + * + */ +struct J3DIndTexCoordScaleInfo { + /* 0x0 */ u8 mScaleS; + /* 0x1 */ u8 mScaleT; + /* 0x2 */ u8 field_0x2; + /* 0x3 */ u8 field_0x3; + + J3DIndTexCoordScaleInfo& operator=(const J3DIndTexCoordScaleInfo& other) { + __memcpy(this, &other, sizeof(J3DIndTexCoordScaleInfo)); + return *this; + } +}; // Size: 0x4 + +/** + * @ingroup jsystem-j3d + * + */ +struct J3DBlendInfo { + void operator=(J3DBlendInfo const& other) { + __memcpy(this, &other, sizeof(J3DBlendInfo)); + } + /* 0x0 */ u8 mType; + /* 0x1 */ u8 mSrcFactor; + /* 0x2 */ u8 mDstFactor; + /* 0x3 */ u8 mOp; +}; + +/** + * @ingroup jsystem-j3d + * + */ +struct J3DTevOrderInfo { + void operator=(const J3DTevOrderInfo& other) { + *(u32*) this = *(u32*)&other; + } + + /* 0x0 */ u8 mTexCoord; + /* 0x1 */ u8 mTexMap; + /* 0x2 */ u8 mColorChan; + /* 0x3 */ u8 field_0x3; // Maybe padding +}; + +/** + * @ingroup jsystem-j3d + * + */ +struct J3DColorChanInfo { + /* 0x0 */ u8 mEnable; + /* 0x1 */ u8 mMatSrc; + /* 0x2 */ u8 mLightMask; + /* 0x3 */ u8 mDiffuseFn; + /* 0x4 */ u8 mAttnFn; + /* 0x5 */ u8 mAmbSrc; + /* 0x6 */ u8 pad[2]; +}; + +/** + * @ingroup jsystem-j3d + * + */ +struct J3DZModeInfo { + /* 0x0 */ u8 field_0x0; + /* 0x1 */ u8 field_0x1; + /* 0x2 */ u8 field_0x2; + /* 0x3 */ u8 pad; +}; + +/** + * @ingroup jsystem-j3d + * + */ +struct J3DAlphaCompInfo { + /* 0x0 */ u8 mComp0; + /* 0x1 */ u8 mRef0; + /* 0x2 */ u8 mOp; + /* 0x3 */ u8 mComp1; + /* 0x4 */ u8 mRef1; + /* 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; + } +}; + #endif /* J3DSTRUCT_H */ diff --git a/include/JSystem/J3DGraphBase/J3DTevs.h b/include/JSystem/J3DGraphBase/J3DTevs.h index 239bd335c53..1f7d6dfa593 100644 --- a/include/JSystem/J3DGraphBase/J3DTevs.h +++ b/include/JSystem/J3DGraphBase/J3DTevs.h @@ -4,61 +4,34 @@ #include "dolphin/types.h" #include #include "JSystem/J3DGraphBase/J3DGD.h" +#include "JSystem/J3DGraphBase/J3DStruct.h" -/** - * @ingroup jsystem-j3d - * - */ -struct J3DTevStageInfo { - /* 0x0 */ u8 field_0x0; - /* 0x1 */ u8 mTevColorOp; - /* 0x2 */ u8 mTevColorAB; - /* 0x3 */ u8 mTevColorCD; - /* 0x4 */ u8 field_0x4; - /* 0x5 */ u8 mTevAlphaOp; - /* 0x6 */ u8 mTevAlphaAB; - /* 0x7 */ u8 mTevSwapModeInfo; - /* 0x8 */ u8 field_0x8; - /* 0x8 */ u8 field_0x9; - /* 0x8 */ u8 field_0xa; - /* 0x8 */ u8 field_0xb; - /* 0x8 */ u8 field_0xc; - /* 0x8 */ u8 field_0xd; - /* 0x8 */ u8 field_0xe; - /* 0x8 */ u8 field_0xf; - /* 0x8 */ u8 field_0x10; - /* 0x8 */ u8 field_0x11; - /* 0x8 */ u8 field_0x12; - /* 0x8 */ u8 field_0x13; -}; +extern u8 j3dTevSwapTableTable[1024]; -extern J3DTevStageInfo const j3dDefaultTevStageInfo; - -/** - * @ingroup jsystem-j3d - * - */ -struct J3DTevSwapModeTableInfo { - /* 0x0 */ u8 field_0x0; - /* 0x1 */ u8 field_0x1; - /* 0x2 */ u8 field_0x2; - /* 0x3 */ u8 field_0x3; -}; // Size: 0x4 +extern const J3DLightInfo j3dDefaultLightInfo; +extern const J3DTexCoordInfo j3dDefaultTexCoordInfo[8]; +extern const J3DTexMtxInfo j3dDefaultTexMtxInfo; +extern const J3DIndTexMtxInfo j3dDefaultIndTexMtxInfo; +extern const J3DTevStageInfo j3dDefaultTevStageInfo; +extern const J3DIndTevStageInfo j3dDefaultIndTevStageInfo; +extern const J3DFogInfo j3dDefaultFogInfo; +extern const J3DNBTScaleInfo j3dDefaultNBTScaleInfo; +extern const GXColor j3dDefaultColInfo; +extern const GXColor j3dDefaultAmbInfo; +extern const u8 j3dDefaultColorChanNum; +extern const J3DTevOrderInfo j3dDefaultTevOrderInfoNull; +extern const J3DIndTexOrderInfo j3dDefaultIndTexOrderNull; +extern const GXColorS10 j3dDefaultTevColor; +extern const J3DIndTexCoordScaleInfo j3dDefaultIndTexCoordScaleInfo; +extern const GXColor j3dDefaultTevKColor; +extern const J3DTevSwapModeInfo j3dDefaultTevSwapMode; extern const J3DTevSwapModeTableInfo j3dDefaultTevSwapModeTable; - -/** - * @ingroup jsystem-j3d - * - */ -struct J3DTevSwapModeInfo { - /* 0x0 */ u8 mRasSel; - /* 0x1 */ u8 mTexSel; - /* 0x2 */ u8 field_0x2; - /* 0x3 */ u8 field_0x3; -}; // Size: 0x4 - -extern J3DTevSwapModeInfo const j3dDefaultTevSwapMode; +extern const J3DBlendInfo j3dDefaultBlendInfo; +extern const J3DColorChanInfo j3dDefaultColorChanInfo; +extern const u8 j3dDefaultTevSwapTableID; +extern const u16 j3dDefaultAlphaCmpID; +extern const u16 j3dDefaultZModeID; /** * @ingroup jsystem-j3d @@ -173,25 +146,6 @@ struct J3DTevStage { /* 0x7 */ u8 mTevSwapModeInfo; }; -/** - * @ingroup jsystem-j3d - * - */ -struct J3DIndTevStageInfo { - /* 0x0 */ u8 mIndStage; - /* 0x1 */ u8 mIndFormat; - /* 0x2 */ u8 mBiasSel; - /* 0x3 */ u8 mMtxSel; - /* 0x4 */ u8 mWrapS; - /* 0x5 */ u8 mWrapT; - /* 0x6 */ u8 mPrev; - /* 0x7 */ u8 mLod; - /* 0x8 */ u8 mAlphaSel; - /* 0x9 */ u8 pad[3]; -}; - -extern J3DIndTevStageInfo const j3dDefaultIndTevStageInfo; - /** * @ingroup jsystem-j3d * @@ -237,21 +191,6 @@ struct J3DIndTevStage { /* 0x0 */ u32 mInfo; }; -/** - * @ingroup jsystem-j3d - * - */ -struct J3DTevOrderInfo { - void operator=(const J3DTevOrderInfo& other) { - *(u32*) this = *(u32*)&other; - } - - /* 0x0 */ u8 mTexCoord; - /* 0x1 */ u8 mTexMap; - /* 0x2 */ u8 mColorChan; - /* 0x3 */ u8 field_0x3; // Maybe padding -}; - extern const J3DTevOrderInfo j3dDefaultTevOrderInfoNull; /** @@ -303,6 +242,49 @@ struct J3DTevSwapModeTable { /* 0x0 */ u8 mIdx; }; // Size: 0x1 +/** + * @ingroup jsystem-j3d + * + */ +class J3DLightObj { +public: + J3DLightObj() { mInfo = j3dDefaultLightInfo; } + void load(u32) const; + + J3DLightInfo* getLightInfo() { return &mInfo; } + J3DLightObj& operator=(J3DLightObj const& other) { + mInfo = other.mInfo; + return *this; + } + + /* 0x00 */ J3DLightInfo mInfo; + /* 0x34 */ GXLightObj mLightObj; +}; // Size = 0x74 + +extern const J3DNBTScaleInfo j3dDefaultNBTScaleInfo; + +/** + * @ingroup jsystem-j3d + * + */ +struct J3DNBTScale : public J3DNBTScaleInfo { + J3DNBTScale() { + mbHasScale = j3dDefaultNBTScaleInfo.mbHasScale; + mScale.x = j3dDefaultNBTScaleInfo.mScale.x; + mScale.y = j3dDefaultNBTScaleInfo.mScale.y; + mScale.z = j3dDefaultNBTScaleInfo.mScale.z; + } + + J3DNBTScale(J3DNBTScaleInfo const& info) { + mbHasScale = info.mbHasScale; + mScale.x = info.mScale.x; + mScale.y = info.mScale.y; + mScale.z = info.mScale.z; + } + + Vec* getScale() { return &mScale; } +}; + extern const GXColor j3dDefaultColInfo; extern const GXColor j3dDefaultAmbInfo; extern const GXColorS10 j3dDefaultTevColor; diff --git a/include/JSystem/J3DGraphBase/J3DTexture.h b/include/JSystem/J3DGraphBase/J3DTexture.h index a049f0ba990..0927e08a477 100644 --- a/include/JSystem/J3DGraphBase/J3DTexture.h +++ b/include/JSystem/J3DGraphBase/J3DTexture.h @@ -71,22 +71,6 @@ private: /* 0x64 */ Mtx mMtx; }; // Size: 0x94 -/** - * @ingroup jsystem-j3d - * - */ -struct J3DTexCoordInfo { - /* 0x0 */ u8 mTexGenType; - /* 0x1 */ u8 mTexGenSrc; - /* 0x2 */ u8 mTexGenMtx; - /* 0x3 */ u8 pad; - - J3DTexCoordInfo& operator=(const J3DTexCoordInfo& other) { - __memcpy(this, &other, sizeof(J3DTexCoordInfo)); - return *this; - } -}; - extern J3DTexCoordInfo const j3dDefaultTexCoordInfo[8]; /** diff --git a/include/JSystem/JAudio2/JAUSectionHeap.h b/include/JSystem/JAudio2/JAUSectionHeap.h index 97280f1bf54..21049065f17 100644 --- a/include/JSystem/JAudio2/JAUSectionHeap.h +++ b/include/JSystem/JAudio2/JAUSectionHeap.h @@ -61,7 +61,6 @@ public: JASVoiceBank* newVoiceBank(u32, u32); bool beginNewBankTable(u32, u32); JAUBankTable* endNewBankTable(); - virtual ~JAUSection() {} bool isBuilding() const { return field_0x2c; } bool isOpen() const; diff --git a/include/d/actor/d_a_alink.h b/include/d/actor/d_a_alink.h index 84eb80f610b..ff727effba6 100644 --- a/include/d/actor/d_a_alink.h +++ b/include/d/actor/d_a_alink.h @@ -213,7 +213,7 @@ class daAlinkHIO_data_c : public JORReflexible { public: #if DEBUG daAlinkHIO_data_c(); - ~daAlinkHIO_data_c(); + virtual ~daAlinkHIO_data_c(); void setStructData(char*); void checkDataSize(); diff --git a/include/d/d_bg_s_sph_chk.h b/include/d/d_bg_s_sph_chk.h index 66bb569806e..a7734563c60 100644 --- a/include/d/d_bg_s_sph_chk.h +++ b/include/d/d_bg_s_sph_chk.h @@ -23,7 +23,6 @@ public: class dBgS_CamSphChk : public dBgS_SphChk { public: dBgS_CamSphChk() { SetCam(); } - virtual ~dBgS_CamSphChk() {} }; #endif /* D_BG_D_BG_S_SPH_CHK_H */ diff --git a/src/JSystem/J3DGraphBase/J3DMatBlock.cpp b/src/JSystem/J3DGraphBase/J3DMatBlock.cpp index 0e3b64eef5a..6aa780fdfe2 100644 --- a/src/JSystem/J3DGraphBase/J3DMatBlock.cpp +++ b/src/JSystem/J3DGraphBase/J3DMatBlock.cpp @@ -2019,13 +2019,3 @@ void J3DTexGenBlockPatched::calcPostTexMtxWithoutViewMtx(f32 const (*param_0)[4] } } } - -void J3DTevBlock::diffTevReg() {} - -void J3DTevBlock::diffTevStageIndirect() {} - -void J3DTevBlock::diffTevStage() {} - -void J3DTevBlock::diffTexCoordScale() {} - -void J3DTevBlock::diffTexNo() {} diff --git a/src/JSystem/JAudio2/JAUSectionHeap.cpp b/src/JSystem/JAudio2/JAUSectionHeap.cpp index 153ea20c125..aee48de91d5 100644 --- a/src/JSystem/JAudio2/JAUSectionHeap.cpp +++ b/src/JSystem/JAudio2/JAUSectionHeap.cpp @@ -53,7 +53,6 @@ namespace { } return field_0x8[short_id]; } - virtual ~TStreamDataMgr() {} bool isValid() { return field_0x4; } diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/bitset.h b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/bitset.h index 8accb8bf945..f6bb7354f71 100644 --- a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/bitset.h +++ b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/bitset.h @@ -16,10 +16,10 @@ template class __bitset_base { public: __bitset_base(); - bool test(size_t pos) const; - bool any() const; void set(size_t pos, bool val); void reset(size_t pos); + bool test(size_t pos) const; + bool any() const; private: size_t data[N]; }; diff --git a/src/d/actor/d_a_alink.cpp b/src/d/actor/d_a_alink.cpp index 4a10fbe4ae7..ce09ff1f35f 100644 --- a/src/d/actor/d_a_alink.cpp +++ b/src/d/actor/d_a_alink.cpp @@ -115,9 +115,9 @@ static cXyz l_wolfBaseAnime(1.0f, 88.63934f, -28.497932f); static cXyz l_wolfRopeBaseAnime(0.115164f, 68.336296f, -7.667817f); -static u8 const lit_3757[12] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; +static void dummy_lit_3757() { + Vec temp = { 0.0f, 0.0f, 0.0f }; +} #include "d/actor/d_a_alink_HIO_data.inc" @@ -1191,8 +1191,6 @@ daAlink_FaceTexData const daAlink_c::m_faceTexDataTable[] = { 0x040D, 0x03A7, }; -static const Vec lit_5908 = { 0.0f, 0.0f, 0.0f }; - #include "d/actor/d_a_alink_link.inc" #include "d/actor/d_a_alink_cut.inc" @@ -1685,9 +1683,11 @@ static dJntColData_c l_wolfJntColData[] = { #include "d/actor/d_a_alink_swindow.inc" -daAlinkHIO_c::daAlinkHIO_c() {} +// TODO: These ctors and dtors below might need to go in a new .inc file that gets included right +// after d_a_alink_swindow.inc to slightly improve function order? +// Making them weak functions in a header doesn't seem to work at least. -// TODO: these dtors are probably supposed to be weak functions from the header +daAlinkHIO_c::daAlinkHIO_c() {} daAlinkHIO_wolf_c::~daAlinkHIO_wolf_c() {} diff --git a/src/d/actor/d_a_alink_link.inc b/src/d/actor/d_a_alink_link.inc index d6db8966e10..33917c5f761 100644 --- a/src/d/actor/d_a_alink_link.inc +++ b/src/d/actor/d_a_alink_link.inc @@ -68,7 +68,7 @@ s16 daAlink_c::checkBodyAngleX(s16 param_0) { return param_0; } - Vec sp2C = lit_5908; + Vec sp2C = { 0.0f, 0.0f, 0.0f }; sp2C.y = 0.5f * field_0x598; cXyz sp20; diff --git a/src/d/actor/d_a_alink_wolf.inc b/src/d/actor/d_a_alink_wolf.inc index 77b172f6a7d..d11ad1f6015 100644 --- a/src/d/actor/d_a_alink_wolf.inc +++ b/src/d/actor/d_a_alink_wolf.inc @@ -6979,11 +6979,6 @@ BOOL daAlink_c::setWolfEnemyHangBitePos(fopEn_enemy_c* i_enemy) { return 0; } -/* #pragma push -#pragma force_active on -static u8 lit_50952[12]; -#pragma pop */ - static cXyz l_wolfBiteHitMarkScale(0.5f, 0.5f, 0.5f); void daAlink_c::setWolfBiteDamage(fopEn_enemy_c* i_enemy) { diff --git a/tools/utilities/weak_order_diff.py b/tools/utilities/weak_order_diff.py index 36d90d4d9ff..0a8a7ded2dc 100755 --- a/tools/utilities/weak_order_diff.py +++ b/tools/utilities/weak_order_diff.py @@ -56,8 +56,11 @@ def get_symbols(o_path: Path, diff_data: bool): def print_symbols_with_unmatched_order_for_object( - relative_o_path: str, version: str, diff_data: bool + src_path: str, version: str, diff_data: bool ): + assert src_path.startswith("src/") + relative_o_path = src_path[len("src/"):] + relative_o_path = relative_o_path.rsplit(".")[0] + ".o" target_o = Path("build") / version / "obj" / relative_o_path base_o = Path("build") / version / "src" / relative_o_path if not target_o.exists(): @@ -99,11 +102,11 @@ def main(): description="Print differences in weak function order for an object." ) parser.add_argument( - "o_path", + "src_path", type=str, - default="d/actor/d_a_alink.o", + default="src/d/actor/d_a_alink.cpp", nargs="?", - help="""relative path to the object file to diff (e.g. d/actor/d_a_alink.o).""", + help="""relative path to the source file to diff (e.g. src/d/actor/d_a_alink.cpp).""", ) parser.add_argument( "-v", @@ -119,7 +122,7 @@ def main(): ) args = parser.parse_args() - print_symbols_with_unmatched_order_for_object(args.o_path, args.version, args.data) + print_symbols_with_unmatched_order_for_object(args.src_path, args.version, args.data) if __name__ == "__main__":