From 4d40ca80d88370b269c14a3f5ca498e2a12f1c29 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sun, 9 Oct 2022 01:44:19 -0400 Subject: [PATCH] Fix CColor Get*u8 functions --- include/Kyoto/Graphics/CColor.hpp | 8 ++++---- src/Kyoto/Graphics/DolphinCColor.cpp | 24 ++++++++++++------------ src/MetroidPrime/CActor.cpp | 6 +++--- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/Kyoto/Graphics/CColor.hpp b/include/Kyoto/Graphics/CColor.hpp index 91327df6..ed4b728b 100644 --- a/include/Kyoto/Graphics/CColor.hpp +++ b/include/Kyoto/Graphics/CColor.hpp @@ -36,10 +36,10 @@ public: float GetGreen() const { return CCast::ToReal32(mG) * (1 / 255.f); } float GetBlue() const { return CCast::ToReal32(mB) * (1 / 255.f); } float GetAlpha() const { return CCast::ToReal32(mA) * (1 / 255.f); } - uchar GetReduchar() const { return mR; } - uchar GetGreenuchar() const { return mG; } - uchar GetBlueuchar() const { return mB; } - uchar GetAlphauchar() const { return mA; } + uchar GetRedu8() const { return mR; } + uchar GetGreenu8() const { return mG; } + uchar GetBlueu8() const { return mB; } + uchar GetAlphau8() const { return mA; } ushort ToRGB5A3() const; GXColor ToGX(uint); diff --git a/src/Kyoto/Graphics/DolphinCColor.cpp b/src/Kyoto/Graphics/DolphinCColor.cpp index e74bdbf4..42fe26eb 100644 --- a/src/Kyoto/Graphics/DolphinCColor.cpp +++ b/src/Kyoto/Graphics/DolphinCColor.cpp @@ -68,24 +68,24 @@ uint CColor::Lerp(uint a, uint b, float t) { } CColor CColor::Modulate(const CColor& a, const CColor& b) { - return CColor((uchar)((a.GetReduchar() * b.GetReduchar()) / (uchar)255), - (a.GetGreenuchar() * b.GetGreenuchar()) / (uchar)255, - (a.GetBlueuchar() * b.GetBlueuchar()) / (uchar)255, - (a.GetAlphauchar() * b.GetAlphauchar()) / (uchar)255); + return CColor((uchar)((a.GetRedu8() * b.GetRedu8()) / (uchar)255), + (a.GetGreenu8() * b.GetGreenu8()) / (uchar)255, + (a.GetBlueu8() * b.GetBlueu8()) / (uchar)255, + (a.GetAlphau8() * b.GetAlphau8()) / (uchar)255); } CColor CColor::Add(const CColor& arg0, const CColor& arg1) { - return CColor((uchar)rstl::min_val< uint >(255, arg0.GetReduchar() + arg1.GetReduchar()), - (uchar)rstl::min_val< uint >(255, arg0.GetGreenuchar() + arg1.GetGreenuchar()), - (uchar)rstl::min_val< uint >(255, arg0.GetBlueuchar() + arg1.GetBlueuchar()), - (uchar)rstl::min_val< uint >(255, arg0.GetAlphauchar() + arg1.GetAlphauchar())); + return CColor((uchar)rstl::min_val< uint >(255, arg0.GetRedu8() + arg1.GetRedu8()), + (uchar)rstl::min_val< uint >(255, arg0.GetGreenu8() + arg1.GetGreenu8()), + (uchar)rstl::min_val< uint >(255, arg0.GetBlueu8() + arg1.GetBlueu8()), + (uchar)rstl::min_val< uint >(255, arg0.GetAlphau8() + arg1.GetAlphau8())); } ushort CColor::ToRGB5A3() const { - uchar r = GetReduchar(); - uchar g = GetGreenuchar(); - uchar b = GetBlueuchar(); - uchar a = GetAlphauchar(); + uchar r = GetRedu8(); + uchar g = GetGreenu8(); + uchar b = GetBlueu8(); + uchar a = GetAlphau8(); ushort ret = (1 << 15) | ((b & 0xf8) >> 3) | ((g & 0xf8) << 2) | ((r & 0xf8) << 7); if (a != 0xFF) { ret = ((a & 0xe0) << 7) | ((b & 0xf0) >> 4) | (g & 0xf0) | ((r & 0xf0) << 4); diff --git a/src/MetroidPrime/CActor.cpp b/src/MetroidPrime/CActor.cpp index 58eeadb5..a5702947 100644 --- a/src/MetroidPrime/CActor.cpp +++ b/src/MetroidPrime/CActor.cpp @@ -368,9 +368,9 @@ void CActor::RenderInternal(const CStateManager& mgr) const { addMag = 255; } - const uchar rgb = mulMag * xb4_drawFlags.GetColor().GetAlphauchar(); - CColor mulColor(rgb, rgb, rgb, xb4_drawFlags.GetColor().GetAlphauchar()); - CColor addColor(addMag, addMag, addMag, xb4_drawFlags.GetColor().GetAlphauchar() / 4); + const uchar rgb = mulMag * xb4_drawFlags.GetColor().GetAlphau8(); + CColor mulColor(rgb, rgb, rgb, xb4_drawFlags.GetColor().GetAlphau8()); + CColor addColor(addMag, addMag, addMag, xb4_drawFlags.GetColor().GetAlphau8() / 4); GetModelData()->RenderThermal(x34_transform, mulColor, addColor, xb4_drawFlags); return; } else if (mgr.GetThermalColdScale2() > 0.0001f && xb4_drawFlags.GetTrans() == 0) {