Merge branch 'brightmap' into 'master'

Brightmaps

See merge request KartKrew/Kart!499
This commit is contained in:
SteelT 2021-12-17 19:10:52 +00:00
commit 156ab1da1c
18 changed files with 1344 additions and 478 deletions

View file

@ -111,3 +111,4 @@ k_botitem.c
k_botsearch.c
k_grandprix.c
k_hud.c
k_brightmap.c

256
src/k_brightmap.c Normal file
View file

@ -0,0 +1,256 @@
// DR. ROBOTNIK'S RING RACERS
//-----------------------------------------------------------------------------
// Copyright (C) 2021 by Sally "TehRealSalt" Cochenour
// Copyright (C) 2021 by Kart Krew
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file k_brightmap.c
/// \brief Brightmap texture loading.
#include "k_brightmap.h"
#include "doomdata.h"
#include "doomdef.h"
#include "doomtype.h"
#include "fastcmp.h"
#include "r_textures.h"
#include "w_wad.h"
#include "z_zone.h"
static brightmapStorage_t *brightmapStorage = NULL;
static size_t maxBrightmapStorage = 0;
/*--------------------------------------------------
static brightmapStorage_t *K_NewBrightmap(void)
Increases the size of maxBrightmapStorage by 1.
Input Arguments:-
None
Return:-
The new brightmap storage struct.
--------------------------------------------------*/
static brightmapStorage_t *K_NewBrightmap(void)
{
maxBrightmapStorage++;
brightmapStorage = (brightmapStorage_t *)Z_Realloc(brightmapStorage, sizeof(brightmapStorage_t) * (maxBrightmapStorage + 1), PU_STATIC, NULL);
return &brightmapStorage[ maxBrightmapStorage - 1 ];
}
/*--------------------------------------------------
static brightmapStorage_t *K_GetBrightmapStorageByIndex(size_t checkIndex)
See header file for description.
--------------------------------------------------*/
static brightmapStorage_t *K_GetBrightmapStorageByIndex(size_t checkIndex)
{
if (checkIndex >= maxBrightmapStorage)
{
return NULL;
}
return &brightmapStorage[checkIndex];
}
/*--------------------------------------------------
static brightmapStorage_t *K_GetBrightmapStorageByTextureName(const char *checkName)
See header file for description.
--------------------------------------------------*/
static brightmapStorage_t *K_GetBrightmapStorageByTextureName(const char *checkName)
{
size_t i;
if (maxBrightmapStorage == 0)
{
return NULL;
}
for (i = 0; i < maxBrightmapStorage; i++)
{
brightmapStorage_t *bms = &brightmapStorage[i];
if (stricmp(checkName, bms->textureName) == 0)
{
// Name matches.
return bms;
}
}
return NULL;
}
/*--------------------------------------------------
static boolean K_BRIGHTLumpParser(UINT8 *data, size_t size)
Parses inputted lump data as a BRIGHT lump.
Input Arguments:-
data - Pointer to lump data.
size - The length of the lump data.
Return:-
false if any errors occured, otherwise true.
--------------------------------------------------*/
static boolean K_BRIGHTLumpParser(UINT8 *data, size_t size)
{
char *tkn = M_GetToken((char *)data);
size_t pos = 0;
while (tkn && (pos = M_GetTokenPos()) < size)
{
boolean valid = true;
if (stricmp(tkn, "texture") == 0)
{
Z_Free(tkn);
tkn = M_GetToken(NULL);
pos = M_GetTokenPos();
if (tkn && pos < size)
{
brightmapStorage_t *bms = K_GetBrightmapStorageByTextureName(tkn);
if (bms == NULL)
{
bms = K_NewBrightmap();
strncpy(bms->textureName, tkn, 9);
}
Z_Free(tkn);
tkn = M_GetToken(NULL);
pos = M_GetTokenPos();
if (tkn && pos < size)
{
strncpy(bms->brightmapName, tkn, 9);
}
else
{
CONS_Alert(CONS_ERROR, "No brightmap for brightmap definition.\n");
valid = false;
}
}
else
{
CONS_Alert(CONS_ERROR, "No texture for brightmap definition.\n");
valid = false;
}
}
// todo: SPRITE brightmaps?!
else
{
CONS_Alert(CONS_ERROR, "Unknown keyword '%s' found in BRIGHT lump.\n", tkn);
valid = false;
}
Z_Free(tkn);
if (valid == false)
{
return false;
}
tkn = M_GetToken(NULL);
}
Z_Free(tkn);
return true;
}
/*--------------------------------------------------
void K_InitBrightmaps(void)
See header file for description.
--------------------------------------------------*/
void K_InitBrightmaps(void)
{
INT32 wadNum;
size_t i;
I_Assert(brightmapStorage == NULL);
maxBrightmapStorage = 0;
for (wadNum = 0; wadNum < numwadfiles; wadNum++)
{
UINT16 lumpNum;
// Find BRIGHT lump in the WAD
lumpNum = W_CheckNumForNamePwad("BRIGHT", wadNum, 0);
while (lumpNum != INT16_MAX)
{
UINT8 *data;
data = (UINT8 *)W_CacheLumpNumPwad(wadNum, lumpNum, PU_STATIC);
// If that didn't exist, we have nothing to do here.
if (data == NULL)
{
lumpNum = W_CheckNumForNamePwad("BRIGHT", (UINT16)wadNum, lumpNum + 1);
continue;
}
else
{
lumpinfo_t *lump_p = &wadfiles[wadNum]->lumpinfo[lumpNum];
size_t size = W_LumpLengthPwad(wadNum, lumpNum);
size_t nameLength = strlen(wadfiles[wadNum]->filename) + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name
char *name = malloc(nameLength + 1);
sprintf(name, "%s|%s", wadfiles[wadNum]->filename, lump_p->fullname);
name[nameLength] = '\0';
size = W_LumpLengthPwad(wadNum, lumpNum);
CONS_Printf(M_GetText("Loading BRIGHT from %s\n"), name);
K_BRIGHTLumpParser(data, size);
free(name);
}
lumpNum = W_CheckNumForNamePwad("BRIGHT", (UINT16)wadNum, lumpNum + 1);
}
}
if (maxBrightmapStorage == 0)
{
// No brightmaps were defined.
return;
}
for (i = 0; i < maxBrightmapStorage; i++)
{
brightmapStorage_t *bms = K_GetBrightmapStorageByIndex(i);
INT32 texNum, bmNum;
if (bms == NULL)
{
// Shouldn't happen.
break;
}
texNum = R_CheckTextureNumForName(bms->textureName);
if (texNum != -1)
{
bmNum = R_CheckTextureNumForName(bms->brightmapName);
if (bmNum == -1)
{
texturebrightmaps[texNum] = 0;
}
else
{
texturebrightmaps[texNum] = bmNum;
}
}
}
R_ClearTextureNumCache(false);
// Clear brightmapStorage now that we're done with it.
Z_Free(brightmapStorage);
brightmapStorage = NULL;
}

