1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     pl_SharedFont.h
4 
5   Copyright (C)2010 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: 25126 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_PL_CTR_PL_SHAREDFONT_H_
17 #define NN_PL_CTR_PL_SHAREDFONT_H_
18 
19 #include <nn/Handle.h>
20 #include <nn/Result.h>
21 #include <nn/types.h>
22 #include <nn/fnd.h>
23 
24 namespace nn {
25 namespace pl {
26 namespace CTR {
27 
28 /*!
29     @name       共有フォント
30     @{
31  */
32 /*!
33     @brief  共有フォントの種類を表します。
34  */
35 enum SharedFontType
36 {
37     SHARED_FONT_TYPE_NULL,
38     SHARED_FONT_TYPE_STD,     //!< 日米欧フォント
39     SHARED_FONT_TYPE_CN,      //!< 中国フォント
40     SHARED_FONT_TYPE_KR,      //!< 韓国フォント
41     SHARED_FONT_TYPE_TW       //!< 台湾フォント
42 };
43 
44 /*!
45     @brief  共有フォントのロード状態を表します。
46  */
47 enum SharedFontLoadState
48 {
49     SHARED_FONT_LOAD_STATE_NULL,
50     SHARED_FONT_LOAD_STATE_LOADING,     //!< ロード中
51     SHARED_FONT_LOAD_STATE_LOADED,      //!< ロード済
52     SHARED_FONT_LOAD_STATE_FAILED,      //!< ロード失敗
53 
54     SHARED_FONT_LOAD_STATE_MAX_BIT = (1u << 31)
55 };
56 
57 namespace detail
58 {
59     // 共有フォント用共有メモリのサイズ: 3,236 MB
60     const size_t  SHAREDFONT_MEMORY_SIZE = 1024 * 4 * 809;
61 
62     struct SharedFontBufferHeader
63     {
64         util::SizedEnum4<SharedFontLoadState>   state;
65         util::SizedEnum4<SharedFontType>        type;
66         size_t                                  size;
67         bit8                                    padding[116];
68     };
69 
70     struct SharedFontBuffer
71     {
72         SharedFontBufferHeader  header;
73         // 128 byte アライメントが必要
74         bit8    font[SHAREDFONT_MEMORY_SIZE - sizeof(SharedFontBufferHeader)];
75     };
76 }
77 
78 /*!
79     @brief      共有フォントを使用可能にします。
80     @return     処理結果を返します。
81  */
82 nn::Result          InitializeSharedFont();
83 
84 /*!
85     @brief      共有フォントのアドレスを取得します。
86     @return     共有フォントのアドレスを返します。
87  */
88 void*               GetSharedFontAddress();
89 
90 /*!
91     @brief      共有フォントのサイズを取得します。
92     @return     共有フォントのサイズを返します。
93  */
94 size_t              GetSharedFontSize();
95 
96 /*!
97     @brief      共有フォントの種類を取得します。
98     @return     共有フォントの種類を返します。
99  */
100 SharedFontType      GetSharedFontType();
101 
102 /*!
103     @brief      共有フォントのロード状態を取得します。
104     @return     共有フォントのロード状態を返します。
105  */
106 SharedFontLoadState GetSharedFontLoadState();
107 
108 /*!
109     @}
110  */
111 
112 } // end of namespace CTR
113 } // end of namespace pl
114 } // end of namespace nn
115 
116 
117 #endif  // ifndef NN_PL_CTR_PL_SHAREDFONT_H_
118