1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: gr_Fog.h 4 5 Copyright (C)2009-2012 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: 47511 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NN_GR_CTR_GR_FOG_H_ 17 #define NN_GR_CTR_GR_FOG_H_ 18 19 #include <nn/gr/CTR/gr_Utility.h> 20 21 namespace nn 22 { 23 namespace gr 24 { 25 namespace CTR 26 { 27 28 /* Please see man pages for details 29 30 */ 31 class Fog 32 { 33 public : 34 // 35 static const u32 FOG_LOOKUP_TABLE_ELEMENT_NUM = 128; 36 37 public : 38 /* Please see man pages for details 39 40 41 */ 42 bool isEnable; 43 44 /* Please see man pages for details 45 46 47 */ 48 bool isEnableZFlip; 49 50 /* Please see man pages for details 51 52 53 */ 54 u8 colorR; 55 56 /* Please see man pages for details 57 58 59 */ 60 u8 colorG; 61 62 /* Please see man pages for details 63 64 65 */ 66 u8 colorB; 67 NN_PADDING3; 68 69 public : 70 /* Please see man pages for details 71 72 73 74 75 */ 76 void SetTable( const f32 table[ FOG_LOOKUP_TABLE_ELEMENT_NUM ], 77 const f32 lastDiffValue = 0.0f ); 78 79 /* Please see man pages for details 80 81 82 83 84 85 */ MakeAllCommand(bit32 * command)86 bit32* MakeAllCommand( bit32* command ) const 87 { 88 // Set command 89 command = MakeConfigCommand( command ); 90 91 // Fog lookup table commands 92 if ( isEnable ) 93 { 94 command = MakeTableCommand( command ); 95 } 96 return command; 97 } 98 99 100 /* Please see man pages for details 101 102 103 104 105 106 */ MakeDisableCommand(bit32 * command)107 static bit32* MakeDisableCommand( bit32* command ) 108 { 109 // 0x0e0 110 *command++ = PICA_DATA_FOG_FALSE; 111 *command++ = PICA_CMD_HEADER_SINGLE_BE( PICA_REG_GAS_FOG_MODE, 0x1 ); 112 113 return command; 114 } 115 116 /* Please see man pages for details 117 118 119 120 121 122 */ MakeConfigCommand(bit32 * command)123 bit32* MakeConfigCommand( bit32* command ) const 124 { 125 // 0x0e0 126 *command++ = ( isEnable ? PICA_DATA_FOG : PICA_DATA_FOG_FALSE ) | ( ( isEnableZFlip ? 1 : 0 ) << 16 ); 127 *command++ = PICA_CMD_HEADER_SINGLE_BE( PICA_REG_GAS_FOG_MODE, 0x5 ); 128 129 // 0x0e1 130 *command++ = colorR | colorG << 8 | colorB << 16; 131 *command++ = PICA_CMD_HEADER_SINGLE( PICA_REG_FOG_COLOR ); 132 133 return command; 134 } 135 136 /* Please see man pages for details 137 138 139 140 141 142 */ MakeTableCommand(bit32 * command)143 bit32* MakeTableCommand( bit32* command ) const 144 { 145 std::memcpy( command, m_TableCommand, sizeof( m_TableCommand ) ); 146 return command + ( FOG_LOOKUP_TABLE_ELEMENT_NUM + 4 ); 147 } 148 149 public : 150 /* Please see man pages for details 151 152 */ Fog()153 Fog() : 154 isEnable( false ), 155 isEnableZFlip( false ), 156 colorR( 0 ), 157 colorG( 0 ), 158 colorB( 0 ) 159 { 160 for ( u32 index = 0; index < ( FOG_LOOKUP_TABLE_ELEMENT_NUM + 4 ); index++ ) 161 { 162 m_TableCommand[ index ] = 0; 163 } 164 } 165 166 protected : 167 /* Please see man pages for details 168 169 170 */ 171 u32 m_TableCommand[ FOG_LOOKUP_TABLE_ELEMENT_NUM + 4 ]; 172 }; 173 174 } // namespace CTR 175 } // namespace gr 176 } //namespace nn 177 178 #endif // NN_GR_CTR_GR_FOG_H_ 179