38
src/k_brightmap.h Normal file
View file

@ -0,0 +1,38 @@
// DR. ROBOTNIK'S RING RACERS
//-----------------------------------------------------------------------------
// Copyright (C) 2021 by Sally "TehRealSalt" Cochenour
// Copyright (C) 2021 by Kart Krew
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file k_brightmap.h
/// \brief Brightmap texture loading.
#ifndef __K_BRIGHTMAP_H__
#define __K_BRIGHTMAP_H__
#include "doomdata.h"
#include "doomdef.h"
#include "doomtype.h"
typedef struct brightmapStorage_s
{
// Brightmap storage struct.
// Stores data for brightmap definitions,
// before putting them into texturebrightmaps.
char textureName[9]; // The texture's name.
char brightmapName[9]; // The brightmap's name.
} brightmapStorage_t;
/*--------------------------------------------------
void K_InitBrightmaps(void);
Finds all BRIGHT lumps and processes them.
--------------------------------------------------*/
void K_InitBrightmaps(void);
#endif // __K_BRIGHTMAP_H__

View file

@ -91,6 +91,7 @@
#include "k_waypoint.h"
#include "k_bot.h"
#include "k_grandprix.h"
#include "k_brightmap.h"
// Replay names have time
#if !defined (UNDER_CE)
@ -4457,6 +4458,9 @@ boolean P_AddWadFile(const char *wadfilename)
// Reload ANIMDEFS
P_InitPicAnims();
// Reload BRIGHT
K_InitBrightmaps();
// Flush and reload HUD graphics
ST_UnloadGraphics();
HU_LoadGraphics();

View file

@ -30,6 +30,9 @@
#include "byteptr.h"
#include "dehacked.h"
// DRRR
#include "k_brightmap.h"
//
// Graphics.
// SRB2 graphics for walls and sprites
@ -1175,6 +1178,9 @@ void R_InitTextureData(void)
CONS_Printf("P_InitPicAnims()...\n");
P_InitPicAnims();
CONS_Printf("K_InitBrightmaps()...\n");
K_InitBrightmaps();
}
//

View file

@ -72,12 +72,14 @@ UINT8 *topleft;
// =========================================================================
lighttable_t *dc_colormap;
lighttable_t *dc_fullbright;
INT32 dc_x = 0, dc_yl = 0, dc_yh = 0;
fixed_t dc_iscale, dc_texturemid;
UINT8 dc_hires; // under MSVC boolean is a byte, while on other systems, it a bit,
// soo lets make it a byte on all system for the ASM code
UINT8 *dc_source;
UINT8 *dc_brightmap;
// -----------------------
// translucency stuff here
@ -109,6 +111,7 @@ INT32 dc_numlights = 0, dc_maxlights, dc_texheight;
INT32 ds_y, ds_x1, ds_x2;
lighttable_t *ds_colormap;
lighttable_t *ds_fullbright;
lighttable_t *ds_translation; // Lactozilla: Sprite splat drawer
fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
@ -118,6 +121,7 @@ UINT16 ds_flatwidth, ds_flatheight;
boolean ds_powersoftwo;
UINT8 *ds_source; // points to the start of a flat
UINT8 *ds_brightmap; // start of brightmap flat
UINT8 *ds_transmap; // one of the translucency tables
// Vectors for Software's tilted slope drawers

View file

