summaryrefslogtreecommitdiff
path: root/arm9/lib/include/NNS_g2d.h
blob: 722f476752f1b9ffb30d51e7451c2616a2e2cd4e (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#ifndef NNSYS_NNS_G2D_H
#define NNSYS_NNS_G2D_H
#include "gx.h"

typedef struct NNSG2dCharacterData
{

    u16                             H;
    u16                             W;

    GXTexFmt                        pixelFmt;    // GXTexFmt

    GXOBJVRamModeChar               mapingType;  // GXOBJVRamModeChar
    u32                             characterFmt;// 31 ..... 10 ...........9 8 ................ 0
    //     Reserved  VramTransfer   NNSG2dCharacterFmt
    u32                             szByte;
    void*                           pRawData;  // offset addr of the content.

}
NNSG2dCharacterData;

typedef struct NNSG2dScreenData
{

    u16     screenWidth;    // screen width (pixels) of rawData
    u16     screenHeight;   // screen height (pixels) of rawData
    u16     colorMode;      // character data color mode
    u16     screenFormat;   // screen data format
    u32     szByte;         // size of rawData
    u32     rawData[1];     // screen data (variable length)

}
NNSG2dScreenData;

typedef struct NNSG2dPaletteData
{

    GXTexFmt            fmt;
    BOOL                bExtendedPlt;

    u32                 szByte;
    void*               pRawData;          // offset addr of the content.

}
NNSG2dPaletteData;

typedef enum NNS_G2D_VRAM_TYPE
{
    NNS_G2D_VRAM_TYPE_3DMAIN = 0,
    NNS_G2D_VRAM_TYPE_2DMAIN = 1,
    NNS_G2D_VRAM_TYPE_2DSUB  = 2,
    NNS_G2D_VRAM_TYPE_MAX    = 3

} NNS_G2D_VRAM_TYPE;

typedef enum NNSG2dCharacterDataMapingType
{
    NNS_G2D_CHARACTERMAPING_1D_32,
    NNS_G2D_CHARACTERMAPING_1D_64,
    NNS_G2D_CHARACTERMAPING_1D_128,
    NNS_G2D_CHARACTERMAPING_1D_256,
    NNS_G2D_CHARACTERMAPING_2D,
    NNS_G2D_CHARACTERMAPING_MAX

} NNSG2dCharacterDataMapingType;

typedef struct NNSG2dImageAttr
{
    GXTexSizeS                      sizeS;          // Image size (Invalid data is set during 1D mapping.)
    GXTexSizeT                      sizeT;          // Image size (Invalid data is set during 1D mapping.)

    GXTexFmt                        fmt;            // Image format
    BOOL                            bExtendedPlt;   // Whether or not to use the extended palette

    GXTexPlttColor0                 plttUse;        // How to use palette number 0
    GXOBJVRamModeChar               mappingType;    // Mapping mode
}
NNSG2dImageAttr;

typedef struct NNSG2dVRamLocation
{
    u32                 baseAddrOfVram[ NNS_G2D_VRAM_TYPE_MAX ];
}
NNSG2dVRamLocation;

typedef struct NNSG2dImageProxy
{
    NNSG2dVRamLocation        vramLocation;
    NNSG2dImageAttr           attr;
}
NNSG2dImageProxy;

typedef struct NNSG2dPaletteCompressInfo
{
    u16               numPalette;
    u16               pad16;
    void*             pPlttIdxTbl;        // offset addr.

}
NNSG2dPaletteCompressInfo;

void NNS_G2dLoadImage1DMapping
(
    const NNSG2dCharacterData*  pSrcData,
    u32                         baseAddr,
    NNS_G2D_VRAM_TYPE           type,
    NNSG2dImageProxy*           pImgProxy
);

void NNS_G2dLoadImage2DMapping
(
    const NNSG2dCharacterData*  pSrcData,
    u32                         baseAddr,
    NNS_G2D_VRAM_TYPE           type,
    NNSG2dImageProxy*           pImgProxy
);

typedef struct NNSG2dImagePaletteProxy
{

    GXTexFmt                  fmt;          // palette format
    // (Obtainable values are limited to GX_TEXFMT_PLTT16 and GX_TEXFMT_PLTT256)

    BOOL                      bExtendedPlt; // Use expanded palette?

    NNSG2dVRamLocation        vramLocation;
}
NNSG2dImagePaletteProxy;

void NNS_G2dLoadPalette
(
    const NNSG2dPaletteData*    pSrcData,
    u32                         addr,
    NNS_G2D_VRAM_TYPE           type,
    NNSG2dImagePaletteProxy*    pPltProxy
);

void NNS_G2dLoadPaletteEx
(
    const NNSG2dPaletteData*            pSrcData,
    const NNSG2dPaletteCompressInfo*    pCmpInfo,
    u32                                 addr,
    NNS_G2D_VRAM_TYPE                   type,
    NNSG2dImagePaletteProxy*            pPltProxy
);

typedef struct NNSG2dCellVramTransferData
{
    u32        srcDataOffset;
    u32        szByte;

}
NNSG2dCellVramTransferData;

typedef struct NNSG2dVramTransferData
{
    u32                                 szByteMax;             // Maximum byte count during all VRAM transfers
    NNSG2dCellVramTransferData*         pCellTransferDataArray;// This is the length of the numCells amount of the maintained NNSG2dCellDataBank.
    //

}
NNSG2dVramTransferData;

typedef struct NNSG2dCellOAMAttrData
{
    u16         attr0;
    u16         attr1;
    u16         attr2;

}
NNSG2dCellOAMAttrData;

typedef struct NNSG2dCellData
{
    u16                       numOAMAttrs;      // Number of OAM attributes
    u16                       cellAttr;         // Information related to cell type
    // Information related to flips (upper 8 bits)
    // Information related to bounding information
    //
    // Information related to rendering optimization (lower 8 bits)
    //      (6bit => Radius of bounding sphere  >> 2 )


    NNSG2dCellOAMAttrData*    pOamAttrArray;    // Pointer to the NNSG2dCellOAMAttrData array

}
NNSG2dCellData;

typedef struct NNSG2dCellDataBank
{
    u16                              numCells;               // Total number of cells
    u16                              cellBankAttr;           // Attribute
    NNSG2dCellData*                  pCellDataArrayHead;     // offset address
    NNSG2dCharacterDataMapingType    mappingMode;            // Mapping mode of the referenced character

    NNSG2dVramTransferData*          pVramTransferData;      // Information related to Vram transfer animation

    void*                            pStringBank;            // Character string bank
    void*                            pExtendedData;          // offset addr (if it exists)


}
NNSG2dCellDataBank;

typedef enum NNSG2dAnimationPlayMode
{
    NNS_G2D_ANIMATIONPLAYMODE_INVALID = 0x0,    // Disabled
    NNS_G2D_ANIMATIONPLAYMODE_FORWARD,          // one-time playback (forward)
    NNS_G2D_ANIMATIONPLAYMODE_FORWARD_LOOP,     // repeat playback (forward loop)
    NNS_G2D_ANIMATIONPLAYMODE_REVERSE,          // reverse playback (reverse (forward + backward))
    NNS_G2D_ANIMATIONPLAYMODE_REVERSE_LOOP,     // reverse playback repeat (reverse (forward + backward) loop)
    NNS_G2D_ANIMATIONPLAYMODE_MAX
}
NNSG2dAnimationPlayMode;

typedef struct NNSG2dAnimFrameData
{
    void*           pContent;   // pointer to animation result
    u16             frames;     // animation frame continuation time (units: video frames)
    u16             pad16;      // padding

}
NNSG2dAnimFrameData;

typedef struct NNSG2dAnimSequenceData
{
    u16                     numFrames;         // number of animation frames forming the sequence
    u16                     loopStartFrameIdx; // loop start animation frame number

    u32                     animType;          // animation type (upper 16 bits)
    //  animation elements (lower 16 bits)
    // (What's referenced by NNSG2dAnimFrameData.pContent is changed)

    NNSG2dAnimationPlayMode playMode;          // animation sequence playback method
    NNSG2dAnimFrameData*    pAnmFrameArray;    // offset from the head of pFrameArray.

}
NNSG2dAnimSequenceData;

typedef struct NNSG2dAnimBankData
{

    u16                       numSequences;         // number of animation sequences
    u16                       numTotalFrames;       // total number of animation frames
    NNSG2dAnimSequenceData*   pSequenceArrayHead;   // pointer to animation sequence array
    NNSG2dAnimFrameData*      pFrameArrayHead;      // pointer to animation frame array
    void*                     pAnimContents;        // pointer to animation result array
    void*                     pStringBank;          // pointer to string bank (set during execution)
    void*                     pExtendedData;        // pointer to library expansion area (not used)

}
NNSG2dAnimBankData;


BOOL NNS_G2dGetUnpackedBGCharacterData( void* pNcgrFile, NNSG2dCharacterData** ppCharData );
BOOL NNS_G2dGetUnpackedCharacterData( void* pNcgrFile, NNSG2dCharacterData** ppCharData );
BOOL NNS_G2dGetUnpackedScreenData( void* pNscrFile, NNSG2dScreenData** ppScrData );
BOOL NNS_G2dGetUnpackedPaletteData( void* pNclrFile, NNSG2dPaletteData** ppPltData );
BOOL NNS_G2dGetUnpackedPaletteData( void* pNclrFile, NNSG2dPaletteData** ppPltData );
BOOL NNS_G2dGetUnpackedPaletteCompressInfo( void* pNclrFile, NNSG2dPaletteCompressInfo** ppPltCmpInfo );
BOOL NNS_G2dGetUnpackedCellBank( void* pNcerFile, NNSG2dCellDataBank** ppCellBank );
BOOL NNS_G2dGetUnpackedAnimBank( void* pNanrFile, NNSG2dAnimBankData** ppAnimBank );

#endif //NNSYS_NNS_G2D_H