Browse Source

more fill options

David Rose 17 years ago
parent
commit
90d7caf0a9

+ 500 - 45
panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx

@@ -34,56 +34,458 @@ PStatCollector TinyGraphicsStateGuardian::_vertices_immediate_pcollector("Vertic
 
 
 
 
 static const ZB_fillTriangleFunc fill_tri_funcs
 static const ZB_fillTriangleFunc fill_tri_funcs
-[2 /* alpha test: anone, abin (binary) */]
+[2 /* depth write: zon, zoff */]
+[3 /* color write: noblend, blend, nocolor */]
+[3 /* alpha test: anone, aless, amore */]
 [2 /* ztest: znone, zless */]
 [2 /* ztest: znone, zless */]
 [3 /* white, flat, smooth */]
 [3 /* white, flat, smooth */]
 [3 /* untextured, textured, perspective textured */] = {
 [3 /* untextured, textured, perspective textured */] = {
-  { // alpha test anone
-    {
-      { ZB_fillTriangleFlat_anone_znone,
-        ZB_fillTriangleMapping_anone_znone,
-        ZB_fillTriangleMappingPerspective_anone_znone },
-      { ZB_fillTriangleFlat_anone_znone,
-        ZB_fillTriangleMappingFlat_anone_znone,
-        ZB_fillTriangleMappingPerspectiveFlat_anone_znone },
-      { ZB_fillTriangleSmooth_anone_znone,
-        ZB_fillTriangleMappingSmooth_anone_znone,
-        ZB_fillTriangleMappingPerspectiveSmooth_anone_znone },
+  { // depth write zon
+    { // color write noblend
+      { // alpha test anone
+        {
+          { ZB_fillTriangleFlat_xx_zon_noblend_anone_znone,
+            ZB_fillTriangleMapping_xx_zon_noblend_anone_znone,
+            ZB_fillTriangleMappingPerspective_xx_zon_noblend_anone_znone },
+          { ZB_fillTriangleFlat_xx_zon_noblend_anone_znone,
+            ZB_fillTriangleMappingFlat_xx_zon_noblend_anone_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_anone_znone },
+          { ZB_fillTriangleSmooth_xx_zon_noblend_anone_znone,
+            ZB_fillTriangleMappingSmooth_xx_zon_noblend_anone_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_anone_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zon_noblend_anone_zless,
+            ZB_fillTriangleMapping_xx_zon_noblend_anone_zless,
+            ZB_fillTriangleMappingPerspective_xx_zon_noblend_anone_zless },
+          { ZB_fillTriangleFlat_xx_zon_noblend_anone_zless,
+            ZB_fillTriangleMappingFlat_xx_zon_noblend_anone_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_anone_zless },
+          { ZB_fillTriangleSmooth_xx_zon_noblend_anone_zless,
+            ZB_fillTriangleMappingSmooth_xx_zon_noblend_anone_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_anone_zless },
+        },
+      },
+      { // alpha test aless
+        {
+          { ZB_fillTriangleFlat_xx_zon_noblend_aless_znone,
+            ZB_fillTriangleMapping_xx_zon_noblend_aless_znone,
+            ZB_fillTriangleMappingPerspective_xx_zon_noblend_aless_znone },
+          { ZB_fillTriangleFlat_xx_zon_noblend_aless_znone,
+            ZB_fillTriangleMappingFlat_xx_zon_noblend_aless_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_aless_znone },
+          { ZB_fillTriangleSmooth_xx_zon_noblend_aless_znone,
+            ZB_fillTriangleMappingSmooth_xx_zon_noblend_aless_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_aless_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zon_noblend_aless_zless,
+            ZB_fillTriangleMapping_xx_zon_noblend_aless_zless,
+            ZB_fillTriangleMappingPerspective_xx_zon_noblend_aless_zless },
+          { ZB_fillTriangleFlat_xx_zon_noblend_aless_zless,
+            ZB_fillTriangleMappingFlat_xx_zon_noblend_aless_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_aless_zless },
+          { ZB_fillTriangleSmooth_xx_zon_noblend_aless_zless,
+            ZB_fillTriangleMappingSmooth_xx_zon_noblend_aless_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_aless_zless },
+        },
+      },
+      { // alpha test amore
+        {
+          { ZB_fillTriangleFlat_xx_zon_noblend_amore_znone,
+            ZB_fillTriangleMapping_xx_zon_noblend_amore_znone,
+            ZB_fillTriangleMappingPerspective_xx_zon_noblend_amore_znone },
+          { ZB_fillTriangleFlat_xx_zon_noblend_amore_znone,
+            ZB_fillTriangleMappingFlat_xx_zon_noblend_amore_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_amore_znone },
+          { ZB_fillTriangleSmooth_xx_zon_noblend_amore_znone,
+            ZB_fillTriangleMappingSmooth_xx_zon_noblend_amore_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_amore_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zon_noblend_amore_zless,
+            ZB_fillTriangleMapping_xx_zon_noblend_amore_zless,
+            ZB_fillTriangleMappingPerspective_xx_zon_noblend_amore_zless },
+          { ZB_fillTriangleFlat_xx_zon_noblend_amore_zless,
+            ZB_fillTriangleMappingFlat_xx_zon_noblend_amore_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_amore_zless },
+          { ZB_fillTriangleSmooth_xx_zon_noblend_amore_zless,
+            ZB_fillTriangleMappingSmooth_xx_zon_noblend_amore_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_amore_zless },
+        },
+      },
     },
     },
-    {
-      { ZB_fillTriangleFlat_anone_zless,
-        ZB_fillTriangleMapping_anone_zless,
-        ZB_fillTriangleMappingPerspective_anone_zless },
-      { ZB_fillTriangleFlat_anone_zless,
-        ZB_fillTriangleMappingFlat_anone_zless,
-        ZB_fillTriangleMappingPerspectiveFlat_anone_zless },
-      { ZB_fillTriangleSmooth_anone_zless,
-        ZB_fillTriangleMappingSmooth_anone_zless,
-        ZB_fillTriangleMappingPerspectiveSmooth_anone_zless },
+    { // color write blend
+      { // alpha test anone
+        {
+          { ZB_fillTriangleFlat_xx_zon_blend_anone_znone,
+            ZB_fillTriangleMapping_xx_zon_blend_anone_znone,
+            ZB_fillTriangleMappingPerspective_xx_zon_blend_anone_znone },
+          { ZB_fillTriangleFlat_xx_zon_blend_anone_znone,
+            ZB_fillTriangleMappingFlat_xx_zon_blend_anone_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_anone_znone },
+          { ZB_fillTriangleSmooth_xx_zon_blend_anone_znone,
+            ZB_fillTriangleMappingSmooth_xx_zon_blend_anone_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_anone_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zon_blend_anone_zless,
+            ZB_fillTriangleMapping_xx_zon_blend_anone_zless,
+            ZB_fillTriangleMappingPerspective_xx_zon_blend_anone_zless },
+          { ZB_fillTriangleFlat_xx_zon_blend_anone_zless,
+            ZB_fillTriangleMappingFlat_xx_zon_blend_anone_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_anone_zless },
+          { ZB_fillTriangleSmooth_xx_zon_blend_anone_zless,
+            ZB_fillTriangleMappingSmooth_xx_zon_blend_anone_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_anone_zless },
+        },
+      },
+      { // alpha test aless
+        {
+          { ZB_fillTriangleFlat_xx_zon_blend_aless_znone,
+            ZB_fillTriangleMapping_xx_zon_blend_aless_znone,
+            ZB_fillTriangleMappingPerspective_xx_zon_blend_aless_znone },
+          { ZB_fillTriangleFlat_xx_zon_blend_aless_znone,
+            ZB_fillTriangleMappingFlat_xx_zon_blend_aless_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_aless_znone },
+          { ZB_fillTriangleSmooth_xx_zon_blend_aless_znone,
+            ZB_fillTriangleMappingSmooth_xx_zon_blend_aless_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_aless_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zon_blend_aless_zless,
+            ZB_fillTriangleMapping_xx_zon_blend_aless_zless,
+            ZB_fillTriangleMappingPerspective_xx_zon_blend_aless_zless },
+          { ZB_fillTriangleFlat_xx_zon_blend_aless_zless,
+            ZB_fillTriangleMappingFlat_xx_zon_blend_aless_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_aless_zless },
+          { ZB_fillTriangleSmooth_xx_zon_blend_aless_zless,
+            ZB_fillTriangleMappingSmooth_xx_zon_blend_aless_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_aless_zless },
+        },
+      },
+      { // alpha test amore
+        {
+          { ZB_fillTriangleFlat_xx_zon_blend_amore_znone,
+            ZB_fillTriangleMapping_xx_zon_blend_amore_znone,
+            ZB_fillTriangleMappingPerspective_xx_zon_blend_amore_znone },
+          { ZB_fillTriangleFlat_xx_zon_blend_amore_znone,
+            ZB_fillTriangleMappingFlat_xx_zon_blend_amore_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_amore_znone },
+          { ZB_fillTriangleSmooth_xx_zon_blend_amore_znone,
+            ZB_fillTriangleMappingSmooth_xx_zon_blend_amore_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_amore_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zon_blend_amore_zless,
+            ZB_fillTriangleMapping_xx_zon_blend_amore_zless,
+            ZB_fillTriangleMappingPerspective_xx_zon_blend_amore_zless },
+          { ZB_fillTriangleFlat_xx_zon_blend_amore_zless,
+            ZB_fillTriangleMappingFlat_xx_zon_blend_amore_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_amore_zless },
+          { ZB_fillTriangleSmooth_xx_zon_blend_amore_zless,
+            ZB_fillTriangleMappingSmooth_xx_zon_blend_amore_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_amore_zless },
+        },
+      },
+    },
+    { // color write nocolor
+      { // alpha test anone
+        {
+          { ZB_fillTriangleFlat_xx_zon_nocolor_anone_znone,
+            ZB_fillTriangleMapping_xx_zon_nocolor_anone_znone,
+            ZB_fillTriangleMappingPerspective_xx_zon_nocolor_anone_znone },
+          { ZB_fillTriangleFlat_xx_zon_nocolor_anone_znone,
+            ZB_fillTriangleMappingFlat_xx_zon_nocolor_anone_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_anone_znone },
+          { ZB_fillTriangleSmooth_xx_zon_nocolor_anone_znone,
+            ZB_fillTriangleMappingSmooth_xx_zon_nocolor_anone_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_anone_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zon_nocolor_anone_zless,
+            ZB_fillTriangleMapping_xx_zon_nocolor_anone_zless,
+            ZB_fillTriangleMappingPerspective_xx_zon_nocolor_anone_zless },
+          { ZB_fillTriangleFlat_xx_zon_nocolor_anone_zless,
+            ZB_fillTriangleMappingFlat_xx_zon_nocolor_anone_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_anone_zless },
+          { ZB_fillTriangleSmooth_xx_zon_nocolor_anone_zless,
+            ZB_fillTriangleMappingSmooth_xx_zon_nocolor_anone_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_anone_zless },
+        },
+      },
+      { // alpha test aless
+        {
+          { ZB_fillTriangleFlat_xx_zon_nocolor_aless_znone,
+            ZB_fillTriangleMapping_xx_zon_nocolor_aless_znone,
+            ZB_fillTriangleMappingPerspective_xx_zon_nocolor_aless_znone },
+          { ZB_fillTriangleFlat_xx_zon_nocolor_aless_znone,
+            ZB_fillTriangleMappingFlat_xx_zon_nocolor_aless_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_aless_znone },
+          { ZB_fillTriangleSmooth_xx_zon_nocolor_aless_znone,
+            ZB_fillTriangleMappingSmooth_xx_zon_nocolor_aless_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_aless_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zon_nocolor_aless_zless,
+            ZB_fillTriangleMapping_xx_zon_nocolor_aless_zless,
+            ZB_fillTriangleMappingPerspective_xx_zon_nocolor_aless_zless },
+          { ZB_fillTriangleFlat_xx_zon_nocolor_aless_zless,
+            ZB_fillTriangleMappingFlat_xx_zon_nocolor_aless_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_aless_zless },
+          { ZB_fillTriangleSmooth_xx_zon_nocolor_aless_zless,
+            ZB_fillTriangleMappingSmooth_xx_zon_nocolor_aless_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_aless_zless },
+        },
+      },
+      { // alpha test amore
+        {
+          { ZB_fillTriangleFlat_xx_zon_nocolor_amore_znone,
+            ZB_fillTriangleMapping_xx_zon_nocolor_amore_znone,
+            ZB_fillTriangleMappingPerspective_xx_zon_nocolor_amore_znone },
+          { ZB_fillTriangleFlat_xx_zon_nocolor_amore_znone,
+            ZB_fillTriangleMappingFlat_xx_zon_nocolor_amore_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_amore_znone },
+          { ZB_fillTriangleSmooth_xx_zon_nocolor_amore_znone,
+            ZB_fillTriangleMappingSmooth_xx_zon_nocolor_amore_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_amore_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zon_nocolor_amore_zless,
+            ZB_fillTriangleMapping_xx_zon_nocolor_amore_zless,
+            ZB_fillTriangleMappingPerspective_xx_zon_nocolor_amore_zless },
+          { ZB_fillTriangleFlat_xx_zon_nocolor_amore_zless,
+            ZB_fillTriangleMappingFlat_xx_zon_nocolor_amore_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_amore_zless },
+          { ZB_fillTriangleSmooth_xx_zon_nocolor_amore_zless,
+            ZB_fillTriangleMappingSmooth_xx_zon_nocolor_amore_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_amore_zless },
+        },
+      },
     },
     },
   },
   },
-  { // alpha test abin
-    {
-      { ZB_fillTriangleFlat_abin_znone,
-        ZB_fillTriangleMapping_abin_znone,
-        ZB_fillTriangleMappingPerspective_abin_znone },
-      { ZB_fillTriangleFlat_abin_znone,
-        ZB_fillTriangleMappingFlat_abin_znone,
-        ZB_fillTriangleMappingPerspectiveFlat_abin_znone },
-      { ZB_fillTriangleSmooth_abin_znone,
-        ZB_fillTriangleMappingSmooth_abin_znone,
-        ZB_fillTriangleMappingPerspectiveSmooth_abin_znone },
+  { // depth write zoff
+    { // color write noblend
+      { // alpha test anone
+        {
+          { ZB_fillTriangleFlat_xx_zoff_noblend_anone_znone,
+            ZB_fillTriangleMapping_xx_zoff_noblend_anone_znone,
+            ZB_fillTriangleMappingPerspective_xx_zoff_noblend_anone_znone },
+          { ZB_fillTriangleFlat_xx_zoff_noblend_anone_znone,
+            ZB_fillTriangleMappingFlat_xx_zoff_noblend_anone_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_anone_znone },
+          { ZB_fillTriangleSmooth_xx_zoff_noblend_anone_znone,
+            ZB_fillTriangleMappingSmooth_xx_zoff_noblend_anone_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_anone_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zoff_noblend_anone_zless,
+            ZB_fillTriangleMapping_xx_zoff_noblend_anone_zless,
+            ZB_fillTriangleMappingPerspective_xx_zoff_noblend_anone_zless },
+          { ZB_fillTriangleFlat_xx_zoff_noblend_anone_zless,
+            ZB_fillTriangleMappingFlat_xx_zoff_noblend_anone_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_anone_zless },
+          { ZB_fillTriangleSmooth_xx_zoff_noblend_anone_zless,
+            ZB_fillTriangleMappingSmooth_xx_zoff_noblend_anone_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_anone_zless },
+        },
+      },
+      { // alpha test aless
+        {
+          { ZB_fillTriangleFlat_xx_zoff_noblend_aless_znone,
+            ZB_fillTriangleMapping_xx_zoff_noblend_aless_znone,
+            ZB_fillTriangleMappingPerspective_xx_zoff_noblend_aless_znone },
+          { ZB_fillTriangleFlat_xx_zoff_noblend_aless_znone,
+            ZB_fillTriangleMappingFlat_xx_zoff_noblend_aless_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_aless_znone },
+          { ZB_fillTriangleSmooth_xx_zoff_noblend_aless_znone,
+            ZB_fillTriangleMappingSmooth_xx_zoff_noblend_aless_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_aless_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zoff_noblend_aless_zless,
+            ZB_fillTriangleMapping_xx_zoff_noblend_aless_zless,
+            ZB_fillTriangleMappingPerspective_xx_zoff_noblend_aless_zless },
+          { ZB_fillTriangleFlat_xx_zoff_noblend_aless_zless,
+            ZB_fillTriangleMappingFlat_xx_zoff_noblend_aless_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_aless_zless },
+          { ZB_fillTriangleSmooth_xx_zoff_noblend_aless_zless,
+            ZB_fillTriangleMappingSmooth_xx_zoff_noblend_aless_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_aless_zless },
+        },
+      },
+      { // alpha test amore
+        {
+          { ZB_fillTriangleFlat_xx_zoff_noblend_amore_znone,
+            ZB_fillTriangleMapping_xx_zoff_noblend_amore_znone,
+            ZB_fillTriangleMappingPerspective_xx_zoff_noblend_amore_znone },
+          { ZB_fillTriangleFlat_xx_zoff_noblend_amore_znone,
+            ZB_fillTriangleMappingFlat_xx_zoff_noblend_amore_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_amore_znone },
+          { ZB_fillTriangleSmooth_xx_zoff_noblend_amore_znone,
+            ZB_fillTriangleMappingSmooth_xx_zoff_noblend_amore_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_amore_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zoff_noblend_amore_zless,
+            ZB_fillTriangleMapping_xx_zoff_noblend_amore_zless,
+            ZB_fillTriangleMappingPerspective_xx_zoff_noblend_amore_zless },
+          { ZB_fillTriangleFlat_xx_zoff_noblend_amore_zless,
+            ZB_fillTriangleMappingFlat_xx_zoff_noblend_amore_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_amore_zless },
+          { ZB_fillTriangleSmooth_xx_zoff_noblend_amore_zless,
+            ZB_fillTriangleMappingSmooth_xx_zoff_noblend_amore_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_amore_zless },
+        },
+      },
+    },
+    { // color write blend
+      { // alpha test anone
+        {
+          { ZB_fillTriangleFlat_xx_zoff_blend_anone_znone,
+            ZB_fillTriangleMapping_xx_zoff_blend_anone_znone,
+            ZB_fillTriangleMappingPerspective_xx_zoff_blend_anone_znone },
+          { ZB_fillTriangleFlat_xx_zoff_blend_anone_znone,
+            ZB_fillTriangleMappingFlat_xx_zoff_blend_anone_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_anone_znone },
+          { ZB_fillTriangleSmooth_xx_zoff_blend_anone_znone,
+            ZB_fillTriangleMappingSmooth_xx_zoff_blend_anone_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_anone_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zoff_blend_anone_zless,
+            ZB_fillTriangleMapping_xx_zoff_blend_anone_zless,
+            ZB_fillTriangleMappingPerspective_xx_zoff_blend_anone_zless },
+          { ZB_fillTriangleFlat_xx_zoff_blend_anone_zless,
+            ZB_fillTriangleMappingFlat_xx_zoff_blend_anone_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_anone_zless },
+          { ZB_fillTriangleSmooth_xx_zoff_blend_anone_zless,
+            ZB_fillTriangleMappingSmooth_xx_zoff_blend_anone_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_anone_zless },
+        },
+      },
+      { // alpha test aless
+        {
+          { ZB_fillTriangleFlat_xx_zoff_blend_aless_znone,
+            ZB_fillTriangleMapping_xx_zoff_blend_aless_znone,
+            ZB_fillTriangleMappingPerspective_xx_zoff_blend_aless_znone },
+          { ZB_fillTriangleFlat_xx_zoff_blend_aless_znone,
+            ZB_fillTriangleMappingFlat_xx_zoff_blend_aless_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_aless_znone },
+          { ZB_fillTriangleSmooth_xx_zoff_blend_aless_znone,
+            ZB_fillTriangleMappingSmooth_xx_zoff_blend_aless_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_aless_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zoff_blend_aless_zless,
+            ZB_fillTriangleMapping_xx_zoff_blend_aless_zless,
+            ZB_fillTriangleMappingPerspective_xx_zoff_blend_aless_zless },
+          { ZB_fillTriangleFlat_xx_zoff_blend_aless_zless,
+            ZB_fillTriangleMappingFlat_xx_zoff_blend_aless_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_aless_zless },
+          { ZB_fillTriangleSmooth_xx_zoff_blend_aless_zless,
+            ZB_fillTriangleMappingSmooth_xx_zoff_blend_aless_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_aless_zless },
+        },
+      },
+      { // alpha test amore
+        {
+          { ZB_fillTriangleFlat_xx_zoff_blend_amore_znone,
+            ZB_fillTriangleMapping_xx_zoff_blend_amore_znone,
+            ZB_fillTriangleMappingPerspective_xx_zoff_blend_amore_znone },
+          { ZB_fillTriangleFlat_xx_zoff_blend_amore_znone,
+            ZB_fillTriangleMappingFlat_xx_zoff_blend_amore_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_amore_znone },
+          { ZB_fillTriangleSmooth_xx_zoff_blend_amore_znone,
+            ZB_fillTriangleMappingSmooth_xx_zoff_blend_amore_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_amore_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zoff_blend_amore_zless,
+            ZB_fillTriangleMapping_xx_zoff_blend_amore_zless,
+            ZB_fillTriangleMappingPerspective_xx_zoff_blend_amore_zless },
+          { ZB_fillTriangleFlat_xx_zoff_blend_amore_zless,
+            ZB_fillTriangleMappingFlat_xx_zoff_blend_amore_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_amore_zless },
+          { ZB_fillTriangleSmooth_xx_zoff_blend_amore_zless,
+            ZB_fillTriangleMappingSmooth_xx_zoff_blend_amore_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_amore_zless },
+        },
+      },
     },
     },
-    {
-      { ZB_fillTriangleFlat_abin_zless,
-        ZB_fillTriangleMapping_abin_zless,
-        ZB_fillTriangleMappingPerspective_abin_zless },
-      { ZB_fillTriangleFlat_abin_zless,
-        ZB_fillTriangleMappingFlat_abin_zless,
-        ZB_fillTriangleMappingPerspectiveFlat_abin_zless },
-      { ZB_fillTriangleSmooth_abin_zless,
-        ZB_fillTriangleMappingSmooth_abin_zless,
-        ZB_fillTriangleMappingPerspectiveSmooth_abin_zless },
+    { // color write nocolor
+      { // alpha test anone
+        {
+          { ZB_fillTriangleFlat_xx_zoff_nocolor_anone_znone,
+            ZB_fillTriangleMapping_xx_zoff_nocolor_anone_znone,
+            ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_anone_znone },
+          { ZB_fillTriangleFlat_xx_zoff_nocolor_anone_znone,
+            ZB_fillTriangleMappingFlat_xx_zoff_nocolor_anone_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_anone_znone },
+          { ZB_fillTriangleSmooth_xx_zoff_nocolor_anone_znone,
+            ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_anone_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_anone_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zoff_nocolor_anone_zless,
+            ZB_fillTriangleMapping_xx_zoff_nocolor_anone_zless,
+            ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_anone_zless },
+          { ZB_fillTriangleFlat_xx_zoff_nocolor_anone_zless,
+            ZB_fillTriangleMappingFlat_xx_zoff_nocolor_anone_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_anone_zless },
+          { ZB_fillTriangleSmooth_xx_zoff_nocolor_anone_zless,
+            ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_anone_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_anone_zless },
+        },
+      },
+      { // alpha test aless
+        {
+          { ZB_fillTriangleFlat_xx_zoff_nocolor_aless_znone,
+            ZB_fillTriangleMapping_xx_zoff_nocolor_aless_znone,
+            ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_aless_znone },
+          { ZB_fillTriangleFlat_xx_zoff_nocolor_aless_znone,
+            ZB_fillTriangleMappingFlat_xx_zoff_nocolor_aless_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_aless_znone },
+          { ZB_fillTriangleSmooth_xx_zoff_nocolor_aless_znone,
+            ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_aless_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_aless_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zoff_nocolor_aless_zless,
+            ZB_fillTriangleMapping_xx_zoff_nocolor_aless_zless,
+            ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_aless_zless },
+          { ZB_fillTriangleFlat_xx_zoff_nocolor_aless_zless,
+            ZB_fillTriangleMappingFlat_xx_zoff_nocolor_aless_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_aless_zless },
+          { ZB_fillTriangleSmooth_xx_zoff_nocolor_aless_zless,
+            ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_aless_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_aless_zless },
+        },
+      },
+      { // alpha test amore
+        {
+          { ZB_fillTriangleFlat_xx_zoff_nocolor_amore_znone,
+            ZB_fillTriangleMapping_xx_zoff_nocolor_amore_znone,
+            ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_amore_znone },
+          { ZB_fillTriangleFlat_xx_zoff_nocolor_amore_znone,
+            ZB_fillTriangleMappingFlat_xx_zoff_nocolor_amore_znone,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_amore_znone },
+          { ZB_fillTriangleSmooth_xx_zoff_nocolor_amore_znone,
+            ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_amore_znone,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_amore_znone },
+        },
+        {
+          { ZB_fillTriangleFlat_xx_zoff_nocolor_amore_zless,
+            ZB_fillTriangleMapping_xx_zoff_nocolor_amore_zless,
+            ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_amore_zless },
+          { ZB_fillTriangleFlat_xx_zoff_nocolor_amore_zless,
+            ZB_fillTriangleMappingFlat_xx_zoff_nocolor_amore_zless,
+            ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_amore_zless },
+          { ZB_fillTriangleSmooth_xx_zoff_nocolor_amore_zless,
+            ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_amore_zless,
+            ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_amore_zless },
+        },
+      },
     },
     },
   },
   },
 };
 };
@@ -225,6 +627,19 @@ free_pointers() {
   _vertices_size = 0;
   _vertices_size = 0;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: TinyGraphicsStateGuardian::depth_offset_decals
+//       Access: Public, Virtual
+//  Description: Returns true if this GSG can implement decals using a
+//               DepthOffsetAttrib, or false if that is unreliable
+//               and the three-step rendering process should be used
+//               instead.
+////////////////////////////////////////////////////////////////////
+bool TinyGraphicsStateGuardian::
+depth_offset_decals() {
+  return false;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: TinyGraphicsStateGuardian::make_geom_munger
 //     Function: TinyGraphicsStateGuardian::make_geom_munger
 //       Access: Public, Virtual
 //       Access: Public, Virtual
@@ -680,9 +1095,49 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
   // Set up the appropriate function callback for filling triangles,
   // Set up the appropriate function callback for filling triangles,
   // according to the current state.
   // according to the current state.
 
 
+  int depth_write_state = 0;
+  if (_target._depth_write->get_mode() != DepthWriteAttrib::M_on) {
+    depth_write_state = 1;
+  }
+
+  int color_write_state = 0;
+  switch (_target._transparency->get_mode()) {
+  case TransparencyAttrib::M_alpha:
+  case TransparencyAttrib::M_dual:
+    color_write_state = 1;
+    break;
+
+  default:
+    break;
+  }
+
+  unsigned int color_channels =
+    _target._color_write->get_channels() & _color_write_mask;
+  if (color_channels == ColorWriteAttrib::C_off) {
+    color_write_state = 2;
+  }
+
   int alpha_test_state = 0;
   int alpha_test_state = 0;
-  if (_target._transparency->get_mode() != TransparencyAttrib::M_none) {
+  switch (_target._alpha_test->get_mode()) {
+  case AlphaTestAttrib::M_none:
+  case AlphaTestAttrib::M_never:
+  case AlphaTestAttrib::M_always:
+  case AlphaTestAttrib::M_equal:
+  case AlphaTestAttrib::M_not_equal:
+    alpha_test_state = 0;
+    break;
+
+  case AlphaTestAttrib::M_less:
+  case AlphaTestAttrib::M_less_equal:
     alpha_test_state = 1;
     alpha_test_state = 1;
+    _c->zb->reference_alpha = (unsigned int)_target._alpha_test->get_reference_alpha() * 0xff00;
+    break;
+
+  case AlphaTestAttrib::M_greater:
+  case AlphaTestAttrib::M_greater_equal:
+    alpha_test_state = 2;
+    _c->zb->reference_alpha = (unsigned int)_target._alpha_test->get_reference_alpha() * 0xff00;
+    break;
   }
   }
 
 
   int depth_test_state = 1;
   int depth_test_state = 1;
@@ -715,7 +1170,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
     }
     }
   }
   }
 
 