@ -32,11 +32,13 @@ extern UINT8 *topleft;
// -------------------------
extern lighttable_t *dc_colormap;
extern lighttable_t *dc_fullbright;
extern INT32 dc_x, dc_yl, dc_yh;
extern fixed_t dc_iscale, dc_texturemid;
extern UINT8 dc_hires;
extern UINT8 *dc_source; // first pixel in a column
extern UINT8 *dc_brightmap; // brightmap texture column, can be NULL
// translucency stuff here
extern UINT8 *dc_transmap;
@ -57,6 +59,7 @@ extern INT32 dc_texheight;
extern INT32 ds_y, ds_x1, ds_x2;
extern lighttable_t *ds_colormap;
extern lighttable_t *ds_fullbright;
extern lighttable_t *ds_translation;
extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
@ -66,6 +69,7 @@ extern UINT16 ds_flatwidth, ds_flatheight;
extern boolean ds_powersoftwo;
extern UINT8 *ds_source;
extern UINT8 *ds_brightmap;
extern UINT8 *ds_transmap;
typedef struct {
@ -167,6 +171,7 @@ void R_DrawViewBorder(void);
#endif
#define TRANSPARENTPIXEL 255
#define BRIGHTPIXEL 0
// -----------------
// 8bpp DRAWING CODE

File diff suppressed because it is too large Load diff

View file

@ -235,7 +235,9 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
}
if (currentplane->slope)
{
ds_colormap = colormaps;
}
else
{
pindex = distance >> LIGHTZSHIFT;
@ -244,8 +246,13 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
ds_colormap = planezlight[pindex];
}
ds_fullbright = colormaps;
if (encoremap && !currentplane->noencore)
{
ds_colormap += COLORMAP_REMAPOFFSET;
ds_fullbright += COLORMAP_REMAPOFFSET;
}
if (currentplane->extra_colormap)
ds_colormap = currentplane->extra_colormap->colormap + (ds_colormap - colormaps);
@ -641,7 +648,7 @@ static void R_DrawSkyPlane(visplane_t *pl)
// Reset column drawer function (note: couldn't we just call walldrawerfunc directly?)
// (that is, unless we'll need to switch drawers in future for some reason)
colfunc = colfuncs[BASEDRAWFUNC];
R_SetColumnFunc(BASEDRAWFUNC, false);
// use correct aspect ratio scale
dc_iscale = skyscale[viewssnum];
@ -651,8 +658,12 @@ static void R_DrawSkyPlane(visplane_t *pl)
// Because of this hack, sky is not affected
// by sector colormaps (INVUL inverse mapping is not implemented in SRB2 so is irrelevant).
dc_colormap = colormaps;
dc_fullbright = colormaps;
if (encoremap)
{
dc_colormap += COLORMAP_REMAPOFFSET;
dc_fullbright += COLORMAP_REMAPOFFSET;
}
dc_texturemid = skytexturemid;
dc_texheight = textureheight[skytexture]
>>FRACBITS;
@ -669,6 +680,7 @@ static void R_DrawSkyPlane(visplane_t *pl)
dc_source =
R_GetColumn(texturetranslation[skytexture],
-angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18
dc_brightmap = NULL;
colfunc();
}
}
@ -808,7 +820,8 @@ void R_DrawSinglePlane(visplane_t *pl)
}
planeripple.active = false;
spanfunc = spanfuncs[BASEDRAWFUNC];
ds_brightmap = NULL;
R_SetSpanFunc(BASEDRAWFUNC, false, false);
if (pl->polyobj)
{
@ -965,6 +978,17 @@ void R_DrawSinglePlane(visplane_t *pl)
R_CheckFlatLength(ds_flatwidth * ds_flatheight);
}
if (type == LEVELFLAT_TEXTURE)
{
// Get the span's brightmap.
// FLATS not supported, SORRY!!
INT32 bmNum = R_GetTextureBrightmap(levelflat->u.texture.num);
if (bmNum != 0)
{
ds_brightmap = (UINT8 *)R_GenerateTextureAsFlat(bmNum);
}
}
if (!pl->slope // Don't mess with angle on slopes! We'll handle this ourselves later
&& viewangle != pl->viewangle+pl->plangle)
{
@ -1080,15 +1104,7 @@ void R_DrawSinglePlane(visplane_t *pl)
planezlight = zlight[light];
// Use the correct span drawer depending on the powers-of-twoness
if (!ds_powersoftwo)
{
if (spanfuncs_npo2[spanfunctype])
spanfunc = spanfuncs_npo2[spanfunctype];
else
spanfunc = spanfuncs[spanfunctype];
}
else
spanfunc = spanfuncs[spanfunctype];
R_SetSpanFunc(spanfunctype, !ds_powersoftwo, ds_brightmap != NULL);
// set the maximum value for unsigned
pl->top[pl->maxx+1] = 0xffff;

View file

@ -36,6 +36,7 @@ static boolean markceiling;
static boolean maskedtexture;
static INT32 toptexture, bottomtexture, midtexture;
static INT32 topbrightmap, bottombrightmap, midbrightmap;
static INT32 numthicksides, numbackffloors;
angle_t rw_normalangle;
@ -83,7 +84,7 @@ static fixed_t *maskedtextureheight = NULL;
// multi-patch textures. They are not normally needed as multi-patch
// textures don't have holes in it. At least not for now.
static void R_Render2sidedMultiPatchColumn(column_t *column)
static void R_Render2sidedMultiPatchColumn(column_t *column, column_t *brightmap)
{
INT32 topscreen, bottomscreen;
@ -93,6 +94,8 @@ static void R_Render2sidedMultiPatchColumn(column_t *column)
dc_yl = (sprtopscreen+FRACUNIT-1)>>FRACBITS;
dc_yh = (bottomscreen-1)>>FRACBITS;
dc_brightmap = NULL;
if (windowtop != INT32_MAX && windowbottom != INT32_MAX)
{
dc_yl = ((windowtop + FRACUNIT)>>FRACBITS);
@ -110,10 +113,14 @@ static void R_Render2sidedMultiPatchColumn(column_t *column)
if (dc_yl <= dc_yh && dc_yh < vid.height && dc_yh > 0)
{
dc_source = (UINT8 *)column + 3;
if (brightmap != NULL)
{
dc_brightmap = (UINT8 *)brightmap + 3;
}
if (colfunc == colfuncs[BASEDRAWFUNC])
if (R_CheckColumnFunc(BASEDRAWFUNC) == true)
(colfuncs[COLDRAWFUNC_TWOSMULTIPATCH])();
else if (colfunc == colfuncs[COLDRAWFUNC_FUZZY])
else if (R_CheckColumnFunc(COLDRAWFUNC_FUZZY) == true)
(colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS])();
else
colfunc();
@ -132,12 +139,12 @@ transnum_t R_GetLinedefTransTable(line_t *ldef)
void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
{
size_t pindex;
column_t *col;
INT32 lightnum, texnum, i;
column_t *col, *bmCol = NULL;
INT32 lightnum, texnum, bmnum, i;
fixed_t height, realbot;
lightlist_t *light;
r_lightlist_t *rlight;
void (*colfunc_2s)(column_t *);
void (*colfunc_2s)(column_t *, column_t *);
line_t *ldef;
sector_t *front, *back;
INT32 times, repeats;
@ -155,6 +162,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
frontsector = curline->frontsector;
backsector = curline->backsector;
texnum = R_GetTextureNum(curline->sidedef->midtexture);
bmnum = R_GetTextureBrightmap(texnum);
windowbottom = windowtop = sprbotscreen = INT32_MAX;
ldef = curline->linedef;
@ -188,16 +196,18 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
if (transtable != NUMTRANSMAPS && (blendmode || transtable))
{
dc_transmap = R_GetBlendTable(blendmode, transtable);
colfunc = colfuncs[COLDRAWFUNC_FUZZY];
R_SetColumnFunc(COLDRAWFUNC_FUZZY, bmnum != 0);
}
else if (ldef->special == 909)
{
colfunc = colfuncs[COLDRAWFUNC_FOG];
R_SetColumnFunc(COLDRAWFUNC_FOG, bmnum != 0);
windowtop = frontsector->ceilingheight;
windowbottom = frontsector->floorheight;
}
else
colfunc = colfuncs[BASEDRAWFUNC];
{
R_SetColumnFunc(BASEDRAWFUNC, bmnum != 0);
}
if (curline->polyseg && curline->polyseg->translucency > 0)
{
@ -205,7 +215,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
return;
dc_transmap = R_GetTranslucencyTable(curline->polyseg->translucency);
colfunc = colfuncs[COLDRAWFUNC_FUZZY];
R_SetColumnFunc(COLDRAWFUNC_FUZZY, bmnum != 0);
}
range = max(ds->x2-ds->x1, 1);
@ -215,6 +225,8 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
// Texture must be cached before setting colfunc_2s,
// otherwise texture[texnum]->holes may be false when it shouldn't be
R_CheckTextureCache(texnum);
if (bmnum) { R_CheckTextureCache(bmnum); }
// handle case where multipatch texture is drawn on a 2sided wall, multi-patch textures
// are not stored per-column with post info in SRB2
if (textures[texnum]->holes)
@ -265,7 +277,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
rlight->extra_colormap = *light->extra_colormap;
rlight->flags = light->flags;
if ((colfunc != colfuncs[COLDRAWFUNC_FUZZY])
if ((R_CheckColumnFunc(COLDRAWFUNC_FUZZY) == false)
|| (rlight->flags & FF_FOG)
|| (rlight->extra_colormap && (rlight->extra_colormap->flags & CMF_FOG)))
lightnum = (rlight->lightlevel >> LIGHTSEGSHIFT);
@ -282,13 +294,13 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
}
else
{
if ((colfunc != colfuncs[COLDRAWFUNC_FUZZY])
if ((R_CheckColumnFunc(COLDRAWFUNC_FUZZY) == false)
|| (frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG)))
lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT);
else
lightnum = LIGHTLEVELS - 1;
if (colfunc == colfuncs[COLDRAWFUNC_FOG]
if ((R_CheckColumnFunc(COLDRAWFUNC_FOG) == true)
|| (frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG)))
;
else
@ -400,6 +412,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
// draw the texture
col = (column_t *)((UINT8 *)R_GetColumn(texnum, maskedtexturecol[dc_x]) - 3);
if (bmnum) { bmCol = (column_t *)((UINT8 *)R_GetColumn(bmnum, maskedtexturecol[dc_x]) - 3); }
for (i = 0; i < dc_numlights; i++)
{
@ -431,8 +444,12 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
if (height <= windowtop)
{
dc_colormap = rlight->rcolormap;
dc_fullbright = colormaps;
if (encoremap && !(ldef->flags & ML_TFERLINE))
{
dc_colormap += COLORMAP_REMAPOFFSET;
dc_fullbright += COLORMAP_REMAPOFFSET;
}
continue;
}
@ -440,7 +457,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
if (windowbottom >= realbot)
{
windowbottom = realbot;
colfunc_2s(col);
colfunc_2s(col, bmCol);
for (i++; i < dc_numlights; i++)
{
rlight = &dc_lightlist[i];
@ -449,15 +466,19 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
continue;
}
colfunc_2s(col);
colfunc_2s(col, bmCol);
windowtop = windowbottom + 1;
dc_colormap = rlight->rcolormap;
dc_fullbright = colormaps;
if (encoremap && !(ldef->flags & ML_TFERLINE))
{
dc_colormap += COLORMAP_REMAPOFFSET;
dc_fullbright += COLORMAP_REMAPOFFSET;
}
}
windowbottom = realbot;
if (windowtop < windowbottom)
colfunc_2s(col);
colfunc_2s(col, bmCol);
spryscale += rw_scalestep;
continue;
@ -470,8 +491,12 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
pindex = MAXLIGHTSCALE - 1;
dc_colormap = walllights[pindex];
dc_fullbright = colormaps;
if (encoremap && !(ldef->flags & ML_TFERLINE))
{
dc_colormap += COLORMAP_REMAPOFFSET;
dc_fullbright += COLORMAP_REMAPOFFSET;
}
if (frontsector->extra_colormap)
dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps);
@ -481,6 +506,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
// draw the texture
col = (column_t *)((UINT8 *)R_GetColumn(texnum, maskedtexturecol[dc_x]) - 3);
if (bmnum) { bmCol = (column_t *)((UINT8 *)R_GetColumn(bmnum, maskedtexturecol[dc_x]) - 3); }
#if 0 // Disabling this allows inside edges to render below the planes, for until the clipping is fixed to work right when POs are near the camera. -Red
if (curline->dontrenderme && curline->polyseg && (curline->polyseg->flags & POF_RENDERPLANES))
@ -535,19 +561,20 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
}
else
#endif
colfunc_2s(col);
colfunc_2s(col, bmCol);
}
spryscale += rw_scalestep;
}
}
colfunc = colfuncs[BASEDRAWFUNC];
R_SetColumnFunc(BASEDRAWFUNC, false);
}
// Loop through R_DrawMaskedColumn calls
static void R_DrawRepeatMaskedColumn(column_t *col)
static void R_DrawRepeatMaskedColumn(column_t *col, column_t *bm)
{
while (sprtopscreen < sprbotscreen) {
R_DrawMaskedColumn(col);
R_DrawMaskedColumn(col, bm);
if ((INT64)sprtopscreen + dc_texheight*spryscale > (INT64)INT32_MAX) // prevent overflow
sprtopscreen = INT32_MAX;
else
@ -555,10 +582,10 @@ static void R_DrawRepeatMaskedColumn(column_t *col)
}
}
static void R_DrawRepeatFlippedMaskedColumn(column_t *col)
static void R_DrawRepeatFlippedMaskedColumn(column_t *col, column_t *bm)
{
do {
R_DrawFlippedMaskedColumn(col);
R_DrawFlippedMaskedColumn(col, bm);
sprtopscreen += dc_texheight*spryscale;
} while (sprtopscreen < sprbotscreen);
}
@ -582,9 +609,9 @@ static boolean R_IsFFloorTranslucent(visffloor_t *pfloor)
void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
{
size_t pindex;
column_t * col;
column_t * col, *bmCol = NULL;
INT32 lightnum;
INT32 texnum;
INT32 texnum, bmnum;
sector_t tempsec;
INT32 templight;
INT32 i, p;
@ -605,7 +632,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
fixed_t left_top, left_bottom; // needed here for slope skewing
pslope_t *skewslope = NULL;
void (*colfunc_2s) (column_t *);
void (*colfunc_2s) (column_t *, column_t *);
// Calculate light table.
// Use different light tables
@ -616,14 +643,16 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
backsector = pfloor->target;
frontsector = curline->frontsector == pfloor->target ? curline->backsector : curline->frontsector;
texnum = R_GetTextureNum(sides[pfloor->master->sidenum[0]].midtexture);
bmnum = R_GetTextureBrightmap(texnum);
colfunc = colfuncs[BASEDRAWFUNC];
R_SetColumnFunc(BASEDRAWFUNC, bmnum != 0);
if (pfloor->master->flags & ML_TFERLINE)
{
size_t linenum = curline->linedef-backsector->lines[0];
newline = pfloor->master->frontsector->lines[0] + linenum;
texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture);
bmnum = R_GetTextureBrightmap(texnum);
}
if (pfloor->flags & FF_TRANSLUCENT)
@ -641,10 +670,14 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
}
if (fuzzy)
colfunc = colfuncs[COLDRAWFUNC_FUZZY];
{
R_SetColumnFunc(COLDRAWFUNC_FUZZY, bmnum != 0);
}
}
else if (pfloor->flags & FF_FOG)
colfunc = colfuncs[COLDRAWFUNC_FOG];
{
R_SetColumnFunc(COLDRAWFUNC_FOG, bmnum != 0);
}
range = max(ds->x2-ds->x1, 1);
//SoM: Moved these up here so they are available for my lightlist calculations
@ -752,7 +785,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT);
else if (pfloor->flags & FF_FOG)
lightnum = (pfloor->master->frontsector->lightlevel >> LIGHTSEGSHIFT);
else if (colfunc == colfuncs[COLDRAWFUNC_FUZZY])
else if (R_CheckColumnFunc(COLDRAWFUNC_FUZZY) == true)
lightnum = LIGHTLEVELS-1;
else
lightnum = R_FakeFlat(frontsector, &tempsec, &templight, &templight, false)
@ -833,6 +866,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
// Texture must be cached before setting colfunc_2s,
// otherwise texture[texnum]->holes may be false when it shouldn't be
R_CheckTextureCache(texnum);
if (bmnum) { R_CheckTextureCache(bmnum); }
//faB: handle case where multipatch texture is drawn on a 2sided wall, multi-patch textures
// are not stored per-column with post info anymore in Doom Legacy
if (textures[texnum]->holes)
@ -916,6 +951,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
// Get data for the column
col = (column_t *)((UINT8 *)R_GetColumn(texnum,maskedtexturecol[dc_x]) - 3);
if (bmnum) { bmCol = (column_t *)((UINT8 *)R_GetColumn(bmnum, maskedtexturecol[dc_x]) - 3); }
// SoM: New code does not rely on R_DrawColumnShadowed_8 which
// will (hopefully) put less strain on the stack.
@ -998,8 +1034,12 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
if (lighteffect)
{
dc_colormap = rlight->rcolormap;
dc_fullbright = colormaps;
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
{
dc_colormap += COLORMAP_REMAPOFFSET;
dc_fullbright += COLORMAP_REMAPOFFSET;
}
}
if (solid && windowtop < bheight)
windowtop = bheight;
@ -1011,7 +1051,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
{
windowbottom = sprbotscreen;
// draw the texture
colfunc_2s (col);
colfunc_2s (col, bmCol);
for (i++; i < dc_numlights; i++)
{
rlight = &dc_lightlist[i];
@ -1022,7 +1062,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
continue;
}
// draw the texture
colfunc_2s (col);
colfunc_2s (col, bmCol);
if (solid)
windowtop = bheight;
else
@ -1030,14 +1070,18 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
if (lighteffect)
{
dc_colormap = rlight->rcolormap;
dc_fullbright = colormaps;
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
{
dc_colormap += COLORMAP_REMAPOFFSET;
dc_fullbright += COLORMAP_REMAPOFFSET;
}
}
}
windowbottom = sprbotscreen;
// draw the texture, if there is any space left
if (windowtop < windowbottom)
colfunc_2s (col);
colfunc_2s (col, bmCol);
spryscale += rw_scalestep;
continue;
@ -1050,9 +1094,13 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
pindex = MAXLIGHTSCALE - 1;
dc_colormap = walllights[pindex];
dc_fullbright = colormaps;
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
{
dc_colormap += COLORMAP_REMAPOFFSET;
dc_fullbright += COLORMAP_REMAPOFFSET;
}
if (pfloor->flags & FF_FOG && pfloor->master->frontsector->extra_colormap)
dc_colormap = pfloor->master->frontsector->extra_colormap->colormap + (dc_colormap - colormaps);
@ -1060,11 +1108,12 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps);
// draw the texture
colfunc_2s (col);
colfunc_2s (col, bmCol);
spryscale += rw_scalestep;
}
}
colfunc = colfuncs[BASEDRAWFUNC];
R_SetColumnFunc(BASEDRAWFUNC, false);
#undef CLAMPMAX
#undef CLAMPMIN
@ -1311,8 +1360,12 @@ static void R_RenderSegLoop (void)
pindex = MAXLIGHTSCALE-1;
dc_colormap = walllights[pindex];
dc_fullbright = colormaps;
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
{
dc_colormap += COLORMAP_REMAPOFFSET;
dc_fullbright += COLORMAP_REMAPOFFSET;
}
dc_x = rw_x;
dc_iscale = 0xffffffffu / (unsigned)rw_scale;
@ -1350,7 +1403,7 @@ static void R_RenderSegLoop (void)
else
dc_lightlist[i].rcolormap = xwalllights[pindex];
colfunc = colfuncs[COLDRAWFUNC_SHADOWED];
R_SetColumnFunc(COLDRAWFUNC_SHADOWED, false);
}
}
@ -1366,8 +1419,11 @@ static void R_RenderSegLoop (void)
dc_yh = yh;
dc_texturemid = rw_midtexturemid;
dc_source = R_GetColumn(midtexture,texturecolumn);
dc_brightmap = (midbrightmap ? R_GetColumn(midbrightmap, texturecolumn) : NULL);
dc_texheight = textureheight[midtexture]>>FRACBITS;
R_SetColumnFunc(colfunctype, dc_brightmap != NULL);
//profile stuff ---------------------------------------------------------
#ifdef TIMING
ProfZeroTimer();
@ -1427,7 +1483,9 @@ static void R_RenderSegLoop (void)
dc_yh = mid;
dc_texturemid = rw_toptexturemid;
dc_source = R_GetColumn(toptexture,texturecolumn);
dc_brightmap = (topbrightmap ? R_GetColumn(topbrightmap, texturecolumn) : NULL);
dc_texheight = textureheight[toptexture]>>FRACBITS;
R_SetColumnFunc(colfunctype, dc_brightmap != NULL);
colfunc();
ceilingclip[rw_x] = (INT16)mid;
}
@ -1462,9 +1520,10 @@ static void R_RenderSegLoop (void)
dc_yl = mid;
dc_yh = yh;
dc_texturemid = rw_bottomtexturemid;
dc_source = R_GetColumn(bottomtexture,
texturecolumn);
dc_source = R_GetColumn(bottomtexture,texturecolumn);
dc_brightmap = (bottombrightmap ? R_GetColumn(bottombrightmap, texturecolumn) : NULL);
dc_texheight = textureheight[bottomtexture]>>FRACBITS;
R_SetColumnFunc(colfunctype, dc_brightmap != NULL);
colfunc();
floorclip[rw_x] = (INT16)mid;
}
@ -1558,7 +1617,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
memset(&segleft, 0x00, sizeof(segleft));
memset(&segright, 0x00, sizeof(segright));
colfunc = colfuncs[BASEDRAWFUNC];
R_SetColumnFunc(BASEDRAWFUNC, false);
if (ds_p == drawsegs+maxdrawsegs)
{
@ -1738,6 +1797,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
worldbottomslope -= viewz;
midtexture = toptexture = bottomtexture = maskedtexture = 0;
midbrightmap = topbrightmap = bottombrightmap = 0;
ds_p->maskedtexturecol = NULL;
ds_p->numthicksides = numthicksides = 0;
ds_p->thicksidecol = NULL;
@ -1785,6 +1845,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
fixed_t texheight;
// single sided line
midtexture = R_GetTextureNum(sidedef->midtexture);
midbrightmap = R_GetTextureBrightmap(midtexture);
texheight = textureheight[midtexture];
// a single sided line is terminal, so it must mark ends
markfloor = markceiling = true;
@ -2021,11 +2082,14 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (!toptexture) //Second side has no texture, use the first side's instead.
toptexture = R_GetTextureNum(sidedef->toptexture);
topbrightmap = R_GetTextureBrightmap(toptexture);
texheight = textureheight[toptexture];
}
else
{
toptexture = R_GetTextureNum(sidedef->toptexture);
topbrightmap = R_GetTextureBrightmap(toptexture);
texheight = textureheight[toptexture];
}
if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked
@ -2052,6 +2116,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
{
// bottom texture
bottomtexture = R_GetTextureNum(sidedef->bottomtexture);
bottombrightmap = R_GetTextureBrightmap(bottomtexture);
if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked
if (linedef->flags & ML_DONTPEGBOTTOM)
@ -2772,7 +2837,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
rw_bsilheight = &(ds_p->bsilheight);
R_RenderSegLoop();
colfunc = colfuncs[BASEDRAWFUNC];
R_SetColumnFunc(BASEDRAWFUNC, false);
if (portalline) // if curline is a portal, set portalrender for drawseg
ds_p->portalpass = portalrender+1;

View file

@ -444,6 +444,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
}
ds_colormap = vis->colormap;
ds_fullbright = colormaps;
ds_translation = R_GetSpriteTranslation(vis);
if (ds_translation == NULL)
ds_translation = colormaps;
@ -468,10 +469,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
else
ds_transmap = NULL;
if (ds_powersoftwo)
spanfunc = spanfuncs[spanfunctype];
else
spanfunc = spanfuncs_npo2[spanfunctype];
R_SetSpanFunc(spanfunctype, !ds_powersoftwo, false);
if (maxy >= vid.height)
maxy = vid.height-1;

