Skip to content

Commit c31d6da

Browse files
authored
Implement GX_TF_C14X2 conversion (#222)
1 parent caf21ab commit c31d6da

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

lib/gfx/texture_convert.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,17 @@ struct TextureDecoderC8 {
315315
static void decode_texel(Target* target, const Source* in, const uint32_t x) { target[x] = in[x]; }
316316
};
317317

318+
struct TextureDecoderC14X2 {
319+
using Source = uint16_t;
320+
using Target = uint16_t;
321+
322+
static constexpr uint32_t Frac = 1;
323+
static constexpr uint32_t BlockWidth = 4;
324+
static constexpr uint32_t BlockHeight = 4;
325+
326+
static void decode_texel(Target* target, const Source* in, const uint32_t x) { target[x] = bswap(in[x]) & 0x3fff; }
327+
};
328+
318329
struct TextureDecoderRGB565 {
319330
using Source = uint16_t;
320331
using Target = RGBA8;
@@ -603,7 +614,8 @@ ConvertedTexture convert_texture(u32 format, uint32_t width, uint32_t height, ui
603614
converted = DecodeTiled<TextureDecoderC8>(width, height, mips, data);
604615
break;
605616
case GX_TF_C14X2:
606-
FATAL("convert_texture: C14X2 unimplemented");
617+
converted = DecodeTiled<TextureDecoderC14X2>(width, height, mips, data);
618+
break;
607619
case GX_TF_RGB565:
608620
converted = DecodeTiled<TextureDecoderRGB565>(width, height, mips, data);
609621
break;

0 commit comments

Comments
 (0)