diff options
| author | LagoLunatic <LagoLunatic@users.noreply.github.com> | 2025-12-13 00:04:03 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-12 21:04:03 -0800 |
| commit | 1b8ea3206dbbaa6e4ebe7b4dfadffd8d85f37480 (patch) | |
| tree | 334a6f146edd70f260a6d3156e1aad8221b22e42 /include/JSystem | |
| parent | 7e514502d2e97781aa0488c08e39e505f29f36f5 (diff) | |
J3D debug work (#2949)
* J3D debug work
* Clean up JSystem GXColor ctors, remove a couple fakematches
* Update symbols.txt
* Fix res include syntax
* Remove fakematch that isn't necessary anymore
* Fix some Shield regressions
Diffstat (limited to 'include/JSystem')
| -rw-r--r-- | include/JSystem/J2DGraph/J2DMatBlock.h | 7 | ||||
| -rw-r--r-- | include/JSystem/J2DGraph/J2DTevs.h | 23 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DMatBlock.h | 106 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DTevs.h | 12 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphBase/J3DTexture.h | 23 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphLoader/J3DMaterialFactory.h | 8 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphLoader/J3DMaterialFactory_v21.h | 10 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphLoader/J3DModelLoader.h | 2 | ||||
| -rw-r--r-- | include/JSystem/JSupport/JSupport.h | 6 |
9 files changed, 132 insertions, 65 deletions
diff --git a/include/JSystem/J2DGraph/J2DMatBlock.h b/include/JSystem/J2DGraph/J2DMatBlock.h index 90321c9196..381f581f07 100644 --- a/include/JSystem/J2DGraph/J2DMatBlock.h +++ b/include/JSystem/J2DGraph/J2DMatBlock.h @@ -20,7 +20,7 @@ struct ResTLUT; struct J2DGXColorS10 : public GXColorS10 { J2DGXColorS10() {} -#if PLATFORM_GCN +#if PLATFORM_GCN && __MWERKS__ J2DGXColorS10(J2DGXColorS10& other) { r = other.r; g = other.g; @@ -637,6 +637,11 @@ struct J2DAlphaComp { mAlphaCmp = J2DCalcAlphaCmp(info.field_0x0, info.mRef0, info.mRef1); mRef0 = info.field_0x1; mRef1 = info.field_0x4; + } + void operator=(const J2DAlphaComp& other) { + mAlphaCmp = other.mAlphaCmp; + mRef0 = other.mRef0; + mRef1 = other.mRef1; } u8 getComp0() { return mAlphaCmp >> 5 & 7; } u8 getRef0() { return mRef0; } diff --git a/include/JSystem/J2DGraph/J2DTevs.h b/include/JSystem/J2DGraph/J2DTevs.h index 62c9c4c548..5630d4a028 100644 --- a/include/JSystem/J2DGraph/J2DTevs.h +++ b/include/JSystem/J2DGraph/J2DTevs.h @@ -562,7 +562,7 @@ inline u8 J2DCalcTevSwapTable(u8 param_0, u8 param_1, u8 param_2, u8 param_3) { } extern const J2DTevSwapModeTableInfo j2dDefaultTevSwapModeTable; -extern const u8 data_804561AC; +extern const u8 j2dDefaultTevSwapTableID; /** * @ingroup jsystem-j2d @@ -571,21 +571,24 @@ extern const u8 data_804561AC; class J2DTevSwapModeTable { public: - J2DTevSwapModeTable() { field_0x0 = data_804561AC; } + J2DTevSwapModeTable() { mIdx = j2dDefaultTevSwapTableID; } J2DTevSwapModeTable(const J2DTevSwapModeTableInfo& info) { - field_0x0 = J2DCalcTevSwapTable(info.field_0x0, info.field_0x1, info.field_0x2, info.field_0x3); + mIdx = J2DCalcTevSwapTable(info.field_0x0, info.field_0x1, info.field_0x2, info.field_0x3); + } + void operator=(const J2DTevSwapModeTable& other) { + mIdx = other.mIdx; } void setTevSwapModeTableInfo(const J2DTevSwapModeTableInfo& info) { - field_0x0 = J2DCalcTevSwapTable(info.field_0x0, info.field_0x1, info.field_0x2, info.field_0x3); + mIdx = J2DCalcTevSwapTable(info.field_0x0, info.field_0x1, info.field_0x2, info.field_0x3); } - u8 getR() const { return field_0x0 >> 6 & 3; } - u8 getG() const { return field_0x0 >> 4 & 3; } - u8 getB() const { return field_0x0 >> 2 & 3; } - u8 getA() const { return field_0x0 & 3; } + u8 getR() const { return mIdx >> 6 & 3; } + u8 getG() const { return mIdx >> 4 & 3; } + u8 getB() const { return mIdx >> 2 & 3; } + u8 getA() const { return mIdx & 3; } private: - /* 0x0 */ u8 field_0x0; + /* 0x0 */ u8 mIdx; }; /** @@ -638,7 +641,7 @@ extern const GXColorS10 j2dDefaultTevColor; extern const GXColor j2dDefaultTevKColor; extern const J2DTevOrderInfo j2dDefaultTevOrderInfoNull; extern const u8 j2dDefaultPEBlockDither; -extern const u8 data_804561AC; +extern const u8 j2dDefaultTevSwapTableID; extern const u16 j2dDefaultAlphaCmp; #endif /* J2DTEVS_H */ diff --git a/include/JSystem/J3DGraphBase/J3DMatBlock.h b/include/JSystem/J3DGraphBase/J3DMatBlock.h index ee13669988..4b082e193e 100644 --- a/include/JSystem/J3DGraphBase/J3DMatBlock.h +++ b/include/JSystem/J3DGraphBase/J3DMatBlock.h @@ -14,17 +14,24 @@ struct J3DGXColorS10 : public GXColorS10 { J3DGXColorS10() {} -#if PLATFORM_GCN +#if PLATFORM_GCN && __MWERKS__ J3DGXColorS10(J3DGXColorS10& other) { __memcpy(this, &other, sizeof(J3DGXColorS10)); } +#elif DEBUG + J3DGXColorS10(const J3DGXColorS10& other) { + GXColorS10 sp08 = other; + J3DGXColorS10* r31 = this; + __memcpy(r31, &sp08, sizeof(GXColorS10)); + J3DGXColorS10* r30 = r31; + } #else - J3DGXColorS10(J3DGXColorS10 const& other) { __memcpy(this, &other, sizeof(J3DGXColorS10)); } + J3DGXColorS10(const J3DGXColorS10& other) { __memcpy(this, &other, sizeof(J3DGXColorS10)); } #endif - // TODO: In theory, this copy ctor should be non-const in GCN versions, as seen in TWW maps - J3DGXColorS10(GXColorS10 const& color) : GXColorS10(color) {} + J3DGXColorS10(const GXColorS10& color) : GXColorS10(color) {} J3DGXColorS10& operator=(const GXColorS10& color) { - // FAKE match. __memcpy created issues in J3DTevBlockPatched::initialize + // Fakematch? Instruction order is wrong with __memcpy or GXColorS10::operator= + // Might be real as this matches on debug as well. ((u32*)this)[0] = ((u32*)&color)[0]; ((u32*)this)[1] = ((u32*)&color)[1]; return *this; @@ -37,20 +44,21 @@ struct J3DGXColorS10 : public GXColorS10 { */ struct J3DGXColor : public GXColor { J3DGXColor() {} - // TODO: In theory, these copy ctors should be non-const in GCN versions, as seen in TWW maps - J3DGXColor(J3DGXColor const& other) { __memcpy(this, &other, sizeof(J3DGXColor)); } - J3DGXColor(GXColor const& color) : GXColor(color) {} - - // making color a reference breaks J3DColorBlockLightOff::initialize et al - J3DGXColor& operator=(GXColor color) { + +#if PLATFORM_GCN && __MWERKS__ + J3DGXColor(J3DGXColor& other) { __memcpy(this, &other, sizeof(J3DGXColor)); } +#else + J3DGXColor(const J3DGXColor& other) { __memcpy(this, &other, sizeof(J3DGXColor)); } +#endif + + J3DGXColor(const GXColor color) : GXColor(color) {} + + J3DGXColor& operator=(const GXColor color) { *(GXColor*)this = color; return *this; } J3DGXColor& operator=(const J3DGXColor& other) { - r = other.r; - g = other.g; - b = other.b; - a = other.a; + GXColor::operator=(other); return *this; } }; @@ -71,7 +79,9 @@ struct J3DNBTScale : public J3DNBTScaleInfo { J3DNBTScale(J3DNBTScaleInfo const& info) { mbHasScale = info.mbHasScale; - mScale = info.mScale; + mScale.x = info.mScale.x; + mScale.y = info.mScale.y; + mScale.z = info.mScale.z; } Vec* getScale() { return &mScale; } @@ -139,7 +149,7 @@ struct J3DColorChan { info.mDiffuseFn, info.mAttnFn, ambSrc); } void setColorChanInfo(J3DColorChanInfo const& info) { - // Bug: It compares info.mAmbSrc (an 8 bit integer) with 0xFFFF instead of 0xFF. + // !@bug: It compares info.mAmbSrc (an 8 bit integer) with 0xFFFF instead of 0xFF. // This inline is only called by the default constructor J3DColorChan(). // The J3DColorChan(const J3DColorChanInfo&) constructor does not call this inline, and instead duplicates the // same logic but without the bug. @@ -165,6 +175,10 @@ struct J3DColorChan { #endif return AttnArr[(u32)(mColorChanID & (3 << 9)) >> 9]; } + J3DColorChan& operator=(const J3DColorChan& other) { + mColorChanID = other.mColorChanID; + return *this; + } void load() const { J3DGDWrite_u32(setChanCtrlMacro(getEnable(), (GXColorSrc)getAmbSrc(), (GXColorSrc)getMatSrc(), getLightMask(), @@ -1453,6 +1467,10 @@ struct J3DZMode { mZModeID = zModeID; return *this; } + J3DZMode& operator=(const J3DZMode& other) { + mZModeID = other.mZModeID; + return *this; + } void setZModeInfo(const J3DZModeInfo& info) { mZModeID = calcZModeID(info.field_0x0, info.field_0x1, info.field_0x2); @@ -1487,7 +1505,7 @@ struct J3DZMode { */ struct J3DBlendInfo { void operator=(J3DBlendInfo const& other) { - *(int*)&mType = *(int*)&other.mType; + __memcpy(this, &other, sizeof(J3DBlendInfo)); } /* 0x0 */ u8 mType; /* 0x1 */ u8 mSrcFactor; @@ -1502,8 +1520,12 @@ extern const J3DBlendInfo j3dDefaultBlendInfo; * */ struct J3DBlend : public J3DBlendInfo { - J3DBlend() : J3DBlendInfo(j3dDefaultBlendInfo) {} - J3DBlend(J3DBlendInfo const& info) : J3DBlendInfo(info) {} + J3DBlend() { + J3DBlendInfo::operator=(j3dDefaultBlendInfo); + } + J3DBlend(J3DBlendInfo const& info) { + J3DBlendInfo::operator=(info); + } void setType(u8 i_type) { mType = i_type; } void setSrcFactor(u8 i_factor) { mSrcFactor = i_factor; } @@ -1630,6 +1652,10 @@ struct J3DIndTexOrderInfo { /* 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; @@ -1639,12 +1665,21 @@ extern const J3DIndTexOrderInfo j3dDefaultIndTexOrderNull; * */ struct J3DIndTexOrder : public J3DIndTexOrderInfo { - J3DIndTexOrder() : J3DIndTexOrderInfo(j3dDefaultIndTexOrderNull) {} + J3DIndTexOrder() { + J3DIndTexOrderInfo::operator=(j3dDefaultIndTexOrderNull); + } J3DIndTexOrder& operator=(J3DIndTexOrder const& other) { +#if DEBUG + J3DIndTexOrderInfo::operator=(other); +#else + // Fakematch: Instruction order is wrong with __memcpy or J3DIndTexCoordScaleInfo::operator= *(u32*)this = *(u32*)&other; +#endif return *this; } - J3DIndTexOrder(J3DIndTexOrderInfo const& info) : J3DIndTexOrderInfo(info) {} + J3DIndTexOrder(J3DIndTexOrderInfo const& info) { + J3DIndTexOrderInfo::operator=(info); + } u8 getMap() const { return (GXTexMapID)mMap; } u8 getCoord() const { return (GXTexCoordID)mCoord; } }; // Size: 0x04 @@ -1657,7 +1692,10 @@ extern J3DIndTexMtxInfo const j3dDefaultIndTexMtxInfo; */ struct J3DIndTexMtx : public J3DIndTexMtxInfo { J3DIndTexMtx() { *(J3DIndTexMtxInfo*)this = j3dDefaultIndTexMtxInfo; } - J3DIndTexMtx(J3DIndTexMtxInfo const& info) { *(J3DIndTexMtxInfo*)this = info; } + J3DIndTexMtx(const J3DIndTexMtxInfo& info) { *(J3DIndTexMtxInfo*)this = info; } + J3DIndTexMtx(const J3DIndTexMtx& other) { + __memcpy(this, &other, sizeof(J3DIndTexMtx)); + } ~J3DIndTexMtx() {} void load(u32 param_1) const { J3DGDSetIndTexMtx((GXIndTexMtxID)(param_1 + GX_ITM_0), (Mtx3P)field_0x0, field_0x18); @@ -1673,6 +1711,11 @@ struct J3DIndTexCoordScaleInfo { /* 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; @@ -1682,15 +1725,26 @@ extern const J3DIndTexCoordScaleInfo j3dDefaultIndTexCoordScaleInfo; * */ struct J3DIndTexCoordScale : public J3DIndTexCoordScaleInfo { - J3DIndTexCoordScale() : J3DIndTexCoordScaleInfo(j3dDefaultIndTexCoordScaleInfo) {} - J3DIndTexCoordScale(J3DIndTexCoordScaleInfo const& info) : J3DIndTexCoordScaleInfo(info) {} + J3DIndTexCoordScale() { + J3DIndTexCoordScaleInfo::operator=(j3dDefaultIndTexCoordScaleInfo); + } + J3DIndTexCoordScale(const J3DIndTexCoordScaleInfo& info) { + J3DIndTexCoordScaleInfo::operator=(info); + } + J3DIndTexCoordScale(const J3DIndTexCoordScale& other) { + __memcpy(this, &other, sizeof(J3DIndTexCoordScale)); + } ~J3DIndTexCoordScale() {} u8 getScaleS() { return mScaleS; } u8 getScaleT() { return mScaleT; } J3DIndTexCoordScale& operator=(const J3DIndTexCoordScale& other) { - //__memcpy(this, &other, sizeof(J3DIndTexCoordScaleInfo)); +#if DEBUG + J3DIndTexCoordScaleInfo::operator=(other); +#else + // Fakematch: Instruction order is wrong with __memcpy or J3DIndTexCoordScaleInfo::operator= *(u32*)this = *(u32*)&other; +#endif return *this; } }; // Size: 0x4 diff --git a/include/JSystem/J3DGraphBase/J3DTevs.h b/include/JSystem/J3DGraphBase/J3DTevs.h index 15c4b6ae10..239bd335c5 100644 --- a/include/JSystem/J3DGraphBase/J3DTevs.h +++ b/include/JSystem/J3DGraphBase/J3DTevs.h @@ -259,7 +259,9 @@ extern const J3DTevOrderInfo j3dDefaultTevOrderInfoNull; * */ struct J3DTevOrder : public J3DTevOrderInfo { - J3DTevOrder() : J3DTevOrderInfo(j3dDefaultTevOrderInfoNull) {} + J3DTevOrder() { + J3DTevOrderInfo::operator=(j3dDefaultTevOrderInfoNull); + } J3DTevOrder(const J3DTevOrderInfo& info) : J3DTevOrderInfo(info) {} J3DTevOrderInfo& getTevOrderInfo() { return *this; } @@ -269,6 +271,10 @@ struct J3DTevOrder : public J3DTevOrderInfo { extern u8 j3dTevSwapTableTable[1024]; extern u8 const j3dDefaultTevSwapTableID; +inline u8 calcTevSwapTableID(u8 param_0, u8 param_1, u8 param_2, u8 param_3) { + return 0x40 * (u8)param_0 + 0x10 * (u8)param_1 + 4 * (u8)param_2 + param_3; +} + /** * @ingroup jsystem-j3d * @@ -289,10 +295,6 @@ struct J3DTevSwapModeTable { return *this; } - u8 calcTevSwapTableID(u8 param_0, u8 param_1, u8 param_2, u8 param_3) { - return 0x40 * param_0 + 0x10 * param_1 + 4 * param_2 + param_3; - } - u8 getR() const { return *(&j3dTevSwapTableTable[mIdx * 4] + 0); } u8 getG() const { return *(&j3dTevSwapTableTable[mIdx * 4] + 1); } u8 getB() const { return *(&j3dTevSwapTableTable[mIdx * 4] + 2); } diff --git a/include/JSystem/J3DGraphBase/J3DTexture.h b/include/JSystem/J3DGraphBase/J3DTexture.h index 33848d1744..a049f0ba99 100644 --- a/include/JSystem/J3DGraphBase/J3DTexture.h +++ b/include/JSystem/J3DGraphBase/J3DTexture.h @@ -82,10 +82,7 @@ struct J3DTexCoordInfo { /* 0x3 */ u8 pad; J3DTexCoordInfo& operator=(const J3DTexCoordInfo& other) { - mTexGenType = other.mTexGenType; - mTexGenSrc = other.mTexGenSrc; - mTexGenMtx = other.mTexGenMtx; - pad = other.pad; + __memcpy(this, &other, sizeof(J3DTexCoordInfo)); return *this; } }; @@ -98,14 +95,14 @@ extern J3DTexCoordInfo const j3dDefaultTexCoordInfo[8]; */ struct J3DTexCoord : public J3DTexCoordInfo { J3DTexCoord() { - setTexCoordInfo(j3dDefaultTexCoordInfo[0]); - resetTexMtxReg(); + J3DTexCoordInfo::operator=(j3dDefaultTexCoordInfo[0]); + mTexMtxReg = mTexGenMtx; } - J3DTexCoord(J3DTexCoordInfo const& info) { - setTexCoordInfo(info); - resetTexMtxReg(); + J3DTexCoord(const J3DTexCoordInfo& info) { + J3DTexCoordInfo::operator=(info); + mTexMtxReg = mTexGenMtx; } - void setTexCoordInfo(J3DTexCoordInfo const& info) { + void setTexCoordInfo(const J3DTexCoordInfo& info) { __memcpy(this, &info, sizeof(J3DTexCoordInfo)); } @@ -116,8 +113,12 @@ struct J3DTexCoord : public J3DTexCoordInfo { void setTexGenMtx(u8 param_1) { mTexGenMtx = param_1; } void setTexMtxReg(u16 reg) { mTexMtxReg = reg; } J3DTexCoord& operator=(const J3DTexCoord& other) { - // Fake match (__memcpy or = doesn't match) +#if DEBUG + J3DTexCoordInfo::operator=(other); +#else + // Fakematch: Instruction order is wrong with __memcpy or J3DTexCoordInfo::operator= *(u32*)this = *(u32*)&other; +#endif return *this; } diff --git a/include/JSystem/J3DGraphLoader/J3DMaterialFactory.h b/include/JSystem/J3DGraphLoader/J3DMaterialFactory.h index 208390a258..bed19cd693 100644 --- a/include/JSystem/J3DGraphLoader/J3DMaterialFactory.h +++ b/include/JSystem/J3DGraphLoader/J3DMaterialFactory.h @@ -113,7 +113,7 @@ public: u32 calcSizePatchedMaterial(J3DMaterial*, int, u32) const; u32 calcSizeLockedMaterial(J3DMaterial*, int, u32) const; J3DGXColor newMatColor(int, int) const; - u8 newColorChanNum(int) const; + const u8 newColorChanNum(int) const; J3DColorChan newColorChan(int, int) const; J3DGXColor newAmbColor(int, int) const; u32 newTexGenNum(int) const; @@ -124,7 +124,7 @@ public: J3DTevOrder newTevOrder(int, int) const; J3DGXColorS10 newTevColor(int, int) const; J3DGXColor newTevKColor(int, int) const; - u8 newTevStageNum(int) const; + const u8 newTevStageNum(int) const; J3DTevStage newTevStage(int, int) const; J3DTevSwapModeTable newTevSwapModeTable(int, int) const; u8 newIndTexStageNum(int) const; @@ -136,8 +136,8 @@ public: J3DAlphaComp newAlphaComp(int) const; J3DBlend newBlend(int) const; J3DZMode newZMode(int) const; - u8 newZCompLoc(int) const; - u8 newDither(int) const; + const u8 newZCompLoc(int) const; + const u8 newDither(int) const; J3DNBTScale newNBTScale(int) const; u16 getMaterialID(int idx) const { return mpMaterialID[idx]; } diff --git a/include/JSystem/J3DGraphLoader/J3DMaterialFactory_v21.h b/include/JSystem/J3DGraphLoader/J3DMaterialFactory_v21.h index 5ed3539d37..e1369bbe5f 100644 --- a/include/JSystem/J3DGraphLoader/J3DMaterialFactory_v21.h +++ b/include/JSystem/J3DGraphLoader/J3DMaterialFactory_v21.h @@ -56,7 +56,7 @@ public: u32 countStages(int) const; J3DMaterial* create(J3DMaterial*, int, u32) const; J3DGXColor newMatColor(int, int) const; - u8 newColorChanNum(int) const; + const u8 newColorChanNum(int) const; J3DColorChan newColorChan(int, int) const; u32 newTexGenNum(int) const; J3DTexCoord newTexCoord(int, int) const; @@ -66,15 +66,15 @@ public: J3DTevOrder newTevOrder(int, int) const; J3DGXColorS10 newTevColor(int, int) const; J3DGXColor newTevKColor(int, int) const; - u8 newTevStageNum(int) const; + const u8 newTevStageNum(int) const; J3DTevStage newTevStage(int, int) const; J3DTevSwapModeTable newTevSwapModeTable(int, int) const; J3DFog newFog(int) const; J3DAlphaComp newAlphaComp(int) const; J3DBlend newBlend(int) const; - J3DZMode newZMode(int) const; - u8 newZCompLoc(int) const; - u8 newDither(int) const; + const J3DZMode newZMode(int) const; + const u8 newZCompLoc(int) const; + const u8 newDither(int) const; J3DNBTScale newNBTScale(int) const; u16 getMaterialID(u16 idx) { return mpMaterialID[idx]; } diff --git a/include/JSystem/J3DGraphLoader/J3DModelLoader.h b/include/JSystem/J3DGraphLoader/J3DModelLoader.h index 1e2aa2051a..a0a9709002 100644 --- a/include/JSystem/J3DGraphLoader/J3DModelLoader.h +++ b/include/JSystem/J3DGraphLoader/J3DModelLoader.h @@ -239,7 +239,7 @@ enum J3DModelLoaderFlagTypes { J3DMLF_Material_Color_AmbientOn = 0x80000000 }; -static inline u32 getMdlDataFlag_TevStageNum(u32 flags) { return (flags >> 0x10) & 0x1f; } +static inline u32 getMdlDataFlag_TevStageNum(u32 flags) { return (flags & 0x001f0000) >> 0x10; } static inline u32 getMdlDataFlag_TexGenFlag(u32 flags) { return flags & 0x0c000000; } static inline u32 getMdlDataFlag_ColorFlag(u32 flags) { return flags & 0xc0000000; } static inline u32 getMdlDataFlag_PEFlag(u32 flags) { return flags & 0x30000000; } diff --git a/include/JSystem/JSupport/JSupport.h b/include/JSystem/JSupport/JSupport.h index 0b9a37aec5..4f103bdf1a 100644 --- a/include/JSystem/JSupport/JSupport.h +++ b/include/JSystem/JSupport/JSupport.h @@ -23,11 +23,13 @@ T* JSUConvertOffsetToPtr(const void* ptr, uintptr_t offset) { */ template <typename T> T* JSUConvertOffsetToPtr(const void* ptr, const void* offset) { + T* ret; if (offset == NULL) { - return NULL; + ret = NULL; } else { - return (T*)((intptr_t)ptr + (intptr_t)offset); + ret = (T*)((intptr_t)ptr + (intptr_t)offset); } + return ret; } inline u8 JSULoNibble(u8 param_0) { return param_0 & 0x0f; } |