View file

@ -54,6 +54,9 @@ extern extracolormap_t *extra_colormaps;
// for global animation
extern INT32 *texturetranslation;
// for brightmaps
extern INT32 *texturebrightmaps;
// Sprites
extern size_t numspritelumps, max_spritelumps;

View file

@ -55,6 +55,7 @@ INT32 *texturewidth;
fixed_t *textureheight; // needed for texture pegging
INT32 *texturetranslation;
INT32 *texturebrightmaps;
// Painfully simple texture id cacheing to make maps load faster. :3
static struct {
@ -500,6 +501,20 @@ INT32 R_GetTextureNum(INT32 texnum)
return texturetranslation[texnum];
}
//
// R_GetTextureBrightmap
//
// Returns the actual texture id that we should use.
// This can either be the texture's brightmap,
// or 0 if not valid.
//
INT32 R_GetTextureBrightmap(INT32 texnum)
{
if (texnum < 0 || texnum >= numtextures)
return 0;
return texturebrightmaps[texnum];
}
//
// R_CheckTextureCache
//
@ -944,6 +959,7 @@ void R_LoadTextures(void)
Z_Free(textures[i]);
Z_Free(texturecache[i]);
}
Z_Free(texturebrightmaps);
Z_Free(texturetranslation);
Z_Free(textures);
}
@ -1044,9 +1060,14 @@ void R_LoadTextures(void)
textureheight = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 4));
// Create translation table for global animation.
texturetranslation = Z_Malloc((numtextures + 1) * sizeof(*texturetranslation), PU_STATIC, NULL);
// Create brightmap texture table.
texturebrightmaps = Z_Malloc((numtextures + 1) * sizeof(*texturebrightmaps), PU_STATIC, NULL);
for (i = 0; i < numtextures; i++)
{
texturetranslation[i] = i;
texturebrightmaps[i] = 0;
}
for (i = 0, w = 0; w < numwadfiles; w++)
{

View file

@ -82,6 +82,7 @@ void R_FlushTextureCache(void);
UINT8 *R_GenerateTexture(size_t texnum);
UINT8 *R_GenerateTextureAsFlat(size_t texnum);
INT32 R_GetTextureNum(INT32 texnum);
INT32 R_GetTextureBrightmap(INT32 texnum);
void R_CheckTextureCache(INT32 tex);
void R_ClearTextureNumCache(boolean btell);

View file

@ -604,7 +604,7 @@ INT16 *mceilingclip;
fixed_t spryscale = 0, sprtopscreen = 0, sprbotscreen = 0;
fixed_t windowtop = 0, windowbottom = 0;
void R_DrawMaskedColumn(column_t *column)
void R_DrawMaskedColumn(column_t *column, column_t *brightmap)
{
INT32 topscreen;
INT32 bottomscreen;
@ -613,6 +613,9 @@ void R_DrawMaskedColumn(column_t *column)
basetexturemid = dc_texturemid;
R_SetColumnFunc(colfunctype, brightmap != NULL);
dc_brightmap = NULL;
for (; column->topdelta != 0xff ;)
{
// calculate unclipped screen coordinates
@ -647,6 +650,11 @@ void R_DrawMaskedColumn(column_t *column)
if (dc_yl <= dc_yh && dc_yh > 0)
{
dc_source = (UINT8 *)column + 3;
if (brightmap != NULL)
{
dc_brightmap = (UINT8 *)brightmap + 3;
}
dc_texturemid = basetexturemid - (topdelta<<FRACBITS);
// Drawn by R_DrawColumn.
@ -661,6 +669,10 @@ void R_DrawMaskedColumn(column_t *column)
#endif
}
column = (column_t *)((UINT8 *)column + column->length + 4);
if (brightmap != NULL)
{
brightmap = (column_t *)((UINT8 *)brightmap + brightmap->length + 4);
}
}
dc_texturemid = basetexturemid;
@ -668,7 +680,7 @@ void R_DrawMaskedColumn(column_t *column)
INT32 lengthcol; // column->length : for flipped column function pointers and multi-patch on 2sided wall = texture->height
void R_DrawFlippedMaskedColumn(column_t *column)
void R_DrawFlippedMaskedColumn(column_t *column, column_t *brightmap)
{
INT32 topscreen;
INT32 bottomscreen;
@ -676,6 +688,9 @@ void R_DrawFlippedMaskedColumn(column_t *column)
INT32 topdelta, prevdelta = -1;
UINT8 *d,*s;
R_SetColumnFunc(colfunctype, brightmap != NULL);
dc_brightmap = NULL;
for (; column->topdelta != 0xff ;)
{
// calculate unclipped screen coordinates
@ -714,6 +729,14 @@ void R_DrawFlippedMaskedColumn(column_t *column)
dc_source = ZZ_Alloc(column->length);
for (s = (UINT8 *)column+2+column->length, d = dc_source; d < dc_source+column->length; --s)
*d++ = *s;
if (brightmap != NULL)
{
dc_brightmap = ZZ_Alloc(brightmap->length);
for (s = (UINT8 *)brightmap+2+brightmap->length, d = dc_brightmap; d < dc_brightmap+brightmap->length; --s)
*d++ = *s;
}
dc_texturemid = basetexturemid - (topdelta<<FRACBITS);
// Still drawn by R_DrawColumn.
@ -726,6 +749,10 @@ void R_DrawFlippedMaskedColumn(column_t *column)
Z_Free(dc_source);
}
column = (column_t *)((UINT8 *)column + column->length + 4);
if (brightmap != NULL)
{
brightmap = (column_t *)((UINT8 *)brightmap + brightmap->length + 4);
}
}
dc_texturemid = basetexturemid;
@ -781,7 +808,7 @@ UINT8 *R_GetSpriteTranslation(vissprite_t *vis)
static void R_DrawVisSprite(vissprite_t *vis)
{
column_t *column;
void (*localcolfunc)(column_t *);
void (*localcolfunc)(column_t *, column_t *);
INT32 texturecolumn;
INT32 pwidth;
fixed_t frac;
@ -805,26 +832,27 @@ static void R_DrawVisSprite(vissprite_t *vis)
if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) return; // ditto
}
colfunc = colfuncs[BASEDRAWFUNC]; // hack: this isn't resetting properly somewhere.
R_SetColumnFunc(BASEDRAWFUNC, false); // hack: this isn't resetting properly somewhere.
dc_colormap = vis->colormap;
dc_fullbright = colormaps;
dc_translation = R_GetSpriteTranslation(vis);
if (R_SpriteIsFlashing(vis)) // Bosses "flash"
colfunc = colfuncs[COLDRAWFUNC_TRANS]; // translate certain pixels to white
R_SetColumnFunc(COLDRAWFUNC_TRANS, false); // translate certain pixels to white
else if (vis->mobj->color && vis->transmap) // Color mapping
{
colfunc = colfuncs[COLDRAWFUNC_TRANSTRANS];
R_SetColumnFunc(COLDRAWFUNC_TRANSTRANS, false);
dc_transmap = vis->transmap;
}
else if (vis->transmap)
{
colfunc = colfuncs[COLDRAWFUNC_FUZZY];
R_SetColumnFunc(COLDRAWFUNC_FUZZY, false);
dc_transmap = vis->transmap; //Fab : 29-04-98: translucency table
}
else if (vis->mobj->color) // translate green skin to another color
colfunc = colfuncs[COLDRAWFUNC_TRANS];
R_SetColumnFunc(COLDRAWFUNC_TRANS, false);
else if (vis->mobj->sprite == SPR_PLAY) // Looks like a player, but doesn't have a color? Get rid of green sonic syndrome.
colfunc = colfuncs[COLDRAWFUNC_TRANS];
R_SetColumnFunc(COLDRAWFUNC_TRANS, false);
if (vis->extra_colormap && !(vis->renderflags & RF_NOCOLORMAPS))
{
@ -836,8 +864,13 @@ static void R_DrawVisSprite(vissprite_t *vis)
if (!dc_colormap)
dc_colormap = colormaps;
dc_fullbright = colormaps;
if (encoremap && !vis->mobj->color && !(vis->mobj->flags & MF_DONTENCOREMAP))
{
dc_colormap += COLORMAP_REMAPOFFSET;
dc_fullbright += COLORMAP_REMAPOFFSET;
}
dc_texturemid = vis->texturemid;
dc_texheight = 0;
@ -910,7 +943,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn]));
localcolfunc (column);
localcolfunc (column, NULL);
}
}
else if (vis->cut & SC_SHEAR)
@ -932,7 +965,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
#endif
sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale));
localcolfunc (column);
localcolfunc (column, NULL);
}
}
else
@ -952,11 +985,11 @@ static void R_DrawVisSprite(vissprite_t *vis)
#else
column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[frac>>FRACBITS]));
#endif
localcolfunc (column);
localcolfunc (column, NULL);
}
}
colfunc = colfuncs[BASEDRAWFUNC];
R_SetColumnFunc(BASEDRAWFUNC, false);
dc_hires = 0;
vis->x1 = x1;
@ -986,13 +1019,17 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
if (vis->transmap)
{
colfunc = colfuncs[COLDRAWFUNC_FUZZY];
R_SetColumnFunc(COLDRAWFUNC_FUZZY, false);
dc_transmap = vis->transmap; //Fab : 29-04-98: translucency table
}
dc_colormap = colormaps;
dc_fullbright = colormaps;
if (encoremap)
{
dc_colormap += COLORMAP_REMAPOFFSET;
dc_fullbright += COLORMAP_REMAPOFFSET;
}
dc_iscale = FixedDiv(FRACUNIT, vis->scale);
dc_texturemid = vis->texturemid;
@ -1021,10 +1058,10 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
#else
column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[frac>>FRACBITS]));
#endif
R_DrawMaskedColumn(column);
R_DrawMaskedColumn(column, NULL);
}
colfunc = colfuncs[BASEDRAWFUNC];
R_SetColumnFunc(BASEDRAWFUNC, false);
}
//

