mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Support for patches and textures to be used in place of sector flats
Still a work in progress.
This commit is contained in:
parent
addf2bb3c4
commit
714c997aac
14 changed files with 841 additions and 535 deletions
|
@ -2699,7 +2699,7 @@ static void readtexture(MYFILE *f, const char *name)
|
|||
char *word;
|
||||
char *word2;
|
||||
char *tmp;
|
||||
INT32 i, j, value;
|
||||
INT32 i, value;
|
||||
UINT16 width = 0, height = 0;
|
||||
INT16 patchcount = 0;
|
||||
texture_t *texture;
|
||||
|
@ -2783,13 +2783,8 @@ static void readtexture(MYFILE *f, const char *name)
|
|||
while (textures[i])
|
||||
i++;
|
||||
|
||||
// Fill the global texture buffer entries.
|
||||
j = 1;
|
||||
while (j << 1 <= texture->width)
|
||||
j <<= 1;
|
||||
|
||||
textures[i] = texture;
|
||||
texturewidthmask[i] = j - 1;
|
||||
texturewidth[i] = texture->width;
|
||||
textureheight[i] = texture->height << FRACBITS;
|
||||
|
||||
// Clean up.
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "../z_zone.h"
|
||||
#include "../v_video.h"
|
||||
#include "../r_draw.h"
|
||||
#include "../p_setup.h"
|
||||
|
||||
//Hurdler: 25/04/2000: used for new colormap code in hardware mode
|
||||
//static UINT8 *gr_colormap = NULL; // by default it must be NULL ! (because colormap tables are not initialized)
|
||||
|
@ -551,11 +552,13 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm
|
|||
|
||||
static size_t gr_numtextures;
|
||||
static GLTexture_t *gr_textures; // for ALL Doom textures
|
||||
static GLTexture_t *gr_textures2;
|
||||
|
||||
void HWR_InitTextureCache(void)
|
||||
{
|
||||
gr_numtextures = 0;
|
||||
gr_textures = NULL;
|
||||
gr_textures2 = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -594,7 +597,10 @@ void HWR_FreeTextureCache(void)
|
|||
// texturecache info, we can free it
|
||||
if (gr_textures)
|
||||
free(gr_textures);
|
||||
if (gr_textures2)
|
||||
free(gr_textures2);
|
||||
gr_textures = NULL;
|
||||
gr_textures2 = NULL;
|
||||
gr_numtextures = 0;
|
||||
}
|
||||
|
||||
|
@ -612,6 +618,9 @@ void HWR_PrepLevelCache(size_t pnumtextures)
|
|||
gr_textures = calloc(pnumtextures, sizeof (*gr_textures));
|
||||
if (gr_textures == NULL)
|
||||
I_Error("3D can't alloc gr_textures");
|
||||
gr_textures2 = calloc(pnumtextures, sizeof (*gr_textures2));
|
||||
if (gr_textures2 == NULL)
|
||||
I_Error("3D can't alloc gr_textures2");
|
||||
}
|
||||
|
||||
void HWR_SetPalette(RGBA_t *palette)
|
||||
|
@ -642,7 +651,7 @@ GLTexture_t *HWR_GetTexture(INT32 tex)
|
|||
GLTexture_t *grtex;
|
||||
#ifdef PARANOIA
|
||||
if ((unsigned)tex >= gr_numtextures)
|
||||
I_Error(" HWR_GetTexture: tex >= numtextures\n");
|
||||
I_Error("HWR_GetTexture: tex >= numtextures\n");
|
||||
#endif
|
||||
grtex = &gr_textures[tex];
|
||||
|
||||
|
@ -657,6 +666,35 @@ GLTexture_t *HWR_GetTexture(INT32 tex)
|
|||
return grtex;
|
||||
}
|
||||
|
||||
// Lactozilla
|
||||
lumpnum_t gr_patchflat;
|
||||
|
||||
static void HWR_LoadPatchFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
|
||||
{
|
||||
patch_t *patch = (patch_t *)W_CacheLumpNum(flatlumpnum, PU_STATIC);
|
||||
|
||||
grMipmap->width = (UINT16)SHORT(patch->width);
|
||||
grMipmap->height = (UINT16)SHORT(patch->height);
|
||||
|
||||
R_FlatPatch(patch, Z_Malloc(grMipmap->width * grMipmap->height, PU_HWRCACHE, &grMipmap->grInfo.data));
|
||||
|
||||
Z_Free(patch);
|
||||
}
|
||||
|
||||
static void HWR_LoadTextureFlat(GLMipmap_t *grMipmap, INT32 texturenum)
|
||||
{
|
||||
// setup the texture info
|
||||
grMipmap->grInfo.smallLodLog2 = GR_LOD_LOG2_64;
|
||||
grMipmap->grInfo.largeLodLog2 = GR_LOD_LOG2_64;
|
||||
grMipmap->grInfo.aspectRatioLog2 = GR_ASPECT_LOG2_1x1;
|
||||
grMipmap->grInfo.format = GR_TEXFMT_P_8;
|
||||
grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
|
||||
|
||||
grMipmap->width = (UINT16)textures[texturenum]->width;
|
||||
grMipmap->height = (UINT16)textures[texturenum]->height;
|
||||
|
||||
R_FlatTexture(texturenum, Z_Malloc(grMipmap->width * grMipmap->height, PU_HWRCACHE, &grMipmap->grInfo.data));
|
||||
}
|
||||
|
||||
static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
|
||||
{
|
||||
|
@ -695,15 +733,20 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
|
|||
pflatsize = 64;
|
||||
break;
|
||||
}
|
||||
grMipmap->width = (UINT16)pflatsize;
|
||||
grMipmap->height = (UINT16)pflatsize;
|
||||
|
||||
// the flat raw data needn't be converted with palettized textures
|
||||
W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum),
|
||||
PU_HWRCACHE, &grMipmap->grInfo.data));
|
||||
if (R_CheckIfPatch(flatlumpnum))
|
||||
HWR_LoadPatchFlat(grMipmap, flatlumpnum);
|
||||
else
|
||||
{
|
||||
grMipmap->width = (UINT16)pflatsize;
|
||||
grMipmap->height = (UINT16)pflatsize;
|
||||
|
||||
// the flat raw data needn't be converted with palettized textures
|
||||
W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum),
|
||||
PU_HWRCACHE, &grMipmap->grInfo.data));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Download a Doom 'flat' to the hardware cache and make it ready for use
|
||||
void HWR_GetFlat(lumpnum_t flatlumpnum)
|
||||
{
|
||||
|
@ -718,6 +761,30 @@ void HWR_GetFlat(lumpnum_t flatlumpnum)
|
|||
|
||||
// The system-memory data can be purged now.
|
||||
Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED);
|
||||
|
||||
gr_patchflat = 0;
|
||||
if (R_CheckIfPatch(flatlumpnum))
|
||||
gr_patchflat = flatlumpnum;
|
||||
}
|
||||
|
||||
void HWR_GetTextureFlat(INT32 texturenum)
|
||||
{
|
||||
GLTexture_t *grtex;
|
||||
#ifdef PARANOIA
|
||||
if ((unsigned)texturenum >= gr_numtextures)
|
||||
I_Error("HWR_GetTextureFlat: texturenum >= numtextures\n");
|
||||
#endif
|
||||
if (texturenum == 0 || texturenum == -1)
|
||||
return;
|
||||
grtex = &gr_textures2[texturenum];
|
||||
|
||||
if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded)
|
||||
HWR_LoadTextureFlat(&grtex->mipmap, texturenum);
|
||||
|
||||
HWD.pfnSetTexture(&grtex->mipmap);
|
||||
|
||||
// The system-memory data can be purged now.
|
||||
Z_ChangeTag(grtex->mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -101,6 +101,7 @@ void HWR_FreeTextureCache(void);
|
|||
void HWR_FreeExtraSubsectors(void);
|
||||
|
||||
void HWR_GetFlat(lumpnum_t flatlumpnum);
|
||||
void HWR_GetTextureFlat(INT32 texturenum);
|
||||
GLTexture_t *HWR_GetTexture(INT32 tex);
|
||||
void HWR_GetPatch(GLPatch_t *gpatch);
|
||||
void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap);
|
||||
|
@ -114,6 +115,8 @@ void HWR_GetFadeMask(lumpnum_t fademasklumpnum);
|
|||
// --------
|
||||
// hw_draw.c
|
||||
// --------
|
||||
extern lumpnum_t gr_patchflat;
|
||||
|
||||
extern float gr_patch_scalex;
|
||||
extern float gr_patch_scaley;
|
||||
|
||||
|
|
|
@ -70,9 +70,9 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing);
|
|||
#endif
|
||||
|
||||
#ifdef SORTING
|
||||
void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight,
|
||||
void HWR_AddTransparentFloor(lumpnum_t lumpnum, INT32 texturenum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight,
|
||||
INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap);
|
||||
void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight,
|
||||
void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, INT32 texturenum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight,
|
||||
INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap);
|
||||
#else
|
||||
static void HWR_Add3DWater(lumpnum_t lumpnum, extrasubsector_t *xsub, fixed_t fixedheight,
|
||||
|
@ -522,7 +522,7 @@ static UINT8 HWR_FogBlockAlpha(INT32 light, UINT32 color) // Let's see if this c
|
|||
// HWR_RenderPlane : Render a floor or ceiling convex polygon
|
||||
// -----------------+
|
||||
static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight,
|
||||
FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, boolean fogplane, extracolormap_t *planecolormap)
|
||||
FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, INT32 texturenum, sector_t *FOFsector, UINT8 alpha, boolean fogplane, extracolormap_t *planecolormap)
|
||||
{
|
||||
polyvertex_t * pv;
|
||||
float height; //constant y for all points on the convex flat polygon
|
||||
|
@ -530,8 +530,7 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
|
|||
INT32 nrPlaneVerts; //verts original define of convex flat polygon
|
||||
INT32 i;
|
||||
float flatxref,flatyref;
|
||||
float fflatsize;
|
||||
INT32 flatflag;
|
||||
float fflatwidth, fflatheight;
|
||||
size_t len;
|
||||
float scrollx = 0.0f, scrolly = 0.0f;
|
||||
angle_t angle = 0;
|
||||
|
@ -540,6 +539,7 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
|
|||
#ifdef ESLOPE
|
||||
pslope_t *slope = NULL;
|
||||
#endif
|
||||
patch_t *patch;
|
||||
|
||||
static FOutVector *planeVerts = NULL;
|
||||
static UINT16 numAllocedPlaneVerts = 0;
|
||||
|
@ -599,38 +599,44 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
|
|||
switch (len)
|
||||
{
|
||||
case 4194304: // 2048x2048 lump
|
||||
fflatsize = 2048.0f;
|
||||
flatflag = 2047;
|
||||
fflatwidth = fflatheight = 2048.0f;
|
||||
break;
|
||||
case 1048576: // 1024x1024 lump
|
||||
fflatsize = 1024.0f;
|
||||
flatflag = 1023;
|
||||
fflatwidth = fflatheight = 1024.0f;
|
||||
break;
|
||||
case 262144:// 512x512 lump
|
||||
fflatsize = 512.0f;
|
||||
flatflag = 511;
|
||||
fflatwidth = fflatheight = 512.0f;
|
||||
break;
|
||||
case 65536: // 256x256 lump
|
||||
fflatsize = 256.0f;
|
||||
flatflag = 255;
|
||||
fflatwidth = fflatheight = 256.0f;
|
||||
break;
|
||||
case 16384: // 128x128 lump
|
||||
fflatsize = 128.0f;
|
||||
flatflag = 127;
|
||||
fflatwidth = fflatheight = 128.0f;
|
||||
break;
|
||||
case 1024: // 32x32 lump
|
||||
fflatsize = 32.0f;
|
||||
flatflag = 31;
|
||||
fflatwidth = fflatheight = 32.0f;
|
||||
break;
|
||||
default: // 64x64 lump
|
||||
fflatsize = 64.0f;
|
||||
flatflag = 63;
|
||||
fflatwidth = fflatheight = 64.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
if (gr_patchflat && R_CheckIfPatch(gr_patchflat)) // Just in case?
|
||||
{
|
||||
patch = (patch_t *)W_CacheLumpNum(gr_patchflat, PU_STATIC);
|
||||
fflatwidth = patch->width;
|
||||
fflatheight = patch->height;
|
||||
}
|
||||
|
||||
if (texturenum != 0 && texturenum != -1)
|
||||
{
|
||||
fflatwidth = textures[texturenum]->width;
|
||||
fflatheight = textures[texturenum]->height;
|
||||
}
|
||||
|
||||
// reference point for flat texture coord for each vertex around the polygon
|
||||
flatxref = (float)(((fixed_t)pv->x & (~flatflag)) / fflatsize);
|
||||
flatyref = (float)(((fixed_t)pv->y & (~flatflag)) / fflatsize);
|
||||
flatxref = (float)((FLOAT_TO_FIXED(pv->x) % llrint(fflatwidth)) / fflatwidth);
|
||||
flatyref = (float)((FLOAT_TO_FIXED(pv->y) % llrint(fflatheight)) / fflatheight);
|
||||
|
||||
// transform
|
||||
v3d = planeVerts;
|
||||
|
@ -639,14 +645,14 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
|
|||
{
|
||||
if (!isceiling) // it's a floor
|
||||
{
|
||||
scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatsize;
|
||||
scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatsize;
|
||||
scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatwidth;
|
||||
scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatheight;
|
||||
angle = FOFsector->floorpic_angle>>ANGLETOFINESHIFT;
|
||||
}
|
||||
else // it's a ceiling
|
||||
{
|
||||
scrollx = FIXED_TO_FLOAT(FOFsector->ceiling_xoffs)/fflatsize;
|
||||
scrolly = FIXED_TO_FLOAT(FOFsector->ceiling_yoffs)/fflatsize;
|
||||
scrollx = FIXED_TO_FLOAT(FOFsector->ceiling_xoffs)/fflatwidth;
|
||||
scrolly = FIXED_TO_FLOAT(FOFsector->ceiling_yoffs)/fflatheight;
|
||||
angle = FOFsector->ceilingpic_angle>>ANGLETOFINESHIFT;
|
||||
}
|
||||
}
|
||||
|
@ -654,14 +660,14 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
|
|||
{
|
||||
if (!isceiling) // it's a floor
|
||||
{
|
||||
scrollx = FIXED_TO_FLOAT(gr_frontsector->floor_xoffs)/fflatsize;
|
||||
scrolly = FIXED_TO_FLOAT(gr_frontsector->floor_yoffs)/fflatsize;
|
||||
scrollx = FIXED_TO_FLOAT(gr_frontsector->floor_xoffs)/fflatwidth;
|
||||
scrolly = FIXED_TO_FLOAT(gr_frontsector->floor_yoffs)/fflatheight;
|
||||
angle = gr_frontsector->floorpic_angle>>ANGLETOFINESHIFT;
|
||||
}
|
||||
else // it's a ceiling
|
||||
{
|
||||
scrollx = FIXED_TO_FLOAT(gr_frontsector->ceiling_xoffs)/fflatsize;
|
||||
scrolly = FIXED_TO_FLOAT(gr_frontsector->ceiling_yoffs)/fflatsize;
|
||||
scrollx = FIXED_TO_FLOAT(gr_frontsector->ceiling_xoffs)/fflatwidth;
|
||||
scrolly = FIXED_TO_FLOAT(gr_frontsector->ceiling_yoffs)/fflatheight;
|
||||
angle = gr_frontsector->ceilingpic_angle>>ANGLETOFINESHIFT;
|
||||
}
|
||||
}
|
||||
|
@ -686,8 +692,8 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
|
|||
for (i = 0; i < nrPlaneVerts; i++,v3d++,pv++)
|
||||
{
|
||||
// Hurdler: add scrolling texture on floor/ceiling
|
||||
v3d->sow = (float)((pv->x / fflatsize) - flatxref + scrollx);
|
||||
v3d->tow = (float)(flatyref - (pv->y / fflatsize) + scrolly);
|
||||
v3d->sow = (float)((pv->x / fflatwidth) - flatxref + scrollx);
|
||||
v3d->tow = (float)(flatyref - (pv->y / fflatheight) + scrolly);
|
||||
|
||||
//v3d->sow = (float)(pv->x / fflatsize);
|
||||
//v3d->tow = (float)(pv->y / fflatsize);
|
||||
|
@ -3145,21 +3151,21 @@ static inline void HWR_AddPolyObjectSegs(void)
|
|||
|
||||
#ifdef POLYOBJECTS_PLANES
|
||||
static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight,
|
||||
FBITFIELD blendmode, UINT8 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector,
|
||||
FBITFIELD blendmode, UINT8 lightlevel, lumpnum_t lumpnum, INT32 texturenum, sector_t *FOFsector,
|
||||
UINT8 alpha, extracolormap_t *planecolormap)
|
||||
{
|
||||
float height; //constant y for all points on the convex flat polygon
|
||||
FOutVector *v3d;
|
||||
INT32 i;
|
||||
float flatxref,flatyref;
|
||||
float fflatsize;
|
||||
INT32 flatflag;
|
||||
float fflatwidth, fflatheight;
|
||||
size_t len;
|
||||
float scrollx = 0.0f, scrolly = 0.0f;
|
||||
angle_t angle = 0;
|
||||
FSurfaceInfo Surf;
|
||||
fixed_t tempxsow, tempytow;
|
||||
size_t nrPlaneVerts;
|
||||
patch_t *patch;
|
||||
|
||||
static FOutVector *planeVerts = NULL;
|
||||
static UINT16 numAllocedPlaneVerts = 0;
|
||||
|
@ -3190,38 +3196,44 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
|||
switch (len)
|
||||
{
|
||||
case 4194304: // 2048x2048 lump
|
||||
fflatsize = 2048.0f;
|
||||
flatflag = 2047;
|
||||
fflatwidth = fflatheight = 2048.0f;
|
||||
break;
|
||||
case 1048576: // 1024x1024 lump
|
||||
fflatsize = 1024.0f;
|
||||
flatflag = 1023;
|
||||
fflatwidth = fflatheight = 1024.0f;
|
||||
break;
|
||||
case 262144:// 512x512 lump
|
||||
fflatsize = 512.0f;
|
||||
flatflag = 511;
|
||||
fflatwidth = fflatheight = 512.0f;
|
||||
break;
|
||||
case 65536: // 256x256 lump
|
||||
fflatsize = 256.0f;
|
||||
flatflag = 255;
|
||||
fflatwidth = fflatheight = 256.0f;
|
||||
break;
|
||||
case 16384: // 128x128 lump
|
||||
fflatsize = 128.0f;
|
||||
flatflag = 127;
|
||||
fflatwidth = fflatheight = 128.0f;
|
||||
break;
|
||||
case 1024: // 32x32 lump
|
||||
fflatsize = 32.0f;
|
||||
flatflag = 31;
|
||||
fflatwidth = fflatheight = 32.0f;
|
||||
break;
|
||||
default: // 64x64 lump
|
||||
fflatsize = 64.0f;
|
||||
flatflag = 63;
|
||||
fflatwidth = fflatheight = 64.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
if (gr_patchflat && R_CheckIfPatch(gr_patchflat)) // Just in case?
|
||||
{
|
||||
patch = (patch_t *)W_CacheLumpNum(gr_patchflat, PU_STATIC);
|
||||
fflatwidth = patch->width;
|
||||
fflatheight = patch->height;
|
||||
}
|
||||
|
||||
if (texturenum != 0 && texturenum != -1)
|
||||
{
|
||||
fflatwidth = textures[texturenum]->width;
|
||||
fflatheight = textures[texturenum]->height;
|
||||
}
|
||||
|
||||
// reference point for flat texture coord for each vertex around the polygon
|
||||
flatxref = (float)(((fixed_t)FIXED_TO_FLOAT(polysector->origVerts[0].x) & (~flatflag)) / fflatsize);
|
||||
flatyref = (float)(((fixed_t)FIXED_TO_FLOAT(polysector->origVerts[0].y) & (~flatflag)) / fflatsize);
|
||||
flatxref = (float)((polysector->origVerts[0].x % llrint(fflatwidth)) / fflatwidth);
|
||||
flatyref = (float)((polysector->origVerts[0].y % llrint(fflatheight)) / fflatheight);
|
||||
|
||||
// transform
|
||||
v3d = planeVerts;
|
||||
|
@ -3230,14 +3242,14 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
|||
{
|
||||
if (!isceiling) // it's a floor
|
||||
{
|
||||
scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatsize;
|
||||
scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatsize;
|
||||
scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatwidth;
|
||||
scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatheight;
|
||||
angle = FOFsector->floorpic_angle>>ANGLETOFINESHIFT;
|
||||
}
|
||||
else // it's a ceiling
|
||||
{
|
||||
scrollx = FIXED_TO_FLOAT(FOFsector->ceiling_xoffs)/fflatsize;
|
||||
scrolly = FIXED_TO_FLOAT(FOFsector->ceiling_yoffs)/fflatsize;
|
||||
scrollx = FIXED_TO_FLOAT(FOFsector->ceiling_xoffs)/fflatwidth;
|
||||
scrolly = FIXED_TO_FLOAT(FOFsector->ceiling_yoffs)/fflatheight;
|
||||
angle = FOFsector->ceilingpic_angle>>ANGLETOFINESHIFT;
|
||||
}
|
||||
}
|
||||
|
@ -3245,14 +3257,14 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
|||
{
|
||||
if (!isceiling) // it's a floor
|
||||
{
|
||||
scrollx = FIXED_TO_FLOAT(gr_frontsector->floor_xoffs)/fflatsize;
|
||||
scrolly = FIXED_TO_FLOAT(gr_frontsector->floor_yoffs)/fflatsize;
|
||||
scrollx = FIXED_TO_FLOAT(gr_frontsector->floor_xoffs)/fflatwidth;
|
||||
scrolly = FIXED_TO_FLOAT(gr_frontsector->floor_yoffs)/fflatheight;
|
||||
angle = gr_frontsector->floorpic_angle>>ANGLETOFINESHIFT;
|
||||
}
|
||||
else // it's a ceiling
|
||||
{
|
||||
scrollx = FIXED_TO_FLOAT(gr_frontsector->ceiling_xoffs)/fflatsize;
|
||||
scrolly = FIXED_TO_FLOAT(gr_frontsector->ceiling_yoffs)/fflatsize;
|
||||
scrollx = FIXED_TO_FLOAT(gr_frontsector->ceiling_xoffs)/fflatwidth;
|
||||
scrolly = FIXED_TO_FLOAT(gr_frontsector->ceiling_yoffs)/fflatheight;
|
||||
angle = gr_frontsector->ceilingpic_angle>>ANGLETOFINESHIFT;
|
||||
}
|
||||
}
|
||||
|
@ -3276,8 +3288,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
|||
for (i = 0; i < (INT32)nrPlaneVerts; i++,v3d++)
|
||||
{
|
||||
// Hurdler: add scrolling texture on floor/ceiling
|
||||
v3d->sow = (float)((FIXED_TO_FLOAT(polysector->origVerts[i].x) / fflatsize) - flatxref + scrollx); // Go from the polysector's original vertex locations
|
||||
v3d->tow = (float)(flatyref - (FIXED_TO_FLOAT(polysector->origVerts[i].y) / fflatsize) + scrolly); // Means the flat is offset based on the original vertex locations
|
||||
v3d->sow = (float)((FIXED_TO_FLOAT(polysector->origVerts[i].x) / fflatwidth) - flatxref + scrollx); // Go from the polysector's original vertex locations
|
||||
v3d->tow = (float)(flatyref - (FIXED_TO_FLOAT(polysector->origVerts[i].y) / fflatheight) + scrolly); // Means the flat is offset based on the original vertex locations
|
||||
|
||||
// Need to rotate before translate
|
||||
if (angle) // Only needs to be done if there's an altered angle
|
||||
|
@ -3336,14 +3348,15 @@ static void HWR_AddPolyObjectPlanes(void)
|
|||
{
|
||||
FSurfaceInfo Surf;
|
||||
FBITFIELD blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf);
|
||||
HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, po_ptrs[i], false, polyobjsector->floorheight,
|
||||
HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, levelflats[polyobjsector->floorpic].texturenum, po_ptrs[i], false, polyobjsector->floorheight,
|
||||
polyobjsector->lightlevel, Surf.FlatColor.s.alpha, polyobjsector, blendmode, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
HWR_GetFlat(levelflats[polyobjsector->floorpic].lumpnum);
|
||||
HWR_GetTextureFlat(levelflats[polyobjsector->floorpic].texturenum);
|
||||
HWR_RenderPolyObjectPlane(po_ptrs[i], false, polyobjsector->floorheight, PF_Occlude,
|
||||
polyobjsector->lightlevel, levelflats[polyobjsector->floorpic].lumpnum,
|
||||
polyobjsector->lightlevel, levelflats[polyobjsector->floorpic].lumpnum, levelflats[polyobjsector->floorpic].texturenum,
|
||||
polyobjsector, 255, NULL);
|
||||
}
|
||||
}
|
||||
|
@ -3358,14 +3371,15 @@ static void HWR_AddPolyObjectPlanes(void)
|
|||
FBITFIELD blendmode;
|
||||
memset(&Surf, 0x00, sizeof(Surf));
|
||||
blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf);
|
||||
HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, po_ptrs[i], true, polyobjsector->ceilingheight,
|
||||
HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, levelflats[polyobjsector->ceilingpic].texturenum, po_ptrs[i], true, polyobjsector->ceilingheight,
|
||||
polyobjsector->lightlevel, Surf.FlatColor.s.alpha, polyobjsector, blendmode, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
HWR_GetFlat(levelflats[polyobjsector->ceilingpic].lumpnum);
|
||||
HWR_GetTextureFlat(levelflats[polyobjsector->ceilingpic].texturenum);
|
||||
HWR_RenderPolyObjectPlane(po_ptrs[i], true, polyobjsector->ceilingheight, PF_Occlude,
|
||||
polyobjsector->lightlevel, levelflats[polyobjsector->floorpic].lumpnum,
|
||||
polyobjsector->lightlevel, levelflats[polyobjsector->floorpic].lumpnum, levelflats[polyobjsector->floorpic].texturenum,
|
||||
polyobjsector, 255, NULL);
|
||||
}
|
||||
}
|
||||
|
@ -3517,11 +3531,12 @@ static void HWR_Subsector(size_t num)
|
|||
if (sub->validcount != validcount)
|
||||
{
|
||||
HWR_GetFlat(levelflats[gr_frontsector->floorpic].lumpnum);
|
||||
HWR_GetTextureFlat(levelflats[gr_frontsector->floorpic].texturenum);
|
||||
HWR_RenderPlane(gr_frontsector, &extrasubsectors[num], false,
|
||||
// Hack to make things continue to work around slopes.
|
||||
locFloorHeight == cullFloorHeight ? locFloorHeight : gr_frontsector->floorheight,
|
||||
// We now return you to your regularly scheduled rendering.
|
||||
PF_Occlude, floorlightlevel, levelflats[gr_frontsector->floorpic].lumpnum, NULL, 255, false, floorcolormap);
|
||||
PF_Occlude, floorlightlevel, levelflats[gr_frontsector->floorpic].lumpnum, levelflats[gr_frontsector->floorpic].texturenum, NULL, 255, false, floorcolormap);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -3539,11 +3554,12 @@ static void HWR_Subsector(size_t num)
|
|||
if (sub->validcount != validcount)
|
||||
{
|
||||
HWR_GetFlat(levelflats[gr_frontsector->ceilingpic].lumpnum);
|
||||
HWR_GetTextureFlat(levelflats[gr_frontsector->ceilingpic].texturenum);
|
||||
HWR_RenderPlane(NULL, &extrasubsectors[num], true,
|
||||
// Hack to make things continue to work around slopes.
|
||||
locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gr_frontsector->ceilingheight,
|
||||
// We now return you to your regularly scheduled rendering.
|
||||
PF_Occlude, ceilinglightlevel, levelflats[gr_frontsector->ceilingpic].lumpnum,NULL, 255, false, ceilingcolormap);
|
||||
PF_Occlude, ceilinglightlevel, levelflats[gr_frontsector->ceilingpic].lumpnum, levelflats[gr_frontsector->ceilingpic].texturenum, NULL, 255, false, ceilingcolormap);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -3602,7 +3618,7 @@ static void HWR_Subsector(size_t num)
|
|||
else
|
||||
alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, NORMALFOG);
|
||||
|
||||
HWR_AddTransparentFloor(0,
|
||||
HWR_AddTransparentFloor(0, 0,
|
||||
&extrasubsectors[num],
|
||||
false,
|
||||
*rover->bottomheight,
|
||||
|
@ -3621,6 +3637,7 @@ static void HWR_Subsector(size_t num)
|
|||
rover->alpha-1, rover->master->frontsector);
|
||||
#else
|
||||
HWR_AddTransparentFloor(levelflats[*rover->bottompic].lumpnum,
|
||||
levelflats[*rover->bottompic].texturenum,
|
||||
&extrasubsectors[num],
|
||||
false,
|
||||
*rover->bottomheight,
|
||||
|
@ -3632,8 +3649,9 @@ static void HWR_Subsector(size_t num)
|
|||
else
|
||||
{
|
||||
HWR_GetFlat(levelflats[*rover->bottompic].lumpnum);
|
||||
HWR_GetTextureFlat(levelflats[*rover->bottompic].texturenum);
|
||||
light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false);
|
||||
HWR_RenderPlane(NULL, &extrasubsectors[num], false, *rover->bottomheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum,
|
||||
HWR_RenderPlane(NULL, &extrasubsectors[num], false, *rover->bottomheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum, levelflats[*rover->bottompic].texturenum,
|
||||
rover->master->frontsector, 255, false, gr_frontsector->lightlist[light].extra_colormap);
|
||||
}
|
||||
}
|
||||
|
@ -3665,7 +3683,7 @@ static void HWR_Subsector(size_t num)
|
|||
else
|
||||
alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, NORMALFOG);
|
||||
|
||||
HWR_AddTransparentFloor(0,
|
||||
HWR_AddTransparentFloor(0, 0,
|
||||
&extrasubsectors[num],
|
||||
true,
|
||||
*rover->topheight,
|
||||
|
@ -3684,6 +3702,7 @@ static void HWR_Subsector(size_t num)
|
|||
rover->alpha-1, rover->master->frontsector);
|
||||
#else
|
||||
HWR_AddTransparentFloor(levelflats[*rover->toppic].lumpnum,
|
||||
levelflats[*rover->bottompic].texturenum,
|
||||
&extrasubsectors[num],
|
||||
true,
|
||||
*rover->topheight,
|
||||
|
@ -3696,8 +3715,9 @@ static void HWR_Subsector(size_t num)
|
|||
else
|
||||
{
|
||||
HWR_GetFlat(levelflats[*rover->toppic].lumpnum);
|
||||
HWR_GetTextureFlat(levelflats[*rover->toppic].texturenum);
|
||||
light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false);
|
||||
HWR_RenderPlane(NULL, &extrasubsectors[num], true, *rover->topheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum,
|
||||
HWR_RenderPlane(NULL, &extrasubsectors[num], true, *rover->topheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, levelflats[*rover->toppic].texturenum,
|
||||
rover->master->frontsector, 255, false, gr_frontsector->lightlist[light].extra_colormap);
|
||||
}
|
||||
}
|
||||
|
@ -5021,6 +5041,7 @@ typedef struct
|
|||
fixed_t fixedheight;
|
||||
INT32 lightlevel;
|
||||
lumpnum_t lumpnum;
|
||||
INT32 texturenum;
|
||||
INT32 alpha;
|
||||
sector_t *FOFSector;
|
||||
FBITFIELD blend;
|
||||
|
@ -5039,6 +5060,7 @@ typedef struct
|
|||
fixed_t fixedheight;
|
||||
INT32 lightlevel;
|
||||
lumpnum_t lumpnum;
|
||||
INT32 texturenum;
|
||||
INT32 alpha;
|
||||
sector_t *FOFSector;
|
||||
FBITFIELD blend;
|
||||
|
@ -5071,7 +5093,7 @@ static INT32 drawcount = 0;
|
|||
#define MAX_TRANSPARENTFLOOR 512
|
||||
|
||||
// This will likely turn into a copy of HWR_Add3DWater and replace it.
|
||||
void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling,
|
||||
void HWR_AddTransparentFloor(lumpnum_t lumpnum, INT32 texturenum, extrasubsector_t *xsub, boolean isceiling,
|
||||
fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap)
|
||||
{
|
||||
static size_t allocedplanes = 0;
|
||||
|
@ -5090,6 +5112,7 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean
|
|||
planeinfo[numplanes].fixedheight = fixedheight;
|
||||
planeinfo[numplanes].lightlevel = lightlevel;
|
||||
planeinfo[numplanes].lumpnum = lumpnum;
|
||||
planeinfo[numplanes].texturenum = texturenum;
|
||||
planeinfo[numplanes].xsub = xsub;
|
||||
planeinfo[numplanes].alpha = alpha;
|
||||
planeinfo[numplanes].FOFSector = FOFSector;
|
||||
|
@ -5103,7 +5126,7 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean
|
|||
|
||||
// Adding this for now until I can create extrasubsector info for polyobjects
|
||||
// When that happens it'll just be done through HWR_AddTransparentFloor and HWR_RenderPlane
|
||||
void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling,
|
||||
void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, INT32 texturenum, polyobj_t *polysector, boolean isceiling,
|
||||
fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap)
|
||||
{
|
||||
static size_t allocedpolyplanes = 0;
|
||||
|
@ -5122,6 +5145,7 @@ void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector,
|
|||
polyplaneinfo[numpolyplanes].fixedheight = fixedheight;
|
||||
polyplaneinfo[numpolyplanes].lightlevel = lightlevel;
|
||||
polyplaneinfo[numpolyplanes].lumpnum = lumpnum;
|
||||
polyplaneinfo[numpolyplanes].texturenum = texturenum;
|
||||
polyplaneinfo[numpolyplanes].polysector = polysector;
|
||||
polyplaneinfo[numpolyplanes].alpha = alpha;
|
||||
polyplaneinfo[numpolyplanes].FOFSector = FOFSector;
|
||||
|
@ -5283,9 +5307,12 @@ static void HWR_CreateDrawNodes(void)
|
|||
gr_frontsector = NULL;
|
||||
|
||||
if (!(sortnode[sortindex[i]].plane->blend & PF_NoTexture))
|
||||
{
|
||||
HWR_GetFlat(sortnode[sortindex[i]].plane->lumpnum);
|
||||
HWR_GetTextureFlat(sortnode[sortindex[i]].plane->texturenum);
|
||||
}
|
||||
HWR_RenderPlane(NULL, sortnode[sortindex[i]].plane->xsub, sortnode[sortindex[i]].plane->isceiling, sortnode[sortindex[i]].plane->fixedheight, sortnode[sortindex[i]].plane->blend, sortnode[sortindex[i]].plane->lightlevel,
|
||||
sortnode[sortindex[i]].plane->lumpnum, sortnode[sortindex[i]].plane->FOFSector, sortnode[sortindex[i]].plane->alpha, sortnode[sortindex[i]].plane->fogplane, sortnode[sortindex[i]].plane->planecolormap);
|
||||
sortnode[sortindex[i]].plane->lumpnum, sortnode[sortindex[i]].plane->texturenum, sortnode[sortindex[i]].plane->FOFSector, sortnode[sortindex[i]].plane->alpha, sortnode[sortindex[i]].plane->fogplane, sortnode[sortindex[i]].plane->planecolormap);
|
||||
}
|
||||
else if (sortnode[sortindex[i]].polyplane)
|
||||
{
|
||||
|
@ -5293,9 +5320,12 @@ static void HWR_CreateDrawNodes(void)
|
|||
gr_frontsector = NULL;
|
||||
|
||||
if (!(sortnode[sortindex[i]].polyplane->blend & PF_NoTexture))
|
||||
{
|
||||
HWR_GetFlat(sortnode[sortindex[i]].polyplane->lumpnum);
|
||||
HWR_GetTextureFlat(sortnode[sortindex[i]].polyplane->texturenum);
|
||||
}
|
||||
HWR_RenderPolyObjectPlane(sortnode[sortindex[i]].polyplane->polysector, sortnode[sortindex[i]].polyplane->isceiling, sortnode[sortindex[i]].polyplane->fixedheight, sortnode[sortindex[i]].polyplane->blend, sortnode[sortindex[i]].polyplane->lightlevel,
|
||||
sortnode[sortindex[i]].polyplane->lumpnum, sortnode[sortindex[i]].polyplane->FOFSector, sortnode[sortindex[i]].polyplane->alpha, sortnode[sortindex[i]].polyplane->planecolormap);
|
||||
sortnode[sortindex[i]].polyplane->lumpnum, sortnode[sortindex[i]].polyplane->texturenum, sortnode[sortindex[i]].polyplane->FOFSector, sortnode[sortindex[i]].polyplane->alpha, sortnode[sortindex[i]].polyplane->planecolormap);
|
||||
}
|
||||
else if (sortnode[sortindex[i]].wall)
|
||||
{
|
||||
|
|
|
@ -564,6 +564,8 @@ INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat)
|
|||
|
||||
// store the flat lump number
|
||||
levelflat->lumpnum = R_GetFlatNumForName(flatname);
|
||||
// Lactozilla
|
||||
levelflat->texturenum = R_CheckTextureNumForName(flatname);
|
||||
|
||||
#ifndef ZDEBUG
|
||||
CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name);
|
||||
|
@ -608,6 +610,8 @@ INT32 P_AddLevelFlatRuntime(const char *flatname)
|
|||
|
||||
// store the flat lump number
|
||||
levelflat->lumpnum = R_GetFlatNumForName(flatname);
|
||||
// Lactozilla
|
||||
levelflat->texturenum = R_CheckTextureNumForName(flatname);
|
||||
|
||||
#ifndef ZDEBUG
|
||||
CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name);
|
||||
|
|
|
@ -42,6 +42,17 @@ typedef struct
|
|||
INT32 animseq; // start pos. in the anim sequence
|
||||
INT32 numpics;
|
||||
INT32 speed;
|
||||
|
||||
// Lactozilla
|
||||
UINT8 *flatpatch;
|
||||
UINT16 width, height;
|
||||
fixed_t topoffset, leftoffset;
|
||||
size_t texturenum;
|
||||
|
||||
#ifdef ESLOPE
|
||||
UINT8 *resizedflat;
|
||||
UINT16 resizedwidth, resizedheight;
|
||||
#endif
|
||||
} levelflat_t;
|
||||
|
||||
extern size_t numlevelflats;
|
||||
|
|
|
@ -322,8 +322,8 @@ void P_InitPicAnims(void)
|
|||
if ((W_CheckNumForName(animdefs[i].startname)) == LUMPERROR)
|
||||
continue;
|
||||
|
||||
lastanim->picnum = R_FlatNumForName(animdefs[i].endname);
|
||||
lastanim->basepic = R_FlatNumForName(animdefs[i].startname);
|
||||
lastanim->picnum = R_GetFlatNumForName(animdefs[i].endname);
|
||||
lastanim->basepic = R_GetFlatNumForName(animdefs[i].startname);
|
||||
}
|
||||
|
||||
lastanim->istexture = animdefs[i].istexture;
|
||||
|
|
204
src/r_data.c
204
src/r_data.c
|
@ -101,9 +101,7 @@ texture_t **textures = NULL;
|
|||
static UINT32 **texturecolumnofs; // column offset lookup table for each texture
|
||||
static UINT8 **texturecache; // graphics data for each generated full-size texture
|
||||
|
||||
// texture width is a power of 2, so it can easily repeat along sidedefs using a simple mask
|
||||
INT32 *texturewidthmask;
|
||||
|
||||
INT32 *texturewidth;
|
||||
fixed_t *textureheight; // needed for texture pegging
|
||||
|
||||
INT32 *texturetranslation;
|
||||
|
@ -335,10 +333,14 @@ void R_CheckTextureCache(INT32 tex)
|
|||
UINT8 *R_GetColumn(fixed_t tex, INT32 col)
|
||||
{
|
||||
UINT8 *data;
|
||||
INT32 width = texturewidth[tex];
|
||||
|
||||
if (width & (width - 1))
|
||||
col = (UINT32)col % width;
|
||||
else
|
||||
col &= (width - 1);
|
||||
|
||||
col &= texturewidthmask[tex];
|
||||
data = texturecache[tex];
|
||||
|
||||
if (!data)
|
||||
data = R_GenerateTexture(tex);
|
||||
|
||||
|
@ -376,7 +378,7 @@ void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *index);
|
|||
#define TX_END "TX_END"
|
||||
void R_LoadTextures(void)
|
||||
{
|
||||
INT32 i, k, w;
|
||||
INT32 i, w;
|
||||
UINT16 j;
|
||||
UINT16 texstart, texend, texturesLumpPos;
|
||||
patch_t *patchlump;
|
||||
|
@ -443,9 +445,9 @@ void R_LoadTextures(void)
|
|||
texturecolumnofs = (void *)((UINT8 *)textures + (numtextures * sizeof(void *)));
|
||||
// Allocate texture referencing cache.
|
||||
texturecache = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 2));
|
||||
// Allocate texture width mask table.
|
||||
texturewidthmask = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 3));
|
||||
// Allocate texture height mask table.
|
||||
// Allocate texture width table.
|
||||
texturewidth = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 3));
|
||||
// Allocate texture height table.
|
||||
textureheight = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 4));
|
||||
// Create translation table for global animation.
|
||||
texturetranslation = Z_Malloc((numtextures + 1) * sizeof(*texturetranslation), PU_STATIC, NULL);
|
||||
|
@ -513,11 +515,7 @@ void R_LoadTextures(void)
|
|||
|
||||
Z_Unlock(patchlump);
|
||||
|
||||
k = 1;
|
||||
while (k << 1 <= texture->width)
|
||||
k <<= 1;
|
||||
|
||||
texturewidthmask[i] = k - 1;
|
||||
texturewidth[i] = texture->width;
|
||||
textureheight[i] = texture->height << FRACBITS;
|
||||
}
|
||||
}
|
||||
|
@ -905,7 +903,7 @@ void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *texindex)
|
|||
newTexture = R_ParseTexture(true);
|
||||
// Store the new texture
|
||||
textures[*texindex] = newTexture;
|
||||
texturewidthmask[*texindex] = newTexture->width - 1;
|
||||
texturewidth[*texindex] = newTexture->width;
|
||||
textureheight[*texindex] = newTexture->height << FRACBITS;
|
||||
// Increment i back in R_LoadTextures()
|
||||
(*texindex)++;
|
||||
|
@ -1017,6 +1015,41 @@ lumpnum_t R_GetFlatNumForName(const char *name)
|
|||
lump = LUMPERROR;
|
||||
}
|
||||
|
||||
// Lactozilla
|
||||
if (lump == LUMPERROR)
|
||||
{
|
||||
// Scan wad files backwards so patched flats take preference.
|
||||
for (i = numwadfiles - 1; i >= 0; i--)
|
||||
{
|
||||
switch (wadfiles[i]->type)
|
||||
{
|
||||
case RET_WAD:
|
||||
if ((start = W_CheckNumForNamePwad("TX_START", (UINT16)i, 0)) == INT16_MAX)
|
||||
continue;
|
||||
if ((end = W_CheckNumForNamePwad("TX_END", (UINT16)i, start)) == INT16_MAX)
|
||||
continue;
|
||||
break;
|
||||
case RET_PK3:
|
||||
if ((start = W_CheckNumForFolderStartPK3("Textures/", i, 0)) == INT16_MAX)
|
||||
continue;
|
||||
if ((end = W_CheckNumForFolderEndPK3("Textures/", i, start)) == INT16_MAX)
|
||||
continue;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
// Now find lump with specified name in that range.
|
||||
lump = W_CheckNumForNamePwad(name, (UINT16)i, start);
|
||||
if (lump < end)
|
||||
{
|
||||
lump += (i<<16); // found it, in our constraints
|
||||
break;
|
||||
}
|
||||
lump = LUMPERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (lump == LUMPERROR)
|
||||
{
|
||||
if (strcmp(name, SKYFLATNAME))
|
||||
|
@ -1603,3 +1636,144 @@ void R_PrecacheLevel(void)
|
|||
"texturememory: %s k\n"
|
||||
"spritememory: %s k\n", sizeu1(flatmemory>>10), sizeu2(texturememory>>10), sizeu3(spritememory>>10));
|
||||
}
|
||||
|
||||
// https://github.com/coelckers/prboom-plus/blob/master/prboom2/src/r_patch.c#L350
|
||||
boolean R_CheckIfPatch(lumpnum_t lump)
|
||||
{
|
||||
size_t size;
|
||||
INT16 width, height;
|
||||
patch_t *patch;
|
||||
boolean result;
|
||||
|
||||
size = W_LumpLength(lump);
|
||||
|
||||
// minimum length of a valid Doom patch
|
||||
if (size < 13)
|
||||
return false;
|
||||
|
||||
patch = (patch_t *)W_CacheLumpNum(lump, PU_STATIC);
|
||||
|
||||
width = SHORT(patch->width);
|
||||
height = SHORT(patch->height);
|
||||
|
||||
result = (height > 0 && height <= 16384 && width > 0 && width <= 16384 && width < size / 4);
|
||||
|
||||
if (result)
|
||||
{
|
||||
// The dimensions seem like they might be valid for a patch, so
|
||||
// check the column directory for extra security. All columns
|
||||
// must begin after the column directory, and none of them must
|
||||
// point past the end of the patch.
|
||||
INT16 x;
|
||||
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
UINT32 ofs = LONG(patch->columnofs[x]);
|
||||
|
||||
// Need one byte for an empty column (but there's patches that don't know that!)
|
||||
if (ofs < (UINT32)width * 4 + 8 || ofs >= (UINT32)size)
|
||||
{
|
||||
result = false;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Z_Free(patch);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Lactozilla
|
||||
void R_FlatPatch(patch_t *patch, UINT8 *flat)
|
||||
{
|
||||
fixed_t col, ofs;
|
||||
column_t *column;
|
||||
UINT8 *desttop, *dest, *deststop;
|
||||
UINT8 *source;
|
||||
|
||||
desttop = flat;
|
||||
deststop = desttop + (patch->width * patch->height);
|
||||
|
||||
for (col = 0; col < SHORT(patch->width); col++, desttop++)
|
||||
{
|
||||
INT32 topdelta, prevdelta = -1;
|
||||
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[col]));
|
||||
|
||||
while (column->topdelta != 0xff)
|
||||
{
|
||||
topdelta = column->topdelta;
|
||||
if (topdelta <= prevdelta)
|
||||
topdelta += prevdelta;
|
||||
prevdelta = topdelta;
|
||||
|
||||
dest = desttop + (topdelta * patch->width);
|
||||
source = (UINT8 *)(column) + 3;
|
||||
for (ofs = 0; dest < deststop && ofs < column->length; ofs++)
|
||||
{
|
||||
if (source[ofs] != TRANSPARENTPIXEL)
|
||||
*dest = source[ofs];
|
||||
dest += patch->width;
|
||||
}
|
||||
column = (column_t *)((UINT8 *)column + column->length + 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void R_FlatTexture(size_t tex, UINT8 *flat)
|
||||
{
|
||||
texture_t *texture = textures[tex];
|
||||
|
||||
fixed_t col, ofs;
|
||||
column_t *column;
|
||||
UINT8 *desttop, *dest, *deststop;
|
||||
UINT8 *source;
|
||||
|
||||
desttop = flat;
|
||||
deststop = desttop + (texture->width * texture->height);
|
||||
|
||||
for (col = 0; col < SHORT(texture->width); col++, desttop++)
|
||||
{
|
||||
INT32 topdelta, prevdelta = -1;
|
||||
column = (column_t *)R_GetColumn(tex, col);
|
||||
if (!texture->holes)
|
||||
{
|
||||
dest = desttop;
|
||||
source = (UINT8 *)(column);
|
||||
for (ofs = 0; dest < deststop && ofs < texture->height; ofs++)
|
||||
{
|
||||
if (source[ofs] != TRANSPARENTPIXEL)
|
||||
*dest = source[ofs];
|
||||
dest += texture->width;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (column->topdelta != 0xff)
|
||||
{
|
||||
topdelta = column->topdelta;
|
||||
if (topdelta <= prevdelta)
|
||||
topdelta += prevdelta;
|
||||
prevdelta = topdelta;
|
||||
|
||||
dest = desttop + (topdelta * texture->width);
|
||||
source = (UINT8 *)(column) + 3;
|
||||
for (ofs = 0; dest < deststop && ofs < column->length; ofs++)
|
||||
{
|
||||
if (source[ofs] != TRANSPARENTPIXEL)
|
||||
*dest = source[ofs];
|
||||
dest += texture->width;
|
||||
}
|
||||
column = (column_t *)((UINT8 *)column + column->length + 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void R_CropFlat(UINT8 *origflat, UINT8 *cropflat, UINT16 origwidth, UINT16 origheight, UINT16 cropwidth, UINT16 cropheight)
|
||||
{
|
||||
UINT16 x, y;
|
||||
for (y = 0; y < cropheight; y++)
|
||||
for (x = 0; x < cropwidth; x++)
|
||||
cropflat[(y * cropwidth) + x] = origflat[(y * origwidth) + x];
|
||||
}
|
||||
|
|
12
src/r_data.h
12
src/r_data.h
|
@ -51,9 +51,7 @@ typedef struct
|
|||
// all loaded and prepared textures from the start of the game
|
||||
extern texture_t **textures;
|
||||
|
||||
// texture width is a power of 2, so it can easily repeat along sidedefs using a simple mask
|
||||
extern INT32 *texturewidthmask;
|
||||
|
||||
extern INT32 *texturewidth;
|
||||
extern fixed_t *textureheight; // needed for texture pegging
|
||||
|
||||
extern INT16 color8to16[256]; // remap color index to highcolor
|
||||
|
@ -81,7 +79,6 @@ void R_PrecacheLevel(void);
|
|||
// Floor/ceiling opaque texture tiles,
|
||||
// lookup by name. For animation?
|
||||
lumpnum_t R_GetFlatNumForName(const char *name);
|
||||
#define R_FlatNumForName(x) R_GetFlatNumForName(x)
|
||||
|
||||
// Called by P_Ticker for switches and animations,
|
||||
// returns the texture number for the texture name.
|
||||
|
@ -95,6 +92,13 @@ INT32 R_ColormapNumForName(char *name);
|
|||
INT32 R_CreateColormap(char *p1, char *p2, char *p3);
|
||||
const char *R_ColormapNameForNum(INT32 num);
|
||||
|
||||
boolean R_CheckIfPatch(lumpnum_t lump);
|
||||
|
||||
// Lactozilla
|
||||
void R_FlatPatch(patch_t *patch, UINT8 *flat);
|
||||
void R_FlatTexture(size_t tex, UINT8 *flat);
|
||||
void R_CropFlat(UINT8 *origflat, UINT8 *cropflat, UINT16 origwidth, UINT16 origheight, UINT16 cropwidth, UINT16 cropheight);
|
||||
|
||||
extern INT32 numtextures;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -99,6 +99,8 @@ INT32 dc_numlights = 0, dc_maxlights, dc_texheight;
|
|||
INT32 ds_y, ds_x1, ds_x2;
|
||||
lighttable_t *ds_colormap;
|
||||
fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
|
||||
UINT16 ds_flatwidth, ds_flatheight;
|
||||
boolean ds_powersoftwo;
|
||||
|
||||
UINT8 *ds_source; // start of a 64*64 tile image
|
||||
UINT8 *ds_transmap; // one of the translucency tables
|
||||
|
|
13
src/r_draw.h
13
src/r_draw.h
|
@ -57,7 +57,9 @@ extern INT32 dc_texheight;
|
|||
extern INT32 ds_y, ds_x1, ds_x2;
|
||||
extern lighttable_t *ds_colormap;
|
||||
extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
|
||||
extern UINT8 *ds_source; // start of a 64*64 tile image
|
||||
extern UINT16 ds_flatwidth, ds_flatheight;
|
||||
extern boolean ds_powersoftwo;
|
||||
extern UINT8 *ds_source;
|
||||
extern UINT8 *ds_transmap;
|
||||
|
||||
#ifdef ESLOPE
|
||||
|
@ -125,6 +127,8 @@ void R_FillBackScreen(void);
|
|||
void R_DrawViewBorder(void);
|
||||
#endif
|
||||
|
||||
#define TRANSPARENTPIXEL 247
|
||||
|
||||
// -----------------
|
||||
// 8bpp DRAWING CODE
|
||||
// -----------------
|
||||
|
@ -166,6 +170,13 @@ void R_DrawFogSpan_8(void);
|
|||
void R_DrawFogColumn_8(void);
|
||||
void R_DrawColumnShadowed_8(void);
|
||||
|
||||
#ifndef NOWATER
|
||||
void R_DrawTranslucentWaterSpan_8(void);
|
||||
|
||||
extern INT32 ds_bgofs;
|
||||
extern INT32 ds_waterofs;
|
||||
#endif
|
||||
|
||||
// ------------------
|
||||
// 16bpp DRAWING CODE
|
||||
// ------------------
|
||||
|
|
499
src/r_draw8.c
499
src/r_draw8.c
|
@ -105,8 +105,6 @@ void R_DrawColumn_8(void)
|
|||
}
|
||||
}
|
||||
|
||||
#define TRANSPARENTPIXEL 247
|
||||
|
||||
void R_Draw2sMultiPatchColumn_8(void)
|
||||
{
|
||||
INT32 count;
|
||||
|
@ -543,80 +541,60 @@ void R_DrawTranslatedColumn_8(void)
|
|||
*/
|
||||
void R_DrawSpan_8 (void)
|
||||
{
|
||||
UINT32 xposition;
|
||||
UINT32 yposition;
|
||||
UINT32 xstep, ystep;
|
||||
fixed_t xposition;
|
||||
fixed_t yposition;
|
||||
fixed_t xstep, ystep;
|
||||
|
||||
UINT8 *source;
|
||||
UINT8 *colormap;
|
||||
UINT8 *dest;
|
||||
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
||||
|
||||
size_t count;
|
||||
UINT32 flatsize = ds_flatwidth * ds_flatheight;
|
||||
size_t count = (ds_x2 - ds_x1 + 1);
|
||||
|
||||
// SoM: we only need 6 bits for the integer part (0 thru 63) so the rest
|
||||
// can be used for the fraction part. This allows calculation of the memory address in the
|
||||
// texture with two shifts, an OR and one AND. (see below)
|
||||
// for texture sizes > 64 the amount of precision we can allow will decrease, but only by one
|
||||
// bit per power of two (obviously)
|
||||
// Ok, because I was able to eliminate the variable spot below, this function is now FASTER
|
||||
// than the original span renderer. Whodathunkit?
|
||||
xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup;
|
||||
xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup;
|
||||
xposition = ds_xfrac; yposition = ds_yfrac;
|
||||
xstep = ds_xstep; ystep = ds_ystep;
|
||||
|
||||
if (ds_powersoftwo)
|
||||
{
|
||||
xposition <<= nflatshiftup; yposition <<= nflatshiftup;
|
||||
xstep <<= nflatshiftup; ystep <<= nflatshiftup;
|
||||
}
|
||||
|
||||
source = ds_source;
|
||||
colormap = ds_colormap;
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
count = ds_x2 - ds_x1 + 1;
|
||||
|
||||
if (dest+8 > deststop)
|
||||
if (dest > deststop)
|
||||
return;
|
||||
|
||||
while (count >= 8)
|
||||
if (!ds_powersoftwo)
|
||||
{
|
||||
// SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't
|
||||
// have the uber complicated math to calculate it now, so that was a memory write we didn't
|
||||
// need!
|
||||
dest[0] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
while (count-- && dest <= deststop)
|
||||
{
|
||||
fixed_t x = (xposition >> FRACBITS);
|
||||
fixed_t y = (yposition >> FRACBITS);
|
||||
|
||||
dest[1] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
// Carefully align all of my Friends.
|
||||
if (x < 0)
|
||||
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
||||
if (y < 0)
|
||||
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
||||
|
||||
dest[2] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[3] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[4] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[5] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[6] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[7] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest += 8;
|
||||
count -= 8;
|
||||
*dest++ = colormap[source[((y * ds_flatwidth) + x) % flatsize]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
}
|
||||
while (count-- && dest <= deststop)
|
||||
else
|
||||
{
|
||||
*dest++ = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
while (count-- && dest <= deststop)
|
||||
{
|
||||
*dest++ = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1065,117 +1043,64 @@ void R_DrawTiltedSplat_8(void)
|
|||
*/
|
||||
void R_DrawSplat_8 (void)
|
||||
{
|
||||
UINT32 xposition;
|
||||
UINT32 yposition;
|
||||
UINT32 xstep, ystep;
|
||||
fixed_t xposition;
|
||||
fixed_t yposition;
|
||||
fixed_t xstep, ystep;
|
||||
|
||||
UINT8 *source;
|
||||
UINT8 *colormap;
|
||||
UINT8 *dest;
|
||||
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
||||
|
||||
size_t count;
|
||||
UINT32 flatsize = ds_flatwidth * ds_flatheight;
|
||||
size_t count = (ds_x2 - ds_x1 + 1);
|
||||
UINT32 val;
|
||||
|
||||
// SoM: we only need 6 bits for the integer part (0 thru 63) so the rest
|
||||
// can be used for the fraction part. This allows calculation of the memory address in the
|
||||
// texture with two shifts, an OR and one AND. (see below)
|
||||
// for texture sizes > 64 the amount of precision we can allow will decrease, but only by one
|
||||
// bit per power of two (obviously)
|
||||
// Ok, because I was able to eliminate the variable spot below, this function is now FASTER
|
||||
// than the original span renderer. Whodathunkit?
|
||||
xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup;
|
||||
xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup;
|
||||
xposition = ds_xfrac; yposition = ds_yfrac;
|
||||
xstep = ds_xstep; ystep = ds_ystep;
|
||||
|
||||
if (ds_powersoftwo)
|
||||
{
|
||||
xposition <<= nflatshiftup; yposition <<= nflatshiftup;
|
||||
xstep <<= nflatshiftup; ystep <<= nflatshiftup;
|
||||
}
|
||||
|
||||
source = ds_source;
|
||||
colormap = ds_colormap;
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
count = ds_x2 - ds_x1 + 1;
|
||||
|
||||
while (count >= 8)
|
||||
if (!ds_powersoftwo)
|
||||
{
|
||||
// SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't
|
||||
// have the uber complicated math to calculate it now, so that was a memory write we didn't
|
||||
// need!
|
||||
//
|
||||
// <Callum> 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size)
|
||||
val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
|
||||
val &= 4194303;
|
||||
val = source[val];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[0] = colormap[val];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
while (count-- && dest <= deststop)
|
||||
{
|
||||
fixed_t x = (xposition >> FRACBITS);
|
||||
fixed_t y = (yposition >> FRACBITS);
|
||||
|
||||
val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
|
||||
val &= 4194303;
|
||||
val = source[val];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[1] = colormap[val];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
// Carefully align all of my Friends.
|
||||
if (x < 0)
|
||||
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
||||
if (y < 0)
|
||||
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
||||
|
||||
val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
|
||||
val &= 4194303;
|
||||
val = source[val];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[2] = colormap[val];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
|
||||
val &= 4194303;
|
||||
val = source[val];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[3] = colormap[val];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
|
||||
val &= 4194303;
|
||||
val = source[val];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[4] = colormap[val];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
|
||||
val &= 4194303;
|
||||
val = source[val];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[5] = colormap[val];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
|
||||
val &= 4194303;
|
||||
val = source[val];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[6] = colormap[val];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
|
||||
val &= 4194303;
|
||||
val = source[val];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[7] = colormap[val];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest += 8;
|
||||
count -= 8;
|
||||
val = source[((y * ds_flatwidth) + x) % flatsize];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
*dest = colormap[val];
|
||||
dest++;
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
}
|
||||
while (count--)
|
||||
else
|
||||
{
|
||||
val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
|
||||
val &= 4194303;
|
||||
val = source[val];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
*dest = colormap[val];
|
||||
|
||||
dest++;
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
while (count-- && dest <= deststop)
|
||||
{
|
||||
val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
*dest = colormap[val];
|
||||
dest++;
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1184,97 +1109,64 @@ void R_DrawSplat_8 (void)
|
|||
*/
|
||||
void R_DrawTranslucentSplat_8 (void)
|
||||
{
|
||||
UINT32 xposition;
|
||||
UINT32 yposition;
|
||||
UINT32 xstep, ystep;
|
||||
fixed_t xposition;
|
||||
fixed_t yposition;
|
||||
fixed_t xstep, ystep;
|
||||
|
||||
UINT8 *source;
|
||||
UINT8 *colormap;
|
||||
UINT8 *dest;
|
||||
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
||||
|
||||
size_t count;
|
||||
UINT8 val;
|
||||
UINT32 flatsize = ds_flatwidth * ds_flatheight;
|
||||
size_t count = (ds_x2 - ds_x1 + 1);
|
||||
UINT32 val;
|
||||
|
||||
// SoM: we only need 6 bits for the integer part (0 thru 63) so the rest
|
||||
// can be used for the fraction part. This allows calculation of the memory address in the
|
||||
// texture with two shifts, an OR and one AND. (see below)
|
||||
// for texture sizes > 64 the amount of precision we can allow will decrease, but only by one
|
||||
// bit per power of two (obviously)
|
||||
// Ok, because I was able to eliminate the variable spot below, this function is now FASTER
|
||||
// than the original span renderer. Whodathunkit?
|
||||
xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup;
|
||||
xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup;
|
||||
xposition = ds_xfrac; yposition = ds_yfrac;
|
||||
xstep = ds_xstep; ystep = ds_ystep;
|
||||
|
||||
if (ds_powersoftwo)
|
||||
{
|
||||
xposition <<= nflatshiftup; yposition <<= nflatshiftup;
|
||||
xstep <<= nflatshiftup; ystep <<= nflatshiftup;
|
||||
}
|
||||
|
||||
source = ds_source;
|
||||
colormap = ds_colormap;
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
count = ds_x2 - ds_x1 + 1;
|
||||
|
||||
while (count >= 8)
|
||||
if (!ds_powersoftwo)
|
||||
{
|
||||
// SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't
|
||||
// have the uber complicated math to calculate it now, so that was a memory write we didn't
|
||||
// need!
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[0] = *(ds_transmap + (colormap[val] << 8) + dest[0]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
while (count-- && dest <= deststop)
|
||||
{
|
||||
fixed_t x = (xposition >> FRACBITS);
|
||||
fixed_t y = (yposition >> FRACBITS);
|
||||
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[1] = *(ds_transmap + (colormap[val] << 8) + dest[1]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
// Carefully align all of my Friends.
|
||||
if (x < 0)
|
||||
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
||||
if (y < 0)
|
||||
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
||||
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[2] = *(ds_transmap + (colormap[val] << 8) + dest[2]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[3] = *(ds_transmap + (colormap[val] << 8) + dest[3]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[4] = *(ds_transmap + (colormap[val] << 8) + dest[4]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[5] = *(ds_transmap + (colormap[val] << 8) + dest[5]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[6] = *(ds_transmap + (colormap[val] << 8) + dest[6]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
dest[7] = *(ds_transmap + (colormap[val] << 8) + dest[7]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest += 8;
|
||||
count -= 8;
|
||||
val = source[((y * ds_flatwidth) + x) % flatsize];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
*dest = *(ds_transmap + (colormap[val] << 8) + *dest);
|
||||
dest++;
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
}
|
||||
while (count--)
|
||||
else
|
||||
{
|
||||
val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
*dest = *(ds_transmap + (colormap[val] << 8) + *dest);
|
||||
|
||||
dest++;
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
while (count-- && dest <= deststop)
|
||||
{
|
||||
val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)];
|
||||
if (val != TRANSPARENTPIXEL)
|
||||
*dest = *(ds_transmap + (colormap[val] << 8) + *dest);
|
||||
dest++;
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1283,80 +1175,125 @@ void R_DrawTranslucentSplat_8 (void)
|
|||
*/
|
||||
void R_DrawTranslucentSpan_8 (void)
|
||||
{
|
||||
UINT32 xposition;
|
||||
UINT32 yposition;
|
||||
UINT32 xstep, ystep;
|
||||
fixed_t xposition;
|
||||
fixed_t yposition;
|
||||
fixed_t xstep, ystep;
|
||||
|
||||
UINT8 *source;
|
||||
UINT8 *colormap;
|
||||
UINT8 *dest;
|
||||
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
||||
|
||||
size_t count;
|
||||
UINT32 flatsize = ds_flatwidth * ds_flatheight;
|
||||
size_t count = (ds_x2 - ds_x1 + 1);
|
||||
UINT32 val;
|
||||
|
||||
// SoM: we only need 6 bits for the integer part (0 thru 63) so the rest
|
||||
// can be used for the fraction part. This allows calculation of the memory address in the
|
||||
// texture with two shifts, an OR and one AND. (see below)
|
||||
// for texture sizes > 64 the amount of precision we can allow will decrease, but only by one
|
||||
// bit per power of two (obviously)
|
||||
// Ok, because I was able to eliminate the variable spot below, this function is now FASTER
|
||||
// than the original span renderer. Whodathunkit?
|
||||
xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup;
|
||||
xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup;
|
||||
xposition = ds_xfrac; yposition = ds_yfrac;
|
||||
xstep = ds_xstep; ystep = ds_ystep;
|
||||
|
||||
if (ds_powersoftwo)
|
||||
{
|
||||
xposition <<= nflatshiftup; yposition <<= nflatshiftup;
|
||||
xstep <<= nflatshiftup; ystep <<= nflatshiftup;
|
||||
}
|
||||
|
||||
source = ds_source;
|
||||
colormap = ds_colormap;
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
count = ds_x2 - ds_x1 + 1;
|
||||
|
||||
while (count >= 8)
|
||||
if (!ds_powersoftwo)
|
||||
{
|
||||
// SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't
|
||||
// have the uber complicated math to calculate it now, so that was a memory write we didn't
|
||||
// need!
|
||||
dest[0] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[0]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
while (count-- && dest <= deststop)
|
||||
{
|
||||
fixed_t x = (xposition >> FRACBITS);
|
||||
fixed_t y = (yposition >> FRACBITS);
|
||||
|
||||
dest[1] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[1]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
// Carefully align all of my Friends.
|
||||
if (x < 0)
|
||||
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
||||
if (y < 0)
|
||||
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
||||
|
||||
dest[2] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[2]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[3] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[3]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[4] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[4]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[5] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[5]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[6] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[6]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[7] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[7]);
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest += 8;
|
||||
count -= 8;
|
||||
val = ((y * ds_flatwidth) + x) % flatsize;
|
||||
*dest = *(ds_transmap + (colormap[source[val]] << 8) + *dest);
|
||||
dest++;
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
}
|
||||
while (count--)
|
||||
else
|
||||
{
|
||||
*dest = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + *dest);
|
||||
dest++;
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
while (count-- && dest <= deststop)
|
||||
{
|
||||
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
||||
*dest = *(ds_transmap + (colormap[source[val]] << 8) + *dest);
|
||||
dest++;
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NOWATER
|
||||
void R_DrawTranslucentWaterSpan_8(void)
|
||||
{
|
||||
fixed_t xposition;
|
||||
fixed_t yposition;
|
||||
fixed_t xstep, ystep;
|
||||
|
||||
UINT8 *source;
|
||||
UINT8 *colormap;
|
||||
UINT8 *dest;
|
||||
UINT8 *dsrc;
|
||||
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
||||
|
||||
UINT32 flatsize = ds_flatwidth * ds_flatheight;
|
||||
size_t count = (ds_x2 - ds_x1 + 1);
|
||||
|
||||
xposition = ds_xfrac; yposition = (ds_yfrac + ds_waterofs);
|
||||
xstep = ds_xstep; ystep = ds_ystep;
|
||||
|
||||
if (ds_powersoftwo)
|
||||
{
|
||||
xposition <<= nflatshiftup; yposition <<= nflatshiftup;
|
||||
xstep <<= nflatshiftup; ystep <<= nflatshiftup;
|
||||
}
|
||||
|
||||
source = ds_source;
|
||||
colormap = ds_colormap;
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
|
||||
|
||||
if (!ds_powersoftwo)
|
||||
{
|
||||
while (count-- && dest <= deststop)
|
||||
{
|
||||
fixed_t x = (xposition >> FRACBITS);
|
||||
fixed_t y = (yposition >> FRACBITS);
|
||||
|
||||
// Carefully align all of my Friends.
|
||||
if (x < 0)
|
||||
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
||||
if (y < 0)
|
||||
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
||||
|
||||
*dest++ = colormap[*(ds_transmap + (source[((y * ds_flatwidth) + x) % flatsize] << 8) + *dsrc++)];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (count-- && dest <= deststop)
|
||||
{
|
||||
*dest++ = colormap[*(ds_transmap + (source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)] << 8) + *dsrc++)];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/** \brief The R_DrawFogSpan_8 function
|
||||
Draws the actual span with fogging.
|
||||
*/
|
||||
|
|
354
src/r_plane.c
354
src/r_plane.c
|
@ -173,91 +173,13 @@ void R_PortalRestoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor
|
|||
// viewheight
|
||||
|
||||
#ifndef NOWATER
|
||||
static INT32 bgofs;
|
||||
INT32 ds_bgofs;
|
||||
INT32 ds_waterofs;
|
||||
|
||||
static INT32 wtofs=0;
|
||||
static INT32 waterofs;
|
||||
static boolean itswater;
|
||||
#endif
|
||||
|
||||
#ifndef NOWATER
|
||||
static void R_DrawTranslucentWaterSpan_8(void)
|
||||
{
|
||||
UINT32 xposition;
|
||||
UINT32 yposition;
|
||||
UINT32 xstep, ystep;
|
||||
|
||||
UINT8 *source;
|
||||
UINT8 *colormap;
|
||||
UINT8 *dest;
|
||||
UINT8 *dsrc;
|
||||
|
||||
size_t count;
|
||||
|
||||
// SoM: we only need 6 bits for the integer part (0 thru 63) so the rest
|
||||
// can be used for the fraction part. This allows calculation of the memory address in the
|
||||
// texture with two shifts, an OR and one AND. (see below)
|
||||
// for texture sizes > 64 the amount of precision we can allow will decrease, but only by one
|
||||
// bit per power of two (obviously)
|
||||
// Ok, because I was able to eliminate the variable spot below, this function is now FASTER
|
||||
// than the original span renderer. Whodathunkit?
|
||||
xposition = ds_xfrac << nflatshiftup; yposition = (ds_yfrac + waterofs) << nflatshiftup;
|
||||
xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup;
|
||||
|
||||
source = ds_source;
|
||||
colormap = ds_colormap;
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
dsrc = screens[1] + (ds_y+bgofs)*vid.width + ds_x1;
|
||||
count = ds_x2 - ds_x1 + 1;
|
||||
|
||||
while (count >= 8)
|
||||
{
|
||||
// SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't
|
||||
// have the uber complicated math to calculate it now, so that was a memory write we didn't
|
||||
// need!
|
||||
dest[0] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[1] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[2] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[3] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[4] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[5] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[6] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest[7] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
|
||||
dest += 8;
|
||||
count -= 8;
|
||||
}
|
||||
while (count--)
|
||||
{
|
||||
*dest++ = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)];
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
|
||||
{
|
||||
angle_t angle, planecos, planesin;
|
||||
|
@ -304,17 +226,17 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
|
|||
{
|
||||
const INT32 yay = (wtofs + (distance>>9) ) & 8191;
|
||||
// ripples da water texture
|
||||
bgofs = FixedDiv(FINESINE(yay), (1<<12) + (distance>>11))>>FRACBITS;
|
||||
ds_bgofs = FixedDiv(FINESINE(yay), (1<<12) + (distance>>11))>>FRACBITS;
|
||||
angle = (currentplane->viewangle + currentplane->plangle + xtoviewangle[x1])>>ANGLETOFINESHIFT;
|
||||
|
||||
angle = (angle + 2048) & 8191; // 90 degrees
|
||||
ds_xfrac += FixedMul(FINECOSINE(angle), (bgofs<<FRACBITS));
|
||||
ds_yfrac += FixedMul(FINESINE(angle), (bgofs<<FRACBITS));
|
||||
ds_xfrac += FixedMul(FINECOSINE(angle), (ds_bgofs<<FRACBITS));
|
||||
ds_yfrac += FixedMul(FINESINE(angle), (ds_bgofs<<FRACBITS));
|
||||
|
||||
if (y+bgofs>=viewheight)
|
||||
bgofs = viewheight-y-1;
|
||||
if (y+bgofs<0)
|
||||
bgofs = -y;
|
||||
if (y+ds_bgofs>=viewheight)
|
||||
ds_bgofs = viewheight-y-1;
|
||||
if (y+ds_bgofs<0)
|
||||
ds_bgofs = -y;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -726,11 +648,142 @@ void R_DrawPlanes(void)
|
|||
}
|
||||
}
|
||||
#ifndef NOWATER
|
||||
waterofs = (leveltime & 1)*16384;
|
||||
ds_waterofs = (leveltime & 1)*16384;
|
||||
wtofs = leveltime * 140;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Lactozilla
|
||||
static void R_GetPatchFlat(levelflat_t *levelflat, boolean leveltexture)
|
||||
{
|
||||
patch_t *patch = NULL;
|
||||
|
||||
if (levelflat->flatpatch == NULL)
|
||||
{
|
||||
#ifdef ESLOPE
|
||||
INT32 resizewidth, resizeheight, newresize;
|
||||
#endif // ESLOPE
|
||||
|
||||
if (!leveltexture)
|
||||
{
|
||||
patch = (patch_t *)ds_source;
|
||||
levelflat->width = ds_flatwidth = patch->width;
|
||||
levelflat->height = ds_flatheight = patch->height;
|
||||
|
||||
levelflat->flatpatch = Z_Malloc(ds_flatwidth * ds_flatheight, PU_LEVEL, NULL);
|
||||
memset(levelflat->flatpatch, TRANSPARENTPIXEL, ds_flatwidth * ds_flatheight);
|
||||
R_FlatPatch(patch, levelflat->flatpatch);
|
||||
|
||||
levelflat->topoffset = patch->topoffset * FRACUNIT;
|
||||
levelflat->leftoffset = patch->leftoffset * FRACUNIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
texture_t *texture = textures[levelflat->texturenum];
|
||||
levelflat->width = ds_flatwidth = texture->width;
|
||||
levelflat->height = ds_flatheight = texture->height;
|
||||
|
||||
levelflat->flatpatch = Z_Malloc(ds_flatwidth * ds_flatheight, PU_LEVEL, NULL);
|
||||
memset(levelflat->flatpatch, TRANSPARENTPIXEL, ds_flatwidth * ds_flatheight);
|
||||
R_FlatTexture(levelflat->texturenum, levelflat->flatpatch);
|
||||
|
||||
levelflat->topoffset = levelflat->leftoffset = 0;
|
||||
}
|
||||
ds_source = levelflat->flatpatch;
|
||||
|
||||
// If GZDoom has the same limitation then I'm not even going to bother.
|
||||
// Crop the texture.
|
||||
#ifdef ESLOPE
|
||||
// Scale up to nearest power of 2
|
||||
resizewidth = resizeheight = 1;
|
||||
while (resizewidth < levelflat->width)
|
||||
resizewidth <<= 1;
|
||||
while (resizeheight < levelflat->height)
|
||||
resizeheight <<= 1;
|
||||
// Scale down to fit in 2048x2048
|
||||
if (resizewidth > 2048)
|
||||
resizewidth = 2048;
|
||||
if (resizeheight > 2048)
|
||||
resizeheight = 2048;
|
||||
// Then scale down to fit the actual flat dimensions
|
||||
while (resizewidth > levelflat->width)
|
||||
resizewidth >>= 1;
|
||||
while (resizeheight > levelflat->height)
|
||||
resizeheight >>= 1;
|
||||
|
||||
levelflat->resizedwidth = levelflat->resizedheight = (newresize = min(resizewidth, resizeheight));
|
||||
levelflat->resizedflat = Z_Malloc(newresize * newresize, PU_LEVEL, NULL);
|
||||
memset(levelflat->resizedflat, TRANSPARENTPIXEL, newresize * newresize);
|
||||
R_CropFlat(levelflat->flatpatch, levelflat->resizedflat, levelflat->width, levelflat->height, newresize, newresize);
|
||||
#endif // ESLOPE
|
||||
}
|
||||
else
|
||||
{
|
||||
ds_source = levelflat->flatpatch;
|
||||
ds_flatwidth = levelflat->width;
|
||||
ds_flatheight = levelflat->height;
|
||||
|
||||
xoffs += levelflat->leftoffset;
|
||||
yoffs += levelflat->topoffset;
|
||||
}
|
||||
|
||||
#ifdef ESLOPE
|
||||
if (currentplane->slope)
|
||||
{
|
||||
ds_source = levelflat->resizedflat;
|
||||
ds_flatwidth = levelflat->resizedwidth;
|
||||
ds_flatheight = levelflat->resizedheight;
|
||||
|
||||
// uuuuuuuhhhhhhhh.......................
|
||||
switch (ds_flatwidth * ds_flatheight)
|
||||
{
|
||||
case 4194304: // 2048x2048 lump
|
||||
nflatmask = 0x3FF800;
|
||||
nflatxshift = 21;
|
||||
nflatyshift = 10;
|
||||
nflatshiftup = 5;
|
||||
break;
|
||||
case 1048576: // 1024x1024 lump
|
||||
nflatmask = 0xFFC00;
|
||||
nflatxshift = 22;
|
||||
nflatyshift = 12;
|
||||
nflatshiftup = 6;
|
||||
break;
|
||||
case 262144:// 512x512 lump
|
||||
nflatmask = 0x3FE00;
|
||||
nflatxshift = 23;
|
||||
nflatyshift = 14;
|
||||
nflatshiftup = 7;
|
||||
break;
|
||||
case 65536: // 256x256 lump
|
||||
nflatmask = 0xFF00;
|
||||
nflatxshift = 24;
|
||||
nflatyshift = 16;
|
||||
nflatshiftup = 8;
|
||||
break;
|
||||
case 16384: // 128x128 lump
|
||||
nflatmask = 0x3F80;
|
||||
nflatxshift = 25;
|
||||
nflatyshift = 18;
|
||||
nflatshiftup = 9;
|
||||
break;
|
||||
case 1024: // 32x32 lump
|
||||
nflatmask = 0x3E0;
|
||||
nflatxshift = 27;
|
||||
nflatyshift = 22;
|
||||
nflatshiftup = 11;
|
||||
break;
|
||||
default: // 64x64 lump
|
||||
nflatmask = 0xFC0;
|
||||
nflatxshift = 26;
|
||||
nflatyshift = 20;
|
||||
nflatshiftup = 10;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif // ESLOPE
|
||||
}
|
||||
|
||||
void R_DrawSinglePlane(visplane_t *pl)
|
||||
{
|
||||
INT32 light = 0;
|
||||
|
@ -738,6 +791,7 @@ void R_DrawSinglePlane(visplane_t *pl)
|
|||
INT32 stop, angle;
|
||||
size_t size;
|
||||
ffloor_t *rover;
|
||||
levelflat_t *levelflat;
|
||||
|
||||
if (!(pl->minx <= pl->maxx))
|
||||
return;
|
||||
|
@ -878,64 +932,78 @@ void R_DrawSinglePlane(visplane_t *pl)
|
|||
viewangle = pl->viewangle+pl->plangle;
|
||||
}
|
||||
|
||||
currentplane = pl;
|
||||
|
||||
ds_source = (UINT8 *)
|
||||
W_CacheLumpNum(levelflats[pl->picnum].lumpnum,
|
||||
PU_STATIC); // Stay here until Z_ChangeTag
|
||||
|
||||
size = W_LumpLength(levelflats[pl->picnum].lumpnum);
|
||||
|
||||
switch (size)
|
||||
{
|
||||
case 4194304: // 2048x2048 lump
|
||||
nflatmask = 0x3FF800;
|
||||
nflatxshift = 21;
|
||||
nflatyshift = 10;
|
||||
nflatshiftup = 5;
|
||||
break;
|
||||
case 1048576: // 1024x1024 lump
|
||||
nflatmask = 0xFFC00;
|
||||
nflatxshift = 22;
|
||||
nflatyshift = 12;
|
||||
nflatshiftup = 6;
|
||||
break;
|
||||
case 262144:// 512x512 lump'
|
||||
nflatmask = 0x3FE00;
|
||||
nflatxshift = 23;
|
||||
nflatyshift = 14;
|
||||
nflatshiftup = 7;
|
||||
break;
|
||||
case 65536: // 256x256 lump
|
||||
nflatmask = 0xFF00;
|
||||
nflatxshift = 24;
|
||||
nflatyshift = 16;
|
||||
nflatshiftup = 8;
|
||||
break;
|
||||
case 16384: // 128x128 lump
|
||||
nflatmask = 0x3F80;
|
||||
nflatxshift = 25;
|
||||
nflatyshift = 18;
|
||||
nflatshiftup = 9;
|
||||
break;
|
||||
case 1024: // 32x32 lump
|
||||
nflatmask = 0x3E0;
|
||||
nflatxshift = 27;
|
||||
nflatyshift = 22;
|
||||
nflatshiftup = 11;
|
||||
break;
|
||||
default: // 64x64 lump
|
||||
nflatmask = 0xFC0;
|
||||
nflatxshift = 26;
|
||||
nflatyshift = 20;
|
||||
nflatshiftup = 10;
|
||||
break;
|
||||
}
|
||||
|
||||
xoffs = pl->xoffs;
|
||||
yoffs = pl->yoffs;
|
||||
planeheight = abs(pl->height - pl->viewz);
|
||||
|
||||
currentplane = pl;
|
||||
levelflat = &levelflats[pl->picnum];
|
||||
|
||||
if (levelflat->texturenum != 0 && levelflat->texturenum != -1)
|
||||
R_GetPatchFlat(levelflat, true);
|
||||
else
|
||||
{
|
||||
ds_source = (UINT8 *)W_CacheLumpNum(levelflat->lumpnum, PU_STATIC); // Stay here until Z_ChangeTag
|
||||
size = W_LumpLength(levelflat->lumpnum);
|
||||
|
||||
switch (size)
|
||||
{
|
||||
case 4194304: // 2048x2048 lump
|
||||
nflatmask = 0x3FF800;
|
||||
nflatxshift = 21;
|
||||
nflatyshift = 10;
|
||||
nflatshiftup = 5;
|
||||
ds_flatwidth = ds_flatheight = 2048;
|
||||
break;
|
||||
case 1048576: // 1024x1024 lump
|
||||
nflatmask = 0xFFC00;
|
||||
nflatxshift = 22;
|
||||
nflatyshift = 12;
|
||||
nflatshiftup = 6;
|
||||
ds_flatwidth = ds_flatheight = 1024;
|
||||
break;
|
||||
case 262144:// 512x512 lump
|
||||
nflatmask = 0x3FE00;
|
||||
nflatxshift = 23;
|
||||
nflatyshift = 14;
|
||||
nflatshiftup = 7;
|
||||
ds_flatwidth = ds_flatheight = 512;
|
||||
break;
|
||||
case 65536: // 256x256 lump
|
||||
nflatmask = 0xFF00;
|
||||
nflatxshift = 24;
|
||||
nflatyshift = 16;
|
||||
nflatshiftup = 8;
|
||||
ds_flatwidth = ds_flatheight = 256;
|
||||
break;
|
||||
case 16384: // 128x128 lump
|
||||
nflatmask = 0x3F80;
|
||||
nflatxshift = 25;
|
||||
nflatyshift = 18;
|
||||
nflatshiftup = 9;
|
||||
ds_flatwidth = ds_flatheight = 128;
|
||||
break;
|
||||
case 1024: // 32x32 lump
|
||||
nflatmask = 0x3E0;
|
||||
nflatxshift = 27;
|
||||
nflatyshift = 22;
|
||||
nflatshiftup = 11;
|
||||
ds_flatwidth = ds_flatheight = 32;
|
||||
break;
|
||||
default: // 64x64 lump
|
||||
nflatmask = 0xFC0;
|
||||
nflatxshift = 26;
|
||||
nflatyshift = 20;
|
||||
nflatshiftup = 10;
|
||||
ds_flatwidth = ds_flatheight = 64;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (R_CheckIfPatch(levelflat->lumpnum))
|
||||
R_GetPatchFlat(levelflat, false);
|
||||
ds_powersoftwo = (!((ds_flatwidth & (ds_flatwidth - 1)) || (ds_flatheight & (ds_flatheight - 1))));
|
||||
|
||||
if (light >= LIGHTLEVELS)
|
||||
light = LIGHTLEVELS-1;
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ void SCR_SetMode(void)
|
|||
//fuzzcolfunc = R_DrawTranslucentColumn_8_ASM;
|
||||
walldrawerfunc = R_DrawWallColumn_8_MMX;
|
||||
twosmultipatchfunc = R_Draw2sMultiPatchColumn_8_MMX;
|
||||
spanfunc = basespanfunc = R_DrawSpan_8_MMX;
|
||||
//spanfunc = basespanfunc = R_DrawSpan_8_MMX;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue