1 /*---------------------------------------------------------------------------*
2   Project:  TPL data access library
3   File:     TPL.h
4 
5   Copyright 2005 Nintendo.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12  *---------------------------------------------------------------------------*/
13 
14 /*---------------------------------------------------------------------------*
15   This TPL library provides a simple interface for TPL files, which used
16   to be the texture data format for the character pipeline in the Nintendo GameCube
17   software development kit.
18   This file also contains wrapper definitions for the conventional TEX API in
19   the new library.
20  *---------------------------------------------------------------------------*/
21 
22 #ifndef TPL_H
23 #define TPL_H
24 
25 /*---------------------------------------------------------------------------*/
26 #include <revolution/gx/GXTexture.h>
27 #include <revolution/os.h>
28 #include <revolution/dvd.h>
29 
30 // Macros for conventional character pipeline functions
31 #ifdef  COMPATIBLE_OLD_TEXPALETTE
32 
33 #define TEXPalettePtr       TPLPalettePtr
34 #define TEXDescriptorPtr    TPLDescriptorPtr
35 #define TEXGetPalette       TPLGetPalette
36 #define TEXReleasePalette   TPLReleasePalette
37 #define TEXGet              TPLGet
38 
39 #define TEXGetGXTexObjFromPalette   TPLGetGXTexObjFromPalette
40 #define TEXGetGXTexObjFromPaletteCI TPLGetGXTexObjFromPaletteCI
41 
42 #endif
43 
44 /*---------------------------------------------------------------------------*/
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 /*---------------------------------------------------------------------------*
50     Structure definitions
51  *---------------------------------------------------------------------------*/
52 typedef struct
53 {
54     u16             numEntries;
55     u8              unpacked;
56     u8              pad8;
57 
58     GXTlutFmt       format;
59     Ptr             data;
60 
61 } TPLClutHeader, *TPLClutHeaderPtr;
62 
63 /*---------------------------------------------------------------------------*/
64 typedef struct
65 {
66     u16             height;
67     u16             width;
68 
69     u32             format;
70     Ptr             data;
71 
72     GXTexWrapMode   wrapS;
73     GXTexWrapMode   wrapT;
74 
75     GXTexFilter     minFilter;
76     GXTexFilter     magFilter;
77 
78     float           LODBias;
79 
80     u8              edgeLODEnable;
81     u8              minLOD;
82     u8              maxLOD;
83     u8              unpacked;
84 
85 } TPLHeader, *TPLHeaderPtr;
86 
87 /*---------------------------------------------------------------------------*/
88 typedef struct
89 {
90     TPLHeaderPtr        textureHeader;
91     TPLClutHeaderPtr    CLUTHeader;
92 
93 } TPLDescriptor, *TPLDescriptorPtr;
94 
95 /*---------------------------------------------------------------------------*/
96 typedef struct
97 {
98     u32                 versionNumber;
99 
100     u32                 numDescriptors;
101     TPLDescriptorPtr    descriptorArray;
102 
103 } TPLPalette, *TPLPalettePtr;
104 
105 /*---------------------------------------------------------------------------*
106     Function prototypes
107  *---------------------------------------------------------------------------*/
108 void                TPLBind         ( TPLPalettePtr pal );
109 TPLDescriptorPtr    TPLGet          ( TPLPalettePtr pal, u32 id );
110 
111 void TPLGetGXTexObjFromPalette      ( TPLPalettePtr pal, GXTexObj *to, u32 id );
112 void TPLGetGXTexObjFromPaletteCI    ( TPLPalettePtr pal, GXTexObj *to,
113                                       GXTlutObj *tlo, GXTlut tluts, u32 id );
114 
115 
116 
117 /*---------------------------------------------------------------------------*/
118 #ifdef __cplusplus
119 }
120 #endif
121 
122 #endif
123