From ea9c3b0360cb8af5418989f8381371aa8f6c94cb Mon Sep 17 00:00:00 2001 From: TimeServ Date: Fri, 29 Jul 2005 01:12:09 +0000 Subject: [PATCH] software transtable rewrite, sw additive support for sprites/blob particles/line particles (no models yet), AddBlend/Trans functions need optimization git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1174 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/r_part.c | 16 +- engine/client/render.h | 1 - engine/client/renderer.c | 8 - engine/common/particles.h | 2 + engine/sw/d_ifacea.h | 4 +- engine/sw/d_local.h | 36 +-- engine/sw/d_part.c | 530 +++++++++++++++++--------------------- engine/sw/d_polyse.c | 179 +------------ engine/sw/d_scan.c | 2 +- engine/sw/d_sprite.c | 24 +- engine/sw/d_trans.c | 511 +++++++++--------------------------- engine/sw/r_alias.c | 33 ++- engine/sw/r_draw.c | 2 + engine/sw/r_main.c | 2 +- engine/sw/sw_draw.c | 33 +-- 15 files changed, 437 insertions(+), 946 deletions(-) diff --git a/engine/client/r_part.c b/engine/client/r_part.c index 5a52ccbbc..dd37e85a4 100644 --- a/engine/client/r_part.c +++ b/engine/client/r_part.c @@ -81,8 +81,8 @@ static double cost[7] = {1.000000, 0.623490, -0.222521, -0.900969, -0.900969, -0 #define crand() (rand()%32767/16383.5f-1) -void D_DrawParticleTrans (particle_t *pparticle); -void D_DrawSparkTrans (particle_t *pparticle, vec3_t src, vec3_t dest); +void D_DrawParticleTrans (particle_t *pparticle, int blendmode); +void D_DrawSparkTrans (particle_t *pparticle, vec3_t src, vec3_t dest, int blendmode); void P_ReadPointFile_f (void); @@ -176,7 +176,7 @@ typedef struct part_type_s { float timelimit; enum {PT_NORMAL, PT_SPARK, PT_SPARKFAN, PT_TEXTUREDSPARK, PT_BEAM, PT_DECAL} type; - enum {BM_MERGE, BM_ADD, BM_SUBTRACT} blendmode; + blendmode_t blendmode; float rotationstartmin, rotationstartrand; float rotationmin, rotationrand; @@ -1946,7 +1946,7 @@ int P_RunParticleEffectType (vec3_t org, vec3_t dir, float count, int typenum) p->alpha = ptype->alpha-p->die*(ptype->alpha/ptype->die)*ptype->alphachange; else p->alpha = ptype->alpha; - p->color = 0; + // p->color = 0; p->nextemit = particletime + ptype->emitstart - p->die; if (ptype->emittime < 0) p->trailstate = NULL; @@ -2630,7 +2630,7 @@ int P_ParticleTrail (vec3_t startpos, vec3_t end, int type, trailstate_t **tsk) p->alpha = ptype->alpha-p->die*(ptype->alpha/ptype->die)*ptype->alphachange; else p->alpha = ptype->alpha; - p->color = 0; +// p->color = 0; // if (ptype->spawnmode == SM_TRACER) if (ptype->spawnparam1) @@ -3448,7 +3448,7 @@ void SWD_DrawParticleSpark(particle_t *p, part_type_t *type) VectorMA(p->org, -2.5/(speed), p->vel, dest); } - D_DrawSparkTrans(p, src, dest); + D_DrawSparkTrans(p, src, dest, type->blendmode); } void SWD_DrawParticleBlob(particle_t *p, part_type_t *type) { @@ -3469,7 +3469,7 @@ void SWD_DrawParticleBlob(particle_t *p, part_type_t *type) else if (b > 255) b = 255; p->color = GetPalette(r, g, b); - D_DrawParticleTrans(p); + D_DrawParticleTrans(p, type->blendmode); } void SWD_DrawParticleBeam(beamseg_t *beam, part_type_t *type) { @@ -3505,7 +3505,7 @@ void SWD_DrawParticleBeam(beamseg_t *beam, part_type_t *type) else if (b > 255) b = 255; p->color = GetPalette(r, g, b); - D_DrawSparkTrans(p, p->org, q->org ); + D_DrawSparkTrans(p, p->org, q->org, type->blendmode); } #endif diff --git a/engine/client/render.h b/engine/client/render.h index c2e82022b..bfba7b706 100644 --- a/engine/client/render.h +++ b/engine/client/render.h @@ -367,7 +367,6 @@ extern cvar_t gl_finish; extern cvar_t gl_max_size; extern cvar_t gl_playermip; -extern cvar_t r_palconvbits; extern cvar_t r_palconvwrite; extern cvar_t r_lightmap_saturation; diff --git a/engine/client/renderer.c b/engine/client/renderer.c index 10bd567f7..773cabcb3 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -184,10 +184,6 @@ cvar_t r_drawflat = {"r_drawflat","0", NULL, CVAR_SEMICHEAT}; cvar_t r_wallcolour = {"r_wallcolour","0 0 1"}; cvar_t r_floorcolour = {"r_floorcolour","0.5 0.5 1"}; -cvar_t r_transtables = {"r_transtables","2"}; -cvar_t r_transtablehalf = {"r_transtablehalf", "1"}; -cvar_t r_transtablewrite = {"r_transtablewrite", "1"}; -cvar_t r_palconvbits = {"r_palconvbits", "565"}; cvar_t r_palconvwrite = {"r_palconvwrite", "1"}; cvar_t r_lightmap_saturation = {"r_lightmap_saturation", "1"}; @@ -362,10 +358,6 @@ void SWRenderer_Init(void) Cvar_Register (&r_ambient, SWRENDEREROPTIONS); Cvar_Register (&r_reportsurfout, SWRENDEREROPTIONS); - Cvar_Register (&r_transtables, SWRENDEREROPTIONS); - Cvar_Register (&r_transtablewrite, SWRENDEREROPTIONS); - Cvar_Register (&r_transtablehalf, SWRENDEREROPTIONS); - Cvar_Register (&r_palconvbits, SWRENDEREROPTIONS); Cvar_Register (&r_palconvwrite, SWRENDEREROPTIONS); } #endif diff --git a/engine/common/particles.h b/engine/common/particles.h index 04ece5651..ccf0f559f 100644 --- a/engine/common/particles.h +++ b/engine/common/particles.h @@ -175,4 +175,6 @@ void P_EmitSkyEffectTris(struct model_s *mod, struct msurface_s *fa); // trailstate functions void P_DelinkTrailstate(trailstate_t **tsk); +typedef enum { BM_MERGE, BM_ADD, BM_SUBTRACT } blendmode_t; + #endif diff --git a/engine/sw/d_ifacea.h b/engine/sw/d_ifacea.h index a6e8a1e85..2824204fa 100644 --- a/engine/sw/d_ifacea.h +++ b/engine/sw/d_ifacea.h @@ -46,8 +46,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // particle_t structure // !!! if this is changed, it must be changed in d_iface.h too !!! // driver-usable fields -#define pt_org 0 -#define pt_color 12 +#define pt_org 8 +#define pt_color 20 // drivers never touch the following fields /*#define pt_next 16 #define pt_vel 20 diff --git a/engine/sw/d_local.h b/engine/sw/d_local.h index cd535ff3f..fe5bf096e 100644 --- a/engine/sw/d_local.h +++ b/engine/sw/d_local.h @@ -117,37 +117,19 @@ extern float d_scalemip[3]; extern void (*d_drawspans) (espan_t *pspan); - - #ifdef PEXT_TRANS -typedef qbyte tlookup[256][256]; -typedef qbyte tlookupp[256]; -extern tlookup *t_lookup; -extern tlookupp *t_curlookupp; -extern int t_numtables; -extern int t_numtablesinv;//65546/numtables -extern int t_state; +#define PAL555_SIZE 32*32*32 +#define TRANS_LEVELS 65 +#define TRANS_MAX (TRANS_LEVELS - 1) -#define TT_REVERSE 0x1 // reverse table points -#define TT_ZERO 0x2 // zero alpha -#define TT_ONE 0x4 // full alpha -#define TT_USEHALF 0x8 // using half transtables - -// cvar defines for transtable -extern cvar_t r_transtablewrite; -extern cvar_t r_transtables; -extern cvar_t r_transtablehalf; +#define TRANS_UPPER_CAP (TRANS_MAX / (TRANS_LEVELS + 0.0)) +#define TRANS_LOWER_CAP (1.0 / TRANS_LEVELS) void D_InitTrans(void); -#define Trans(p, p2) (t_curlookupp[p][p2]) // void Set_TransLevelI(int level); -void Set_TransLevelF(float level); - - - -extern qbyte *palxxxto8; -extern int palmask[3]; -extern int palshift[3]; +void D_SetTransLevel(float level, blendmode_t blend); +extern qbyte _fastcall Trans(qbyte p, qbyte p2); +extern qbyte _fastcall AddBlend(qbyte p, qbyte p2); +extern qbyte *pal555to8; #endif - diff --git a/engine/sw/d_part.c b/engine/sw/d_part.c index 70c634e12..fa7313c9a 100644 --- a/engine/sw/d_part.c +++ b/engine/sw/d_part.c @@ -359,169 +359,14 @@ void D_DrawParticle32 (particle_t *pparticle) } } -#define draw(x, y) x=Trans(x,(int)y) -#define rdraw(x, y) x=Trans((int)y,x) -void D_DrawParticleReverseTrans (particle_t *pparticle) -{ - vec3_t local, transformed; - float zi; - qbyte *pdest; - short *pz; - int i, izi, pix, count, u, v; - -// transform point - VectorSubtract (pparticle->org, r_origin, local); - - transformed[0] = DotProduct(local, r_pright); - transformed[1] = DotProduct(local, r_pup); - transformed[2] = DotProduct(local, r_ppn); - - if (transformed[2] < PARTICLE_Z_CLIP) - return; - -// project the point -// FIXME: preadjust xcenter and ycenter - zi = 1.0 / transformed[2]; - u = (int)(xcenter + zi * transformed[0] + 0.5); - v = (int)(ycenter - zi * transformed[1] + 0.5); - - if ((v > d_vrectbottom_particle) || - (u > d_vrectright_particle) || - (v < d_vrecty) || - (u < d_vrectx)) - { - return; - } - - pz = d_pzbuffer + (d_zwidth * v) + u; - izi = (int)(zi * 0x8000); - - pix = ((int)(izi*pparticle->scale)) >> d_pix_shift; - - if (pix < d_pix_min) - pix = d_pix_min; - else if (pix > d_pix_max) - pix = d_pix_max; - - u -= pix/2; - v -= pix/2; - if (u < 0) u = 0; - if (v < 0) v = 0; - pdest = d_viewbuffer + d_scantable[v] + u; - - switch (pix) - { - case 1: - count = 1 << d_y_aspect_shift; - - for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) - { - if (pz[0] <= izi) - { -// pz[0] = izi; - rdraw(pdest[0], pparticle->color); - } - } - break; - - case 2: - count = 2 << d_y_aspect_shift; - - for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) - { - if (pz[0] <= izi) - { -// pz[0] = izi; - rdraw(pdest[0], pparticle->color); - } - - if (pz[1] <= izi) - { -// pz[1] = izi; - rdraw(pdest[1], pparticle->color); - } - } - break; - - case 3: - count = 3 << d_y_aspect_shift; - - for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) - { - if (pz[0] <= izi) - { -// pz[0] = izi; - rdraw(pdest[0], pparticle->color); - } - - if (pz[1] <= izi) - { -// pz[1] = izi; - rdraw(pdest[1], pparticle->color); - } - - if (pz[2] <= izi) - { -// pz[2] = izi; - rdraw(pdest[2], pparticle->color); - } - } - break; - - case 4: - count = 4 << d_y_aspect_shift; - - for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) - { - if (pz[0] <= izi) - { -// pz[0] = izi; - rdraw(pdest[0], pparticle->color); - } - - if (pz[1] <= izi) - { -// pz[1] = izi; - rdraw(pdest[1], pparticle->color); - } - - if (pz[2] <= izi) - { -// pz[2] = izi; - rdraw(pdest[2], pparticle->color); - } - - if (pz[3] <= izi) - { -// pz[3] = izi; - rdraw(pdest[3], pparticle->color); - } - } - break; - - default: - count = pix << d_y_aspect_shift; - - for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) - { - for (i=0 ; icolor); - } - } - } - break; - } -} - -void D_DrawParticleTrans (particle_t *pparticle) +#define draw(x, y) x=Trans(x,y) +#define addblend(x, y) x=AddBlend(x,y) +void D_DrawParticleTrans (particle_t *pparticle, blendmode_t blendmode) { vec3_t local, transformed; float zi; qbyte *pdest; + qbyte pcolor; short *pz; int i, izi, pix, count, u, v; @@ -536,22 +381,18 @@ void D_DrawParticleTrans (particle_t *pparticle) return; } - Set_TransLevelF(pparticle->alpha); - - if (t_state & TT_ZERO) + if (pparticle->alpha < TRANS_LOWER_CAP) return; - - if (t_state & TT_ONE) + + if (pparticle->alpha > TRANS_UPPER_CAP && blendmode == BM_MERGE) { D_DrawParticle(pparticle); return; } - if (t_state & TT_REVERSE) - { - D_DrawParticleReverseTrans(pparticle); - return; - } + D_SetTransLevel(pparticle->alpha, blendmode); + + pcolor = pparticle->color; // transform point VectorSubtract (pparticle->org, r_origin, local); @@ -593,111 +434,223 @@ void D_DrawParticleTrans (particle_t *pparticle) if (v < 0) v = 0; pdest = d_viewbuffer + d_scantable[v] + u; - switch (pix) + if (blendmode == BM_ADD) // additive drawing { - case 1: - count = 1 << d_y_aspect_shift; - - for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) + switch (pix) { - if (pz[0] <= izi) + case 1: + count = 1 << d_y_aspect_shift; + + for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) { -// pz[0] = izi; - draw(pdest[0], pparticle->color); - } - } - break; - - case 2: - count = 2 << d_y_aspect_shift; - - for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) - { - if (pz[0] <= izi) - { -// pz[0] = izi; - draw(pdest[0], pparticle->color); - } - - if (pz[1] <= izi) - { -// pz[1] = izi; - draw(pdest[1], pparticle->color); - } - } - break; - - case 3: - count = 3 << d_y_aspect_shift; - - for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) - { - if (pz[0] <= izi) - { -// pz[0] = izi; - draw(pdest[0], pparticle->color); - } - - if (pz[1] <= izi) - { -// pz[1] = izi; - draw(pdest[1], pparticle->color); - } - - if (pz[2] <= izi) - { -// pz[2] = izi; - draw(pdest[2], pparticle->color); - } - } - break; - - case 4: - count = 4 << d_y_aspect_shift; - - for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) - { - if (pz[0] <= izi) - { -// pz[0] = izi; - draw(pdest[0], pparticle->color); - } - - if (pz[1] <= izi) - { -// pz[1] = izi; - draw(pdest[1], pparticle->color); - } - - if (pz[2] <= izi) - { -// pz[2] = izi; - draw(pdest[2], pparticle->color); - } - - if (pz[3] <= izi) - { -// pz[3] = izi; - draw(pdest[3], pparticle->color); - } - } - break; - - default: - count = pix << d_y_aspect_shift; - - for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) - { - for (i=0 ; icolor); + // pz[0] = izi; + addblend(pdest[0], pcolor); } } + break; + + case 2: + count = 2 << d_y_aspect_shift; + + for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) + { + if (pz[0] <= izi) + { + // pz[0] = izi; + addblend(pdest[0], pcolor); + } + + if (pz[1] <= izi) + { + // pz[1] = izi; + addblend(pdest[1], pcolor); + } + } + break; + + case 3: + count = 3 << d_y_aspect_shift; + + for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) + { + if (pz[0] <= izi) + { + // pz[0] = izi; + addblend(pdest[0], pcolor); + } + + if (pz[1] <= izi) + { + // pz[1] = izi; + addblend(pdest[1], pcolor); + } + + if (pz[2] <= izi) + { + // pz[2] = izi; + addblend(pdest[2], pcolor); + } + } + break; + + case 4: + count = 4 << d_y_aspect_shift; + + for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) + { + if (pz[0] <= izi) + { + // pz[0] = izi; + addblend(pdest[0], pcolor); + } + + if (pz[1] <= izi) + { + // pz[1] = izi; + addblend(pdest[1], pcolor); + } + + if (pz[2] <= izi) + { + // pz[2] = izi; + addblend(pdest[2], pcolor); + } + + if (pz[3] <= izi) + { + // pz[3] = izi; + addblend(pdest[3], pcolor); + } + } + break; + + default: + count = pix << d_y_aspect_shift; + + for ( ; count ; count--, pz += d_zwidth, pdest += screenwidth) + { + for (i=0 ; ialpha); - - if (t_state & TT_ZERO) - return; + D_SetTransLevel(pparticle->alpha, blendmode); D_2dPos(src, &u1, &v1, &z1); D_2dPos(dest, &u2, &v2, &z2); @@ -961,13 +911,11 @@ void D_DrawSparkTrans (particle_t *pparticle, vec3_t src, vec3_t dest) //draw a u1 = u1<<16; v1 = v1<<16; z1 = z1<<16; - { - du /= count; - dv /= count; - dz /= count; - } + du /= count; + dv /= count; + dz /= count; - if (t_state & TT_ONE) + if (blendmode == BM_ADD) // additive { do { @@ -975,8 +923,9 @@ void D_DrawSparkTrans (particle_t *pparticle, vec3_t src, vec3_t dest) //draw a if (*pz <= z1>>16) { + // *pz = z1>>16; pdest = d_viewbuffer + d_scantable[v1>>16] + (u1>>16); - *pdest = pparticle->color; + addblend(*pdest, (qbyte)pparticle->color); } u1 += du; @@ -984,7 +933,7 @@ void D_DrawSparkTrans (particle_t *pparticle, vec3_t src, vec3_t dest) //draw a z1 += dz; } while (count--); } - else if (t_state & TT_REVERSE) + else // merge blend { do { @@ -992,26 +941,9 @@ void D_DrawSparkTrans (particle_t *pparticle, vec3_t src, vec3_t dest) //draw a if (*pz <= z1>>16) { + // *pz = z1>>16; pdest = d_viewbuffer + d_scantable[v1>>16] + (u1>>16); - rdraw(*pdest, pparticle->color); - } - - u1 += du; - v1 += dv; - z1 += dz; - } while (count--); - } - else - { - do - { - pz = d_pzbuffer + (d_zwidth * (v1>>16)) + (u1>>16); - - if (*pz <= z1>>16) - { -// *pz = z1>>16; - pdest = d_viewbuffer + d_scantable[v1>>16] + (u1>>16); - draw(*pdest, pparticle->color); + draw(*pdest, (qbyte)pparticle->color); } u1 += du; diff --git a/engine/sw/d_polyse.c b/engine/sw/d_polyse.c index b700dc544..86c5c8236 100644 --- a/engine/sw/d_polyse.c +++ b/engine/sw/d_polyse.c @@ -249,83 +249,6 @@ void D_PolysetDrawFinalVerts32 (finalvert_t *fv, int numverts) } } -void D_PolysetRecursiveTriangleReverseTrans (int *lp1, int *lp2, int *lp3) -{ - int *temp; - int d; - int new[6]; - int z; - short *zbuf; - - d = lp2[0] - lp1[0]; - if (d < -1 || d > 1) - goto split; - d = lp2[1] - lp1[1]; - if (d < -1 || d > 1) - goto split; - - d = lp3[0] - lp2[0]; - if (d < -1 || d > 1) - goto split2; - d = lp3[1] - lp2[1]; - if (d < -1 || d > 1) - goto split2; - - d = lp1[0] - lp3[0]; - if (d < -1 || d > 1) - goto split3; - d = lp1[1] - lp3[1]; - if (d < -1 || d > 1) - { -split3: - temp = lp1; - lp1 = lp3; - lp3 = lp2; - lp2 = temp; - - goto split; - } - - return; // entire tri is filled - -split2: - temp = lp1; - lp1 = lp2; - lp2 = lp3; - lp3 = temp; - -split: -// split this edge - new[0] = (lp1[0] + lp2[0]) >> 1; - new[1] = (lp1[1] + lp2[1]) >> 1; - new[2] = (lp1[2] + lp2[2]) >> 1; - new[3] = (lp1[3] + lp2[3]) >> 1; - new[5] = (lp1[5] + lp2[5]) >> 1; - -// draw the point if splitting a leading edge - if (lp2[1] > lp1[1]) - goto nodraw; - if ((lp2[1] == lp1[1]) && (lp2[0] < lp1[0])) - goto nodraw; - - - z = new[5]>>16; - zbuf = zspantable[new[1]] + new[0]; - if (z >= *zbuf) - { - int pix; - - *zbuf = z; - pix = d_pcolormap[skintable[new[3]>>16][new[2]>>16]]; - d_viewbuffer[d_scantable[new[1]] + new[0]] = Trans(pix, d_viewbuffer[d_scantable[new[1]] + new[0]]); - } - -nodraw: -// recursively continue - D_PolysetRecursiveTriangleReverseTrans (lp3, lp1, new); - D_PolysetRecursiveTriangleReverseTrans (lp3, new, lp2); -} - void D_PolysetRecursiveTriangleTrans (int *lp1, int *lp2, int *lp3) { int *temp; @@ -564,73 +487,6 @@ nodraw: D_PolysetRecursiveTriangle16 (lp3, new, lp2); } -void D_PolysetDrawSpans8ReverseTrans (spanpackage_t *pspanpackage) -{ - int lcount; - qbyte *lpdest; - qbyte *lptex; - int lsfrac, ltfrac; - int llight; - int lzi; - short *lpz; - - if (d_aspancount<0) - return; - - do - { - lcount = d_aspancount - pspanpackage->count; - - 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; - - do - { - if ((lzi >> 16) >= *lpz) - { - *lpdest = Trans(((qbyte *)acolormap)[*lptex + (llight & 0xFF00)], *lpdest); -// gel mapping *lpdest = gelmap[*lpdest]; - *lpz = lzi >> 16; - } - lpdest++; - lzi += r_zistepx; - lpz++; - llight += r_lstepx; - lptex += a_ststepxwhole; - lsfrac += a_sstepxfrac; - lptex += lsfrac >> 16; - lsfrac &= 0xFFFF; - ltfrac += a_tstepxfrac; - if (ltfrac & 0x10000) - { - lptex += r_affinetridesc.skinwidth; - ltfrac &= 0xFFFF; - } - } while (--lcount); - } - - pspanpackage++; - } while (pspanpackage->count != -999999); -} - void D_PolysetDrawSpans8Trans (spanpackage_t *pspanpackage) { int lcount; @@ -641,15 +497,6 @@ void D_PolysetDrawSpans8Trans (spanpackage_t *pspanpackage) int lzi; short *lpz; - if (t_state & TT_REVERSE) - { - if (t_state & TT_ONE) - D_PolysetDrawSpans8C(pspanpackage); - else - D_PolysetDrawSpans8ReverseTrans(pspanpackage); - return; - } - if (d_aspancount<0) return; @@ -1133,7 +980,12 @@ void D_RasterizeAliasPolySmoothC (void) else if (r_pixbytes == 2) D_PolysetDrawSpans16 (a_spans); else - D_PolysetDrawSpans8Trans (a_spans); + { + if (transbackfac) + D_PolysetDrawSpans8Trans (a_spans); + else + D_PolysetDrawSpans8C (a_spans); + } // scan out the bottom part of the right edge, if it exists if (pedgetable->numrightedges == 2) @@ -1167,7 +1019,12 @@ void D_RasterizeAliasPolySmoothC (void) else if (r_pixbytes == 2) D_PolysetDrawSpans16 (pstart); else - D_PolysetDrawSpans8Trans (pstart); + { + if (transbackfac) + D_PolysetDrawSpans8Trans (pstart); + else + D_PolysetDrawSpans8C (pstart); + } } } @@ -1303,16 +1160,8 @@ void D_DrawSubdivC (void) #ifdef PEXT_TRANS if (r_pixbytes == 4) drawfnc = D_PolysetRecursiveTriangle32Trans; - else if (!(t_state & TT_ONE)) - { - if (t_state & TT_ZERO) - return; - - if (t_state & TT_REVERSE) - drawfnc = D_PolysetRecursiveTriangleReverseTrans; - else - drawfnc = D_PolysetRecursiveTriangleTrans; - } + else if (r_pixbytes == 1) + drawfnc = D_PolysetRecursiveTriangleTrans; else #endif drawfnc = D_PolysetRecursiveTriangleC; diff --git a/engine/sw/d_scan.c b/engine/sw/d_scan.c index bef5ff268..03d782cee 100644 --- a/engine/sw/d_scan.c +++ b/engine/sw/d_scan.c @@ -636,7 +636,7 @@ void D_DrawSpans8_Smooth (espan_t *pspan) } do { -#if 1 +#if 0 #define mins (s>>16) #define mint (t>>16) #define pix *(pbase + (mins) + (mint) * cachewidth) diff --git a/engine/sw/d_sprite.c b/engine/sw/d_sprite.c index df71e1625..6e13287b5 100644 --- a/engine/sw/d_sprite.c +++ b/engine/sw/d_sprite.c @@ -503,7 +503,10 @@ NextSpan: } #ifdef PEXT_TRANS -void D_SpriteDrawSpansReverseTrans (sspan_t *pspan) +// Additive version of SpriteDrawSpansTrans +// 1 line change but due to the loop a seperate +// copy is a better idea +void D_SpriteDrawSpansAdditive (sspan_t *pspan) { int count, spancount, izistep; int izi; @@ -635,7 +638,7 @@ void D_SpriteDrawSpansReverseTrans (sspan_t *pspan) if (*pz <= (izi >> 16)) { *pz = izi >> 16; - *pdest = Trans(btemp, *pdest); + *pdest = AddBlend(*pdest, btemp); } } @@ -1067,15 +1070,20 @@ void D_DrawSprite (void) D_SpriteDrawSpans16 (sprite_spans); else //1 { - Set_TransLevelF(currententity->alpha); - if (t_state & TT_ONE) - D_SpriteDrawSpans (sprite_spans); - else if (!(t_state & TT_ZERO)) + if (currententity->alpha > TRANS_LOWER_CAP) { - if (t_state & TT_REVERSE) - D_SpriteDrawSpansReverseTrans (sprite_spans); + if (currententity->flags & Q2RF_ADDATIVE) + { + D_SetTransLevel(currententity->alpha, BM_ADD); + D_SpriteDrawSpansAdditive (sprite_spans); + } + else if (currententity->alpha > TRANS_UPPER_CAP) + D_SpriteDrawSpans (sprite_spans); else + { + D_SetTransLevel(currententity->alpha, BM_MERGE); D_SpriteDrawSpansTrans (sprite_spans); + } } } #endif diff --git a/engine/sw/d_trans.c b/engine/sw/d_trans.c index aaec0c379..c516a73c5 100644 --- a/engine/sw/d_trans.c +++ b/engine/sw/d_trans.c @@ -6,221 +6,53 @@ #include "r_local.h" void MakeVideoPalette(void); -int t_numtables; +void MakeSwizzledPalette(void); -qbyte p1multitable[] = {1, 99, 49, 97, 48, 19, 47, 93, 23, 91, 9, 89, 22, 87, 43, 17, 21, 83, 41, 81, 4, 79, 39, 77, 19, 3, 37, 73, 18, 71, 7, 69, 17, 67, 33, 13, 16, 63, 31, 61, 3, 59, 29, 57, 14, 11, 27, 53, 13, 51, 1, 49, 12, 47, 23, 9, 11, 43, 21, 41, 2, 39, 19, 37, 9, 7, 17, 33, 8, 31, 3, 29, 7, 27, 13, 1, 6, 23, 11, 21, 1, 19, 9, 17, 4, 3, 7, 13, 3, 11, 1, 9, 2, 7, 3, 1, 1, 3, 1, 1, 0}; -qbyte p2multitable[] = {0, 1, 1, 3, 2, 1, 3, 7, 2, 9, 1, 11, 3, 13, 7, 3, 4, 17, 9, 19, 1, 21, 11, 23, 6, 1, 13, 27, 7, 29, 3, 31, 8, 33, 17, 7, 9, 37, 19, 39, 2, 41, 21, 43, 11, 9, 23, 47, 12, 49, 1, 51, 13, 53, 27, 11, 14, 57, 29, 59, 3, 61, 31, 63, 16, 13, 33, 67, 17, 69, 7, 71, 18, 73, 37, 3, 19, 77, 39, 79, 4, 81, 41, 83, 21, 17, 43, 87, 22, 89, 9, 91, 23, 93, 47, 19, 24, 97, 49, 99, 1}; -tlookup *t_lookup; -tlookupp *t_curlookupp; -int t_curtable; +int *srctable; +int *dsttable; +qbyte *pal555to8; -int t_numtables; -int t_numtablesinv;//numtables/65546 - -int t_state; +int swzpal[TRANS_LEVELS][256]; #define palette host_basepal #define _abs(x) ((x)*(x)) -void R_ReverseTable(int table) -{ - int p, p2, temp; - - for (p = 0; p < 256; p++) - for (p2 = p+1; p2 < 256; p2++) - { - temp = (t_lookup[table])[p][p2]; - (t_lookup[table])[p][p2] = (t_lookup[table])[p2][p]; - (t_lookup[table])[p2][p] = temp; - } -} - -void R_CalcTransTable(int table, int level) -{ - FILE * f; - int p; - int p2; - int r, g, b, j; - int i; - unsigned char *pa; - int m, rvr; - int dif, curdif; - - qbyte p1multi; - qbyte p2multi; - qbyte pixdivide; - - p1multi = p1multitable[level]; - p2multi = p2multitable[level]; - - pixdivide = p1multi + p2multi; - - if (level > 99) // trivial generate for p2 - { - for (p = 0; p < 256; p++) - for (p2 = 0; p2 < 256; p2++) - (t_lookup[table])[p][p2] = p2; - return; - } - - if (level < 1) // trivial generate for p - { - for (p = 0; p < 256; p++) - for (p2 = 0; p2 < 256; p2++) - (t_lookup[table])[p][p2] = p; - return; - } - - if (level > 50) - { - level = 100 - level; - rvr = 1; - } - else - rvr = 0; - - COM_FOpenFile (va("tables/ttable%i.dat", (int) level) , &f); //we can ignore the filesize return value - if (f) - { - if (fread (t_lookup[table], 256, 256, f) == 256) - { - if (rvr) - R_ReverseTable(table); - fclose(f); - return; - } - fclose(f); - } - - Con_Printf("Generating transtable %i%%\n", level); - - for (p = 0; p < 256; p++) - { - j = p*3; - for (p2 = 0; p2 < 256; p2++) - { - dif = 0x7fffffff; - m=0; - - i = p2*3; - r = (palette[j+0] * p1multi + palette[i+0] * p2multi) / pixdivide; - g = (palette[j+1] * p1multi + palette[i+1] * p2multi) / pixdivide; - b = (palette[j+2] * p1multi + palette[i+2] * p2multi) / pixdivide; - for (i = 0,pa=palette; i < 256-16; i++,pa+=3) - { - curdif = _abs(r - pa[0]) + _abs(g - pa[1]) + _abs(b - pa[2]); - if (curdif <= 0) //force 0 - { - m = i; - break; - } - if (curdif < dif) - { - dif = curdif; - m = i; - } - } - (t_lookup[table])[p][p2] = m; - } - } - - if (r_transtablewrite.value) - { - COM_CreatePath(va("%s/tables/", com_gamedir)); -#if 1 - f = fopen (va("%s/tables/ttable%i.dat", com_gamedir, (int) level), "wb"); - if (f) - { - if (fwrite (t_lookup[table], 256, 256, f) != 256) - { - Con_Printf("Couldn't write data to \"tables/ttable%i.dat\"\n", (int) level); - fclose(f); - if (rvr) - R_ReverseTable(table); // make sure it gets reversed if needed - return; - } - fclose(f); - } - else - Con_Printf("Couldn't write data to \"tables/ttable%i.dat\"\n", (int) level); -#else - COM_WriteFile(va("tables/ttable%i.dat", (int)level, t_lookup[table], 256*256); -#endif - } - - if (rvr) // just reverse it here instead of having to do reversed writes - R_ReverseTable(table); -} - void D_InitTrans(void) { - int i; - int table; - - if (t_lookup) - BZ_Free(t_lookup); -//no trans palette yet.. - Con_SafePrintf("Making/loading transparency lookup tables\nPlease wait...\n"); - + // create pal555to8 and swizzled palette MakeVideoPalette(); + MakeSwizzledPalette(); - t_numtables = 5; - - i = r_transtables.value; - if (i > 0 && i < 50) // might need a max bound sanity check here - { - t_numtables = i; - } - - if ((i = COM_CheckParm("-ttables")) != 0) - { - t_numtables = Q_atoi(com_argv[i+1]); - if (t_numtables < 1) - t_numtables = 1; - if (t_numtables > 50) - t_numtables = 50; - } - -t_numtablesinv = ((float)65536/t_numtables)+1;//65546/numtables - -t_state = TT_ZERO; -t_curtable=0; -//t_lookup = Hunk_AllocName(sizeof(tlookup)*t_numtables, "Transtables"); -t_lookup = BZ_Malloc(sizeof(tlookup)*t_numtables); -t_curlookupp = t_lookup[t_curtable]; - - if (r_transtablehalf.value) - { - t_state = TT_ZERO|TT_USEHALF; - for (table = 0; table < t_numtables; table++) - R_CalcTransTable(table, (int)floor(((table+1)/(float)(t_numtables*2+1))*100 + 0.5)); - } - else - { - if (t_numtables == 1) - R_CalcTransTable(0, 50); - else if (t_numtables == 2) - { - R_CalcTransTable(0, 33); - R_CalcTransTable(1, 67); - } - else - { - for (table = 0; table < t_numtables; table++) - R_CalcTransTable(table, (int)floor(100/((float)(t_numtables-1)/table) + 0.5)); - } - } - Con_Printf("Done\n"); + srctable = swzpal[0]; + dsttable = swzpal[TRANS_MAX]; } -#ifndef Trans -byte _fastcall Trans(byte p, byte p2) +#if 0 +#define Trans(p, p2) (t_curlookupp[p][p2]) +#else +// TODO: INLINE THESE FUNCTIONS +qbyte _fastcall Trans(qbyte p, qbyte p2) { - return t_curlookupp[p][p2]; + int x; + + x = (srctable[p] + dsttable[p2]) | 0x01F07C1F; + return pal555to8[x & (x >> 15)]; } #endif +qbyte _fastcall AddBlend(qbyte p, qbyte p2) +{ + int x, y; + + x = (srctable[p] + dsttable[p2]); + y = x & 0x40100400; // overflow bits + x = (x | 0x01F07C1F) & 0x3FFFFFFF; + y = y - (y >> 5); + x = x | y; + return pal555to8[x & (x >> 15)]; +} + /* void Set_TransLevelI(int level) { @@ -229,219 +61,112 @@ void Set_TransLevelI(int level) } */ -void Set_TransLevelF(float level) //MUST be between 0 and 1 +void D_SetTransLevel(float level, blendmode_t blend) //MUST be between 0 and 1 { - if (level>1) - level = 1; + int ilvl; - if (t_state & TT_USEHALF) - { - t_state = TT_ZERO; - t_curtable = floor(level*(t_numtables*2+1) + 0.5); - if (t_curtable > t_numtables) - { - t_curtable = (t_numtables*2+1)-t_curtable; - t_state = TT_REVERSE|TT_ONE; - } + // cap and set level + ilvl = (bound(0, level, 1) * (TRANS_MAX + 0.99)); - if (t_curtable > 0) - { - t_state &= ~(TT_ZERO|TT_ONE); - t_curlookupp = t_lookup[t_curtable-1]; - } - - - t_state |= TT_USEHALF; - } - else if (t_numtables == 1) + // set blending tables + switch (blend) { - if (level < 0.33) - t_state = TT_ZERO; - else if (level > 0.67) - t_state = TT_ONE; - else - t_state = 0; - } - else if (t_numtables == 2) - { - if (level > 0.75) - t_state = TT_ONE; - else if (level > 0.50) - { - t_state = 0; - t_curtable = 1; - t_curlookupp = t_lookup[t_curtable]; - } - else if (level > 0.25) - { - t_state = 0; - t_curtable = 0; - t_curlookupp = t_lookup[t_curtable]; - } - else - t_state = TT_ZERO; - } - else - { - t_curtable = level*t_numtables; - if (t_curtable >= t_numtables) - t_state = TT_ONE; - else if (t_curtable <= 0) - t_state = TT_ZERO; - else - { - t_state = 0; - t_curlookupp = t_lookup[t_curtable]; - } + case BM_ADD: + dsttable = swzpal[ilvl]; + srctable = swzpal[TRANS_MAX]; + break; + default: + dsttable = swzpal[ilvl]; + srctable = swzpal[TRANS_MAX - ilvl]; } } -qbyte *palxxxto8; -int palmask[3]; -int palshift[3]; +#define _abs(x) ((x)*(x)) +qbyte FindIndexFromRGB(int red, int green, int blue) +{ + int i, best=15; + int bestdif=256*256*256, curdif; + extern qbyte *host_basepal; + qbyte *pa; + pa = host_basepal; + for (i = 0; i < 256; i++, pa+=3) + { + curdif = _abs(red - pa[0]) + _abs(green - pa[1]) + _abs(blue - pa[2]); + if (curdif < bestdif) + { + if (curdif<1) + return i; + bestdif = curdif; + best = i; + } + } + return best; +} -#define FindPallete(r,g,b) palxxxto8[((r&palmask[0])>>palshift[0]) | ((g&palmask[1])<>1][g>>1][b>>1]) +#define FindPalette(r,g,b) pal555to8[((r&0xF8)>>3)|((g&0xF8)<<2)|((b&0xF8)<<7)] qbyte GetPalette(int red, int green, int blue) { - if (palxxxto8) //fast precalculated method - return FindPallete(red,green,blue); + if (pal555to8) //fast precalculated method + return FindPalette(red,green,blue); else //slow, horrible method. - { - int i, best=15; - int bestdif=256*256*256, curdif; - extern qbyte *host_basepal; - qbyte *pa; - - #define _abs(x) ((x)*(x)) - - pa = host_basepal; - for (i = 0; i < 256; i++, pa+=3) - { - curdif = _abs(red - pa[0]) + _abs(green - pa[1]) + _abs(blue - pa[2]); - if (curdif < bestdif) - { - if (curdif<1) - return i; - bestdif = curdif; - best = i; - } - } - return best; - } + return FindIndexFromRGB(red, green, blue); } void MakeVideoPalette(void) { -// pal77 *temp; - qbyte *temp; - int r, g, b; - int rs, gs, bs, size; - int rstep, gstep, bstep; - int gshift, bshift; FILE *f; - char filename[11]; + int r, g, b; - if (strlen(r_palconvbits.string) != 3) - { - // r5g6b5 is default - rs = 5; - gs = 6; - bs = 5; - } - else - { - // convert to int - rs = r_palconvbits.string[0] - '0'; - gs = r_palconvbits.string[1] - '0'; - bs = r_palconvbits.string[2] - '0'; + // allocate memory + if (!pal555to8) + pal555to8 = BZ_Malloc(PAL555_SIZE); + // pal555to8 = Hunk_AllocName(PAL555_SIZE, "RGB data"); - // limit to 4-8 (can't have 3 because the forumla breaks) - if (rs < 4) - rs = 4; - else if (rs > 8) - rs = 8; - - if (gs < 4) - gs = 4; - else if (gs > 8) - gs = 8; - - if (bs < 4) - bs = 4; - else if (bs > 8) - bs = 8; - } - - Q_strcpy(filename, "rgb000.pal"); - filename[3] = rs + '0'; - filename[4] = gs + '0'; - filename[5] = bs + '0'; - - palshift[0] = 1<>= 1; - gstep >>= 1; - bstep >>= 1; - - for (r = palshift[0] - 1; r >= 0; r--) - for (g = palshift[1] - 1; g >= 0; g--) - for (b = palshift[2] - 1; b >= 0; b--) - { - temp[r+(g<>2, g<<3|g>>2, b<<3|b>>2); + // write palette conversion table if (r_palconvwrite.value) - COM_WriteFile(filename, palxxxto8, size); + COM_WriteFile("pal555.pal", pal555to8, PAL555_SIZE); } +void MakeSwizzledPalette(void) +{ + int idx, lvl; + qbyte *pa; + + // create swizzled palettes + for (lvl = 0; lvl < TRANS_LEVELS; lvl++) + { + pa = host_basepal; + for (idx = 0; idx < 256; idx++) + { + // create a b10r10g10 table for each alpha level + // may need some hacking due to the tendancy of + // identity merges becoming darker + swzpal[lvl][idx] = ( (pa[0] * lvl) >> 4 ) << 10; // red + swzpal[lvl][idx] |= ( (pa[1] * lvl) >> 4 ); // green + swzpal[lvl][idx] |= ( (pa[2] * lvl) >> 4 ) << 20; // blue + swzpal[lvl][idx] = swzpal[lvl][idx] & 0x3feffbff; + pa += 3; + } + } +} void MediaSW_ShowFrame8bit(qbyte *framedata, int inwidth, int inheight, qbyte *palette) { @@ -466,13 +191,13 @@ void MediaSW_ShowFrame8bit(qbyte *framedata, int inwidth, int inheight, qbyte *p fstep = (inwidth<<16)/vid.conwidth; for (x=0 ; x>16)]*3], palette[src[(f>>16)]*3+1], palette[src[(f>>16)]*3+2]); + dest[x] = FindPalette(palette[src[(f>>16)]*3], palette[src[(f>>16)]*3+1], palette[src[(f>>16)]*3+2]); f += fstep; - dest[x+1] = FindPallete(palette[src[(f>>16)]*3], palette[src[(f>>16)]*3+1], palette[src[(f>>16)]*3+2]); + dest[x+1] = FindPalette(palette[src[(f>>16)]*3], palette[src[(f>>16)]*3+1], palette[src[(f>>16)]*3+2]); f += fstep; - dest[x+2] = FindPallete(palette[src[(f>>16)]*3], palette[src[(f>>16)]*3+1], palette[src[(f>>16)]*3+2]); + dest[x+2] = FindPalette(palette[src[(f>>16)]*3], palette[src[(f>>16)]*3+1], palette[src[(f>>16)]*3+2]); f += fstep; - dest[x+3] = FindPallete(palette[src[(f>>16)]*3], palette[src[(f>>16)]*3+1], palette[src[(f>>16)]*3+2]); + dest[x+3] = FindPalette(palette[src[(f>>16)]*3], palette[src[(f>>16)]*3+1], palette[src[(f>>16)]*3+2]); f += fstep; } } @@ -570,13 +295,13 @@ void MediaSW_ShowFrameRGBA_32(qbyte *framedata, int inwidth, int inheight) //top fstep = ((inwidth)*0x10000)/vid.conwidth; for (x=0 ; x>16)*4], src[(f>>16)*4+1], src[(f>>16)*4+2]); + dest[x] = FindPalette(src[(f>>16)*4], src[(f>>16)*4+1], src[(f>>16)*4+2]); f += fstep; - dest[x+1] = FindPallete(src[(f>>16)*4], src[(f>>16)*4+1], src[(f>>16)*4+2]); + dest[x+1] = FindPalette(src[(f>>16)*4], src[(f>>16)*4+1], src[(f>>16)*4+2]); f += fstep; - dest[x+2] = FindPallete(src[(f>>16)*4], src[(f>>16)*4+1], src[(f>>16)*4+2]); + dest[x+2] = FindPalette(src[(f>>16)*4], src[(f>>16)*4+1], src[(f>>16)*4+2]); f += fstep; - dest[x+3] = FindPallete(src[(f>>16)*4], src[(f>>16)*4+1], src[(f>>16)*4+2]); + dest[x+3] = FindPalette(src[(f>>16)*4], src[(f>>16)*4+1], src[(f>>16)*4+2]); f += fstep; } } @@ -670,13 +395,13 @@ void MediaSW_ShowFrameBGR_24_Flip(qbyte *framedata, int inwidth, int inheight) / fstep = ((inwidth)*0x10000)/vid.conwidth; for (x=0 ; x>16)*3+2], src[(f>>16)*3+1], src[(f>>16)*3]); + dest[x] = FindPalette(src[(f>>16)*3+2], src[(f>>16)*3+1], src[(f>>16)*3]); f += fstep; - dest[x+1] = FindPallete(src[(f>>16)*3+2], src[(f>>16)*3+1], src[(f>>16)*3]); + dest[x+1] = FindPalette(src[(f>>16)*3+2], src[(f>>16)*3+1], src[(f>>16)*3]); f += fstep; - dest[x+2] = FindPallete(src[(f>>16)*3+2], src[(f>>16)*3+1], src[(f>>16)*3]); + dest[x+2] = FindPalette(src[(f>>16)*3+2], src[(f>>16)*3+1], src[(f>>16)*3]); f += fstep; - dest[x+3] = FindPallete(src[(f>>16)*3+2], src[(f>>16)*3+1], src[(f>>16)*3]); + dest[x+3] = FindPalette(src[(f>>16)*3+2], src[(f>>16)*3+1], src[(f>>16)*3]); f += fstep; } } diff --git a/engine/sw/r_alias.c b/engine/sw/r_alias.c index f9bd83976..828072711 100644 --- a/engine/sw/r_alias.c +++ b/engine/sw/r_alias.c @@ -320,11 +320,10 @@ void R_AliasPreparePoints (void) else { #if id386 - if (t_state & TT_ONE) - drawfnc = D_PolysetDrawAsm; - else + drawfnc = D_PolysetDrawAsm; +#else + drawfnc = D_PolysetDrawC; #endif - drawfnc = D_PolysetDrawC; } for (i=0 ; ialpha); - if (t_state & TT_ZERO) - return; + if (r_pixbytes == 1) + { + if (currententity->alpha < TRANS_LOWER_CAP) + return; + + if (currententity->alpha > TRANS_UPPER_CAP) + { + transbackfac = 0; + } + else + { + D_SetTransLevel(currententity->alpha, BM_MERGE); + transbackfac = 1; + } + } + else + { + transfactor = currententity->alpha*255; + transbackfac = 255 - transfactor; + } r_amodels_drawn++; @@ -893,9 +909,6 @@ void R_AliasDrawModel (alight_t *plighting) R_AliasSetupLighting (plighting); R_AliasSetupFrame (); - transfactor = currententity->alpha*255; - transbackfac = 255 - transfactor; - if (!currententity->colormap) currententity->colormap = vid.colormap; // Sys_Error ("R_AliasDrawModel: !currententity->colormap"); diff --git a/engine/sw/r_draw.c b/engine/sw/r_draw.c index 71c895b74..70dae108f 100644 --- a/engine/sw/r_draw.c +++ b/engine/sw/r_draw.c @@ -1703,6 +1703,7 @@ void R_16DrawSpanletAlphaTest( void ) //16 bit rendering only } while (--s_spanletvars.spancount > 0); } +#if 0 void R_8DrawSpanletBlended( void ) //8 bit FIXME { unsigned btemp; @@ -1731,6 +1732,7 @@ void R_8DrawSpanletBlended( void ) //8 bit FIXME s_spanletvars.t += s_spanletvars.tstep; } while (--s_spanletvars.spancount > 0); } +#endif void R_32DrawSpanletAlphaTest( void ) { diff --git a/engine/sw/r_main.c b/engine/sw/r_main.c index 580029166..0e799dc0e 100644 --- a/engine/sw/r_main.c +++ b/engine/sw/r_main.c @@ -652,7 +652,7 @@ void SWR_DrawBeam(entity_t *e) for (; len>=0; len--) { VectorAdd(o1, dir, o2); - D_DrawSparkTrans (&p, o1, o2); + D_DrawSparkTrans (&p, o1, o2, 0); VectorCopy(o2, o1); } } diff --git a/engine/sw/sw_draw.c b/engine/sw/sw_draw.c index 6219931e0..0ef7b5eb2 100644 --- a/engine/sw/sw_draw.c +++ b/engine/sw/sw_draw.c @@ -652,8 +652,8 @@ void SWDraw_Character (int x, int y, unsigned int num) } } -#define FindPallete(r,g,b) palxxxto8[((r&palmask[0])>>palshift[0]) | ((g&palmask[1])<>3)|((g&0xF8)<<2)|((b&0xF8)<<7)] +#define colourmask(p,r,g,b) FindPalette(host_basepal[p*3]*r, host_basepal[p*3+1]*g, host_basepal[p*3+2]*b) #define draw(p) colourmask(p, (int)consolecolours[colour].r, (int)consolecolours[colour].g, (int)consolecolours[colour].b) void SWDraw_ColouredCharacter (int x, int y, unsigned int num) { @@ -2374,11 +2374,7 @@ void SWDraw_FadeScreen (void) VID_LockBuffer (); } - - - - - +#if 0 void SWDraw_Box(int x1, int y1, int x2, int y2, int paletteindex, float alpha) { int x; @@ -2391,8 +2387,8 @@ void SWDraw_Box(int x1, int y1, int x2, int y2, int paletteindex, float alpha) unsigned uc; int u, v; - Set_TransLevelF(alpha); - if (t_state & TT_ZERO) + D_SetTransLevel(alpha, BM_MERGE); + if (alpha < TRANS_LOWER_CAP) return; if (x1 < x2) @@ -2427,20 +2423,10 @@ void SWDraw_Box(int x1, int y1, int x2, int y2, int paletteindex, float alpha) if (r_pixbytes == 1) { - if (t_state & TT_ONE) - { - dest = vid.buffer + y*vid.rowbytes + x; - for (v=0 ; v