summaryrefslogtreecommitdiff
path: root/include/rvl/tpl.h
blob: 9e68fac7c86590b938680f39b6d10eb376ab17fc (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*---------------------------------------------------------------------------*
  This TPL library provides a simple interface for TPL files, which used
  to be the texture data format for the character pipeline in the Nintendo GameCube
  software development kit.
  This file also contains wrapper definitions for the conventional TEX API in
  the new library.
 *---------------------------------------------------------------------------*/

#ifndef TPL_H
#define TPL_H

/*---------------------------------------------------------------------------*/
#include "rvl/GXTexture.h"

// Macros for conventional character pipeline functions
#ifdef  COMPATIBLE_OLD_TEXPALETTE

#define TEXPalettePtr       TPLPalettePtr
#define TEXDescriptorPtr    TPLDescriptorPtr
#define TEXGetPalette       TPLGetPalette
#define TEXReleasePalette   TPLReleasePalette
#define TEXGet              TPLGet

#define TEXGetGXTexObjFromPalette   TPLGetGXTexObjFromPalette
#define TEXGetGXTexObjFromPaletteCI TPLGetGXTexObjFromPaletteCI

#endif

/*---------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif

/*---------------------------------------------------------------------------*
    Structure definitions
 *---------------------------------------------------------------------------*/
typedef struct
{
    u16             numEntries;
    u8              unpacked;
    u8              pad8;

    GXTlutFmt       format;
    Ptr             data;

} TPLClutHeader, *TPLClutHeaderPtr;

/*---------------------------------------------------------------------------*/
typedef struct
{
    u16             height;
    u16             width;

    u32             format;
    Ptr             data;

    GXTexWrapMode   wrapS;
    GXTexWrapMode   wrapT;

    GXTexFilter     minFilter;
    GXTexFilter     magFilter;

    float           LODBias;

    u8              edgeLODEnable;
    u8              minLOD;
    u8              maxLOD;
    u8              unpacked;

} TPLHeader, *TPLHeaderPtr;

/*---------------------------------------------------------------------------*/
typedef struct
{
    TPLHeaderPtr        textureHeader;
    TPLClutHeaderPtr    CLUTHeader;

} TPLDescriptor, *TPLDescriptorPtr;

/*---------------------------------------------------------------------------*/
typedef struct
{
    u32                 versionNumber;

    u32                 numDescriptors;
    TPLDescriptorPtr    descriptorArray;

} TPLPalette, *TPLPalettePtr;

/*---------------------------------------------------------------------------*
    Function prototypes
 *---------------------------------------------------------------------------*/
void                TPLBind         ( TPLPalettePtr pal );
TPLDescriptorPtr    TPLGet          ( TPLPalettePtr pal, u32 id );

void TPLGetGXTexObjFromPalette      ( TPLPalettePtr pal, GXTexObj *to, u32 id );
void TPLGetGXTexObjFromPaletteCI    ( TPLPalettePtr pal, GXTexObj *to,
                                      GXTlutObj *tlo, GXTlut tluts, u32 id );



/*---------------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif

#endif