Browse Source

ref_soft: Make it draw something, screen settings still wrong

pull/2/head
mittorn 6 years ago
parent
commit
e7785c9ccb
  1. 30
      r_edge.c
  2. 3
      r_glblit.c
  3. 6
      r_local.h
  4. 124
      r_main.c
  5. 44
      r_misc.c
  6. 28
      r_rast.c
  7. 12
      r_scan.c
  8. 43
      r_surf.c

30
r_edge.c

@ -69,6 +69,7 @@ static void (*pdrawfunc)(void);
edge_t edge_head; edge_t edge_head;
edge_t edge_tail; edge_t edge_tail;
edge_t edge_aftertail; edge_t edge_aftertail;
edge_t edge_sentinel; edge_t edge_sentinel;
@ -160,9 +161,15 @@ void R_InsertNewEdges (edge_t *edgestoadd, edge_t *edgelist)
{ {
next_edge = edgestoadd->next; next_edge = edgestoadd->next;
edgesearch: edgesearch:
if( !edgelist )
{
// gEngfuncs.Con_Printf("NULL edgelist!\n");
//return;
}
if (edgelist->u >= edgestoadd->u) if (edgelist->u >= edgestoadd->u)
goto addedge; goto addedge;
edgelist=edgelist->next; edgelist=edgelist->next;
#if 1
if (edgelist->u >= edgestoadd->u) if (edgelist->u >= edgestoadd->u)
goto addedge; goto addedge;
edgelist=edgelist->next; edgelist=edgelist->next;
@ -172,6 +179,7 @@ edgesearch:
if (edgelist->u >= edgestoadd->u) if (edgelist->u >= edgestoadd->u)
goto addedge; goto addedge;
edgelist=edgelist->next; edgelist=edgelist->next;
#endif
goto edgesearch; goto edgesearch;
// insert edgestoadd before edgelist // insert edgestoadd before edgelist
@ -255,10 +263,14 @@ pushback:
// find out where the edge goes in the edge list // find out where the edge goes in the edge list
pwedge = pedge->prev->prev; pwedge = pedge->prev->prev;
// if( !pwedge )
// return;
while (pwedge->u > pedge->u) while (pwedge->u > pedge->u)
{ {
pwedge = pwedge->prev; pwedge = pwedge->prev;
//if( !pwedge )
//return;
} }
// put the edge back into the edge list // put the edge back into the edge list
@ -647,7 +659,7 @@ void R_ScanEdges (void)
// clear active edges to just the background edges around the whole screen // clear active edges to just the background edges around the whole screen
// FIXME: most of this only needs to be set up once // FIXME: most of this only needs to be set up once
edge_head.u = 0; //r_refdef.vrect.x << 20; edge_head.u = 1 << 20; //r_refdef.vrect.x << 20;
edge_head_u_shift20 = edge_head.u >> 20; edge_head_u_shift20 = edge_head.u >> 20;
edge_head.u_step = 0; edge_head.u_step = 0;
edge_head.prev = NULL; edge_head.prev = NULL;
@ -655,7 +667,7 @@ void R_ScanEdges (void)
edge_head.surfs[0] = 0; edge_head.surfs[0] = 0;
edge_head.surfs[1] = 1; edge_head.surfs[1] = 1;
edge_tail.u = 0xFFFFF; // (r_refdef.vrectright << 20) + 0xFFFFF; edge_tail.u =(gpGlobals->width << 20) + 0xFFFFF; // (r_refdef.vrectright << 20) + 0xFFFFF;
edge_tail_u_shift20 = edge_tail.u >> 20; edge_tail_u_shift20 = edge_tail.u >> 20;
edge_tail.u_step = 0; edge_tail.u_step = 0;
edge_tail.prev = &edge_head; edge_tail.prev = &edge_head;
@ -689,7 +701,7 @@ void R_ScanEdges (void)
{ {
R_InsertNewEdges (newedges[iv], edge_head.next); R_InsertNewEdges (newedges[iv], edge_head.next);
} }
#if 1
(*pdrawfunc) (); (*pdrawfunc) ();
// flush the span list if we can't be sure we have enough spans left for // flush the span list if we can't be sure we have enough spans left for
@ -704,7 +716,7 @@ void R_ScanEdges (void)
span_p = basespan_p; span_p = basespan_p;
} }
#endif
if (removeedges[iv]) if (removeedges[iv])
R_RemoveEdges (removeedges[iv]); R_RemoveEdges (removeedges[iv]);
@ -779,12 +791,12 @@ Simple single color fill with no texture mapping
void D_FlatFillSurface (surf_t *surf, int color) void D_FlatFillSurface (surf_t *surf, int color)
{ {
espan_t *span; espan_t *span;
byte *pdest; pixel_t *pdest;
int u, u2; int u, u2;
for (span=surf->spans ; span ; span=span->pnext) for (span=surf->spans ; span ; span=span->pnext)
{ {
pdest = (byte *)d_viewbuffer + r_screenwidth*span->v; pdest = d_viewbuffer + r_screenwidth*span->v;
u = span->u; u = span->u;
u2 = span->u + span->count - 1; u2 = span->u + span->count - 1;
for ( ; u <= u2 ; u++) for ( ; u <= u2 ; u++)
@ -869,7 +881,7 @@ void D_BackgroundSurf (surf_t *s)
d_zistepv = 0; d_zistepv = 0;
d_ziorigin = -0.9; d_ziorigin = -0.9;
D_FlatFillSurface (s, (int)sw_clearcolor->value & 0xFF); D_FlatFillSurface (s, (int)sw_clearcolor->value & 0xFFFF);
D_DrawZSpans (s->spans); D_DrawZSpans (s->spans);
} }
@ -1027,6 +1039,8 @@ void D_SolidSurf (surf_t *s)
} }
#endif #endif
if( !pface )
return;
// FIXME: make this passed in to D_CacheSurface // FIXME: make this passed in to D_CacheSurface
pcurrentcache = D_CacheSurface (pface, miplevel); pcurrentcache = D_CacheSurface (pface, miplevel);
@ -1078,7 +1092,7 @@ void D_DrawflatSurfaces (void)
// make a stable color for each surface by taking the low // make a stable color for each surface by taking the low
// bits of the msurface pointer // bits of the msurface pointer
D_FlatFillSurface (s, (int)s->msurf & 0xFF); D_FlatFillSurface (s, (int)s->msurf & 0xFFFF);
D_DrawZSpans (s->spans); D_DrawZSpans (s->spans);
} }
} }

