1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: gr_LookUpTable.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_LOOK_UP_TABLE_H_ 17 #define NN_GR_LOOK_UP_TABLE_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 LookUpTable 32 { 33 public : 34 //! 参照テーブルは256個の要素を持ちます。 35 static const u32 LOOKUP_TABLE_ELEMENT_NUM = 256; 36 37 public : 38 /*! 39 @brief 参照テーブルを設定します。 40 41 @param[in] table 256個の参照データです。 42 */ 43 void SetTable( const f32 table[ LOOKUP_TABLE_ELEMENT_NUM ] ); 44 45 /*! 46 @brief 参照テーブルをロードするコマンドを生成します。 47 48 @param[in] command 描画コマンドの書き込み先の先頭アドレスです。 49 @param[in] type 参照テーブルのロード先の指定です。 50 51 @return 書き込まれた描画コマンドの終端の次のアドレスを返します。 52 */ 53 /* 54 type は PICA_DATA_SAMPLER_D0、 55 PICA_DATA_SAMPLER_D1、 56 PICA_DATA_SAMPLER_FR、 57 PICA_DATA_SAMPLER_FB、 58 PICA_DATA_SAMPLER_FG、 59 PICA_DATA_SAMPLER_RR 60 のいずれかを指定します。 61 */ 62 MakeCommand(bit32 * command,const PicaDataFragLightSampler type)63 bit32* MakeCommand( bit32* command, const PicaDataFragLightSampler type ) const 64 { 65 // 0x1c5 66 *command++ = PICA_CMD_DATA_FRAG_LIGHT_LUT( 0, type ); 67 *command++ = PICA_CMD_HEADER_SINGLE( PICA_REG_FRAG_LIGHT_LUT ); 68 69 std::memcpy( command, m_TableCommand, sizeof( m_TableCommand ) ); 70 71 return command + ( LOOKUP_TABLE_ELEMENT_NUM + 4 ); 72 }; 73 74 /*! 75 @brief スポットライトの角度減衰で用いられる参照テーブルをロードするコマンドを生成します。 76 77 @param[in] command 描画コマンドの書き込み先の先頭アドレスです。 78 @param[in] light_id スポットライト参照テーブルのロード先を、光源番号で指定します。 79 80 @return 書き込まれた描画コマンドの終端の次のアドレスを返します。 81 */ MakeSpotTableCommand(bit32 * command,u8 light_id)82 bit32* MakeSpotTableCommand( bit32* command, u8 light_id ) const 83 { 84 return MakeCommand( command, static_cast< PicaDataFragLightSampler >( PICA_DATA_SAMPLER_SP + light_id ) ); 85 } 86 87 /*! 88 @brief ライトの距離減衰で用いられる参照テーブルをロードするコマンドを生成します。 89 90 @param[in] command 描画コマンドの書き込み先の先頭アドレスです。 91 @param[in] light_id 距離減衰参照テーブルのロード先を、光源番号で指定します。 92 93 @return 書き込まれた描画コマンドの終端の次のアドレスを返します。 94 */ MakeDistAttnTableCommand(bit32 * command,u8 light_id)95 bit32* MakeDistAttnTableCommand( bit32* command, u8 light_id ) const 96 { 97 return MakeCommand( command, static_cast< PicaDataFragLightSampler >( PICA_DATA_SAMPLER_DA + light_id ) ); 98 } 99 100 private : 101 /*! 102 @brief 参照テーブルを描画コマンドの形に変換して保持します。 103 型は bit32 です。 104 配列の上限値は nn::gr::CTR::LookUpTable::LOOKUP_TABLE_ELEMENT_NUM + 4 です。 105 */ 106 bit32 m_TableCommand[ LOOKUP_TABLE_ELEMENT_NUM + 4 ]; 107 }; 108 109 } // namespace CTR 110 } // namespace gr 111 } // namespace nn 112 113 #endif // NN_GR_LOOK_UP_TABLE_H_ 114