1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     font_DispStringBuffer.cpp
4 
5   Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain proprietary
8   information of Nintendo and/or its licensed developers and are protected by
9   national and international copyright laws. They may not be disclosed to third
10   parties or copied or duplicated in any form, in whole or in part, without the
11   prior written consent of Nintendo.
12 
13   The content herein is highly confidential and should be handled accordingly.
14 
15   $Revision: 31311 $
16  *---------------------------------------------------------------------------*/
17 
18 #include "precompiled.h"
19 
20 #include <nn/types.h>
21 #include <nn/assert.h>
22 
23 #include <nw/config.h>
24 #include <nw/font/font_DispStringBuffer.h>
25 
26 namespace nw {
27 namespace font {
28 
DispStringBuffer(u32 charNum)29 DispStringBuffer::DispStringBuffer(u32 charNum)
30 :   charCountMax(charNum),
31     charCount(0),
32     commandBufferSize(0),
33     textColorCommandOffset(0)
34 {
35     ResetDrawCharCount();
36     ClearCommand();
37 
38     u8* ptr = reinterpret_cast<u8*>(this->GetCharAttrs())
39                + sizeof(internal::CharAttribute) * this->charCountMax;
40 
41     this->drawFlags = ptr;
42     const u32 drawFlagBytes = math::RoundUp(this->charCountMax, 8) / 8;
43     ptr += math::RoundUp(drawFlagBytes, sizeof(u32));
44 
45     this->commandBuffer = reinterpret_cast<u32*>(ptr);
46     this->commandBufferCapacity = CalcCommandBufferCapacity(charNum);
47     ptr += sizeof(u32) * this->commandBufferCapacity;
48 }
49 
50 }   // namespace font
51 }   // namespace nw
52