1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - GX -
3   File:     gx_capture.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_GX_CAPTURE_H_
19 #define NITRO_GX_CAPTURE_H_
20 
21 #include <nitro/gx/gxcommon.h>
22 #ifdef SDK_NITRO
23 #include <nitro/hw/ARM9/ioreg_GX.h>
24 #else
25 #include <twl/hw/ARM9/ioreg_GX.h>
26 #endif
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 //----------------------------------------------------------------------------
33 // Type definition
34 //----------------------------------------------------------------------------
35 
36 //----------------------------------------------------------------------------
37 //    Parameters for GX_SetCapture
38 //----------------------------------------------------------------------------
39 typedef enum
40 {
41     GX_CAPTURE_DEST_VRAM_A_0x00000 = 0,
42     GX_CAPTURE_DEST_VRAM_B_0x00000 = 1,
43     GX_CAPTURE_DEST_VRAM_C_0x00000 = 2,
44     GX_CAPTURE_DEST_VRAM_D_0x00000 = 3,
45 
46     GX_CAPTURE_DEST_VRAM_A_0x08000 = 4,
47     GX_CAPTURE_DEST_VRAM_B_0x08000 = 5,
48     GX_CAPTURE_DEST_VRAM_C_0x08000 = 6,
49     GX_CAPTURE_DEST_VRAM_D_0x08000 = 7,
50 
51     GX_CAPTURE_DEST_VRAM_A_0x10000 = 8,
52     GX_CAPTURE_DEST_VRAM_B_0x10000 = 9,
53     GX_CAPTURE_DEST_VRAM_C_0x10000 = 10,
54     GX_CAPTURE_DEST_VRAM_D_0x10000 = 11,
55 
56     GX_CAPTURE_DEST_VRAM_A_0x18000 = 12,
57     GX_CAPTURE_DEST_VRAM_B_0x18000 = 13,
58     GX_CAPTURE_DEST_VRAM_C_0x18000 = 14,
59     GX_CAPTURE_DEST_VRAM_D_0x18000 = 15
60 }
61 GXCaptureDest;
62 
63 #define GX_CAPTURE_DEST_ASSERT(x)                         \
64     SDK_MINMAX_ASSERT(x, GX_CAPTURE_DEST_VRAM_A_0x00000, GX_CAPTURE_DEST_VRAM_D_0x18000)
65 
66 
67 typedef enum
68 {
69     GX_CAPTURE_SIZE_128x128 = 0,
70     GX_CAPTURE_SIZE_256x64 = 1,
71     GX_CAPTURE_SIZE_256x128 = 2,
72     GX_CAPTURE_SIZE_256x192 = 3
73 }
74 GXCaptureSize;
75 
76 #define GX_CAPTURE_SIZE_ASSERT(x)                 \
77     SDK_MINMAX_ASSERT(x, GX_CAPTURE_SIZE_128x128, GX_CAPTURE_SIZE_256x192)
78 
79 typedef enum
80 {
81     GX_CAPTURE_SRCA_2D3D = 0,
82     GX_CAPTURE_SRCA_3D = 1
83 }
84 GXCaptureSrcA;
85 
86 #define GX_CAPTURE_SRCA_ASSERT(x)              \
87     SDK_MINMAX_ASSERT(x, GX_CAPTURE_SRCA_2D3D, GX_CAPTURE_SRCA_3D)
88 
89 typedef enum
90 {
91     GX_CAPTURE_SRCB_VRAM_0x00000 = 0,
92     GX_CAPTURE_SRCB_MRAM = 1,
93     GX_CAPTURE_SRCB_VRAM_0x08000 = 2,
94     GX_CAPTURE_SRCB_VRAM_0x10000 = 4,
95     GX_CAPTURE_SRCB_VRAM_0x18000 = 6
96 }
97 GXCaptureSrcB;
98 
99 #define GX_CAPTURE_SRCB_ASSERT(x)                      \
100     SDK_ASSERT( (x) == GX_CAPTURE_SRCB_VRAM_0x00000 || \
101                 (x) == GX_CAPTURE_SRCB_MRAM         || \
102                 (x) == GX_CAPTURE_SRCB_VRAM_0x08000 || \
103                 (x) == GX_CAPTURE_SRCB_VRAM_0x10000 || \
104                 (x) == GX_CAPTURE_SRCB_VRAM_0x18000 )
105 
106 typedef enum
107 {
108     GX_CAPTURE_MODE_A = 0,
109     GX_CAPTURE_MODE_B = 1,
110     GX_CAPTURE_MODE_AB = 2
111 }
112 GXCaptureMode;
113 
114 #define GX_CAPTURE_MODE_ASSERT(x) SDK_MINMAX_ASSERT(x, GX_CAPTURE_MODE_A, GX_CAPTURE_MODE_AB)
115 
116 
117 /* if include from Other Environment for exsample VC or BCB, */
118 /* please define SDK_FROM_TOOL                               */
119 #if !(defined(SDK_WIN32) || defined(SDK_FROM_TOOL))
120 
121 //----------------------------------------------------------------------------
122 // Declaration of function
123 //----------------------------------------------------------------------------
124 
125 // DISPCAPCNT
126 static void GX_SetCapture(GXCaptureSize sz,
127                           GXCaptureMode mode,
128                           GXCaptureSrcA a, GXCaptureSrcB b, GXCaptureDest dest, int eva, int evb);
129 
130 
131 //----------------------------------------------------------------------------
132 // Implementation of inline function
133 //----------------------------------------------------------------------------
134 
135 /*---------------------------------------------------------------------------*
136   Name:         GX_SetCapture
137 
138   Description:  Specify attributes for display capture
139 
140   Arguments:    sz        capture size
141                 mode      capture mode
142                 a         capture data src A
143                 b         capture data src B
144                 dest      capture data dest
145                 eva       blending ratio of src A
146                 evb       blending ratio of src B
147 
148   Returns:      none
149  *---------------------------------------------------------------------------*/
GX_SetCapture(GXCaptureSize sz,GXCaptureMode mode,GXCaptureSrcA a,GXCaptureSrcB b,GXCaptureDest dest,int eva,int evb)150 static inline void GX_SetCapture(GXCaptureSize sz,
151                                  GXCaptureMode mode,
152                                  GXCaptureSrcA a,
153                                  GXCaptureSrcB b, GXCaptureDest dest, int eva, int evb)
154 {
155     GX_CAPTURE_DEST_ASSERT(dest);
156     GX_CAPTURE_SIZE_ASSERT(sz);
157     GX_CAPTURE_SRCA_ASSERT(a);
158     GX_CAPTURE_SRCB_ASSERT(b);
159     GX_CAPTURE_MODE_ASSERT(mode);
160     SDK_MINMAX_ASSERT(eva, 0, 16);
161     SDK_MINMAX_ASSERT(evb, 0, 16);
162 
163     reg_GX_DISPCAPCNT = (REG_GX_DISPCAPCNT_E_MASK |
164                          (mode << REG_GX_DISPCAPCNT_MOD_SHIFT) |
165                          (b << REG_GX_DISPCAPCNT_SRCB_SHIFT) |
166                          (a << REG_GX_DISPCAPCNT_SRCA_SHIFT) |
167                          (sz << REG_GX_DISPCAPCNT_WSIZE_SHIFT) |
168                          (dest << REG_GX_DISPCAPCNT_DEST_SHIFT) |
169                          (evb << REG_GX_DISPCAPCNT_EVB_SHIFT) |
170                          (eva << REG_GX_DISPCAPCNT_EVA_SHIFT));
171 }
172 
173 /*---------------------------------------------------------------------------*
174   Name:         GX_ResetCapture
175 
176   Description:  Reset display capture
177 
178   Arguments:    none
179 
180   Returns:      none
181  *---------------------------------------------------------------------------*/
GX_ResetCapture(void)182 static inline void GX_ResetCapture(void)
183 {
184     reg_GX_DISPCAPCNT &= ~REG_GX_DISPCAPCNT_E_MASK;
185 }
186 
187 
188 #endif // SDK_FROM_TOOL
189 
190 #ifdef __cplusplus
191 }/* extern "C" */
192 #endif
193 
194 #endif
195