1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     gr_Viewport.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: 29908 $
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)26             bit32* Viewport::MakeCommand( bit32* command )
27             {
28                 // コマンドに積む値に変換します
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                 // コマンドを積みます
35                 *command++ = width24;
36                 *command++ = PICA_CMD_HEADER_SINGLE_BE( PICA_REG_VIEWPORT_WIDTH1, 0x7 );
37 
38                 *command++ = width31;
39                 *command++ = PICA_CMD_HEADER_SINGLE( PICA_REG_VIEWPORT_WIDTH2 );
40 
41                 *command++ = height24;
42                 *command++ = PICA_CMD_HEADER_SINGLE_BE( PICA_REG_VIEWPORT_HEIGHT1, 0x7 );
43 
44                 *command++ = height31;
45                 *command++ = PICA_CMD_HEADER_SINGLE( PICA_REG_VIEWPORT_HEIGHT2 );
46 
47                 *command++ = PICA_CMD_DATA_VIEWPORT_XY( x, y );
48                 *command++ = PICA_CMD_HEADER_SINGLE( PICA_REG_VIEWPORT_XY );
49 
50                 return command;
51             }
52 
53         } // namespace CTR
54     } // namespace gr
55 } // namespace nn
56