Readability or whatever

This commit is contained in:
eukos 2015-07-26 00:18:05 +02:00
parent 9a3a6853b6
commit 2b87c9136e

View file

@ -28,8 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// TODO: put in span spilling to shrink list size
// !!! if this is changed, it must be changed in d_polysa.s too !!!
#define DPS_MAXSPANS MAXHEIGHT+1
// 1 extra for spanpackage that marks end
#define DPS_MAXSPANS MAXHEIGHT+1 // 1 extra for spanpackage that marks end
extern int coloredlights;
extern cvar_t *temp1;
// !!! if this is changed, it must be changed in asm_draw.h too !!!
@ -85,29 +84,29 @@ edgetable edgetables[12] = {
};
// FIXME: some of these can become statics
int a_sstepxfrac, a_tstepxfrac, r_lstepx, a_ststepxwhole;
int r_sstepx, r_tstepx, r_lstepy, r_sstepy, r_tstepy;
int r_zistepx, r_zistepy;
int r_lrstepx, r_lrstepy;
int r_lgstepx, r_lgstepy;
int r_lbstepx, r_lbstepy;
int d_aspancount, d_countextrastep;
int a_sstepxfrac, a_tstepxfrac, r_lstepx, a_ststepxwhole;
int r_sstepx, r_tstepx, r_lstepy, r_sstepy, r_tstepy;
int r_zistepx, r_zistepy;
int r_lrstepx, r_lrstepy;
int r_lgstepx, r_lgstepy;
int r_lbstepx, r_lbstepy;
int d_aspancount, d_countextrastep;
spanpackage_t *a_spans;
spanpackage_t *d_pedgespanpackage;
static int ystart;
byte *d_pdest, *d_ptex;
short *d_pz;
int d_sfrac, d_tfrac, d_light, d_zi;
int d_lightrgb[3];
int d_ptexextrastep, d_sfracextrastep;
int d_tfracextrastep, d_lightextrastep, d_pdestextrastep;
int d_lightbasestep, d_pdestbasestep, d_ptexbasestep;
int d_lightbasestepr, d_lightbasestepg, d_lightbasestepb;
int d_lightextrastepr, d_lightextrastepg, d_lightextrastepb;
int d_sfracbasestep, d_tfracbasestep;
int d_ziextrastep, d_zibasestep;
int d_pzextrastep, d_pzbasestep;
spanpackage_t *a_spans;
spanpackage_t *d_pedgespanpackage;
static int ystart;
byte *d_pdest, *d_ptex;
short *d_pz;
int d_sfrac, d_tfrac, d_light, d_zi;
int d_lightrgb[3];
int d_ptexextrastep, d_sfracextrastep;
int d_tfracextrastep, d_lightextrastep, d_pdestextrastep;
int d_lightbasestep, d_pdestbasestep, d_ptexbasestep;
int d_lightbasestepr, d_lightbasestepg, d_lightbasestepb;
int d_lightextrastepr, d_lightextrastepg, d_lightextrastepb;
int d_sfracbasestep, d_tfracbasestep;
int d_ziextrastep, d_zibasestep;
int d_pzextrastep, d_pzbasestep;
typedef struct {
int quotient;
@ -119,7 +118,7 @@ static adivtab_t adivtab[32*32] = {
};
byte *skintable[MAX_LBM_HEIGHT];
int skinwidth;
int skinwidth;
byte *skinstart;
void D_PolysetDrawSpans8 (spanpackage_t *pspanpackage);
@ -143,25 +142,17 @@ D_PolysetDraw
void D_PolysetDraw (void)
{
spanpackage_t spans[DPS_MAXSPANS + 1 +
((CACHE_SIZE - 1) / sizeof(spanpackage_t)) + 1];
// one extra because of cache line pretouching
((CACHE_SIZE - 1) / sizeof(spanpackage_t)) + 1]; // one extra because of cache line pretouching
a_spans = (spanpackage_t *)
(((long)&spans[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
if (r_affinetridesc.drawtype)
{
D_DrawSubdiv ();
}
else
{
D_DrawNonSubdiv ();
}
}
/*
================
D_PolysetDrawFinalVerts
@ -169,7 +160,7 @@ D_PolysetDrawFinalVerts
*/
void D_PolysetDrawFinalVerts (finalvert_t *fv, int numverts)
{
int i, z;
int i, z;
short *zbuf;
for (i=0 ; i<numverts ; i++, fv++)
@ -187,7 +178,7 @@ void D_PolysetDrawFinalVerts (finalvert_t *fv, int numverts)
*zbuf = z;
pix = skintable[fv->v[3]>>16][fv->v[2]>>16];
pix = ((byte *)acolormap)[pix + (fv->v[4] & 0xFF00) ]; //
pix = ((byte *)acolormap)[pix + (fv->v[4] & 0xFF00) ];
d_viewbuffer[d_scantable[fv->v[1]] + fv->v[0]] = pix;
}
@ -203,10 +194,10 @@ D_DrawSubdiv
*/
void D_DrawSubdiv (void)
{
mtriangle_t *ptri;
finalvert_t *pfv, *index0, *index1, *index2;
int i;
int lnumtriangles;
mtriangle_t *ptri;
finalvert_t *pfv, *index0, *index1, *index2;
int i;
int lnumtriangles;
pfv = r_affinetridesc.pfinalverts;
ptri = r_affinetridesc.ptriangles;
@ -322,7 +313,6 @@ void D_DrawNonSubdiv (void)
r_p2[8] = index2->v[8]; // lightb
}
if (!ptri->facesfront)
{
if (index0->flags & ALIAS_ONSEAM)
@ -334,9 +324,10 @@ void D_DrawNonSubdiv (void)
}
D_PolysetSetEdgeTable ();
if (r_filter->value)
D_RasterizeAliasPolySmooth ();
else
/* if (r_filter->value)
D_RasterizeAliasPolySmooth ();
else*/
D_RasterizeAliasPolySmooth ();
}
}
@ -434,8 +425,8 @@ D_PolysetUpdateTables
*/
void D_PolysetUpdateTables (void)
{
int i;
byte *s;
int i;
byte *s;
if (r_affinetridesc.skinwidth != skinwidth ||
r_affinetridesc.pskin != skinstart)
@ -458,7 +449,6 @@ D_PolysetScanLeftEdge
*/
void D_PolysetScanLeftEdge (int height)
{
do
{
d_pedgespanpackage->pdest = d_pdest;
@ -475,12 +465,11 @@ void D_PolysetScanLeftEdge (int height)
d_pedgespanpackage->zi = d_zi;
// leilei - colored lights on models
if (coloredlights){
d_pedgespanpackage->lightr = d_lightrgb[0];
d_pedgespanpackage->lightg = d_lightrgb[1];
d_pedgespanpackage->lightb = d_lightrgb[2];
}
if (coloredlights){
d_pedgespanpackage->lightr = d_lightrgb[0];
d_pedgespanpackage->lightg = d_lightrgb[1];
d_pedgespanpackage->lightb = d_lightrgb[2];
}
d_pedgespanpackage++;
@ -562,12 +551,11 @@ void D_PolysetScanLeftEdgeFilter (int height)
d_pedgespanpackage->zi = d_zi;
// leilei - colored lights on models
if (coloredlights){
d_pedgespanpackage->lightr = d_lightrgb[0];
d_pedgespanpackage->lightg = d_lightrgb[1];
d_pedgespanpackage->lightb = d_lightrgb[2];
}
if (coloredlights){
d_pedgespanpackage->lightr = d_lightrgb[0];
d_pedgespanpackage->lightg = d_lightrgb[1];
d_pedgespanpackage->lightb = d_lightrgb[2];
}
d_pedgespanpackage++;
@ -697,28 +685,26 @@ void D_PolysetCalcGradients (int skinwidth)
ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
if(coloredlights){
t0 = r_p0[6] - r_p2[6];
t1 = r_p1[6] - r_p2[6];
r_lrstepx = (int)
ceil((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
r_lrstepy = (int)
ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
t0 = r_p0[7] - r_p2[7];
t1 = r_p1[7] - r_p2[7];
r_lgstepx = (int)
ceil((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
r_lgstepy = (int)
ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
t0 = r_p0[8] - r_p2[8];
t1 = r_p1[8] - r_p2[8];
r_lbstepx = (int)
ceil((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
r_lbstepy = (int)
ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
t0 = r_p0[6] - r_p2[6];
t1 = r_p1[6] - r_p2[6];
r_lrstepx = (int)
ceil((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
r_lrstepy = (int)
ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
t0 = r_p0[7] - r_p2[7];
t1 = r_p1[7] - r_p2[7];
r_lgstepx = (int)
ceil((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
r_lgstepy = (int)
ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
t0 = r_p0[8] - r_p2[8];
t1 = r_p1[8] - r_p2[8];
r_lbstepx = (int)
ceil((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
r_lbstepy = (int)
ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
}
@ -743,8 +729,6 @@ void D_PolysetCalcGradients (int skinwidth)
r_zistepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) *
ystepdenominv);
#if id386broken
a_sstepxfrac = r_sstepx << 16;
a_tstepxfrac = r_tstepx << 16;
@ -756,19 +740,6 @@ void D_PolysetCalcGradients (int skinwidth)
a_ststepxwhole = skinwidth * (r_tstepx >> 16) + (r_sstepx >> 16);
}
#endif // !id386
#if 0
#endif
#if !id386broken
/*
================
D_PolysetDrawSpans8
@ -791,8 +762,6 @@ extern vec3_t colormod;
extern int hqlite;
extern int ditheredrend; // dithering
// Huge "enhanced stuff" C function for alias models
// only should be called when we need it (for effect flags, alpha, colored lighting)
// TODO: Split this into 3 functions and asm each as such:
@ -812,143 +781,142 @@ extern int ditheredrend; // dithering
// D_PolySetDrawSpans18AlphaTest
// D_PolySetDrawSpans18Alpha18
extern int kernel[2][2][2];
void D_PolysetDrawSpans8RGB_C_Filter (spanpackage_t *pspanpackage)
{
int lcount;
byte *lpdest;
byte *lpbuf;
byte *lptex;
int lsfrac, ltfrac;
int llight;
int llightrgb[3];
int colme[3];
int rgb;
int lzi;
short *lpz;
byte *lpdest;
byte *lpbuf;
byte *lptex;
int lcount;
int lsfrac, ltfrac;
int llight;
int llightrgb[3];
int colme[3];
int rgb;
int lzi;
short *lpz;
unsigned char *pix24; // leilei - colored lighting
int trans[3];
if (currententity->effects & EF_NODRAW || currententity->leifect)
if (currententity->effects & EF_NODRAW || currententity->leifect)
return; // haha don't do it
do
do{
lcount = d_aspancount - pspanpackage->count;
errorterm += erroradjustup;
if (errorterm >= 0)
{
lcount = d_aspancount - pspanpackage->count;
d_aspancount += d_countextrastep;
errorterm -= erroradjustdown;
}
else
d_aspancount += ubasestep;
errorterm += erroradjustup;
if (errorterm >= 0)
{
d_aspancount += d_countextrastep;
errorterm -= erroradjustdown;
}
else
{
d_aspancount += ubasestep;
}
if (lcount)
{
lpdest = pspanpackage->pdest;
lptex = pspanpackage->ptex;
lpz = pspanpackage->pz;
lsfrac = pspanpackage->sfrac;
ltfrac = pspanpackage->tfrac;
llight = pspanpackage->light;
lzi = pspanpackage->zi;
if (lcount)
if(coloredlights)
{
lpdest = pspanpackage->pdest;
lptex = pspanpackage->ptex;
lpz = pspanpackage->pz;
lsfrac = pspanpackage->sfrac;
ltfrac = pspanpackage->tfrac;
llight = pspanpackage->light;
lzi = pspanpackage->zi;
if(coloredlights){
llightrgb[0] = pspanpackage->lightr;
llightrgb[1] = pspanpackage->lightg;
llightrgb[2] = pspanpackage->lightb;
}
}
do
do{
if ((lzi >> 16) >= *lpz)
{
// Blending
if (gamemode == GAME_KUROK || *lptex != 255)
{
if (currententity->effects & EF_ADDITIVE)
*lpdest = addTable[((byte *)acolormap)[*lptex + (llight & 0xFF00)]][*lpdest];
else
{
if ((lzi >> 16) >= *lpz)
{
// Blending
if (gamemode == GAME_KUROK || *lptex != 255) {
if (currententity->effects & EF_ADDITIVE)
*lpdest = addTable[((byte *)acolormap)[*lptex + (llight & 0xFF00)]][*lpdest];
else{
if (coloredlights){
if (coloredlights){
if (*lptex < host_fullbrights || currententity->effects & EF_FULLBRIGHT)
{ // Preserve the fullbrights
pix24 = (unsigned char *)&d_8to24table[((byte *)acolormap)[*lptex + (8192 & 0xFF00)]];
// TODO FIXME: colored light vectors similar to dp105/q3
{
trans[0] = (pix24[0] * (16384 - llightrgb[0])) >> 15;
trans[1] = (pix24[1] * (16384 - llightrgb[1])) >> 15;
trans[2] = (pix24[2] * (16384 - llightrgb[2])) >> 15;
{ // Preserve the fullbrights
pix24 = (unsigned char *)&d_8to24table[((byte *)acolormap)[*lptex + (8192 & 0xFF00)]];
// TODO FIXME: colored light vectors similar to dp105/q3
trans[0] = (pix24[0] * (16384 - llightrgb[0])) >> 15;
trans[1] = (pix24[1] * (16384 - llightrgb[1])) >> 15;
trans[2] = (pix24[2] * (16384 - llightrgb[2])) >> 15;
if (trans[0] < 0) trans[0] = 0; if (trans[1] < 0) trans[1] = 0; if (trans[2] < 0) trans[2] = 0;
if (trans[0] > 63) trans[0] = 63; if (trans[1] > 63) trans[1] = 63; if (trans[2] > 63) trans[2] = 63;
// 18-Bit lighting - Alpha Blending
if (currententity->alpha){
if (currententity->alpha < 0.33)
*lpdest = transTable[palmap2[trans[0]][trans[1]][trans[2]]][*lpdest];
else if (currententity->alpha < 0.88)
*lpdest = transTable[*lpdest][palmap2[trans[0]][trans[1]][trans[2]]];
}
else
// 18-Bit lighting - Vanilla Blending
*lpdest = palmap2[trans[0]][trans[1]][trans[2]];
}
}
else
// 15-Bit lighting - Alpha Blending - Fullbright colors
if (currententity->alpha){
if (currententity->alpha < 0.33)
*lpdest = transTable[((byte *)acolormap)[*lptex]][*lpdest];
else if (currententity->alpha < 0.88)
*lpdest = transTable[*lpdest][((byte *)acolormap)[*lptex]];
}
else
// 15-Bit lighting - Vanilla Blending - Fullbright colors
if (*lptex > host_fullbrights && currententity->muzzlehack)
*lpdest = addTable[((byte *)acolormap)[*lptex]][*lpdest];
else
*lpdest = ((byte *)acolormap)[*lptex];
}
else
if (trans[0] < 0)
trans[0] = 0;
if (trans[1] < 0)
trans[1] = 0;
if (trans[2] < 0)
trans[2] = 0;
// 8-Bit lighting - Alpha Blending
if (currententity->alpha){
if (currententity->alpha < 0.33)
*lpdest = transTable[((byte *)acolormap)[*lptex + (llight & 0xFF00)]][*lpdest];
else if (currententity->alpha < 0.88)
*lpdest = transTable[*lpdest][((byte *)acolormap)[*lptex + (llight & 0xFF00)]];
}
else
// 8-Bit lighting - Vanilla stuff
if (currententity->effects & EF_FULLBRIGHT)
*lpdest = ((byte *)acolormap)[*lptex];
else if (*lptex > host_fullbrights && currententity->muzzlehack)
*lpdest = addTable[((byte *)acolormap)[*lptex]][*lpdest];
else
*lpdest = ((byte *)acolormap)[*lptex + (llight & 0xFF00)];
// *lpdest++ = *(lpwast + idiths + iditht * r_affinetridesc.skinwidth);
*lpz = lzi >> 16;
}
if (trans[0] > 63)
trans[0] = 63;
if (trans[1] > 63)
trans[1] = 63;
if (trans[2] > 63)
trans[2] = 63;
// 18-Bit lighting - Alpha Blending
if (currententity->alpha){
if (currententity->alpha < 0.33)
*lpdest = transTable[palmap2[trans[0]][trans[1]][trans[2]]][*lpdest];
else if (currententity->alpha < 0.88)
*lpdest = transTable[*lpdest][palmap2[trans[0]][trans[1]][trans[2]]];
}
else
// 18-Bit lighting - Vanilla Blending
*lpdest = palmap2[trans[0]][trans[1]][trans[2]];
}
else{
// 15-Bit lighting - Alpha Blending - Fullbright colors
if (currententity->alpha)
{
if (currententity->alpha < 0.33)
*lpdest = transTable[((byte *)acolormap)[*lptex]][*lpdest];
else if (currententity->alpha < 0.88)
*lpdest = transTable[*lpdest][((byte *)acolormap)[*lptex]];
}
else
{ // 15-Bit lighting - Vanilla Blending - Fullbright colors
if (*lptex > host_fullbrights && currententity->muzzlehack)
*lpdest = addTable[((byte *)acolormap)[*lptex]][*lpdest];
else
*lpdest = ((byte *)acolormap)[*lptex];
}
}
}
else
// 8-Bit lighting - Alpha Blending
if (currententity->alpha){
if (currententity->alpha < 0.33)
*lpdest = transTable[((byte *)acolormap)[*lptex + (llight & 0xFF00)]][*lpdest];
else if (currententity->alpha < 0.88)
*lpdest = transTable[*lpdest][((byte *)acolormap)[*lptex + (llight & 0xFF00)]];
}
else
// 8-Bit lighting - Vanilla stuff
if (currententity->effects & EF_FULLBRIGHT)
*lpdest = ((byte *)acolormap)[*lptex];
else if (*lptex > host_fullbrights && currententity->muzzlehack)
*lpdest = addTable[((byte *)acolormap)[*lptex]][*lpdest];
else
*lpdest = ((byte *)acolormap)[*lptex + (llight & 0xFF00)];
// *lpdest++ = *(lpwast + idiths + iditht * r_affinetridesc.skinwidth);
//
*lpz = lzi >> 16;
}
}
}
lpdest++;
lzi += r_zistepx;
lpz++;
@ -976,7 +944,7 @@ void D_PolysetDrawSpans8RGB_C_Filter (spanpackage_t *pspanpackage)
}
pspanpackage++;
} while (pspanpackage->count != -999999);
} while (pspanpackage->count != -999999);
}
@ -2499,20 +2467,23 @@ void D_RasterizeAliasPolySmooth (void)
d_countextrastep = ubasestep + 1;
originalcount = a_spans[initialrightheight].count;
a_spans[initialrightheight].count = -999999; // mark end of the spanpackages
#ifdef dithermodelhack
if (coloredlights == 2)
D_PolysetDrawSpans8_C (a_spans);
else
#endif
if (coloredlights)
if (r_filter->value)
D_PolysetDrawSpans8_C (a_spans);
else
D_PolysetDrawSpans8_C (a_spans);
else
D_PolysetDrawSpans8_C (a_spans);
//D_PolysetDrawSpans8 (a_spans);
// eukara - not sure what is going on here
#ifdef dithermodelhack
if (coloredlights == 2)
D_PolysetDrawSpans8_C (a_spans);
else
#endif
if (coloredlights)
{
if (r_filter->value)
D_PolysetDrawSpans8_C (a_spans);
else
D_PolysetDrawSpans8_C (a_spans);
}
else
D_PolysetDrawSpans8_C (a_spans);
// scan out the bottom part of the right edge, if it exists
if (pedgetable->numrightedges == 2)
@ -2534,22 +2505,23 @@ else
prightbottom[0], prightbottom[1]);
d_countextrastep = ubasestep + 1;
a_spans[initialrightheight + height].count = -999999;
// mark end of the spanpackages
#ifdef dithermodelhack
if (coloredlights == 2)
D_PolysetDrawSpans8_C (pstart);
else
#endif
if (coloredlights)
if (r_filter->value)
D_PolysetDrawSpans8_C (pstart);
a_spans[initialrightheight + height].count = -999999; // mark end of the spanpackages
#ifdef dithermodelhack
if (coloredlights == 2)
D_PolysetDrawSpans8_C (pstart);
else
D_PolysetDrawSpans8_C (pstart);
else
D_PolysetDrawSpans8_C (pstart);
#endif
if (coloredlights)
{
if (r_filter->value)
D_PolysetDrawSpans8_C (pstart);
else
D_PolysetDrawSpans8_C (pstart);
}
else
D_PolysetDrawSpans8_C (pstart);
}
}
/*
@ -2818,11 +2790,11 @@ void D_RasterizeAliasPolySmoothFilter (void)
d_countextrastep = ubasestep + 1;
originalcount = a_spans[initialrightheight].count;
a_spans[initialrightheight].count = -999999; // mark end of the spanpackages
if (coloredlights)
if (coloredlights)
D_PolysetDrawSpans8_C (a_spans);
else
else
D_PolysetDrawSpans8_C (a_spans);
//D_PolysetDrawSpans8 (a_spans);
// scan out the bottom part of the right edge, if it exists
if (pedgetable->numrightedges == 2)
@ -2846,11 +2818,10 @@ else
d_countextrastep = ubasestep + 1;
a_spans[initialrightheight + height].count = -999999;
// mark end of the spanpackages
if (coloredlights)
D_PolysetDrawSpans8_C (pstart);
else
D_PolysetDrawSpans8_C (pstart);
if (coloredlights)
D_PolysetDrawSpans8_C (pstart);
else
D_PolysetDrawSpans8_C (pstart);
// D_PolysetDrawSpans8_C (pstart);
// D_PolysetDrawSpans8_C (pstart);
@ -2993,6 +2964,3 @@ split:
D_PolysetRecursiveTriangle (new, lp2, lp3);
}
*/