1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - GX -
3   File:     struct_2d.h
4 
5   Copyright 2003-2008 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   $Date:: 2008-09-18#$
14   $Rev: 8573 $
15   $Author: okubata_ryoma $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef NITRO_STRUCT_2D_H_
19 #define NITRO_STRUCT_2D_H_
20 
21 #include <nitro/gx/gxcommon.h>
22 
23 
24 
25 
26 
27 //----------------------------------------------------------------------------
28 //
29 // Typedefs, basic structure definitions, and macro definitions
30 //
31 //----------------------------------------------------------------------------
32 
33 //----------------------------------------------------------------------------
34 // A typedef and macros for text screen data format
35 //----------------------------------------------------------------------------
36 typedef u16 GXScrFmtText;
37 #define GX_SCRFMT_TEXT_CHARNAME_SHIFT                      (0)
38 #define GX_SCRFMT_TEXT_CHARNAME_MASK                       (0x03ff)
39 #define GX_SCRFMT_TEXT_HF_SHIFT                            (10)
40 #define GX_SCRFMT_TEXT_HF_MASK                             (0x0400)
41 #define GX_SCRFMT_TEXT_VF_SHIFT                            (11)
42 #define GX_SCRFMT_TEXT_VF_MASK                             (0x0800)
43 #define GX_SCRFMT_TEXT_COLORPLTT_SHIFT                     (12)
44 #define GX_SCRFMT_TEXT_COLORPLTT_MASK                      (0xf000)
45 #define GX_SCRFMT_TEXT(pltt, vf, hf, name)              \
46     ((u16)(((name) << GX_SCRFMT_TEXT_CHARNAME_SHIFT) |  \
47            ((hf) << GX_SCRFMT_TEXT_HF_SHIFT)         |  \
48            ((vf) << GX_SCRFMT_TEXT_VF_SHIFT)         |  \
49            ((pltt) << GX_SCRFMT_TEXT_COLORPLTT_SHIFT)))
50 
51 //----------------------------------------------------------------------------
52 // A typedef and macros for affine screen data format
53 //----------------------------------------------------------------------------
54 typedef u8 GXScrFmtAffine;
55 #define GX_SCRFMT_AFFINE_CHARNAME_SHIFT                    (0)
56 #define GX_SCRFMT_AFFINE_CHARNAME_MASK                     (0xff)
57 
58 //----------------------------------------------------------------------------
59 // A typedef and macros for bitmap screen data format
60 //----------------------------------------------------------------------------
61 typedef u8 GXScrFmt256Bmp;
62 #define GX_SCRFMT_256BMP_COLORNO_SHIFT                     (0)
63 #define GX_SCRFMT_256BMP_COLORNO_MASK                      (0xff)
64 
65 //----------------------------------------------------------------------------
66 // A structure corresponding to a character in 16 color mode
67 //----------------------------------------------------------------------------
68 typedef union
69 {
70     // 32 bytes
71     // 4bit/pixel
72     u32     data32[8];
73     u16     data16[16];
74     u8      data8[32];
75 }
76 GXCharFmt16;
77 
78 //----------------------------------------------------------------------------
79 // A structure corresponding to a character in 256 color mode
80 //----------------------------------------------------------------------------
81 typedef union
82 {
83     // 64 bytes
84     // 8bit/pixel
85     u32     data32[16];
86     u16     data16[32];
87     u8      data8[64];
88 }
89 GXCharFmt256;
90 
91 //----------------------------------------------------------------------------
92 // A structure corresponding to a 16 colors BG palette
93 //----------------------------------------------------------------------------
94 typedef union
95 {
96     // 32 bytes
97     u16     data16[16];
98     u32     data32[8];
99     GXRgb   rgb[16];
100 }
101 GXBGPltt16;
102 
103 // GXBGPltt16 and GXOBJPltt16 are the same.
104 typedef GXBGPltt16 GXOBJPltt16;
105 
106 //----------------------------------------------------------------------------
107 // A structure corresponding to a 256 colors BG palette
108 //----------------------------------------------------------------------------
109 typedef union
110 {
111     // 512 bytes
112     u16     data16[256];
113     u32     data32[128];
114     GXRgb   rgb[256];
115 }
116 GXBGPltt256;
117 
118 // GXBGPltt256 and GXOBJPltt256 are the same.
119 typedef GXBGPltt256 GXOBJPltt256;
120 
121 
122 
123 
124 
125 //----------------------------------------------------------------------------
126 //
127 // Structure definitions for BG screen
128 //
129 //----------------------------------------------------------------------------
130 
131 //----------------------------------------------------------------------------
132 // A structure corresponding to 32x32 text screen
133 //----------------------------------------------------------------------------
134 typedef union
135 {
136     // 2K bytes
137     u16     data16[32 * 32];
138     u32     data32[32 * 32 / 2];
139     GXScrFmtText scr[32][32];
140 }
141 GXScrText32x32;
142 
143 //----------------------------------------------------------------------------
144 // A structure corresponding to 64x32 text screen
145 //----------------------------------------------------------------------------
146 typedef union
147 {
148     // 4K bytes
149     u16     data16[64 * 32];
150     u32     data32[64 * 32 / 2];
151     GXScrFmtText scr[64][32];
152 }
153 GXScrText64x32;
154 
155 //----------------------------------------------------------------------------
156 // A structure corresponding to 32x64 text screen
157 //----------------------------------------------------------------------------
158 typedef union
159 {
160     // 4K bytes
161     u16     data16[32 * 64];
162     u32     data32[32 * 64 / 2];
163     GXScrFmtText scr[32][64];
164 }
165 GXScrText32x64;
166 
167 //----------------------------------------------------------------------------
168 // A structure corresponding to 64x64 text screen
169 //----------------------------------------------------------------------------
170 typedef union
171 {
172     // 8K bytes
173     u16     data16[64 * 64];
174     u32     data32[64 * 64 / 2];
175     GXScrFmtText scr[64][64];
176 }
177 GXScrText64x64;
178 
179 //----------------------------------------------------------------------------
180 // A structure corresponding to 16x16 affine screen
181 //----------------------------------------------------------------------------
182 typedef union
183 {
184     // 256 bytes
185     u8      data8[16 * 16];
186     u32     data32[16 * 16 / 4];
187     GXScrFmtAffine scr[16][16];
188 }
189 GXScrAffine16x16;
190 
191 //----------------------------------------------------------------------------
192 // A structure corresponding to 32x32 affine screen
193 //----------------------------------------------------------------------------
194 typedef union
195 {
196     // 1K bytes
197     u8      data8[32 * 32];
198     u32     data32[32 * 32 / 4];
199     GXScrFmtAffine scr[32][32];
200 }
201 GXScrAffine32x32;
202 
203 //----------------------------------------------------------------------------
204 // A structure corresponding to 64x64 affine screen
205 //----------------------------------------------------------------------------
206 typedef union
207 {
208     // 4K bytes
209     u8      data8[64 * 64];
210     u32     data32[64 * 64 / 4];
211     GXScrFmtAffine scr[64][64];
212 }
213 GXScrAffine64x64;
214 
215 //----------------------------------------------------------------------------
216 // A structure corresponding to 128x128 affine screen
217 //----------------------------------------------------------------------------
218 typedef union
219 {
220     // 16K bytes
221     u8      data8[128 * 128];
222     u32     data32[128 * 128 / 4];
223     GXScrFmtAffine scr[128][128];
224 }
225 GXScrAffine128x128;
226 
227 //----------------------------------------------------------------------------
228 // A structure corresponding to 128x128 bitmap screen
229 //----------------------------------------------------------------------------
230 typedef union
231 {
232     // 16K bytes
233     u8      data8[128 * 128];
234     u32     data32[128 * 128 / 4];
235     GXScrFmt256Bmp scr[128][128];
236 }
237 GXScr256Bmp128x128;
238 
239 //----------------------------------------------------------------------------
240 // A structure corresponding to 256x256 bitmap screen
241 //----------------------------------------------------------------------------
242 typedef union
243 {
244     // 64K bytes
245     u8      data8[256 * 256];
246     u32     data32[256 * 256 / 4];
247     GXScrFmt256Bmp scr[256][256];
248 }
249 GXScr256Bmp256x256;
250 
251 //----------------------------------------------------------------------------
252 // A structure corresponding to 512x256 bitmap screen
253 //----------------------------------------------------------------------------
254 typedef union
255 {
256     // 128K bytes
257     u8      data8[512 * 256];
258     u32     data32[512 * 256 / 4];
259     GXScrFmt256Bmp scr[512][256];
260 }
261 GXScr256Bmp512x256;
262 
263 //----------------------------------------------------------------------------
264 // A structure corresponding to 512x512 bitmap screen
265 //----------------------------------------------------------------------------
266 typedef union
267 {
268     // 256K bytes
269     u8      data8[512 * 512];
270     u32     data32[512 * 512 / 4];
271     GXScrFmt256Bmp scr[512][512];
272 }
273 GXScr256Bmp512x512;
274 
275 //----------------------------------------------------------------------------
276 // A structure corresponding to 128x128 direct color bitmap screen
277 //----------------------------------------------------------------------------
278 typedef union
279 {
280     // 32K bytes
281     u16     data16[128 * 128];
282     u32     data32[128 * 128 / 2];
283     GXRgba  scr[128][128];
284 }
285 GXScrDCBmp128x128;
286 
287 //----------------------------------------------------------------------------
288 // A structure corresponding to 256x256 direct color bitmap screen
289 //----------------------------------------------------------------------------
290 typedef union
291 {
292     // 128K bytes
293     u16     data16[256 * 256];
294     u32     data32[256 * 256 / 2];
295     GXRgba  scr[256][256];
296 }
297 GXScrDCBmp256x256;
298 
299 //----------------------------------------------------------------------------
300 // A structure corresponding to 512x256 direct color bitmap screen
301 //----------------------------------------------------------------------------
302 typedef union
303 {
304     // 256K bytes
305     u16     data16[512 * 256];
306     u32     data32[512 * 256 / 2];
307     GXRgba  scr[512][256];
308 }
309 GXScrDCBmp512x256;
310 
311 //----------------------------------------------------------------------------
312 // A structure corresponding to 512x512 direct color bitmap screen
313 //----------------------------------------------------------------------------
314 typedef union
315 {
316     // 512K bytes
317     u16     data16[512 * 512];
318     u32     data32[512 * 512 / 2];
319     GXRgba  scr[512][512];
320 }
321 GXScrDCBmp512x512;
322 
323 
324 
325 
326 
327 //----------------------------------------------------------------------------
328 //
329 // Structure definitions for BG characters
330 //
331 //----------------------------------------------------------------------------
332 
333 //----------------------------------------------------------------------------
334 // A structure corresponding to characters in 16 colors mode
335 //----------------------------------------------------------------------------
336 typedef struct
337 {
338     // 32K bytes
339     GXCharFmt16 ch[1024];
340 }
341 GXCharBGText16;
342 
343 //----------------------------------------------------------------------------
344 // A structure corresponding to characters in 256 colors mode(text BG)
345 //----------------------------------------------------------------------------
346 typedef struct
347 {
348     // 64K bytes
349     GXCharFmt256 ch[1024];
350 }
351 GXCharBGText256;
352 
353 //----------------------------------------------------------------------------
354 // A structure corresponding to characters in 256 colors mode(affine BG)
355 //----------------------------------------------------------------------------
356 typedef struct
357 {
358     // 16K bytes
359     GXCharFmt256 ch[256];
360 }
361 GXCharBGAffine256;
362 
363 
364 
365 
366 
367 //----------------------------------------------------------------------------
368 //
369 // Structure definitions for BG palettes
370 //
371 //----------------------------------------------------------------------------
372 
373 //----------------------------------------------------------------------------
374 // A structure corresponding to the standard BG palette
375 //----------------------------------------------------------------------------
376 typedef union
377 {
378     // 512 bytes
379     GXBGPltt256 pltt256;
380     GXBGPltt16 pltt16[16];
381 }
382 GXBGStdPlttData;
383 
384 //----------------------------------------------------------------------------
385 // A structure corresponding to the standard OBJ palette
386 //----------------------------------------------------------------------------
387 typedef union
388 {
389     // 512 bytes
390     GXOBJPltt256 pltt256;
391     GXOBJPltt16 pltt16[16];
392 }
393 GXOBJStdPlttData;
394 
395 //----------------------------------------------------------------------------
396 // A structure corresponding to the standard palette
397 //----------------------------------------------------------------------------
398 typedef struct
399 {
400     // 1024 bytes
401     GXBGStdPlttData bgPltt;
402     GXOBJStdPlttData objPltt;
403 }
404 GXStdPlttData;
405 
406 //----------------------------------------------------------------------------
407 // A structure corresponding to the BG extended palette
408 //----------------------------------------------------------------------------
409 typedef struct
410 {
411     // 8K bytes
412     GXBGPltt256 pltt256[16];
413 }
414 GXBGExtPlttData;
415 
416 //----------------------------------------------------------------------------
417 // A structure corresponding to the OBJ extended palette
418 //----------------------------------------------------------------------------
419 typedef struct
420 {
421     // 8K bytes
422     GXOBJPltt256 pltt256[16];
423 }
424 GXOBJExtPlttData;
425 
426 #endif
427