1 /*---------------------------------------------------------------------------*
2 Project: NitroSDK - GX -
3 File: g3b.c
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 // -DSDK_WIN32 -DSDK_HAS_LONG_LONG_INT for GCC
19 // -DSDK_WIN32 for VC or BCB
20 //
21 #ifdef SDK_WIN32
22 #include <nitro_win32.h>
23 #else
24 #include <nitro/gx/g3b.h>
25 #include <nitro/mi/dma.h>
26 #include <nitro/mi/memory.h>
27 #include "../include/gxasm.h"
28 #endif
29
30 /*---------------------------------------------------------------------------*
31 Name: G3BS_DirectN
32
33 Description: Makes a geometry command with nParams parameters on a display list.
34 Note that the command is not packed.
35
36 Arguments: info a pointer to GXDLInfo
37 op a geometry command(GXOP_xxxxxxx)
38 nParams the number of parameters
39 params parameters
40
41 Returns: none
42 *---------------------------------------------------------------------------*/
G3BS_DirectN(GXDLInfo * info,int op,int nParams,const u32 * params)43 void G3BS_DirectN(GXDLInfo *info, int op, int nParams, const u32 *params)
44 {
45 SDK_NULL_ASSERT(info);
46 SDK_NULL_ASSERT(params);
47 SDK_NULL_ASSERT(info->curr_param);
48 SDK_ALIGN4_ASSERT(info->curr_cmd);
49 SDK_ASSERT(op >= 0 && op < 0x100);
50
51 *(u32 *)info->curr_cmd = (u32)op;
52
53 while (--nParams >= 0)
54 {
55 *(info->curr_param + nParams) = *(params + nParams);
56 }
57 }
58
59
60 /*---------------------------------------------------------------------------*
61 Name: G3BS_LoadMtx44
62
63 Description: Make a geometry command which loads a 4x4 matrix
64 to the current matrix.
65
66 Arguments: info a pointer to GXDLInfo
67 m a pointer to a constant 4x4 matrix
68
69 Returns: none
70 *---------------------------------------------------------------------------*/
G3BS_LoadMtx44(GXDLInfo * info,const MtxFx44 * m)71 void G3BS_LoadMtx44(GXDLInfo *info, const MtxFx44 *m)
72 {
73 SDK_NULL_ASSERT(info);
74 SDK_NULL_ASSERT(m);
75 SDK_NULL_ASSERT(info->curr_param);
76 SDK_ALIGN4_ASSERT(info->curr_cmd);
77
78 *(u32 *)info->curr_cmd = G3OP_MTX_LOAD_4x4;
79
80 #ifndef SDK_WIN32
81 MI_Copy64B(&m->_00, (void *)info->curr_param);
82 #else
83 *(info->curr_param + 0) = (u32)m->_00;
84 *(info->curr_param + 1) = (u32)m->_01;
85 *(info->curr_param + 2) = (u32)m->_02;
86 *(info->curr_param + 3) = (u32)m->_03;
87
88 *(info->curr_param + 4) = (u32)m->_10;
89 *(info->curr_param + 5) = (u32)m->_11;
90 *(info->curr_param + 6) = (u32)m->_12;
91 *(info->curr_param + 7) = (u32)m->_13;
92
93 *(info->curr_param + 8) = (u32)m->_20;
94 *(info->curr_param + 9) = (u32)m->_21;
95 *(info->curr_param + 10) = (u32)m->_22;
96 *(info->curr_param + 11) = (u32)m->_23;
97
98 *(info->curr_param + 12) = (u32)m->_30;
99 *(info->curr_param + 13) = (u32)m->_31;
100 *(info->curr_param + 14) = (u32)m->_32;
101 *(info->curr_param + 15) = (u32)m->_33;
102 #endif
103 }
104
105
106 /*---------------------------------------------------------------------------*
107 Name: G3BS_LoadMtx43
108
109 Description: Make a geometry command which loads a 4x3 matrix
110 to the current matrix.
111
112 Arguments: info a pointer to GXDLInfo
113 m a pointer to a constant 4x3 matrix
114
115 Returns: none
116 *---------------------------------------------------------------------------*/
G3BS_LoadMtx43(GXDLInfo * info,const MtxFx43 * m)117 void G3BS_LoadMtx43(GXDLInfo *info, const MtxFx43 *m)
118 {
119 SDK_NULL_ASSERT(info);
120 SDK_NULL_ASSERT(m);
121 SDK_NULL_ASSERT(info->curr_param);
122 SDK_ALIGN4_ASSERT(info->curr_cmd);
123
124 *(u32 *)info->curr_cmd = G3OP_MTX_LOAD_4x3;
125 #ifndef SDK_WIN32
126 MI_Copy48B(&m->_00, (void *)info->curr_param);
127 #else
128 *(info->curr_param + 0) = (u32)m->_00;
129 *(info->curr_param + 1) = (u32)m->_01;
130 *(info->curr_param + 2) = (u32)m->_02;
131
132 *(info->curr_param + 3) = (u32)m->_10;
133 *(info->curr_param + 4) = (u32)m->_11;
134 *(info->curr_param + 5) = (u32)m->_12;
135
136 *(info->curr_param + 6) = (u32)m->_20;
137 *(info->curr_param + 7) = (u32)m->_21;
138 *(info->curr_param + 8) = (u32)m->_22;
139
140 *(info->curr_param + 9) = (u32)m->_30;
141 *(info->curr_param + 10) = (u32)m->_31;
142 *(info->curr_param + 11) = (u32)m->_32;
143 #endif
144 }
145
146
147 /*---------------------------------------------------------------------------*
148 Name: G3BS_MultMtx44
149
150 Description: Makes a geometry command which multiplies the current matrix
151 by a 4x4 matrix from the left.
152
153 Arguments: info a pointer to GXDLInfo
154 m a pointer to a constant 4x4 matrix
155
156 Returns: none
157 *---------------------------------------------------------------------------*/
G3BS_MultMtx44(GXDLInfo * info,const MtxFx44 * m)158 void G3BS_MultMtx44(GXDLInfo *info, const MtxFx44 *m)
159 {
160 SDK_NULL_ASSERT(info);
161 SDK_NULL_ASSERT(m);
162 SDK_NULL_ASSERT(info->curr_param);
163 SDK_ALIGN4_ASSERT(info->curr_cmd);
164
165 *(u32 *)info->curr_cmd = G3OP_MTX_MULT_4x4;
166 #ifndef SDK_WIN32
167 MI_Copy64B(&m->_00, (void *)info->curr_param);
168 #else
169 *(info->curr_param + 0) = (u32)m->_00;
170 *(info->curr_param + 1) = (u32)m->_01;
171 *(info->curr_param + 2) = (u32)m->_02;
172 *(info->curr_param + 3) = (u32)m->_03;
173
174 *(info->curr_param + 4) = (u32)m->_10;
175 *(info->curr_param + 5) = (u32)m->_11;
176 *(info->curr_param + 6) = (u32)m->_12;
177 *(info->curr_param + 7) = (u32)m->_13;
178
179 *(info->curr_param + 8) = (u32)m->_20;
180 *(info->curr_param + 9) = (u32)m->_21;
181 *(info->curr_param + 10) = (u32)m->_22;
182 *(info->curr_param + 11) = (u32)m->_23;
183
184 *(info->curr_param + 12) = (u32)m->_30;
185 *(info->curr_param + 13) = (u32)m->_31;
186 *(info->curr_param + 14) = (u32)m->_32;
187 *(info->curr_param + 15) = (u32)m->_33;
188 #endif
189 }
190
191
192 /*---------------------------------------------------------------------------*
193 Name: G3BS_MultMtx43
194
195 Description: Make a geometry command which multiplies the current matrix
196 by a 4x3 matrix from the left.
197
198 Arguments: info a pointer to GXDLInfo
199 m a pointer to a constant 4x3 matrix
200
201 Returns: none
202 *---------------------------------------------------------------------------*/
G3BS_MultMtx43(GXDLInfo * info,const MtxFx43 * m)203 void G3BS_MultMtx43(GXDLInfo *info, const MtxFx43 *m)
204 {
205 SDK_NULL_ASSERT(info);
206 SDK_NULL_ASSERT(m);
207 SDK_NULL_ASSERT(info->curr_param);
208 SDK_ALIGN4_ASSERT(info->curr_cmd);
209
210 *(u32 *)info->curr_cmd = G3OP_MTX_MULT_4x3;
211 #ifndef SDK_WIN32
212 MI_Copy48B(&m->_00, (void *)info->curr_param);
213 #else
214 *(info->curr_param + 0) = (u32)m->_00;
215 *(info->curr_param + 1) = (u32)m->_01;
216 *(info->curr_param + 2) = (u32)m->_02;
217
218 *(info->curr_param + 3) = (u32)m->_10;
219 *(info->curr_param + 4) = (u32)m->_11;
220 *(info->curr_param + 5) = (u32)m->_12;
221
222 *(info->curr_param + 6) = (u32)m->_20;
223 *(info->curr_param + 7) = (u32)m->_21;
224 *(info->curr_param + 8) = (u32)m->_22;
225
226 *(info->curr_param + 9) = (u32)m->_30;
227 *(info->curr_param + 10) = (u32)m->_31;
228 *(info->curr_param + 11) = (u32)m->_32;
229 #endif
230 }
231
232
233 /*---------------------------------------------------------------------------*
234 Name: G3BS_MultMtx33
235
236 Description: Makes a geometry command which multiplies the current matrix
237 by a 3x3 matrix from the left.
238
239 Arguments: info a pointer to GXDLInfo
240 m a pointer to a constant 3x3 matrix
241
242 Returns: none
243 *---------------------------------------------------------------------------*/
G3BS_MultMtx33(GXDLInfo * info,const MtxFx33 * m)244 void G3BS_MultMtx33(GXDLInfo *info, const MtxFx33 *m)
245 {
246 SDK_NULL_ASSERT(info);
247 SDK_NULL_ASSERT(m);
248 SDK_NULL_ASSERT(info->curr_param);
249 SDK_ALIGN4_ASSERT(info->curr_cmd);
250
251 *(u32 *)info->curr_cmd = G3OP_MTX_MULT_3x3;
252 #ifndef SDK_WIN32
253 MI_Copy36B(&m->_00, (void *)info->curr_param);
254 #else
255 *(info->curr_param + 0) = (u32)m->_00;
256 *(info->curr_param + 1) = (u32)m->_01;
257 *(info->curr_param + 2) = (u32)m->_02;
258
259 *(info->curr_param + 3) = (u32)m->_10;
260 *(info->curr_param + 4) = (u32)m->_11;
261 *(info->curr_param + 5) = (u32)m->_12;
262
263 *(info->curr_param + 6) = (u32)m->_20;
264 *(info->curr_param + 7) = (u32)m->_21;
265 *(info->curr_param + 8) = (u32)m->_22;
266 #endif
267 }
268
269 /*---------------------------------------------------------------------------*
270 Name: G3BS_MultTransMtx33
271
272 Description: Make a geometry command which multiplies and translates matrix together.
273
274 Arguments: info a pointer to GXDLInfo
275 mtx a pointer to a constant 3x3 matrix
276 trans a pointer to a constant translation vector
277
278 Returns: none
279 *---------------------------------------------------------------------------*/
G3BS_MultTransMtx33(GXDLInfo * info,const MtxFx33 * mtx,const VecFx32 * trans)280 void G3BS_MultTransMtx33(GXDLInfo *info, const MtxFx33 *mtx, const VecFx32 *trans)
281 {
282 SDK_NULL_ASSERT(info);
283 SDK_NULL_ASSERT(mtx);
284 SDK_NULL_ASSERT(trans);
285 SDK_NULL_ASSERT(info->curr_param);
286 SDK_ALIGN4_ASSERT(info->curr_cmd);
287
288 *(u32 *)info->curr_cmd = G3OP_MTX_MULT_4x3;
289 #ifndef SDK_WIN32
290 MI_Copy36B(&mtx->_00, (void *)info->curr_param);
291 MI_CpuCopy32(trans, (u32 *)info->curr_param + 9, sizeof(VecFx32));
292 #else
293 *((u32 *)info->curr_param + 0) = (u32)mtx->_00;
294 *((u32 *)info->curr_param + 1) = (u32)mtx->_01;
295 *((u32 *)info->curr_param + 2) = (u32)mtx->_02;
296
297 *((u32 *)info->curr_param + 3) = (u32)mtx->_10;
298 *((u32 *)info->curr_param + 4) = (u32)mtx->_11;
299 *((u32 *)info->curr_param + 5) = (u32)mtx->_12;
300
301 *((u32 *)info->curr_param + 6) = (u32)mtx->_20;
302 *((u32 *)info->curr_param + 7) = (u32)mtx->_21;
303 *((u32 *)info->curr_param + 8) = (u32)mtx->_22;
304
305 *((u32 *)info->curr_param + 9) = trans->x;
306 *((u32 *)info->curr_param + 10) = trans->y;
307 *((u32 *)info->curr_param + 11) = trans->z;
308 #endif
309 }
310
311
312 /*---------------------------------------------------------------------------*
313 Name: G3B_Direct0
314
315 Description: Makes a geometry command with a parameter on a display list.
316 Note that the command is not packed.
317 Also, the pointers of GXDLInfo proceed.
318
319 Arguments: info a pointer to GXDLInfo
320 op a geometry command(GXOP_xxxxxxx)
321 param0 a parameter
322
323 Returns: none
324 *---------------------------------------------------------------------------*/
G3B_Direct0(GXDLInfo * info,int op)325 void G3B_Direct0(GXDLInfo *info, int op)
326 {
327 G3BS_Direct0(info, op);
328 G3B_UpdateGXDLInfo(info, 0);
329 }
330
331
332 /*---------------------------------------------------------------------------*
333 Name: G3B_Direct1
334
335 Description: Makes a geometry command with a parameter on a display list.
336 Note that the command is not packed.
337 Also, the pointers of GXDLInfo proceed.
338
339 Arguments: info a pointer to GXDLInfo
340 op a geometry command(GXOP_xxxxxxx)
341 param0 a parameter
342
343 Returns: none
344 *---------------------------------------------------------------------------*/
G3B_Direct1(GXDLInfo * info,int op,u32 param0)345 void G3B_Direct1(GXDLInfo *info, int op, u32 param0)
346 {
347 G3BS_Direct1(info, op, param0);
348 G3B_UpdateGXDLInfo(info, 1);
349 }
350
351
352 /*---------------------------------------------------------------------------*
353 Name: G3B_Direct2
354
355 Description: Makes a geometry command with two parameters on a display list.
356 Note that the command is not packed.
357 Also, the pointers of GXDLInfo proceed.
358
359 Arguments: info a pointer to GXDLInfo
360 op a geometry command(GXOP_xxxxxxx)
361 param0 a parameter
362 param1 a parameter
363
364 Returns: none
365 *---------------------------------------------------------------------------*/
G3B_Direct2(GXDLInfo * info,int op,u32 param0,u32 param1)366 void G3B_Direct2(GXDLInfo *info, int op, u32 param0, u32 param1)
367 {
368 G3BS_Direct2(info, op, param0, param1);
369 G3B_UpdateGXDLInfo(info, 2);
370 }
371
372
373 /*---------------------------------------------------------------------------*
374 Name: G3B_Direct3
375
376 Description: Makes a geometry command with three parameters on a display list.
377 Note that the command is not packed.
378 Also, the pointers of GXDLInfo proceed.
379
380 Arguments: info a pointer to GXDLInfo
381 op a geometry command(GXOP_xxxxxxx)
382 param0 a parameter
383 param1 a parameter
384 param2 a parameter
385
386 Returns: none
387 *---------------------------------------------------------------------------*/
G3B_Direct3(GXDLInfo * info,int op,u32 param0,u32 param1,u32 param2)388 void G3B_Direct3(GXDLInfo *info, int op, u32 param0, u32 param1, u32 param2)
389 {
390 G3BS_Direct3(info, op, param0, param1, param2);
391 G3B_UpdateGXDLInfo(info, 3);
392 }
393
394
395 /*---------------------------------------------------------------------------*
396 Name: G3B_DirectN
397
398 Description: Makes a geometry command with nParams parameters on a display list.
399 Note that the command is not packed.
400 Also, the pointers of GXDLInfo proceed.
401
402 Arguments: info a pointer to GXDLInfo
403 op a geometry command(GXOP_xxxxxxx)
404 nParams the number of parameters
405 params parameters
406
407 Returns: none
408 *---------------------------------------------------------------------------*/
G3B_DirectN(GXDLInfo * info,int op,int nParams,const u32 * params)409 void G3B_DirectN(GXDLInfo *info, int op, int nParams, const u32 *params)
410 {
411 G3BS_DirectN(info, op, nParams, params);
412 G3B_UpdateGXDLInfo(info, nParams);
413 }
414
415
416 /*---------------------------------------------------------------------------*
417 Name: G3B_Nop
418
419 Description: Makes a geometry command which does nothing on a display list.
420 Note that the command is not packed.
421 Also, the pointers of GXDLInfo proceed.
422
423 Arguments: info a pointer to GXDLInfo
424
425 Returns: none
426 *---------------------------------------------------------------------------*/
G3B_Nop(GXDLInfo * info)427 void G3B_Nop(GXDLInfo *info)
428 {
429 G3BS_Nop(info);
430 G3B_UpdateGXDLInfo(info, G3OP_NOP_NPARAMS);
431 }
432
433
434 /*---------------------------------------------------------------------------*
435 Name: G3B_MtxMode
436
437 Description: Makes a geometry command, which sets a matrix mode,
438 on a display list. Note that the command is not packed.
439 Also, the pointers of GXDLInfo proceed.
440
441 Arguments: info a pointer to GXDLInfo
442 mode a matrix mode
443
444 Returns: none
445 *---------------------------------------------------------------------------*/
G3B_MtxMode(GXDLInfo * info,GXMtxMode mode)446 void G3B_MtxMode(GXDLInfo *info, GXMtxMode mode)
447 {
448 G3BS_MtxMode(info, mode);
449 G3B_UpdateGXDLInfo(info, G3OP_MTX_MODE_NPARAMS);
450 }
451
452
453 /*---------------------------------------------------------------------------*
454 Name: G3B_PushMtx
455
456 Description: Makes a geometry command, which stores a current matrix to
457 the top of the matrix stack and increments the stack pointer,
458 on a display list. Note that the command is not packed.
459 Also, the pointers of GXDLInfo proceed.
460
461 Arguments: info a pointer to GXDLInfo
462
463 Returns: none
464 *---------------------------------------------------------------------------*/
G3B_PushMtx(GXDLInfo * info)465 void G3B_PushMtx(GXDLInfo *info)
466 {
467 G3BS_PushMtx(info);
468 G3B_UpdateGXDLInfo(info, G3OP_MTX_PUSH_NPARAMS);
469 }
470
471
472 /*---------------------------------------------------------------------------*
473 Name: G3B_PopMtx
474
475 Description: Makes a geometry command, which pops the num'th matrix
476 from the matrix stack pointer on the stack,
477 and adds num to the pointer. Note that the command is not packed.
478 Also, the pointers of GXDLInfo proceed.
479
480 Arguments: info a pointer to GXDLInfo
481 num an offset to the stack pointer
482
483 Returns: none
484 *---------------------------------------------------------------------------*/
G3B_PopMtx(GXDLInfo * info,int num)485 void G3B_PopMtx(GXDLInfo *info, int num)
486 {
487 G3BS_PopMtx(info, num);
488 G3B_UpdateGXDLInfo(info, G3OP_MTX_POP_NPARAMS);
489 }
490
491
492 /*---------------------------------------------------------------------------*
493 Name: G3B_StoreMtx
494
495 Description: Makes a geometry command, which stores a current matrix
496 to the num'th matrix from the matrix stack pointer on the stack,
497 on a display list. Note that the command is not packed.
498 Also, the pointers of GXDLInfo proceed.
499
500 Arguments: info a pointer to GXDLInfo
501 num an offset to the stack pointer
502
503 Returns: none
504 *---------------------------------------------------------------------------*/
G3B_StoreMtx(GXDLInfo * info,int num)505 void G3B_StoreMtx(GXDLInfo *info, int num)
506 {
507 G3BS_StoreMtx(info, num);
508 G3B_UpdateGXDLInfo(info, G3OP_MTX_STORE_NPARAMS);
509 }
510
511
512 /*---------------------------------------------------------------------------*
513 Name: G3B_RestoreMtx
514
515 Description: Makes a geometry command, which gets the num'th matrix from
516 the matrix stack pointer on the stack, on a display list.
517 Note that the command is not packed.
518 Also, the pointers of GXDLInfo proceed.
519
520 Arguments: info a pointer to GXDLInfo
521 num an offset to the stack pointer
522
523 Returns: none
524 *---------------------------------------------------------------------------*/
G3B_RestoreMtx(GXDLInfo * info,int num)525 void G3B_RestoreMtx(GXDLInfo *info, int num)
526 {
527 G3BS_RestoreMtx(info, num);
528 G3B_UpdateGXDLInfo(info, G3OP_MTX_RESTORE_NPARAMS);
529 }
530
531
532 /*---------------------------------------------------------------------------*
533 Name: G3B_Identity
534
535 Description: Makes a geometry command, which sets an identity matrix
536 to the current matrix, on a display list.
537 Note that the command is not packed.
538 Also, the pointers of GXDLInfo proceed.
539
540 Arguments: info a pointer to GXDLInfo
541
542 Returns: none
543 *---------------------------------------------------------------------------*/
G3B_Identity(GXDLInfo * info)544 void G3B_Identity(GXDLInfo *info)
545 {
546 G3BS_Identity(info);
547 G3B_UpdateGXDLInfo(info, G3OP_MTX_IDENTITY_NPARAMS);
548 }
549
550
551 /*---------------------------------------------------------------------------*
552 Name: G3B_LoadMtx44
553
554 Description: Make a geometry command which loads a 4x4 matrix
555 to the current matrix.
556 Also, the pointers of GXDLInfo proceed.
557
558 Arguments: info a pointer to GXDLInfo
559 m a pointer to a constant 4x4 matrix
560
561 Returns: none
562 *---------------------------------------------------------------------------*/
G3B_LoadMtx44(GXDLInfo * info,const MtxFx44 * m)563 void G3B_LoadMtx44(GXDLInfo *info, const MtxFx44 *m)
564 {
565 G3BS_LoadMtx44(info, m);
566 G3B_UpdateGXDLInfo(info, G3OP_MTX_LOAD_4x4_NPARAMS);
567 }
568
569
570 /*---------------------------------------------------------------------------*
571 Name: G3B_LoadMtx43
572
573 Description: Make a geometry command which loads a 4x3 matrix
574 to the current matrix.
575 Also, the pointers of GXDLInfo proceed.
576
577 Arguments: info a pointer to GXDLInfo
578 m a pointer to a constant 4x3 matrix
579
580 Returns: none
581 *---------------------------------------------------------------------------*/
G3B_LoadMtx43(GXDLInfo * info,const MtxFx43 * m)582 void G3B_LoadMtx43(GXDLInfo *info, const MtxFx43 *m)
583 {
584 G3BS_LoadMtx43(info, m);
585 G3B_UpdateGXDLInfo(info, G3OP_MTX_LOAD_4x3_NPARAMS);
586 }
587
588
589 /*---------------------------------------------------------------------------*
590 Name: G3B_MultMtx44
591
592 Description: Makes a geometry command which multiplies the current matrix
593 by a 4x4 matrix from the left.
594 Also, the pointers of GXDLInfo proceed.
595
596 Arguments: info a pointer to GXDLInfo
597 m a pointer to a constant 4x4 matrix
598
599 Returns: none
600 *---------------------------------------------------------------------------*/
G3B_MultMtx44(GXDLInfo * info,const MtxFx44 * m)601 void G3B_MultMtx44(GXDLInfo *info, const MtxFx44 *m)
602 {
603 G3BS_MultMtx44(info, m);
604 G3B_UpdateGXDLInfo(info, G3OP_MTX_MULT_4x4_NPARAMS);
605 }
606
607
608 /*---------------------------------------------------------------------------*
609 Name: G3B_MultMtx43
610
611 Description: Make a geometry command which multiplies the current matrix
612 by a 4x3 matrix from the left.
613 Also, the pointers of GXDLInfo proceed.
614
615 Arguments: info a pointer to GXDLInfo
616 m a pointer to a constant 4x3 matrix
617
618 Returns: none
619 *---------------------------------------------------------------------------*/
G3B_MultMtx43(GXDLInfo * info,const MtxFx43 * m)620 void G3B_MultMtx43(GXDLInfo *info, const MtxFx43 *m)
621 {
622 G3BS_MultMtx43(info, m);
623 G3B_UpdateGXDLInfo(info, G3OP_MTX_MULT_4x3_NPARAMS);
624 }
625
626
627 /*---------------------------------------------------------------------------*
628 Name: G3B_MultMtx33
629
630 Description: Makes a geometry command which multiplies the current matrix
631 by a 3x3 matrix from the left.
632 Also, the pointers of GXDLInfo proceed.
633
634 Arguments: info a pointer to GXDLInfo
635 m a pointer to a constant 3x3 matrix
636
637 Returns: none
638 *---------------------------------------------------------------------------*/
G3B_MultMtx33(GXDLInfo * info,const MtxFx33 * m)639 void G3B_MultMtx33(GXDLInfo *info, const MtxFx33 *m)
640 {
641 G3BS_MultMtx33(info, m);
642 G3B_UpdateGXDLInfo(info, G3OP_MTX_MULT_3x3_NPARAMS);
643 }
644
645 /*---------------------------------------------------------------------------*
646 Name: G3B_MultTrans
647
648 Description: Make a geometry command which multiplies and translates matrix together.
649
650 Arguments: info a pointer to GXDLInfo
651 mtx a pointer to a constant 3x3 matrix
652 trans a pointer to a constant translation vector
653
654 Returns: none
655 *---------------------------------------------------------------------------*/
G3B_MultTransMtx33(GXDLInfo * info,const MtxFx33 * mtx,const VecFx32 * trans)656 void G3B_MultTransMtx33(GXDLInfo *info, const MtxFx33 *mtx, const VecFx32 *trans)
657 {
658 G3BS_MultTransMtx33(info, mtx, trans);
659 G3B_UpdateGXDLInfo(info, G3OP_MTX_MULT_4x3_NPARAMS);
660 }
661
662 /*---------------------------------------------------------------------------*
663 Name: G3B_Scale
664
665 Description: Makes a geometry command, which multiplies the current matrix
666 by a scale matrix. Note that the command is not packed.
667 Also, the pointers of GXDLInfo proceed.
668
669 Arguments: info a pointer to GXDLInfo
670 x X coordinate of a scale
671 y Y coordinate of a scale
672 z Z coordinate of a scale
673
674 Returns: none
675 *---------------------------------------------------------------------------*/
G3B_Scale(GXDLInfo * info,fx32 x,fx32 y,fx32 z)676 void G3B_Scale(GXDLInfo *info, fx32 x, fx32 y, fx32 z)
677 {
678 G3BS_Scale(info, x, y, z);
679 G3B_UpdateGXDLInfo(info, G3OP_MTX_SCALE_NPARAMS);
680 }
681
682
683 /*---------------------------------------------------------------------------*
684 Name: G3B_Translate
685
686 Description: Makes a geometry command, which multiplies the current matrix
687 by a translation matrix. Note that the command is not packed.
688 Also, the pointers of GXDLInfo proceed.
689
690 Arguments: info a pointer to GXDLInfo
691 x X coordinate of a translation vector
692 y Y coordinate of a translation vector
693 z Z coordinate of a translation vector
694
695 Returns: none
696 *---------------------------------------------------------------------------*/
G3B_Translate(GXDLInfo * info,fx32 x,fx32 y,fx32 z)697 void G3B_Translate(GXDLInfo *info, fx32 x, fx32 y, fx32 z)
698 {
699 G3BS_Translate(info, x, y, z);
700 G3B_UpdateGXDLInfo(info, G3OP_MTX_TRANS_NPARAMS);
701 }
702
703
704 /*---------------------------------------------------------------------------*
705 Name: G3B_Color
706
707 Description: Makes a geometry command, which sends a vertex color.
708 Also, the pointers of GXDLInfo proceed.
709
710 Arguments: info a pointer to GXDLInfo
711 rgb a vertex color(R:5, G:5, B:5)
712
713 Returns: none
714 *---------------------------------------------------------------------------*/
G3B_Color(GXDLInfo * info,GXRgb rgb)715 void G3B_Color(GXDLInfo *info, GXRgb rgb)
716 {
717 G3BS_Color(info, rgb);
718 G3B_UpdateGXDLInfo(info, G3OP_COLOR_NPARAMS);
719 }
720
721
722 /*---------------------------------------------------------------------------*
723 Name: G3B_Normal
724
725 Description: Makes a geometry command, which sends a normal vector.
726 Also, the pointers of GXDLInfo proceed.
727
728 Arguments: info a pointer to GXDLInfo
729 x X coordinate of a normal vector
730 y Y coordinate of a normal vector
731 z Z coordinate of a normal vector
732
733 Returns: none
734 *---------------------------------------------------------------------------*/
G3B_Normal(GXDLInfo * info,fx16 x,fx16 y,fx16 z)735 void G3B_Normal(GXDLInfo *info, fx16 x, fx16 y, fx16 z)
736 {
737 G3BS_Normal(info, x, y, z);
738 G3B_UpdateGXDLInfo(info, G3OP_NORMAL_NPARAMS);
739 }
740
741
742 /*---------------------------------------------------------------------------*
743 Name: G3B_TexCoord
744
745 Description: Makes a geometry command, which sends a texture coordinate.
746 Also, the pointers of GXDLInfo proceed.
747
748 Arguments: info a pointer to GXDLInfo
749 s an S of a texture coordinate
750 t a T of a texture coordinate
751
752 Returns: none
753 *---------------------------------------------------------------------------*/
G3B_TexCoord(GXDLInfo * info,fx32 s,fx32 t)754 void G3B_TexCoord(GXDLInfo *info, fx32 s, fx32 t)
755 {
756 G3BS_TexCoord(info, s, t);
757 G3B_UpdateGXDLInfo(info, G3OP_TEXCOORD_NPARAMS);
758 }
759
760
761 /*---------------------------------------------------------------------------*
762 Name: G3B_Vtx
763
764 Description: Makes a geometry command, which sends a vertex as a fx16 vector.
765 Also, the pointers of GXDLInfo proceed.
766
767 Arguments: info a pointer to GXDLInfo
768 x X coordinate of a vertex
769 y Y coordinate of a vertex
770 z Z coordinate of a vertex
771
772 Returns: none
773 *---------------------------------------------------------------------------*/
G3B_Vtx(GXDLInfo * info,fx16 x,fx16 y,fx16 z)774 void G3B_Vtx(GXDLInfo *info, fx16 x, fx16 y, fx16 z)
775 {
776 G3BS_Vtx(info, x, y, z);
777 G3B_UpdateGXDLInfo(info, G3OP_VTX_16_NPARAMS);
778 }
779
780
781 /*---------------------------------------------------------------------------*
782 Name: G3B_Vtx10
783
784 Description: Makes a geometry command, which sends a vertex as a s3.6 vector.
785 Also, the pointers of GXDLInfo proceed.
786
787 Arguments: info a pointer to GXDLInfo
788 x X coordinate of a vertex
789 y Y coordinate of a vertex
790 z Z coordinate of a vertex
791
792 Returns: none
793 *---------------------------------------------------------------------------*/
G3B_Vtx10(GXDLInfo * info,fx16 x,fx16 y,fx16 z)794 void G3B_Vtx10(GXDLInfo *info, fx16 x, fx16 y, fx16 z)
795 {
796 G3BS_Vtx10(info, x, y, z);
797 G3B_UpdateGXDLInfo(info, G3OP_VTX_10_NPARAMS);
798 }
799
800
801 /*---------------------------------------------------------------------------*
802 Name: G3B_VtxXY
803
804 Description: Makes a geometry command, which sends XY components of a vertex.
805 The Z coordinate is the same to the vertex sent just before.
806 Also, the pointers of GXDLInfo proceed.
807
808 Arguments: info a pointer to GXDLInfo
809 x X coordinate of a vertex
810 y Y coordinate of a vertex
811
812 Returns: none
813 *---------------------------------------------------------------------------*/
G3B_VtxXY(GXDLInfo * info,fx16 x,fx16 y)814 void G3B_VtxXY(GXDLInfo *info, fx16 x, fx16 y)
815 {
816 G3BS_VtxXY(info, x, y);
817 G3B_UpdateGXDLInfo(info, G3OP_VTX_XY_NPARAMS);
818 }
819
820
821 /*---------------------------------------------------------------------------*
822 Name: G3B_VtxXZ
823
824 Description: Makes a geometry command, which sends XZ components of a vertex.
825 The Y coordinate is the same to the vertex sent just before.
826 Also, the pointers of GXDLInfo proceed.
827
828 Arguments: info a pointer to GXDLInfo
829 x X coordinate of a vertex
830 z Z coordinate of a vertex
831
832 Returns: none
833 *---------------------------------------------------------------------------*/
G3B_VtxXZ(GXDLInfo * info,fx16 x,fx16 z)834 void G3B_VtxXZ(GXDLInfo *info, fx16 x, fx16 z)
835 {
836 G3BS_VtxXZ(info, x, z);
837 G3B_UpdateGXDLInfo(info, G3OP_VTX_XZ_NPARAMS);
838 }
839
840
841 /*---------------------------------------------------------------------------*
842 Name: G3B_VtxYZ
843
844 Description: Makes a geometry command, which sends YZ components of a vertex.
845 The X component is the same to the vertex sent just before.
846 Also, the pointers of GXDLInfo proceed.
847
848 Arguments: info a pointer to GXDLInfo
849 y Y coordinate of a vertex
850 z Z coordinate of a vertex
851
852 Returns: none
853 *---------------------------------------------------------------------------*/
G3B_VtxYZ(GXDLInfo * info,fx16 y,fx16 z)854 void G3B_VtxYZ(GXDLInfo *info, fx16 y, fx16 z)
855 {
856 G3BS_VtxYZ(info, y, z);
857 G3B_UpdateGXDLInfo(info, G3OP_VTX_YZ_NPARAMS);
858 }
859
860
861 /*---------------------------------------------------------------------------*
862 Name: G3B_VtxDiff
863
864 Description: Makes a geometry commnad, which sends a vector as an offset
865 to the last vertex sent.
866 Also, the pointers of GXDLInfo proceed.
867
868 Arguments: info a pointer to GXDLInfo
869 x X coordinate of an offset
870 y Y coordinate of an offset
871 z Z coordinate of an offset
872
873 Returns: none
874 *---------------------------------------------------------------------------*/
G3B_VtxDiff(GXDLInfo * info,fx16 x,fx16 y,fx16 z)875 void G3B_VtxDiff(GXDLInfo *info, fx16 x, fx16 y, fx16 z)
876 {
877 G3BS_VtxDiff(info, x, y, z);
878 G3B_UpdateGXDLInfo(info, G3OP_VTX_DIFF_NPARAMS);
879 }
880
881
882 /*---------------------------------------------------------------------------*
883 Name: G3B_PolygonAttr
884
885 Description: Makes a geometry command, which sends attributes for polygons.
886 Also, the pointers of GXDLInfo proceed.
887
888 Arguments: info a pointer to GXDLInfo
889 light a 4bits field specifying light enable/disable
890 polyMode a polygon mode
891 cullMode a cull mode
892 polygonID a polygon ID
893 alpha an alpha value
894 misc miscellaneous flags
895
896 Returns: none
897 *---------------------------------------------------------------------------*/
G3B_PolygonAttr(GXDLInfo * info,int light,GXPolygonMode polyMode,GXCull cullMode,int polygonID,int alpha,int misc)898 void G3B_PolygonAttr(GXDLInfo *info, int light, GXPolygonMode polyMode, GXCull cullMode, int polygonID, int alpha, int misc // GXPolygonAttrMisc
899 )
900 {
901 G3BS_PolygonAttr(info, light, polyMode, cullMode, polygonID, alpha, misc);
902 G3B_UpdateGXDLInfo(info, G3OP_POLYGON_ATTR_NPARAMS);
903 }
904
905
906 /*---------------------------------------------------------------------------*
907 Name: G3B_TexImageParam
908
909 Description: Makes a geometry command, which sends parameters for a texture.
910 Also, the pointers of GXDLInfo proceed.
911
912 Arguments: info a pointer to GXDLInfo
913 texFmt format of a texture
914 texGen selects the source of a texture coordinate
915 s the size of a texture in the direction of the S-axis
916 t the size of a texture in the direction of the T-axis
917 repeat repeat
918 flip flip
919 pltt0 use/not use the color of pltt. 0
920 addr the offset address in the texture image slots
921 (shift 3bits internally)
922
923 Returns: none
924 *---------------------------------------------------------------------------*/
G3B_TexImageParam(GXDLInfo * info,GXTexFmt texFmt,GXTexGen texGen,GXTexSizeS s,GXTexSizeT t,GXTexRepeat repeat,GXTexFlip flip,GXTexPlttColor0 pltt0,u32 addr)925 void G3B_TexImageParam(GXDLInfo *info,
926 GXTexFmt texFmt,
927 GXTexGen texGen,
928 GXTexSizeS s, GXTexSizeT t, GXTexRepeat repeat, GXTexFlip flip,
929 GXTexPlttColor0 pltt0, u32 addr)
930 {
931 G3BS_TexImageParam(info, texFmt, texGen, s, t, repeat, flip, pltt0, addr);
932
933 G3B_UpdateGXDLInfo(info, G3OP_TEXIMAGE_PARAM_NPARAMS);
934 }
935
936
937 /*---------------------------------------------------------------------------*
938 Name: G3B_TexPlttBase
939
940 Description: Makes a geometry command, which sends a base address of
941 a texture palette.
942 Also, the pointers of GXDLInfo proceed.
943
944 Arguments: info a pointer to GXDLInfo
945 addr the offset address in the texture palette slots
946 texFmt format of a texture
947
948 Returns: none
949 *---------------------------------------------------------------------------*/
G3B_TexPlttBase(GXDLInfo * info,u32 addr,GXTexFmt texfmt)950 void G3B_TexPlttBase(GXDLInfo *info, u32 addr, GXTexFmt texfmt)
951 {
952 G3BS_TexPlttBase(info, addr, texfmt);
953
954 G3B_UpdateGXDLInfo(info, G3OP_TEXPLTT_BASE_NPARAMS);
955 }
956
957
958 /*---------------------------------------------------------------------------*
959 Name: G3B_MaterialColorDiffAmb
960
961 Description: Makes a geometry command, which sends diffuse and ambient.
962 Also, the pointers of GXDLInfo proceed.
963
964 Arguments: info a pointer to GXDLInfo
965 diffuse a diffuse color
966 ambient an ambient color
967 IsSetVtxColor sets a diffuse color as a vertex color if TRUE
968
969 Returns: none
970 *---------------------------------------------------------------------------*/
G3B_MaterialColorDiffAmb(GXDLInfo * info,GXRgb diffuse,GXRgb ambient,BOOL IsSetVtxColor)971 void G3B_MaterialColorDiffAmb(GXDLInfo *info, GXRgb diffuse, GXRgb ambient, BOOL IsSetVtxColor)
972 {
973 G3BS_MaterialColorDiffAmb(info, diffuse, ambient, IsSetVtxColor);
974
975 G3B_UpdateGXDLInfo(info, G3OP_DIF_AMB_NPARAMS);
976 }
977
978
979 /*---------------------------------------------------------------------------*
980 Name: G3B_MaterialColorSpecEmi
981
982 Description: Makes a geometry command, which sends specular and emission.
983 Also, the pointers of GXDLInfo proceed.
984
985 Arguments: info a pointer to GXDLInfo
986 specular a specular color
987 emission an emission color
988 IsShininess use the shininess table to change a specular
989 color if TRUE
990
991 Returns: none
992 *---------------------------------------------------------------------------*/
G3B_MaterialColorSpecEmi(GXDLInfo * info,GXRgb specular,GXRgb emission,BOOL IsShininess)993 void G3B_MaterialColorSpecEmi(GXDLInfo *info, GXRgb specular, GXRgb emission, BOOL IsShininess)
994 {
995 G3BS_MaterialColorSpecEmi(info, specular, emission, IsShininess);
996
997 G3B_UpdateGXDLInfo(info, G3OP_SPE_EMI_NPARAMS);
998 }
999
1000
1001 /*---------------------------------------------------------------------------*
1002 Name: G3B_LightVector
1003
1004 Description: Makes a geometry command, which sends a light vector.
1005 Also, the pointers of GXDLInfo proceed.
1006
1007 Arguments: info a pointer to GXDLInfo
1008 lightID light ID
1009 x X coordinate of a light vector
1010 y Y coordinate of a light vector
1011 z Z coordinate of a light vector
1012
1013 Returns: none
1014 *---------------------------------------------------------------------------*/
G3B_LightVector(GXDLInfo * info,GXLightId lightID,fx16 x,fx16 y,fx16 z)1015 void G3B_LightVector(GXDLInfo *info, GXLightId lightID, fx16 x, fx16 y, fx16 z)
1016 {
1017 G3BS_LightVector(info, lightID, x, y, z);
1018
1019 G3B_UpdateGXDLInfo(info, G3OP_LIGHT_VECTOR_NPARAMS);
1020 }
1021
1022
1023 /*---------------------------------------------------------------------------*
1024 Name: G3B_LightColor
1025
1026 Description: Makes a geometry command, which sends a light color.
1027 Also, the pointers of GXDLInfo proceed.
1028
1029 Arguments: info a pointer to GXDLInfo
1030 lightID light ID
1031 rgb a light color(R:5, G:5, B:5)
1032
1033 Returns: none
1034 *---------------------------------------------------------------------------*/
G3B_LightColor(GXDLInfo * info,GXLightId lightID,GXRgb rgb)1035 void G3B_LightColor(GXDLInfo *info, GXLightId lightID, GXRgb rgb)
1036 {
1037 G3BS_LightColor(info, lightID, rgb);
1038
1039 G3B_UpdateGXDLInfo(info, G3OP_LIGHT_COLOR_NPARAMS);
1040 }
1041
1042
1043 /*---------------------------------------------------------------------------*
1044 Name: G3B_Shininess
1045
1046 Description: Makes a geometry command, which sets up the shininess table.
1047 Also, the pointers of GXDLInfo proceed.
1048
1049 Arguments: info a pointer to GXDLInfo
1050 table a pointer to the shininess data(32 words)
1051
1052 Returns: none
1053 *---------------------------------------------------------------------------*/
G3B_Shininess(GXDLInfo * info,const u32 * table)1054 void G3B_Shininess(GXDLInfo *info, const u32 *table)
1055 {
1056 G3BS_Shininess(info, table);
1057 G3B_UpdateGXDLInfo(info, G3OP_SHININESS_NPARAMS);
1058 }
1059
1060
1061 /*---------------------------------------------------------------------------*
1062 Name: G3B_Begin
1063
1064 Description: Makes a geometry command, which starts sending primitives.
1065 Also, the pointers of GXDLInfo proceed.
1066
1067 Arguments: info a pointer to GXDLInfo
1068 primitive the type of primitives
1069
1070 Returns: none
1071 *---------------------------------------------------------------------------*/
G3B_Begin(GXDLInfo * info,GXBegin primitive)1072 void G3B_Begin(GXDLInfo *info, GXBegin primitive)
1073 {
1074 G3BS_Begin(info, primitive);
1075 G3B_UpdateGXDLInfo(info, G3OP_BEGIN_NPARAMS);
1076 }
1077
1078
1079 /*---------------------------------------------------------------------------*
1080 Name: G3B_End
1081
1082 Description: Makes a geometry command, which ends sending primitives.
1083 Also, the pointers of GXDLInfo proceed.
1084
1085 Arguments: info a pointer to GXDLInfo
1086
1087 Returns: none
1088 *---------------------------------------------------------------------------*/
G3B_End(GXDLInfo * info)1089 void G3B_End(GXDLInfo *info)
1090 {
1091 G3BS_End(info);
1092 G3B_UpdateGXDLInfo(info, G3OP_END_NPARAMS);
1093 }
1094
1095
1096 /*---------------------------------------------------------------------------*
1097 Name: G3B_SwapBuffers
1098
1099 Description: Makes a geometry command, which swaps the polygon list RAM,
1100 the vertex RAM, etc.
1101 Also, the pointers of GXDLInfo proceed.
1102
1103 Arguments: info a pointer to GXDLInfo
1104 am auto sort/manual sort
1105 zw Z buffer/W buffer
1106
1107 Returns: none
1108 *---------------------------------------------------------------------------*/
G3B_SwapBuffers(GXDLInfo * info,GXSortMode am,GXBufferMode zw)1109 void G3B_SwapBuffers(GXDLInfo *info, GXSortMode am, GXBufferMode zw)
1110 {
1111 G3BS_SwapBuffers(info, am, zw);
1112 G3B_UpdateGXDLInfo(info, G3OP_SWAP_BUFFERS_NPARAMS);
1113 }
1114
1115
1116 /*---------------------------------------------------------------------------*
1117 Name: G3B_ViewPort
1118
1119 Description: Makes a geometry command, which specifies viewport.
1120 Also, the pointers of GXDLInfo proceed.
1121
1122 Arguments: info a pointer to GXDLInfo
1123 x1 the X coordinate of the lower left
1124 y1 the Y coordinate of the lower left
1125 x2 the X coordinate of the upper right
1126 y2 the Y coordinate of the upper right
1127
1128 Returns: none
1129 *---------------------------------------------------------------------------*/
G3B_ViewPort(GXDLInfo * info,int x1,int y1,int x2,int y2)1130 void G3B_ViewPort(GXDLInfo *info, int x1, int y1, int x2, int y2)
1131 {
1132 G3BS_ViewPort(info, x1, y1, x2, y2);
1133 G3B_UpdateGXDLInfo(info, G3OP_VIEWPORT_NPARAMS);
1134 }
1135
1136
1137 /*---------------------------------------------------------------------------*
1138 Name: G3B_BoxTest
1139
1140 Description: Makes a geometry command, which tests if a box is
1141 in the frustum or not.
1142 Also, the pointers of GXDLInfo proceed.
1143
1144 Arguments: info a pointer to GXDLInfo
1145 box a pointer to GXBoxTestParam
1146
1147 Returns: none
1148 *---------------------------------------------------------------------------*/
G3B_BoxTest(GXDLInfo * info,const GXBoxTestParam * box)1149 void G3B_BoxTest(GXDLInfo *info, const GXBoxTestParam *box)
1150 {
1151 G3BS_BoxTest(info, box);
1152
1153 G3B_UpdateGXDLInfo(info, G3OP_BOX_TEST_NPARAMS);
1154 }
1155
1156
1157 /*---------------------------------------------------------------------------*
1158 Name: G3B_PositionTest
1159
1160 Description: Makes a geometry command, which applies a position vector
1161 to the current clip matrix.
1162 Also, the pointers of GXDLInfo proceed.
1163
1164 Arguments: info a pointer to GXDLInfo
1165 x X coordinate of a position
1166 y Y coordinate of a position
1167 z Z coordinate of a position
1168
1169 Returns: none
1170 *---------------------------------------------------------------------------*/
G3B_PositionTest(GXDLInfo * info,fx16 x,fx16 y,fx16 z)1171 void G3B_PositionTest(GXDLInfo *info, fx16 x, fx16 y, fx16 z)
1172 {
1173 G3BS_PositionTest(info, x, y, z);
1174
1175 G3B_UpdateGXDLInfo(info, G3OP_POS_TEST_NPARAMS);
1176 }
1177
1178
1179 /*---------------------------------------------------------------------------*
1180 Name: G3B_VectorTest
1181
1182 Description: Makes a geometry command, which applies a vector
1183 to the current vector matrix.
1184 Also, the pointers of GXDLInfo proceed.
1185
1186 Arguments: info a pointer to GXDLInfo
1187 x X coordinate of a vector
1188 y Y coordinate of a vector
1189 z Z coordinate of a vector
1190
1191 Returns: none
1192 *---------------------------------------------------------------------------*/
G3B_VectorTest(GXDLInfo * info,fx16 x,fx16 y,fx16 z)1193 void G3B_VectorTest(GXDLInfo *info, fx16 x, fx16 y, fx16 z)
1194 {
1195 G3BS_VectorTest(info, x, y, z);
1196
1197 G3B_UpdateGXDLInfo(info, G3OP_VEC_TEST_NPARAMS);
1198 }
1199