1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: gr_Fog.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: 29329 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NN_GR_FRAGMENT_FOG_H_ 17 #define NN_GR_FRAGMENT_FOG_H_ 18 19 #include <nn/gr/CTR/gr_Prefix.h> 20 21 namespace nn 22 { 23 namespace gr 24 { 25 namespace CTR 26 { 27 28 /*! 29 @brief フォグ関連のコマンドを生成するのためのクラスです。 30 */ 31 class Fog 32 { 33 public : 34 //! フォグ参照テーブルは128個の要素を持ちます。 35 static const u32 FOG_LOOKUP_TABLE_ELEMENT_NUM = 128; 36 37 public : 38 /*! 39 @brief フォグを有効にする場合はtrueを設定します。 40 型は bool です。 41 */ 42 bool isEnable; 43 44 /*! 45 @brief Zフリップモードの有効化/無効化の設定です。 46 型は bool です。 47 */ 48 bool isEnableZFlip; 49 50 /*! 51 @brief フォグカラーの赤成分です。 52 型は u8 です。 53 */ 54 u8 colorR; 55 56 /*! 57 @brief フォグカラーの緑成分です。 58 型は u8 です。 59 */ 60 u8 colorG; 61 62 /*! 63 @brief フォグカラーの青成分です。 64 型は u8 です。 65 */ 66 u8 colorB; 67 NN_PADDING3; 68 69 public : 70 71 72 /*! 73 @brief フォグ参照テーブルを設定します。 74 75 @param[in] table 128個の参照データです。 76 */ 77 void SetTable( const f32 table[ FOG_LOOKUP_TABLE_ELEMENT_NUM ] ); 78 79 80 /*! 81 @brief フォグを設定するコマンドを生成します。 82 83 @param[in] command 描画コマンドの書き込み先の先頭アドレスです。 84 85 @return 書き込まれた描画コマンドの終端の次のアドレスを返します。 86 */ MakeAllCommand(bit32 * command)87 bit32* MakeAllCommand( bit32* command ) const 88 { 89 command = MakeConfigCommand( command ); // 設定用コマンド 90 if ( isEnable ) command = MakeTableCommand( command ); // フォグの参照テーブルコマンド 91 return command; 92 } 93 94 /*! 95 @brief フォグを設定するコマンドを生成します。 96 97 @param[in] command 描画コマンドの書き込み先の先頭アドレスです。 98 99 @return 書き込まれた描画コマンドの終端の次のアドレスを返します。 100 */ MakeConfigCommand(bit32 * command)101 bit32* MakeConfigCommand( bit32* command ) const 102 { 103 // 0x0e0 104 *command++ = ( isEnable ? PICA_DATA_FOG : PICA_DATA_FOG_FALSE ) | ( ( isEnableZFlip ? 1 : 0 ) << 16 ); 105 *command++ = PICA_CMD_HEADER_SINGLE_BE( PICA_REG_GAS_FOG_MODE, 0x5 ); 106 107 // 0x0e1 108 *command++ = colorR | colorG << 8 | colorB << 16; 109 *command++ = PICA_CMD_HEADER_SINGLE( PICA_REG_FOG_COLOR ); 110 111 return command; 112 } 113 114 /*! 115 @brief フォグを設定するコマンドを生成します。 116 117 @param[in] command 描画コマンドの書き込み先の先頭アドレスです。 118 119 @return 書き込まれた描画コマンドの終端の次のアドレスを返します。 120 */ MakeTableCommand(bit32 * command)121 bit32* MakeTableCommand( bit32* command ) const 122 { 123 std::memcpy( command, m_TableCommand, sizeof( m_TableCommand ) ); 124 return command + ( FOG_LOOKUP_TABLE_ELEMENT_NUM + 4 ); 125 } 126 127 public : 128 /*! 129 @brief フォグを設定するコマンドを生成します。 130 */ Fog()131 Fog() : isEnable( false ), isEnableZFlip( false ), colorR( 0 ), colorG( 0 ), colorB( 0 ) {} 132 133 private : 134 135 /*! 136 @brief 参照テーブルを描画コマンドの形に変換して保持します。 137 型は u32[] です。 138 */ 139 u32 m_TableCommand[ FOG_LOOKUP_TABLE_ELEMENT_NUM + 4 ]; 140 }; 141 142 } // namespace CTR 143 } // namespace gr 144 } //namespace nn 145 146 #endif // NN_GR_FRAGMENT_FOG_H_ 147