-  _c->zb_fill_tri = fill_tri_funcs[alpha_test_state][depth_test_state][color_state][texture_state];
+  _c->zb_fill_tri = fill_tri_funcs[depth_write_state][color_write_state][alpha_test_state][depth_test_state][color_state][texture_state];
   //_c->zb_fill_tri = ZB_fillTriangleFlat_zless;
   //_c->zb_fill_tri = ZB_fillTriangleFlat_zless;
   
   
   return true;
   return true;

+ 2 - 0
panda/src/tinydisplay/tinyGraphicsStateGuardian.h

@@ -50,6 +50,8 @@ public:
   virtual void reset();
   virtual void reset();
   virtual void free_pointers();
   virtual void free_pointers();
 
 
+  virtual bool depth_offset_decals();
+
   virtual PT(GeomMunger) make_geom_munger(const RenderState *state,
   virtual PT(GeomMunger) make_geom_munger(const RenderState *state,
                                           Thread *current_thread);
                                           Thread *current_thread);
 
 

+ 649 - 32
panda/src/tinydisplay/zbuffer.h

@@ -49,6 +49,14 @@ typedef unsigned int PIXEL;
                (PIXEL_G(p1) * PIXEL_G(p2)) >> 16, \
                (PIXEL_G(p1) * PIXEL_G(p2)) >> 16, \
                (PIXEL_B(p1) * PIXEL_B(p2)) >> 16)
                (PIXEL_B(p1) * PIXEL_B(p2)) >> 16)
 
 
