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