1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - GX -
3   File:     g2.h
4 
5   Copyright 2003-2009 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:: 2009-06-04#$
14   $Rev: 10698 $
15   $Author: okubata_ryoma $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef NITRO_G2_H_
19 #define NITRO_G2_H_
20 
21 #include <nitro/gx/gxcommon.h>
22 #ifndef SDK_TWL
23 #include <nitro/hw/ARM9/ioreg_G2.h>
24 #include <nitro/hw/ARM9/ioreg_G2S.h>
25 #include <nitro/hw/ARM9/ioreg_GX.h>
26 #include <nitro/hw/ARM9/ioreg_GXS.h>
27 #else
28 #include <twl/hw/ARM9/ioreg_G2.h>
29 #include <twl/hw/ARM9/ioreg_G2S.h>
30 #include <twl/hw/ARM9/ioreg_GX.h>
31 #include <twl/hw/ARM9/ioreg_GXS.h>
32 #endif
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 //----------------------------------------------------------------------------
39 // Type definition
40 //----------------------------------------------------------------------------
41 
42 typedef struct
43 {
44     u8      planeMask:5;
45     u8      effect:1;
46     u8      _reserve:2;
47 }
48 GXWndPlane;
49 
50 typedef enum
51 {
52     GX_WND_PLANEMASK_NONE = 0x0000,
53     GX_WND_PLANEMASK_BG0 = 0x0001,
54     GX_WND_PLANEMASK_BG1 = 0x0002,
55     GX_WND_PLANEMASK_BG2 = 0x0004,
56     GX_WND_PLANEMASK_BG3 = 0x0008,
57     GX_WND_PLANEMASK_OBJ = 0x0010
58 }
59 GXWndPlaneMask;
60 
61 #define GX_WND_PLANEMASK_ASSERT(x)                                   \
62     SDK_MINMAX_ASSERT(x,                                             \
63                       GX_WND_PLANEMASK_NONE,                         \
64                       (GX_WND_PLANEMASK_BG0 | GX_WND_PLANEMASK_BG1 | \
65                        GX_WND_PLANEMASK_BG2 | GX_WND_PLANEMASK_BG3 | \
66                        GX_WND_PLANEMASK_OBJ))
67 
68 
69 typedef enum
70 {
71     GX_BLEND_PLANEMASK_NONE = 0x0000,
72     GX_BLEND_PLANEMASK_BG0 = 0x0001,
73     GX_BLEND_PLANEMASK_BG1 = 0x0002,
74     GX_BLEND_PLANEMASK_BG2 = 0x0004,
75     GX_BLEND_PLANEMASK_BG3 = 0x0008,
76     GX_BLEND_PLANEMASK_OBJ = 0x0010,
77     GX_BLEND_PLANEMASK_BD = 0x0020
78 }
79 GXBlendPlaneMask;
80 
81 #define GX_BLEND_PLANEMASK_ASSERT(x) \
82     SDK_MINMAX_ASSERT(x, GX_BLEND_PLANEMASK_NONE, 0x3f)
83 
84 #define GX_MOSAICSIZE_ASSERT(x) SDK_MINMAX_ASSERT(x, 0, 15)
85 
86 
87 /* if include from Other Environment for exsample VC or BCB, */
88 /* please define SDK_FROM_TOOL                               */
89 #if !(defined(SDK_WIN32) || defined(SDK_FROM_TOOL))
90 
91 //----------------------------------------------------------------------------
92 // Declaration of function
93 //----------------------------------------------------------------------------
94 
95 
96 //
97 // Main 2D engine
98 //
99 static void G2_SetBG0Offset(int hOffset, int vOffset);
100 static void G2_SetBG1Offset(int hOffset, int vOffset);
101 static void G2_SetBG2Offset(int hOffset, int vOffset);
102 static void G2_SetBG3Offset(int hOffset, int vOffset);
103 
104 // mtx->_00 = A, mtx->_01 = B, mtx->_10 = C, mtx->_11 = D in the programming manual
105 static void G2_SetBG2Affine(const MtxFx22 *mtx, int centerX, int centerY, int x1, int y1);
106 static void G2_SetBG3Affine(const MtxFx22 *mtx, int centerX, int centerY, int x1, int y1);
107 
108 static void G2_SetWnd0InsidePlane(int wnd /* GXWndPlaneMask */ , BOOL effect);
109 static void G2_SetWnd1InsidePlane(int wnd /* GXWndPlaneMask */ , BOOL effect);
110 static void G2_SetWndOutsidePlane(int wnd /* GXWndPlaneMask */ , BOOL effect);
111 static void G2_SetWndOBJInsidePlane(int wnd /* GXWndPlaneMask */ , BOOL effect);
112 static void G2_SetWnd0Position(int x1, int y1, int x2, int y2);
113 static void G2_SetWnd1Position(int x1, int y1, int x2, int y2);
114 
115 static void G2_SetBGMosaicSize(int hSize, int vSize);
116 static void G2_SetOBJMosaicSize(int hSize, int vSize);
117 
118 // BLDCNT, BLDALPHA, BLDY are packaged by them.
119 static void G2_BlendNone(void);
120 static void G2_SetBlendAlpha(int plane1,        // GXBlendPlaneMask
121                              int plane2,        // GXBlendPlaneMask
122                              int ev1, int ev2);
123 // brightness takes -16 to +16, the mode of BLDCNT changes corresponding to the sign.
124 static void G2_SetBlendBrightness(int plane,    // GXBlendPlaneMask
125                                   int brightness);
126 static void G2_SetBlendBrightnessExt(int plane1,        // GXBlendPlaneMask
127                                      int plane2,        // GXBlendPlaneMask
128                                      int ev1, int ev2, int brightness);
129 
130 static void G2_ChangeBlendAlpha(int ev1, int ev2);
131 static void G2_ChangeBlendBrightness(int brightness);
132 
133 //
134 // Sub 2D engine
135 //
136 static void G2S_SetBG0Offset(int hOffset, int vOffset);
137 static void G2S_SetBG1Offset(int hOffset, int vOffset);
138 static void G2S_SetBG2Offset(int hOffset, int vOffset);
139 static void G2S_SetBG3Offset(int hOffset, int vOffset);
140 
141 // mtx->_00 = A, mtx->_01 = B, mtx->_10 = C, mtx->_11 = D in the programming manual
142 static void G2S_SetBG2Affine(const MtxFx22 *mtx, int centerX, int centerY, int x1, int y1);
143 static void G2S_SetBG3Affine(const MtxFx22 *mtx, int centerX, int centerY, int x1, int y1);
144 
145 static void G2S_SetWnd0InsidePlane(int wnd /* GXWndPlaneMask */ , BOOL effect);
146 static void G2S_SetWnd1InsidePlane(int wnd /* GXWndPlaneMask */ , BOOL effect);
147 static void G2S_SetWndOutsidePlane(int wnd /* GXWndPlaneMask */ , BOOL effect);
148 static void G2S_SetWndOBJInsidePlane(int wnd /* GXWndPlaneMask */ , BOOL effect);
149 static void G2S_SetWnd0Position(int x1, int y1, int x2, int y2);
150 static void G2S_SetWnd1Position(int x1, int y1, int x2, int y2);
151 
152 static void G2S_SetBGMosaicSize(int hSize, int vSize);
153 static void G2S_SetOBJMosaicSize(int hSize, int vSize);
154 
155 // BLDCNT, BLDALPHA, BLDY are packaged by them.
156 static void G2S_BlendNone(void);
157 static void G2S_SetBlendAlpha(int plane1,       // GXBlendPlaneMask
158                               int plane2,       // GXBlendPlaneMask
159                               int ev1, int ev2);
160 // brightness takes -16 to +16, the mode of BLDCNT changes corresponding to the sign.
161 static void G2S_SetBlendBrightness(int plane,   // GXBlendPlaneMask
162                                    int brightness);
163 static void G2S_SetBlendBrightnessExt(int plane1,       // GXBlendPlaneMask
164                                       int plane2,       // GXBlendPlaneMask
165                                       int ev1, int ev2, int brightness);
166 
167 static void G2S_ChangeBlendAlpha(int ev1, int ev2);
168 static void G2S_ChangeBlendBrightness(int brightness);
169 
170 
171 //----------------------------------------------------------------------------
172 // Internal use only
173 //----------------------------------------------------------------------------
174 void    G2x_SetBGyAffine_(u32 addr, const MtxFx22 *mtx, int centerX, int centerY, int x1, int y1);
175 void    G2x_SetBlendAlpha_(u32 addr, int plane1, int plane2, int ev1, int ev2);
176 void    G2x_SetBlendBrightness_(u32 addr, int plane, int brightness);
177 void    G2x_SetBlendBrightnessExt_(u32 addr, int plane1, int plane2, int ev1, int ev2,
178                                    int brightness);
179 void    G2x_ChangeBlendBrightness_(u32 addr, int brightness);
180 
181 
182 //----------------------------------------------------------------------------
183 // Implementation of inline function
184 //----------------------------------------------------------------------------
185 
186 //----------------------------------------------------------------------------
187 //
188 // Display A(Main Display)
189 //
190 //----------------------------------------------------------------------------
191 
192 
193 /*---------------------------------------------------------------------------*
194   Name:         G2_SetBG0Offset
195 
196   Description:  Set the BG0 screen offset
197 
198   Arguments:    hOffset    H-offset(in dot)
199                 vOffset    V-offset(in dot)
200 
201   Returns:      none
202  *---------------------------------------------------------------------------*/
G2_SetBG0Offset(int hOffset,int vOffset)203 static inline void G2_SetBG0Offset(int hOffset, int vOffset)
204 {
205     SDK_WARNING(0 == (reg_GX_DISPCNT & REG_GX_DISPCNT_BG02D3D_MASK),
206                 "BG0 is in 3D mode now. call \'G3X_SetHOffset\'\n");
207 
208     reg_G2_BG0OFS = (u32)(((hOffset << REG_G2_BG0OFS_HOFFSET_SHIFT) & REG_G2_BG0OFS_HOFFSET_MASK) |
209                           ((vOffset << REG_G2_BG0OFS_VOFFSET_SHIFT) & REG_G2_BG0OFS_VOFFSET_MASK));
210 }
211 
212 
213 /*---------------------------------------------------------------------------*
214   Name:         G2_SetBG1Offset
215 
216   Description:  Set the BG1 screen offset
217 
218   Arguments:    hOffset    H-offset(in dot)
219                 vOffset    V-offset(in dot)
220 
221   Returns:      none
222  *---------------------------------------------------------------------------*/
G2_SetBG1Offset(int hOffset,int vOffset)223 static inline void G2_SetBG1Offset(int hOffset, int vOffset)
224 {
225     reg_G2_BG1OFS = (u32)(((hOffset << REG_G2_BG1OFS_HOFFSET_SHIFT) & REG_G2_BG1OFS_HOFFSET_MASK) |
226                           ((vOffset << REG_G2_BG1OFS_VOFFSET_SHIFT) & REG_G2_BG1OFS_VOFFSET_MASK));
227 }
228 
229 
230 /*---------------------------------------------------------------------------*
231   Name:         G2_SetBG2Offset
232 
233   Description:  Set the BG2 screen offset
234 
235   Arguments:    hOffset    H-offset(in dot)
236                 vOffset    V-offset(in dot)
237 
238   Returns:      none
239  *---------------------------------------------------------------------------*/
G2_SetBG2Offset(int hOffset,int vOffset)240 static inline void G2_SetBG2Offset(int hOffset, int vOffset)
241 {
242 #ifdef SDK_DEBUG
243     {
244         u32     tmp = (reg_GX_DISPCNT & REG_GX_DISPCNT_BGMODE_MASK) >> REG_GX_DISPCNT_BGMODE_SHIFT;
245         SDK_WARNING((0 == tmp) || (1 == tmp) || (3 == tmp),
246                     "G2_SetBG2Offset requires BG #2 to be text mode. Use G2_SetBG2Affine instead.");
247     }
248 #endif
249     reg_G2_BG2OFS = (u32)(((hOffset << REG_G2_BG2OFS_HOFFSET_SHIFT) & REG_G2_BG2OFS_HOFFSET_MASK) |
250                           ((vOffset << REG_G2_BG2OFS_VOFFSET_SHIFT) & REG_G2_BG2OFS_VOFFSET_MASK));
251 }
252 
253 
254 /*---------------------------------------------------------------------------*
255   Name:         G2_SetBG3Offset
256 
257   Description:  Set the BG3 screen offset
258 
259   Arguments:    hOffset    H-offset(in dot)
260                 vOffset    V-offset(in dot)
261 
262   Returns:      none
263  *---------------------------------------------------------------------------*/
G2_SetBG3Offset(int hOffset,int vOffset)264 static inline void G2_SetBG3Offset(int hOffset, int vOffset)
265 {
266 #ifdef SDK_DEBUG
267     {
268         u32     tmp = (reg_GX_DISPCNT & REG_GX_DISPCNT_BGMODE_MASK) >> REG_GX_DISPCNT_BGMODE_SHIFT;
269         SDK_WARNING(0 == tmp,
270                     "G2_SetBG3Offset requires BG #3 to be text mode. Use G2_SetBG3Affine instead.");
271     }
272 #endif
273     reg_G2_BG3OFS = (u32)(((hOffset << REG_G2_BG3OFS_HOFFSET_SHIFT) & REG_G2_BG3OFS_HOFFSET_MASK) |
274                           ((vOffset << REG_G2_BG3OFS_VOFFSET_SHIFT) & REG_G2_BG3OFS_VOFFSET_MASK));
275 }
276 
277 
278 /*---------------------------------------------------------------------------*
279   Name:         G2_SetWnd0InsidePlane
280 
281   Description:  Select the planes inside the Window #0
282 
283   Arguments:    wnd      Set of the planes inside the Window #0
284                 effect   enable/disable blending/brightness effect
285 
286   Returns:      none
287  *---------------------------------------------------------------------------*/
G2_SetWnd0InsidePlane(int wnd,BOOL effect)288 static inline void G2_SetWnd0InsidePlane(int wnd, BOOL effect)
289 {
290     u32     tmp;
291     GX_WND_PLANEMASK_ASSERT(wnd);
292 
293     tmp = ((reg_G2_WININ & ~REG_G2_WININ_WIN0IN_MASK) | ((u32)wnd << REG_G2_WININ_WIN0IN_SHIFT));
294 
295     if (effect)
296     {
297         tmp |= (0x20 << REG_G2_WININ_WIN0IN_SHIFT);     // EFCT
298     }
299 
300     reg_G2_WININ = (u16)tmp;
301 }
302 
303 
304 /*---------------------------------------------------------------------------*
305   Name:         G2_GetWnd0InsidePlane
306 
307   Description:  Get the planes inside the Window #0
308 
309   Arguments:    none.
310 
311   Returns:      structrue of the plane mask and effect flag;
312  *---------------------------------------------------------------------------*/
G2_GetWnd0InsidePlane(void)313 static inline GXWndPlane G2_GetWnd0InsidePlane(void)
314 {
315     return *(volatile GXWndPlane *)(REG_WININ_ADDR);
316 }
317 
318 
319 /*---------------------------------------------------------------------------*
320   Name:         G2_SetWnd1InsidePlane
321 
322   Description:  Select the planes inside the Window #1
323 
324   Arguments:    wnd      Set of the planes inside the Window #1
325                 effect   enable/disable blending/brightness effect
326 
327   Returns:      none
328  *---------------------------------------------------------------------------*/
G2_SetWnd1InsidePlane(int wnd,BOOL effect)329 static inline void G2_SetWnd1InsidePlane(int wnd, BOOL effect)
330 {
331     u32     tmp;
332     GX_WND_PLANEMASK_ASSERT(wnd);
333 
334     tmp = ((reg_G2_WININ & ~REG_G2_WININ_WIN1IN_MASK) | ((u32)wnd << REG_G2_WININ_WIN1IN_SHIFT));
335 
336     if (effect)
337     {
338         tmp |= (0x20 << REG_G2_WININ_WIN1IN_SHIFT);     // EFCT
339     }
340 
341     reg_G2_WININ = (u16)tmp;
342 }
343 
344 
345 /*---------------------------------------------------------------------------*
346   Name:         G2_GetWnd1InsidePlane
347 
348   Description:  Get the planes inside the Window #1
349 
350   Arguments:    none.
351 
352   Returns:      structrue of the plane mask and effect flag;
353  *---------------------------------------------------------------------------*/
G2_GetWnd1InsidePlane(void)354 static inline GXWndPlane G2_GetWnd1InsidePlane(void)
355 {
356     return *(volatile GXWndPlane *)(REG_WININ_ADDR + 1);
357 }
358 
359 
360 /*---------------------------------------------------------------------------*
361   Name:         G2_SetWndOutsidePlane
362 
363   Description:  Select the planes outside the Window #0, #1, OBJ
364 
365   Arguments:    wnd      Set of the planes outside the windows
366                 effect   enable/disable blending/brightness effect
367 
368   Returns:      none
369  *---------------------------------------------------------------------------*/
G2_SetWndOutsidePlane(int wnd,BOOL effect)370 static inline void G2_SetWndOutsidePlane(int wnd, BOOL effect)
371 {
372     u32     tmp;
373     GX_WND_PLANEMASK_ASSERT(wnd);
374 
375     tmp = ((reg_G2_WINOUT & ~REG_G2_WINOUT_WINOUT_MASK) | ((u32)wnd << REG_G2_WINOUT_WINOUT_SHIFT));
376 
377     if (effect)
378     {
379         tmp |= (0x20 << REG_G2_WINOUT_WINOUT_SHIFT);    // EFCT
380     }
381 
382     reg_G2_WINOUT = (u16)tmp;
383 }
384 
385 
386 /*---------------------------------------------------------------------------*
387   Name:         G2_GetWndOutsidePlane
388 
389   Description:  Get the planes outside the Window
390 
391   Arguments:    none.
392 
393   Returns:      structrue of the plane mask and effect flag;
394  *---------------------------------------------------------------------------*/
G2_GetWndOutsidePlane(void)395 static inline GXWndPlane G2_GetWndOutsidePlane(void)
396 {
397     return *(volatile GXWndPlane *)(REG_WINOUT_ADDR);
398 }
399 
400 
401 /*---------------------------------------------------------------------------*
402   Name:         G2_SetWndOBJInsidePlane
403 
404   Description:  Select the planes inside the OBJ window
405 
406   Arguments:    wnd      Set of the planes inside the OBJ window
407 
408   Returns:      none
409  *---------------------------------------------------------------------------*/
G2_SetWndOBJInsidePlane(int wnd,BOOL effect)410 static inline void G2_SetWndOBJInsidePlane(int wnd, BOOL effect)
411 {
412     u32     tmp;
413     GX_WND_PLANEMASK_ASSERT(wnd);
414 
415     tmp = ((reg_G2_WINOUT & ~REG_G2_WINOUT_OBJWININ_MASK) |
416            ((u32)wnd << REG_G2_WINOUT_OBJWININ_SHIFT));
417 
418     if (effect)
419     {
420         tmp |= (0x20 << REG_G2_WINOUT_OBJWININ_SHIFT);  // EFCT
421     }
422 
423     reg_G2_WINOUT = (u16)tmp;
424 }
425 
426 
427 /*---------------------------------------------------------------------------*
428   Name:         G2_GetWndOBJInsidePlane
429 
430   Description:  Get the planes inside the OBJ Window
431 
432   Arguments:    none.
433 
434   Returns:      structrue of the plane mask and effect flag;
435  *---------------------------------------------------------------------------*/
G2_GetWndOBJInsidePlane(void)436 static inline GXWndPlane G2_GetWndOBJInsidePlane(void)
437 {
438     return *(volatile GXWndPlane *)(REG_WINOUT_ADDR + 1);
439 }
440 
441 
442 /*---------------------------------------------------------------------------*
443   Name:         G2_SetWnd0Position
444 
445   Description:  Specify the position of the Window #0
446 
447   Arguments:    x1        X coordinate of the upper left of the window
448                 y1        Y coordinate of the upper left of the window
449                 x2        X coordinate of the lower right of the window
450                 y2        Y coordinate of the lower right of the window
451 
452   Returns:      none
453  *---------------------------------------------------------------------------*/
G2_SetWnd0Position(int x1,int y1,int x2,int y2)454 static inline void G2_SetWnd0Position(int x1, int y1, int x2, int y2)
455 {
456     SDK_MINMAX_ASSERT(y1, 0, 192);
457     SDK_MINMAX_ASSERT(y2, 0, 192);
458 
459     // Note that the addresses of reg_G2_WIN0H and reg_G2_WIN0V are separate.
460     reg_G2_WIN0H = (u16)(((x1 << REG_G2_WIN0H_LEFTX_SHIFT) & REG_G2_WIN0H_LEFTX_MASK) |
461                          ((x2 << REG_G2_WIN0H_RIGHTX_SHIFT) & REG_G2_WIN0H_RIGHTX_MASK));
462 
463     reg_G2_WIN0V = (u16)(((y1 << REG_G2_WIN0V_UPY_SHIFT) & REG_G2_WIN0V_UPY_MASK) |
464                          ((y2 << REG_G2_WIN0V_DOWNY_SHIFT) & REG_G2_WIN0V_DOWNY_MASK));
465 }
466 
467 
468 /*---------------------------------------------------------------------------*
469   Name:         G2_SetWnd1Position
470 
471   Description:  Specify the position of the Window #1
472 
473   Arguments:    x1        X coordinate of the upper left of the window
474                 y1        Y coordinate of the upper left of the window
475                 x2        X coordinate of the lower right of the window
476                 y2        Y coordinate of the lower right of the window
477 
478   Returns:      none
479  *---------------------------------------------------------------------------*/
G2_SetWnd1Position(int x1,int y1,int x2,int y2)480 static inline void G2_SetWnd1Position(int x1, int y1, int x2, int y2)
481 {
482     SDK_MINMAX_ASSERT(y1, 0, 192);
483     SDK_MINMAX_ASSERT(y2, 0, 192);
484 
485     // Note that the addresses of reg_G2_WIN1H and reg_G2_WIN1V are separate.
486     reg_G2_WIN1H = (u16)(((x1 << REG_G2_WIN1H_LEFTX_SHIFT) & REG_G2_WIN1H_LEFTX_MASK) |
487                          ((x2 << REG_G2_WIN1H_RIGHTX_SHIFT) & REG_G2_WIN1H_RIGHTX_MASK));
488 
489     reg_G2_WIN1V = (u16)(((y1 << REG_G2_WIN1V_UPY_SHIFT) & REG_G2_WIN1V_UPY_MASK) |
490                          ((y2 << REG_G2_WIN1V_DOWNY_SHIFT) & REG_G2_WIN1V_DOWNY_MASK));
491 }
492 
493 
494 /*---------------------------------------------------------------------------*
495   Name:         G2_SetBGMosaicSize
496 
497   Description:  Specify the size of the mosaic applied on BGs
498 
499   Arguments:    hSize     the size of the mosaic in horizontal direction
500                 vSize     the size of the mosaic in verticale direction
501 
502   Returns:      none
503  *---------------------------------------------------------------------------*/
G2_SetBGMosaicSize(int hSize,int vSize)504 static inline void G2_SetBGMosaicSize(int hSize, int vSize)
505 {
506     GX_MOSAICSIZE_ASSERT(hSize);
507     GX_MOSAICSIZE_ASSERT(vSize);
508 
509     *((vu8 *)REG_MOSAIC_ADDR) = (u8)((hSize << REG_G2_MOSAIC_BGHSIZE_SHIFT) |
510                                      (vSize << REG_G2_MOSAIC_BGVSIZE_SHIFT));
511 }
512 
513 
514 /*---------------------------------------------------------------------------*
515   Name:         G2_SetOBJMosaicSize
516 
517   Description:  Specify the size of the mosaic applied on OBJs
518 
519   Arguments:    hSize     the size of the mosaic in horizontal direction
520                 vSize     the size of the mosaic in verticale direction
521 
522   Returns:      none
523  *---------------------------------------------------------------------------*/
G2_SetOBJMosaicSize(int hSize,int vSize)524 static inline void G2_SetOBJMosaicSize(int hSize, int vSize)
525 {
526     GX_MOSAICSIZE_ASSERT(hSize);
527     GX_MOSAICSIZE_ASSERT(vSize);
528 
529     *((vu8 *)(REG_MOSAIC_ADDR + 1)) = (u8)((hSize << (REG_G2_MOSAIC_OBJHSIZE_SHIFT - 8)) |
530                                            (vSize << (REG_G2_MOSAIC_OBJVSIZE_SHIFT - 8)));
531 }
532 
533 
534 /*---------------------------------------------------------------------------*
535   Name:         G2_BlendNone
536 
537   Description:  No Blendings between the planes
538 
539   Arguments:    none
540 
541   Returns:      none
542  *---------------------------------------------------------------------------*/
G2_BlendNone()543 static inline void G2_BlendNone()
544 {
545     reg_G2_BLDCNT = 0;
546 }
547 
548 
549 /*---------------------------------------------------------------------------*
550   Name:         G2_ChangeBlendAlpha
551 
552   Description:  Set blending coefficients directly
553 
554   Arguments:    ev1     blending coefficient1
555                 ev2     blending coefficient2
556 
557   Returns:      none
558  *---------------------------------------------------------------------------*/
G2_ChangeBlendAlpha(int ev1,int ev2)559 static inline void G2_ChangeBlendAlpha(int ev1, int ev2)
560 {
561     GX_ALPHA_ASSERT(ev1);
562     GX_ALPHA_ASSERT(ev2);
563 
564     reg_G2_BLDALPHA = (u16)((ev1 << REG_G2_BLDALPHA_EVA_SHIFT) |
565                             (ev2 << REG_G2_BLDALPHA_EVB_SHIFT));
566 }
567 
568 
569 /*---------------------------------------------------------------------------*
570   Name:         G2_SetBG2Affine
571 
572   Description:  Affine transform on BG2(MAIN engine).
573 
574   Arguments:    mtx          a pointer to a matrix
575                 centerX      center of rotation
576                 centerY      center of rotation
577                 x1           the upper left point before rotation
578                 y1           the upper left point before rotation
579 
580   Returns:      none
581  *---------------------------------------------------------------------------*/
G2_SetBG2Affine(const MtxFx22 * mtx,int centerX,int centerY,int x1,int y1)582 static inline void G2_SetBG2Affine(const MtxFx22 *mtx, int centerX, int centerY, int x1, int y1)
583 {
584     G2x_SetBGyAffine_((u32)&reg_G2_BG2PA, mtx, centerX, centerY, x1, y1);
585 }
586 
587 
588 /*---------------------------------------------------------------------------*
589   Name:         G2_SetBG3Affine
590 
591   Description:  Affine transform on BG3(MAIN engine).
592 
593   Arguments:    mtx          a pointer to a matrix
594                 centerX      center of rotation
595                 centerY      center of rotation
596                 x1           the upper left point before rotation
597                 y1           the upper left point before rotation
598 
599   Returns:      none
600  *---------------------------------------------------------------------------*/
G2_SetBG3Affine(const MtxFx22 * mtx,int centerX,int centerY,int x1,int y1)601 static inline void G2_SetBG3Affine(const MtxFx22 *mtx, int centerX, int centerY, int x1, int y1)
602 {
603     G2x_SetBGyAffine_((u32)&reg_G2_BG3PA, mtx, centerX, centerY, x1, y1);
604 }
605 
606 
607 /*---------------------------------------------------------------------------*
608   Name:         G2_SetBlendAlpha
609 
610   Description:  Alpha blending on plane1 and plane2(MAIN engine).
611 
612   Arguments:    plane1       a set of planes
613                 plane2       a set of planes
614                 ev1          coefficient of plane1's color(0 to 16)
615                 ev2          coefficient of plane2's color(0 to 16)
616 
617   Returns:      none
618  *---------------------------------------------------------------------------*/
G2_SetBlendAlpha(int plane1,int plane2,int ev1,int ev2)619 static inline void G2_SetBlendAlpha(int plane1, int plane2, int ev1, int ev2)
620 {
621     G2x_SetBlendAlpha_((u32)&reg_G2_BLDCNT, plane1, plane2, ev1, ev2);
622 }
623 
624 
625 /*---------------------------------------------------------------------------*
626   Name:         G2_SetBlendBrightness
627 
628   Description:  Changes brightness of plane(MAIN engine).
629 
630   Arguments:    plane        a set of planes
631                 brightness   chnage of brightness(-16 to 16)
632 
633   Returns:      none
634  *---------------------------------------------------------------------------*/
G2_SetBlendBrightness(int plane,int brightness)635 static inline void G2_SetBlendBrightness(int plane, int brightness)
636 {
637     G2x_SetBlendBrightness_((u32)&reg_G2_BLDCNT, plane, brightness);
638 }
639 
640 
641 /*---------------------------------------------------------------------------*
642   Name:         G2_SetBlendBrightnessExt
643 
644   Description:  Changes brightness of plane1,
645                 and alpha blending on plane1 and plane2(MAIN engine).
646 
647   Arguments:    plane1       a set of planes
648                 plane2       a set of planes
649                 ev1          coefficient of plane1's color(0 to 16)
650                 ev2          coefficient of plane1's color(0 to 16)
651                 brightness   change of brightness(-16 to 16)
652 
653   Returns:      none
654  *---------------------------------------------------------------------------*/
G2_SetBlendBrightnessExt(int plane1,int plane2,int ev1,int ev2,int brightness)655 static inline void G2_SetBlendBrightnessExt(int plane1,
656                                             int plane2, int ev1, int ev2, int brightness)
657 {
658     G2x_SetBlendBrightnessExt_((u32)&reg_G2_BLDCNT, plane1, plane2, ev1, ev2, brightness);
659 }
660 
661 
662 /*---------------------------------------------------------------------------*
663   Name:         G2_ChangeBlendBrightness
664 
665   Description:  Change brightness parameter only(MAIN engine).
666 
667   Arguments:    brightness   change of brightness(-16 to 16)
668 
669   Returns:      none
670  *---------------------------------------------------------------------------*/
G2_ChangeBlendBrightness(int brightness)671 static inline void G2_ChangeBlendBrightness(int brightness)
672 {
673     G2x_ChangeBlendBrightness_((u32)&reg_G2_BLDCNT, brightness);
674 }
675 
676 
677 
678 //----------------------------------------------------------------------------
679 //
680 // Display B(Sub Display)
681 //
682 //----------------------------------------------------------------------------
683 /*---------------------------------------------------------------------------*
684   Name:         G2S_SetBG0Offset
685 
686   Description:  Set the BG0 screen offset
687 
688   Arguments:    hOffset    H-offset(in dot)
689                 vOffset    V-offset(in dot)
690 
691   Returns:      none
692  *---------------------------------------------------------------------------*/
G2S_SetBG0Offset(int hOffset,int vOffset)693 static inline void G2S_SetBG0Offset(int hOffset, int vOffset)
694 {
695     reg_G2S_DB_BG0OFS =
696         (u32)(((hOffset << REG_G2S_DB_BG0OFS_HOFFSET_SHIFT) & REG_G2S_DB_BG0OFS_HOFFSET_MASK) |
697               ((vOffset << REG_G2S_DB_BG0OFS_VOFFSET_SHIFT) & REG_G2S_DB_BG0OFS_VOFFSET_MASK));
698 }
699 
700 
701 /*---------------------------------------------------------------------------*
702   Name:         G2S_SetBG1Offset
703 
704   Description:  Set the BG1 screen offset
705 
706   Arguments:    hOffset    H-offset(in dot)
707                 vOffset    V-offset(in dot)
708 
709   Returns:      none
710  *---------------------------------------------------------------------------*/
G2S_SetBG1Offset(int hOffset,int vOffset)711 static inline void G2S_SetBG1Offset(int hOffset, int vOffset)
712 {
713     reg_G2S_DB_BG1OFS =
714         (u32)(((hOffset << REG_G2S_DB_BG1OFS_HOFFSET_SHIFT) & REG_G2S_DB_BG1OFS_HOFFSET_MASK) |
715               ((vOffset << REG_G2S_DB_BG1OFS_VOFFSET_SHIFT) & REG_G2S_DB_BG1OFS_VOFFSET_MASK));
716 }
717 
718 
719 /*---------------------------------------------------------------------------*
720   Name:         G2S_SetBG2Offset
721 
722   Description:  Set the BG2 screen offset
723 
724   Arguments:    hOffset    H-offset(in dot)
725                 vOffset    V-offset(in dot)
726 
727   Returns:      none
728  *---------------------------------------------------------------------------*/
G2S_SetBG2Offset(int hOffset,int vOffset)729 static inline void G2S_SetBG2Offset(int hOffset, int vOffset)
730 {
731 #ifdef SDK_DEBUG
732     {
733         u32     tmp =
734             (reg_GXS_DB_DISPCNT & REG_GXS_DB_DISPCNT_BGMODE_MASK) >>
735             REG_GXS_DB_DISPCNT_BGMODE_SHIFT;
736         SDK_WARNING((0 == tmp) || (1 == tmp)
737                     || (3 == tmp),
738                     "G2S_SetBG2Offset requires BG #2 to be text mode. Use G2S_SetBG2Affine instead.");
739     }
740 #endif
741 
742     reg_G2S_DB_BG2OFS =
743         (u32)(((hOffset << REG_G2S_DB_BG2OFS_HOFFSET_SHIFT) & REG_G2S_DB_BG2OFS_HOFFSET_MASK) |
744               ((vOffset << REG_G2S_DB_BG2OFS_VOFFSET_SHIFT) & REG_G2S_DB_BG2OFS_VOFFSET_MASK));
745 }
746 
747 
748 /*---------------------------------------------------------------------------*
749   Name:         G2S_SetBG3Offset
750 
751   Description:  Set the BG3 screen offset
752 
753   Arguments:    hOffset    H-offset(in dot)
754                 vOffset    V-offset(in dot)
755 
756   Returns:      none
757  *---------------------------------------------------------------------------*/
G2S_SetBG3Offset(int hOffset,int vOffset)758 static inline void G2S_SetBG3Offset(int hOffset, int vOffset)
759 {
760 #ifdef SDK_DEBUG
761     {
762         u32     tmp =
763             (reg_GXS_DB_DISPCNT & REG_GXS_DB_DISPCNT_BGMODE_MASK) >>
764             REG_GXS_DB_DISPCNT_BGMODE_SHIFT;
765         SDK_WARNING(0 == tmp,
766                     "G2S_SetBG3Offset requires BG #3 to be text mode. Use G2S_SetBG3Affine instead.");
767     }
768 #endif
769 
770     reg_G2S_DB_BG3OFS =
771         (u32)(((hOffset << REG_G2S_DB_BG3OFS_HOFFSET_SHIFT) & REG_G2S_DB_BG3OFS_HOFFSET_MASK) |
772               ((vOffset << REG_G2S_DB_BG3OFS_VOFFSET_SHIFT) & REG_G2S_DB_BG3OFS_VOFFSET_MASK));
773 }
774 
775 
776 /*---------------------------------------------------------------------------*
777   Name:         G2S_SetWnd0InsidePlane
778 
779   Description:  Select the planes inside the Window #0
780 
781   Arguments:    wnd      Set of the planes inside the Window #0
782                 effect   enable/disable blending/brightness effect
783 
784   Returns:      none
785  *---------------------------------------------------------------------------*/
G2S_SetWnd0InsidePlane(int wnd,BOOL effect)786 static inline void G2S_SetWnd0InsidePlane(int wnd, BOOL effect)
787 {
788     u32     tmp;
789     GX_WND_PLANEMASK_ASSERT(wnd);
790 
791     tmp = ((reg_G2S_DB_WININ & ~REG_G2S_DB_WININ_WIN0IN_MASK) |
792            ((u32)wnd << REG_G2S_DB_WININ_WIN0IN_SHIFT));
793 
794     if (effect)
795     {
796         tmp |= (0x20 << REG_G2S_DB_WININ_WIN0IN_SHIFT); // EFCT
797     }
798 
799     reg_G2S_DB_WININ = (u16)tmp;
800 }
801 
802 
803 /*---------------------------------------------------------------------------*
804   Name:         G2S_GetWnd0InsidePlane
805 
806   Description:  Get the planes inside the Window #0(SUB engine).
807 
808   Arguments:    none.
809 
810   Returns:      structrue of the plane mask and effect flag;
811  *---------------------------------------------------------------------------*/
G2S_GetWnd0InsidePlane(void)812 static inline GXWndPlane G2S_GetWnd0InsidePlane(void)
813 {
814     return *(volatile GXWndPlane *)(REG_DB_WININ_ADDR);
815 }
816 
817 
818 /*---------------------------------------------------------------------------*
819   Name:         G2S_SetWnd1InsidePlane
820 
821   Description:  Select the planes inside the Window #1
822 
823   Arguments:    wnd      Set of the planes inside the Window #1
824                 effect   enable/disable blending/brightness effect
825 
826   Returns:      none
827  *---------------------------------------------------------------------------*/
G2S_SetWnd1InsidePlane(int wnd,BOOL effect)828 static inline void G2S_SetWnd1InsidePlane(int wnd, BOOL effect)
829 {
830     u32     tmp;
831     GX_WND_PLANEMASK_ASSERT(wnd);
832 
833     tmp = ((reg_G2S_DB_WININ & ~REG_G2S_DB_WININ_WIN1IN_MASK) |
834            ((u32)wnd << REG_G2S_DB_WININ_WIN1IN_SHIFT));
835 
836     if (effect)
837     {
838         tmp |= (0x20 << REG_G2S_DB_WININ_WIN1IN_SHIFT); // EFCT
839     }
840 
841     reg_G2S_DB_WININ = (u16)tmp;
842 }
843 
844 
845 /*---------------------------------------------------------------------------*
846   Name:         G2S_GetWnd1InsidePlane
847 
848   Description:  Get the planes inside the Window #1(SUB engine).
849 
850   Arguments:    none.
851 
852   Returns:      structrue of the plane mask and effect flag;
853  *---------------------------------------------------------------------------*/
G2S_GetWnd1InsidePlane(void)854 static inline GXWndPlane G2S_GetWnd1InsidePlane(void)
855 {
856     return *(volatile GXWndPlane *)(REG_DB_WININ_ADDR + 1);
857 }
858 
859 
860 /*---------------------------------------------------------------------------*
861   Name:         G2S_SetWndOutsidePlane
862 
863   Description:  Select the planes outside the Window #0, #1, OBJ
864 
865   Arguments:    wnd      Set of the planes outside the windows
866                 effect   enable/disable blending/brightness effect
867 
868   Returns:      none
869  *---------------------------------------------------------------------------*/
G2S_SetWndOutsidePlane(int wnd,BOOL effect)870 static inline void G2S_SetWndOutsidePlane(int wnd, BOOL effect)
871 {
872     u32     tmp;
873     GX_WND_PLANEMASK_ASSERT(wnd);
874 
875     tmp = ((reg_G2S_DB_WINOUT & ~REG_G2S_DB_WINOUT_WINOUT_MASK) |
876            ((u32)wnd << REG_G2S_DB_WINOUT_WINOUT_SHIFT));
877 
878     if (effect)
879     {
880         tmp |= (0x20 << REG_G2S_DB_WINOUT_WINOUT_SHIFT);        // EFCT
881     }
882 
883     reg_G2S_DB_WINOUT = (u16)tmp;
884 }
885 
886 
887 /*---------------------------------------------------------------------------*
888   Name:         G2S_GetWndOutsidePlane
889 
890   Description:  Get the planes outside the Window(SUB engine).
891 
892   Arguments:    none.
893 
894   Returns:      structrue of the plane mask and effect flag;
895  *---------------------------------------------------------------------------*/
G2S_GetWndOutsidePlane(void)896 static inline GXWndPlane G2S_GetWndOutsidePlane(void)
897 {
898     return *(volatile GXWndPlane *)(REG_DB_WINOUT_ADDR);
899 }
900 
901 
902 /*---------------------------------------------------------------------------*
903   Name:         G2S_SetWndOBJInsidePlane
904 
905   Description:  Select the planes inside the OBJ window
906 
907   Arguments:    wnd      Set of the planes inside the OBJ window
908 
909   Returns:      none
910  *---------------------------------------------------------------------------*/
G2S_SetWndOBJInsidePlane(int wnd,BOOL effect)911 static inline void G2S_SetWndOBJInsidePlane(int wnd, BOOL effect)
912 {
913     u32     tmp;
914     GX_WND_PLANEMASK_ASSERT(wnd);
915 
916     tmp = ((reg_G2S_DB_WINOUT & ~REG_G2S_DB_WINOUT_OBJWININ_MASK) |
917            ((u32)wnd << REG_G2S_DB_WINOUT_OBJWININ_SHIFT));
918 
919     if (effect)
920     {
921         tmp |= (0x20 << REG_G2S_DB_WINOUT_OBJWININ_SHIFT);      // EFCT
922     }
923 
924     reg_G2S_DB_WINOUT = (u16)tmp;
925 }
926 
927 
928 /*---------------------------------------------------------------------------*
929   Name:         G2S_GetWndOBJInsidePlane
930 
931   Description:  Get the planes inside the OBJ Window(SUB engine).
932 
933   Arguments:    none.
934 
935   Returns:      structrue of the plane mask and effect flag;
936  *---------------------------------------------------------------------------*/
G2S_GetWndOBJInsidePlane(void)937 static inline GXWndPlane G2S_GetWndOBJInsidePlane(void)
938 {
939     return *(volatile GXWndPlane *)(REG_DB_WINOUT_ADDR + 1);
940 }
941 
942 
943 /*---------------------------------------------------------------------------*
944   Name:         G2S_SetWnd0Position
945 
946   Description:  Specify the position of the Window #0
947 
948   Arguments:    x1        X coordinate of the upper left of the window
949                 y1        Y coordinate of the upper left of the window
950                 x2        X coordinate of the lower right of the window
951                 y2        Y coordinate of the lower right of the window
952 
953   Returns:      none
954  *---------------------------------------------------------------------------*/
G2S_SetWnd0Position(int x1,int y1,int x2,int y2)955 static inline void G2S_SetWnd0Position(int x1, int y1, int x2, int y2)
956 {
957     SDK_MINMAX_ASSERT(y1, 0, 192);
958     SDK_MINMAX_ASSERT(y2, 0, 192);
959 
960     // Note that the addresses of reg_G2S_DB_WIN0H and reg_G2S_DB_WIN0V are separate.
961     reg_G2S_DB_WIN0H = (u16)(((x1 << REG_G2S_DB_WIN0H_LEFTX_SHIFT) & REG_G2S_DB_WIN0H_LEFTX_MASK) |
962                              ((x2 << REG_G2S_DB_WIN0H_RIGHTX_SHIFT) &
963                               REG_G2S_DB_WIN0H_RIGHTX_MASK));
964 
965     reg_G2S_DB_WIN0V = (u16)(((y1 << REG_G2S_DB_WIN0V_UPY_SHIFT) & REG_G2S_DB_WIN0V_UPY_MASK) |
966                              ((y2 << REG_G2S_DB_WIN0V_DOWNY_SHIFT) & REG_G2S_DB_WIN0V_DOWNY_MASK));
967 }
968 
969 
970 /*---------------------------------------------------------------------------*
971   Name:         G2S_SetWnd1Position
972 
973   Description:  Specify the position of the Window #1
974 
975   Arguments:    x1        X coordinate of the upper left of the window
976                 y1        Y coordinate of the upper left of the window
977                 x2        X coordinate of the lower right of the window
978                 y2        Y coordinate of the lower right of the window
979 
980   Returns:      none
981  *---------------------------------------------------------------------------*/
G2S_SetWnd1Position(int x1,int y1,int x2,int y2)982 static inline void G2S_SetWnd1Position(int x1, int y1, int x2, int y2)
983 {
984     SDK_MINMAX_ASSERT(y1, 0, 192);
985     SDK_MINMAX_ASSERT(y2, 0, 192);
986 
987     // Note that the addresses of reg_G2S_DB_WIN1H and reg_G2S_DB_WIN1V are separate.
988     reg_G2S_DB_WIN1H = (u16)(((x1 << REG_G2S_DB_WIN1H_LEFTX_SHIFT) & REG_G2S_DB_WIN1H_LEFTX_MASK) |
989                              ((x2 << REG_G2S_DB_WIN1H_RIGHTX_SHIFT) &
990                               REG_G2S_DB_WIN1H_RIGHTX_MASK));
991 
992     reg_G2S_DB_WIN1V = (u16)(((y1 << REG_G2S_DB_WIN1V_UPY_SHIFT) & REG_G2S_DB_WIN1V_UPY_MASK) |
993                              ((y2 << REG_G2S_DB_WIN1V_DOWNY_SHIFT) & REG_G2S_DB_WIN1V_DOWNY_MASK));
994 }
995 
996 
997 /*---------------------------------------------------------------------------*
998   Name:         G2S_SetBGMosaicSize
999 
1000   Description:  Specify the size of the mosaic applied on BGs
1001 
1002   Arguments:    hSize     the size of the mosaic in horizontal direction
1003                 vSize     the size of the mosaic in verticale direction
1004 
1005   Returns:      none
1006  *---------------------------------------------------------------------------*/
G2S_SetBGMosaicSize(int hSize,int vSize)1007 static inline void G2S_SetBGMosaicSize(int hSize, int vSize)
1008 {
1009     GX_MOSAICSIZE_ASSERT(hSize);
1010     GX_MOSAICSIZE_ASSERT(vSize);
1011 
1012     *((vu8 *)REG_DB_MOSAIC_ADDR) = (u8)((hSize << REG_G2S_DB_MOSAIC_BGHSIZE_SHIFT) |
1013                                         (vSize << REG_G2S_DB_MOSAIC_BGVSIZE_SHIFT));
1014 
1015 }
1016 
1017 
1018 /*---------------------------------------------------------------------------*
1019   Name:         G2S_SetOBJMosaicSize
1020 
1021   Description:  Specify the size of the mosaic applied on OBJs
1022 
1023   Arguments:    hSize     the size of the mosaic in horizontal direction
1024                 vSize     the size of the mosaic in verticale direction
1025 
1026   Returns:      none
1027  *---------------------------------------------------------------------------*/
G2S_SetOBJMosaicSize(int hSize,int vSize)1028 static inline void G2S_SetOBJMosaicSize(int hSize, int vSize)
1029 {
1030     GX_MOSAICSIZE_ASSERT(hSize);
1031     GX_MOSAICSIZE_ASSERT(vSize);
1032 
1033     *((vu8 *)(REG_DB_MOSAIC_ADDR + 1)) = (u8)((hSize << (REG_G2S_DB_MOSAIC_OBJHSIZE_SHIFT - 8)) |
1034                                               (vSize << (REG_G2S_DB_MOSAIC_OBJVSIZE_SHIFT - 8)));
1035 
1036 }
1037 
1038 
1039 /*---------------------------------------------------------------------------*
1040   Name:         G2S_BlendNone
1041 
1042   Description:  No Blendings between the planes
1043 
1044   Arguments:    none
1045 
1046   Returns:      none
1047  *---------------------------------------------------------------------------*/
G2S_BlendNone()1048 static inline void G2S_BlendNone()
1049 {
1050     reg_G2S_DB_BLDCNT = 0;
1051 }
1052 
1053 
1054 /*---------------------------------------------------------------------------*
1055   Name:         G2S_ChangeBlendAlpha
1056 
1057   Description:  Set blending coefficients directly
1058 
1059   Arguments:    ev1     blending coefficient1
1060                 ev2     blending coefficient2
1061 
1062   Returns:      none
1063  *---------------------------------------------------------------------------*/
G2S_ChangeBlendAlpha(int ev1,int ev2)1064 static inline void G2S_ChangeBlendAlpha(int ev1, int ev2)
1065 {
1066     GX_ALPHA_ASSERT(ev1);
1067     GX_ALPHA_ASSERT(ev2);
1068 
1069     reg_G2S_DB_BLDALPHA = (u16)((ev1 << REG_G2S_DB_BLDALPHA_EVA_SHIFT) |
1070                                 (ev2 << REG_G2S_DB_BLDALPHA_EVB_SHIFT));
1071 }
1072 
1073 
1074 /*---------------------------------------------------------------------------*
1075   Name:         G2S_SetBG2Affine
1076 
1077   Description:  Affine transform on BG2(SUB engine).
1078 
1079   Arguments:    mtx          a pointer to a matrix
1080                 centerX      center of rotation
1081                 centerY      center of rotation
1082                 x1           the upper left point before rotation
1083                 y1           the upper left point before rotation
1084 
1085   Returns:      none
1086  *---------------------------------------------------------------------------*/
G2S_SetBG2Affine(const MtxFx22 * mtx,int centerX,int centerY,int x1,int y1)1087 static inline void G2S_SetBG2Affine(const MtxFx22 *mtx, int centerX, int centerY, int x1, int y1)
1088 {
1089     G2x_SetBGyAffine_((u32)&reg_G2S_DB_BG2PA, mtx, centerX, centerY, x1, y1);
1090 }
1091 
1092 
1093 /*---------------------------------------------------------------------------*
1094   Name:         G2S_SetBG3Affine
1095 
1096   Description:  Affine transform on BG3(SUB engine).
1097 
1098   Arguments:    mtx          a pointer to a matrix
1099                 centerX      center of rotation
1100                 centerY      center of rotation
1101                 x1           the upper left point before rotation
1102                 y1           the upper left point before rotation
1103 
1104   Returns:      none
1105  *---------------------------------------------------------------------------*/
G2S_SetBG3Affine(const MtxFx22 * mtx,int centerX,int centerY,int x1,int y1)1106 static inline void G2S_SetBG3Affine(const MtxFx22 *mtx, int centerX, int centerY, int x1, int y1)
1107 {
1108     G2x_SetBGyAffine_((u32)&reg_G2S_DB_BG3PA, mtx, centerX, centerY, x1, y1);
1109 }
1110 
1111 
1112 /*---------------------------------------------------------------------------*
1113   Name:         G2S_SetBlendAlpha
1114 
1115   Description:  Alpha blending on plane1 and plane2(SUB engine).
1116 
1117   Arguments:    plane1       a set of planes
1118                 plane2       a set of planes
1119                 ev1          coefficient of plane1's color(0 to 16)
1120                 ev2          coefficient of plane2's color(0 to 16)
1121 
1122   Returns:      none
1123  *---------------------------------------------------------------------------*/
G2S_SetBlendAlpha(int plane1,int plane2,int ev1,int ev2)1124 static inline void G2S_SetBlendAlpha(int plane1, int plane2, int ev1, int ev2)
1125 {
1126     G2x_SetBlendAlpha_((u32)&reg_G2S_DB_BLDCNT, plane1, plane2, ev1, ev2);
1127 }
1128 
1129 
1130 /*---------------------------------------------------------------------------*
1131   Name:         G2S_SetBlendBrightness
1132 
1133   Description:  Changes brightness of plane(SUB engine).
1134 
1135   Arguments:    plane        a set of planes
1136                 brightness   chnage of brightness(-16 to 16)
1137 
1138   Returns:      none
1139  *---------------------------------------------------------------------------*/
G2S_SetBlendBrightness(int plane,int brightness)1140 static inline void G2S_SetBlendBrightness(int plane, int brightness)
1141 {
1142     G2x_SetBlendBrightness_((u32)&reg_G2S_DB_BLDCNT, plane, brightness);
1143 }
1144 
1145 
1146 /*---------------------------------------------------------------------------*
1147   Name:         G2S_SetBlendBrightnessExt
1148 
1149   Description:  Changes brightness of plane1,
1150                 and alpha blending on plane1 and plane2(SUB engine).
1151 
1152   Arguments:    plane1       a set of planes
1153                 plane2       a set of planes
1154                 ev1          coefficient of plane1's color(0 to 16)
1155                 ev2          coefficient of plane1's color(0 to 16)
1156                 brightness   change of brightness(-16 to 16)
1157 
1158   Returns:      none
1159  *---------------------------------------------------------------------------*/
G2S_SetBlendBrightnessExt(int plane1,int plane2,int ev1,int ev2,int brightness)1160 static inline void G2S_SetBlendBrightnessExt(int plane1,
1161                                              int plane2, int ev1, int ev2, int brightness)
1162 {
1163     G2x_SetBlendBrightnessExt_((u32)&reg_G2S_DB_BLDCNT, plane1, plane2, ev1, ev2, brightness);
1164 }
1165 
1166 
1167 /*---------------------------------------------------------------------------*
1168   Name:         G2S_ChangeBlendBrightness
1169 
1170   Description:  Change brightness parameter only(SUB engine).
1171 
1172   Arguments:    brightness   change of brightness(-16 to 16)
1173 
1174   Returns:      none
1175  *---------------------------------------------------------------------------*/
G2S_ChangeBlendBrightness(int brightness)1176 static inline void G2S_ChangeBlendBrightness(int brightness)
1177 {
1178     G2x_ChangeBlendBrightness_((u32)&reg_G2S_DB_BLDCNT, brightness);
1179 }
1180 
1181 
1182 
1183 #endif // SDK_FROM_TOOL
1184 
1185 
1186 #ifdef __cplusplus
1187 }/* extern "C" */
1188 #endif
1189 
1190 /* NITRO_G2_H_ */
1191 #endif
1192