From f0e2db19ea894f2ad686456bbaafe67b5c2256d6 Mon Sep 17 00:00:00 2001 From: wheremyfoodat Date: Mon, 6 Mar 2023 21:52:36 +0200 Subject: [PATCH] [PICA] Implement I4 textures --- src/core/renderer_gl/textures.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/core/renderer_gl/textures.cpp b/src/core/renderer_gl/textures.cpp index a48bf602..6c42bfd4 100644 --- a/src/core/renderer_gl/textures.cpp +++ b/src/core/renderer_gl/textures.cpp @@ -176,6 +176,18 @@ u32 Texture::decodeTexel(u32 u, u32 v, Texture::Formats fmt, const void* data) { return (alpha << 24) | (0 << 16) | (0 << 8) | 0; } + case Formats::I4: { + u32 offset = getSwizzledOffset_4bpp(u, v, size.u()); + auto ptr = static_cast(data); + + // For odd U coordinates, grab the top 4 bits, and the low 4 bits for even coordinates + u8 intensity = ptr[offset] >> ((u % 2) ? 4 : 0); + intensity = Colour::convert4To8Bit(intensity & 0xf); + + // Intensity formats just copy the intensity value to every colour channel + return (0xff << 24) | (intensity << 16) | (intensity << 8) | intensity; + } + case Formats::I8: { u32 offset = getSwizzledOffset(u, v, size.u(), 1); auto ptr = static_cast(data);