2 FNAME(white_untextured) (
ZBuffer *zb,
15 #define PUT_PIXEL(_a) \
17 zz=z >> ZB_POINT_Z_FRAC_BITS; \
18 if (ZCMP(pz[_a], zz)) { \
19 STORE_PIX(pp[_a], 0xffffffffUL, 0xffffUL, 0xffffUL, 0xffffUL, 0xffffUL); \
20 STORE_Z(pz[_a], zz); \
25 #define PIXEL_COUNT pixel_count_white_untextured
27 #include "ztriangle.h"
31 FNAME(flat_untextured) (
ZBuffer *zb,
35 int or0, og0, ob0, oa0;
45 if (!ACMP(zb, p2->a)) { \
52 color=RGBA_TO_PIXEL(or0, og0, ob0, oa0); \
55 #define PUT_PIXEL(_a) \
57 zz=z >> ZB_POINT_Z_FRAC_BITS; \
58 if (ZCMP(pz[_a], zz)) { \
59 STORE_PIX(pp[_a], color, or0, og0, ob0, oa0); \
60 STORE_Z(pz[_a], zz); \
65 #define PIXEL_COUNT pixel_count_flat_untextured
67 #include "ztriangle.h"
76 FNAME(smooth_untextured) (
ZBuffer *zb,
85 c0 = RGBA_TO_PIXEL(p0->r, p0->g, p0->b, p0->a); \
86 c1 = RGBA_TO_PIXEL(p1->r, p1->g, p1->b, p1->a); \
87 c2 = RGBA_TO_PIXEL(p2->r, p2->g, p2->b, p2->a); \
88 if (c0 == c1 && c0 == c2) { \
90 FNAME(flat_untextured)(zb, p0, p1, p2); \
99 #define PUT_PIXEL(_a) \
101 zz=z >> ZB_POINT_Z_FRAC_BITS; \
102 if (ZCMP(pz[_a], zz)) { \
103 if (ACMP(zb, oa1)) { \
104 STORE_PIX(pp[_a], RGBA_TO_PIXEL(or1, og1, ob1, oa1), or1, og1, ob1, oa1); \
105 STORE_Z(pz[_a], zz); \
115 #define PIXEL_COUNT pixel_count_smooth_untextured
117 #include "ztriangle.h"
121 FNAME(white_textured) (
ZBuffer *zb,
129 #define EARLY_OUT() \
133 #define DRAW_INIT() \
135 texture_def = &zb->current_textures[0]; \
138 #define PUT_PIXEL(_a) \
140 zz=z >> ZB_POINT_Z_FRAC_BITS; \
141 if (ZCMP(pz[_a], zz)) { \
142 tmp = ZB_LOOKUP_TEXTURE(texture_def, s, t, mipmap_level, mipmap_dx); \
143 if (ACMP(zb, PIXEL_A(tmp))) { \
144 STORE_PIX(pp[_a], tmp, PIXEL_R(tmp), PIXEL_G(tmp), PIXEL_B(tmp), PIXEL_A(tmp)); \
145 STORE_Z(pz[_a], zz); \
153 #define PIXEL_COUNT pixel_count_white_textured
155 #include "ztriangle.h"
159 FNAME(flat_textured) (
ZBuffer *zb,
163 int or0, og0, ob0, oa0;
168 #define EARLY_OUT() \
172 #define DRAW_INIT() \
174 if (p2->a == 0 && !ACMP(zb, p2->a)) { \
178 texture_def = &zb->current_textures[0]; \
185 #define PUT_PIXEL(_a) \
187 zz=z >> ZB_POINT_Z_FRAC_BITS; \
188 if (ZCMP(pz[_a], zz)) { \
189 tmp = ZB_LOOKUP_TEXTURE(texture_def, s, t, mipmap_level, mipmap_dx); \
190 int a = PALPHA_MULT(oa0, PIXEL_A(tmp)); \
193 RGBA_TO_PIXEL(PCOMPONENT_MULT(or0, PIXEL_R(tmp)), \
194 PCOMPONENT_MULT(og0, PIXEL_G(tmp)), \
195 PCOMPONENT_MULT(ob0, PIXEL_B(tmp)), \
197 PCOMPONENT_MULT(or0, PIXEL_R(tmp)), \
198 PCOMPONENT_MULT(og0, PIXEL_G(tmp)), \
199 PCOMPONENT_MULT(ob0, PIXEL_B(tmp)), \
201 STORE_Z(pz[_a], zz); \
209 #define PIXEL_COUNT pixel_count_flat_textured
211 #include "ztriangle.h"
215 FNAME(smooth_textured) (
ZBuffer *zb,
224 #define EARLY_OUT() \
227 c0 = RGBA_TO_PIXEL(p0->r, p0->g, p0->b, p0->a); \
228 c1 = RGBA_TO_PIXEL(p1->r, p1->g, p1->b, p1->a); \
229 c2 = RGBA_TO_PIXEL(p2->r, p2->g, p2->b, p2->a); \
230 if (c0 == c1 && c0 == c2) { \
232 if (c0 == 0xffffffff) { \
234 FNAME(white_textured)(zb, p0, p1, p2); \
237 FNAME(flat_textured)(zb, p0, p1, p2); \
242 #define DRAW_INIT() \
244 texture_def = &zb->current_textures[0]; \
247 #define PUT_PIXEL(_a) \
249 zz=z >> ZB_POINT_Z_FRAC_BITS; \
250 if (ZCMP(pz[_a], zz)) { \
251 tmp = ZB_LOOKUP_TEXTURE(texture_def, s, t, mipmap_level, mipmap_dx); \
252 int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \
255 RGBA_TO_PIXEL(PCOMPONENT_MULT(or1, PIXEL_R(tmp)), \
256 PCOMPONENT_MULT(og1, PIXEL_G(tmp)), \
257 PCOMPONENT_MULT(ob1, PIXEL_B(tmp)), \
259 PCOMPONENT_MULT(or1, PIXEL_R(tmp)), \
260 PCOMPONENT_MULT(og1, PIXEL_G(tmp)), \
261 PCOMPONENT_MULT(ob1, PIXEL_B(tmp)), \
263 STORE_Z(pz[_a], zz); \
275 #define PIXEL_COUNT pixel_count_smooth_textured
277 #include "ztriangle.h"
287 FNAME(white_perspective) (
ZBuffer *zb,
291 PN_stdfloat fdzdx,fndzdx,ndszdx,ndtzdx;
298 #define EARLY_OUT() \
302 #define DRAW_INIT() \
304 texture_def = &zb->current_textures[0]; \
305 fdzdx=(PN_stdfloat)dzdx; \
306 fndzdx=NB_INTERP * fdzdx; \
307 ndszdx=NB_INTERP * dszdx; \
308 ndtzdx=NB_INTERP * dtzdx; \
312 #define PUT_PIXEL(_a) \
314 zz=z >> ZB_POINT_Z_FRAC_BITS; \
315 if (ZCMP(pz[_a], zz)) { \
316 tmp = ZB_LOOKUP_TEXTURE(texture_def, s, t, mipmap_level, mipmap_dx); \
317 if (ACMP(zb, PIXEL_A(tmp))) { \
318 STORE_PIX(pp[_a], tmp, PIXEL_R(tmp), PIXEL_G(tmp), PIXEL_B(tmp), PIXEL_A(tmp)); \
319 STORE_Z(pz[_a], zz); \
327 #define DRAW_LINE() \
333 PN_stdfloat sz,tz,fz,zinv; \
335 fz=(PN_stdfloat)z1; \
337 pp=(PIXEL *)((char *)pp1 + x1 * PSZB); \
342 while (n>=(NB_INTERP-1)) { \
349 dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
350 dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
351 CALC_MIPMAP_LEVEL(mipmap_level, mipmap_dx, dsdx, dtdx); \
364 pp=(PIXEL *)((char *)pp + NB_INTERP * PSZB); \
375 dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
376 dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
377 CALC_MIPMAP_LEVEL(mipmap_level, mipmap_dx, dsdx, dtdx); \
382 pp=(PIXEL *)((char *)pp + PSZB); \
387 #define PIXEL_COUNT pixel_count_white_perspective
389 #include "ztriangle.h"
397 FNAME(flat_perspective) (
ZBuffer *zb,
401 PN_stdfloat fdzdx,fndzdx,ndszdx,ndtzdx;
402 int or0, og0, ob0, oa0;
408 #define EARLY_OUT() \
412 #define DRAW_INIT() \
414 if (p2->a == 0 && !ACMP(zb, p2->a)) { \
418 texture_def = &zb->current_textures[0]; \
419 fdzdx=(PN_stdfloat)dzdx; \
420 fndzdx=NB_INTERP * fdzdx; \
421 ndszdx=NB_INTERP * dszdx; \
422 ndtzdx=NB_INTERP * dtzdx; \
429 #define PUT_PIXEL(_a) \
431 zz=z >> ZB_POINT_Z_FRAC_BITS; \
432 if (ZCMP(pz[_a], zz)) { \
433 tmp = ZB_LOOKUP_TEXTURE(texture_def, s, t, mipmap_level, mipmap_dx); \
434 int a = PALPHA_MULT(oa0, PIXEL_A(tmp)); \
437 RGBA_TO_PIXEL(PCOMPONENT_MULT(or0, PIXEL_R(tmp)), \
438 PCOMPONENT_MULT(og0, PIXEL_G(tmp)), \
439 PCOMPONENT_MULT(ob0, PIXEL_B(tmp)), \
441 PCOMPONENT_MULT(or0, PIXEL_R(tmp)), \
442 PCOMPONENT_MULT(og0, PIXEL_G(tmp)), \
443 PCOMPONENT_MULT(ob0, PIXEL_B(tmp)), \
445 STORE_Z(pz[_a], zz); \
453 #define DRAW_LINE() \
459 int or1,og1,ob1,oa1; \
460 PN_stdfloat sz,tz,fz,zinv; \
462 fz=(PN_stdfloat)z1; \
464 pp=(PIXEL *)((char *)pp1 + x1 * PSZB); \
473 while (n>=(NB_INTERP-1)) { \
480 dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
481 dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
482 CALC_MIPMAP_LEVEL(mipmap_level, mipmap_dx, dsdx, dtdx); \
495 pp=(PIXEL *)((char *)pp + NB_INTERP * PSZB); \
506 dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
507 dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
508 CALC_MIPMAP_LEVEL(mipmap_level, mipmap_dx, dsdx, dtdx); \
513 pp=(PIXEL *)((char *)pp + PSZB); \
518 #define PIXEL_COUNT pixel_count_flat_perspective
520 #include "ztriangle.h"
528 FNAME(smooth_perspective) (
ZBuffer *zb,
532 PN_stdfloat fdzdx,fndzdx,ndszdx,ndtzdx;
538 #define EARLY_OUT() \
541 c0 = RGBA_TO_PIXEL(p0->r, p0->g, p0->b, p0->a); \
542 c1 = RGBA_TO_PIXEL(p1->r, p1->g, p1->b, p1->a); \
543 c2 = RGBA_TO_PIXEL(p2->r, p2->g, p2->b, p2->a); \
544 if (c0 == c1 && c0 == c2) { \
546 if (c0 == 0xffffffff) { \
548 FNAME(white_perspective)(zb, p0, p1, p2); \
551 FNAME(flat_perspective)(zb, p0, p1, p2); \
556 #define DRAW_INIT() \
558 texture_def = &zb->current_textures[0]; \
559 fdzdx=(PN_stdfloat)dzdx; \
560 fndzdx=NB_INTERP * fdzdx; \
561 ndszdx=NB_INTERP * dszdx; \
562 ndtzdx=NB_INTERP * dtzdx; \
565 #define PUT_PIXEL(_a) \
567 zz=z >> ZB_POINT_Z_FRAC_BITS; \
568 if (ZCMP(pz[_a], zz)) { \
569 tmp = ZB_LOOKUP_TEXTURE(texture_def, s, t, mipmap_level, mipmap_dx); \
570 int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \
573 RGBA_TO_PIXEL(PCOMPONENT_MULT(or1, PIXEL_R(tmp)), \
574 PCOMPONENT_MULT(og1, PIXEL_G(tmp)), \
575 PCOMPONENT_MULT(ob1, PIXEL_B(tmp)), \
577 PCOMPONENT_MULT(or1, PIXEL_R(tmp)), \
578 PCOMPONENT_MULT(og1, PIXEL_G(tmp)), \
579 PCOMPONENT_MULT(ob1, PIXEL_B(tmp)), \
581 STORE_Z(pz[_a], zz); \
593 #define DRAW_LINE() \
599 int or1,og1,ob1,oa1; \
600 PN_stdfloat sz,tz,fz,zinv; \
602 fz=(PN_stdfloat)z1; \
604 pp=(PIXEL *)((char *)pp1 + x1 * PSZB); \
613 while (n>=(NB_INTERP-1)) { \
620 dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
621 dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
622 CALC_MIPMAP_LEVEL(mipmap_level, mipmap_dx, dsdx, dtdx); \
635 pp=(PIXEL *)((char *)pp + NB_INTERP * PSZB); \
646 dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
647 dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
648 CALC_MIPMAP_LEVEL(mipmap_level, mipmap_dx, dsdx, dtdx); \
653 pp=(PIXEL *)((char *)pp + PSZB); \
658 #define PIXEL_COUNT pixel_count_smooth_perspective
660 #include "ztriangle.h"
669 FNAME(smooth_multitex2) (
ZBuffer *zb,
672 PN_stdfloat fdzdx,fndzdx,ndszdx,ndtzdx,ndszadx,ndtzadx;
679 #define EARLY_OUT() \
683 #define DRAW_INIT() \
685 fdzdx=(PN_stdfloat)dzdx; \
686 fndzdx=NB_INTERP * fdzdx; \
687 ndszdx=NB_INTERP * dszdx; \
688 ndtzdx=NB_INTERP * dtzdx; \
689 ndszadx=NB_INTERP * dszadx; \
690 ndtzadx=NB_INTERP * dtzadx; \
693 #define PUT_PIXEL(_a) \
695 zz=z >> ZB_POINT_Z_FRAC_BITS; \
696 if (ZCMP(pz[_a], zz)) { \
697 tmp = ZB_LOOKUP_TEXTURE(&zb->current_textures[0], s, t, mipmap_level, mipmap_dx); \
698 int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \
700 int tmpa = ZB_LOOKUP_TEXTURE(&zb->current_textures[1], sa, ta, mipmap_levela, mipmap_dxa); \
702 RGBA_TO_PIXEL(PCOMPONENT_MULT3(or1, PIXEL_R(tmp), PIXEL_R(tmpa)), \
703 PCOMPONENT_MULT3(og1, PIXEL_G(tmp), PIXEL_G(tmpa)), \
704 PCOMPONENT_MULT3(ob1, PIXEL_B(tmp), PIXEL_B(tmpa)), \
706 PCOMPONENT_MULT3(or1, PIXEL_R(tmp), PIXEL_R(tmpa)), \
707 PCOMPONENT_MULT3(og1, PIXEL_G(tmp), PIXEL_G(tmpa)), \
708 PCOMPONENT_MULT3(ob1, PIXEL_B(tmp), PIXEL_B(tmpa)), \
710 STORE_Z(pz[_a], zz); \
724 #define DRAW_LINE() \
728 int s,t,sa,ta,z,zz; \
729 int n,dsdx,dtdx,dsadx,dtadx; \
730 int or1,og1,ob1,oa1; \
731 PN_stdfloat sz,tz,sza,tza,fz,zinv; \
733 fz=(PN_stdfloat)z1; \
735 pp=(PIXEL *)((char *)pp1 + x1 * PSZB); \
746 while (n>=(NB_INTERP-1)) { \
753 dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
754 dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
755 CALC_MIPMAP_LEVEL(mipmap_level, mipmap_dx, dsdx, dtdx); \
758 PN_stdfloat ssa,tta; \
763 dsadx= (int)( (dszadx - ssa*fdzdx)*zinv ); \
764 dtadx= (int)( (dtzadx - tta*fdzdx)*zinv ); \
765 CALC_MIPMAP_LEVEL(mipmap_levela, mipmap_dxa, dsadx, dtadx); \
778 pp=(PIXEL *)((char *)pp + NB_INTERP * PSZB); \
791 dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
792 dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
793 CALC_MIPMAP_LEVEL(mipmap_level, mipmap_dx, dsdx, dtdx); \
796 PN_stdfloat ssa,tta; \
801 dsadx= (int)( (dszadx - ssa*fdzdx)*zinv ); \
802 dtadx= (int)( (dtzadx - tta*fdzdx)*zinv ); \
803 CALC_MIPMAP_LEVEL(mipmap_levela, mipmap_dxa, dsadx, dtadx); \
808 pp=(PIXEL *)((char *)pp + PSZB); \
813 #define PIXEL_COUNT pixel_count_smooth_multitex2
815 #include "ztriangle.h"
824 FNAME(smooth_multitex3) (
ZBuffer *zb,
827 PN_stdfloat fdzdx,fndzdx,ndszdx,ndtzdx,ndszadx,ndtzadx,ndszbdx,ndtzbdx;
835 #define EARLY_OUT() \
839 #define DRAW_INIT() \
841 fdzdx=(PN_stdfloat)dzdx; \
842 fndzdx=NB_INTERP * fdzdx; \
843 ndszdx=NB_INTERP * dszdx; \
844 ndtzdx=NB_INTERP * dtzdx; \
845 ndszadx=NB_INTERP * dszadx; \
846 ndtzadx=NB_INTERP * dtzadx; \
847 ndszbdx=NB_INTERP * dszbdx; \
848 ndtzbdx=NB_INTERP * dtzbdx; \
851 #define PUT_PIXEL(_a) \
853 zz=z >> ZB_POINT_Z_FRAC_BITS; \
854 if (ZCMP(pz[_a], zz)) { \
855 tmp = ZB_LOOKUP_TEXTURE(&zb->current_textures[0], s, t, mipmap_level, mipmap_dx); \
856 int a = PALPHA_MULT(oa1, PIXEL_A(tmp)); \
858 int tmpa = ZB_LOOKUP_TEXTURE(&zb->current_textures[1], sa, ta, mipmap_levela, mipmap_dxa); \
859 int tmpb = ZB_LOOKUP_TEXTURE(&zb->current_textures[2], sb, tb, mipmap_levelb, mipmap_dxb); \
861 RGBA_TO_PIXEL(PCOMPONENT_MULT4(or1, PIXEL_R(tmp), PIXEL_R(tmpa), PIXEL_R(tmpb)), \
862 PCOMPONENT_MULT4(og1, PIXEL_G(tmp), PIXEL_G(tmpa), PIXEL_G(tmpb)), \
863 PCOMPONENT_MULT4(ob1, PIXEL_B(tmp), PIXEL_B(tmpa), PIXEL_B(tmpb)), \
865 PCOMPONENT_MULT4(or1, PIXEL_R(tmp), PIXEL_R(tmpa), PIXEL_R(tmpb)), \
866 PCOMPONENT_MULT4(og1, PIXEL_G(tmp), PIXEL_G(tmpa), PIXEL_G(tmpb)), \
867 PCOMPONENT_MULT4(ob1, PIXEL_B(tmp), PIXEL_B(tmpa), PIXEL_B(tmpb)), \
869 STORE_Z(pz[_a], zz); \
885 #define DRAW_LINE() \
889 int s,t,sa,ta,sb,tb,z,zz; \
890 int n,dsdx,dtdx,dsadx,dtadx,dsbdx,dtbdx; \
891 int or1,og1,ob1,oa1; \
892 PN_stdfloat sz,tz,sza,tza,szb,tzb,fz,zinv; \
894 fz=(PN_stdfloat)z1; \
896 pp=(PIXEL *)((char *)pp1 + x1 * PSZB); \
909 while (n>=(NB_INTERP-1)) { \
916 dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
917 dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
918 CALC_MIPMAP_LEVEL(mipmap_level, mipmap_dx, dsdx, dtdx); \
921 PN_stdfloat ssa,tta; \
926 dsadx= (int)( (dszadx - ssa*fdzdx)*zinv ); \
927 dtadx= (int)( (dtzadx - tta*fdzdx)*zinv ); \
928 CALC_MIPMAP_LEVEL(mipmap_levela, mipmap_dxa, dsadx, dtadx); \
931 PN_stdfloat ssb,ttb; \
936 dsbdx= (int)( (dszbdx - ssb*fdzdx)*zinv ); \
937 dtbdx= (int)( (dtzbdx - ttb*fdzdx)*zinv ); \
938 CALC_MIPMAP_LEVEL(mipmap_levelb, mipmap_dxb, dsbdx, dtbdx); \
951 pp=(PIXEL *)((char *)pp + NB_INTERP * PSZB); \
966 dsdx= (int)( (dszdx - ss*fdzdx)*zinv ); \
967 dtdx= (int)( (dtzdx - tt*fdzdx)*zinv ); \
968 CALC_MIPMAP_LEVEL(mipmap_level, mipmap_dx, dsdx, dtdx); \
971 PN_stdfloat ssa,tta; \
976 dsadx= (int)( (dszadx - ssa*fdzdx)*zinv ); \
977 dtadx= (int)( (dtzadx - tta*fdzdx)*zinv ); \
978 CALC_MIPMAP_LEVEL(mipmap_levela, mipmap_dxa, dsadx, dtadx); \
981 PN_stdfloat ssb,ttb; \
986 dsbdx= (int)( (dszbdx - ssb*fdzdx)*zinv ); \
987 dtbdx= (int)( (dtzbdx - ttb*fdzdx)*zinv ); \
988 CALC_MIPMAP_LEVEL(mipmap_levelb, mipmap_dxb, dsbdx, dtbdx); \
993 pp=(PIXEL *)((char *)pp + PSZB); \
998 #define PIXEL_COUNT pixel_count_smooth_multitex3
1000 #include "ztriangle.h"
1008 #undef INTERP_MIPMAP
1009 #undef CALC_MIPMAP_LEVEL
1010 #undef ZB_LOOKUP_TEXTURE