1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     font_DispStringBuffer.h
4 
5   Copyright (C)2009-2012 Nintendo Co., Ltd./HAL Laboratory, Inc.  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   $Revision: 46347 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_FONT_CTR_FONT_DISP_STRING_BUFFER_H_
17 #define NN_FONT_CTR_FONT_DISP_STRING_BUFFER_H_
18 
19 #include <nn/font/font_Types.h>
20 
21 namespace nn {
22 namespace font {
23 namespace CTR {
24 
25 struct CharAttribute
26 {
27     math::VEC4          pos;
28     util::Color8        color[internal::TEXTCOLOR_MAX];
29     math::VEC4          tex;
30     const internal::TextureObject*
31                         pTexObj;        //
32 };
33 
34 //---------------------------------------------------------------------------
35 //
36 //---------------------------------------------------------------------------
37 struct DispStringBuffer
38 {
39     const u32           charCountMax;           //
40 
41     u16                 charCount;              //
42     u16                 drawCharCount;          //
43 
44     u8                  generatedCommand;       //
45     u8                  padding[3];
46 
47     u8*                 drawFlags;              //
48     u32*                commandBuffer;          //
49     u32                 commandBufferSize;      //
50     u32                 commandBufferCapacity;  //
51     u32                 textColorCommandOffset; //
52 
53     //
GetCharAttrsDispStringBuffer54     CharAttribute* GetCharAttrs() const
55     {
56         return reinterpret_cast<CharAttribute*>( reinterpret_cast<uptr>(this) + sizeof(*this) );
57     }
58 
59     static u32          CalcCommandBufferCapacity(u32 charNum);
60 
61     //
62     explicit            DispStringBuffer(u32 charNum);
63 
64     //
ClearCommandDispStringBuffer65     void                ClearCommand()
66     {
67         generatedCommand = false;
68     }
69 
70     //
IsGeneratedCommandDispStringBuffer71     bool                IsGeneratedCommand()
72     {
73         return 0 != generatedCommand;
74     }
75 
76     //
IsCommandEmptyDispStringBuffer77     bool                IsCommandEmpty()
78     {
79         return 0 == commandBufferSize;
80     }
81 
82     //
GetDrawCharCountDispStringBuffer83     u16                 GetDrawCharCount() const    { return drawCharCount; }
84 
85     //
SetDrawCharCountDispStringBuffer86     void                SetDrawCharCount(u16 count)
87     {
88         drawCharCount = count;
89     }
90 
91     //
ResetDrawCharCountDispStringBuffer92     void                ResetDrawCharCount()
93     {
94         SetDrawCharCount(0xFFFF);
95     }
96 };
97 
98 }   // namespace CTR
99 }   // namespace font
100 }   // namespace nn
101 
102 #endif //  NN_FONT_CTR_FONT_DISP_STRING_BUFFER_H_
103