sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
gsPrimitive.c
1// ____ ___ | / _____ _____
2// | __ | |___/ | |
3// |___| ___| | \ __|__ | gsKit Open Source Project.
4// ----------------------------------------------------------------------
5// Copyright 2004 - Chris "Neovanglist" Gilbert <Neovanglist@LainOS.org>
6// Licenced under Academic Free License version 2.0
7// Review gsKit README & LICENSE files for further details.
8//
9// gsPrimitive.c - Primitive creation, handling, and manipulation.
10//
11// Parts taken from emoon's BreakPoint Demo Library
12//
13
14#include "gsKit.h"
15#include "gsInline.h"
16
17void gsKit_prim_point(GSGLOBAL *gsGlobal, float x, float y, int iz, u64 color)
18{
19 u64* p_store;
20 u64* p_data;
21 int qsize = 2;
22 int bsize = 32;
23
24 int ix = gsKit_float_to_int_x(gsGlobal, x);
25 int iy = gsKit_float_to_int_y(gsGlobal, y);
26
27 p_store = p_data = gsKit_heap_alloc(gsGlobal, qsize, bsize, GSKIT_GIF_PRIM_POINT);
28
29 if(p_store == gsGlobal->CurQueue->last_tag)
30 {
31 *p_data++ = GIF_TAG_POINT(0);
32 *p_data++ = GIF_TAG_POINT_REGS;
33 }
34
35 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_POINT, 0, 0, gsGlobal->PrimFogEnable,
37 0, gsGlobal->PrimContext, 0) ;
38
39 *p_data++ = color;
40 *p_data++ = GS_SETREG_XYZ2( ix, iy, iz );
41}
42
43void gsKit_prim_list_points(GSGLOBAL *gsGlobal, int count, const GSPRIMPOINT *vertices)
44{
45 u64* p_store;
46 u64* p_data;
47 int qsize = (count*2) + 2;
48 int bytes = count * sizeof(GSPRIMPOINT);
49
50 p_store = p_data = gsKit_heap_alloc(gsGlobal, qsize, (qsize*16), GIF_AD);
51
52 *p_data++ = GIF_TAG_AD(qsize);
53 *p_data++ = GIF_AD;
54
55
56 if(p_store == gsGlobal->CurQueue->last_tag)
57 {
58 *p_data++ = GIF_TAG_POINT(count-1);
59 *p_data++ = GIF_TAG_POINT_REGS;
60 }
61
62 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_POINT, 0, 0, gsGlobal->PrimFogEnable,
64 0, gsGlobal->PrimContext, 0) ;
65
66 *p_data++ = GS_PRIM;
67
68 memcpy(p_data, vertices, bytes);
69}
70
71void gsKit_prim_line_3d(GSGLOBAL *gsGlobal, float x1, float y1, int iz1, float x2, float y2, int iz2, u64 color)
72{
73 u64* p_store;
74 u64* p_data;
75 int qsize = 2;
76 int bsize = 32;
77
78 int ix1 = gsKit_float_to_int_x(gsGlobal, x1);
79 int iy1 = gsKit_float_to_int_y(gsGlobal, y1);
80
81 int ix2 = gsKit_float_to_int_x(gsGlobal, x2);
82 int iy2 = gsKit_float_to_int_y(gsGlobal, y2);
83
84 p_store = p_data = gsKit_heap_alloc(gsGlobal, qsize, bsize, GSKIT_GIF_PRIM_LINE);
85
86 if(p_store == gsGlobal->CurQueue->last_tag)
87 {
88 *p_data++ = GIF_TAG_LINE(0);
89 *p_data++ = GIF_TAG_LINE_REGS;
90 }
91
92 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_LINE, 0, 0, gsGlobal->PrimFogEnable,
94 0, gsGlobal->PrimContext, 0) ;
95
96 *p_data++ = color;
97 *p_data++ = GS_SETREG_XYZ2( ix1, iy1, iz1 );
98 *p_data++ = GS_SETREG_XYZ2( ix2, iy2, iz2 );
99}
100
101void gsKit_prim_line_goraud_3d(GSGLOBAL *gsGlobal, float x1, float y1, int iz1, float x2, float y2, int iz2, u64 color1, u64 color2)
102{
103 u64* p_store;
104 u64* p_data;
105 int qsize = 3;
106 int bsize = 48;
107
108 int ix1 = gsKit_float_to_int_x(gsGlobal, x1);
109 int iy1 = gsKit_float_to_int_y(gsGlobal, y1);
110
111 int ix2 = gsKit_float_to_int_x(gsGlobal, x2);
112 int iy2 = gsKit_float_to_int_y(gsGlobal, y2);
113
114 p_store = p_data = gsKit_heap_alloc(gsGlobal, qsize, bsize, GSKIT_GIF_PRIM_LINE);
115
116 if(p_store == gsGlobal->CurQueue->last_tag)
117 {
118 *p_data++ = GIF_TAG_LINE_GORAUD(0);
119 *p_data++ = GIF_TAG_LINE_GORAUD_REGS;
120 }
121
122 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_LINE, 1, 0, gsGlobal->PrimFogEnable,
124 0, gsGlobal->PrimContext, 0) ;
125
126 *p_data++ = color1;
127 *p_data++ = GS_SETREG_XYZ2( ix1, iy1, iz1 );
128
129 *p_data++ = color2;
130 *p_data++ = GS_SETREG_XYZ2( ix2, iy2, iz2 );
131}
132
133void gsKit_prim_list_line_goraud_3d(GSGLOBAL *gsGlobal, int count, const GSPRIMPOINT *vertices)
134{
135 u64* p_store;
136 u64* p_data;
137 int qsize = (count*2) + 1;
138 int bytes = count * sizeof(GSPRIMPOINT);
139
140 p_store = p_data = gsKit_heap_alloc(gsGlobal, qsize, (qsize*16), GIF_AD);
141
142 if(p_store == gsGlobal->CurQueue->last_tag)
143 {
144 *p_data++ = GIF_TAG_AD(qsize);
145 *p_data++ = GIF_AD;
146 }
147
148 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_LINE, 1, 0, gsGlobal->PrimFogEnable,
150 0, gsGlobal->PrimContext, 0) ;
151
152 *p_data++ = GS_PRIM;
153
154 memcpy(p_data, vertices, bytes);
155}
156
157void gsKit_prim_line_strip(GSGLOBAL *gsGlobal, float *LineStrip, int segments, int iz, u64 color)
158{
159 u64* p_data;
160 int qsize = 2 + segments;
161 int count;
162 int vertexdata[segments*2];
163
164 for(count = 0; count < (segments * 2); count+=2)
165 {
166 vertexdata[count+0] = gsKit_float_to_int_x(gsGlobal, *LineStrip++);
167 vertexdata[count+1] = gsKit_float_to_int_y(gsGlobal, *LineStrip++);
168 }
169
170 p_data = gsKit_heap_alloc(gsGlobal, qsize, (qsize * 16), GIF_AD);
171
172 *p_data++ = GIF_TAG_AD(qsize);
173 *p_data++ = GIF_AD;
174
175 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_LINESTRIP, 0, 0, gsGlobal->PrimFogEnable,
177 0, gsGlobal->PrimContext, 0) ;
178 *p_data++ = GS_PRIM;
179
180 *p_data++ = color;
181 *p_data++ = GS_RGBAQ;
182
183 for(count = 0; count < (segments * 2); count+=2)
184 {
185 *p_data++ = GS_SETREG_XYZ2( vertexdata[count], vertexdata[count+1], iz );
186 *p_data++ = GS_XYZ2;
187 }
188}
189
190void gsKit_prim_line_strip_3d(GSGLOBAL *gsGlobal, float *LineStrip, int segments, u64 color)
191{
192 u64* p_data;
193 int qsize = 2 + segments;
194 int count;
195 int vertexdata[segments*3];
196
197 for(count = 0; count < (segments * 3); count+=3)
198 {
199 vertexdata[count+0] = gsKit_float_to_int_x(gsGlobal, *LineStrip++);
200 vertexdata[count+1] = gsKit_float_to_int_y(gsGlobal, *LineStrip++);
201 vertexdata[count+2] = (int)((*LineStrip++) * 16.0f); // z
202 }
203
204 p_data = gsKit_heap_alloc(gsGlobal, qsize, (qsize * 16), GIF_AD);
205
206 *p_data++ = GIF_TAG_AD(qsize);
207 *p_data++ = GIF_AD;
208
209 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_LINESTRIP, 0, 0, gsGlobal->PrimFogEnable,
211 0, gsGlobal->PrimContext, 0) ;
212
213 *p_data++ = GS_PRIM;
214
215 *p_data++ = color;
216 *p_data++ = GS_RGBAQ;
217
218 for(count = 0; count < (segments * 3); count+=3)
219 {
220 *p_data++ = GS_SETREG_XYZ2( vertexdata[count], vertexdata[count+1], vertexdata[count+2] );
221 *p_data++ = GS_XYZ2;
222 }
223}
224
225void gsKit_prim_sprite(GSGLOBAL *gsGlobal, float x1, float y1, float x2, float y2, int iz, u64 color)
226{
227 u64* p_store;
228 u64* p_data;
229 int qsize = 2;
230 int bsize = 32;
231
232 int ix1 = gsKit_float_to_int_x(gsGlobal, x1);
233 int iy1 = gsKit_float_to_int_y(gsGlobal, y1);
234
235 int ix2 = gsKit_float_to_int_x(gsGlobal, x2);
236 int iy2 = gsKit_float_to_int_y(gsGlobal, y2);
237
238 p_store = p_data = gsKit_heap_alloc(gsGlobal, qsize, bsize, GSKIT_GIF_PRIM_SPRITE);
239
240 if(p_store == gsGlobal->CurQueue->last_tag)
241 {
242 *p_data++ = GIF_TAG_SPRITE(0);
243 *p_data++ = GIF_TAG_SPRITE_REGS;
244 }
245
246 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_SPRITE, 0, 0, gsGlobal->PrimFogEnable,
248 0, gsGlobal->PrimContext, 0) ;
249
250 *p_data++ = color;
251 *p_data++ = GS_SETREG_XYZ2( ix1, iy1, iz );
252 *p_data++ = GS_SETREG_XYZ2( ix2, iy2, iz );
253}
254
255void gsKit_prim_list_sprite_gouraud_3d(GSGLOBAL *gsGlobal, int count, const GSPRIMPOINT *vertices)
256{
257 u64* p_store;
258 u64* p_data;
259 int qsize = (count*2) + 1;
260 int bytes = count * sizeof(GSPRIMPOINT);
261
262 p_store = p_data = gsKit_heap_alloc(gsGlobal, qsize, (qsize*16), GIF_AD);
263
264 if(p_store == gsGlobal->CurQueue->last_tag)
265 {
266 *p_data++ = GIF_TAG_AD(qsize);
267 *p_data++ = GIF_AD;
268 }
269
270 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_SPRITE, 1, 0, gsGlobal->PrimFogEnable,
272 0, gsGlobal->PrimContext, 0);
273
274 *p_data++ = GS_PRIM;
275
276 memcpy(p_data, vertices, bytes);
277}
278
279void gsKit_prim_list_sprite_flat_color(GSGLOBAL *gsGlobal, gs_rgbaq color, int count, const gs_xyz2 *vertices)
280{
281 u64* p_store;
282 u64* p_data;
283 int qsize = count + 2;
284 int bytes = count * sizeof(gs_xyz2);
285
286 p_store = p_data = gsKit_heap_alloc(gsGlobal, qsize, (qsize*16), GIF_AD);
287
288 if(p_store == gsGlobal->CurQueue->last_tag)
289 {
290 *p_data++ = GIF_TAG_AD(qsize);
291 *p_data++ = GIF_AD;
292 }
293
294 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_SPRITE, 0, 0, gsGlobal->PrimFogEnable,
296 0, gsGlobal->PrimContext, 0);
297
298 *p_data++ = GS_PRIM;
299
300 // Copy color
301 memcpy(p_data, &color, sizeof(gs_rgbaq));
302 p_data += 2; // Advance 2 u64, which is 16 bytes the gs_rgbaq struct size
303 // Copy vertices
304 memcpy(p_data, vertices, bytes);
305}
306
307void gsKit_prim_list_sprite_flat(GSGLOBAL *gsGlobal, int count, const u128 *flatContent)
308{
309 u64* p_store;
310 u64* p_data;
311 int qsize = count + 1;
312 int bytes = count * sizeof(u128);
313
314 p_store = p_data = gsKit_heap_alloc(gsGlobal, qsize, (qsize*16), GIF_AD);
315
316 if(p_store == gsGlobal->CurQueue->last_tag)
317 {
318 *p_data++ = GIF_TAG_AD(qsize);
319 *p_data++ = GIF_AD;
320 }
321
322 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_SPRITE, 0, 0, gsGlobal->PrimFogEnable,
324 0, gsGlobal->PrimContext, 0);
325
326 *p_data++ = GS_PRIM;
327
328 memcpy(p_data, flatContent, bytes);
329}
330
331
332void gsKit_prim_triangle_3d(GSGLOBAL *gsGlobal, float x1, float y1, int iz1,
333 float x2, float y2, int iz2,
334 float x3, float y3, int iz3, u64 color)
335{
336 u64* p_data;
337 int qsize = 5;
338 int bsize = 80;
339
340 int ix1 = gsKit_float_to_int_x(gsGlobal, x1);
341 int iy1 = gsKit_float_to_int_y(gsGlobal, y1);
342
343 int ix2 = gsKit_float_to_int_x(gsGlobal, x2);
344 int iy2 = gsKit_float_to_int_y(gsGlobal, y2);
345
346 int ix3 = gsKit_float_to_int_x(gsGlobal, x3);
347 int iy3 = gsKit_float_to_int_y(gsGlobal, y3);
348
349 p_data = gsKit_heap_alloc(gsGlobal, qsize, bsize, GIF_AD);
350
351 *p_data++ = GIF_TAG_AD(5);
352 *p_data++ = GIF_AD;
353
354 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_TRIANGLE, 0, 0, gsGlobal->PrimFogEnable,
356 0, gsGlobal->PrimContext, 0) ;
357 *p_data++ = GS_PRIM;
358
359 *p_data++ = color;
360 *p_data++ = GS_RGBAQ;
361
362 *p_data++ = GS_SETREG_XYZ2(ix1, iy1, iz1);
363 *p_data++ = GS_XYZ2;
364
365 *p_data++ = GS_SETREG_XYZ2(ix2, iy2, iz2);
366 *p_data++ = GS_XYZ2;
367
368 *p_data++ = GS_SETREG_XYZ2(ix3, iy3, iz3);
369 *p_data++ = GS_XYZ2;
370}
371
372void gsKit_prim_triangle_strip(GSGLOBAL *gsGlobal, float *TriStrip, int segments, int iz, u64 color)
373{
374 u64* p_data;
375 int qsize = 2 + segments;
376 int count;
377 int vertexdata[segments*2];
378
379 for(count = 0; count < (segments * 2); count+=2)
380 {
381 vertexdata[count+0] = gsKit_float_to_int_x(gsGlobal, *TriStrip++);
382 vertexdata[count+1] = gsKit_float_to_int_y(gsGlobal, *TriStrip++);
383 }
384
385 p_data = gsKit_heap_alloc(gsGlobal, qsize, (qsize * 16), GIF_AD);
386
387 *p_data++ = GIF_TAG_AD(qsize);
388 *p_data++ = GIF_AD;
389
390 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_TRISTRIP, 0, 0, gsGlobal->PrimFogEnable,
392 0, gsGlobal->PrimContext, 0) ;
393
394 *p_data++ = GS_PRIM;
395
396 *p_data++ = color;
397 *p_data++ = GS_RGBAQ;
398
399 for(count = 0; count < (segments * 2); count+=2)
400 {
401 *p_data++ = GS_SETREG_XYZ2( vertexdata[count], vertexdata[count+1], iz );
402 *p_data++ = GS_XYZ2;
403 }
404}
405
406void gsKit_prim_triangle_strip_3d(GSGLOBAL *gsGlobal, float *TriStrip, int segments, u64 color)
407{
408 u64* p_data;
409 int qsize = 2 + segments;
410 int count;
411 int vertexdata[segments*3];
412
413 for(count = 0; count < (segments * 3); count+=3)
414 {
415 vertexdata[count+0] = gsKit_float_to_int_x(gsGlobal, *TriStrip++);
416 vertexdata[count+1] = gsKit_float_to_int_y(gsGlobal, *TriStrip++);
417 vertexdata[count+2] = (int)((*TriStrip++) * 16.0f); // z
418 }
419
420 p_data = gsKit_heap_alloc(gsGlobal, qsize, (qsize * 16), GIF_AD);
421
422 *p_data++ = GIF_TAG_AD(qsize);
423 *p_data++ = GIF_AD;
424
425 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_TRISTRIP, 0, 0, gsGlobal->PrimFogEnable,
427 0, gsGlobal->PrimContext, 0) ;
428
429 *p_data++ = GS_PRIM;
430
431 *p_data++ = color;
432 *p_data++ = GS_RGBAQ;
433
434 for(count = 0; count < (segments * 3); count+=3)
435 {
436 *p_data++ = GS_SETREG_XYZ2( vertexdata[count], vertexdata[count+1], vertexdata[count+2] );
437 *p_data++ = GS_XYZ2;
438 }
439}
440
441void gsKit_prim_triangle_fan(GSGLOBAL *gsGlobal, float *TriFan, int verticies, int iz, u64 color)
442{
443 u64* p_data;
444 int qsize = 2 + verticies;
445 int count;
446 int vertexdata[verticies*2];
447
448 for(count = 0; count < (verticies * 2); count+=2)
449 {
450 vertexdata[count+0] = gsKit_float_to_int_x(gsGlobal, *TriFan++);
451 vertexdata[count+1] = gsKit_float_to_int_y(gsGlobal, *TriFan++);
452 }
453
454 p_data = gsKit_heap_alloc(gsGlobal, qsize, (qsize * 16), GIF_AD);
455
456 *p_data++ = GIF_TAG_AD(qsize);
457 *p_data++ = GIF_AD;
458
459 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_TRIFAN, 0, 0, gsGlobal->PrimFogEnable,
461 0, gsGlobal->PrimContext, 0) ;
462
463 *p_data++ = GS_PRIM;
464
465 *p_data++ = color;
466 *p_data++ = GS_RGBAQ;
467
468 for(count = 0; count < (verticies * 2); count+=2)
469 {
470 *p_data++ = GS_SETREG_XYZ2( vertexdata[count], vertexdata[count+1], iz );
471 *p_data++ = GS_XYZ2;
472 }
473}
474
475void gsKit_prim_triangle_fan_3d(GSGLOBAL *gsGlobal, float *TriFan, int verticies, u64 color)
476{
477 u64* p_data;
478 int qsize = 2 + verticies;
479 int count;
480 int vertexdata[verticies*3];
481
482 for(count = 0; count < (verticies * 3); count+=3)
483 {
484 vertexdata[count+0] = gsKit_float_to_int_x(gsGlobal, *TriFan++);
485 vertexdata[count+1] = gsKit_float_to_int_y(gsGlobal, *TriFan++);
486 vertexdata[count+2] = (int)(*TriFan++ * 16.0f); // z
487 }
488
489 p_data = gsKit_heap_alloc(gsGlobal, qsize, (qsize * 16), GIF_AD);
490
491 *p_data++ = GIF_TAG_AD(qsize);
492 *p_data++ = GIF_AD;
493
494 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_TRIFAN, 0, 0, gsGlobal->PrimFogEnable,
496 0, gsGlobal->PrimContext, 0) ;
497
498 *p_data++ = GS_PRIM;
499
500 *p_data++ = color;
501 *p_data++ = GS_RGBAQ;
502
503 for(count = 0; count < (verticies * 3); count+=3)
504 {
505 *p_data++ = GS_SETREG_XYZ2( vertexdata[count], vertexdata[count+1], vertexdata[count+2] );
506 *p_data++ = GS_XYZ2;
507 }
508}
509
510void gsKit_prim_triangle_gouraud_3d(GSGLOBAL *gsGlobal, float x1, float y1, int iz1,
511 float x2, float y2, int iz2,
512 float x3, float y3, int iz3,
513 u64 color1, u64 color2, u64 color3)
514{
515 u64* p_store;
516 u64* p_data;
517 int qsize = 4;
518 int bsize = 64;
519
520 int ix1 = gsKit_float_to_int_x(gsGlobal, x1);
521 int iy1 = gsKit_float_to_int_y(gsGlobal, y1);
522
523 int ix2 = gsKit_float_to_int_x(gsGlobal, x2);
524 int iy2 = gsKit_float_to_int_y(gsGlobal, y2);
525
526 int ix3 = gsKit_float_to_int_x(gsGlobal, x3);
527 int iy3 = gsKit_float_to_int_y(gsGlobal, y3);
528
529 p_store = p_data = gsKit_heap_alloc(gsGlobal, qsize, bsize, GSKIT_GIF_PRIM_TRIANGLE_GOURAUD);
530
531 if(p_store == gsGlobal->CurQueue->last_tag)
532 {
533 *p_data++ = GIF_TAG_TRIANGLE_GOURAUD(0);
535 }
536
537 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_TRIANGLE, 1, 0, gsGlobal->PrimFogEnable,
539 0, gsGlobal->PrimContext, 0) ;
540
541 *p_data++ = color1;
542 *p_data++ = GS_SETREG_XYZ2(ix1, iy1, iz1);
543
544 *p_data++ = color2;
545 *p_data++ = GS_SETREG_XYZ2(ix2, iy2, iz2);
546
547 *p_data++ = color3;
548 *p_data++ = GS_SETREG_XYZ2(ix3, iy3, iz3);
549}
550
551void gsKit_prim_list_triangle_gouraud_3d(GSGLOBAL *gsGlobal, int count, const GSPRIMPOINT *vertices)
552{
553 u64* p_store;
554 u64* p_data;
555 int qsize = (count*2) + 1;
556 int bytes = count * sizeof(GSPRIMPOINT);
557
558 p_store = p_data = gsKit_heap_alloc(gsGlobal, qsize, (qsize*16), GIF_AD);
559
560 if(p_store == gsGlobal->CurQueue->last_tag)
561 {
562 *p_data++ = GIF_TAG_AD(qsize);
563 *p_data++ = GIF_AD;
564 }
565
566 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_TRIANGLE, 1, 0, gsGlobal->PrimFogEnable,
568 0, gsGlobal->PrimContext, 0);
569
570 *p_data++ = GS_PRIM;
571
572 memcpy(p_data, vertices, bytes);
573}
574
575void gsKit_prim_quad_3d(GSGLOBAL *gsGlobal, float x1, float y1, int iz1,
576 float x2, float y2, int iz2,
577 float x3, float y3, int iz3,
578 float x4, float y4, int iz4, u64 color)
579{
580 u64* p_store;
581 u64* p_data;
582 int qsize = 3;
583 int bsize = 48;
584
585 int ix1 = gsKit_float_to_int_x(gsGlobal, x1);
586 int iy1 = gsKit_float_to_int_y(gsGlobal, y1);
587
588 int ix2 = gsKit_float_to_int_x(gsGlobal, x2);
589 int iy2 = gsKit_float_to_int_y(gsGlobal, y2);
590
591 int ix3 = gsKit_float_to_int_x(gsGlobal, x3);
592 int iy3 = gsKit_float_to_int_y(gsGlobal, y3);
593
594 int ix4 = gsKit_float_to_int_x(gsGlobal, x4);
595 int iy4 = gsKit_float_to_int_y(gsGlobal, y4);
596
597 p_store = p_data = gsKit_heap_alloc( gsGlobal, qsize, bsize, GSKIT_GIF_PRIM_QUAD);
598
599 if(p_store == gsGlobal->CurQueue->last_tag)
600 {
601 *p_data++ = GIF_TAG_QUAD(0);
602 *p_data++ = GIF_TAG_QUAD_REGS;
603 }
604
605 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_TRISTRIP, 0, 0, gsGlobal->PrimFogEnable,
607 0, gsGlobal->PrimContext, 0) ;
608
609 *p_data++ = color;
610 *p_data++ = GS_SETREG_XYZ2( ix1, iy1, iz1 );
611 *p_data++ = GS_SETREG_XYZ2( ix2, iy2, iz2 );
612 *p_data++ = GS_SETREG_XYZ2( ix3, iy3, iz3 );
613 *p_data++ = GS_SETREG_XYZ2( ix4, iy4, iz4 );
614}
615
616void gsKit_prim_quad_gouraud_3d(GSGLOBAL *gsGlobal, float x1, float y1, int iz1,
617 float x2, float y2, int iz2,
618 float x3, float y3, int iz3,
619 float x4, float y4, int iz4,
620 u64 color1, u64 color2,
621 u64 color3, u64 color4)
622{
623 u64* p_store;
624 u64* p_data;
625 int qsize = 5;
626 int bsize = 80;
627
628 int ix1 = gsKit_float_to_int_x(gsGlobal, x1);
629 int iy1 = gsKit_float_to_int_y(gsGlobal, y1);
630
631 int ix2 = gsKit_float_to_int_x(gsGlobal, x2);
632 int iy2 = gsKit_float_to_int_y(gsGlobal, y2);
633
634 int ix3 = gsKit_float_to_int_x(gsGlobal, x3);
635 int iy3 = gsKit_float_to_int_y(gsGlobal, y3);
636
637 int ix4 = gsKit_float_to_int_x(gsGlobal, x4);
638 int iy4 = gsKit_float_to_int_y(gsGlobal, y4);
639
640 p_store = p_data = gsKit_heap_alloc(gsGlobal, qsize, bsize, GSKIT_GIF_PRIM_QUAD_GOURAUD);
641
642 if(p_store == gsGlobal->CurQueue->last_tag)
643 {
644 *p_data++ = GIF_TAG_QUAD_GOURAUD(0);
645 *p_data++ = GIF_TAG_QUAD_GOURAUD_REGS;
646 }
647
648 *p_data++ = GS_SETREG_PRIM( GS_PRIM_PRIM_TRISTRIP, 1, 0, gsGlobal->PrimFogEnable,
650 0, gsGlobal->PrimContext, 0) ;
651
652 *p_data++ = color1;
653 *p_data++ = GS_SETREG_XYZ2( ix1, iy1, iz1 );
654
655 *p_data++ = color2;
656 *p_data++ = GS_SETREG_XYZ2( ix2, iy2, iz2 );
657
658 *p_data++ = color3;
659 *p_data++ = GS_SETREG_XYZ2( ix3, iy3, iz3 );
660
661 *p_data++ = color4;
662 *p_data++ = GS_SETREG_XYZ2( ix4, iy4, iz4 );
663}
#define GIF_TAG_AD(NLOOP)
A+D GIFTAG.
Definition gsInit.h:308
#define GS_PRIM
GS Primitive.
Definition gsInit.h:156
#define GIF_TAG_LINE(NLOOP)
Line Primitive GIFTAG.
Definition gsInit.h:321
#define GIF_TAG_SPRITE_REGS
Sprite Primitive REGLIST.
Definition gsInit.h:357
#define GIF_TAG_QUAD_GOURAUD(NLOOP)
Gouraud Shaded Quad Primitive GIFTAG.
Definition gsInit.h:391
#define GSKIT_GIF_PRIM_POINT
gsKit GIFTAG REGLIST mode PRIM Identifiers
Definition gsInit.h:282
#define GS_SETREG_XYZ2
GS Vertex Value Object Creation Macro.
Definition gsInit.h:590
#define GIF_TAG_POINT(NLOOP)
Point Primitive GIFTAG.
Definition gsInit.h:311
#define GIF_TAG_LINE_REGS
Line Primitive REGLIST.
Definition gsInit.h:323
#define GS_XYZ2
GS Vertex Coordinate Value.
Definition gsInit.h:166
#define GIF_TAG_SPRITE(NLOOP)
Sprite Primitive GIFTAG.
Definition gsInit.h:355
#define GIF_TAG_POINT_REGS
Point Primitive REGLIST.
Definition gsInit.h:313
#define GS_PRIM_PRIM_TRIANGLE
GS Triangle Primitive.
Definition gsInit.h:273
#define GS_RGBAQ
GS Color in RGBAQ Format.
Definition gsInit.h:158
#define GIF_TAG_TRIANGLE_GOURAUD_REGS
Gouraud Shaded Triangle Primitive REGLIST.
Definition gsInit.h:379
#define GIF_TAG_LINE_GORAUD_REGS
Line Goraud Primitive REGLIST.
Definition gsInit.h:333
#define GIF_TAG_QUAD(NLOOP)
Quad Primitive GIFTAG.
Definition gsInit.h:365
#define GIF_TAG_QUAD_GOURAUD_REGS
Gouraud Shaded Quad Primitive REGLIST.
Definition gsInit.h:393
#define GIF_AD
GIF_TAG Address+Data Setting. (Used after GIF_TAG).
Definition gsInit.h:494
#define GS_PRIM_PRIM_POINT
GS Point Primitive.
Definition gsInit.h:267
#define GS_PRIM_PRIM_LINESTRIP
GS Line Strip Primitive.
Definition gsInit.h:271
#define GIF_TAG_QUAD_REGS
Quad Primitive REGLIST.
Definition gsInit.h:367
#define GS_PRIM_PRIM_SPRITE
GS Sprite Primitive.
Definition gsInit.h:279
#define GS_PRIM_PRIM_LINE
GS Line Primitive.
Definition gsInit.h:269
#define GIF_TAG_TRIANGLE_GOURAUD(NLOOP)
Gouraud Shaded Triangle Primitive GIFTAG.
Definition gsInit.h:377
#define GIF_TAG_LINE_GORAUD(NLOOP)
Line Goraud Primitive GIFTAG.
Definition gsInit.h:331
#define GS_PRIM_PRIM_TRIFAN
GS Triangle Fan Primitive.
Definition gsInit.h:277
#define GS_PRIM_PRIM_TRISTRIP
GS Triangle Strip Primitive.
Definition gsInit.h:275
int PrimAlphaEnable
Primitive Alpha Blending Enable.
Definition gsInit.h:945
int PrimContext
Primitive Context.
Definition gsInit.h:942
GSQUEUE * CurQueue
Draw Queue (Current).
Definition gsInit.h:934
int PrimFogEnable
Primitive Fog Enable.
Definition gsInit.h:943
int PrimAAEnable
Primitive AntiAlaising Enable.
Definition gsInit.h:944
void * last_tag
Pointer to the GIF_TAG of the last object in this draw queue.
Definition gsInit.h:863