1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     dbg_DirectPrint.h
4 
5   Copyright (C)2009-2012 Nintendo Co., Ltd.  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   $Rev: 48011 $
14  *---------------------------------------------------------------------------*/
15 
16 /* Please see man pages for details
17 
18 
19 
20 */
21 
22 #ifndef NN_DBG_CTR_DBG_DIRECTPRINT_H_
23 #define NN_DBG_CTR_DBG_DIRECTPRINT_H_
24 
25 #ifdef  __cplusplus
26 
27 #include <nn/util/util_Color.h>
28 #include <gles2/gl2.h>
29 
30 namespace nn { namespace dbg { namespace CTR {
31 
32 //----------------------------------------------------------------------
33 //
34 //
35 //
36 //
37 //
38 //
39 //
40 //
41 //----------------------------------------------------------------------
42 class DirectPrint
43 {
44 public:
45     //----------------------------------------------------------------------
46     //
47     //----------------------------------------------------------------------
48     static const int FONT_WIDTH  = 6;
49 
50     //----------------------------------------------------------------------
51     //
52     //----------------------------------------------------------------------
53     static const int FONT_HEIGHT = 8;
54 
55 public:
56     DirectPrint();
57     ~DirectPrint();
58 
59 public:
60 
61 //
62 //
63 
64     //----------------------------------------------------------------------
65     //
66     //
67     //
68     //
69     //
70     //
71     //
72     //
73     //
74     //
75     //
76     //
77     //
78     //
79     //
80     //
81     //
82     //----------------------------------------------------------------------
83     void ChangeDisplaybuffer( void* dispbuf, GLenum format, const nn::math::VEC2& size );
84 
85     //----------------------------------------------------------------------
86     //
87     //
88     //
89     //
90     //
91     //
92     //
93     //
94     //
95     //
96     //
97     //
98     //----------------------------------------------------------------------
99     void ChangeDisplaybuffer( void* dispbuf );
100 
101     //----------------------------------------------------------------------
102     //
103     //
104     //
105     //----------------------------------------------------------------------
GetDisplaybuffer()106     void* GetDisplaybuffer() { return static_cast<void*>(m_CurBuffer); }
107 
108 //
109 
110 //
111 //
112 
113     //----------------------------------------------------------------------
114     //
115     //
116     //
117     //----------------------------------------------------------------------
118     void Flush();
119 
120     //----------------------------------------------------------------------
121     //
122     //----------------------------------------------------------------------
123     void Clear();
124 
125 //
126 
127 //
128 //
129 
130     //----------------------------------------------------------------------
131     //
132     //
133     //
134     //
135     //
136     //
137     //
138     //
139     //
140     //
141     //
142     //
143     //
144     //----------------------------------------------------------------------
145     void Printf( const nn::math::VEC2& pos, bool autoLineFeed, bool fillBg, const char* format, ... );
146 
147     //----------------------------------------------------------------------
148     //
149     //
150     //
151     //
152     //
153     //
154     //
155     //----------------------------------------------------------------------
156     void Printf( const nn::math::VEC2& pos, const char* format, ... );
157 
158     //----------------------------------------------------------------------
159     //
160     //
161     //
162     //
163     //
164     //
165     //
166     //
167     //
168     //----------------------------------------------------------------------
169     void VPrintf( const nn::math::VEC2& pos, bool autoLineFeed, bool fillBg, const char* format, va_list v );
170 
171     //----------------------------------------------------------------------
172     //
173     //
174     //
175     //
176     //
177     //
178     //
179     //----------------------------------------------------------------------
180     void VPrintf( const nn::math::VEC2& pos, const char* format, va_list v );
181 
182     //----------------------------------------------------------------------
183     //
184     //
185     //
186     //
187     //
188     //
189     //
190     //
191     //
192     //
193     //----------------------------------------------------------------------
194     void PutString( const nn::math::VEC2& pos, bool autoLineFeed, bool fillBg, const char* str );
195 
196     //----------------------------------------------------------------------
197     //
198     //
199     //
200     //
201     //
202     //
203     //----------------------------------------------------------------------
204     void PutString( const nn::math::VEC2& pos, const char* str );
205 
206     //----------------------------------------------------------------------
207     //
208     //
209     //
210     //
211     //
212     //----------------------------------------------------------------------
213     void PutChar( const nn::math::VEC2& pos, bool fillBg, char c );
214 
215     //----------------------------------------------------------------------
216     //
217     //
218     //
219     //
220     //
221     //
222     //----------------------------------------------------------------------
223     void PutChar( const nn::math::VEC2& pos, char c );
224 
225 //
226 
227 //
228 //
229 
230     //----------------------------------------------------------------------
231     //
232     //
233     //
234     //----------------------------------------------------------------------
SetCharColor(const nn::util::Color8 & c)235     void SetCharColor( const nn::util::Color8& c ) { m_CharColor = c; };
236 
237     //----------------------------------------------------------------------
238     //
239     //
240     //
241     //----------------------------------------------------------------------
GetCharColor()242     const nn::util::Color8& GetCharColor() const { return m_CharColor; };
243 
244     //----------------------------------------------------------------------
245     //
246     //
247     //
248     //----------------------------------------------------------------------
SetBgColor(const nn::util::Color8 & c)249     void SetBgColor( const nn::util::Color8& c ) { m_BgColor = c; };
250 
251     //----------------------------------------------------------------------
252     //
253     //
254     //
255     //----------------------------------------------------------------------
GetBgColor()256     const nn::util::Color8& GetBgColor() const { return m_BgColor; };
257 
258     //----------------------------------------------------------------------
259     //
260     //
261     //
262     //
263     //
264     //
265     //----------------------------------------------------------------------
GetLastCursorPos()266     const nn::math::VEC2& GetLastCursorPos() const { return m_LastCursorPos; };
267 
268     //----------------------------------------------------------------------
269     //
270     //
271     //
272     //
273     //
274     //
275     //----------------------------------------------------------------------
SetFillSpace(bool fillSpace)276     void SetFillSpace(bool fillSpace) { m_FillSpace = fillSpace; }
277 
278 //
279 
280 
281 
282 private:
283     void ConvertColorFormat( bit8* data, const nn::util::Color8& src, GLenum format );
284     void ConvertPositionUserOriginToDeviceOrigin( nn::math::VEC2* dst, const nn::math::VEC2& src );
285     void PutDot( const nn::math::VEC2& bufPos, const bit8* data, s32 byteByDot );
286 
287 private:
288     bit8*               m_CurBuffer;     //
289     GLenum              m_BufferFormat;  //
290     nn::math::VEC2      m_BufferSize;    //
291     nn::util::Color8    m_CharColor;     //
292     nn::util::Color8    m_BgColor;       //
293     nn::math::VEC2      m_LastCursorPos; //
294     bool                m_FillSpace;
295     NN_PADDING3;
296 };
297 
298 }}}
299 #endif
300 
301 #endif  // NN_DBG_CTR_DBG_DIRECTPRINT_H_
302