summaryrefslogtreecommitdiff
path: root/include/rvl/TPL/TPL.h
blob: 7669f4cda91237b60fa972c9618c8ac7e8bf08b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef RVL_SDK_TPL_H
#define RVL_SDK_TPL_H
#include "common.h"
#include "rvl/GX.h" // IWYU pragma: export


#ifdef __cplusplus
extern "C" {
#endif

/**
 * Documentation from:
 * https://github.com/soopercool101/BrawlCrate/blob/master/BrawlLib/SSBB/Types/TPL.cs
 * https://wiki.tockdom.com/wiki/TPL_(File_Format)
 * DWARF debugging info
 */

typedef struct TPLHeader {
    u16 height;          // at 0x0
    u16 width;           // at 0x2
    u32 format;          // at 0x4
    char *data;          // at 0x8
    GXTexWrapMode wrapS; // at 0xC
    GXTexWrapMode wrapT; // at 0x10
    GXTexFilter minFilt; // at 0x14
    GXTexFilter magFilt; // at 0x18
    f32 lodBias;         // at 0x1C
    u8 edgeLodEnable;    // at 0x20
    u8 minLod;           // at 0x21
    u8 maxLod;           // at 0x22
    u8 unpacked;         // at 0x23
} TPLHeader;

typedef struct TPLClutHeader {
    u16 numEntries;   // at 0x0
    u8 unpacked;      // at 0x1
    u8 padding;       // at 0x2
    GXTlutFmt format; // at 0x4
    char *data;       // at 0x8
} TPLClutHeader;

typedef struct TPLDescriptor {
    TPLHeader *texHeader;      // at 0x0
    TPLClutHeader *clutHeader; // at 0x4
} TPLDescriptor;

typedef struct TPLPalette {
    u32 version;                // at 0x0
    u32 numImages;              // at 0x4
    TPLDescriptor *descriptors; // at 0x8
} TPLPalette;

void TPLBind(TPLPalette *pal);
TPLDescriptor *TPLGet(TPLPalette *pal, u32 id);

#ifdef __cplusplus
}
#endif
#endif