1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: gr_Viewport.cpp 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: 46347 $ 14 *---------------------------------------------------------------------------*/ 15 16 #include <nn/gr/CTR/gr_Viewport.h> 17 #include <nn/gr/CTR/gr_Utility.h> 18 19 namespace nn 20 { 21 namespace gr 22 { 23 namespace CTR 24 { 25 MakeCommand(bit32 * command) const26 bit32* Viewport::MakeCommand( bit32* command ) const 27 { 28 // Converts to values to pack in commands 29 u32 width24 = Float32ToFloat24( width / 2.f ); 30 u32 width31 = Float32ToFloat31( 2.f / width ) << 1; 31 u32 height24 = Float32ToFloat24( height / 2.f ); 32 u32 height31 = Float32ToFloat31( 2.f / height ) << 1; 33 34 // 0x41 35 *command++ = width24; 36 *command++ = PICA_CMD_HEADER_SINGLE_BE( PICA_REG_VIEWPORT_WIDTH1, 0x7 ); 37 38 // 0x42 39 *command++ = width31; 40 *command++ = PICA_CMD_HEADER_SINGLE( PICA_REG_VIEWPORT_WIDTH2 ); 41 42 // 0x43 43 *command++ = height24; 44 *command++ = PICA_CMD_HEADER_SINGLE_BE( PICA_REG_VIEWPORT_HEIGHT1, 0x7 ); 45 46 // 0x44 47 *command++ = height31; 48 *command++ = PICA_CMD_HEADER_SINGLE( PICA_REG_VIEWPORT_HEIGHT2 ); 49 50 // 0x68 51 *command++ = PICA_CMD_DATA_VIEWPORT_XY( x, y ); 52 *command++ = PICA_CMD_HEADER_SINGLE( PICA_REG_VIEWPORT_XY ); 53 54 return command; 55 } 56 57 } // namespace CTR 58 } // namespace gr 59 } // namespace nn 60