1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - FX -
3   File:     fx_mtx22.h
4 
5   Copyright 2003-2008 Nintendo.  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   $Date:: 2008-09-18#$
14   $Rev: 8573 $
15   $Author: okubata_ryoma $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef NITRO_FX_MTX22_H_
19 #define NITRO_FX_MTX22_H_
20 
21 #include <nitro/fx/fx.h>
22 #include <nitro/mi/memory.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 //----------------------------------------------------------------------------
29 // Type definition
30 //----------------------------------------------------------------------------
31 
32 //----------------------------------------------------------------------------
33 // Declaration of function
34 //----------------------------------------------------------------------------
35 
36 SDK_DECL_INLINE void MTX_Identity22(MtxFx22 *pDst);
37 SDK_DECL_INLINE void MTX_Copy22(const MtxFx22 *pSrc, MtxFx22 *pDst);
38 SDK_DECL_INLINE void MTX_Transpose22(const MtxFx22 *pSrc, MtxFx22 *pDst);
39 SDK_DECL_INLINE void MTX_Rot22(MtxFx22 *pDst, fx32 sinVal, fx32 cosVal);
40 int     MTX_Inverse22(const MtxFx22 *pSrc, MtxFx22 *pDst);
41 void    MTX_Concat22(const MtxFx22 *a, const MtxFx22 *b, MtxFx22 *ab);
42 void    MTX_ScaleApply22(const MtxFx22 *pSrc, MtxFx22 *pDst, fx32 x, fx32 y);
43 
44 void    MTX_Identity22_(register MtxFx22 *pDst);
45 void    MTX_Transpose22_(const register MtxFx22 *pSrc, register MtxFx22 *pDst);
46 void    MTX_Scale22_(register MtxFx22 *pDst, register fx32 x, register fx32 y);
47 void    MTX_Rot22_(register MtxFx22 *pDst, register fx32 sinVal, register fx32 cosVal);
48 
49 //----------------------------------------------------------------------------
50 // Implementation of inline function
51 //----------------------------------------------------------------------------
52 
53 /*---------------------------------------------------------------------------*
54   Name:         MTX_Identity22
55 
56   Description:  Sets a matrix to identity.
57 
58   Arguments:    pDst         a pointer to a 2x2 matrix
59 
60   Returns:      none
61  *---------------------------------------------------------------------------*/
MTX_Identity22(MtxFx22 * pDst)62 SDK_INLINE void MTX_Identity22(MtxFx22 *pDst)
63 {
64     SDK_NULL_ASSERT(pDst);
65     MTX_Identity22_(pDst);
66 }
67 
68 /*---------------------------------------------------------------------------*
69   Name:         MTX_Copy22
70 
71   Description:  Copies a 2x2 matrix to a 2x2 matrix.
72 
73   Arguments:    pSrc         a pointer to a 2x2 matrix
74                 pDst         a pointer to a 2x2 matrix
75 
76   Returns:      none
77  *---------------------------------------------------------------------------*/
MTX_Copy22(const MtxFx22 * pSrc,MtxFx22 * pDst)78 SDK_INLINE void MTX_Copy22(const MtxFx22 *pSrc, MtxFx22 *pDst)
79 {
80     SDK_NULL_ASSERT(pSrc);
81     SDK_NULL_ASSERT(pDst);
82     MI_Copy16B(pSrc, pDst);
83 }
84 
85 
86 /*---------------------------------------------------------------------------*
87   Name:         MTX_Transpose22
88 
89   Description:  Computes the transpose of a 2x2 matrix.
90 
91   Arguments:    pSrc         a pointer to a 2x2 matrix
92                 pDst         a pointer to a 2x2 matrix
93 
94   Returns:      none
95  *---------------------------------------------------------------------------*/
MTX_Transpose22(const MtxFx22 * pSrc,MtxFx22 * pDst)96 SDK_INLINE void MTX_Transpose22(const MtxFx22 *pSrc, MtxFx22 *pDst)
97 {
98     SDK_NULL_ASSERT(pSrc);
99     SDK_NULL_ASSERT(pDst);
100     MTX_Transpose22_(pSrc, pDst);
101 }
102 
103 
104 /*---------------------------------------------------------------------------*
105   Name:         MTX_Scale22
106 
107   Description:  Sets a scaling matrix.
108 
109   Arguments:    pDst         a pointer to a 2x2 matrix
110                 x            x scale factor
111                 y            y scale factor
112 
113   Returns:      none
114  *---------------------------------------------------------------------------*/
MTX_Scale22(MtxFx22 * pDst,fx32 x,fx32 y)115 SDK_INLINE void MTX_Scale22(MtxFx22 *pDst, fx32 x, fx32 y)
116 {
117     SDK_NULL_ASSERT(pDst);
118     MTX_Scale22_(pDst, x, y);
119 }
120 
121 
122 /*---------------------------------------------------------------------------*
123   Name:         MTX_Rot22
124 
125   Description:  Sets a rotation matrix.
126 
127   Arguments:    pDst         a pointer to a 2x2 matrix
128                 sinVal       sine of an angle of rotation
129                 cosVal       cosine of an angle of rotation
130 
131   Returns:      none
132  *---------------------------------------------------------------------------*/
MTX_Rot22(MtxFx22 * pDst,fx32 sinVal,fx32 cosVal)133 SDK_INLINE void MTX_Rot22(MtxFx22 *pDst, fx32 sinVal, fx32 cosVal)
134 {
135     SDK_NULL_ASSERT(pDst);
136     MTX_Rot22_(pDst, sinVal, cosVal);
137 }
138 
139 
140 #ifdef __cplusplus
141 }/* extern "C" */
142 #endif
143 
144 #endif
145