diff --git a/src/video_core/color.h b/src/video_core/color.h index 4d2026eb0..229ae4375 100644 --- a/src/video_core/color.h +++ b/src/video_core/color.h @@ -69,6 +69,16 @@ inline const Math::Vec4 DecodeRGB8(const u8* bytes) { return { bytes[2], bytes[1], bytes[0], 255 }; } +/** + * Decode a color stored in HILO8 format + * @remark HILO8 is not intended to store colors, the word color here is used just for consistency, HILO8 is a format intended for normal maps. + * @param bytes Pointer to encoded source color + * @return Result color decoded as Math::Vec4 + */ +inline const Math::Vec4 DecodeHILO8(const u8* bytes) { + return { bytes[0], bytes[1], 0, 255 }; +} + /** * Decode a color stored in RGB565 format * @param bytes Pointer to encoded source color @@ -152,6 +162,16 @@ inline void EncodeRGB8(const Math::Vec4& color, u8* bytes) { bytes[0] = color.b(); } +/** + * Encode a color as HILO8 format + * @remark HILO8 is not intended to store colors, the word color here is used just for consistency, HILO8 is a format intended for normal maps. + * @param color Source color to encode + * @param bytes Destination pointer to store encoded color + */ +inline void EncodeHILO8(const Math::Vec4& color, u8* bytes) { + bytes[0] = color.r(); + bytes[1] = color.g(); +} /** * Encode a color as RGB565 format * @param color Source color to encode diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 883df48a5..4c9443ab0 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp @@ -361,6 +361,12 @@ const Math::Vec4 LookupTexture(const u8* source, int x, int y, const Texture } } + case Regs::TextureFormat::HILO8: + { + auto res = Color::DecodeHILO8(source + VideoCore::GetMortonOffset(x, y, 2)); + return { res.r(), res.g(), 0, 255 }; + } + case Regs::TextureFormat::I8: { const u8* source_ptr = source + VideoCore::GetMortonOffset(x, y, 1); diff --git a/src/video_core/pica.h b/src/video_core/pica.h index a53429716..86f3ada07 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h @@ -152,7 +152,7 @@ struct Regs { RGB565 = 3, RGBA4 = 4, IA8 = 5, - + HILO8 = 6, I8 = 7, A8 = 8, IA4 = 9, @@ -174,6 +174,7 @@ struct Regs { case TextureFormat::RGB565: case TextureFormat::RGBA4: case TextureFormat::IA8: + case TextureFormat::HILO8: return 4; case TextureFormat::A4: