1 /*---------------------------------------------------------------------------*
2   Project: Matrix Vector Library
3   File:    mtx.h
4 
5   Copyright 1998- 2001 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 
14   $Log: mtx.h,v $
15   Revision 1.2  2006/02/04 11:56:44  hashida
16   (none)
17 
18   Revision 1.1.1.1  2005/12/29 06:53:27  hiratsu
19   Initial import.
20 
21   Revision 1.1.1.1  2005/05/12 02:41:07  yasuh-to
22   Ported from dolphin source tree.
23 
24 
25     20    2002/10/15 16:01 Hirose
26     Added one more const to C_QUATMakeClosest( ).
27 
28     19    2002/06/20 11:18 Hirose
29     Added MTXConcatArray.
30 
31     18    2002/04/11 13:09 Hirose
32     const type specifier support. (worked by hiratsu@IRD)
33 
34     17    2001/08/27 3:54p Hirose
35     Added some PSQUAT functions.
36 
37     16    2001/08/03 1:19a Hirose
38     Added quaternion functions.
39 
40     15    2001/07/30 10:17p Hirose
41     Changes for function definitions.
42 
43     14    2001/07/24 6:03p Hirose
44 
45     13    2001/07/23 8:44p Hirose
46     Added some more PS functions again.
47 
48     12    2001/07/09 11:15p Hirose
49     Added general 4x4 matrix functions.
50 
51     11    2001/07/07 7:28p Hirose
52     Added some more PS matrix functions.
53 
54     10    2001/03/29 3:06p Hirose
55     Added MTXInvXpose
56 
57     9     2001/03/16 11:44p Hirose
58     Added PSMTXInverse
59 
60     8     2001/02/22 11:45p Hirose
61     Added some more PS functions. Updated function binding rule.
62 
63     7     2000/07/12 4:40p John
64     Substitutes MTXConcat and MTXMultVecArray with their paired-singles
65     equivalent for Gekko non-debug builds.
66 
67     6     2000/05/11 2:15p Hirose
68     Used macros instead of inline functions in order to avoid error on VC++
69     build
70 
71     5     2000/05/10 1:53p Hirose
72     Added radian-based rotation matrix functions
73 
74     4     2000/04/10 11:56a Danm
75     Added 2 matrix skinning support.
76 
77     3     2000/03/22 2:01p John
78     Added VECSquareDistance and VECDistance.
79 
80     2     2000/01/27 4:54p Tian
81     Detabbed.  Added optimized paired-singles matrix ops.
82 
83     17    1999/11/10 4:39p Alligator
84     Added MTXReflect
85 
86     16    1999/10/06 5:14p Yasu
87     Change char* to void*
88 
89     15    1999/10/06 12:27p Yasu
90     Appended MTXMultVecSR and MTXMultVecArraySR
91 
92     14    1999/09/15 5:45p Mikepc
93     Changed MtxStack member declaration from 'int numMtx' to 'u32 numMtx'
94 
95     13    1999/07/28 3:38p Ryan
96 
97     12    1999/07/28 11:30a Ryan
98     Added Texture Projection functions
99 
100     11    1999/07/02 12:55p Mikepc
101     Changed Mtx row/col
102 
103     10    1999/06/29 10:59p Martho01
104     Changed MTXRowCol() macro argument names to r, c. Added comment.
105 
106     9     1999/06/29 10:25p Martho01
107     Added 'old-style' MTXRowCol macro for referencing matrix elements.
108     'new-style' will come soon.
109 
110     8     1999/06/24 12:51p Mikepc
111     Added $log keyword.
112     Changed file name from MTxVec.h to mtx.h in header section.
113     Changed __MTXVEC_H__ to __MTX_H__ for #ifndef.
114 
115 
116 
117   Change History:
118 
119   [1999/05/28]  [Mike Ockenden] [ changed 'Point' and 'PointPtr' to 'Point3d' , Point3dPtr'
120                                   to avoid conflict with MacOS ]
121 
122   [05/27/1999]	[Mike Ockenden]	[ 1st check-in to source safe.
123                                   changed file name from MtxVec.h to mtx.h ]
124 
125   $NoKeywords: $
126 
127 
128  *---------------------------------------------------------------------------*/
129 
130 
131 /*---------------------------------------------------------------------------*
132     Matrix-Vector Library
133  *---------------------------------------------------------------------------*/
134 
135 #ifndef __MTX_H__
136 #define __MTX_H__
137 
138 
139 
140 #include <revolution/os.h>
141 #include <revolution/mtx/GeoTypes.h>
142 
143 
144 #ifdef __cplusplus
145 extern "C" {
146 #endif
147 
148 /*---------------------------------------------------------------------------*
149     Default function binding configuration
150  *---------------------------------------------------------------------------*/
151 // [Binding Rule]
152 //
153 // "MTX_USE_PS" -> When this flag is specified, it uses PS* (Paired-Single
154 //                 assembler code) functions for non-prefixed function calls.
155 // "MTX_USE_C " -> When this flag is specified, it uses C_* (C code) functions
156 //                 for non-prefixed function calls.
157 //
158 // If both are specified, it will be treated as MTX_USE_PS.
159 // If nothing is specified, NDEBUG build refers PS* functions and
160 // DEBUG build uses C_* functions.
161 
162 // For non-Gekko HW (e.g. emulator)
163 #ifndef GEKKO
164 #define MTX_USE_C
165 #undef  MTX_USE_PS
166 #endif
167 
168 #if ( !defined(MTX_USE_PS) && !defined(MTX_USE_C) )
169 #ifndef _DEBUG
170 #define MTX_USE_PS
171 #endif
172 #endif
173 
174 /*---------------------------------------------------------------------------*
175     Macro definitions
176  *---------------------------------------------------------------------------*/
177 
178 // MtxPtr offset to access next Mtx of an array
179 #define MTX_PTR_OFFSET      3
180 
181 // Mtx44Ptr offset to access next Mtx44 of an array
182 #define MTX44_PTR_OFFSET    4
183 
184 
185 // matrix stack
186 typedef struct
187 {
188 
189     u32    numMtx;
190     MtxPtr stackBase;
191     MtxPtr stackPtr;
192 
193 } MtxStack, *MtxStackPtr;
194 
195 
196 // degree <--> radian conversion macros
197 #define MTXDegToRad(a)   ( (a) *  0.01745329252f )
198 #define MTXRadToDeg(a)   ( (a) * 57.29577951f )
199 
200 
201 // Matrix-element-referencing macro.
202 // Insulates user from changes from row-major to column-major and vice-versa.
203 // Fully documents which index is row, which index is column.
204 // XXX this version will change once matrices are transposed.
205 
206 #define MTXRowCol(m,r,c) ((m)[(r)][(c)])
207 
208 
209 /*---------------------------------------------------------------------------*
210     GENERAL MATRIX SECTION
211  *---------------------------------------------------------------------------*/
212 // C version
213 void    C_MTXIdentity           ( Mtx m );
214 void    C_MTXCopy               ( const Mtx src, Mtx dst );
215 void    C_MTXConcat             ( const Mtx a, const Mtx b, Mtx ab );
216 void    C_MTXConcatArray        ( const Mtx a, const Mtx* srcBase, Mtx* dstBase, u32 count );
217 void    C_MTXTranspose          ( const Mtx src, Mtx xPose );
218 u32     C_MTXInverse            ( const Mtx src, Mtx inv );
219 u32     C_MTXInvXpose           ( const Mtx src, Mtx invX );
220 
221 // PS assembler version
222 #ifdef GEKKO
223 void    PSMTXIdentity           ( Mtx m );
224 void    PSMTXCopy               ( const Mtx src, Mtx dst );
225 void    PSMTXConcat             ( const Mtx a, const Mtx b, Mtx ab );
226 void    PSMTXConcatArray        ( const Mtx a, const Mtx* srcBase, Mtx* dstBase, u32 count );
227 void    PSMTXTranspose          ( const Mtx src, Mtx xPose );
228 u32     PSMTXInverse            ( const Mtx src, Mtx inv );
229 u32     PSMTXInvXpose           ( const Mtx src, Mtx invX );
230 #endif
231 
232 // Bindings
233 #ifdef MTX_USE_PS
234 #define MTXIdentity             PSMTXIdentity
235 #define MTXCopy                 PSMTXCopy
236 #define MTXConcat               PSMTXConcat
237 #define MTXConcatArray          PSMTXConcatArray
238 #define MTXTranspose            PSMTXTranspose
239 #define MTXInverse              PSMTXInverse
240 #define MTXInvXpose             PSMTXInvXpose
241 #else // MTX_USE_C
242 #define MTXIdentity             C_MTXIdentity
243 #define MTXCopy                 C_MTXCopy
244 #define MTXConcat               C_MTXConcat
245 #define MTXConcatArray          C_MTXConcatArray
246 #define MTXTranspose            C_MTXTranspose
247 #define MTXInverse              C_MTXInverse
248 #define MTXInvXpose             C_MTXInvXpose
249 #endif
250 
251 
252 /*---------------------------------------------------------------------------*
253     MATRIX-VECTOR SECTION
254  *---------------------------------------------------------------------------*/
255 // C version
256 void    C_MTXMultVec            ( const Mtx m, const Vec *src, Vec *dst );
257 void    C_MTXMultVecArray       ( const Mtx m, const Vec *srcBase, Vec *dstBase, u32 count );
258 void    C_MTXMultVecSR          ( const Mtx m, const Vec *src, Vec *dst );
259 void    C_MTXMultVecArraySR     ( const Mtx m, const Vec *srcBase, Vec *dstBase, u32 count );
260 
261 // PS assembler version
262 #ifdef GEKKO
263 void    PSMTXMultVec            ( const Mtx m, const Vec *src, Vec *dst );
264 void    PSMTXMultVecArray       ( const Mtx m, const Vec *srcBase, Vec *dstBase, u32 count );
265 void    PSMTXMultVecSR          ( const Mtx m, const Vec *src, Vec *dst );
266 void    PSMTXMultVecArraySR     ( const Mtx m, const Vec *srcBase, Vec *dstBase, u32 count );
267 #endif
268 
269 // Bindings
270 #ifdef MTX_USE_PS
271 #define MTXMultVec              PSMTXMultVec
272 #define MTXMultVecArray         PSMTXMultVecArray
273 #define MTXMultVecSR            PSMTXMultVecSR
274 #define MTXMultVecArraySR       PSMTXMultVecArraySR
275 #else // MTX_USE_C
276 #define MTXMultVec              C_MTXMultVec
277 #define MTXMultVecArray         C_MTXMultVecArray
278 #define MTXMultVecSR            C_MTXMultVecSR
279 #define MTXMultVecArraySR       C_MTXMultVecArraySR
280 #endif
281 
282 
283 /*---------------------------------------------------------------------------*
284     MODEL MATRIX SECTION
285  *---------------------------------------------------------------------------*/
286 // C version
287 void    C_MTXQuat             ( Mtx m, const Quaternion *q );
288 void    C_MTXReflect          ( Mtx m, const Vec *p, const Vec *n );
289 
290 void    C_MTXTrans            ( Mtx m, f32 xT, f32 yT, f32 zT );
291 void    C_MTXTransApply       ( const Mtx src, Mtx dst, f32 xT, f32 yT, f32 zT );
292 void    C_MTXScale            ( Mtx m, f32 xS, f32 yS, f32 zS );
293 void    C_MTXScaleApply       ( const Mtx src, Mtx dst, f32 xS, f32 yS, f32 zS );
294 
295 void    C_MTXRotRad           ( Mtx m, char axis, f32 rad );
296 void    C_MTXRotTrig          ( Mtx m, char axis, f32 sinA, f32 cosA );
297 void    C_MTXRotAxisRad       ( Mtx m, const Vec *axis, f32 rad );
298 
299 // PS assembler version
300 #ifdef GEKKO
301 void    PSMTXQuat             ( Mtx m, const Quaternion *q );
302 void    PSMTXReflect          ( Mtx m, const Vec *p, const Vec *n );
303 
304 void    PSMTXTrans            ( Mtx m, f32 xT, f32 yT, f32 zT );
305 void    PSMTXTransApply       ( const Mtx src, Mtx dst, f32 xT, f32 yT, f32 zT );
306 void    PSMTXScale            ( Mtx m, f32 xS, f32 yS, f32 zS );
307 void    PSMTXScaleApply       ( const Mtx src, Mtx dst, f32 xS, f32 yS, f32 zS );
308 
309 void    PSMTXRotRad           ( Mtx m, char axis, f32 rad );
310 void    PSMTXRotTrig          ( Mtx m, char axis, f32 sinA, f32 cosA );
311 void    PSMTXRotAxisRad       ( Mtx m, const Vec *axis, f32 rad );
312 #endif
313 
314 // Bindings
315 #ifdef MTX_USE_PS
316 #define MTXQuat                 PSMTXQuat
317 #define MTXReflect              PSMTXReflect
318 #define MTXTrans                PSMTXTrans
319 #define MTXTransApply           PSMTXTransApply
320 #define MTXScale                PSMTXScale
321 #define MTXScaleApply           PSMTXScaleApply
322 #define MTXRotRad               PSMTXRotRad
323 #define MTXRotTrig              PSMTXRotTrig
324 #define MTXRotAxisRad           PSMTXRotAxisRad
325 
326 #define MTXRotDeg( m, axis, deg ) \
327     PSMTXRotRad( m, axis, MTXDegToRad(deg) )
328 #define MTXRotAxisDeg( m, axis, deg ) \
329     PSMTXRotAxisRad( m, axis, MTXDegToRad(deg) )
330 
331 #else // MTX_USE_C
332 #define MTXQuat                 C_MTXQuat
333 #define MTXReflect              C_MTXReflect
334 #define MTXTrans                C_MTXTrans
335 #define MTXTransApply           C_MTXTransApply
336 #define MTXScale                C_MTXScale
337 #define MTXScaleApply           C_MTXScaleApply
338 #define MTXRotRad               C_MTXRotRad
339 #define MTXRotTrig              C_MTXRotTrig
340 #define MTXRotAxisRad           C_MTXRotAxisRad
341 
342 #define MTXRotDeg( m, axis, deg ) \
343     C_MTXRotRad( m, axis, MTXDegToRad(deg) )
344 #define MTXRotAxisDeg( m, axis, deg ) \
345     C_MTXRotAxisRad( m, axis, MTXDegToRad(deg) )
346 
347 #endif
348 
349 
350 // Obsolete. Don't use this if possible.
351 #define MTXRotAxis              MTXRotAxisDeg
352 
353 
354 /*---------------------------------------------------------------------------*
355     VIEW MATRIX SECTION
356  *---------------------------------------------------------------------------*/
357 // C version only so far
358 void    C_MTXLookAt         ( Mtx            m,
359                               const Point3d *camPos,
360                               const Vec     *camUp,
361                               const Point3d *target );
362 
363 // Bindings
364 #define MTXLookAt               C_MTXLookAt
365 
366 
367 /*---------------------------------------------------------------------------*
368     PROJECTION MATRIX SECTION
369  *---------------------------------------------------------------------------*/
370 // C version only so far
371 void    C_MTXFrustum        ( Mtx44 m, f32 t, f32 b, f32 l, f32 r, f32 n, f32 f );
372 void    C_MTXPerspective    ( Mtx44 m, f32 fovY, f32 aspect, f32 n, f32 f );
373 void    C_MTXOrtho          ( Mtx44 m, f32 t, f32 b, f32 l, f32 r, f32 n, f32 f );
374 
375 // Bindings
376 #define MTXFrustum              C_MTXFrustum
377 #define MTXPerspective          C_MTXPerspective
378 #define MTXOrtho                C_MTXOrtho
379 
380 
381 /*---------------------------------------------------------------------------*
382     TEXTURE PROJECTION MATRIX SECTION
383  *---------------------------------------------------------------------------*/
384 // C version only so far
385 void    C_MTXLightFrustum       ( Mtx m, f32 t, f32 b, f32 l, f32 r, f32 n,
386                                   f32 scaleS, f32 scaleT, f32 transS,
387                                   f32 transT );
388 
389 void    C_MTXLightPerspective   ( Mtx m, f32 fovY, f32 aspect, f32 scaleS,
390                                   f32 scaleT, f32 transS, f32 transT );
391 
392 void    C_MTXLightOrtho         ( Mtx m, f32 t, f32 b, f32 l, f32 r, f32 scaleS,
393                                   f32 scaleT, f32 transS, f32 transT );
394 
395 // Bindings
396 #define MTXLightFrustum         C_MTXLightFrustum
397 #define MTXLightPerspective     C_MTXLightPerspective
398 #define MTXLightOrtho           C_MTXLightOrtho
399 
400 
401 /*---------------------------------------------------------------------------*
402     VECTOR SECTION
403  *---------------------------------------------------------------------------*/
404 // C version
405 void    C_VECAdd              ( const Vec *a, const Vec *b, Vec *ab );
406 void    C_VECSubtract         ( const Vec *a, const Vec *b, Vec *a_b );
407 void    C_VECScale            ( const Vec *src, Vec *dst, f32 scale );
408 void    C_VECNormalize        ( const Vec *src, Vec *unit );
409 f32     C_VECSquareMag        ( const Vec *v );
410 f32     C_VECMag              ( const Vec *v );
411 f32     C_VECDotProduct       ( const Vec *a, const Vec *b );
412 void    C_VECCrossProduct     ( const Vec *a, const Vec *b, Vec *axb );
413 f32     C_VECSquareDistance   ( const Vec *a, const Vec *b );
414 f32     C_VECDistance         ( const Vec *a, const Vec *b );
415 void    C_VECReflect          ( const Vec *src, const Vec *normal, Vec *dst );
416 void    C_VECHalfAngle        ( const Vec *a, const Vec *b, Vec *half );
417 
418 // PS assembler version
419 #ifdef GEKKO
420 void    PSVECAdd              ( const Vec *a, const Vec *b, Vec *ab );
421 void    PSVECSubtract         ( const Vec *a, const Vec *b, Vec *a_b );
422 void    PSVECScale            ( const Vec *src, Vec *dst, f32 scale );
423 void    PSVECNormalize        ( const Vec *src, Vec *unit );
424 f32     PSVECSquareMag        ( const Vec *v );
425 f32     PSVECMag              ( const Vec *v );
426 f32     PSVECDotProduct       ( const Vec *a, const Vec *b );
427 void    PSVECCrossProduct     ( const Vec *a, const Vec *b, Vec *axb );
428 f32     PSVECSquareDistance   ( const Vec *a, const Vec *b );
429 f32     PSVECDistance         ( const Vec *a, const Vec *b );
430 #endif
431 
432 // Bindings
433 #ifdef MTX_USE_PS
434 #define VECAdd                  PSVECAdd
435 #define VECSubtract             PSVECSubtract
436 #define VECScale                PSVECScale
437 #define VECNormalize            PSVECNormalize
438 #define VECSquareMag            PSVECSquareMag
439 #define VECMag                  PSVECMag
440 #define VECDotProduct           PSVECDotProduct
441 #define VECCrossProduct         PSVECCrossProduct
442 #define VECSquareDistance       PSVECSquareDistance
443 #define VECDistance             PSVECDistance
444 #else // MTX_USE_C
445 #define VECAdd                  C_VECAdd
446 #define VECSubtract             C_VECSubtract
447 #define VECScale                C_VECScale
448 #define VECNormalize            C_VECNormalize
449 #define VECSquareMag            C_VECSquareMag
450 #define VECMag                  C_VECMag
451 #define VECDotProduct           C_VECDotProduct
452 #define VECCrossProduct         C_VECCrossProduct
453 #define VECSquareDistance       C_VECSquareDistance
454 #define VECDistance             C_VECDistance
455 #endif
456 
457 #define VECReflect              C_VECReflect
458 #define VECHalfAngle            C_VECHalfAngle
459 
460 
461 /*---------------------------------------------------------------------------*
462     QUATERNION SECTION
463  *---------------------------------------------------------------------------*/
464 // C version
465 void C_QUATAdd              ( const Quaternion *p, const Quaternion *q, Quaternion *r );
466 void C_QUATSubtract         ( const Quaternion *p, const Quaternion *q, Quaternion *r );
467 void C_QUATMultiply         ( const Quaternion *p, const Quaternion *q, Quaternion *pq );
468 void C_QUATDivide           ( const Quaternion *p, const Quaternion *q, Quaternion *r );
469 void C_QUATScale            ( const Quaternion *q, Quaternion *r, f32 scale );
470 f32  C_QUATDotProduct       ( const Quaternion *p, const Quaternion *q );
471 void C_QUATNormalize        ( const Quaternion *src, Quaternion *unit );
472 void C_QUATInverse          ( const Quaternion *src, Quaternion *inv );
473 void C_QUATExp              ( const Quaternion *q, Quaternion *r );
474 void C_QUATLogN             ( const Quaternion *q, Quaternion *r );
475 
476 void C_QUATMakeClosest      ( const Quaternion *q, const Quaternion *qto, Quaternion *r );
477 void C_QUATRotAxisRad       ( Quaternion *r, const Vec *axis, f32 rad );
478 void C_QUATMtx              ( Quaternion *r, const Mtx m );
479 
480 void C_QUATLerp             ( const Quaternion *p, const Quaternion *q, Quaternion *r, f32 t );
481 void C_QUATSlerp            ( const Quaternion *p, const Quaternion *q, Quaternion *r, f32 t );
482 void C_QUATSquad            ( const Quaternion *p, const Quaternion *a, const Quaternion *b,
483                               const Quaternion *q, Quaternion *r, f32 t );
484 void C_QUATCompA            ( const Quaternion *qprev, const Quaternion *q,
485                               const Quaternion *qnext, Quaternion *a );
486 
487 
488 // PS assembler version
489 #ifdef GEKKO
490 void PSQUATAdd              ( const Quaternion *p, const Quaternion *q, Quaternion *r );
491 void PSQUATSubtract         ( const Quaternion *p, const Quaternion *q, Quaternion *r );
492 void PSQUATMultiply         ( const Quaternion *p, const Quaternion *q, Quaternion *pq );
493 void PSQUATDivide           ( const Quaternion *p, const Quaternion *q, Quaternion *r );
494 void PSQUATScale            ( const Quaternion *q, Quaternion *r, f32 scale );
495 f32  PSQUATDotProduct       ( const Quaternion *p, const Quaternion *q );
496 void PSQUATNormalize        ( const Quaternion *src, Quaternion *unit );
497 void PSQUATInverse          ( const Quaternion *src, Quaternion *inv );
498 #endif
499 
500 
501 // Bindings
502 #ifdef MTX_USE_PS
503 #define QUATAdd                 PSQUATAdd
504 #define QUATSubtract            PSQUATSubtract
505 #define QUATMultiply            PSQUATMultiply
506 #define QUATDivide              PSQUATDivide
507 #define QUATScale               PSQUATScale
508 #define QUATDotProduct          PSQUATDotProduct
509 #define QUATNormalize           PSQUATNormalize
510 #define QUATInverse             PSQUATInverse
511 #else // MTX_USE_C
512 #define QUATAdd                 C_QUATAdd
513 #define QUATSubtract            C_QUATSubtract
514 #define QUATMultiply            C_QUATMultiply
515 #define QUATDivide              C_QUATDivide
516 #define QUATScale               C_QUATScale
517 #define QUATDotProduct          C_QUATDotProduct
518 #define QUATNormalize           C_QUATNormalize
519 #define QUATInverse             C_QUATInverse
520 #endif
521 
522 #define QUATExp                 C_QUATExp
523 #define QUATLogN                C_QUATLogN
524 #define QUATMakeClosest         C_QUATMakeClosest
525 #define QUATRotAxisRad          C_QUATRotAxisRad
526 #define QUATMtx                 C_QUATMtx
527 #define QUATLerp                C_QUATLerp
528 #define QUATSlerp               C_QUATSlerp
529 #define QUATSquad               C_QUATSquad
530 #define QUATCompA               C_QUATCompA
531 
532 
533 /*---------------------------------------------------------------------------*
534     SPECIAL PURPOSE MATRIX SECTION
535  *---------------------------------------------------------------------------*/
536 // Only PS assembler versions are available
537 #ifdef GEKKO
538 void    PSMTXReorder          ( const Mtx src, ROMtx dest );
539 void    PSMTXROMultVecArray   ( const ROMtx m, const Vec *srcBase, Vec *dstBase, u32 count );
540 void    PSMTXROSkin2VecArray  ( const ROMtx m0, const ROMtx m1, const f32 *wtBase, const Vec *srcBase, Vec *dstBase, u32 count);
541 void    PSMTXMultS16VecArray  ( const Mtx m, const S16Vec *srcBase, Vec *dstBase, u32 count );
542 void    PSMTXROMultS16VecArray( const ROMtx m, const S16Vec *srcBase, Vec *dstBase, u32 count );
543 #endif
544 
545 
546 /*---------------------------------------------------------------------------*
547     MATRIX STACK SECTION
548  *---------------------------------------------------------------------------*/
549 void    MTXInitStack          ( MtxStack *sPtr, u32 numMtx );
550 MtxPtr  MTXPush               ( MtxStack *sPtr, const Mtx m );
551 MtxPtr  MTXPushFwd            ( MtxStack *sPtr, const Mtx m );
552 MtxPtr  MTXPushInv            ( MtxStack *sPtr, const Mtx m );
553 MtxPtr  MTXPushInvXpose       ( MtxStack *sPtr, const Mtx m );
554 MtxPtr  MTXPop                ( MtxStack *sPtr );
555 MtxPtr  MTXGetStackPtr        ( const MtxStack *sPtr );
556 
557 
558 // Macro to create a matrix stack.
559 // The macro exposes the  use of OSAlloc() for
560 // ease of replacement if desired.
561 #define MTXAllocStack( sPtr, numMtx ) (  ((MtxStackPtr)(sPtr))->stackBase = (MtxPtr)OSAlloc( ( (numMtx) * sizeof(Mtx) ) )  )
562 
563 // Macro to free a matrix stack
564 #define MTXFreeStack( sPtr )    (  OSFree( (void*)( ((MtxStackPtr)(sPtr))->stackBase ) )  )
565 
566 
567 /*---------------------------------------------------------------------------*/
568 
569 
570 #ifdef __cplusplus
571 }
572 #endif
573 
574 #endif // __MTX_H__
575 
576 /*===========================================================================*/
577 
578