View file

@ -47,8 +47,8 @@ extern fixed_t windowtop;
extern fixed_t windowbottom;
extern INT32 lengthcol;
void R_DrawMaskedColumn(column_t *column);
void R_DrawFlippedMaskedColumn(column_t *column);
void R_DrawMaskedColumn(column_t *column, column_t *brightmap);
void R_DrawFlippedMaskedColumn(column_t *column, column_t *brightmap);
// ----------------
// SPRITE RENDERING

View file

@ -49,10 +49,13 @@
// --------------------------------------------
void (*colfunc)(void);
void (*colfuncs[COLDRAWFUNC_MAX])(void);
void (*colfuncs_asm[COLDRAWFUNC_MAX])(void);
int colfunctype;
void (*spanfunc)(void);
void (*spanfuncs[SPANDRAWFUNC_MAX])(void);
void (*spanfuncs_npo2[SPANDRAWFUNC_MAX])(void);
void (*spanfuncs_asm[SPANDRAWFUNC_MAX])(void);
// ------------------
// global video state
@ -118,9 +121,6 @@ void SCR_SetDrawFuncs(void)
colfuncs[BASEDRAWFUNC] = R_DrawColumn_8;
spanfuncs[BASEDRAWFUNC] = R_DrawSpan_8;
colfunc = colfuncs[BASEDRAWFUNC];
spanfunc = spanfuncs[BASEDRAWFUNC];
colfuncs[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_8;
colfuncs[COLDRAWFUNC_TRANS] = R_DrawTranslatedColumn_8;
colfuncs[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8;
@ -165,21 +165,24 @@ void SCR_SetDrawFuncs(void)
{
if (R_MMX)
{
colfuncs[BASEDRAWFUNC] = R_DrawColumn_8_MMX;
//colfuncs[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8_ASM;
//colfuncs[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_8_ASM;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_8_MMX;
spanfuncs[BASEDRAWFUNC] = R_DrawSpan_8_MMX;
colfuncs_asm[BASEDRAWFUNC] = R_DrawColumn_8_MMX;
//colfuncs_asm[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8_ASM;
//colfuncs_asm[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_8_ASM;
colfuncs_asm[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_8_MMX;
spanfuncs_asm[BASEDRAWFUNC] = R_DrawSpan_8_MMX;
}
else
{
colfuncs[BASEDRAWFUNC] = R_DrawColumn_8_ASM;
//colfuncs[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8_ASM;
//colfuncs[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_8_ASM;
colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_8_ASM;
colfuncs_asm[BASEDRAWFUNC] = R_DrawColumn_8_ASM;
//colfuncs_asm[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8_ASM;
//colfuncs_asm[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_8_ASM;
colfuncs_asm[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_8_ASM;
}
}
#endif
R_SetColumnFunc(BASEDRAWFUNC, false);
R_SetSpanFunc(BASEDRAWFUNC, false, false);
}
/* else if (vid.bpp > 1)
{
@ -201,6 +204,61 @@ void SCR_SetDrawFuncs(void)
*/
}
void R_SetColumnFunc(size_t id, boolean brightmapped)
{
I_Assert(id < COLDRAWFUNC_MAX);
colfunctype = id;
if (colfuncs_asm[id] != NULL && brightmapped == false)
{
colfunc = colfuncs_asm[id];
}
else
{
colfunc = colfuncs[id];
}
}
void R_SetSpanFunc(size_t id, boolean npo2, boolean brightmapped)
{
I_Assert(id < COLDRAWFUNC_MAX);
if (spanfuncs_npo2[id] != NULL && npo2 == true)
{
spanfunc = spanfuncs_npo2[id];
}
else if (spanfuncs_asm[id] != NULL && brightmapped == false)
{
spanfunc = spanfuncs_asm[id];
}
else
{
spanfunc = spanfuncs[id];
}
}
boolean R_CheckColumnFunc(size_t id)
{
size_t i;
if (colfunc == NULL)
{
// Shouldn't happen.
return false;
}
for (i = 0; i < COLDRAWFUNC_MAX; i++)
{
if (colfunc == colfuncs[id] || colfunc == colfuncs_asm[id])
{
return true;
}
}
return false;
}
void SCR_SetMode(void)
{
if (dedicated)

View file

@ -135,6 +135,8 @@ enum
extern void (*colfunc)(void);
extern void (*colfuncs[COLDRAWFUNC_MAX])(void);
extern void (*colfuncs_asm[COLDRAWFUNC_MAX])(void);
extern int colfunctype;
enum
{
@ -163,6 +165,7 @@ enum
extern void (*spanfunc)(void);
extern void (*spanfuncs[SPANDRAWFUNC_MAX])(void);
extern void (*spanfuncs_npo2[SPANDRAWFUNC_MAX])(void);
extern void (*spanfuncs_asm[SPANDRAWFUNC_MAX])(void);
// -----
// CPUID
@ -205,6 +208,13 @@ void SCR_SetMode(void);
// Set drawer functions for Software
void SCR_SetDrawFuncs(void);
// Set current column / span drawers
void R_SetColumnFunc(size_t id, boolean brightmapped);
void R_SetSpanFunc(size_t id, boolean npo2, boolean brightmapped);
// Compare current column drawer
boolean R_CheckColumnFunc(size_t id);
// Recalc screen size dependent stuff
void SCR_Recalc(void);