Fix CColor Get*u8 functions

This commit is contained in:
Luke Street 2022-10-09 01:44:19 -04:00
parent 133326ae40
commit 4d40ca80d8
3 changed files with 19 additions and 19 deletions

View File

@ -36,10 +36,10 @@ public:
float GetGreen() const { return CCast::ToReal32(mG) * (1 / 255.f); } float GetGreen() const { return CCast::ToReal32(mG) * (1 / 255.f); }
float GetBlue() const { return CCast::ToReal32(mB) * (1 / 255.f); } float GetBlue() const { return CCast::ToReal32(mB) * (1 / 255.f); }
float GetAlpha() const { return CCast::ToReal32(mA) * (1 / 255.f); } float GetAlpha() const { return CCast::ToReal32(mA) * (1 / 255.f); }
uchar GetReduchar() const { return mR; } uchar GetRedu8() const { return mR; }
uchar GetGreenuchar() const { return mG; } uchar GetGreenu8() const { return mG; }
uchar GetBlueuchar() const { return mB; } uchar GetBlueu8() const { return mB; }
uchar GetAlphauchar() const { return mA; } uchar GetAlphau8() const { return mA; }
ushort ToRGB5A3() const; ushort ToRGB5A3() const;
GXColor ToGX(uint); GXColor ToGX(uint);

View File

@ -68,24 +68,24 @@ uint CColor::Lerp(uint a, uint b, float t) {
} }
CColor CColor::Modulate(const CColor& a, const CColor& b) { CColor CColor::Modulate(const CColor& a, const CColor& b) {
return CColor((uchar)((a.GetReduchar() * b.GetReduchar()) / (uchar)255), return CColor((uchar)((a.GetRedu8() * b.GetRedu8()) / (uchar)255),
(a.GetGreenuchar() * b.GetGreenuchar()) / (uchar)255, (a.GetGreenu8() * b.GetGreenu8()) / (uchar)255,
(a.GetBlueuchar() * b.GetBlueuchar()) / (uchar)255, (a.GetBlueu8() * b.GetBlueu8()) / (uchar)255,
(a.GetAlphauchar() * b.GetAlphauchar()) / (uchar)255); (a.GetAlphau8() * b.GetAlphau8()) / (uchar)255);
} }
CColor CColor::Add(const CColor& arg0, const CColor& arg1) { CColor CColor::Add(const CColor& arg0, const CColor& arg1) {
return CColor((uchar)rstl::min_val< uint >(255, arg0.GetReduchar() + arg1.GetReduchar()), return CColor((uchar)rstl::min_val< uint >(255, arg0.GetRedu8() + arg1.GetRedu8()),
(uchar)rstl::min_val< uint >(255, arg0.GetGreenuchar() + arg1.GetGreenuchar()), (uchar)rstl::min_val< uint >(255, arg0.GetGreenu8() + arg1.GetGreenu8()),
(uchar)rstl::min_val< uint >(255, arg0.GetBlueuchar() + arg1.GetBlueuchar()), (uchar)rstl::min_val< uint >(255, arg0.GetBlueu8() + arg1.GetBlueu8()),
(uchar)rstl::min_val< uint >(255, arg0.GetAlphauchar() + arg1.GetAlphauchar())); (uchar)rstl::min_val< uint >(255, arg0.GetAlphau8() + arg1.GetAlphau8()));
} }
ushort CColor::ToRGB5A3() const { ushort CColor::ToRGB5A3() const {
uchar r = GetReduchar(); uchar r = GetRedu8();
uchar g = GetGreenuchar(); uchar g = GetGreenu8();
uchar b = GetBlueuchar(); uchar b = GetBlueu8();
uchar a = GetAlphauchar(); uchar a = GetAlphau8();
ushort ret = (1 << 15) | ((b & 0xf8) >> 3) | ((g & 0xf8) << 2) | ((r & 0xf8) << 7); ushort ret = (1 << 15) | ((b & 0xf8) >> 3) | ((g & 0xf8) << 2) | ((r & 0xf8) << 7);
if (a != 0xFF) { if (a != 0xFF) {
ret = ((a & 0xe0) << 7) | ((b & 0xf0) >> 4) | (g & 0xf0) | ((r & 0xf0) << 4); ret = ((a & 0xe0) << 7) | ((b & 0xf0) >> 4) | (g & 0xf0) | ((r & 0xf0) << 4);

View File

@ -368,9 +368,9 @@ void CActor::RenderInternal(const CStateManager& mgr) const {
addMag = 255; addMag = 255;
} }
const uchar rgb = mulMag * xb4_drawFlags.GetColor().GetAlphauchar(); const uchar rgb = mulMag * xb4_drawFlags.GetColor().GetAlphau8();
CColor mulColor(rgb, rgb, rgb, xb4_drawFlags.GetColor().GetAlphauchar()); CColor mulColor(rgb, rgb, rgb, xb4_drawFlags.GetColor().GetAlphau8());
CColor addColor(addMag, addMag, addMag, xb4_drawFlags.GetColor().GetAlphauchar() / 4); CColor addColor(addMag, addMag, addMag, xb4_drawFlags.GetColor().GetAlphau8() / 4);
GetModelData()->RenderThermal(x34_transform, mulColor, addColor, xb4_drawFlags); GetModelData()->RenderThermal(x34_transform, mulColor, addColor, xb4_drawFlags);
return; return;
} else if (mgr.GetThermalColdScale2() > 0.0001f && xb4_drawFlags.GetTrans() == 0) { } else if (mgr.GetThermalColdScale2() > 0.0001f && xb4_drawFlags.GetTrans() == 0) {