3
r_glblit.c

@ -168,6 +168,9 @@ void R_InitBlit()
R_BuildScreenMap(); R_BuildScreenMap();
R_BuildBlendMaps(); R_BuildBlendMaps();
d_pzbuffer = malloc(vid.width*vid.height*2);
R_InitCaches();
} }
void R_BlitScreen() void R_BlitScreen()

6
r_local.h

@ -783,11 +783,11 @@ extern cvar_t *r_showhull;
#define DS_SPAN_LIST_END -128 #define DS_SPAN_LIST_END -128
#define NUMSTACKEDGES 2000 #define NUMSTACKEDGES 4000
#define MINEDGES NUMSTACKEDGES #define MINEDGES NUMSTACKEDGES
#define NUMSTACKSURFACES 1000 #define NUMSTACKSURFACES 2000
#define MINSURFACES NUMSTACKSURFACES #define MINSURFACES NUMSTACKSURFACES
#define MAXSPANS 3000 #define MAXSPANS 6000
// flags in finalvert_t.flags // flags in finalvert_t.flags
#define ALIAS_LEFT_CLIP 0x0001 #define ALIAS_LEFT_CLIP 0x0001

124
r_main.c

@ -19,6 +19,7 @@ GNU General Public License for more details.
//#include "beamdef.h" //#include "beamdef.h"
//#include "particledef.h" //#include "particledef.h"
#include "entity_types.h" #include "entity_types.h"
#include "mod_local.h"
#define IsLiquidContents( cnt ) ( cnt == CONTENTS_WATER || cnt == CONTENTS_SLIME || cnt == CONTENTS_LAVA ) #define IsLiquidContents( cnt ) ( cnt == CONTENTS_WATER || cnt == CONTENTS_SLIME || cnt == CONTENTS_LAVA )
@ -1230,6 +1231,125 @@ void R_EdgeDrawing (void)
R_ScanEdges (); R_ScanEdges ();
} }
#if 0
/*
===============
R_MarkLeaves
Mark the leaves and nodes that are in the PVS for the current leaf
===============
*/
void R_MarkLeaves( void )
{
qboolean novis = false;
qboolean force = false;
mleaf_t *leaf = NULL;
mnode_t *node;
vec3_t test;
int i;
if( !RI.drawWorld ) return;
/*if( FBitSet( r_novis->flags, FCVAR_CHANGED ) || tr.fResetVis )
{
// force recalc viewleaf
ClearBits( r_novis->flags, FCVAR_CHANGED );
tr.fResetVis = false;
RI.viewleaf = NULL;
}*/
VectorCopy( RI.pvsorigin, test );
if( RI.viewleaf != NULL )
{
// merge two leafs that can be a crossed-line contents
if( RI.viewleaf->contents == CONTENTS_EMPTY )
{
VectorSet( test, RI.pvsorigin[0], RI.pvsorigin[1], RI.pvsorigin[2] - 16.0f );
leaf = gEngfuncs.Mod_PointInLeaf( test, WORLDMODEL->nodes );
}
else
{
VectorSet( test, RI.pvsorigin[0], RI.pvsorigin[1], RI.pvsorigin[2] + 16.0f );
leaf = gEngfuncs.Mod_PointInLeaf( test, WORLDMODEL->nodes );
}
if(( leaf->contents != CONTENTS_SOLID ) && ( RI.viewleaf != leaf ))
force = true;
}
if( RI.viewleaf == RI.oldviewleaf && RI.viewleaf != NULL && !force )
return;
// development aid to let you run around
// and see exactly where the pvs ends
//if( sw_lockpvs->value ) return;
RI.oldviewleaf = RI.viewleaf;
tr.visframecount++;
if( RI.drawOrtho || !RI.viewleaf || !WORLDMODEL->visdata )
novis = true;
gEngfuncs.R_FatPVS( RI.pvsorigin, REFPVS_RADIUS, RI.visbytes, FBitSet( RI.params, RP_OLDVIEWLEAF ), novis );
if( force && !novis ) gEngfuncs.R_FatPVS( test, REFPVS_RADIUS, RI.visbytes, true, novis );
for( i = 0; i < WORLDMODEL->numleafs; i++ )
{
if( CHECKVISBIT( RI.visbytes, i ))
{
node = (mnode_t *)&WORLDMODEL->leafs[i+1];
do
{
if( node->visframe == tr.visframecount )
break;
node->visframe = tr.visframecount;
node = node->parent;
} while( node );
}
}
}
#else
/*
===============
R_MarkLeaves
===============
*/
void R_MarkLeaves (void)
{
byte *vis;
mnode_t *node;
int i;
if (r_oldviewcluster == r_viewcluster && !r_novis->value && r_viewcluster != -1)
return;
r_visframecount++;
r_oldviewcluster = r_viewcluster;
gEngfuncs.R_FatPVS( RI.pvsorigin, REFPVS_RADIUS, RI.visbytes, FBitSet( RI.params, RP_OLDVIEWLEAF ), false );
vis = RI.visbytes;
for (i = 0; i < WORLDMODEL->numleafs; i++)
{
if (vis[i>>3] & (1<<(i&7)))
{
node = (mnode_t *) &WORLDMODEL->leafs[i+1];
do
{
if (node->visframe == r_visframecount)
break;
node->visframe = r_visframecount;
node = node->parent;
} while (node);
}
}
}
#endif
/* /*
================ ================
R_RenderScene R_RenderScene
@ -1257,7 +1377,7 @@ void R_RenderScene( void )
// R_SetupGL( true ); // R_SetupGL( true );
R_Clear( ~0 ); R_Clear( ~0 );
//R_MarkLeaves(); R_MarkLeaves();
R_DrawFog (); R_DrawFog ();
// R_PushDlights (r_worldmodel); ?? // R_PushDlights (r_worldmodel); ??
R_CheckGLFog(); R_CheckGLFog();
@ -1542,7 +1662,7 @@ qboolean R_Init()
//r_dspeeds = ri.Cvar_Get ("r_dspeeds", "0", 0); //r_dspeeds = ri.Cvar_Get ("r_dspeeds", "0", 0);
// r_lightlevel = ri.Cvar_Get ("r_lightlevel", "0", 0); // r_lightlevel = ri.Cvar_Get ("r_lightlevel", "0", 0);
//r_lerpmodels = ri.Cvar_Get( "r_lerpmodels", "1", 0 ); //r_lerpmodels = ri.Cvar_Get( "r_lerpmodels", "1", 0 );
//r_novis = ri.Cvar_Get( "r_novis", "0", 0 ); r_novis = gEngfuncs.Cvar_Get( "r_novis", "0", 0, "" );
// create the window and set up the context // create the window and set up the context
r_temppool = Mem_AllocPool( "ref_sw zone" ); r_temppool = Mem_AllocPool( "ref_sw zone" );

44
r_misc.c

@ -254,55 +254,65 @@ void R_ViewChanged (vrect_t *vr)
xOrigin = r_refdef.xOrigin; xOrigin = r_refdef.xOrigin;
yOrigin = r_refdef.yOrigin; yOrigin = r_refdef.yOrigin;
#endif
int fov_x = 2.0 * tan (RI.fov_x/360*M_PI);
int fov_y = 2.0 * tan (RI.fov_y/360*M_PI);
// values for perspective projection // values for perspective projection
// if math were exact, the values would range from 0.5 to to range+0.5 // if math were exact, the values would range from 0.5 to to range+0.5
// hopefully they wll be in the 0.000001 to range+.999999 and truncate // hopefully they wll be in the 0.000001 to range+.999999 and truncate
// the polygon rasterization will never render in the first row or column // the polygon rasterization will never render in the first row or column
// but will definately render in the [range] row and column, so adjust the // but will definately render in the [range] row and column, so adjust the
// buffer origin to get an exact edge to edge fill // buffer origin to get an exact edge to edge fill
xcenter = ((float)r_refdef.vrect.width * XCENTERING) + xcenter = ((float)gpGlobals->width * XCENTERING) +
r_refdef.vrect.x - 0.5; 0 - 0.5;
aliasxcenter = xcenter * r_aliasuvscale; //aliasxcenter = xcenter * r_aliasuvscale;
ycenter = ((float)r_refdef.vrect.height * YCENTERING) + ycenter = ((float)gpGlobals->height * YCENTERING) +
r_refdef.vrect.y - 0.5; 0 - 0.5;
aliasycenter = ycenter * r_aliasuvscale; //aliasycenter = ycenter * r_aliasuvscale;
xscale = r_refdef.vrect.width / r_refdef.horizontalFieldOfView; xscale = gpGlobals->width * 1.5 / fov_x;
aliasxscale = xscale * r_aliasuvscale; //aliasxscale = xscale * r_aliasuvscale;
xscaleinv = 1.0 / xscale; xscaleinv = 1.0 / xscale;
yscale = xscale; yscale = xscale;
aliasyscale = yscale * r_aliasuvscale; //aliasyscale = yscale * r_aliasuvscale;
yscaleinv = 1.0 / yscale; yscaleinv = 1.0 / yscale;
xscaleshrink = (r_refdef.vrect.width-6)/r_refdef.horizontalFieldOfView; xscaleshrink = (gpGlobals->width-6)/fov_x;
yscaleshrink = xscaleshrink; yscaleshrink = xscaleshrink;
// ???
#define PLANE_ANYZ 5
int xOrigin = r_origin[0];
int yOrigin = r_origin[1];
// left side clip // left side clip
screenedge[0].normal[0] = -1.0 / (xOrigin*r_refdef.horizontalFieldOfView); screenedge[0].normal[0] = -1.0 / (xOrigin*fov_x);
screenedge[0].normal[1] = 0; screenedge[0].normal[1] = 0;
screenedge[0].normal[2] = 1; screenedge[0].normal[2] = 1;
screenedge[0].type = PLANE_ANYZ; screenedge[0].type = PLANE_ANYZ;
// right side clip // right side clip
screenedge[1].normal[0] = screenedge[1].normal[0] =
1.0 / ((1.0-xOrigin)*r_refdef.horizontalFieldOfView); 1.0 / ((1.0-xOrigin)*fov_x);
screenedge[1].normal[1] = 0; screenedge[1].normal[1] = 0;
screenedge[1].normal[2] = 1; screenedge[1].normal[2] = 1;
screenedge[1].type = PLANE_ANYZ; screenedge[1].type = PLANE_ANYZ;
// top side clip // top side clip
screenedge[2].normal[0] = 0; screenedge[2].normal[0] = 0;
screenedge[2].normal[1] = -1.0 / (yOrigin*verticalFieldOfView); screenedge[2].normal[1] = -1.0 / (yOrigin*fov_y);
screenedge[2].normal[2] = 1; screenedge[2].normal[2] = 1;
screenedge[2].type = PLANE_ANYZ; screenedge[2].type = PLANE_ANYZ;
// bottom side clip // bottom side clip
screenedge[3].normal[0] = 0; screenedge[3].normal[0] = 0;
screenedge[3].normal[1] = 1.0 / ((1.0-yOrigin)*verticalFieldOfView); screenedge[3].normal[1] = 1.0 / ((1.0-yOrigin)*fov_y);
screenedge[3].normal[2] = 1; screenedge[3].normal[2] = 1;
screenedge[3].type = PLANE_ANYZ; screenedge[3].type = PLANE_ANYZ;
#endif
for (i=0 ; i<4 ; i++) for (i=0 ; i<4 ; i++)
VectorNormalize (screenedge[i].normal); VectorNormalize (screenedge[i].normal);

28
r_rast.c

@ -226,6 +226,8 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
int v, v2, ceilv0; int v, v2, ceilv0;
float scale, lzi0, u0, v0; float scale, lzi0, u0, v0;
int side; int side;
if( isnan( pv0->position[1]) )
return;
if (r_lastvertvalid) if (r_lastvertvalid)
{ {
@ -263,6 +265,13 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
v0 = gpGlobals->height; v0 = gpGlobals->height;
ceilv0 = (int) ceil(v0); ceilv0 = (int) ceil(v0);
if( ceilv0 < 0 )
{
printf("ceilv0 %d %f %f %f %f\n", ceilv0, v0, scale, transformed[1], ycenter );
printf("%f %f %f %f\n", world[1],modelorg[1], local[1], transformed[1] );
}
} }
world = &pv1->position[0]; world = &pv1->position[0];
@ -306,7 +315,7 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
// create the edge // create the edge
if (ceilv0 == r_ceilv1) if (ceilv0 == r_ceilv1 || ceilv0 < 0 )
{ {
// we cache unclipped horizontal edges as fully clipped // we cache unclipped horizontal edges as fully clipped
if (cacheoffset != 0x7FFFFFFF) if (cacheoffset != 0x7FFFFFFF)
@ -330,6 +339,7 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
{ {
// trailing edge (go from p1 to p2) // trailing edge (go from p1 to p2)
v = ceilv0; v = ceilv0;
if( v < 0 )printf("v0 %d\n", v);
v2 = r_ceilv1 - 1; v2 = r_ceilv1 - 1;
edge->surfs[0] = surface_p - surfaces; edge->surfs[0] = surface_p - surfaces;
@ -343,6 +353,7 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
// leading edge (go from p2 to p1) // leading edge (go from p2 to p1)
v2 = ceilv0 - 1; v2 = ceilv0 - 1;
v = r_ceilv1; v = r_ceilv1;
if( v < 0 )printf("v1 %d\n", v);
edge->surfs[0] = 0; edge->surfs[0] = 0;
edge->surfs[1] = surface_p - surfaces; edge->surfs[1] = surface_p - surfaces;
@ -359,10 +370,12 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
// it to incorrectly extend to the scan, and the extension of the line goes off // it to incorrectly extend to the scan, and the extension of the line goes off
// the edge of the screen // the edge of the screen
// FIXME: is this actually needed? // FIXME: is this actually needed?
// if (edge->u < r_refdef.vrect_x_adj_shift20) int r = (gpGlobals->width<<20) + (1<<19) - 1;
// edge->u = r_refdef.vrect_x_adj_shift20; int x = (1<<20) + (1<<19) - 1;
// if (edge->u > r_refdef.vrectright_adj_shift20) if (edge->u < x)
// edge->u = r_refdef.vrectright_adj_shift20; edge->u = x;
if (edge->u > r)
edge->u = r;
// //
// sort the edge in normally // sort the edge in normally
@ -371,6 +384,11 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
if (edge->surfs[0]) if (edge->surfs[0])
u_check++; // sort trailers after leaders u_check++; // sort trailers after leaders
if( v < 0 )
{
printf("v %d\n", v);
v = 0;
}
if (!newedges[v] || newedges[v]->u >= u_check) if (!newedges[v] || newedges[v]->u >= u_check)
{ {
edge->next = newedges[v]; edge->next = newedges[v];

12
r_scan.c

@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "r_local.h" #include "r_local.h"
unsigned char *r_turb_pbase, *r_turb_pdest; pixel_t *r_turb_pbase, *r_turb_pdest;
fixed16_t r_turb_s, r_turb_t, r_turb_sstep, r_turb_tstep; fixed16_t r_turb_s, r_turb_t, r_turb_sstep, r_turb_tstep;
int *r_turb_turb; int *r_turb_turb;
int r_turb_spancount; int r_turb_spancount;
@ -143,7 +143,7 @@ void Turbulent8 (espan_t *pspan)
do do
{ {
r_turb_pdest = (unsigned char *)((byte *)d_viewbuffer + r_turb_pdest = (d_viewbuffer +
(r_screenwidth * pspan->v) + pspan->u); (r_screenwidth * pspan->v) + pspan->u);
count = pspan->count; count = pspan->count;
@ -271,7 +271,7 @@ void NonTurbulent8 (espan_t *pspan)
r_turb_sstep = 0; // keep compiler happy r_turb_sstep = 0; // keep compiler happy
r_turb_tstep = 0; // ditto r_turb_tstep = 0; // ditto
r_turb_pbase = (unsigned char *)cacheblock; r_turb_pbase = cacheblock;
sdivz16stepu = d_sdivzstepu * 16; sdivz16stepu = d_sdivzstepu * 16;
tdivz16stepu = d_tdivzstepu * 16; tdivz16stepu = d_tdivzstepu * 16;
@ -279,7 +279,7 @@ void NonTurbulent8 (espan_t *pspan)
do do
{ {
r_turb_pdest = (unsigned char *)((byte *)d_viewbuffer + r_turb_pdest = (d_viewbuffer +
(r_screenwidth * pspan->v) + pspan->u); (r_screenwidth * pspan->v) + pspan->u);
count = pspan->count; count = pspan->count;
@ -401,7 +401,7 @@ D_DrawSpans16
void D_DrawSpans16 (espan_t *pspan) void D_DrawSpans16 (espan_t *pspan)
{ {
int count, spancount; int count, spancount;
unsigned char *pbase, *pdest; pixel_t *pbase, *pdest;
fixed16_t s, t, snext, tnext, sstep, tstep; fixed16_t s, t, snext, tnext, sstep, tstep;
float sdivz, tdivz, zi, z, du, dv, spancountminus1; float sdivz, tdivz, zi, z, du, dv, spancountminus1;
float sdivz8stepu, tdivz8stepu, zi8stepu; float sdivz8stepu, tdivz8stepu, zi8stepu;
@ -417,7 +417,7 @@ void D_DrawSpans16 (espan_t *pspan)
do do
{ {
pdest = (unsigned char *)((byte *)d_viewbuffer + pdest = (d_viewbuffer +
(r_screenwidth * pspan->v) + pspan->u); (r_screenwidth * pspan->v) + pspan->u);
count = pspan->count; count = pspan->count;

43
r_surf.c

@ -28,13 +28,13 @@ int lightdelta, lightdeltastep;
int lightright, lightleftstep, lightrightstep, blockdivshift; int lightright, lightleftstep, lightrightstep, blockdivshift;
unsigned blockdivmask; unsigned blockdivmask;
void *prowdestbase; void *prowdestbase;
unsigned char *pbasesource; pixel_t *pbasesource;
int surfrowbytes; // used by ASM files int surfrowbytes; // used by ASM files
unsigned *r_lightptr; unsigned *r_lightptr;
int r_stepback; int r_stepback;
int r_lightwidth; int r_lightwidth;
int r_numhblocks, r_numvblocks; int r_numhblocks, r_numvblocks;
unsigned char *r_source, *r_sourcemax; pixel_t *r_source, *r_sourcemax;
void R_DrawSurfaceBlock8_mip0 (void); void R_DrawSurfaceBlock8_mip0 (void);
void R_DrawSurfaceBlock8_mip1 (void); void R_DrawSurfaceBlock8_mip1 (void);
@ -188,18 +188,19 @@ R_DrawSurface
*/ */
void R_DrawSurface (void) void R_DrawSurface (void)
{ {
unsigned char *basetptr; pixel_t *basetptr;
int smax, tmax, twidth; int smax, tmax, twidth;
int u; int u;
int soffset, basetoffset, texwidth; int soffset, basetoffset, texwidth;
int horzblockstep; int horzblockstep;
unsigned char *pcolumndest; pixel_t *pcolumndest;
void (*pblockdrawer)(void); void (*pblockdrawer)(void);
image_t *mt; image_t *mt;
surfrowbytes = r_drawsurf.rowbytes; surfrowbytes = r_drawsurf.rowbytes;
mt = r_drawsurf.image; mt = r_drawsurf.image;
r_drawsurf.surfmip = 0;
r_source = mt->pixels[r_drawsurf.surfmip]; r_source = mt->pixels[r_drawsurf.surfmip];
@ -219,7 +220,7 @@ void R_DrawSurface (void)
//============================== //==============================
pblockdrawer = surfmiptable[r_drawsurf.surfmip]; pblockdrawer = surfmiptable[0];
// TODO: only needs to be set when there is a display settings change // TODO: only needs to be set when there is a display settings change
horzblockstep = blocksize; horzblockstep = blocksize;
@ -272,7 +273,7 @@ R_DrawSurfaceBlock8_mip0
void R_DrawSurfaceBlock8_mip0 (void) void R_DrawSurfaceBlock8_mip0 (void)
{ {
int v, i, b, lightstep, lighttemp, light; int v, i, b, lightstep, lighttemp, light;
unsigned char pix, *psource, *prowdest; pixel_t pix, *psource, *prowdest;
psource = pbasesource; psource = pbasesource;
prowdest = prowdestbase; prowdest = prowdestbase;
@ -281,11 +282,11 @@ void R_DrawSurfaceBlock8_mip0 (void)
{ {
// FIXME: make these locals? // FIXME: make these locals?
// FIXME: use delta rather than both right and left, like ASM? // FIXME: use delta rather than both right and left, like ASM?
lightleft = r_lightptr[0]; //lightleft = r_lightptr[0];
lightright = r_lightptr[1]; //lightright = r_lightptr[1];
r_lightptr += r_lightwidth; //r_lightptr += r_lightwidth;
lightleftstep = (r_lightptr[0] - lightleft) >> 4; //lightleftstep = (r_lightptr[0] - lightleft) >> 4;
lightrightstep = (r_lightptr[1] - lightright) >> 4; //lightrightstep = (r_lightptr[1] - lightright) >> 4;
for (i=0 ; i<16 ; i++) for (i=0 ; i<16 ; i++)
{ {
@ -297,14 +298,15 @@ void R_DrawSurfaceBlock8_mip0 (void)
for (b=15; b>=0; b--) for (b=15; b>=0; b--)
{ {
pix = psource[b]; pix = psource[b];
prowdest[b] = ((unsigned char *)vid.colormap) prowdest[b] = pix;
[(light & 0xFF00) + pix]; //((unsigned char *)vid.colormap)
//[(light & 0xFF00) + pix];
light += lightstep; light += lightstep;
} }
psource += sourcetstep; psource += sourcetstep;
lightright += lightrightstep; //lightright += lightrightstep;
lightleft += lightleftstep; //lightleft += lightleftstep;
prowdest += surfrowbytes; prowdest += surfrowbytes;
} }
@ -489,7 +491,7 @@ void R_InitCaches (void)
{ {
size = SURFCACHE_SIZE_AT_320X240; size = SURFCACHE_SIZE_AT_320X240;
pix = vid.width*vid.height; pix =1920 * 1080 * 16;
if (pix > 64000) if (pix > 64000)
size += (pix-64000)*3; size += (pix-64000)*3;
} }
@ -543,10 +545,10 @@ surfcache_t *D_SCAlloc (int width, int size)
surfcache_t *new; surfcache_t *new;
qboolean wrapped_this_time; qboolean wrapped_this_time;
if ((width < 0) || (width > 256)) if ((width < 0) )// || (width > 256))
gEngfuncs.Host_Error ("D_SCAlloc: bad cache width %d\n", width); gEngfuncs.Host_Error ("D_SCAlloc: bad cache width %d\n", width);
if ((size <= 0) || (size > 0x10000)) if ((size <= 0) || (size > 0x10000000))
gEngfuncs.Host_Error ("D_SCAlloc: bad cache size %d\n", size); gEngfuncs.Host_Error ("D_SCAlloc: bad cache size %d\n", size);
size = (int)&((surfcache_t *)0)->data[size]; size = (int)&((surfcache_t *)0)->data[size];
@ -674,11 +676,10 @@ D_CacheSurface
surfcache_t *D_CacheSurface (msurface_t *surface, int miplevel) surfcache_t *D_CacheSurface (msurface_t *surface, int miplevel)
{ {
surfcache_t *cache; surfcache_t *cache;
// //
// if the surface is animating or flashing, flush the cache // if the surface is animating or flashing, flush the cache
// //
r_drawsurf.image = R_GetTexture(R_TextureAnimation (surface->texinfo->texture->gl_texturenum)); r_drawsurf.image = R_GetTexture(R_TextureAnimation (surface)->gl_texturenum);
/// todo: port this /// todo: port this
//r_drawsurf.lightadj[0] = r_newrefdef.lightstyles[surface->styles[0]].white*128; //r_drawsurf.lightadj[0] = r_newrefdef.lightstyles[surface->styles[0]].white*128;
@ -715,7 +716,7 @@ surfcache_t *D_CacheSurface (msurface_t *surface, int miplevel)
if (!cache) // if a texture just animated, don't reallocate it if (!cache) // if a texture just animated, don't reallocate it
{ {
cache = D_SCAlloc (r_drawsurf.surfwidth, cache = D_SCAlloc (r_drawsurf.surfwidth,
r_drawsurf.surfwidth * r_drawsurf.surfheight); r_drawsurf.surfwidth * r_drawsurf.surfheight * 2);
CACHESPOT(surface)[miplevel] = cache; CACHESPOT(surface)[miplevel] = cache;
cache->owner = &CACHESPOT(surface)[miplevel]; cache->owner = &CACHESPOT(surface)[miplevel];
cache->mipscale = surfscale; cache->mipscale = surfscale;

Loading…
Cancel
Save