projects
/
dosdemo
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
removed clang-format and clang_complete files from the repo
[dosdemo]
/
src
/
3dgfx
/
polytmpl.h
diff --git
a/src/3dgfx/polytmpl.h
b/src/3dgfx/polytmpl.h
index
2072e2b
..
f601623
100644
(file)
--- a/
src/3dgfx/polytmpl.h
+++ b/
src/3dgfx/polytmpl.h
@@
-12,6
+12,9
@@
static uint32_t SCANEDGE(struct pvertex *v0, struct pvertex *v1, struct pvertex
#ifdef TEXMAP
int32_t u, v, du, dv, uslope, vslope;
#endif
#ifdef TEXMAP
int32_t u, v, du, dv, uslope, vslope;
#endif
+#ifdef ZBUF
+ int32_t z, dz, zslope;
+#endif
int32_t start_idx, end_idx;
if(v0->y > v1->y) {
int32_t start_idx, end_idx;
if(v0->y > v1->y) {
@@
-48,6
+51,11
@@
static uint32_t SCANEDGE(struct pvertex *v0, struct pvertex *v1, struct pvertex
uslope = (du << 8) / dy;
vslope = (dv << 8) / dy;
#endif
uslope = (du << 8) / dy;
vslope = (dv << 8) / dy;
#endif
+#ifdef ZBUF
+ z = v0->z;
+ dz = v1->z - v0->z;
+ zslope = (dz << 8) / dy;
+#endif
start_idx = v0->y >> 8;
end_idx = v1->y >> 8;
start_idx = v0->y >> 8;
end_idx = v1->y >> 8;
@@
-58,7
+66,6
@@
static uint32_t SCANEDGE(struct pvertex *v0, struct pvertex *v1, struct pvertex
x += slope;
#ifdef GOURAUD
/* we'll store the color in the edge tables with COLOR_SHIFT extra bits of precision */
x += slope;
#ifdef GOURAUD
/* we'll store the color in the edge tables with COLOR_SHIFT extra bits of precision */
- CHECKEDGE(i);
edge[i].r = r;
edge[i].g = g;
edge[i].b = b;
edge[i].r = r;
edge[i].g = g;
edge[i].b = b;
@@
-66,18
+73,20
@@
static uint32_t SCANEDGE(struct pvertex *v0, struct pvertex *v1, struct pvertex
g += gslope;
b += bslope;
#ifdef BLEND_ALPHA
g += gslope;
b += bslope;
#ifdef BLEND_ALPHA
- CHECKEDGE(i);
edge[i].a = a;
a += aslope;
#endif
#endif /* GOURAUD */
#ifdef TEXMAP
edge[i].a = a;
a += aslope;
#endif
#endif /* GOURAUD */
#ifdef TEXMAP
- CHECKEDGE(i);
edge[i].u = u;
edge[i].v = v;
u += uslope;
v += vslope;
#endif
edge[i].u = u;
edge[i].v = v;
u += uslope;
v += vslope;
#endif
+#ifdef ZBUF
+ edge[i].z = z;
+ z += zslope;
+#endif
}
return (uint32_t)start_idx | ((uint32_t)(end_idx - 1) << 16);
}
return (uint32_t)start_idx | ((uint32_t)(end_idx - 1) << 16);
@@
-89,12
+98,9
@@
void POLYFILL(struct pvertex *pv, int nverts)
int topidx = 0, botidx = 0, sltop = pfill_fb.height, slbot = 0;
g3d_pixel color;
/* the following variables are used for interpolating horizontally accros scanlines */
int topidx = 0, botidx = 0, sltop = pfill_fb.height, slbot = 0;
g3d_pixel color;
/* the following variables are used for interpolating horizontally accros scanlines */
-#if defined(GOURAUD) || defined(TEXMAP)
+#if defined(GOURAUD) || defined(TEXMAP) || defined(ZBUF)
int mid;
int32_t dx, tmp;
int mid;
int32_t dx, tmp;
-#else
- /* flat version, just pack the color now */
- color = G3D_PACK_RGB(pv[0].r, pv[0].g, pv[0].b);
#endif
#ifdef GOURAUD
int32_t r, g, b, dr, dg, db, rslope, gslope, bslope;
#endif
#ifdef GOURAUD
int32_t r, g, b, dr, dg, db, rslope, gslope, bslope;
@@
-105,6
+111,14
@@
void POLYFILL(struct pvertex *pv, int nverts)
#ifdef TEXMAP
int32_t u, v, du, dv, uslope, vslope;
#endif
#ifdef TEXMAP
int32_t u, v, du, dv, uslope, vslope;
#endif
+#ifdef ZBUF
+ int32_t z, dz, zslope;
+#endif
+
+#if !defined(GOURAUD) && !defined(TEXMAP)
+ /* flat version, just pack the color now */
+ color = G3D_PACK_RGB(pv[0].r, pv[0].g, pv[0].b);
+#endif
for(i=1; i<nverts; i++) {
if(pv[i].y < pv[topidx].y) topidx = i;
for(i=1; i<nverts; i++) {
if(pv[i].y < pv[topidx].y) topidx = i;
@@
-154,6
+168,10
@@
void POLYFILL(struct pvertex *pv, int nverts)
right[idx].u = pv[i1].u;
right[idx].v = pv[i1].v;
#endif
right[idx].u = pv[i1].u;
right[idx].v = pv[i1].v;
#endif
+#ifdef ZBUF
+ left[idx].z = pv[i0].z;
+ right[idx].z = pv[i1].z;
+#endif
CHECKEDGE(idx);
if(idx > slbot) slbot = idx;
if(idx < sltop) sltop = idx;
CHECKEDGE(idx);
if(idx > slbot) slbot = idx;
if(idx < sltop) sltop = idx;
@@
-217,12
+235,19
@@
void POLYFILL(struct pvertex *pv, int nverts)
uslope = (du << 8) / dx;
vslope = (dv << 8) / dx;
#endif
uslope = (du << 8) / dx;
vslope = (dv << 8) / dx;
#endif
+#ifdef ZBUF
+ dz = right[mid].z - left[mid].z;
+ zslope = (dz << 8) / dx;
+#endif
#endif /* !defined(HIGH_QUALITY) */
/* for each scanline ... */
for(i=sltop; i<=slbot; i++) {
g3d_pixel *pixptr;
int32_t x;
#endif /* !defined(HIGH_QUALITY) */
/* for each scanline ... */
for(i=sltop; i<=slbot; i++) {
g3d_pixel *pixptr;
int32_t x;
+#ifdef ZBUF
+ uint16_t *zptr;
+#endif
CHECKEDGE(i);
x = left[i].x;
CHECKEDGE(i);
x = left[i].x;
@@
-240,9
+265,13
@@
void POLYFILL(struct pvertex *pv, int nverts)
u = left[i].u;
v = left[i].v;
#endif
u = left[i].u;
v = left[i].v;
#endif
+#ifdef ZBUF
+ z = left[i].z;
+ zptr = pfill_zbuf + i * pfill_fb.width + (x >> 8);
+#endif
CHECKEDGE(i);
CHECKEDGE(i);
-#if defined(HIGH_QUALITY) && (defined(GOURAUD) || defined(TEXMAP))
+#if defined(HIGH_QUALITY) && (defined(GOURAUD) || defined(TEXMAP) || defined(ZBUF))
if(!(dx = right[i].x - left[i].x)) dx = 256;
CHECKEDGE(i);
if(!(dx = right[i].x - left[i].x)) dx = 256;
CHECKEDGE(i);
@@
-264,11
+293,18
@@
void POLYFILL(struct pvertex *pv, int nverts)
uslope = (du << 8) / dx;
vslope = (dv << 8) / dx;
#endif
uslope = (du << 8) / dx;
vslope = (dv << 8) / dx;
#endif
+#ifdef ZBUF
+ dz = right[i].z - left[i].z;
+ zslope = (dz << 8) / dx;
+#endif
#endif /* HIGH_QUALITY */
CHECKEDGE(i);
/* go across the scanline interpolating if necessary */
while(x <= right[i].x) {
#endif /* HIGH_QUALITY */
CHECKEDGE(i);
/* go across the scanline interpolating if necessary */
while(x <= right[i].x) {
+ /*if(x == (180 << 8) && i == 174) {
+ asm("int $3");
+ }*/
#if defined(GOURAUD) || defined(TEXMAP) || defined(BLEND_ALPHA) || defined(BLEND_ADD)
int cr, cg, cb;
#endif
#if defined(GOURAUD) || defined(TEXMAP) || defined(BLEND_ALPHA) || defined(BLEND_ADD)
int cr, cg, cb;
#endif
@@
-278,6
+314,34
@@
void POLYFILL(struct pvertex *pv, int nverts)
#ifdef BLEND_ALPHA
int alpha, inv_alpha;
#endif
#ifdef BLEND_ALPHA
int alpha, inv_alpha;
#endif
+
+#ifdef ZBUF
+ int32_t cz = z;
+ z += zslope;
+
+ if(z <= *zptr) {
+ *zptr++ = z;
+ } else {
+#ifdef GOURAUD
+ r += rslope;
+ g += gslope;
+ b += bslope;
+#ifdef BLEND_ALPHA
+ a += aslope;
+#endif
+#endif
+#ifdef TEXMAP
+ u += uslope;
+ v += vslope;
+#endif
+ /* skip pixel */
+ pixptr++;
+ zptr++;
+ x += 256;
+ continue;
+ }
+#endif
+
#ifdef GOURAUD
/* we upped the color precision to while interpolating the
* edges, now drop the extra bits before packing
#ifdef GOURAUD
/* we upped the color precision to while interpolating the
* edges, now drop the extra bits before packing