diff --git a/.vscode/settings.json b/.vscode/settings.json index 4cc6a08a..000066a6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -28,6 +28,7 @@ "limits": "cpp", "utility": "cpp", "initializer_list": "cpp", - "new": "cpp" + "new": "cpp", + "cstdlib": "cpp" } } diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index f0672a3f..939fd8f0 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -369,6 +369,8 @@ nw4r/lyt/lyt_bounding.cpp: nw4r/lyt/lyt_material.cpp: .text start:0x8048D7D0 end:0x804905D0 .data start:0x8056E738 end:0x8056E7A8 + .sdata2 start:0x8057F280 end:0x8057F2A0 + .sbss2 start:0x8057FFB8 end:0x8057FFC0 nw4r/lyt/lyt_resourceAccessor.cpp: .text start:0x80492000 end:0x80492058 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index e08f5331..543d738a 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -26051,7 +26051,7 @@ Get__Q34nw4r3lyt6TexMapCFP9_GXTexObj = .text:0x804905D0; // type:function size:0 Get__Q34nw4r3lyt6TexMapCFP10_GXTlutObj = .text:0x804906C0; // type:function size:0x1C Set__Q34nw4r3lyt6TexMapFPCQ34nw4r3lyt6TexMap = .text:0x804906E0; // type:function size:0x14C Set__Q34nw4r3lyt6TexMapFPC13TPLDescriptor = .text:0x80490830; // type:function size:0x74 -ReplaceImage__Q34nw4r3lyt6TexMapFP10TPLPaletteUlPCc = .text:0x804908B0; // type:function size:0xD0 +ReplaceImage__Q34nw4r3lyt6TexMapFP10TPLPaletteUl = .text:0x804908B0; // type:function size:0xD0 __ct__Q34nw4r3lyt8DrawInfoFv = .text:0x80490980; // type:function size:0x74 __dt__Q34nw4r3lyt8DrawInfoFv = .text:0x80490A00; // type:function size:0x40 GetStepCurveValue__Q34nw4r3lyt27@unnamed@lyt_animation_cpp@FfPCQ44nw4r3lyt3res7StepKeyUl = .text:0x80490A40; // type:function size:0xE8 @@ -37080,9 +37080,9 @@ __vt__Q34nw4r3lyt7TextBox = .data:0x8056E570; // type:object size:0x84 @LOCAL@GetTextureFlipInfo__Q34nw4r3lyt24@unnamed@lyt_window_cpp@FUc@flipInfos = .data:0x8056E5F8; // type:object size:0x3C __vt__Q34nw4r3lyt6Window = .data:0x8056E634; // type:object size:0x8C __vt__Q34nw4r3lyt8Bounding = .data:0x8056E6C0; // type:object size:0x74 -lbl_8056E738 = .data:0x8056E738; // type:object size:0x20 data:4byte -lbl_8056E758 = .data:0x8056E758; // type:object size:0x20 data:4byte -lbl_8056E778 = .data:0x8056E778; // type:object size:0x30 +@LOCAL@SetupGX__Q34nw4r3lyt8MaterialFbUc@kColSels = .data:0x8056E738; // type:object size:0x20 data:4byte +@LOCAL@SetupGX__Q34nw4r3lyt8MaterialFbUc@kAlpSels = .data:0x8056E758; // type:object size:0x20 data:4byte +__vt__Q34nw4r3lyt8Material = .data:0x8056E778; // type:object size:0x30 lbl_8056E7A8 = .data:0x8056E7A8; // type:object size:0x10 lbl_8056E7B8 = .data:0x8056E7B8; // type:object size:0x28 __vt__Q34nw4r3lyt16ResourceAccessor = .data:0x8056E7E0; // type:object size:0x14 @@ -48085,7 +48085,7 @@ lbl_8057FF90 = .sdata2:0x8057FF90; // type:object size:0x4 lbl_8057FFA0 = .sbss2:0x8057FFA0; // type:object size:0x8 data:4byte lbl_8057FFA8 = .sbss2:0x8057FFA8; // type:object size:0x8 lbl_8057FFB0 = .sbss2:0x8057FFB0; // type:object size:0x8 -lbl_8057FFB8 = .sbss2:0x8057FFB8; // type:object size:0x8 data:2byte +DefaultBlackColor = .sbss2:0x8057FFB8; // type:object size:0x8 scope:local data:2byte lbl_8057FFC0 = .sbss2:0x8057FFC0; // type:object size:0x8 data:byte lbl_8057FFC8 = .sbss2:0x8057FFC8; // type:object size:0x4 lbl_80580000 = .bss:0x80580000; // type:object size:0x14 data:4byte diff --git a/include/nw4r/lyt/lyt_layout.h b/include/nw4r/lyt/lyt_layout.h index 13689a32..9cbeb585 100644 --- a/include/nw4r/lyt/lyt_layout.h +++ b/include/nw4r/lyt/lyt_layout.h @@ -1,5 +1,6 @@ #ifndef NW4R_LYT_LAYOUT_H #define NW4R_LYT_LAYOUT_H + #include "common.h" #include #include @@ -8,6 +9,7 @@ #include #include + namespace nw4r { namespace lyt { diff --git a/include/nw4r/lyt/lyt_material.h b/include/nw4r/lyt/lyt_material.h index 94b2110f..05a574f1 100644 --- a/include/nw4r/lyt/lyt_material.h +++ b/include/nw4r/lyt/lyt_material.h @@ -12,6 +12,7 @@ namespace lyt { class Material { public: + Material(); Material(const res::Material *pRes, const ResBlockSet &resBlockSet); void Init(); @@ -19,25 +20,35 @@ public: void ReserveGXMem(u8 texMapNum, u8 texSRTNum, u8 texCoordGenNum, u8 tevStageNum, bool allocTevSwap, u8 indStageNum, u8 indSRTNum, bool allocChanCtrl, bool allocMatCol, bool allocAlpComp, bool allocBlendMode); - TexMap *GetTexMapAry() const; + const TexMap *GetTexMapAry() const; TexMap *GetTexMapAry(); - TexSRT *GetTexSRTAry() const; + const TexSRT *GetTexSRTAry() const; TexSRT *GetTexSRTAry(); - TexCoordGen *GetTexCoordGenAry() const; + const TexCoordGen *GetTexCoordGenAry() const; TexCoordGen *GetTexCoordGenAry(); + const ChanCtrl *GetChanCtrlAry() const; ChanCtrl *GetChanCtrlAry(); + const ut::Color *GetMatColAry() const; ut::Color *GetMatColAry(); + const TevSwapMode *GetTevSwapAry() const; TevSwapMode *GetTevSwapAry(); + const AlphaCompare *GetAlphaComparePtr() const; AlphaCompare *GetAlphaComparePtr(); + const BlendMode *GetBlendModePtr() const; BlendMode *GetBlendModePtr(); + const IndirectStage *GetIndirectStageAry() const; IndirectStage *GetIndirectStageAry(); + const TexSRT *GetIndTexSRTAry() const; TexSRT *GetIndTexSRTAry(); + const TevStage *GetTevStageAry() const; TevStage *GetTevStageAry(); + void SetName(const char *name); void SetTextureNum(u8 val); void SetTexCoordGenNum(u8 val); void SetTevStageNum(u8 val); void SetIndStageNum(u8 val); + s16 GetColorElement(u32 colorType); void SetColorElement(u32 colorType, s16 value); void AddAnimationLink(AnimationLink *pAnimationLink); @@ -67,6 +78,7 @@ public: } // SetTexSRTElement__Q34nw4r3lyt8MaterialFUlUlf + // GetTexturePtr__Q34nw4r3lyt8MaterialFUc // GetTexSRTCap__Q34nw4r3lyt8MaterialCFv diff --git a/include/nw4r/lyt/lyt_pane.h b/include/nw4r/lyt/lyt_pane.h index cdbce93c..54e16eea 100644 --- a/include/nw4r/lyt/lyt_pane.h +++ b/include/nw4r/lyt/lyt_pane.h @@ -101,8 +101,8 @@ public: math::VEC2 GetVtxPos() const; void CalculateMtxChild(const DrawInfo &drawInfo); u16 GetExtUserDataNum() const; - res::ExtUserData *GetExtUserData() const; - res::ExtUserData *FindExtUserDataByName(const char *name); + const res::ExtUserData *GetExtUserData() const; + const res::ExtUserData *FindExtUserDataByName(const char *name); virtual ~Pane(); // at 0x8 NW4R_UT_RTTI_DECL(Pane); // at 0x0C diff --git a/include/nw4r/lyt/lyt_resources.h b/include/nw4r/lyt/lyt_resources.h index 168503da..851c6641 100644 --- a/include/nw4r/lyt/lyt_resources.h +++ b/include/nw4r/lyt/lyt_resources.h @@ -4,6 +4,7 @@ #include #include #include +#include #define PANE_NAME_SIZE 16 #define PANE_USERDATA_SIZE 8 @@ -42,24 +43,24 @@ struct TexSRT { struct TexMap { // GetWarpModeS__Q44nw4r3lyt3res6TexMapCFv GXTexWrapMode GetWarpModeS() const { - return (GXTexWrapMode)wrapSflt; // TODO + return (GXTexWrapMode)(wrapSflt & 3); } // GetWarpModeT__Q44nw4r3lyt3res6TexMapCFv GXTexWrapMode GetWarpModeT() const { - return (GXTexWrapMode)wrapTflt; // TODO + return (GXTexWrapMode)(wrapTflt & 3); } // GetMinFilter__Q44nw4r3lyt3res6TexMapCFv GXTexFilter GetMinFilter() const { - u8 bitData; - return (GXTexFilter)bitData; // TODO + u8 bitData = (wrapSflt >> 2) & 7; + return (GXTexFilter)((bitData + 1) & 7); } // GetMagFilter__Q44nw4r3lyt3res6TexMapCFv GXTexFilter GetMagFilter() const { - u8 bitData; - return (GXTexFilter)bitData; // TODO + u8 bitData = (wrapTflt >> 2) & 1; + return (GXTexFilter)((bitData + 1) & 1); } u16 texIdx; // at 0x0 u8 wrapSflt; // at 0x2 @@ -78,7 +79,7 @@ struct MaterialResourceNum { } // GetIndTexSRTNum__Q44nw4r3lyt3res19MaterialResourceNumCFv u8 GetIndTexSRTNum() const { - return (bits >> 4) & 0xF; + return (bits >> 13) & 0x3; } // HasBlendMode__Q44nw4r3lyt3res19MaterialResourceNumCFv @@ -102,7 +103,7 @@ struct MaterialResourceNum { } // GetChanCtrlNum__Q44nw4r3lyt3res19MaterialResourceNumCFv - u8 GetChanControlNum() const { + u8 GetChanCtrlNum() const { return (bits >> 25) & 1; } @@ -113,7 +114,7 @@ struct MaterialResourceNum { // GetTexSRTNum__Q44nw4r3lyt3res19MaterialResourceNumCFv u8 GetTexSRTNum() const { - return (bits >> 13) & 0x3; + return (bits >> 4) & 0xF; } // GetTexMapNum__Q44nw4r3lyt3res19MaterialResourceNumCFv @@ -126,7 +127,7 @@ struct MaterialResourceNum { struct Material { char name[20]; // at 0x00 GXColorS10 tevCols[3]; // at 0x14 - GXColorS10 tevKCols[3]; // at 0x2C + GXColor tevKCols[4]; // at 0x2C MaterialResourceNum resNum; // at 0x3C }; diff --git a/include/nw4r/lyt/lyt_texMap.h b/include/nw4r/lyt/lyt_texMap.h index 38a78a40..5a6609a7 100644 --- a/include/nw4r/lyt/lyt_texMap.h +++ b/include/nw4r/lyt/lyt_texMap.h @@ -14,7 +14,34 @@ inline bool IsCITexelFormat(GXTexFmt fmt) { class TexMap { public: - TexMap() {} + TexMap(TPLPalette *pTPLPalette, u32 id) { + Set(pTPLPalette, id); + } + + TexMap() { + mpImage = nullptr; + mWidth = 0; + mHeight = 0; + + mBits.textureFormat = 0; + mBits.mipmap = 0; + + mBits.wrapS = 0; + mBits.wrapT = 0; + mBits.minFilter = 1; + mBits.magFilter = 1; + + mMinLOD = 0.0f; + mMaxLOD = 0.0f; + mLODBias = 0; + mBits.biasClampEnable = 0; + mBits.edgeLODEnable = 0; + + mpPalette = nullptr; + mBits.anisotropy = 0; + mBits.paletteFormat = 0; + mPaletteEntryNum = 0; + } void Get(GXTexObj *) const; void Get(GXTlutObj *) const; @@ -79,69 +106,74 @@ public: } GXTexFmt GetTexelFormat() const { - return (GXTexFmt)mBits.mTexelFormat; + return (GXTexFmt)mBits.textureFormat; } void SetTexelFormat(GXTexFmt fmt) { - mBits.mTexelFormat = fmt; + mBits.textureFormat = fmt; } bool IsMipMap() const { - return mBits.mIsMipMap; + return mBits.mipmap; } void SetMipMap(bool b) { - mBits.mIsMipMap = b; + mBits.mipmap = b; } GXTexWrapMode GetWrapModeS() const { - return (GXTexWrapMode)mBits.mWrapModeS; + return (GXTexWrapMode)mBits.wrapS; } GXTexWrapMode GetWrapModeT() const { - return (GXTexWrapMode)mBits.mWrapModeT; + return (GXTexWrapMode)mBits.wrapT; } void SetWrapMode(GXTexWrapMode wrapS, GXTexWrapMode wrapT) { - mBits.mWrapModeS = wrapS; - mBits.mWrapModeT = wrapT; + mBits.wrapS = wrapS; + mBits.wrapT = wrapT; } GXTexFilter GetMinFilter() const { - return (GXTexFilter)mBits.mMinFilter; + return (GXTexFilter)mBits.minFilter; } GXTexFilter GetMagFilter() const { - return (GXTexFilter)mBits.mMagFilter; + return (GXTexFilter)mBits.magFilter; } void SetFilter(GXTexFilter minFlt, GXTexFilter magFlt) { - mBits.mMinFilter = minFlt; - mBits.mMagFilter = magFlt; + mBits.minFilter = minFlt; + mBits.magFilter = magFlt; } bool IsBiasClampEnable() const { - return mBits.mIsBiasClampEnable; + return mBits.biasClampEnable; } void SetBiasClampEnable(bool b) { - mBits.mIsBiasClampEnable = b; + mBits.biasClampEnable = b; } bool IsEdgeLODEnable() const { - return mBits.mIsEdgeLODEnable; + return mBits.edgeLODEnable; } void SetEdgeLODEnable(bool b) { - mBits.mIsEdgeLODEnable = b; + mBits.edgeLODEnable = b; } GXAnisotropy GetAnisotropy() const { - return (GXAnisotropy)mBits.mAnisotropy; + return (GXAnisotropy)mBits.anisotropy; } void SetAnisotropy(GXAnisotropy a) { - mBits.mAnisotropy = a; + mBits.anisotropy = a; } GXTlutFmt GetPaletteFormat() const { - return (GXTlutFmt)mBits.mPaletteFormat; + return (GXTlutFmt)mBits.paletteFormat; } void SetPaletteFormat(GXTlutFmt fmt) { - mBits.mPaletteFormat = fmt; + mBits.paletteFormat = fmt; } + // ReplaceImage__Q34nw4r3lyt6TexMapFP10TPLPaletteUl + void ReplaceImage(TPLPalette *pal, u32 id); + // ReplaceImage__Q34nw4r3lyt6TexMapFPC13TPLDescriptor + void ReplaceImage(TPLDescriptor *pTPLDesc); + private: void *mpImage; // at 0x00 void *mpPalette; // at 0x04 @@ -152,18 +184,17 @@ private: u16 mLODBias; // at 0x14 u16 mPaletteEntryNum; // at 0x16 struct { - u32 mTexelFormat : 4; // GXTexFmt - u32 mIsMipMap : 1; // bool - u32 mWrapModeS : 2; // GXTexWrapMode - u32 mWrapModeT : 2; // GXTexWrapMode - u32 mMinFilter : 3; // GXTexFilter - u32 mMagFilter : 3; // GXTexFilter - u32 mIsBiasClampEnable : 1; // bool - u32 mIsEdgeLODEnable : 1; // bool - u32 mAnisotropy : 2; // GXAnisotropy - u32 mPaletteFormat : 2; // GXTlutFmt - - } mBits; // at 0x18 + u32 textureFormat : 4; // (>> 28) & 0xF : GXTexFmt + u32 mipmap : 1; // (>> 27) & 0x1 : bool + u32 wrapS : 2; // (>> 25) & 0x3 : GXTexWrapMode + u32 wrapT : 2; // (>> 23) & 0x3 : GXTexWrapMode + u32 minFilter : 3; // (>> 20) & 0x7 : GXTexFilter + u32 magFilter : 1; // (>> 19) & 0x1 : GXTexFilter + u32 biasClampEnable : 1; // (>> 18) & 0x1 : bool + u32 edgeLODEnable : 1; // (>> 17) & 0x1 : bool + u32 anisotropy : 2; // (>> 15) & 0x3 : GXAnisotropy + u32 paletteFormat : 2; // (>> 13) & 0x3 : GXTlutFmt + } mBits; // at 0x18 }; } // namespace lyt } // namespace nw4r diff --git a/include/nw4r/lyt/lyt_types.h b/include/nw4r/lyt/lyt_types.h index 563b0689..3f676c68 100644 --- a/include/nw4r/lyt/lyt_types.h +++ b/include/nw4r/lyt/lyt_types.h @@ -9,17 +9,17 @@ namespace lyt { namespace detail { struct BitGXNums { - u32 texMap : 4; - u32 texSRT : 4; - u32 texCoordGen : 4; - u32 indSRT : 2; - u32 indStage : 3; - u32 tevSwap : 1; - u32 tevStage : 5; - u32 chanCtrl : 1; - u32 matCol : 1; - u32 alpComp : 1; - u32 blendMode : 1; + u32 texMap : 4; // ( >> 28 ) & F + u32 texSRT : 4; // ( >> 24 ) & F + u32 texCoordGen : 4; // ( >> 20 ) & F + u32 indSRT : 2; // ( >> 18 ) & 3 + u32 indStage : 3; // ( >> 15 ) & 7 + u32 tevSwap : 1; // ( >> 14 ) & 1 + u32 tevStage : 5; // ( >> 9 ) & 1F + u32 chanCtrl : 1; // ( >> 8 ) & 1 + u32 matCol : 1; // ( >> 7 ) & 1 + u32 alpComp : 1; // ( >> 6 ) & 1 + u32 blendMode : 1; // ( >> 5 ) & 1 }; template @@ -40,10 +40,15 @@ T GetBits(T bits, int pos, int len) { } template -T *ConvertOffsToPtr(const void *baseAddress, unsigned int offset) { +T *ConvertOffsToPtr(void *baseAddress, unsigned int offset) { return (T *)((u32)baseAddress + offset); } +template +const T *ConvertOffsToPtr(const void *baseAddress, unsigned int offset) { + return (const T *)((u32)baseAddress + offset); +} + } // namespace detail struct Size { Size() : width(), height() {} @@ -66,13 +71,14 @@ struct AnimTransform { u16 GetFrameSize() const; bool IsLoopData() const; - virtual ~AnimTransform() = 0; - virtual void SetResource(const res::AnimationBlock *pRes, ResourceAccessor *pResAccessor) = 0; - virtual void SetResource(const res::AnimationBlock *pRes, ResourceAccessor *pResAccessor, u16 animNum) = 0; - virtual void Bind(Pane *pPane, bool bRecursive) = 0; - virtual void Bind(Material *pMaterial, bool bDisable) = 0; - virtual void Animate(u32 idx, Pane *pPane) = 0; - virtual void Animate(u32 idx, Material *pMaterial) = 0; + virtual ~AnimTransform() = 0; // at 0x08 + virtual void SetResource(const res::AnimationBlock *pRes, ResourceAccessor *pResAccessor) = 0; // at 0x0C + virtual void SetResource(const res::AnimationBlock *pRes, ResourceAccessor *pResAccessor, // + u16 animNum) = 0; // at 0x10 + virtual void Bind(Pane *pPane, bool bRecursive) = 0; // at 0x14 + virtual void Bind(Material *pMaterial, bool bDisable) = 0; // at 0x18 + virtual void Animate(u32 idx, Pane *pPane) = 0; // at 0x1C + virtual void Animate(u32 idx, Material *pMaterial) = 0; // at 0x20 ut::LinkListNode mLink; // at 0x4 res::AnimationBlock *mpRes; // at 0xC @@ -177,7 +183,9 @@ struct TexCoordGen { }; struct ChanCtrl { // 17552 // __ct__Q34nw4r3lyt8ChanCtrlFv - ChanCtrl() {} + ChanCtrl() : reserve1(0), reserve2(0) { + Set(GX_SRC_VTX, GX_SRC_VTX); + } // Set__Q34nw4r3lyt8ChanCtrlF11_GXColorSrc11_GXColorSrc void Set(GXColorSrc colSrc, GXColorSrc alpSrc) { @@ -201,15 +209,62 @@ struct ChanCtrl { // 17552 u8 reserve2; // at 0x3 }; +struct AlphaCompare { // 17457 + // __ct__Q34nw4r3lyt12AlphaCompareFv + AlphaCompare() { + Set(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0); + } + + // Set__Q34nw4r3lyt12AlphaCompareF10_GXCompareUc10_GXAlphaOp10_GXCompareUc + void Set(GXCompare aComp0, u8 aRef0, GXAlphaOp aOp, GXCompare aComp1, u8 aRef1) { + comp = (aComp0 & 0x7) | ((aComp1 & 0x7) << 4); + op = aOp; + ref0 = aRef0; + ref1 = aRef1; + } + + // GetComp0__Q34nw4r3lyt12AlphaCompareCFv + GXCompare GetComp0() const { + return (GXCompare)((comp >> 0) & 0xF); + } + + // GetRef0__Q34nw4r3lyt12AlphaCompareCFv + u8 GetRef0() const { + return ref0; + } + + // GetOp__Q34nw4r3lyt12AlphaCompareCFv + GXAlphaOp GetOp() const { + return (GXAlphaOp)op; + } + + // GetComp1__Q34nw4r3lyt12AlphaCompareCFv + GXCompare GetComp1() const { + return (GXCompare)((comp >> 4) & 0xF); + } + + // GetRef1__Q34nw4r3lyt12AlphaCompareCFv + u8 GetRef1() const { + return ref1; + } + + u8 comp; // at 0x0 + u8 op; // at 0x1 + u8 ref0; // at 0x2 + u8 ref1; // at 0x3 +}; + struct BlendMode { // 10c41 // __ct__Q34nw4r3lyt9BlendModeFv - BlendMode() {} + BlendMode() { + Set(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET); + } // Set__Q34nw4r3lyt9BlendModeF12_GXBlendMode14_GXBlendFactor14_GXBlendFactor10_GXLogicOp - void Set(GXBlendMode aType, GXBlendFactor srcFactor, GXBlendFactor destFactor, GXLogicOp aOp) { + void Set(GXBlendMode aType, GXBlendFactor aSrcFactor, GXBlendFactor aDestFactor, GXLogicOp aOp) { type = aType; - srcFactor = srcFactor; - dstFactor = destFactor; + srcFactor = aSrcFactor; + dstFactor = aDestFactor; op = aOp; } @@ -239,46 +294,11 @@ struct BlendMode { // 10c41 u8 op; // at 0x3 }; -struct AlphaCompare { // 17457 - // __ct__Q34nw4r3lyt12AlphaCompareFv - AlphaCompare() {} - - // Set__Q34nw4r3lyt12AlphaCompareF10_GXCompareUc10_GXAlphaOp10_GXCompareUc - void Set(GXCompare aComp0, u8 aRef0, GXAlphaOp aOp, GXCompare aComp1, u8 aRef1) {} - - // GetComp0__Q34nw4r3lyt12AlphaCompareCFv - GXCompare GetComp0() const { - // return (GXCompare) - } - - // GetRef0__Q34nw4r3lyt12AlphaCompareCFv - u8 GetRef0() const { - return ref0; - } - - // GetOp__Q34nw4r3lyt12AlphaCompareCFv - GXAlphaOp GetOp() const { - return (GXAlphaOp)op; - } - - // GetComp1__Q34nw4r3lyt12AlphaCompareCFv - GXCompare GetComp1() const { - // return (GXCompare) - } - - // GetRef1__Q34nw4r3lyt12AlphaCompareCFv - u8 GetRef1() const { - return ref1; - } - - u8 comp; // at 0x0 - u8 op; // at 0x1 - u8 ref0; // at 0x2 - u8 ref1; // at 0x3 -}; struct IndirectStage { // 172da // __ct__Q34nw4r3lyt13IndirectStageFv - IndirectStage() {} + IndirectStage() { + Set(GX_TEXCOORD0, GX_TEXMAP0, GX_ITS_1, GX_ITS_1); + } // Set__Q34nw4r3lyt13IndirectStageF13_GXTexCoordID11_GXTexMapID14_GXIndTexScale14_GXIndTexScale void Set(GXTexCoordID aTexCoordGen, GXTexMapID aTexMap, GXIndTexScale aScaleS, GXIndTexScale aScaleT) { @@ -324,59 +344,65 @@ struct TexSRT { // 17243 struct TevStageInOp { // 16fe7 // GetA__Q34nw4r3lyt12TevStageInOpCFv u8 GetA() const { - return ab; // TODO + return (ab >> 0) & 0xF; } // GetB__Q34nw4r3lyt12TevStageInOpCFv u8 GetB() const { - return ab; // TODO + return (ab >> 4) & 0xF; } // GetC__Q34nw4r3lyt12TevStageInOpCFv u8 GetC() const { - return cd; // TODO + return (cd >> 0) & 0xF; } // GetD__Q34nw4r3lyt12TevStageInOpCFv u8 GetD() const { - return cd; // TODO + return (cd >> 4) & 0xF; } // GetOp__Q34nw4r3lyt12TevStageInOpCFv u8 GetOp() const { - return op; // TODO + return (op >> 0) & 0xF; } // GetBias__Q34nw4r3lyt12TevStageInOpCFv u8 GetBias() const { - return op; // TODO + return (op >> 4) & 0x3; } // GetScale__Q34nw4r3lyt12TevStageInOpCFv u8 GetScale() const { - return op; // TODO + return (op >> 6) & 0x3; } // IsClamp__Q34nw4r3lyt12TevStageInOpCFv bool IsClamp() const { - return cl; // TODO + return (cl >> 0) & 1; } // GetOutReg__Q34nw4r3lyt12TevStageInOpCFv u8 GetOutReg() const { - return op; // TODO + return (cl >> 1) & 0x3; } // GetKSel__Q34nw4r3lyt12TevStageInOpCFv u8 GetKSel() const { - return cl; // TODO + return (cl >> 3) & 0x1F; } // SetIn__Q34nw4r3lyt12TevStageInOpFUcUcUcUc - void SetIn(u8 a, u8 b, u8 c, u8 d) {} + void SetIn(u8 a, u8 b, u8 c, u8 d) { + ab = (a & 0xF) | ((b & 0xF) << 4); + cd = (c & 0xF) | ((d & 0xF) << 4); + } // SetOp__Q34nw4r3lyt12TevStageInOpFUcUcUcbUcUc - void SetOp(u8 aOp, u8 bias, u8 scale, bool clamp, u8 outReg, u8 kSel) {} + void SetOp(u8 aOp, u8 bias, u8 scale, bool clamp, u8 outReg, u8 kSel) { + op = (aOp & 0xF) | ((bias & 3) << 4) | ((scale & 0x3) << 6); + cl = (clamp & 1) | ((outReg & 0x3) << 1) | ((kSel & 0x1F) << 3); + } u8 ab; // at 0x0 u8 cd; // at 0x1 @@ -386,7 +412,15 @@ struct TevStageInOp { // 16fe7 struct TevStage { // 17094 // __ct__Q34nw4r3lyt8TevStageFv - TevStage() {} + TevStage() { + SetOrder(GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0, GX_TEV_SWAP0, GX_TEV_SWAP0); + SetColorIn(GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_RASC); + SetAlphaIn(GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_RASA); + SetColorOp(GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV, GX_TEV_KCSEL_K0); + SetAlphaOp(GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, true, GX_TEVPREV, GX_TEV_KASEL_K0_R); + SetIndirect(GX_INDTEXSTAGE0, GX_ITF_8, GX_ITB_NONE, GX_ITM_OFF, GX_ITW_OFF, GX_ITW_OFF, false, false, + GX_ITBA_OFF); + } // GetTexCoordGen__Q34nw4r3lyt8TevStageCFv GXTexCoordID GetTexCoordGen() const { @@ -395,7 +429,7 @@ struct TevStage { // 17094 // GetTexMap__Q34nw4r3lyt8TevStageCFv GXTexMapID GetTexMap() const { - return (GXTexMapID)texMap; + return (GXTexMapID)(texMap | (swapSel & 1) << 8); } // GetColorChan__Q34nw4r3lyt8TevStageCFv @@ -405,12 +439,12 @@ struct TevStage { // 17094 // GetRasSwapSel__Q34nw4r3lyt8TevStageCFv GXTevSwapSel GetRasSwapSel() const { - return (GXTevSwapSel)swapSel; // TODO + return (GXTevSwapSel)((swapSel >> 1) & 3); } // GetTexSwapSel__Q34nw4r3lyt8TevStageCFv GXTevSwapSel GetTexSwapSel() const { - return (GXTevSwapSel)swapSel; // TODO + return (GXTevSwapSel)((swapSel >> 3) & 3); } // GetColorInA__Q34nw4r3lyt8TevStageCFv @@ -515,7 +549,7 @@ struct TevStage { // 17094 // GetIndMtxSel__Q34nw4r3lyt8TevStageCFv GXIndTexMtxID GetIndMtxSel() const { - return (GXIndTexMtxID)inBiMt; // TODO + return (GXIndTexMtxID)((inBiMt >> 3) & 0xF); } // GetIndStage__Q34nw4r3lyt8TevStageCFv @@ -525,37 +559,37 @@ struct TevStage { // 17094 // GetIndFormat__Q34nw4r3lyt8TevStageCFv GXIndTexFormat GetIndFormat() const { - return (GXIndTexFormat)indFoAdUtAl; // TODO + return (GXIndTexFormat)((indFoAdUtAl >> 0) & 0x3); } // GetIndBiasSel__Q34nw4r3lyt8TevStageCFv GXIndTexBiasSel GetIndBiasSel() const { - return (GXIndTexBiasSel)inBiMt; // TODO + return (GXIndTexBiasSel)((inBiMt >> 0) & 0x7); } // GetIndWrapS__Q34nw4r3lyt8TevStageCFv GXIndTexWrap GetIndWrapS() const { - return (GXIndTexWrap)indWrap; // TODO + return (GXIndTexWrap)((indWrap >> 0) & 0x7); } // GetIndWrapT__Q34nw4r3lyt8TevStageCFv GXIndTexWrap GetIndWrapT() const { - return (GXIndTexWrap)indWrap; // TODO + return (GXIndTexWrap)((indWrap >> 3) & 0x7); } // IsIndAddPrev__Q34nw4r3lyt8TevStageCFv - bool IsIndAddPrev() const { - return indFoAdUtAl; // TODO + u8 IsIndAddPrev() const { + return ((indFoAdUtAl >> 2) & 1); } // IsIndUtcLod__Q34nw4r3lyt8TevStageCFv - bool IsIndUtcLod() const { - return indFoAdUtAl; // TODO + u8 IsIndUtcLod() const { + return ((indFoAdUtAl >> 3) & 1); } // GetIndAlphaSel__Q34nw4r3lyt8TevStageCFv GXIndTexAlphaSel GetIndAlphaSel() const { - return (GXIndTexAlphaSel)indFoAdUtAl; // TODO + return (GXIndTexAlphaSel)((indFoAdUtAl >> 4) & 3); } // SetOrder__Q34nw4r3lyt8TevStageF13_GXTexCoordID11_GXTexMapID12_GXChannelID13_GXTevSwapSel13_GXTevSwapSel @@ -564,8 +598,7 @@ struct TevStage { // 17094 texCoordGen = aTexCoordGen; colChan = aColChan; texMap = aTexMap; - swapSel = rasSel; // TODO - swapSel = texSel; // TODO + swapSel = ((rasSel & 3) << 1) | ((texSel & 3) << 3); } // SetColorIn__Q34nw4r3lyt8TevStageF14_GXTevColorArg14_GXTevColorArg14_GXTevColorArg14_GXTevColorArg @@ -592,14 +625,9 @@ struct TevStage { // 17094 void SetIndirect(GXIndTexStageID stage, GXIndTexFormat format, GXIndTexBiasSel bias, GXIndTexMtxID mtxSel, GXIndTexWrap wrapS, GXIndTexWrap wrapT, bool addPrev, bool utcLod, GXIndTexAlphaSel alphaSel) { indStage = stage; - indFoAdUtAl = format; // TODO - inBiMt = bias; // TODO - inBiMt = mtxSel; // TODO - indWrap = wrapS; // TODO - indWrap = wrapT; // TODO - indFoAdUtAl = addPrev; // TODO - indFoAdUtAl = utcLod; // TODO - indFoAdUtAl = alphaSel; // TODO + inBiMt = (bias & 0x7) | ((mtxSel & 0xF) << 4); + indWrap = (wrapS & 0x7) | ((wrapT & 0x7) << 3); + indFoAdUtAl = (format & 3) | (addPrev << 2) | (utcLod << 3) | ((alphaSel & 0x3) << 4); } u8 texCoordGen; // at 0x0 @@ -618,30 +646,27 @@ struct TevSwapMode { // 1750a // GetR__Q34nw4r3lyt11TevSwapModeCFv GXTevColorChan GetR() const { - return (GXTevColorChan)swap; // TODO + return (GXTevColorChan)((swap >> 0) & 0x3); } // GetG__Q34nw4r3lyt11TevSwapModeCFv GXTevColorChan GetG() const { - return (GXTevColorChan)swap; // TODO + return (GXTevColorChan)((swap >> 2) & 0x3); } // GetB__Q34nw4r3lyt11TevSwapModeCFv GXTevColorChan GetB() const { - return (GXTevColorChan)swap; // TODO + return (GXTevColorChan)((swap >> 4) & 0x3); } // GetA__Q34nw4r3lyt11TevSwapModeCFv GXTevColorChan GetA() const { - return (GXTevColorChan)swap; // TODO + return (GXTevColorChan)((swap >> 6) & 0x3); } // Set__Q34nw4r3lyt11TevSwapModeF15_GXTevColorChan15_GXTevColorChan15_GXTevColorChan15_GXTevColorChan void Set(GXTevColorChan r, GXTevColorChan g, GXTevColorChan b, GXTevColorChan a) { - swap = r; // TODO - swap = g; // TODO - swap = b; // TODO - swap = a; // TODO + swap = (r << 0) | (g << 2) | (b << 4) | (a << 6); } u8 swap; // at 0x0 diff --git a/include/nw4r/ut/ut_Color.h b/include/nw4r/ut/ut_Color.h index b9616f14..f41e9dbe 100644 --- a/include/nw4r/ut/ut_Color.h +++ b/include/nw4r/ut/ut_Color.h @@ -34,6 +34,10 @@ public: return *this; } + Color &operator=(const GXColor &c) { + *(u32 *)this = *(u32 *)&c; // TODO -> This Seems Maybe Wrong + } + Color operator|(u32 color) { return Color(ToU32() | color); } diff --git a/include/rvl/GX/GXTev.h b/include/rvl/GX/GXTev.h index 5e4438b0..cdd651f0 100644 --- a/include/rvl/GX/GXTev.h +++ b/include/rvl/GX/GXTev.h @@ -13,7 +13,7 @@ void GXSetTevColorOp(GXTevStageID, GXTevOp, GXTevBias, GXTevScale, u8, GXTevRegI void GXSetTevAlphaOp(GXTevStageID, GXTevOp, GXTevBias, GXTevScale, u8, GXTevRegID); void GXSetTevColor(GXTevRegID, GXColor); - +void GXSetTevColorS10(GXTevRegID, GXColorS10); void GXSetTevKColor(GXTevKColorID, GXColor); void GXSetTevKColorSel(GXTevStageID, GXTevKColorSel); void GXSetTevKAlphaSel(GXTevStageID, GXTevKAlphaSel); diff --git a/include/rvl/GX/GXTexture.h b/include/rvl/GX/GXTexture.h index 8f826a2c..d6554e19 100644 --- a/include/rvl/GX/GXTexture.h +++ b/include/rvl/GX/GXTexture.h @@ -13,7 +13,9 @@ void __GXSetSUTexRegs(void); void GXInitTexObj(GXTexObj *, void *, u16, u16, GXTexFmt, GXTexWrapMode, GXTexWrapMode, u8); void GXInitTexObjLOD(GXTexObj *, GXTexFilter, GXTexFilter, f32, f32, f32, u8, u8, GXAnisotropy); +void GXInitTexObjTlut(GXTexObj *, u32); +void GXLoadTlut(GXTlutObj *, u32); void GXLoadTexObj(GXTexObj *, GXTexMapID); #ifdef __cplusplus diff --git a/include/rvl/GX/GXTypes.h b/include/rvl/GX/GXTypes.h index 99094c37..745cbda6 100644 --- a/include/rvl/GX/GXTypes.h +++ b/include/rvl/GX/GXTypes.h @@ -801,6 +801,29 @@ typedef enum _GXTexWrapMode { GX_MAX_TEXWRAPMODE } GXTexWrapMode; +typedef enum GXTlut { + GX_TLUT0, + GX_TLUT1, + GX_TLUT2, + GX_TLUT3, + GX_TLUT4, + GX_TLUT5, + GX_TLUT6, + GX_TLUT7, + GX_TLUT8, + GX_TLUT9, + GX_TLUT10, + GX_TLUT11, + GX_TLUT12, + GX_TLUT13, + GX_TLUT14, + GX_TLUT15, + GX_BIGTLUT0, + GX_BIGTLUT1, + GX_BIGTLUT2, + GX_BIGTLUT3, +} GXTlut; + typedef enum _GXTlutFmt { GX_TL_IA8, GX_TL_RGB565, diff --git a/src/nw4r/lyt/lyt_material.cpp b/src/nw4r/lyt/lyt_material.cpp index f151de6d..82525b90 100644 --- a/src/nw4r/lyt/lyt_material.cpp +++ b/src/nw4r/lyt/lyt_material.cpp @@ -1,439 +1,969 @@ + +#include #include +#include -// DefaultBlackColor -// DefaultWhiteColor +void float_ordering(u16 a) { + 0.5f; + 256.0f / 360.0f; + 0.0f; + 1.0f; + 2.0f; + (f32) a; +} +// All 0 intialization puts it in sbss2?? +static const GXColorS10 DefaultBlackColor = {0, 0, 0, 0}; +static const GXColorS10 DefaultWhiteColor = {0xFF, 0xFF, 0xFF, 0xFF}; + +namespace nw4r { +namespace lyt { +namespace { // __eq__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FRC11_GXColorS10RC11_GXColorS10 -inline bool operator==(const GXColorS10 &a, const GXColorS10 &b) { +bool operator==(const GXColorS10 &a, const GXColorS10 &b) { return (a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a); } -inline bool operator!=(const GXColorS10 &a, const GXColorS10 &b) { - return (a.r != b.r || a.g != b.g || a.b != b.b || a.a != b.a); +bool operator!=(const GXColorS10 &a, const GXColorS10 &b) { + return !(a == b); } -namespace nw4r { -namespace lyt { - -namespace { // CalcTextureMtx__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FPQ34nw4r4math5MTX34RCQ34nw4r3lyt6TexSRT void CalcTextureMtx(math::MTX34 *pMtx, const TexSRT &texSRT) { - math::VEC2 center; - f32 cosR; - f32 sinR; - f32 a0; - f32 a1; + math::VEC2 center(0.5f, 0.5f); + f32 cosR = math::CosDeg(texSRT.rotate); + f32 sinR = math::SinDeg(texSRT.rotate); + f32 a0, a1; + + a0 = cosR * texSRT.scale.x; + a1 = -sinR * texSRT.scale.y; + pMtx->_00 = a0; + pMtx->_01 = a1; + pMtx->_02 = 0.0f; + pMtx->_03 = texSRT.translate.x + center.x + a0 * -center.x + a1 * -center.y; + + a0 = sinR * texSRT.scale.x; + a1 = cosR * texSRT.scale.y; + pMtx->_10 = a0; + pMtx->_11 = a1; + pMtx->_12 = 0.0f; + pMtx->_13 = texSRT.translate.y + center.y + a0 * -center.x + a1 * -center.y; + + pMtx->_20 = 0.0f; + pMtx->_21 = 0.0f; + pMtx->_22 = 1.0f; + pMtx->_23 = 0.0f; } // CalcIndTexMtx__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FPA3_fRCQ34nw4r3lyt6TexSRT void CalcIndTexMtx(f32 (*mtx)[3], const TexSRT &texSRT) { - f32 cosR; - f32 sinR; + f32 cosR = math::CosDeg(texSRT.rotate); + f32 sinR = math::SinDeg(texSRT.rotate); + + mtx[0][0] = cosR * texSRT.scale.x; + mtx[0][1] = -sinR * texSRT.scale.y; + mtx[0][2] = texSRT.translate.x; + mtx[1][0] = sinR * texSRT.scale.x; + mtx[1][1] = cosR * texSRT.scale.y; + mtx[1][2] = texSRT.translate.y; } // SetColorComponentValue__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FPQ34nw4r2ut5ColorUls void SetColorComponentValue(ut::Color *pCol, u32 compIdx, s16 value) { - u8 u8Val; + u8 u8Val = ut::Min(ut::Max(value, 0), 0xFF); + switch (compIdx % 4) { + case 0: + pCol->r = u8Val; + break; + case 1: + pCol->g = u8Val; + break; + case 2: + pCol->b = u8Val; + break; + case 3: + pCol->a = u8Val; + break; + default: + break; + } } // SetIndTexMtx__Q34nw4r3lyt26@unnamed@lyt_material_cpp@F14_GXIndTexMtxIDPA3_Cf void SetIndTexMtx(GXIndTexMtxID id, const f32 (*mtx)[3]) { - f32 m00, m01, m02, m10, m11, m12, a00, a01, a02, a10, a11, a12; - s8 scaleExp; - f32 outMtx[3]; + f32 m00 = mtx[0][0]; + f32 m01 = mtx[0][1]; + f32 m02 = mtx[0][2]; + f32 m10 = mtx[1][0]; + f32 m11 = mtx[1][1]; + f32 m12 = mtx[1][2]; + f32 a00 = math::FAbs(m00); + f32 a01 = math::FAbs(m01); + f32 a02 = math::FAbs(m02); + f32 a10 = math::FAbs(m10); + f32 a11 = math::FAbs(m11); + f32 a12 = math::FAbs(m12); + s8 scaleExp = 0; + + if ((a00 >= 1.0f || a01 >= 1.0f || a02 >= 1.0f || a10 >= 1.0f || a11 >= 1.0f || a12 >= 1.0f)) { + do { + if (scaleExp >= 46) { + break; + } + m00 *= 0.5f; + m01 *= 0.5f; + m02 *= 0.5f; + m10 *= 0.5f; + m11 *= 0.5f; + m12 *= 0.5f; + a00 *= 0.5f; + a01 *= 0.5f; + a02 *= 0.5f; + a10 *= 0.5f; + a11 *= 0.5f; + a12 *= 0.5f; + scaleExp++; + } while ((a00 >= 1.0f || a01 >= 1.0f || a02 >= 1.0f || a10 >= 1.0f || a11 >= 1.0f || a12 >= 1.0f)); + } else if (a00 < 0.5f && a01 < 0.5f && a02 < 0.5f && a10 < 0.5f && a11 < 0.5f && a12 < 0.5f) { + do { + a00 *= 2.0f; + m00 *= 2.0f; + m01 *= 2.0f; + m02 *= 2.0f; + m10 *= 2.0f; + m11 *= 2.0f; + m12 *= 2.0f; + a01 *= 2.0f; + a02 *= 2.0f; + a10 *= 2.0f; + a11 *= 2.0f; + a12 *= 2.0f; + scaleExp--; + } while (a00 < 0.5f && a01 < 0.5f && a02 < 0.5f && a10 < 0.5f && a11 < 0.5f && a12 < 0.5f && scaleExp > -17); + } + f32 outMtx[2][3] = {m00, m01, m02, m10, m11, m12}; + GXSetIndTexMtx(id, outMtx, scaleExp); +} +// GetTexMtx__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FUl +u32 GetTexMtx(u32 texMtxIdx) { + return 30 + 3 * texMtxIdx; +} + +// GetTexMtxIdx__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FUl +u32 GetTexMtxIdx(u32 texMtx) { + return (texMtx - 30) / 3; } // InitTexSRT__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FPQ34nw4r3lyt6TexSRTUl void InitTexSRT(TexSRT *texSRTs, u32 num) { - u32 i; + for (u32 i = 0; i < num; i++) { + texSRTs[i].translate = math::VEC2(0.0f, 0.0f); + texSRTs[i].rotate = 0.0f; + texSRTs[i].scale = math::VEC2(1.0f, 1.0f); + } } // CalcOffsetTexSRTAry__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FRCQ44nw4r3lyt6detail9BitGXNums -u32 CalcOffsetTexSRTAry(const detail::BitGXNums &bitGXNums) {} +u32 CalcOffsetTexSRTAry(const detail::BitGXNums &bitGXNums) { + return bitGXNums.texMap * sizeof(TexMap); +} // CalcOffsetTexCoordGenAry__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FRCQ44nw4r3lyt6detail9BitGXNums -u32 CalcOffsetTexCoordGenAry(const detail::BitGXNums &bitGXNums) {} +u32 CalcOffsetTexCoordGenAry(const detail::BitGXNums &bitGXNums) { + return bitGXNums.texSRT * ROUND_UP(sizeof(TexSRT), 4) + CalcOffsetTexSRTAry(bitGXNums); +} // CalcOffsetChanCtrlAry__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FRCQ44nw4r3lyt6detail9BitGXNums -u32 CalcOffsetChanCtrlAry(const detail::BitGXNums &bitGXNums) {} +u32 CalcOffsetChanCtrlAry(const detail::BitGXNums &bitGXNums) { + return bitGXNums.texCoordGen * ROUND_UP(sizeof(TexCoordGen), 4) + CalcOffsetTexCoordGenAry(bitGXNums); +} // CalcOffsetMatColAry__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FRCQ44nw4r3lyt6detail9BitGXNums -u32 CalcOffsetMatColAry(const detail::BitGXNums &bitGXNums) {} +u32 CalcOffsetMatColAry(const detail::BitGXNums &bitGXNums) { + return bitGXNums.chanCtrl * ROUND_UP(sizeof(ChanCtrl), 4) + CalcOffsetChanCtrlAry(bitGXNums); +} // CalcOffsetTevSwapAry__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FRCQ44nw4r3lyt6detail9BitGXNums -u32 CalcOffsetTevSwapAry(const detail::BitGXNums &bitGXNums) {} +u32 CalcOffsetTevSwapAry(const detail::BitGXNums &bitGXNums) { + return bitGXNums.matCol * ROUND_UP(sizeof(ut::Color), 4) + CalcOffsetMatColAry(bitGXNums); +} // CalcOffsetGetAlphaCompare__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FRCQ44nw4r3lyt6detail9BitGXNums -u32 CalcOffsetGetAlphaCompare(const detail::BitGXNums &bitGXNums) {} +u32 CalcOffsetGetAlphaCompare(const detail::BitGXNums &bitGXNums) { + // just sizeof(TevSwapMode)] doesnt work here. Assuming its aligned to 4 for a ptr purposeD + return bitGXNums.tevSwap * ROUND_UP(sizeof(TevSwapMode), 4) + CalcOffsetTevSwapAry(bitGXNums); +} // CalcOffsetBlendMode__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FRCQ44nw4r3lyt6detail9BitGXNums -u32 CalcOffsetBlendMode(const detail::BitGXNums &bitGXNums) {} +u32 CalcOffsetBlendMode(const detail::BitGXNums &bitGXNums) { + return bitGXNums.alpComp * ROUND_UP(sizeof(AlphaCompare), 4) + CalcOffsetGetAlphaCompare(bitGXNums); +} // CalcOffsetIndirectStageAry__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FRCQ44nw4r3lyt6detail9BitGXNums -u32 CalcOffsetIndirectStageAry(const detail::BitGXNums &bitGXNums) {} +u32 CalcOffsetIndirectStageAry(const detail::BitGXNums &bitGXNums) { + return bitGXNums.blendMode * ROUND_UP(sizeof(BlendMode), 4) + CalcOffsetBlendMode(bitGXNums); +} // CalcOffsetIndTexSRTAry__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FRCQ44nw4r3lyt6detail9BitGXNums -u32 CalcOffsetIndTexSRTAry(const detail::BitGXNums &bitGXNums) {} +u32 CalcOffsetIndTexSRTAry(const detail::BitGXNums &bitGXNums) { + return bitGXNums.indStage * ROUND_UP(sizeof(IndirectStage), 4) + CalcOffsetIndirectStageAry(bitGXNums); +} // CalcOffsetTevStageAry__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FRCQ44nw4r3lyt6detail9BitGXNums -u32 CalcOffsetTevStageAry(const detail::BitGXNums &bitGXNums) {} +u32 CalcOffsetTevStageAry(const detail::BitGXNums &bitGXNums) { + return bitGXNums.indSRT * ROUND_UP(sizeof(TexSRT), 4) + CalcOffsetIndTexSRTAry(bitGXNums); +} } // namespace -// __ct__Q34nw4r3lyt8MaterialFPCQ44nw4r3lyt3res8MaterialRCQ34nw4r3lyt11ResBlockSet -Material::Material(const res::Material *pRes, const ResBlockSet &resBlockSet) { - { int i; } - { int i; } - u32 resOffs; - const res::TexMap *pResTexMap; - const res::TexSRT *pResTexSRTs; - const TexCoordGen *resTexCoordGen; - u8 texMapNum; - u8 texSRTNum; - u8 texCoordGenNum; - bool allocChanCtrl; - bool allocMatCol; - bool allocTevSwap; - bool allocAlpComp; - bool allocBlendMode; - u8 indTexSRTNum; - u8 indStageNum; - u8 tevStageNum; - const res::Texture *textures; - const TexMap *texMaps; - u8 di, si; - const char *fileName; - void *pTplRes; - res::TexSRT *texSRTs; - { int i; } - TexCoordGen *texCoordGens; - { int i; } - const ChanCtrl *pResChanCtrl; - ut::Color *pResMatCol; - const TevSwapMode *pResTevSwap; - const TevSwapMode *tevSwaps; - { int i; } - const TexSRT *indTexSRTs; - const TexSRT *pResIndMtx; - { int i; } - IndirectStage *indirectStages; - const IndirectStage *pResIndStg; - { int i; } - const TevStage *tevStages; - const TevStage *pResTevStg; - { int i; } - const AlphaCompare *pResAlphaCompare; - const BlendMode *pResBlendMode; +// __ct__Q34nw4r3lyt8MaterialFv +Material::Material() { + /* Exists, not in SS. Needed for some function ordering */ } +#pragma dont_inline on +// __ct__Q34nw4r3lyt8MaterialFPCQ44nw4r3lyt3res8MaterialRCQ34nw4r3lyt11ResBlockSet +Material::Material(const res::Material *pRes, const ResBlockSet &resBlockSet) : mAnimList(), mTevKCols() { + Init(); + SetName(pRes->name); + for (int i = 0; i < 3; i++) { + mTevCols[i] = pRes->tevCols[i]; + } + for (int i = 0; i < 4; i++) { + mTevKCols[i] = pRes->tevKCols[i]; + } + + u32 resOffs = sizeof(res::Material); + const res::TexMap *pResTexMap = detail::ConvertOffsToPtr(pRes, resOffs); + resOffs += pRes->resNum.GetTexMapNum() * sizeof(res::TexMap); + + const TexSRT *pResTexSRTs = detail::ConvertOffsToPtr(pRes, resOffs); + resOffs += pRes->resNum.GetTexSRTNum() * sizeof(TexSRT); + + const TexCoordGen *resTexCoordGen = detail::ConvertOffsToPtr(pRes, resOffs); + resOffs += pRes->resNum.GetTexCoordGenNum() * sizeof(TexCoordGen); + + u8 texMapNum = ut::Min(pRes->resNum.GetTexMapNum(), 8); + u8 texSRTNum = ut::Min(pRes->resNum.GetTexSRTNum(), 10); + u8 texCoordGenNum = ut::Min(pRes->resNum.GetTexCoordGenNum(), 8); + bool allocChanCtrl = pRes->resNum.GetChanCtrlNum() != 0; + bool allocMatCol = pRes->resNum.GetMatColNum() != 0; + bool allocTevSwap = pRes->resNum.HasTevSwapTable(); + bool allocAlpComp = pRes->resNum.HasAlphaCompare(); + bool allocBlendMode = pRes->resNum.HasBlendMode(); + u8 indTexSRTNum = ut::Min(pRes->resNum.GetIndTexSRTNum(), 3); + u8 indStageNum = ut::Min(pRes->resNum.GetIndTexStageNum(), 4); + u8 tevStageNum = ut::Min(pRes->resNum.GetTevStageNum(), 16); + + ReserveGXMem(texMapNum, texSRTNum, texCoordGenNum, tevStageNum, allocTevSwap, indStageNum, indTexSRTNum, + allocChanCtrl, allocMatCol, allocAlpComp, allocBlendMode); + + if (mpGXMem) { + SetTextureNum(texMapNum); + if (texMapNum != 0) { + const res::Texture *textures = + detail::ConvertOffsToPtr(resBlockSet.pTextureList, sizeof(res::TextureList)); + TexMap *texMaps = GetTexMapAry(); + u8 di = 0; + for (u8 si = 0; si < texMapNum; di++, si++) { + const char *fileName = + detail::ConvertOffsToPtr(textures, textures[pResTexMap[si].texIdx].nameStrOffset); + void *pTplRes = resBlockSet.pResAccessor->GetResource('timg', fileName, nullptr); + texMaps[di].ReplaceImage((TPLPalette *)pTplRes, 0); + texMaps[di].SetWrapMode(pResTexMap[si].GetWarpModeS(), pResTexMap[si].GetWarpModeT()); + texMaps[di].SetFilter(pResTexMap[si].GetMinFilter(), pResTexMap[si].GetMagFilter()); + } + SetTextureNum(di); + } + } + TexSRT *texSRTs = GetTexSRTAry(); + for (int i = 0; i < texSRTNum; i++) { + texSRTs[i].translate = pResTexSRTs[i].translate; + texSRTs[i].rotate = pResTexSRTs[i].rotate; + texSRTs[i].scale = pResTexSRTs[i].scale; + } + + TexCoordGen *texCoordGens = GetTexCoordGenAry(); + SetTexCoordGenNum(texCoordGenNum); + for (int i = 0; i < mGXMemNum.texCoordGen; i++) { + texCoordGens[i] = resTexCoordGen[i]; + } + + if (allocChanCtrl) { + const ChanCtrl *pResChanCtrl = detail::ConvertOffsToPtr(pRes, resOffs); + GetChanCtrlAry()[0] = *pResChanCtrl; + resOffs += sizeof(ChanCtrl); + } + + if (allocMatCol) { + const ut::Color *pResMatCol = detail::ConvertOffsToPtr(pRes, resOffs); + GetMatColAry()[0] = *pResMatCol; + resOffs += sizeof(ut::Color); + } + + if (allocTevSwap) { + const TevSwapMode *tevSwaps = detail::ConvertOffsToPtr(pRes, resOffs); + TevSwapMode *pResTevSwap = GetTevSwapAry(); + for (int i = 0; i < 4; i++) { + pResTevSwap[i] = tevSwaps[i]; + } + resOffs += 4 * sizeof(TevSwapMode); + } + + if (indTexSRTNum != 0) { + TexSRT *indTexSRTs = GetIndTexSRTAry(); + const TexSRT *pResIndMtx = detail::ConvertOffsToPtr(pRes, resOffs); + for (int i = 0; i < indTexSRTNum; i++) { + indTexSRTs[i] = pResIndMtx[i]; + } + } + resOffs += pRes->resNum.GetIndTexSRTNum() * sizeof(TexSRT); + + if (indStageNum != 0) { + SetIndStageNum(indStageNum); + IndirectStage *indirectStages = GetIndirectStageAry(); + const IndirectStage *pResIndStg = detail::ConvertOffsToPtr(pRes, resOffs); + for (int i = 0; i < indStageNum; i++) { + indirectStages[i] = pResIndStg[i]; + } + } + resOffs += pRes->resNum.GetIndTexStageNum() * sizeof(IndirectStage); + + if (tevStageNum != 0) { + SetTevStageNum(tevStageNum); + TevStage *tevStages = GetTevStageAry(); + const TevStage *pResTevStg = detail::ConvertOffsToPtr(pRes, resOffs); + for (int i = 0; i < tevStageNum; i++) { + tevStages[i] = pResTevStg[i]; + } + } + resOffs += pRes->resNum.GetTevStageNum() * sizeof(TevStage); + + if (allocAlpComp) { + const AlphaCompare *pResAlphaCompare = detail::ConvertOffsToPtr(pRes, resOffs); + *GetAlphaComparePtr() = *pResAlphaCompare; + resOffs += sizeof(AlphaCompare); + } + if (allocBlendMode) { + const BlendMode *pResBlendMode = detail::ConvertOffsToPtr(pRes, resOffs); + *GetBlendModePtr() = *pResBlendMode; + } +} +#pragma dont_inline reset + // Init__Q34nw4r3lyt8MaterialFv -void Material::Init() {} +void Material::Init() { + mTevCols[0] = DefaultBlackColor; + mTevCols[1] = DefaultWhiteColor; + mTevCols[2] = DefaultWhiteColor; + InitBitGXNums(&mGXMemCap); + InitBitGXNums(&mGXMemNum); + mbUserAllocated = false; + mpGXMem = nullptr; +} // __dt__Q34nw4r3lyt8MaterialFv -Material::~Material() {} +Material::~Material() { + UnbindAllAnimation(); + if (mpGXMem) { + Layout::FreeMemory(mpGXMem); + mpGXMem = nullptr; + } +} // InitBitGXNums__Q34nw4r3lyt8MaterialFPQ44nw4r3lyt6detail9BitGXNums -void Material::InitBitGXNums(detail::BitGXNums *ptr) {} +void Material::InitBitGXNums(detail::BitGXNums *ptr) { + ptr->texMap = 0; + ptr->texSRT = 0; + ptr->texCoordGen = 0; + ptr->indSRT = 0; + ptr->indStage = 0; + ptr->tevSwap = 0; + ptr->tevStage = 0; + ptr->chanCtrl = 0; + ptr->matCol = 0; + ptr->alpComp = 0; + ptr->blendMode = 0; +} // ReserveGXMem__Q34nw4r3lyt8MaterialFUcUcUcUcbUcUcbbbb void Material::ReserveGXMem(u8 texMapNum, u8 texSRTNum, u8 texCoordGenNum, u8 tevStageNum, bool allocTevSwap, u8 indStageNum, u8 indSRTNum, bool allocChanCtrl, bool allocMatCol, bool allocAlpComp, bool allocBlendMode) { - int tevSwapNum; - int chanCtrlNum; - int matColNum; - int alpCompNum; - int blendModeNum; - const TevSwapMode *tevSwaps; + int tevSwapNum = allocTevSwap; + int chanCtrlNum = allocChanCtrl; + int matColNum = allocMatCol; + int alpCompNum = allocAlpComp; + int blendModeNum = allocBlendMode; + if (mGXMemCap.texMap < texMapNum || mGXMemCap.texSRT < texSRTNum || mGXMemCap.texCoordGen < texCoordGenNum || + mGXMemCap.tevStage < tevStageNum || mGXMemCap.tevSwap < tevSwapNum || mGXMemCap.indStage < indStageNum || + mGXMemCap.indSRT < indSRTNum || mGXMemCap.chanCtrl < chanCtrlNum || mGXMemCap.matCol < matColNum || + mGXMemCap.alpComp < alpCompNum || mGXMemCap.blendMode < blendModeNum) { + if (mpGXMem) { + Layout::FreeMemory(mpGXMem); + mpGXMem = nullptr; + InitBitGXNums(&mGXMemCap); + InitBitGXNums(&mGXMemNum); + } + mpGXMem = Layout::AllocMemory( + (texCoordGenNum + chanCtrlNum + matColNum + tevSwapNum + alpCompNum + blendModeNum + indStageNum) * 4 + + texMapNum * sizeof(TexMap) + tevStageNum * sizeof(TevStage) + texSRTNum * sizeof(TexSRT) + + indSRTNum * sizeof(TexSRT)); + + if (mpGXMem) { + mGXMemCap.texMap = texMapNum; + mGXMemCap.texSRT = texSRTNum; + mGXMemCap.texCoordGen = texCoordGenNum; + mGXMemCap.indSRT = indSRTNum; + mGXMemCap.indStage = indStageNum; + mGXMemCap.tevSwap = tevSwapNum; + mGXMemCap.tevStage = tevStageNum; + mGXMemCap.chanCtrl = chanCtrlNum; + mGXMemCap.matCol = matColNum; + mGXMemCap.alpComp = alpCompNum; + mGXMemCap.blendMode = blendModeNum; + + mGXMemNum.texSRT = mGXMemCap.texSRT; + InitTexSRT(GetTexSRTAry(), mGXMemNum.texSRT); + + mGXMemNum.indSRT = mGXMemCap.indSRT; + InitTexSRT(GetIndTexSRTAry(), mGXMemNum.indSRT); + + mGXMemNum.chanCtrl = mGXMemCap.chanCtrl; + if (mGXMemNum.chanCtrl != 0) { + GetChanCtrlAry()[0] = ChanCtrl(); + } + + mGXMemNum.matCol = mGXMemCap.matCol; + if (mGXMemNum.matCol != 0) { + GetMatColAry()[0] = 0xFFFFFFFF; + } + + mGXMemNum.tevSwap = mGXMemCap.tevSwap; + if (mGXMemNum.tevSwap != 0) { + TevSwapMode *tevSwaps = GetTevSwapAry(); + tevSwaps[0].Set(GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA); + tevSwaps[1].Set(GX_CH_RED, GX_CH_RED, GX_CH_RED, GX_CH_ALPHA); + tevSwaps[2].Set(GX_CH_GREEN, GX_CH_GREEN, GX_CH_GREEN, GX_CH_ALPHA); + tevSwaps[3].Set(GX_CH_BLUE, GX_CH_BLUE, GX_CH_BLUE, GX_CH_ALPHA); + } + + mGXMemNum.alpComp = mGXMemCap.alpComp; + if (mGXMemNum.alpComp != 0) { + *GetAlphaComparePtr() = AlphaCompare(); + } + + mGXMemNum.blendMode = mGXMemCap.blendMode; + if (mGXMemNum.blendMode != 0) { + *GetBlendModePtr() = BlendMode(); + } + } + } } // GetTexMapAry__Q34nw4r3lyt8MaterialCFv -TexMap *Material::GetTexMapAry() const {} +const TexMap *Material::GetTexMapAry() const { + return detail::ConvertOffsToPtr(mpGXMem, 0); // Might not use the function? +} // GetTexMapAry__Q34nw4r3lyt8MaterialFv -TexMap *Material::GetTexMapAry() {} +TexMap *Material::GetTexMapAry() { + return (detail::ConvertOffsToPtr(mpGXMem, 0)); +} + +// GetTexSRTAry__Q34nw4r3lyt8MaterialCFv +const TexSRT *Material::GetTexSRTAry() const { + return detail::ConvertOffsToPtr(mpGXMem, CalcOffsetTexSRTAry(mGXMemCap)); +} // GetTexSRTAry__Q34nw4r3lyt8MaterialFv -TexSRT *Material::GetTexSRTAry() {} +TexSRT *Material::GetTexSRTAry() { + return detail::ConvertOffsToPtr(mpGXMem, CalcOffsetTexSRTAry(mGXMemCap)); +} // GetTexCoordGenAry__Q34nw4r3lyt8MaterialFv -TexCoordGen *Material::GetTexCoordGenAry() {} +TexCoordGen *Material::GetTexCoordGenAry() { + return detail::ConvertOffsToPtr(mpGXMem, CalcOffsetTexCoordGenAry(mGXMemCap)); +} // GetChanCtrlAry__Q34nw4r3lyt8MaterialFv -ChanCtrl *Material::GetChanCtrlAry() {} +ChanCtrl *Material::GetChanCtrlAry() { + return detail::ConvertOffsToPtr(mpGXMem, CalcOffsetChanCtrlAry(mGXMemCap)); +} // GetMatColAry__Q34nw4r3lyt8MaterialFv -ut::Color *Material::GetMatColAry() {} +ut::Color *Material::GetMatColAry() { + return detail::ConvertOffsToPtr(mpGXMem, CalcOffsetMatColAry(mGXMemCap)); +} // GetTevSwapAry__Q34nw4r3lyt8MaterialFv -TevSwapMode *Material::GetTevSwapAry() {} +TevSwapMode *Material::GetTevSwapAry() { + return detail::ConvertOffsToPtr(mpGXMem, CalcOffsetTevSwapAry(mGXMemCap)); +} // GetAlphaComparePtr__Q34nw4r3lyt8MaterialFv -AlphaCompare *Material::GetAlphaComparePtr() {} +AlphaCompare *Material::GetAlphaComparePtr() { + return detail::ConvertOffsToPtr(mpGXMem, CalcOffsetGetAlphaCompare(mGXMemCap)); +} // GetBlendModePtr__Q34nw4r3lyt8MaterialFv -BlendMode *Material::GetBlendModePtr() {} +BlendMode *Material::GetBlendModePtr() { + return detail::ConvertOffsToPtr(mpGXMem, CalcOffsetBlendMode(mGXMemCap)); +} // GetIndirectStageAry__Q34nw4r3lyt8MaterialFv -IndirectStage *Material::GetIndirectStageAry() {} +IndirectStage *Material::GetIndirectStageAry() { + return detail::ConvertOffsToPtr(mpGXMem, CalcOffsetIndirectStageAry(mGXMemCap)); +} // GetIndTexSRTAry__Q34nw4r3lyt8MaterialFv -TexSRT *Material::GetIndTexSRTAry() {} +TexSRT *Material::GetIndTexSRTAry() { + return detail::ConvertOffsToPtr(mpGXMem, CalcOffsetIndTexSRTAry(mGXMemCap)); +} // GetTevStageAry__Q34nw4r3lyt8MaterialFv -TevStage *Material::GetTevStageAry() {} +TevStage *Material::GetTevStageAry() { + return detail::ConvertOffsToPtr(mpGXMem, CalcOffsetTevStageAry(mGXMemCap)); +} // SetName__Q34nw4r3lyt8MaterialFPCc -void Material::SetName(const char *name) {} +void Material::SetName(const char *name) { + strncpy(mName, name, 20); + mName[20] = '\0'; +} // SetTextureNum__Q34nw4r3lyt8MaterialFUc void Material::SetTextureNum(u8 num) { - TexMap *texMaps; - u32 i; + if (num != 0) { + TexMap *texMaps = GetTexMapAry(); + for (u32 i = mGXMemNum.texMap; i < num; i++) { + new (&texMaps[i]) TexMap(); // Placement operator required + // texMaps[i] = TexMap(); + } + } + mGXMemNum.texMap = num; } // SetTexCoordGenNum__Q34nw4r3lyt8MaterialFUc void Material::SetTexCoordGenNum(u8 num) { - TexCoordGen *texCoordGens; - u32 i; + if (num != 0) { + TexCoordGen *texCoordGens = GetTexCoordGenAry(); + for (u32 i = mGXMemNum.texCoordGen; i < num; i++) { + new (&texCoordGens[i]) TexCoordGen(); + } + } + mGXMemNum.texCoordGen = num; } // SetTevStageNum__Q34nw4r3lyt8MaterialFUc void Material::SetTevStageNum(u8 num) { - TevStage *tevStages; - u32 i; + if (num != 0) { + TevStage *tevStages = GetTevStageAry(); + for (u32 i = mGXMemNum.tevStage; i < num; i++) { + new (&tevStages[i]) TevStage(); + } + } + mGXMemNum.tevStage = num; } // SetIndStageNum__Q34nw4r3lyt8MaterialFUc void Material::SetIndStageNum(u8 num) { - IndirectStage *indStages; - u32 i; + if (num != 0) { + IndirectStage *indStages = GetIndirectStageAry(); + for (u32 i = mGXMemNum.indStage; i < num; i++) { + new (&indStages[i]) IndirectStage(); + } + } + mGXMemNum.indStage = num; } +// GetColorElement__Q34nw4r3lyt8MaterialCFUl + // SetColorElement__Q34nw4r3lyt8MaterialFUls void Material::SetColorElement(u32 colorType, s16 value) { - ut::Color *matCols; - { u32 regIdx; } - { u32 regIdx; } - GXTevKColorSel kColSels[8]; - GXTevKAlphaSel kAlpSels[8]; + // Some sort of Enum ? + // 0:[ MatCol->r] 1:[ MatCol->g] 2:[ MatCol->b] 3:[ MatCol->a + // 4:[ TevCol->r] 5:[ TevCol->g] 6:[ TevCol->b] 7:[ TevCol->a] + // 8:[ TevCol->r] 9:[ TevCol->g] 10:[ TevCol->b] 11:[ TevCol->a] + // 12:[ TevCol->r] 13:[ TevCol->g] 14:[ TevCol->b] 15:[ TevCol->a] + // 16:[TevKCol->r] 17:[TevKCol->g] 18:[TevKCol->b] 19:[TevKCol->a] + // 20:[TevKCol->r] 21:[TevKCol->g] 22:[TevKCol->b] 23:[TevKCol->a] + // 24:[TevKCol->r] 25:[TevKCol->g] 26:[TevKCol->b] 27:[TevKCol->a] + // 28:[TevKCol->r] 29:[TevKCol->g] 30:[TevKCol->b] 31:[TevKCol->a] + // clang-format off + switch (colorType) { + case 0: case 1: case 2: case 3: + if (mGXMemNum.matCol < 1 ) { + break; + } + ut::Color *matCols = GetMatColAry(); + SetColorComponentValue(matCols, colorType , value); + break; + case 4: case 5: case 6: case 7: case 8: case 9: + case 10: case 11: case 12: case 13: case 14: case 15: { + u32 regIdx = (colorType - 4) / 4; + switch ((colorType - 4) % 4) { + case 0: + mTevCols[regIdx].r = value; + break; + case 1: + mTevCols[regIdx].g = value; + break; + case 2: + mTevCols[regIdx].b = value; + break; + case 3: + mTevCols[regIdx].a = value; + break; + } + } break; + case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: + case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: { + u32 regIdx = (colorType - 16) / 4; + SetColorComponentValue(&mTevKCols[regIdx], (colorType - 16) , value); + } break; + } + // clang-format on } // SetupGX__Q34nw4r3lyt8MaterialFbUc bool Material::SetupGX(bool bModVtxCol, u8 alpha) { - bool bUseVtxCol; - bool bUseMatCol; - const ChanCtrl *chanCtrls; - bool bUseRasStage; - ut::Color matCol; - bool bSetTexMtx; - bool bUseTexMtxl; - { int i; } - const TexCoordGen *texCoordGens; - { int i; } - u32 texMtx; - const TexSRT *texSRTs; - { int i; } - { math::MTX34 texMtx; } - u32 tlutID; - u32 bigTlutID; - const TexMap *texMaps; - { int i; } - // TexMap & texMap; - GXTexObj texObj; - u32 tlutName; - GXTlutObj tlutObj; - const TevSwapMode *tevSwaps; - { int i; } - bool bSetIndTexMtx; - bool bUseIndTexMtx; - { int i; } - const TevStage *tevStages; - { int i; } - GXTevStageID tevStage; - GXIndTexMtxID indMtxSel; - u8 tevStageID; - { GXTevStageID tevStage; } - { GXTevStageID tevStage; } - { GXTevStageID tevStage; } - { int i; } - { GXTevStageID tevStage; } - GXTevColorArg colDIn; - GXTevAlphaArg alpDIn; - { GXTevStageID tevStage; } - { GXTevStageID tevStage; } - u8 tevStageNum; - u8 id; - { GXTevStageID tevStage; } - const TexSRT *indTexSRTs; - { int i; } - f32 mtx[2][3]; - const IndirectStage *indirectStages; - { int i; } - GXIndTexStageID indStage; - const AlphaCompare *pAlpComp; - const BlendMode *pBlendMode; + bool bUseVtxCol = true; + bool bUseMatCol = false; + GXSetNumChans(1); + if (IsChanCtrlCap()) { + const ChanCtrl *chanCtrls = GetChanCtrlAry(); + GXSetChanCtrl(GX_COLOR0, false, GX_SRC_REG, chanCtrls->GetColorSrc(), GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE); + GXSetChanCtrl(GX_ALPHA0, false, GX_SRC_REG, chanCtrls->GetAlphaSrc(), GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE); + + bUseVtxCol = chanCtrls->GetColorSrc() == GX_SRC_VTX || chanCtrls->GetAlphaSrc() == GX_SRC_VTX; + bUseMatCol = chanCtrls->GetColorSrc() == GX_SRC_REG || chanCtrls->GetAlphaSrc() == GX_SRC_REG; + } else { + GXSetChanCtrl(GX_COLOR0A0, FALSE, GX_SRC_REG, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE); + } + + // Why set to false and then check if true? + bool bUseRasStage = false; + if (bUseVtxCol) { + bUseRasStage = bUseRasStage || bModVtxCol; + } + + if (bUseMatCol) { + ut::Color matCol = 0xFFFFFFFF; + if (IsMatColorCap()) { + matCol = GetMatColAry()[0]; + } + matCol = detail::MultipleAlpha(matCol, alpha); + GXSetChanMatColor(GX_COLOR0A0, matCol); + bUseRasStage = bUseRasStage || matCol != 0xFFFFFFFF; + } + bool bSetTexMtx = false; + bool bUseTexMtx[10]; + for (int i = 0; i < 10; i++) { + bUseTexMtx[i] = false; + } + GXSetNumTexGens(mGXMemNum.texCoordGen); + if (mGXMemNum.texCoordGen != 0) { + const TexCoordGen *texCoordGens = GetTexCoordGenAry(); + for (int i = 0; i < mGXMemNum.texCoordGen; i++) { + u32 texMtx = texCoordGens[i].GetTexMtx(); + if (texCoordGens[i].GetTexGenType() == GX_TEXMAP1 && texMtx != 0x3C) { + bUseTexMtx[GetTexMtxIdx(texMtx)] = true; + bSetTexMtx = true; + } + GXSetTexCoordGen2((GXTexCoordID)i, texCoordGens[i].GetTexGenType(), texCoordGens[i].GetTexGenSrc(), texMtx, + FALSE, 0x7D); + } + } + if (bSetTexMtx) { + const TexSRT *texSRTs = GetTexSRTAry(); + + for (u8 i = 0; i < mGXMemNum.texSRT; i++) { + if (bUseTexMtx[i]) { + math::MTX34 texMtx; + CalcTextureMtx(&texMtx, texSRTs[i]); + GXLoadTexMtxImm(texMtx, GetTexMtx(i), GX_MTX_2x4); + } + } + } + + if (mGXMemNum.texMap) { + u32 tlutID = 0; + u32 bigTlutID = 16; + + const TexMap *texMaps = GetTexMapAry(); + for (int i = 0; i < mGXMemNum.texMap; i++) { + const TexMap &texMap = texMaps[i]; + GXTexObj texObj; + texMap.Get(&texObj); + if (detail::IsCITexelFormat(texMap.GetTexelFormat())) { + u32 tlutName; + if (texMap.GetTexelFormat() == 10) { + tlutName = bigTlutID++; + } else { + tlutName = tlutID++; + } + GXInitTexObjTlut(&texObj, tlutName); + GXTlutObj tlutObj; + texMap.Get(&tlutObj); + GXLoadTlut(&tlutObj, tlutName); + } + GXLoadTexObj(&texObj, (GXTexMapID)i); + } + } + + GXSetTevColorS10(GX_TEVREG0, mTevCols[0]); + GXSetTevColorS10(GX_TEVREG1, mTevCols[1]); + GXSetTevColorS10(GX_TEVREG2, mTevCols[2]); + GXSetTevKColor(GX_KCOLOR0, mTevKCols[0]); + GXSetTevKColor(GX_KCOLOR1, mTevKCols[1]); + GXSetTevKColor(GX_KCOLOR2, mTevKCols[2]); + GXSetTevKColor(GX_KCOLOR3, mTevKCols[3]); + + if (IsTevSwapCap()) { + const TevSwapMode *tevSwaps = GetTevSwapAry(); + for (int i = 0; i < 4; i++) { + GXSetTevSwapModeTable((GXTevSwapSel)i, tevSwaps[i].GetR(), tevSwaps[i].GetG(), tevSwaps[i].GetB(), + tevSwaps[i].GetA()); + } + } else { + GXSetTevSwapModeTable(GX_TEV_SWAP0, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA); + GXSetTevSwapModeTable(GX_TEV_SWAP1, GX_CH_RED, GX_CH_RED, GX_CH_RED, GX_CH_ALPHA); + GXSetTevSwapModeTable(GX_TEV_SWAP2, GX_CH_GREEN, GX_CH_GREEN, GX_CH_GREEN, GX_CH_ALPHA); + GXSetTevSwapModeTable(GX_TEV_SWAP3, GX_CH_BLUE, GX_CH_BLUE, GX_CH_BLUE, GX_CH_ALPHA); + } + + bool bSetIndTexMtx = false; + bool bUseIndTexMtx[3]; + for (int i = 0; i < 3; i++) { + bUseIndTexMtx[i] = false; + } + if (mGXMemNum.tevStage != 0) { + GXSetNumTevStages(mGXMemNum.tevStage); + const TevStage *tevStages = GetTevStageAry(); + for (int i = 0; i < mGXMemNum.tevStage; i++) { + GXTevStageID tevStage = (GXTevStageID)i; + GXSetTevOrder(tevStage, tevStages[i].GetTexCoordGen(), tevStages[i].GetTexMap(), + tevStages[i].GetColorChan()); + GXSetTevSwapMode(tevStage, tevStages[i].GetRasSwapSel(), tevStages[i].GetTexSwapSel()); + GXSetTevColorIn(tevStage, tevStages[i].GetColorInA(), tevStages[i].GetColorInB(), + tevStages[i].GetColorInC(), tevStages[i].GetColorInD()); + GXSetTevColorOp(tevStage, tevStages[i].GetColorOp(), tevStages[i].GetColorBias(), + tevStages[i].GetColorScale(), tevStages[i].IsColorClamp(), tevStages[i].GetColorOutReg()); + GXSetTevKColorSel(tevStage, tevStages[i].GetKColorSel()); + GXSetTevAlphaIn(tevStage, tevStages[i].GetAlphaInA(), tevStages[i].GetAlphaInB(), + tevStages[i].GetAlphaInC(), tevStages[i].GetAlphaInD()); + GXSetTevAlphaOp(tevStage, tevStages[i].GetAlphaOp(), tevStages[i].GetAlphaBias(), + tevStages[i].GetAlphaScale(), tevStages[i].IsAlphaClamp(), tevStages[i].GetAlphaOutReg()); + GXSetTevKAlphaSel(tevStage, tevStages[i].GetKAlphaSel()); + GXIndTexMtxID indMtxSel = tevStages[i].GetIndMtxSel(); + GXSetTevIndirect(tevStage, tevStages[i].GetIndStage(), tevStages[i].GetIndFormat(), + tevStages[i].GetIndBiasSel(), indMtxSel, tevStages[i].GetIndWrapS(), tevStages[i].GetIndWrapT(), + tevStages[i].IsIndAddPrev(), tevStages[i].IsIndUtcLod(), tevStages[i].GetIndAlphaSel()); + if (1 <= indMtxSel && indMtxSel <= 3) { + bUseIndTexMtx[indMtxSel - 1] = true; + bSetIndTexMtx = true; + } + } + bUseRasStage = true; + } else { + static GXTevKColorSel kColSels[8] = { + GX_TEV_KCSEL_K3_A, + GX_TEV_KCSEL_K3_B, + GX_TEV_KCSEL_K3_G, + GX_TEV_KCSEL_K3_R, + GX_TEV_KCSEL_K2_A, + GX_TEV_KCSEL_K2_B, + GX_TEV_KCSEL_K2_G, + GX_TEV_KCSEL_K2_R, + }; + static GXTevKAlphaSel kAlpSels[8] = { + GX_TEV_KASEL_K3_A, + GX_TEV_KASEL_K3_B, + GX_TEV_KASEL_K3_G, + GX_TEV_KASEL_K3_R, + GX_TEV_KASEL_K2_A, + GX_TEV_KASEL_K2_B, + GX_TEV_KASEL_K2_G, + GX_TEV_KASEL_K2_R, + }; + u8 tevStageID = 0; + if (mGXMemNum.texMap == 0) { + GXTevStageID tevStage = GX_TEVSTAGE0; + GXSetTevOrder(tevStage, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetTevColorIn(tevStage, GX_CC_ZERO, GX_CC_C1, GX_CC_RASC, GX_CC_ZERO); + GXSetTevAlphaIn(tevStage, GX_CA_ZERO, GX_CA_A1, GX_CA_RASA, GX_CA_ZERO); + bUseRasStage = true; + tevStageID = 1; + } else { + if (mGXMemNum.texMap == 1) { + GXTevStageID tevStage = GX_TEVSTAGE0; + GXSetTevOrder(tevStage, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL); + GXSetTevColorIn(tevStage, GX_CC_C0, GX_CC_C1, GX_CC_TEXC, GX_CC_ZERO); + GXSetTevAlphaIn(tevStage, GX_CA_A0, GX_CA_A1, GX_CA_TEXA, GX_CA_ZERO); + tevStageID = 1; + } else { + if (mGXMemNum.texMap == 2) { + GXTevStageID tevStage = GX_TEVSTAGE0; + GXSetTevOrder(tevStage, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL); + GXSetTevColorIn(tevStage, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_TEXC); + GXSetTevAlphaIn(tevStage, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_TEXA); + + tevStage = GX_TEVSTAGE1; + GXSetTevOrder(tevStage, GX_TEXCOORD1, GX_TEXMAP1, GX_COLOR_NULL); + GXSetTevColorIn(tevStage, GX_CC_TEXC, GX_CC_CPREV, GX_CC_KONST, GX_CC_ZERO); + GXSetTevAlphaIn(tevStage, GX_CA_TEXA, GX_CA_APREV, GX_CA_KONST, GX_CA_ZERO); + GXSetTevKColorSel(tevStage, kColSels[0]); + GXSetTevKAlphaSel(tevStage, kAlpSels[0]); + tevStageID = 2; + + } else { + for (int i = 0; i < mGXMemNum.texMap; i++) { + GXTevStageID tevStage = (GXTevStageID)tevStageID; + GXSetTevOrder(tevStage, (GXTexCoordID)i, (GXTexMapID)i, GX_COLOR_NULL); + GXTevColorArg colDIn = i == 0 ? GX_CC_ZERO : GX_CC_CPREV; + GXTevAlphaArg alpDIn = i == 0 ? GX_CA_ZERO : GX_CA_APREV; + GXSetTevColorIn(tevStage, GX_CC_ZERO, GX_CC_TEXC, GX_CC_KONST, colDIn); + GXSetTevAlphaIn(tevStage, GX_CA_ZERO, GX_CA_TEXA, GX_CA_KONST, alpDIn); + GXSetTevKColorSel(tevStage, kColSels[i]); + GXSetTevKAlphaSel(tevStage, kAlpSels[i]); + tevStageID++; + } + } + if (mTevCols[0] != DefaultBlackColor || mTevCols[1] != DefaultWhiteColor) { + GXTevStageID tevStage = (GXTevStageID)tevStageID; + GXSetTevOrder(tevStage, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL); + GXSetTevColorIn(tevStage, GX_CC_C0, GX_CC_C1, GX_CC_CPREV, GX_CC_ZERO); + GXSetTevAlphaIn(tevStage, GX_CA_A0, GX_CA_A1, GX_CA_APREV, GX_CA_ZERO); + tevStageID++; + } + } + if (bUseRasStage) { + GXTevStageID tevStage = (GXTevStageID)tevStageID; + GXSetTevOrder(tevStage, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetTevColorIn(tevStage, GX_CC_ZERO, GX_CC_CPREV, GX_CC_RASC, GX_CC_ZERO); + GXSetTevAlphaIn(tevStage, GX_CA_ZERO, GX_CA_APREV, GX_CA_RASA, GX_CA_ZERO); + tevStageID++; + } + } + + const u8 tevStageNum = tevStageID; + + for (u8 id = 0; id < tevStageNum; id++) { + GXTevStageID tevStage = (GXTevStageID)id; + GXSetTevColorOp(tevStage, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, TRUE, GX_TEVPREV); + GXSetTevAlphaOp(tevStage, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, TRUE, GX_TEVPREV); + GXSetTevDirect(tevStage); + GXSetTevSwapMode(tevStage, GX_TEV_SWAP0, GX_TEV_SWAP0); + } + GXSetNumTevStages(tevStageNum); + } + if (bSetIndTexMtx) { + const TexSRT *indTexSRTs = GetIndTexSRTAry(); + for (int i = 0; i < mGXMemNum.indSRT; i++) { + if (bUseIndTexMtx[i]) { + f32 mtx[2][3]; + CalcIndTexMtx(mtx, indTexSRTs[i]); + SetIndTexMtx((GXIndTexMtxID)(i + 1), mtx); + } + } + } + + GXSetNumIndStages(mGXMemNum.indStage); + if (mGXMemNum.indStage != 0) { + const IndirectStage *indirectStages = GetIndirectStageAry(); + for (int i = 0; i < mGXMemNum.indStage; i++) { + GXIndTexStageID indStage = (GXIndTexStageID)i; + GXSetIndTexOrder(indStage, indirectStages[i].GetTexCoordGen(), indirectStages[i].GetTexMap()); + GXSetIndTexCoordScale(indStage, indirectStages[i].GetScaleS(), indirectStages[i].GetScaleT()); + } + } + if (IsAlphaCompareCap()) { + const AlphaCompare *pAlpComp = GetAlphaComparePtr(); + GXSetAlphaCompare(pAlpComp->GetComp0(), pAlpComp->GetRef0(), pAlpComp->GetOp(), pAlpComp->GetComp1(), + pAlpComp->GetRef1()); + } else { + GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0); + } + if (IsBlendModeCap()) { + const BlendMode *pBlendMode = GetBlendModePtr(); + GXSetBlendMode(pBlendMode->GetType(), pBlendMode->GetSrcFactor(), pBlendMode->GetDstFactor(), + pBlendMode->GetOp()); + + } else { + GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET); + } + return bUseRasStage && bUseVtxCol; } -namespace { -// GetTexMtx__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FUl -u32 GetTexMtx(u32 texMtxIdx) {} - -// GetTexMtxIdx__Q34nw4r3lyt26@unnamed@lyt_material_cpp@FUl -u32 GetTexMtxIdx(u32 texMtx) {} - -} // namespace - // BindAnimation__Q34nw4r3lyt8MaterialFPQ34nw4r3lyt13AnimTransform -void Material::BindAnimation(AnimTransform *pAnimTrans) {} +void Material::BindAnimation(AnimTransform *pAnimTrans) { + pAnimTrans->Bind(this, false); +} // UnbindAnimation__Q34nw4r3lyt8MaterialFPQ34nw4r3lyt13AnimTransform -void Material::UnbindAnimation(AnimTransform *pAnimTrans) {} +void Material::UnbindAnimation(AnimTransform *pAnimTrans) { + detail::UnbindAnimationLink(GetAnimationList(), pAnimTrans); +} // UnbindAllAnimation__Q34nw4r3lyt8MaterialFv -void Material::UnbindAllAnimation() {} +void Material::UnbindAllAnimation() { + UnbindAnimation(nullptr); +} // Animate__Q34nw4r3lyt8MaterialFv void Material::Animate() { - ut::LinkList::Iterator it; - AnimTransform *animTrans; + for (ut::LinkList::Iterator it = mAnimList.GetBeginIter(); it != mAnimList.GetEndIter(); it++) { + if (it->IsEnable()) { + AnimTransform *pAnimTrans = it->GetAnimTransform(); + pAnimTrans->Animate(it->GetIndex(), this); + } + } } // AddAnimationLink__Q34nw4r3lyt8MaterialFPQ34nw4r3lyt13AnimationLink -void Material::AddAnimationLink(AnimationLink *pAnimationLink) {} +void Material::AddAnimationLink(AnimationLink *pAnimationLink) { + mAnimList.PushBack(pAnimationLink); +} // FindAnimationLink__Q34nw4r3lyt8MaterialFPQ34nw4r3lyt13AnimTransform -AnimationLink *Material::FindAnimationLink(AnimTransform *pAnimTrans) {} +AnimationLink *Material::FindAnimationLink(AnimTransform *pAnimTrans) { + return detail::FindAnimationLink(&mAnimList, pAnimTrans); +} // FindAnimationLink__Q34nw4r3lyt8MaterialFRCQ34nw4r3lyt12AnimResource -AnimationLink *Material::FindAnimationLink(const AnimResource &animRes) {} +AnimationLink *Material::FindAnimationLink(const AnimResource &animRes) { + return detail::FindAnimationLink(&mAnimList, animRes); +} // SetAnimationEnable__Q34nw4r3lyt8MaterialFPQ34nw4r3lyt13AnimTransformb -void Material::SetAnimationEnable(AnimTransform *pAnimTrans, bool bEnable) {} +void Material::SetAnimationEnable(AnimTransform *pAnimTrans, bool bEnable) { + AnimationLink *pAnimLink = FindAnimationLink(pAnimTrans); + if (pAnimLink) { + pAnimLink->SetEnable(bEnable); + } +} // SetAnimationEnable__Q34nw4r3lyt8MaterialFRCQ34nw4r3lyt12AnimResourceb void Material::SetAnimationEnable(const AnimResource &animRes, bool bEnable) { - AnimationLink *pAnimLink; + AnimationLink *pAnimLink = FindAnimationLink(animRes); + if (pAnimLink) { + pAnimLink->SetEnable(bEnable); + } } namespace detail { // GetTextureSize__Q34nw4r3lyt6detailFPQ34nw4r3lyt8MaterialUc -Size GetTextureSize(Material *pMaterial, u8 texMapIdx) {} +Size GetTextureSize(Material *pMaterial, u8 texMapIdx) { + if (texMapIdx >= pMaterial->GetTextureNum()) { + return Size(); + } + const TexMap &texMap = pMaterial->GetTexMapAry()[texMapIdx]; + return Size(texMap.GetWidth(), texMap.GetHeight()); +} } // namespace detail } // namespace lyt } // namespace nw4r - -// INLINED FROM OTHER FILES -// ut_inlines.h -// Min__Q34nw4r2ut26@unnamed@lyt_material_cpp@Fss_s -// Max__Q34nw4r2ut26@unnamed@lyt_material_cpp@Fss_s -// Min__Q34nw4r2ut26@unnamed@lyt_material_cpp@FUcUc_Uc - -// lyt_types.h -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPCvUi_PCQ34nw4r3lyt9BlendMode -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPCvUi_PCQ34nw4r3lyt12AlphaCompare -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPCvUi_PCQ34nw4r3lyt8TevStage -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPCvUi_PCQ34nw4r3lyt13IndirectStage -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPCvUi_PCQ34nw4r3lyt11TevSwapMode -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPCvUi_PCQ34nw4r2ut5Color -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPCvUi_PCQ34nw4r3lyt8ChanCtrl -// GetBits__Q34nw4r3lyt6detailFiii_i -// GetBits__Q34nw4r3lyt6detailFUcii_Uc -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPCvUi_PCQ44nw4r3lyt3res7Texture -// GetBits
    __Q34nw4r3lyt6detailFUlii_Ul -// TestBit
      __Q34nw4r3lyt6detailFUli_b -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPCvUi_PCQ34nw4r3lyt11TexCoordGen -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPCvUi_PCQ34nw4r3lyt6TexSRT -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPCvUi_PCQ44nw4r3lyt3res6TexMap -// __ct__Q34nw4r3lyt9BlendModeFv -// Set__Q34nw4r3lyt9BlendModeF12_GXBlendMode14_GXBlendFactor14_GXBlendFactor10_GXLogicOp -// __ct__Q34nw4r3lyt12AlphaCompareFv -// Set__Q34nw4r3lyt12AlphaCompareF10_GXCompareUc10_GXAlphaOp10_GXCompareUc -// Set__Q34nw4r3lyt11TevSwapModeF15_GXTevColorChan15_GXTevColorChan15_GXTevColorChan15_GXTevColorChan -// __ct__Q34nw4r3lyt8ChanCtrlFv -// Set__Q34nw4r3lyt8ChanCtrlF11_GXColorSrc11_GXColorSrc -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPvUi_PQ34nw4r3lyt6TexMap -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPvUi_PQ34nw4r3lyt6TexSRT -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPvUi_PQ34nw4r3lyt11TexCoordGen -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPvUi_PQ34nw4r3lyt8ChanCtrl -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPvUi_PQ34nw4r2ut5Color -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPvUi_PQ34nw4r3lyt11TevSwapMode -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPvUi_PQ34nw4r3lyt12AlphaCompare -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPvUi_PQ34nw4r3lyt9BlendMode -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPvUi_PQ34nw4r3lyt13IndirectStage -// ConvertOffsToPtr__Q34nw4r3lyt6detailFPvUi_PQ34nw4r3lyt8TevStage -// __ct__Q34nw4r3lyt8TevStageFv -// SetIndirect__Q34nw4r3lyt8TevStageF16_GXIndTexStageID15_GXIndTexFormat16_GXIndTexBiasSel14_GXIndTexMtxID13_GXIndTexWrap13_GXIndTexWrapbb17_GXIndTexAlphaSel -// SetAlphaOp__Q34nw4r3lyt8TevStageF8_GXTevOp10_GXTevBias11_GXTevScaleb11_GXTevRegID15_GXTevKAlphaSel -// SetOp__Q34nw4r3lyt12TevStageInOpFUcUcUcbUcUc -// SetColorOp__Q34nw4r3lyt8TevStageF8_GXTevOp10_GXTevBias11_GXTevScaleb11_GXTevRegID15_GXTevKColorSel -// SetAlphaIn__Q34nw4r3lyt8TevStageF14_GXTevAlphaArg14_GXTevAlphaArg14_GXTevAlphaArg14_GXTevAlphaArg -// SetIn__Q34nw4r3lyt12TevStageInOpFUcUcUcUc -// SetColorIn__Q34nw4r3lyt8TevStageF14_GXTevColorArg14_GXTevColorArg14_GXTevColorArg14_GXTevColorArg -// SetOrder__Q34nw4r3lyt8TevStageF13_GXTexCoordID11_GXTexMapID12_GXChannelID13_GXTevSwapSel13_GXTevSwapSel -// __ct__Q34nw4r3lyt13IndirectStageFv -// Set__Q34nw4r3lyt13IndirectStageF13_GXTexCoordID11_GXTexMapID14_GXIndTexScale14_GXIndTexScale -// GetOp__Q34nw4r3lyt9BlendModeCFv -// GetDstFactor__Q34nw4r3lyt9BlendModeCFv -// GetSrcFactor__Q34nw4r3lyt9BlendModeCFv -// GetType__Q34nw4r3lyt9BlendModeCFv -// GetRef1__Q34nw4r3lyt12AlphaCompareCFv -// GetComp1__Q34nw4r3lyt12AlphaCompareCFv -// GetOp__Q34nw4r3lyt12AlphaCompareCFv -// GetRef0__Q34nw4r3lyt12AlphaCompareCFv -// GetComp0__Q34nw4r3lyt12AlphaCompareCFv -// GetScaleT__Q34nw4r3lyt13IndirectStageCFv -// GetScaleS__Q34nw4r3lyt13IndirectStageCFv -// GetTexMap__Q34nw4r3lyt13IndirectStageCFv -// GetTexCoordGen__Q34nw4r3lyt13IndirectStageCFv -// GetIndAlphaSel__Q34nw4r3lyt8TevStageCFv -// IsIndUtcLod__Q34nw4r3lyt8TevStageCFv -// IsIndAddPrev__Q34nw4r3lyt8TevStageCFv -// GetIndWrapT__Q34nw4r3lyt8TevStageCFv -// GetIndWrapS__Q34nw4r3lyt8TevStageCFv -// GetIndBiasSel__Q34nw4r3lyt8TevStageCFv -// GetIndFormat__Q34nw4r3lyt8TevStageCFv -// GetIndStage__Q34nw4r3lyt8TevStageCFv -// GetIndMtxSel__Q34nw4r3lyt8TevStageCFv -// GetKAlphaSel__Q34nw4r3lyt8TevStageCFv -// GetKSel__Q34nw4r3lyt12TevStageInOpCFv -// GetAlphaOutReg__Q34nw4r3lyt8TevStageCFv -// GetOutReg__Q34nw4r3lyt12TevStageInOpCFv -// IsAlphaClamp__Q34nw4r3lyt8TevStageCFv -// IsClamp__Q34nw4r3lyt12TevStageInOpCFv -// GetAlphaScale__Q34nw4r3lyt8TevStageCFv -// GetScale__Q34nw4r3lyt12TevStageInOpCFv -// GetAlphaBias__Q34nw4r3lyt8TevStageCFv -// GetBias__Q34nw4r3lyt12TevStageInOpCFv -// GetAlphaOp__Q34nw4r3lyt8TevStageCFv -// GetOp__Q34nw4r3lyt12TevStageInOpCFv -// GetAlphaInD__Q34nw4r3lyt8TevStageCFv -// GetD__Q34nw4r3lyt12TevStageInOpCFv -// GetAlphaInC__Q34nw4r3lyt8TevStageCFv -// GetC__Q34nw4r3lyt12TevStageInOpCFv -// GetAlphaInB__Q34nw4r3lyt8TevStageCFv -// GetB__Q34nw4r3lyt12TevStageInOpCFv -// GetAlphaInA__Q34nw4r3lyt8TevStageCFv -// GetA__Q34nw4r3lyt12TevStageInOpCFv -// GetKColorSel__Q34nw4r3lyt8TevStageCFv -// GetColorOutReg__Q34nw4r3lyt8TevStageCFv -// IsColorClamp__Q34nw4r3lyt8TevStageCFv -// GetColorScale__Q34nw4r3lyt8TevStageCFv -// GetColorBias__Q34nw4r3lyt8TevStageCFv -// GetColorOp__Q34nw4r3lyt8TevStageCFv -// GetColorInD__Q34nw4r3lyt8TevStageCFv -// GetColorInC__Q34nw4r3lyt8TevStageCFv -// GetColorInB__Q34nw4r3lyt8TevStageCFv -// GetColorInA__Q34nw4r3lyt8TevStageCFv -// GetTexSwapSel__Q34nw4r3lyt8TevStageCFv -// GetRasSwapSel__Q34nw4r3lyt8TevStageCFv -// GetColorChan__Q34nw4r3lyt8TevStageCFv -// GetTexMap__Q34nw4r3lyt8TevStageCFv -// GetTexCoordGen__Q34nw4r3lyt8TevStageCFv -// GetA__Q34nw4r3lyt11TevSwapModeCFv -// GetB__Q34nw4r3lyt11TevSwapModeCFv -// GetG__Q34nw4r3lyt11TevSwapModeCFv -// GetR__Q34nw4r3lyt11TevSwapModeCFv diff --git a/src/nw4r/lyt/lyt_pane.cpp b/src/nw4r/lyt/lyt_pane.cpp index 58ad61a2..02b26c4f 100644 --- a/src/nw4r/lyt/lyt_pane.cpp +++ b/src/nw4r/lyt/lyt_pane.cpp @@ -512,15 +512,15 @@ u16 Pane::GetExtUserDataNum() const { } return 0; } -res::ExtUserData *Pane::GetExtUserData() const { +const res::ExtUserData *Pane::GetExtUserData() const { if (this->mpExtUserDataList) { return detail::ConvertOffsToPtr(this->mpExtUserDataList, sizeof(res::ExtUserDataList)); } return nullptr; } -res::ExtUserData *Pane::FindExtUserDataByName(const char *name) { - res::ExtUserData *pUserData = GetExtUserData(); +const res::ExtUserData *Pane::FindExtUserDataByName(const char *name) { + const res::ExtUserData *pUserData = GetExtUserData(); if (!pUserData) { return nullptr;