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: 26824 $
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])25             void LookUpTable::SetTable( const f32 table[ LOOKUP_TABLE_ELEMENT_NUM ] )
26             {
27                 bit32* command = m_TableCommand;
28 
29                 int i = 0;
30                 *command++ = Float32ToUnsignedFix12( table[ i ] ) | Float32ToFix12( table[ i + 1 ] - table[ i ] ) << 12;
31                 *command++ = PICA_CMD_HEADER_BURST( PICA_REG_FRAG_LIGHT_LUT_DATA0, 128 );
32 
33                 for ( ++i; i < 0x80; ++i )
34                 {
35                     *command++ = Float32ToUnsignedFix12( table[ i ] ) | Float32ToFix12( table[ i + 1 ] - table[ i ] ) << 12;
36                 }
37                 *command++ = 0;
38 
39                 *command++ = Float32ToUnsignedFix12( table[ i ] ) | Float32ToFix12( table[ i + 1 ] - table[ i ] ) << 12;
40                 *command++ = PICA_CMD_HEADER_BURST( PICA_REG_FRAG_LIGHT_LUT_DATA0, 128 );
41 
42                 for ( ++i; i < 0xff; ++i )
43                 {
44                     *command++ = Float32ToUnsignedFix12( table[ i ] ) | Float32ToFix12( table[ i + 1 ] - table[ i ] ) << 12;
45                 }
46 
47                 *command++ = Float32ToUnsignedFix12( table[ i ] );
48                 *command++ = 0;
49             }
50 
51         } // namespace CTR
52     } // namespace gr
53 } // namespace nn
54