r_drawflat/r_floorcolour/r_wallcolour for software, use alpha blending instead of stippling for alpha surfaces in software, misc cleanups

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2277 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-05-14 20:52:13 +00:00
parent 244084ad32
commit 0634baab20
8 changed files with 161 additions and 815 deletions

View file

@ -2439,290 +2439,6 @@ void Cvar_Inc_f (void)
Cvar_SetValue (var, var->value + delta);
}
//////////////////////////
/*
typedef struct msg_trigger_s {
char *match;
char *command;
struct msg_trigger_s *next;
} msg_trigger_t;
msg_trigger_t *msg_trigger;
void Cmd_MessageTrigger (char *message, int type)
{
msg_trigger_t *trigger;
for (trigger = msg_trigger; trigger; trigger = trigger->next)
if (strstr(message, trigger->match))
{
Cbuf_AddText(trigger->command, RESTRICT_LOCAL);
Cbuf_AddText("\n", RESTRICT_LOCAL);
}
}
void Cmd_Msg_Trigger_f (void)
{
char *command;
char *match;
char *parm;
qboolean dup=false;
int i;
msg_trigger_t *trigger, *parent;
if (Cmd_Argc() == 1)
{
if (!msg_trigger)
{
Con_Printf("No message triggers are set\n");
return;
}
Con_Printf("Message triggers are:\n");
for (trigger = msg_trigger; trigger; trigger = trigger->next)
{
Con_Printf("%s: %s\n", trigger->command, trigger->match);
}
return;
}
if (Cmd_Argc() < 3)
{
Con_Printf("Usage: %s execcommand match [-d]\n", Cmd_Argv(0));
return;
}
command = Cmd_Argv(1);
match = Cmd_Argv(2);
for (i = 3; i < Cmd_Argc(); i++)
{
parm = Cmd_Argv(i);
if (!strcmp(parm, "-d"))
dup = true;
//print unknown parms?
}
if (dup)
trigger = NULL;
else
{
for (trigger = msg_trigger; trigger; trigger = trigger->next)
{ //find previous (by command text)
if (!strcmp(trigger->command, command))
break;
}
}
if (!*match) //remove.
{
if (!trigger)
{
Con_Printf("Trigger not found\n");
return;
}
if (msg_trigger == trigger)
{
parent = NULL;
msg_trigger = trigger->next;
}
else
{
for (parent = msg_trigger; parent; parent = parent->next)
{
if (parent->next == trigger)
break;
}
if (!parent)
{
Con_Printf("Something strange happening in Cmd_Msg_Trigger_f\n");
return;
}
parent->next = trigger->next;
}
Z_Free(trigger->match);
Z_Free(trigger);
return;
}
if (!trigger)
{
trigger = Z_Malloc(sizeof(msg_trigger_t) + strlen(command) + 1);
trigger->next = msg_trigger;
msg_trigger = trigger;
trigger->command = (char *)(trigger+1);
strcpy(trigger->command, command);
}
if (trigger->match)
Z_Free(trigger->match);
trigger->match = CopyString(match);
}
#define MAX_FILTER_LEN 4
typedef struct msg_filter_s {
struct msg_filter_s *next;
char *name;
} msg_filter_t;
msg_filter_t *msg_filter;
void Cmd_Msg_Filter_Add (char *name)
{
msg_filter_t *f;
if (strchr(name, ' '))
{
Con_Printf("Filter's may not contain spaces.");
return;
}
if (strchr(name, '#'))
{
Con_Printf("Filter's may not contain hashes internally.");
return;
}
for (f = msg_filter; f; f = f->next) //check if it already exists
{
if (!strcmp(f->name, name))
return;
}
f = Z_Malloc(sizeof(msg_filter_t) + strlen(name)+1);
f->next = msg_filter;
msg_filter = f;
f->name = (char *)(f+1);
strcpy(f->name, name);
}
void Cmd_Msg_Filter_Remove (char *name)
{
msg_filter_t *f;
msg_filter_t *old = NULL;
for (f = msg_filter; f; f = f->next)
{
if (!strcmp(f->name, name))
{
if (old)
old->next = f->next;
else
msg_filter = f->next;
Z_Free(f);
return;
}
old = f;
}
Con_Printf("Couldn't remove filter \'%s\'.\n", name);
}
void Cmd_Msg_Filter_ClearAll (void)
{
msg_filter_t *old;
while(msg_filter)
{
old = msg_filter;
msg_filter = msg_filter->next;
Z_Free(old);
}
}
void Cmd_Msg_Filter_f (void)
{
int first, i;
msg_filter_t *f;
char *name;
qboolean clearem = true;
if (Cmd_Argc()==1)
{ //print em
if (!msg_filter)
Con_Printf("Filtering not enabled\n");
Con_Printf("Current filters:");
for (f = msg_filter; f; f = f->next)
Con_Printf(" %s", f->name);
Con_Printf("\n");
return;
}
first = 1;
if (!strcmp(Cmd_Argv(1), "clear"))
{
Cmd_Msg_Filter_ClearAll();
first++;
}
for(i = first; i < Cmd_Argc(); i++)
{
name = Cmd_Argv(i);
if (*name != '#') //go for ZQuake stylie.
{
clearem = false;
}
}
if (clearem)
Cmd_Msg_Filter_ClearAll();
for(i = first; i < Cmd_Argc(); i++)
{
name = Cmd_Argv(i);
if (strchr(name, ' '))
{
Con_Printf("Filter's may not contain spaces.");
continue;
}
if (*name == '#' || *name == '+')
Cmd_Msg_Filter_Add(name+1);
else if (*name == '-')
Cmd_Msg_Filter_Remove(name+1);
else
Cmd_Msg_Filter_Add(name);
}
}
qboolean Cmd_FilterMessage (char *message, qboolean sameteam) //returns true if the message was filtered.
{
msg_filter_t *f;
char *filter;
char *earliest, *end;
int len, msglen;
char trimmedfilter[MAX_FILTER_LEN+1];
if (!msg_filter) //filtering is off.
return false;
msglen = strlen(message);
for(filter = message+strlen(message)-1; filter>=message; filter--)
{
if (!*filter) //that's not right is it?
break;
if (*filter <= ' ') //ignore whitespace
msglen--;
else
break;
}
len = msglen - MAX_FILTER_LEN;
if (len < 0)
len = 0;
earliest = message+len-1;
for(filter = message+msglen-1; filter>=earliest; filter--)
{
if (*filter == '#') //start of filter.
{
break;
}
if (*filter <= ' ') //not a filter
break;
}
if (filter<=earliest || *filter != '#') //not a filterable message, so don't filter it.
return false;
filter++;
Q_strncpyz(trimmedfilter, filter, sizeof(trimmedfilter)); //might have whitespace.
for (end = trimmedfilter + strlen(filter)-1; end >= trimmedfilter && *end <= ' '; end--) //skip trailing
*end = '\0';
for (f = msg_filter; f; f = f->next)
{
if (!strcmp(trimmedfilter, f->name))
{
//hide the filter part of the message.
memmove(filter-1, message + msglen, strlen(message)-msglen+1);
return false; //allow it.
}
}
return true; //not on our list of allowed.
}
*/
void Cmd_WriteConfig_f(void)
{
vfsfile_t *f;

View file

@ -3195,16 +3195,21 @@ void SV_InitLocal (void)
Cvar_Register (&sv_public, cvargroup_servercontrol);
Cvar_Register (&sv_listen, cvargroup_servercontrol);
sv_listen.restriction = RESTRICT_MAX;
#ifdef TCPCONNECT
Cvar_Register (&sv_port_tcp, cvargroup_servercontrol);
sv_port_tcp.restriction = RESTRICT_MAX;
#endif
#ifdef IPPROTO_IPV6
Cvar_Register (&sv_port_ipv6, cvargroup_servercontrol);
sv_port_ipv6.restriction = RESTRICT_MAX;
#endif
#ifdef USEIPX
Cvar_Register (&sv_port_ipx, cvargroup_servercontrol);
sv_port_ipx.restriction = RESTRICT_MAX;
#endif
Cvar_Register (&sv_port, cvargroup_servercontrol);
sv_port.restriction = RESTRICT_MAX;
Cvar_Register (&sv_reportheartbeats, cvargroup_servercontrol);

View file

@ -28,6 +28,7 @@ float scale_for_mip;
int screenwidth;
int ubasestep, errorterm, erroradjustup, erroradjustdown;
int vstartscan;
int r_wallindex, r_floorindex;
// FIXME: should go away
extern void R_RotateBmodel (void);
@ -78,7 +79,6 @@ D_DrawSolidSurface
*/
// FIXME: clean this up
void D_DrawSolidSurface (surf_t *surf, int color)
{
espan_t *span;
@ -197,6 +197,22 @@ void D_CalcGradients (msurface_t *pface)
bbextentt = ((pface->extents[1] << 16) >> miplevel) - 1;
}
void SWR_Drawflat_Callback(struct cvar_s *var, char *oldvalue)
{
D_FlushCaches();
}
void SWR_Floorcolour_Callback(struct cvar_s *var, char *oldvalue)
{
r_floorindex = fbremapidx(SCR_StringToPalIndex(var->string, 255));
D_FlushCaches();
}
void SWR_Wallcolour_Callback(struct cvar_s *var, char *oldvalue)
{
r_wallindex = fbremapidx(SCR_StringToPalIndex(var->string, 255));
D_FlushCaches();
}
/*
==============
@ -212,7 +228,7 @@ void D_DrawSurfaces (void)
vec3_t world_transformed_modelorg;
vec3_t local_modelorg;
extern int r_dosirds;
extern cvar_t r_fastsky, r_fastskycolour;
extern cvar_t r_fastsky, r_fastskycolour, r_drawflat;
currententity = &r_worldentity;
TransformVector (modelorg, transformed_modelorg);
@ -402,7 +418,6 @@ void D_DrawSurfaces (void)
cacheheight = pcurrentcache->height;
// if (s->entity == &r_worldentity) //temporary
// {
D_CalcGradients (pface);

View file

@ -127,12 +127,6 @@ extern void (*d_drawspans) (espan_t *pspan);
#define REMAP_MAX 64
#ifdef _fastcall
#define FASTCALL _fastcall
#else
#define FASTCALL
#endif
// palette remap cache
typedef struct palremap_s {
int r;
@ -159,11 +153,10 @@ void D_DereferenceRemap(palremap_t *palremap);
void D_InitTrans(void);
// void Set_TransLevelI(int level);
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 Trans(qbyte p, qbyte p2);
extern qbyte AddBlend(qbyte p, qbyte p2);
extern qbyte *pal555to8;
void D_ShutdownTrans(void);
#endif

View file

@ -56,7 +56,7 @@ void D_InitTrans(void)
}
// TODO: INLINE THESE FUNCTIONS
qbyte FASTCALL Trans(qbyte p, qbyte p2)
qbyte Trans(qbyte p, qbyte p2)
{
int x;
@ -65,7 +65,7 @@ qbyte FASTCALL Trans(qbyte p, qbyte p2)
}
qbyte FASTCALL AddBlend(qbyte p, qbyte p2)
qbyte AddBlend(qbyte p, qbyte p2)
{
int x, y;

View file

@ -1247,282 +1247,6 @@ typedef struct
spanletvars_t s_spanletvars;
void R_DrawSpanletTurbulentStipple33( void )
{
extern int *r_turb_turb;
unsigned btemp;
int sturb, tturb;
qbyte *pdest = s_spanletvars.pdest;
short *pz = s_spanletvars.pz;
int izi = s_spanletvars.izi;
if ( s_spanletvars.v & 1 )
{
s_spanletvars.pdest += s_spanletvars.spancount;
s_spanletvars.pz += s_spanletvars.spancount;
if ( s_spanletvars.spancount == AFFINE_SPANLET_SIZE )
s_spanletvars.izi += s_spanletvars.izistep << AFFINE_SPANLET_SIZE_BITS;
else
s_spanletvars.izi += s_spanletvars.izistep * s_spanletvars.izistep;
if ( s_spanletvars.u & 1 )
{
izi += s_spanletvars.izistep;
s_spanletvars.s += s_spanletvars.sstep;
s_spanletvars.t += s_spanletvars.tstep;
pdest++;
pz++;
s_spanletvars.spancount--;
}
s_spanletvars.sstep *= 2;
s_spanletvars.tstep *= 2;
while ( s_spanletvars.spancount > 0 )
{
sturb = ((s_spanletvars.s + r_turb_turb[(s_spanletvars.t>>16)&(CYCLE-1)])>>16)&63;
tturb = ((s_spanletvars.t + r_turb_turb[(s_spanletvars.s>>16)&(CYCLE-1)])>>16)&63;
btemp = *( s_spanletvars.pbase + ( sturb ) + ( tturb << 6 ) );
if ( *pz <= ( izi >> 16 ) )
*pdest = btemp;
izi += s_spanletvars.izistep_times_2;
s_spanletvars.s += s_spanletvars.sstep;
s_spanletvars.t += s_spanletvars.tstep;
pdest += 2;
pz += 2;
s_spanletvars.spancount -= 2;
}
}
}
/*
** R_DrawSpanletTurbulentStipple66
*/
void R_DrawSpanletTurbulentStipple66( void )
{
extern int *r_turb_turb;
unsigned btemp;
int sturb, tturb;
qbyte *pdest = s_spanletvars.pdest;
short *pz = s_spanletvars.pz;
int izi = s_spanletvars.izi;
if ( !( s_spanletvars.v & 1 ) )
{
s_spanletvars.pdest += s_spanletvars.spancount;
s_spanletvars.pz += s_spanletvars.spancount;
if ( s_spanletvars.spancount == AFFINE_SPANLET_SIZE )
s_spanletvars.izi += s_spanletvars.izistep << AFFINE_SPANLET_SIZE_BITS;
else
s_spanletvars.izi += s_spanletvars.izistep * s_spanletvars.izistep;
if ( s_spanletvars.u & 1 )
{
izi += s_spanletvars.izistep;
s_spanletvars.s += s_spanletvars.sstep;
s_spanletvars.t += s_spanletvars.tstep;
pdest++;
pz++;
s_spanletvars.spancount--;
}
s_spanletvars.sstep *= 2;
s_spanletvars.tstep *= 2;
while ( s_spanletvars.spancount > 0 )
{
sturb = ((s_spanletvars.s + r_turb_turb[(s_spanletvars.t>>16)&(CYCLE-1)])>>16)&63;
tturb = ((s_spanletvars.t + r_turb_turb[(s_spanletvars.s>>16)&(CYCLE-1)])>>16)&63;
btemp = *( s_spanletvars.pbase + ( sturb ) + ( tturb << 6 ) );
if ( *pz <= ( izi >> 16 ) )
*pdest = btemp;
izi += s_spanletvars.izistep_times_2;
s_spanletvars.s += s_spanletvars.sstep;
s_spanletvars.t += s_spanletvars.tstep;
pdest += 2;
pz += 2;
s_spanletvars.spancount -= 2;
}
}
else
{
s_spanletvars.pdest += s_spanletvars.spancount;
s_spanletvars.pz += s_spanletvars.spancount;
if ( s_spanletvars.spancount == AFFINE_SPANLET_SIZE )
s_spanletvars.izi += s_spanletvars.izistep << AFFINE_SPANLET_SIZE_BITS;
else
s_spanletvars.izi += s_spanletvars.izistep * s_spanletvars.izistep;
while ( s_spanletvars.spancount > 0 )
{
sturb = ((s_spanletvars.s + r_turb_turb[(s_spanletvars.t>>16)&(CYCLE-1)])>>16)&63;
tturb = ((s_spanletvars.t + r_turb_turb[(s_spanletvars.s>>16)&(CYCLE-1)])>>16)&63;
btemp = *( s_spanletvars.pbase + ( sturb ) + ( tturb << 6 ) );
if ( *pz <= ( izi >> 16 ) )
*pdest = btemp;
izi += s_spanletvars.izistep;
s_spanletvars.s += s_spanletvars.sstep;
s_spanletvars.t += s_spanletvars.tstep;
pdest++;
pz++;
s_spanletvars.spancount--;
}
}
}
/*
** R_DrawSpanletTurbulentBlended
*/
/*void R_DrawSpanletTurbulentBlended66( void )
{
extern int *r_turb_turb;
unsigned btemp;
int sturb, tturb;
do
{
sturb = ((s_spanletvars.s + r_turb_turb[(s_spanletvars.t>>16)&(CYCLE-1)])>>16)&63;
tturb = ((s_spanletvars.t + r_turb_turb[(s_spanletvars.s>>16)&(CYCLE-1)])>>16)&63;
btemp = *( s_spanletvars.pbase + ( sturb ) + ( tturb << 6 ) );
if ( *s_spanletvars.pz <= ( s_spanletvars.izi >> 16 ) )
*s_spanletvars.pdest = vid.alphamap[btemp*256+*s_spanletvars.pdest];
s_spanletvars.izi += s_spanletvars.izistep;
s_spanletvars.pdest++;
s_spanletvars.pz++;
s_spanletvars.s += s_spanletvars.sstep;
s_spanletvars.t += s_spanletvars.tstep;
} while ( --s_spanletvars.spancount > 0 );
}
void R_DrawSpanletTurbulentBlended33( void )
{
unsigned btemp;
int sturb, tturb;
do
{
sturb = ((s_spanletvars.s + r_turb_turb[(s_spanletvars.t>>16)&(CYCLE-1)])>>16)&63;
tturb = ((s_spanletvars.t + r_turb_turb[(s_spanletvars.s>>16)&(CYCLE-1)])>>16)&63;
btemp = *( s_spanletvars.pbase + ( sturb ) + ( tturb << 6 ) );
if ( *s_spanletvars.pz <= ( s_spanletvars.izi >> 16 ) )
*s_spanletvars.pdest = vid.alphamap[btemp+*s_spanletvars.pdest*256];
s_spanletvars.izi += s_spanletvars.izistep;
s_spanletvars.pdest++;
s_spanletvars.pz++;
s_spanletvars.s += s_spanletvars.sstep;
s_spanletvars.t += s_spanletvars.tstep;
} while ( --s_spanletvars.spancount > 0 );
}
*/
/*
** R_DrawSpanlet33
*/
/*void R_DrawSpanlet33( void )
{
unsigned btemp;
do
{
unsigned ts, tt;
ts = s_spanletvars.s >> 16;
tt = s_spanletvars.t >> 16;
btemp = *(s_spanletvars.pbase + (ts) + (tt) * cachewidth);
if ( btemp != 255 )
{
if (*s_spanletvars.pz <= (s_spanletvars.izi >> 16))
{
*s_spanletvars.pdest = vid.alphamap[btemp+*s_spanletvars.pdest*256];
}
}
s_spanletvars.izi += s_spanletvars.izistep;
s_spanletvars.pdest++;
s_spanletvars.pz++;
s_spanletvars.s += s_spanletvars.sstep;
s_spanletvars.t += s_spanletvars.tstep;
} while (--s_spanletvars.spancount > 0);
}
void R_DrawSpanletConstant33( void )
{
do
{
if (*s_spanletvars.pz <= (s_spanletvars.izi >> 16))
{
*s_spanletvars.pdest = vid.alphamap[r_polyblendcolor+*s_spanletvars.pdest*256];
}
s_spanletvars.izi += s_spanletvars.izistep;
s_spanletvars.pdest++;
s_spanletvars.pz++;
} while (--s_spanletvars.spancount > 0);
}
*/
/*
** R_DrawSpanlet66
*/
/*
void R_DrawSpanlet66( void )
{
unsigned btemp;
do
{
unsigned ts, tt;
ts = s_spanletvars.s >> 16;
tt = s_spanletvars.t >> 16;
btemp = *(s_spanletvars.pbase + (ts) + (tt) * cachewidth);
if ( btemp != 255 )
{
if (*s_spanletvars.pz <= (s_spanletvars.izi >> 16))
{
*s_spanletvars.pdest = vid.alphamap[btemp*256+*s_spanletvars.pdest];
}
}
s_spanletvars.izi += s_spanletvars.izistep;
s_spanletvars.pdest++;
s_spanletvars.pz++;
s_spanletvars.s += s_spanletvars.sstep;
s_spanletvars.t += s_spanletvars.tstep;
} while (--s_spanletvars.spancount > 0);
}
*/
void R_DrawSpanletConstant( void )
{
do
@ -1537,64 +1261,7 @@ void R_DrawSpanletConstant( void )
s_spanletvars.pz++;
} while (--s_spanletvars.spancount > 0);
}
/*
** R_DrawSpanlet33Stipple
*/
void R_DrawSpanlet33Stipple( void )
{
unsigned btemp;
qbyte *pdest = s_spanletvars.pdest;
short *pz = s_spanletvars.pz;
int izi = s_spanletvars.izi;
if ( r_q2polydesc.stipple_parity ^ ( s_spanletvars.v & 1 ) )
{
s_spanletvars.pdest += s_spanletvars.spancount;
s_spanletvars.pz += s_spanletvars.spancount;
if ( s_spanletvars.spancount == AFFINE_SPANLET_SIZE )
s_spanletvars.izi += s_spanletvars.izistep << AFFINE_SPANLET_SIZE_BITS;
else
s_spanletvars.izi += s_spanletvars.izistep * s_spanletvars.izistep;
if ( r_q2polydesc.stipple_parity ^ ( s_spanletvars.u & 1 ) )
{
izi += s_spanletvars.izistep;
s_spanletvars.s += s_spanletvars.sstep;
s_spanletvars.t += s_spanletvars.tstep;
pdest++;
pz++;
s_spanletvars.spancount--;
}
s_spanletvars.sstep *= 2;
s_spanletvars.tstep *= 2;
while ( s_spanletvars.spancount > 0 )
{
unsigned s = s_spanletvars.s >> 16;
unsigned t = s_spanletvars.t >> 16;
btemp = *( s_spanletvars.pbase + ( s ) + ( t * cachewidth ) );
if ( btemp != 255 )
{
if ( *pz <= ( izi >> 16 ) )
*pdest = btemp;
}
izi += s_spanletvars.izistep_times_2;
s_spanletvars.s += s_spanletvars.sstep;
s_spanletvars.t += s_spanletvars.tstep;
pdest += 2;
pz += 2;
s_spanletvars.spancount -= 2;
}
}
}
void R_16DrawSpanlet33Stipple( void )
{
unsigned btemp;
@ -1680,6 +1347,70 @@ void R_8DrawSpanletAlphaTest( void ) //8 bit rendering only
} while (--s_spanletvars.spancount > 0);
}
void R_8DrawSpanletAlphaBlend( void ) //8 bit rendering only
{
unsigned btemp;
D_SetTransLevel(r_q2polydesc.alpha*255.0, BM_BLEND);
do
{
unsigned ts, tt;
ts = s_spanletvars.s >> 16;
tt = s_spanletvars.t >> 16;
btemp = *(s_spanletvars.pbase + (ts) + (tt) * cachewidth);
if ( btemp != 255 )
{
if (*s_spanletvars.pz <= (s_spanletvars.izi >> 16))
{
*s_spanletvars.pdest = Trans(*s_spanletvars.pdest, btemp);
}
}
s_spanletvars.izi += s_spanletvars.izistep;
s_spanletvars.pdest++;
s_spanletvars.pz++;
s_spanletvars.s += s_spanletvars.sstep;
s_spanletvars.t += s_spanletvars.tstep;
} while (--s_spanletvars.spancount > 0);
}
void R_8DrawSpanletTurbulentAlphaBlend( void )
{
extern int *r_turb_turb;
unsigned btemp;
D_SetTransLevel(r_q2polydesc.alpha*255.0, BM_BLEND);
do
{
unsigned ts, tt;
ts = ((s_spanletvars.s + r_turb_turb[(s_spanletvars.t>>16)&(CYCLE-1)])>>16)&63;
tt = ((s_spanletvars.t + r_turb_turb[(s_spanletvars.s>>16)&(CYCLE-1)])>>16)&63;
btemp = *(s_spanletvars.pbase + (ts) + (tt) * cachewidth);
if ( btemp != 255 )
{
if (*s_spanletvars.pz <= (s_spanletvars.izi >> 16))
{
*s_spanletvars.pdest = Trans(*s_spanletvars.pdest, btemp);
}
}
s_spanletvars.izi += s_spanletvars.izistep;
s_spanletvars.pdest++;
s_spanletvars.pz++;
s_spanletvars.s += s_spanletvars.sstep;
s_spanletvars.t += s_spanletvars.tstep;
} while (--s_spanletvars.spancount > 0);
}
void R_16DrawSpanletAlphaTest( void ) //16 bit rendering only
{
unsigned btemp;
@ -1709,37 +1440,6 @@ void R_16DrawSpanletAlphaTest( void ) //16 bit rendering only
} while (--s_spanletvars.spancount > 0);
}
#if 0
void R_8DrawSpanletBlended( void ) //8 bit FIXME
{
unsigned btemp;
do
{
unsigned ts, tt;
ts = s_spanletvars.s >> 16;
tt = s_spanletvars.t >> 16;
btemp = *(s_spanletvars.pbase + (ts) + (tt) * cachewidth);
// if ( btemp != 255 )
{
if (*s_spanletvars.pz <= (s_spanletvars.izi >> 16))
{
*s_spanletvars.pdest = t_lookup[1][btemp][*s_spanletvars.pdest];
}
}
s_spanletvars.izi += s_spanletvars.izistep;
s_spanletvars.pdest++;
s_spanletvars.pz++;
s_spanletvars.s += s_spanletvars.sstep;
s_spanletvars.t += s_spanletvars.tstep;
} while (--s_spanletvars.spancount > 0);
}
#endif
void R_32DrawSpanletAlphaTest( void )
{
unsigned btemp;
@ -1830,87 +1530,6 @@ void R_32DrawSpanletTurbulentBlended( void )
/*
** R_DrawSpanlet66Stipple
*/
void R_DrawSpanlet66Stipple( void )
{
unsigned btemp;
qbyte *pdest = s_spanletvars.pdest;
short *pz = s_spanletvars.pz;
int izi = s_spanletvars.izi;
s_spanletvars.pdest += s_spanletvars.spancount;
s_spanletvars.pz += s_spanletvars.spancount;
if ( s_spanletvars.spancount == AFFINE_SPANLET_SIZE )
s_spanletvars.izi += s_spanletvars.izistep << AFFINE_SPANLET_SIZE_BITS;
else
s_spanletvars.izi += s_spanletvars.izistep * s_spanletvars.izistep;
if ( r_q2polydesc.stipple_parity ^ ( s_spanletvars.v & 1 ) )
{
if ( r_q2polydesc.stipple_parity ^ ( s_spanletvars.u & 1 ) )
{
izi += s_spanletvars.izistep;
s_spanletvars.s += s_spanletvars.sstep;
s_spanletvars.t += s_spanletvars.tstep;
pdest++;
pz++;
s_spanletvars.spancount--;
}
s_spanletvars.sstep *= 2;
s_spanletvars.tstep *= 2;
while ( s_spanletvars.spancount > 0 )
{
unsigned s = s_spanletvars.s >> 16;
unsigned t = s_spanletvars.t >> 16;
btemp = *( s_spanletvars.pbase + ( s ) + ( t * cachewidth ) );
if ( btemp != 255 )
{
if ( *pz <= ( izi >> 16 ) )
*pdest = btemp;
}
izi += s_spanletvars.izistep_times_2;
s_spanletvars.s += s_spanletvars.sstep;
s_spanletvars.t += s_spanletvars.tstep;
pdest += 2;
pz += 2;
s_spanletvars.spancount -= 2;
}
}
else
{
while ( s_spanletvars.spancount > 0 )
{
unsigned s = s_spanletvars.s >> 16;
unsigned t = s_spanletvars.t >> 16;
btemp = *( s_spanletvars.pbase + ( s ) + ( t * cachewidth ) );
if ( btemp != 255 )
{
if ( *pz <= ( izi >> 16 ) )
*pdest = btemp;
}
izi += s_spanletvars.izistep;
s_spanletvars.s += s_spanletvars.sstep;
s_spanletvars.t += s_spanletvars.tstep;
pdest++;
pz++;
s_spanletvars.spancount--;
}
}
}
void R_16DrawSpanlet66Stipple( void )
{
unsigned btemp;
@ -2500,81 +2119,18 @@ void R_ClipAndDrawPoly ( float alpha, int isturbulent, qboolean textured )
}
else
{
if (isturbulent)
{
if (alpha < 0.5)
r_q2polydesc.drawspanlet = R_DrawSpanletTurbulentStipple33;
else if (alpha < 0.9)
r_q2polydesc.drawspanlet = R_DrawSpanletTurbulentStipple66;
else
if (alpha >= TRANS_UPPER_CAP)
r_q2polydesc.drawspanlet = R_8DrawSpanletAlphaTest;
else if (isturbulent)
{
r_q2polydesc.alpha = alpha*255;
r_q2polydesc.drawspanlet = R_8DrawSpanletTurbulentAlphaBlend;
}
else
{
if (alpha < 0.5)
r_q2polydesc.drawspanlet = R_DrawSpanlet33Stipple;
else if (alpha < 0.9)
r_q2polydesc.drawspanlet = R_DrawSpanlet66Stipple;
else
r_q2polydesc.drawspanlet = R_8DrawSpanletAlphaTest;
r_q2polydesc.alpha = alpha*255;
r_q2polydesc.drawspanlet = R_8DrawSpanletAlphaBlend;
}
/*
if ( !textured )
{
r_q2polydesc.drawspanlet = R_DrawSpanletConstant;//R_DrawSpanletConstant33;
}
else
{
//
// choose the correct spanlet routine based on alpha
//
if ( alpha == 1 )
{
// isturbulent is ignored because we know that turbulent surfaces
// can't be opaque
r_q2polydesc.drawspanlet = R_DrawSpanletConstant;//R_DrawSpanletOpaque;
}
else
{
if (1)// sw_stipplealpha->value )
{
if ( isturbulent )
{
if ( alpha > 0.33 )
r_q2polydesc.drawspanlet = R_DrawSpanletTurbulentStipple66;
else
r_q2polydesc.drawspanlet = R_DrawSpanletTurbulentStipple33;
}
else if (1)
r_q2polydesc.drawspanlet = R_DrawSpanletAlphaTest;
else
{
if ( alpha > 0.33 )
r_q2polydesc.drawspanlet = R_DrawSpanlet66Stipple;
else
r_q2polydesc.drawspanlet = R_DrawSpanlet33Stipple;
}
}
else
{
if ( isturbulent )
{
if ( alpha > 0.33 )
r_q2polydesc.drawspanlet = R_DrawSpanletConstant;//R_DrawSpanletTurbulentBlended66;
else
r_q2polydesc.drawspanlet = R_DrawSpanletConstant;//R_DrawSpanletTurbulentBlended33;
}
else
{
if ( alpha > 0.33 )
r_q2polydesc.drawspanlet = R_DrawSpanletConstant;//R_DrawSpanlet66;
else
r_q2polydesc.drawspanlet = R_DrawSpanletConstant;//R_DrawSpanlet33;
}
}
}
}
*/
}
// clip to the frustum in worldspace

View file

@ -205,10 +205,14 @@ void SWR_InitTextures (void)
// callback declares
extern cvar_t crosshaircolor, r_skyboxname, r_menutint, v_contrast;
extern cvar_t r_floorcolour, r_wallcolour, r_drawflat;
void SWCrosshaircolor_Callback(struct cvar_s *var, char *oldvalue);
void SWR_Skyboxname_Callback(struct cvar_s *var, char *oldvalue);
void SWR_Menutint_Callback(struct cvar_s *var, char *oldvalue);
void SWV_Gamma_Callback(struct cvar_s *var, char *oldvalue);
void SWR_Floorcolour_Callback(struct cvar_s *var, char *oldvalue);
void SWR_Wallcolour_Callback(struct cvar_s *var, char *oldvalue);
void SWR_Drawflat_Callback(struct cvar_s *var, char *oldvalue);
void SWR_DeInit (void)
{
@ -220,6 +224,9 @@ void SWR_DeInit (void)
Cvar_Unhook(&r_menutint);
Cvar_Unhook(&v_gamma);
Cvar_Unhook(&v_contrast);
Cvar_Unhook(&r_floorcolour);
Cvar_Unhook(&r_wallcolour);
Cvar_Unhook(&r_drawflat);
SWDraw_Shutdown();
D_Shutdown();
@ -246,6 +253,9 @@ void SWR_Init (void)
Cvar_Hook(&r_menutint, SWR_Menutint_Callback);
Cvar_Hook(&v_gamma, SWV_Gamma_Callback);
Cvar_Hook(&v_contrast, SWV_Gamma_Callback);
Cvar_Hook(&r_floorcolour, SWR_Floorcolour_Callback);
Cvar_Hook(&r_wallcolour, SWR_Wallcolour_Callback);
Cvar_Hook(&r_drawflat, SWR_Drawflat_Callback);
if (!r_maxedges.value)
Cvar_SetValue (&r_maxedges, (float)NUMSTACKEDGES);

View file

@ -44,6 +44,7 @@ int lightright, lightleftstep, lightrightstep, blockdivshift;
unsigned blockdivmask;
void *prowdestbase;
unsigned char *pbasesource;
unsigned char ptexcolor;
int surfrowbytes; // used by ASM files
unsigned *r_lightptr;
int r_stepback;
@ -59,6 +60,7 @@ void R_DrawSurfaceBlock16From8 (void);
void R_DrawSurfaceBlock32From8 (void);
void R_DrawSurfaceBlock32From8Lit (void);
void R_DrawSurfaceBlock32From32Lit (void);
void R_DrawSurfaceBlock8_notex (void);
static void (*surfmiptable[4])(void) = {
R_DrawSurfaceBlock8_mip0,
@ -1052,7 +1054,6 @@ texture_t *SWR_TextureAnimation (texture_t *base)
return base;
}
/*
===============
R_DrawSurface
@ -1060,6 +1061,9 @@ R_DrawSurface
*/
void R_DrawSurface (void)
{
extern cvar_t r_drawflat;
extern int r_wallindex, r_floorindex;
extern unsigned char ptexcolor;
unsigned char *basetptr;
int smax, tmax, twidth;
int u;
@ -1099,6 +1103,15 @@ void R_DrawSurface (void)
if (r_pixbytes == 1 || r_pixbytes == 4) //if we are using 4, textures are stored as 1 and expanded acording to palette
{
if (r_drawflat.value)
{
if (r_drawsurf.surf->plane->normal[2] <= 0.5)
ptexcolor = r_wallindex;
else
ptexcolor = r_floorindex;
pblockdrawer = R_DrawSurfaceBlock8_notex;
}
else
pblockdrawer = surfmiptable[r_drawsurf.surfmip];
// TODO: only needs to be set when there is a display settings change
horzblockstep = blocksize;
@ -1260,6 +1273,44 @@ void R_DrawSurface32 (void)
}
//=============================================================================
void R_DrawSurfaceBlock8_notex (void)
{
int v, i, b, lightstep, lighttemp, light;
unsigned char pix, *prowdest;
pix = ptexcolor;
prowdest = prowdestbase;
for (v=0 ; v<r_numvblocks ; v++)
{
// FIXME: make these locals?
// FIXME: use delta rather than both right and left, like ASM?
lightleft = r_lightptr[0];
lightright = r_lightptr[1];
r_lightptr += r_lightwidth;
lightleftstep = (r_lightptr[0] - lightleft) >> blockdivshift;
lightrightstep = (r_lightptr[1] - lightright) >> blockdivshift;
for (i=0 ; i<blocksize ; i++)
{
lighttemp = lightleft - lightright;
lightstep = lighttemp >> blockdivshift;
light = lightright;
for (b=blocksize-1; b>=0; b--)
{
prowdest[b] = ((unsigned char *)vid.colormap)
[(light & 0xFF00) + pix];
light += lightstep;
}
lightright += lightrightstep;
lightleft += lightleftstep;
prowdest += surfrowbytes;
}
}
}
#if !id386