1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: gr_LookUpTable.cpp 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: 33699 $ 14 *---------------------------------------------------------------------------*/ 15 16 #include <nn/gr/CTR/gr_LookUpTable.h> 17 18 namespace nn 19 { 20 namespace gr 21 { 22 namespace CTR 23 { 24 SetTable(const f32 table[LOOKUP_TABLE_ELEMENT_NUM],const f32 lastDiffValue,const bool isInputAbs)25 void LookUpTable::SetTable( const f32 table[ LOOKUP_TABLE_ELEMENT_NUM ], 26 const f32 lastDiffValue, 27 const bool isInputAbs ) 28 { 29 // 入力値が [0.0, 1.0] の場合 30 if ( isInputAbs ) 31 { 32 SetAbsTable( table, lastDiffValue ); 33 } 34 // 入力値が [-1.0, 1.0] の場合 35 else 36 { 37 SetNotAbsTable( table, lastDiffValue ); 38 } 39 } 40 SetAbsTable(const f32 table[LOOKUP_TABLE_ELEMENT_NUM],const f32 lastDiffValue)41 void LookUpTable::SetAbsTable( const f32 table[ LOOKUP_TABLE_ELEMENT_NUM ], 42 const f32 lastDiffValue ) 43 { 44 bit32* command = m_TableCommand; 45 46 // 入力値が [0.0, 1.0] の場合 47 48 int i = 0; 49 *command++ = Float32ToUnsignedFix12( table[ i ] ) | 50 Float32ToFix12( table[ i + 1 ] - table[ i ] ) << 12; 51 *command++ = PICA_CMD_HEADER_BURST( PICA_REG_FRAG_LIGHT_LUT_DATA0, 128 ); 52 53 for ( ++i; i < 0x80; ++i ) 54 { 55 *command++ = Float32ToUnsignedFix12( table[ i ] ) | 56 Float32ToFix12( table[ i + 1 ] - table[ i ] ) << 12; 57 } 58 *command++ = 0; 59 60 *command++ = Float32ToUnsignedFix12( table[ i ] )| 61 Float32ToFix12( table[ i + 1 ] - table[ i ] ) << 12; 62 *command++ = PICA_CMD_HEADER_BURST( PICA_REG_FRAG_LIGHT_LUT_DATA0, 128 ); 63 64 for ( ++i; i < 0xff; ++i ) 65 { 66 *command++ = Float32ToUnsignedFix12( table[ i ] ) | 67 Float32ToFix12( table[ i + 1 ] - table[ i ] ) << 12; 68 } 69 70 // 最後の差分値 71 *command++ = Float32ToUnsignedFix12( table[ i ] ) | 72 Float32ToFix12( lastDiffValue ) << 12; 73 *command++ = 0; 74 } 75 SetNotAbsTable(const f32 table[LOOKUP_TABLE_ELEMENT_NUM],const f32 lastDiffValue)76 void LookUpTable::SetNotAbsTable( const f32 table[ LOOKUP_TABLE_ELEMENT_NUM ], 77 const f32 lastDiffValue ) 78 { 79 bit32* command = m_TableCommand; 80 81 // 入力値が [0.0, 1.0] の場合 82 83 const u32 LOOKUP_TABLE_HALF_ELEMENT_NUM = LOOKUP_TABLE_ELEMENT_NUM / 2; 84 85 u32 i = LOOKUP_TABLE_HALF_ELEMENT_NUM; 86 87 *command++ = Float32ToUnsignedFix12( table[ i ] ) | 88 Float32ToFix12( table[ i + 1 ] - table[ i ] ) << 12; 89 *command++ = PICA_CMD_HEADER_BURST( PICA_REG_FRAG_LIGHT_LUT_DATA0, 128 ); 90 91 for ( ++i; i < 0xff; ++i ) 92 { 93 *command++ = Float32ToUnsignedFix12( table[ i ] ) | 94 Float32ToFix12( table[ i + 1 ] - table[ i ] ) << 12; 95 } 96 97 // 最後の差分値 98 *command++ = Float32ToUnsignedFix12( table[ i ] ) | 99 Float32ToFix12( lastDiffValue ) << 12; 100 *command++ = 0; 101 102 103 // 入力値が [-1.0, 0.0] の場合 104 105 i = 0; 106 107 *command++ = Float32ToUnsignedFix12( table[ i ] ) | 108 Float32ToFix12( table[ i + 1 ] - table[ i ] ) << 12; 109 *command++ = PICA_CMD_HEADER_BURST( PICA_REG_FRAG_LIGHT_LUT_DATA0, 128 ); 110 111 for ( ++i; i < 0x80; ++i ) 112 { 113 *command++ = Float32ToUnsignedFix12( table[ i ] ) | 114 Float32ToFix12( table[ i + 1 ] - table[ i ] ) << 12; 115 } 116 *command++ = 0; 117 } 118 119 } // namespace CTR 120 } // namespace gr 121 } // namespace nn 122