+#define PIXEL_BLEND(r1, g1, b1, r2, g2, b2, a2) \
+  RGBA_TO_PIXEL(((r1) * (0xff00 - (a2)) + (r2) * (a2)) >> 16,   \
+                ((g1) * (0xff00 - (a2)) + (g2) * (a2)) >> 16,   \
+                ((b1) * (0xff00 - (a2)) + (b2) * (a2)) >> 16,   \
+                a2)
+#define PIXEL_BLEND_RGB(rgb, r, g, b, a) \
+  PIXEL_BLEND(PIXEL_R(rgb), PIXEL_G(rgb), PIXEL_B(rgb), r, g, b, a)
+
 
 
 typedef struct {
 typedef struct {
     int xsize,ysize;
     int xsize,ysize;
@@ -63,6 +71,7 @@ typedef struct {
     unsigned char *dctable;
     unsigned char *dctable;
     int *ctable;
     int *ctable;
     PIXEL *current_texture;
     PIXEL *current_texture;
+    unsigned int reference_alpha;
 } ZBuffer;
 } ZBuffer;
 
 
 typedef struct {
 typedef struct {
@@ -106,80 +115,688 @@ void ZB_line_z(ZBuffer * zb, ZBufferPoint * p1, ZBufferPoint * p2);
 
 
 /* ztriangle.c */
 /* ztriangle.c */
 
 
-void ZB_fillTriangleFlat_anone_znone(ZBuffer *zb,
+void ZB_fillTriangleFlat_xx_zon_noblend_anone_znone(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_noblend_anone_znone(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_noblend_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_noblend_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_noblend_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_noblend_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zon_noblend_anone_zless(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_noblend_anone_zless(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_noblend_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_noblend_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_noblend_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_noblend_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zon_noblend_aless_znone(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_noblend_aless_znone(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_noblend_aless_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_noblend_aless_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_noblend_aless_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_noblend_aless_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_aless_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_aless_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zon_noblend_aless_zless(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_noblend_aless_zless(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_noblend_aless_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_noblend_aless_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_noblend_aless_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_noblend_aless_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_aless_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_aless_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zon_noblend_amore_znone(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_noblend_amore_znone(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_noblend_amore_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_noblend_amore_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_noblend_amore_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_noblend_amore_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_amore_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_amore_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zon_noblend_amore_zless(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_noblend_amore_zless(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_noblend_amore_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_noblend_amore_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_noblend_amore_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_noblend_amore_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_noblend_amore_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_noblend_amore_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zon_blend_anone_znone(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_blend_anone_znone(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_blend_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_blend_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_blend_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_blend_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zon_blend_anone_zless(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_blend_anone_zless(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_blend_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_blend_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_blend_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_blend_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zon_blend_aless_znone(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_blend_aless_znone(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_blend_aless_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_blend_aless_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_blend_aless_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_blend_aless_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_aless_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_aless_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zon_blend_aless_zless(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_blend_aless_zless(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_blend_aless_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_blend_aless_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_blend_aless_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_blend_aless_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_aless_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_aless_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zon_blend_amore_znone(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_blend_amore_znone(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_blend_amore_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_blend_amore_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_blend_amore_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_blend_amore_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_amore_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_amore_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zon_blend_amore_zless(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_blend_amore_zless(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_blend_amore_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_blend_amore_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_blend_amore_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_blend_amore_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_blend_amore_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_blend_amore_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zon_nocolor_anone_znone(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_nocolor_anone_znone(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_nocolor_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_nocolor_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_nocolor_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_nocolor_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zon_nocolor_anone_zless(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_nocolor_anone_zless(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_nocolor_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_nocolor_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_nocolor_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_nocolor_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zon_nocolor_aless_znone(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_nocolor_aless_znone(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_nocolor_aless_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_nocolor_aless_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_nocolor_aless_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_nocolor_aless_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_aless_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_aless_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zon_nocolor_aless_zless(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_nocolor_aless_zless(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_nocolor_aless_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_nocolor_aless_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_nocolor_aless_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_nocolor_aless_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_aless_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_aless_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zon_nocolor_amore_znone(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_nocolor_amore_znone(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_nocolor_amore_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_nocolor_amore_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_nocolor_amore_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_nocolor_amore_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_amore_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_amore_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zon_nocolor_amore_zless(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zon_nocolor_amore_zless(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zon_nocolor_amore_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zon_nocolor_amore_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zon_nocolor_amore_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zon_nocolor_amore_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zon_nocolor_amore_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zon_nocolor_amore_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zoff_noblend_anone_znone(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zoff_noblend_anone_znone(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zoff_noblend_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zoff_noblend_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zoff_noblend_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zoff_noblend_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zoff_noblend_anone_zless(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zoff_noblend_anone_zless(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zoff_noblend_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zoff_noblend_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zoff_noblend_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zoff_noblend_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zoff_noblend_aless_znone(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zoff_noblend_aless_znone(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zoff_noblend_aless_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zoff_noblend_aless_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zoff_noblend_aless_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zoff_noblend_aless_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_aless_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_aless_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zoff_noblend_aless_zless(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zoff_noblend_aless_zless(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zoff_noblend_aless_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zoff_noblend_aless_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zoff_noblend_aless_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zoff_noblend_aless_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_aless_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_aless_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zoff_noblend_amore_znone(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zoff_noblend_amore_znone(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zoff_noblend_amore_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zoff_noblend_amore_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zoff_noblend_amore_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zoff_noblend_amore_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_amore_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_amore_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zoff_noblend_amore_zless(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zoff_noblend_amore_zless(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zoff_noblend_amore_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zoff_noblend_amore_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zoff_noblend_amore_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zoff_noblend_amore_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_noblend_amore_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_noblend_amore_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zoff_blend_anone_znone(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zoff_blend_anone_znone(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zoff_blend_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zoff_blend_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zoff_blend_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zoff_blend_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zoff_blend_anone_zless(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zoff_blend_anone_zless(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zoff_blend_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zoff_blend_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zoff_blend_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zoff_blend_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zoff_blend_aless_znone(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zoff_blend_aless_znone(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zoff_blend_aless_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zoff_blend_aless_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zoff_blend_aless_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zoff_blend_aless_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_aless_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_aless_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zoff_blend_aless_zless(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zoff_blend_aless_zless(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zoff_blend_aless_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zoff_blend_aless_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zoff_blend_aless_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zoff_blend_aless_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_aless_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_aless_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zoff_blend_amore_znone(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zoff_blend_amore_znone(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zoff_blend_amore_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zoff_blend_amore_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zoff_blend_amore_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zoff_blend_amore_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_amore_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_amore_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zoff_blend_amore_zless(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zoff_blend_amore_zless(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zoff_blend_amore_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zoff_blend_amore_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zoff_blend_amore_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zoff_blend_amore_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_blend_amore_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_blend_amore_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zoff_nocolor_anone_znone(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zoff_nocolor_anone_znone(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zoff_nocolor_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zoff_nocolor_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_anone_znone(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_anone_znone(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zoff_nocolor_anone_zless(ZBuffer *zb,
+		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleSmooth_xx_zoff_nocolor_anone_zless(ZBuffer *zb,
+		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMapping_xx_zoff_nocolor_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingFlat_xx_zoff_nocolor_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+void ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_anone_zless(ZBuffer *zb,
+		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
+
+void ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_anone_zless(ZBuffer *zb,
+                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
+
+void ZB_fillTriangleFlat_xx_zoff_nocolor_aless_znone(ZBuffer *zb,
 		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
-void ZB_fillTriangleSmooth_anone_znone(ZBuffer *zb,
+void ZB_fillTriangleSmooth_xx_zoff_nocolor_aless_znone(ZBuffer *zb,
 		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 
 
-void ZB_fillTriangleMapping_anone_znone(ZBuffer *zb,
+void ZB_fillTriangleMapping_xx_zoff_nocolor_aless_znone(ZBuffer *zb,
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
-void ZB_fillTriangleMappingFlat_anone_znone(ZBuffer *zb,
+void ZB_fillTriangleMappingFlat_xx_zoff_nocolor_aless_znone(ZBuffer *zb,
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
-void ZB_fillTriangleMappingSmooth_anone_znone(ZBuffer *zb,
+void ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_aless_znone(ZBuffer *zb,
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 
 
-void ZB_fillTriangleMappingPerspective_anone_znone(ZBuffer *zb,
+void ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_aless_znone(ZBuffer *zb,
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
-void ZB_fillTriangleMappingPerspectiveFlat_anone_znone(ZBuffer *zb,
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_aless_znone(ZBuffer *zb,
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
-void ZB_fillTriangleMappingPerspectiveSmooth_anone_znone(ZBuffer *zb,
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_aless_znone(ZBuffer *zb,
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
 
 
-void ZB_fillTriangleFlat_anone_zless(ZBuffer *zb,
+void ZB_fillTriangleFlat_xx_zoff_nocolor_aless_zless(ZBuffer *zb,
 		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
-void ZB_fillTriangleSmooth_anone_zless(ZBuffer *zb,
+void ZB_fillTriangleSmooth_xx_zoff_nocolor_aless_zless(ZBuffer *zb,
 		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 
 
-void ZB_fillTriangleMapping_anone_zless(ZBuffer *zb,
+void ZB_fillTriangleMapping_xx_zoff_nocolor_aless_zless(ZBuffer *zb,
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
-void ZB_fillTriangleMappingFlat_anone_zless(ZBuffer *zb,
+void ZB_fillTriangleMappingFlat_xx_zoff_nocolor_aless_zless(ZBuffer *zb,
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
-void ZB_fillTriangleMappingSmooth_anone_zless(ZBuffer *zb,
+void ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_aless_zless(ZBuffer *zb,
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 
 
-void ZB_fillTriangleMappingPerspective_anone_zless(ZBuffer *zb,
+void ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_aless_zless(ZBuffer *zb,
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
-void ZB_fillTriangleMappingPerspectiveFlat_anone_zless(ZBuffer *zb,
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_aless_zless(ZBuffer *zb,
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
-void ZB_fillTriangleMappingPerspectiveSmooth_anone_zless(ZBuffer *zb,
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_aless_zless(ZBuffer *zb,
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
 
 
-void ZB_fillTriangleFlat_abin_znone(ZBuffer *zb,
+void ZB_fillTriangleFlat_xx_zoff_nocolor_amore_znone(ZBuffer *zb,
 		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
-void ZB_fillTriangleSmooth_abin_znone(ZBuffer *zb,
+void ZB_fillTriangleSmooth_xx_zoff_nocolor_amore_znone(ZBuffer *zb,
 		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 
 
-void ZB_fillTriangleMapping_abin_znone(ZBuffer *zb,
+void ZB_fillTriangleMapping_xx_zoff_nocolor_amore_znone(ZBuffer *zb,
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
-void ZB_fillTriangleMappingFlat_abin_znone(ZBuffer *zb,
+void ZB_fillTriangleMappingFlat_xx_zoff_nocolor_amore_znone(ZBuffer *zb,
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
-void ZB_fillTriangleMappingSmooth_abin_znone(ZBuffer *zb,
+void ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_amore_znone(ZBuffer *zb,
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 
 
-void ZB_fillTriangleMappingPerspective_abin_znone(ZBuffer *zb,
+void ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_amore_znone(ZBuffer *zb,
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
-void ZB_fillTriangleMappingPerspectiveFlat_abin_znone(ZBuffer *zb,
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_amore_znone(ZBuffer *zb,
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
-void ZB_fillTriangleMappingPerspectiveSmooth_abin_znone(ZBuffer *zb,
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_amore_znone(ZBuffer *zb,
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
 
 
-void ZB_fillTriangleFlat_abin_zless(ZBuffer *zb,
+void ZB_fillTriangleFlat_xx_zoff_nocolor_amore_zless(ZBuffer *zb,
 		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		 ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
-void ZB_fillTriangleSmooth_abin_zless(ZBuffer *zb,
+void ZB_fillTriangleSmooth_xx_zoff_nocolor_amore_zless(ZBuffer *zb,
 		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		   ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 
 
-void ZB_fillTriangleMapping_abin_zless(ZBuffer *zb,
+void ZB_fillTriangleMapping_xx_zoff_nocolor_amore_zless(ZBuffer *zb,
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
-void ZB_fillTriangleMappingFlat_abin_zless(ZBuffer *zb,
+void ZB_fillTriangleMappingFlat_xx_zoff_nocolor_amore_zless(ZBuffer *zb,
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
-void ZB_fillTriangleMappingSmooth_abin_zless(ZBuffer *zb,
+void ZB_fillTriangleMappingSmooth_xx_zoff_nocolor_amore_zless(ZBuffer *zb,
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 		    ZBufferPoint *p1,ZBufferPoint *p2,ZBufferPoint *p3);
 
 
-void ZB_fillTriangleMappingPerspective_abin_zless(ZBuffer *zb,
+void ZB_fillTriangleMappingPerspective_xx_zoff_nocolor_amore_zless(ZBuffer *zb,
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
-void ZB_fillTriangleMappingPerspectiveFlat_abin_zless(ZBuffer *zb,
+void ZB_fillTriangleMappingPerspectiveFlat_xx_zoff_nocolor_amore_zless(ZBuffer *zb,
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
-void ZB_fillTriangleMappingPerspectiveSmooth_abin_zless(ZBuffer *zb,
+void ZB_fillTriangleMappingPerspectiveSmooth_xx_zoff_nocolor_amore_zless(ZBuffer *zb,
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2);
 
 
 
 

+ 244 - 12
panda/src/tinydisplay/ztriangle.c

@@ -2,22 +2,254 @@
 #include <stdio.h>
 #include <stdio.h>
 #include "zbuffer.h"
 #include "zbuffer.h"
 
 
-#define ACMP(a) 1
-#define ZCMP(z,zpix) 1
-#define FNAME(name) name ## _anone_znone
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
+#define ACMP(zb,a) 1
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zon_noblend_anone_znone
 #include "ztriangle_two.h"
 #include "ztriangle_two.h"
 
 
-#define ACMP(a) 1
-#define ZCMP(z,zpix) ((zpix) < (z))
-#define FNAME(name) name ## _anone_zless
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
+#define ACMP(zb,a) 1
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zon_noblend_anone_zless
 #include "ztriangle_two.h"
 #include "ztriangle_two.h"
 
 
-#define ACMP(a) ((a) > 0x8000)
-#define ZCMP(z,zpix) 1
-#define FNAME(name) name ## _abin_znone
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
+#define ACMP(zb,a) ((a) < (zb)->reference_alpha)
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zon_noblend_aless_znone
 #include "ztriangle_two.h"
 #include "ztriangle_two.h"
 
 
-#define ACMP(a) ((a) > 0x8000)
-#define ZCMP(z,zpix) ((zpix) < (z))
-#define FNAME(name) name ## _abin_zless
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
+#define ACMP(zb,a) ((a) < (zb)->reference_alpha)
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zon_noblend_aless_zless
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
+#define ACMP(zb,a) ((a) > (zb)->reference_alpha)
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zon_noblend_amore_znone
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
+#define ACMP(zb,a) ((a) > (zb)->reference_alpha)
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zon_noblend_amore_zless
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
+#define ACMP(zb,a) 1
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zon_blend_anone_znone
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
+#define ACMP(zb,a) 1
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zon_blend_anone_zless
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
+#define ACMP(zb,a) ((a) < (zb)->reference_alpha)
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zon_blend_aless_znone
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
+#define ACMP(zb,a) ((a) < (zb)->reference_alpha)
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zon_blend_aless_zless
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
+#define ACMP(zb,a) ((a) > (zb)->reference_alpha)
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zon_blend_amore_znone
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
+#define ACMP(zb,a) ((a) > (zb)->reference_alpha)
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zon_blend_amore_zless
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a)
+#define ACMP(zb,a) 1
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zon_nocolor_anone_znone
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a)
+#define ACMP(zb,a) 1
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zon_nocolor_anone_zless
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a)
+#define ACMP(zb,a) ((a) < (zb)->reference_alpha)
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zon_nocolor_aless_znone
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a)
+#define ACMP(zb,a) ((a) < (zb)->reference_alpha)
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zon_nocolor_aless_zless
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a)
+#define ACMP(zb,a) ((a) > (zb)->reference_alpha)
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zon_nocolor_amore_znone
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z) (zpix) = (z)
+#define STORE_PIX(pix, rgb, r, g, b, a)
+#define ACMP(zb,a) ((a) > (zb)->reference_alpha)
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zon_nocolor_amore_zless
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
+#define ACMP(zb,a) 1
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zoff_noblend_anone_znone
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
+#define ACMP(zb,a) 1
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zoff_noblend_anone_zless
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
+#define ACMP(zb,a) ((a) < (zb)->reference_alpha)
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zoff_noblend_aless_znone
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
+#define ACMP(zb,a) ((a) < (zb)->reference_alpha)
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zoff_noblend_aless_zless
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
+#define ACMP(zb,a) ((a) > (zb)->reference_alpha)
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zoff_noblend_amore_znone
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = (rgb)
+#define ACMP(zb,a) ((a) > (zb)->reference_alpha)
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zoff_noblend_amore_zless
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
+#define ACMP(zb,a) 1
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zoff_blend_anone_znone
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
+#define ACMP(zb,a) 1
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zoff_blend_anone_zless
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
+#define ACMP(zb,a) ((a) < (zb)->reference_alpha)
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zoff_blend_aless_znone
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
+#define ACMP(zb,a) ((a) < (zb)->reference_alpha)
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zoff_blend_aless_zless
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
+#define ACMP(zb,a) ((a) > (zb)->reference_alpha)
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zoff_blend_amore_znone
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a) (pix) = PIXEL_BLEND_RGB(pix, r, g, b, a)
+#define ACMP(zb,a) ((a) > (zb)->reference_alpha)
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zoff_blend_amore_zless
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a)
+#define ACMP(zb,a) 1
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zoff_nocolor_anone_znone
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a)
+#define ACMP(zb,a) 1
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zoff_nocolor_anone_zless
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a)
+#define ACMP(zb,a) ((a) < (zb)->reference_alpha)
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zoff_nocolor_aless_znone
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a)
+#define ACMP(zb,a) ((a) < (zb)->reference_alpha)
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zoff_nocolor_aless_zless
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a)
+#define ACMP(zb,a) ((a) > (zb)->reference_alpha)
+#define ZCMP(zpix, z) 1
+#define FNAME(name) name ## _xx_zoff_nocolor_amore_znone
+#include "ztriangle_two.h"
+
+#define STORE_Z(zpix, z)
+#define STORE_PIX(pix, rgb, r, g, b, a)
+#define ACMP(zb,a) ((a) > (zb)->reference_alpha)
+#define ZCMP(zpix, z) ((zpix) < (z))
+#define FNAME(name) name ## _xx_zoff_nocolor_amore_zless
 #include "ztriangle_two.h"
 #include "ztriangle_two.h"

+ 369 - 343
panda/src/tinydisplay/ztriangle_two.h

@@ -1,28 +1,32 @@
 void FNAME(ZB_fillTriangleFlat) (ZBuffer *zb,
 void FNAME(ZB_fillTriangleFlat) (ZBuffer *zb,
-                      ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
+                                 ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
 {
 {
-    int color;
-    int oa;
+  int color;
+  int or, og, ob, oa;
 
 
 #define INTERP_Z
 #define INTERP_Z
 
 
 #define DRAW_INIT()                                     \
 #define DRAW_INIT()                                     \
-    {                                                   \
-      if (!ACMP(p2->a)) {                               \
-        return;                                         \
-      }                                                 \
-      color=RGBA_TO_PIXEL(p2->r,p2->g,p2->b,p2->a);	\
-    }
-  
-#define PUT_PIXEL(_a)				\
-    {						\
-      zz=z >> ZB_POINT_Z_FRAC_BITS;		\
-      if (ZCMP(zz,pz[_a])) {                    \
-        pp[_a]=color;				\
-        pz[_a]=zz;				\
-      }						\
-      z+=dzdx;					\
-    }
+  {                                                     \
+    if (!ACMP(zb, p2->a)) {                             \
+      return;                                           \
+    }                                                   \
+    or = p2->r;                                         \
+    og = p2->g;                                         \
+    ob = p2->b;                                         \
+    oa = p2->a;                                         \
+    color=RGBA_TO_PIXEL(or, og, ob, oa);                \
+  }
+ 
+#define PUT_PIXEL(_a)                           \
+  {                                             \
+    zz=z >> ZB_POINT_Z_FRAC_BITS;               \
+    if (ZCMP(pz[_a], zz)) {                     \
+      STORE_PIX(pp[_a], color, or, og, ob, oa); \
+      STORE_Z(pz[_a], zz);                      \
+    }                                           \
+    z+=dzdx;                                    \
+  }
 
 
 #include "ztriangle.h"
 #include "ztriangle.h"
 }
 }
@@ -33,7 +37,7 @@ void FNAME(ZB_fillTriangleFlat) (ZBuffer *zb,
  */
  */
 
 
 void FNAME(ZB_fillTriangleSmooth) (ZBuffer *zb,
 void FNAME(ZB_fillTriangleSmooth) (ZBuffer *zb,
-			   ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
+                                   ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
 {
 {
 #define INTERP_Z
 #define INTERP_Z
 #define INTERP_RGB
 #define INTERP_RGB
@@ -42,132 +46,142 @@ void FNAME(ZB_fillTriangleSmooth) (ZBuffer *zb,
   {						\
   {						\
   }
   }
 
 
-#define PUT_PIXEL(_a)                                   \
-  {                                                     \
-    zz=z >> ZB_POINT_Z_FRAC_BITS;                       \
-    if (ZCMP(zz,pz[_a])) {				\
-      if (ACMP(oa1)) {                                  \
-        pp[_a] = RGBA_TO_PIXEL(or1, og1, ob1, oa1);     \
-        pz[_a]=zz;                                      \
-      }                                                 \
-    }                                                   \
-    z+=dzdx;                                            \
-    og1+=dgdx;                                          \
-    or1+=drdx;                                          \
-    ob1+=dbdx;                                          \
-    oa1+=dadx;                                          \
+#define PUT_PIXEL(_a)                                           \
+  {                                                             \
+    zz=z >> ZB_POINT_Z_FRAC_BITS;                               \
+    if (ZCMP(pz[_a], zz)) {                                     \
+      if (ACMP(zb, oa1)) {                                      \
+        STORE_PIX(pp[_a], RGBA_TO_PIXEL(or1, og1, ob1, oa1), or1, og1, ob1, oa1); \
+        STORE_Z(pz[_a], zz);                                    \
+      }                                                         \
+    }                                                           \
+    z+=dzdx;                                                    \
+    og1+=dgdx;                                                  \
+    or1+=drdx;                                                  \
+    ob1+=dbdx;                                                  \
+    oa1+=dadx;                                                  \
   }
   }
 
 
 #include "ztriangle.h"
 #include "ztriangle.h"
 }
 }
 
 
 void FNAME(ZB_fillTriangleMapping) (ZBuffer *zb,
 void FNAME(ZB_fillTriangleMapping) (ZBuffer *zb,
-			    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
+                                    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
 {
 {
-    PIXEL *texture;
+  PIXEL *texture;
 
 
 #define INTERP_Z
 #define INTERP_Z
 #define INTERP_ST
 #define INTERP_ST
 
 
 #define DRAW_INIT()				\
 #define DRAW_INIT()				\
-    {						\
-      texture=zb->current_texture;              \
-    }
+  {						\
+    texture=zb->current_texture;                \
+  }
 
 
 #define PUT_PIXEL(_a)                                   \
 #define PUT_PIXEL(_a)                                   \
-    {                                                   \
-      zz=z >> ZB_POINT_Z_FRAC_BITS;                     \
-      if (ZCMP(zz,pz[_a])) {				\
-        tmp=texture[((t & 0x3FC00000) | s) >> 14];      \
-        if (ACMP(PIXEL_A(tmp))) {                       \
-          pp[_a]=tmp;                                   \
-          pz[_a]=zz;                                    \
-        }                                               \
+  {                                                     \
+    zz=z >> ZB_POINT_Z_FRAC_BITS;                       \
+    if (ZCMP(pz[_a], zz)) {				\
+      tmp=texture[((t & 0x3FC00000) | s) >> 14];        \
+      if (ACMP(zb, PIXEL_A(tmp))) {                     \
+        STORE_PIX(pp[_a], tmp, PIXEL_R(tmp), PIXEL_G(tmp), PIXEL_B(tmp), PIXEL_A(tmp)); \
+        STORE_Z(pz[_a], zz);                            \
       }                                                 \
       }                                                 \
-      z+=dzdx;                                          \
-      s+=dsdx;                                          \
-      t+=dtdx;                                          \
-    }
+    }                                                   \
+    z+=dzdx;                                            \
+    s+=dsdx;                                            \
+    t+=dtdx;                                            \
+  }
 
 
 #include "ztriangle.h"
 #include "ztriangle.h"
 }
 }
 
 
 void FNAME(ZB_fillTriangleMappingFlat) (ZBuffer *zb,
 void FNAME(ZB_fillTriangleMappingFlat) (ZBuffer *zb,
-			    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
+                                        ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
 {
 {
-    PIXEL *texture;
-    int or, og, ob, oa;
+  PIXEL *texture;
+  int or, og, ob, oa;
 
 
 #define INTERP_Z
 #define INTERP_Z
 #define INTERP_ST
 #define INTERP_ST
 
 
 #define DRAW_INIT()				\
 #define DRAW_INIT()				\
-    {						\
-      texture=zb->current_texture;              \
-      or = p2->r;                               \
-      og = p2->g;                               \
-      ob = p2->b;                               \
-      oa = p2->a;                               \
-    }
+  {						\
+    texture=zb->current_texture;                \
+    or = p2->r;                                 \
+    og = p2->g;                                 \
+    ob = p2->b;                                 \
+    oa = p2->a;                                 \
+  }
 
 
-#define PUT_PIXEL(_a)                                           \
-    {                                                           \
-      zz=z >> ZB_POINT_Z_FRAC_BITS;                             \
-      if (ZCMP(zz,pz[_a])) {                                    \
-        tmp=texture[((t & 0x3FC00000) | s) >> 14];              \
-        int a = oa * PIXEL_A(tmp) >> 16;                        \
-        if (ACMP(a)) {                                          \
-          pp[_a] = RGBA_TO_PIXEL(or * PIXEL_R(tmp) >> 16,       \
-                                 og * PIXEL_G(tmp) >> 16,       \
-                                 ob * PIXEL_B(tmp) >> 16,       \
-                                 a);                            \
-          pz[_a]=zz;                                            \
-        }                                                       \
-      }                                                         \
-      z+=dzdx;                                                  \
-      s+=dsdx;                                                  \
-      t+=dtdx;                                                  \
-    }
+#define PUT_PIXEL(_a)                                                   \
+  {                                                                     \
+    zz=z >> ZB_POINT_Z_FRAC_BITS;                                       \
+    if (ZCMP(pz[_a], zz)) {                                             \
+      tmp=texture[((t & 0x3FC00000) | s) >> 14];                        \
+      int a = oa * PIXEL_A(tmp) >> 16;                                  \
+      if (ACMP(zb, a)) {                                                \
+        STORE_PIX(pp[_a],                                               \
+                  RGBA_TO_PIXEL(or * PIXEL_R(tmp) >> 16,                \
+                                og * PIXEL_G(tmp) >> 16,                \
+                                ob * PIXEL_B(tmp) >> 16,                \
+                                a),                                     \
+                  or * PIXEL_R(tmp) >> 16,                              \
+                  og * PIXEL_G(tmp) >> 16,                              \
+                  ob * PIXEL_B(tmp) >> 16,                              \
+                  a);                                                   \
+        STORE_Z(pz[_a], zz);                                            \
+      }                                                                 \
+    }                                                                   \
+    z+=dzdx;                                                            \
+    s+=dsdx;                                                            \
+    t+=dtdx;                                                            \
+  }
 
 
 #include "ztriangle.h"
 #include "ztriangle.h"
 }
 }
 
 
 void FNAME(ZB_fillTriangleMappingSmooth) (ZBuffer *zb,
 void FNAME(ZB_fillTriangleMappingSmooth) (ZBuffer *zb,
-			    ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
+                                          ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
 {
 {
-    PIXEL *texture;
+  PIXEL *texture;
 
 
 #define INTERP_Z
 #define INTERP_Z
 #define INTERP_ST
 #define INTERP_ST
 #define INTERP_RGB
 #define INTERP_RGB
 
 
 #define DRAW_INIT()				\
 #define DRAW_INIT()				\
-    {						\
-      texture=zb->current_texture;              \
-    }
+  {						\
+    texture=zb->current_texture;                \
+  }
 
 
-#define PUT_PIXEL(_a)                                           \
-    {                                                           \
-      zz=z >> ZB_POINT_Z_FRAC_BITS;                             \
-      if (ZCMP(zz,pz[_a])) {                                    \
-        tmp=texture[((t & 0x3FC00000) | s) >> 14];              \
-        int a = oa1 * PIXEL_A(tmp) >> 16;                       \
-        if (ACMP(a)) {                                          \
-          pp[_a] = RGBA_TO_PIXEL(or1 * PIXEL_R(tmp) >> 16,      \
-                                 og1 * PIXEL_G(tmp) >> 16,      \
-                                 ob1 * PIXEL_B(tmp) >> 16,      \
-                                 a);                            \
-          pz[_a]=zz;                                            \
-        }                                                       \
-      }                                                         \
-      z+=dzdx;                                                  \
-      og1+=dgdx;                                                \
-      or1+=drdx;                                                \
-      ob1+=dbdx;                                                \
-      oa1+=dadx;                                                \
-      s+=dsdx;                                                  \
-      t+=dtdx;                                                  \
-    }
+#define PUT_PIXEL(_a)                                                   \
+  {                                                                     \
+    zz=z >> ZB_POINT_Z_FRAC_BITS;                                       \
+    if (ZCMP(pz[_a], zz)) {                                             \
+      tmp=texture[((t & 0x3FC00000) | s) >> 14];                        \
+      int a = oa1 * PIXEL_A(tmp) >> 16;                                 \
+      if (ACMP(zb, a)) {                                                \
+        STORE_PIX(pp[_a],                                               \
+                  RGBA_TO_PIXEL(or1 * PIXEL_R(tmp) >> 16,               \
+                                og1 * PIXEL_G(tmp) >> 16,               \
+                                ob1 * PIXEL_B(tmp) >> 16,               \
+                                a),                                     \
+                  or1 * PIXEL_R(tmp) >> 16,                             \
+                  og1 * PIXEL_G(tmp) >> 16,                             \
+                  ob1 * PIXEL_B(tmp) >> 16,                             \
+                  a);                                                   \
+        STORE_Z(pz[_a], zz);                                            \
+      }                                                                 \
+    }                                                                   \
+    z+=dzdx;                                                            \
+    og1+=dgdx;                                                          \
+    or1+=drdx;                                                          \
+    ob1+=dbdx;                                                          \
+    oa1+=dadx;                                                          \
+    s+=dsdx;                                                            \
+    t+=dtdx;                                                            \
+  }
 
 
 #include "ztriangle.h"
 #include "ztriangle.h"
 }
 }
@@ -178,10 +192,10 @@ void FNAME(ZB_fillTriangleMappingSmooth) (ZBuffer *zb,
  * TODO: pipeline the division
  * TODO: pipeline the division
  */
  */
 void FNAME(ZB_fillTriangleMappingPerspective) (ZBuffer *zb,
 void FNAME(ZB_fillTriangleMappingPerspective) (ZBuffer *zb,
-                            ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
+                                               ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
 {
 {
-    PIXEL *texture;
-    float fdzdx,fndzdx,ndszdx,ndtzdx;
+  PIXEL *texture;
+  float fdzdx,fndzdx,ndszdx,ndtzdx;
 
 
 #define INTERP_Z
 #define INTERP_Z
 #define INTERP_STZ
 #define INTERP_STZ
@@ -189,72 +203,47 @@ void FNAME(ZB_fillTriangleMappingPerspective) (ZBuffer *zb,
 #define NB_INTERP 8
 #define NB_INTERP 8
 
 
 #define DRAW_INIT()				\
 #define DRAW_INIT()				\
-    {						\
-      texture=zb->current_texture;              \
-      fdzdx=(float)dzdx;                        \
-      fndzdx=NB_INTERP * fdzdx;                 \
-      ndszdx=NB_INTERP * dszdx;                 \
-      ndtzdx=NB_INTERP * dtzdx;                 \
-    }
+  {						\
+    texture=zb->current_texture;                \
+    fdzdx=(float)dzdx;                          \
+    fndzdx=NB_INTERP * fdzdx;                   \
+    ndszdx=NB_INTERP * dszdx;                   \
+    ndtzdx=NB_INTERP * dtzdx;                   \
+  }
 
 
 
 
 #define PUT_PIXEL(_a)                                                   \
 #define PUT_PIXEL(_a)                                                   \
-    {                                                                   \
-      zz=z >> ZB_POINT_Z_FRAC_BITS;                                     \
-      if (ZCMP(zz,pz[_a])) {                                            \
-        tmp = *(PIXEL *)((char *)texture+                               \
-                         (((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH))); \
-        if (ACMP(PIXEL_A(tmp))) {                                       \
-          pp[_a]=tmp;                                                   \
-          pz[_a]=zz;                                                    \
-        }                                                               \
+  {                                                                     \
+    zz=z >> ZB_POINT_Z_FRAC_BITS;                                       \
+    if (ZCMP(pz[_a], zz)) {                                             \
+      tmp = *(PIXEL *)((char *)texture+                                 \
+                       (((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH))); \
+      if (ACMP(zb, PIXEL_A(tmp))) {                                     \
+        STORE_PIX(pp[_a], tmp, PIXEL_R(tmp), PIXEL_G(tmp), PIXEL_B(tmp), PIXEL_A(tmp)); \
+        STORE_Z(pz[_a], zz);                                            \
       }                                                                 \
       }                                                                 \
-      z+=dzdx;                                                          \
-      s+=dsdx;                                                          \
-      t+=dtdx;                                                          \
-    }
+    }                                                                   \
+    z+=dzdx;                                                            \
+    s+=dsdx;                                                            \
+    t+=dtdx;                                                            \
+  }
 
 
 #define DRAW_LINE()                                     \
 #define DRAW_LINE()                                     \
-    {                                                   \
-      register unsigned short *pz;                      \
-      register PIXEL *pp;                               \
-      register unsigned int s,t,z,zz;                   \
-      register int n,dsdx,dtdx;                         \
-      float sz,tz,fz,zinv;                              \
-      n=(x2>>16)-x1;                                    \
-      fz=(float)z1;                                     \
-      zinv=1.0 / fz;                                    \
-      pp=(PIXEL *)((char *)pp1 + x1 * PSZB);            \
-      pz=pz1+x1;					\
-      z=z1;						\
-      sz=sz1;                                           \
-      tz=tz1;                                           \
-      while (n>=(NB_INTERP-1)) {                        \
-        {                                               \
-          float ss,tt;                                  \
-          ss=(sz * zinv);                               \
-          tt=(tz * zinv);                               \
-          s=(int) ss;                                   \
-          t=(int) tt;                                   \
-          dsdx= (int)( (dszdx - ss*fdzdx)*zinv );       \
-          dtdx= (int)( (dtzdx - tt*fdzdx)*zinv );       \
-          fz+=fndzdx;                                   \
-          zinv=1.0 / fz;                                \
-        }                                               \
-        PUT_PIXEL(0);                                   \
-        PUT_PIXEL(1);                                   \
-        PUT_PIXEL(2);                                   \
-        PUT_PIXEL(3);                                   \
-        PUT_PIXEL(4);                                   \
-        PUT_PIXEL(5);                                   \
-        PUT_PIXEL(6);                                   \
-        PUT_PIXEL(7);                                   \
-        pz+=NB_INTERP;                                  \
-        pp=(PIXEL *)((char *)pp + NB_INTERP * PSZB);    \
-        n-=NB_INTERP;                                   \
-        sz+=ndszdx;                                     \
-        tz+=ndtzdx;                                     \
-      }                                                 \
+  {                                                     \
+    register unsigned short *pz;                        \
+    register PIXEL *pp;                                 \
+    register unsigned int s,t,z,zz;                     \
+    register int n,dsdx,dtdx;                           \
+    float sz,tz,fz,zinv;                                \
+    n=(x2>>16)-x1;                                      \
+    fz=(float)z1;                                       \
+    zinv=1.0 / fz;                                      \
+    pp=(PIXEL *)((char *)pp1 + x1 * PSZB);              \
+    pz=pz1+x1;                                          \
+    z=z1;						\
+    sz=sz1;                                             \
+    tz=tz1;                                             \
+    while (n>=(NB_INTERP-1)) {                          \
       {                                                 \
       {                                                 \
         float ss,tt;                                    \
         float ss,tt;                                    \
         ss=(sz * zinv);                                 \
         ss=(sz * zinv);                                 \
@@ -263,14 +252,39 @@ void FNAME(ZB_fillTriangleMappingPerspective) (ZBuffer *zb,
         t=(int) tt;                                     \
         t=(int) tt;                                     \
         dsdx= (int)( (dszdx - ss*fdzdx)*zinv );         \
         dsdx= (int)( (dszdx - ss*fdzdx)*zinv );         \
         dtdx= (int)( (dtzdx - tt*fdzdx)*zinv );         \
         dtdx= (int)( (dtzdx - tt*fdzdx)*zinv );         \
+        fz+=fndzdx;                                     \
+        zinv=1.0 / fz;                                  \
       }                                                 \
       }                                                 \
-      while (n>=0) {                                    \
-        PUT_PIXEL(0);                                   \
-        pz+=1;                                          \
-        pp=(PIXEL *)((char *)pp + PSZB);                \
-        n-=1;                                           \
-      }                                                 \
-    }
+      PUT_PIXEL(0);                                     \
+      PUT_PIXEL(1);                                     \
+      PUT_PIXEL(2);                                     \
+      PUT_PIXEL(3);                                     \
+      PUT_PIXEL(4);                                     \
+      PUT_PIXEL(5);                                     \
+      PUT_PIXEL(6);                                     \
+      PUT_PIXEL(7);                                     \
+      pz+=NB_INTERP;                                    \
+      pp=(PIXEL *)((char *)pp + NB_INTERP * PSZB);      \
+      n-=NB_INTERP;                                     \
+      sz+=ndszdx;                                       \
+      tz+=ndtzdx;                                       \
+    }                                                   \
+    {                                                   \
+      float ss,tt;                                      \
+      ss=(sz * zinv);                                   \
+      tt=(tz * zinv);                                   \
+      s=(int) ss;                                       \
+      t=(int) tt;                                       \
+      dsdx= (int)( (dszdx - ss*fdzdx)*zinv );           \
+      dtdx= (int)( (dtzdx - tt*fdzdx)*zinv );           \
+    }                                                   \
+    while (n>=0) {                                      \
+      PUT_PIXEL(0);                                     \
+      pz+=1;                                            \
+      pp=(PIXEL *)((char *)pp + PSZB);                  \
+      n-=1;                                             \
+    }                                                   \
+  }
   
   
 #include "ztriangle.h"
 #include "ztriangle.h"
 }
 }
@@ -280,11 +294,11 @@ void FNAME(ZB_fillTriangleMappingPerspective) (ZBuffer *zb,
  */
  */
 
 
 void FNAME(ZB_fillTriangleMappingPerspectiveFlat) (ZBuffer *zb,
 void FNAME(ZB_fillTriangleMappingPerspectiveFlat) (ZBuffer *zb,
-                                             ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
+                                                   ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
 {
 {
-    PIXEL *texture;
-    float fdzdx,fndzdx,ndszdx,ndtzdx;
-    int or, og, ob, oa;
+  PIXEL *texture;
+  float fdzdx,fndzdx,ndszdx,ndtzdx;
+  int or, og, ob, oa;
 
 
 #define INTERP_Z
 #define INTERP_Z
 #define INTERP_STZ
 #define INTERP_STZ
@@ -292,84 +306,64 @@ void FNAME(ZB_fillTriangleMappingPerspectiveFlat) (ZBuffer *zb,
 
 
 
 
 #define DRAW_INIT() 				\
 #define DRAW_INIT() 				\
-    {						\
-      texture=zb->current_texture;              \
-      fdzdx=(float)dzdx;                        \
-      fndzdx=NB_INTERP * fdzdx;                 \
-      ndszdx=NB_INTERP * dszdx;                 \
-      ndtzdx=NB_INTERP * dtzdx;                 \
-      or = p2->r;                               \
-      og = p2->g;                               \
-      ob = p2->b;                               \
-      oa = p2->a;                               \
-    }
+  {						\
+    texture=zb->current_texture;                \
+    fdzdx=(float)dzdx;                          \
+    fndzdx=NB_INTERP * fdzdx;                   \
+    ndszdx=NB_INTERP * dszdx;                   \
+    ndtzdx=NB_INTERP * dtzdx;                   \
+    or = p2->r;                                 \
+    og = p2->g;                                 \
+    ob = p2->b;                                 \
+    oa = p2->a;                                 \
+  }
 
 
 #define PUT_PIXEL(_a)                                                   \
 #define PUT_PIXEL(_a)                                                   \
-    {                                                                   \
-      zz=z >> ZB_POINT_Z_FRAC_BITS;                                     \
-      if (ZCMP(zz,pz[_a])) {                                            \
-        tmp=*(PIXEL *)((char *)texture+                                 \
-                       (((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH))); \
-        int a = oa * PIXEL_A(tmp) >> 16;                                \
-        if (ACMP(a)) {                                                  \
-          pp[_a] = RGBA_TO_PIXEL(or * PIXEL_R(tmp) >> 16,               \
-                                 og * PIXEL_G(tmp) >> 16,               \
-                                 ob * PIXEL_B(tmp) >> 16,               \
-                                 a);                                    \
-          pz[_a]=zz;                                                    \
-        }                                                               \
+  {                                                                     \
+    zz=z >> ZB_POINT_Z_FRAC_BITS;                                       \
+    if (ZCMP(pz[_a], zz)) {                                             \
+      tmp=*(PIXEL *)((char *)texture+                                   \
+                     (((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH))); \
+      int a = oa * PIXEL_A(tmp) >> 16;                                  \
+      if (ACMP(zb, a)) {                                                \
+        STORE_PIX(pp[_a],                                               \
+                  RGBA_TO_PIXEL(or * PIXEL_R(tmp) >> 16,                \
+                                og * PIXEL_G(tmp) >> 16,                \
+                                ob * PIXEL_B(tmp) >> 16,                \
+                                a),                                     \
+                  or * PIXEL_R(tmp) >> 16,                              \
+                  og * PIXEL_G(tmp) >> 16,                              \
+                  ob * PIXEL_B(tmp) >> 16,                              \
+                  a);                                                   \
+        STORE_Z(pz[_a], zz);                                            \
       }                                                                 \
       }                                                                 \
-      z+=dzdx;                                                          \
-      s+=dsdx;                                                          \
-      t+=dtdx;                                                          \
-    }
+    }                                                                   \
+    z+=dzdx;                                                            \
+    s+=dsdx;                                                            \
+    t+=dtdx;                                                            \
+  }
 
 
 #define DRAW_LINE()                                     \
 #define DRAW_LINE()                                     \
-    {                                                   \
-      register unsigned short *pz;                      \
-      register PIXEL *pp;                               \
-      register unsigned int s,t,z,zz;                   \
-      register int n,dsdx,dtdx;                         \
-      register unsigned int or1,og1,ob1,oa1;            \
-      float sz,tz,fz,zinv;                              \
-      n=(x2>>16)-x1;                                    \
-      fz=(float)z1;                                     \
-      zinv=1.0 / fz;                                    \
-      pp=(PIXEL *)((char *)pp1 + x1 * PSZB);            \
-      pz=pz1+x1;					\
-      z=z1;						\
-      sz=sz1;                                           \
-      tz=tz1;                                           \
-      or1 = r1;                                         \
-      og1 = g1;                                         \
-      ob1 = b1;                                         \
-      oa1 = a1;                                         \
-      while (n>=(NB_INTERP-1)) {                        \
-        {                                               \
-          float ss,tt;                                  \
-          ss=(sz * zinv);                               \
-          tt=(tz * zinv);                               \
-          s=(int) ss;                                   \
-          t=(int) tt;                                   \
-          dsdx= (int)( (dszdx - ss*fdzdx)*zinv );       \
-          dtdx= (int)( (dtzdx - tt*fdzdx)*zinv );       \
-          fz+=fndzdx;                                   \
-          zinv=1.0 / fz;                                \
-        }                                               \
-        PUT_PIXEL(0);                                   \
-        PUT_PIXEL(1);                                   \
-        PUT_PIXEL(2);                                   \
-        PUT_PIXEL(3);                                   \
-        PUT_PIXEL(4);                                   \
-        PUT_PIXEL(5);                                   \
-        PUT_PIXEL(6);                                   \
-        PUT_PIXEL(7);                                   \
-        pz+=NB_INTERP;                                  \
-        pp=(PIXEL *)((char *)pp + NB_INTERP * PSZB);    \
-        n-=NB_INTERP;                                   \
-        sz+=ndszdx;                                     \
-        tz+=ndtzdx;                                     \
-      }                                                 \
+  {                                                     \
+    register unsigned short *pz;                        \
+    register PIXEL *pp;                                 \
+    register unsigned int s,t,z,zz;                     \
+    register int n,dsdx,dtdx;                           \
+    register unsigned int or1,og1,ob1,oa1;              \
+    float sz,tz,fz,zinv;                                \
+    n=(x2>>16)-x1;                                      \
+    fz=(float)z1;                                       \
+    zinv=1.0 / fz;                                      \
+    pp=(PIXEL *)((char *)pp1 + x1 * PSZB);              \
+    pz=pz1+x1;                                          \
+    z=z1;						\
+    sz=sz1;                                             \
+    tz=tz1;                                             \
+    or1 = r1;                                           \
+    og1 = g1;                                           \
+    ob1 = b1;                                           \
+    oa1 = a1;                                           \
+    while (n>=(NB_INTERP-1)) {                          \
       {                                                 \
       {                                                 \
         float ss,tt;                                    \
         float ss,tt;                                    \
         ss=(sz * zinv);                                 \
         ss=(sz * zinv);                                 \
@@ -378,14 +372,39 @@ void FNAME(ZB_fillTriangleMappingPerspectiveFlat) (ZBuffer *zb,
         t=(int) tt;                                     \
         t=(int) tt;                                     \
         dsdx= (int)( (dszdx - ss*fdzdx)*zinv );         \
         dsdx= (int)( (dszdx - ss*fdzdx)*zinv );         \
         dtdx= (int)( (dtzdx - tt*fdzdx)*zinv );         \
         dtdx= (int)( (dtzdx - tt*fdzdx)*zinv );         \
+        fz+=fndzdx;                                     \
+        zinv=1.0 / fz;                                  \
       }                                                 \
       }                                                 \
-      while (n>=0) {                                    \
-        PUT_PIXEL(0);                                   \
-        pz+=1;                                          \
-        pp=(PIXEL *)((char *)pp + PSZB);                \
-        n-=1;                                           \
-      }                                                 \
-    }
+      PUT_PIXEL(0);                                     \
+      PUT_PIXEL(1);                                     \
+      PUT_PIXEL(2);                                     \
+      PUT_PIXEL(3);                                     \
+      PUT_PIXEL(4);                                     \
+      PUT_PIXEL(5);                                     \
+      PUT_PIXEL(6);                                     \
+      PUT_PIXEL(7);                                     \
+      pz+=NB_INTERP;                                    \
+      pp=(PIXEL *)((char *)pp + NB_INTERP * PSZB);      \
+      n-=NB_INTERP;                                     \
+      sz+=ndszdx;                                       \
+      tz+=ndtzdx;                                       \
+    }                                                   \
+    {                                                   \
+      float ss,tt;                                      \
+      ss=(sz * zinv);                                   \
+      tt=(tz * zinv);                                   \
+      s=(int) ss;                                       \
+      t=(int) tt;                                       \
+      dsdx= (int)( (dszdx - ss*fdzdx)*zinv );           \
+      dtdx= (int)( (dtzdx - tt*fdzdx)*zinv );           \
+    }                                                   \
+    while (n>=0) {                                      \
+      PUT_PIXEL(0);                                     \
+      pz+=1;                                            \
+      pp=(PIXEL *)((char *)pp + PSZB);                  \
+      n-=1;                                             \
+    }                                                   \
+  }
 
 
 #include "ztriangle.h"
 #include "ztriangle.h"
 }
 }
@@ -395,94 +414,74 @@ void FNAME(ZB_fillTriangleMappingPerspectiveFlat) (ZBuffer *zb,
  */
  */
 
 
 void FNAME(ZB_fillTriangleMappingPerspectiveSmooth) (ZBuffer *zb,
 void FNAME(ZB_fillTriangleMappingPerspectiveSmooth) (ZBuffer *zb,
-                                             ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
+                                                     ZBufferPoint *p0,ZBufferPoint *p1,ZBufferPoint *p2)
 {
 {
-    PIXEL *texture;
-    float fdzdx,fndzdx,ndszdx,ndtzdx;
+  PIXEL *texture;
+  float fdzdx,fndzdx,ndszdx,ndtzdx;
 
 
 #define INTERP_Z
 #define INTERP_Z
 #define INTERP_STZ
 #define INTERP_STZ
 #define INTERP_RGB
 #define INTERP_RGB
 
 
 #define DRAW_INIT() 				\
 #define DRAW_INIT() 				\
-    {						\
-      texture=zb->current_texture;              \
-      fdzdx=(float)dzdx;                        \
-      fndzdx=NB_INTERP * fdzdx;                 \
-      ndszdx=NB_INTERP * dszdx;                 \
-      ndtzdx=NB_INTERP * dtzdx;                 \
-    }
+  {						\
+    texture=zb->current_texture;                \
+    fdzdx=(float)dzdx;                          \
+    fndzdx=NB_INTERP * fdzdx;                   \
+    ndszdx=NB_INTERP * dszdx;                   \
+    ndtzdx=NB_INTERP * dtzdx;                   \
+  }
 
 
 #define PUT_PIXEL(_a)                                                   \
 #define PUT_PIXEL(_a)                                                   \
-    {                                                                   \
-      zz=z >> ZB_POINT_Z_FRAC_BITS;                                     \
-      if (ZCMP(zz,pz[_a])) {                                            \
-        tmp=*(PIXEL *)((char *)texture+                                 \
-                       (((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH))); \
-        int a = oa1 * PIXEL_A(tmp) >> 16;                               \
-        if (ACMP(a)) {                                                  \
-          pp[_a] = RGBA_TO_PIXEL(or1 * PIXEL_R(tmp) >> 16,              \
-                                 og1 * PIXEL_G(tmp) >> 16,              \
-                                 ob1 * PIXEL_B(tmp) >> 16,              \
-                                 a);                                    \
-          pz[_a]=zz;                                                    \
-        }                                                               \
+  {                                                                     \
+    zz=z >> ZB_POINT_Z_FRAC_BITS;                                       \
+    if (ZCMP(pz[_a], zz)) {                                             \
+      tmp=*(PIXEL *)((char *)texture+                                   \
+                     (((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH))); \
+      int a = oa1 * PIXEL_A(tmp) >> 16;                                 \
+      if (ACMP(zb, a)) {                                                \
+        STORE_PIX(pp[_a],                                               \
+                  RGBA_TO_PIXEL(or1 * PIXEL_R(tmp) >> 16,               \
+                                og1 * PIXEL_G(tmp) >> 16,               \
+                                ob1 * PIXEL_B(tmp) >> 16,               \
+                                a),                                     \
+                  or1 * PIXEL_R(tmp) >> 16,                             \
+                  og1 * PIXEL_G(tmp) >> 16,                             \
+                  ob1 * PIXEL_B(tmp) >> 16,                             \
+                  a);                                                   \
+        STORE_Z(pz[_a], zz);                                            \
       }                                                                 \
       }                                                                 \
-      z+=dzdx;                                                          \
-      og1+=dgdx;                                                        \
-      or1+=drdx;                                                        \
-      ob1+=dbdx;                                                        \
-      oa1+=dadx;                                                        \
-      s+=dsdx;                                                          \
-      t+=dtdx;                                                          \
-    }
+    }                                                                   \
+    z+=dzdx;                                                            \
+    og1+=dgdx;                                                          \
+    or1+=drdx;                                                          \
+    ob1+=dbdx;                                                          \
+    oa1+=dadx;                                                          \
+    s+=dsdx;                                                            \
+    t+=dtdx;                                                            \
+  }
 
 
 #define DRAW_LINE()                                     \
 #define DRAW_LINE()                                     \
-    {                                                   \
-      register unsigned short *pz;                      \
-      register PIXEL *pp;                               \
-      register unsigned int s,t,z,zz;                   \
-      register int n,dsdx,dtdx;                         \
-      register unsigned int or1,og1,ob1,oa1;            \
-      float sz,tz,fz,zinv;                              \
-      n=(x2>>16)-x1;                                    \
-      fz=(float)z1;                                     \
-      zinv=1.0 / fz;                                    \
-      pp=(PIXEL *)((char *)pp1 + x1 * PSZB);            \
-      pz=pz1+x1;					\
-      z=z1;						\
-      sz=sz1;                                           \
-      tz=tz1;                                           \
-      or1 = r1;                                         \
-      og1 = g1;                                         \
-      ob1 = b1;                                         \
-      oa1 = a1;                                         \
-      while (n>=(NB_INTERP-1)) {                        \
-        {                                               \
-          float ss,tt;                                  \
-          ss=(sz * zinv);                               \
-          tt=(tz * zinv);                               \
-          s=(int) ss;                                   \
-          t=(int) tt;                                   \
-          dsdx= (int)( (dszdx - ss*fdzdx)*zinv );       \
-          dtdx= (int)( (dtzdx - tt*fdzdx)*zinv );       \
-          fz+=fndzdx;                                   \
-          zinv=1.0 / fz;                                \
-        }                                               \
-        PUT_PIXEL(0);                                   \
-        PUT_PIXEL(1);                                   \
-        PUT_PIXEL(2);                                   \
-        PUT_PIXEL(3);                                   \
-        PUT_PIXEL(4);                                   \
-        PUT_PIXEL(5);                                   \
-        PUT_PIXEL(6);                                   \
-        PUT_PIXEL(7);                                   \
-        pz+=NB_INTERP;                                  \
-        pp=(PIXEL *)((char *)pp + NB_INTERP * PSZB);    \
-        n-=NB_INTERP;                                   \
-        sz+=ndszdx;                                     \
-        tz+=ndtzdx;                                     \
-      }                                                 \
+  {                                                     \
+    register unsigned short *pz;                        \
+    register PIXEL *pp;                                 \
+    register unsigned int s,t,z,zz;                     \
+    register int n,dsdx,dtdx;                           \
+    register unsigned int or1,og1,ob1,oa1;              \
+    float sz,tz,fz,zinv;                                \
+    n=(x2>>16)-x1;                                      \
+    fz=(float)z1;                                       \
+    zinv=1.0 / fz;                                      \
+    pp=(PIXEL *)((char *)pp1 + x1 * PSZB);              \
+    pz=pz1+x1;                                          \
+    z=z1;						\
+    sz=sz1;                                             \
+    tz=tz1;                                             \
+    or1 = r1;                                           \
+    og1 = g1;                                           \
+    ob1 = b1;                                           \
+    oa1 = a1;                                           \
+    while (n>=(NB_INTERP-1)) {                          \
       {                                                 \
       {                                                 \
         float ss,tt;                                    \
         float ss,tt;                                    \
         ss=(sz * zinv);                                 \
         ss=(sz * zinv);                                 \
@@ -491,18 +490,45 @@ void FNAME(ZB_fillTriangleMappingPerspectiveSmooth) (ZBuffer *zb,
         t=(int) tt;                                     \
         t=(int) tt;                                     \
         dsdx= (int)( (dszdx - ss*fdzdx)*zinv );         \
         dsdx= (int)( (dszdx - ss*fdzdx)*zinv );         \
         dtdx= (int)( (dtzdx - tt*fdzdx)*zinv );         \
         dtdx= (int)( (dtzdx - tt*fdzdx)*zinv );         \
+        fz+=fndzdx;                                     \
+        zinv=1.0 / fz;                                  \
       }                                                 \
       }                                                 \
-      while (n>=0) {                                    \
-        PUT_PIXEL(0);                                   \
-        pz+=1;                                          \
-        pp=(PIXEL *)((char *)pp + PSZB);                \
-        n-=1;                                           \
-      }                                                 \
-    }
+      PUT_PIXEL(0);                                     \
+      PUT_PIXEL(1);                                     \
+      PUT_PIXEL(2);                                     \
+      PUT_PIXEL(3);                                     \
+      PUT_PIXEL(4);                                     \
+      PUT_PIXEL(5);                                     \
+      PUT_PIXEL(6);                                     \
+      PUT_PIXEL(7);                                     \
+      pz+=NB_INTERP;                                    \
+      pp=(PIXEL *)((char *)pp + NB_INTERP * PSZB);      \
+      n-=NB_INTERP;                                     \
+      sz+=ndszdx;                                       \
+      tz+=ndtzdx;                                       \
+    }                                                   \
+    {                                                   \
+      float ss,tt;                                      \
+      ss=(sz * zinv);                                   \
+      tt=(tz * zinv);                                   \
+      s=(int) ss;                                       \
+      t=(int) tt;                                       \
+      dsdx= (int)( (dszdx - ss*fdzdx)*zinv );           \
+      dtdx= (int)( (dtzdx - tt*fdzdx)*zinv );           \
+    }                                                   \
+    while (n>=0) {                                      \
+      PUT_PIXEL(0);                                     \
+      pz+=1;                                            \
+      pp=(PIXEL *)((char *)pp + PSZB);                  \
+      n-=1;                                             \
+    }                                                   \
+  }
 
 
 #include "ztriangle.h"
 #include "ztriangle.h"
 }
 }
 
 
 #undef ACMP
 #undef ACMP
 #undef ZCMP
 #undef ZCMP
+#undef STORE_PIX
+#undef STORE_Z
 #undef FNAME
 #undef FNAME