mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Introduce a sequence of macros to reduce the reliance of Colormap-related code (especially but not limited to Encore mode) on magic numbers.
This commit is contained in:
parent
f40836dcec
commit
4052e01f4a
10 changed files with 32 additions and 26 deletions
|
|
@ -478,7 +478,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex)
|
|||
|
||||
#ifdef GLENCORE
|
||||
if (encoremap)
|
||||
grtex->mipmap.colormap += (256*32);
|
||||
grtex->mipmap.colormap += COLORMAP_REMAPOFFSET;
|
||||
#endif
|
||||
|
||||
blockwidth = texture->width;
|
||||
|
|
@ -833,7 +833,7 @@ void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum, boolean noencoremap)
|
|||
|
||||
#ifdef GLENCORE
|
||||
if (!noencoremap && encoremap)
|
||||
grmip->colormap += (256*32);
|
||||
grmip->colormap += COLORMAP_REMAPOFFSET;
|
||||
#endif
|
||||
|
||||
grmip = HWR_GetCachedGLPatch(flatlumpnum)->mipmap;
|
||||
|
|
|
|||
|
|
@ -5224,7 +5224,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
|||
vis->colormap = colormaps;
|
||||
#ifdef GLENCORE
|
||||
if (encoremap && (thing->flags & (MF_SCENERY|MF_NOTHINK)) && !(thing->flags & MF_DONTENCOREMAP))
|
||||
vis->colormap += (256*32);
|
||||
vis->colormap += COLORMAP_REMAPOFFSET;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -5331,7 +5331,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
|
|||
|
||||
#ifdef GLENCORE
|
||||
if (encoremap && !(thing->flags & MF_DONTENCOREMAP))
|
||||
vis->colormap += (256*32);
|
||||
vis->colormap += COLORMAP_REMAPOFFSET;
|
||||
#endif
|
||||
|
||||
// set top/bottom coords
|
||||
|
|
|
|||
14
src/r_data.c
14
src/r_data.c
|
|
@ -287,7 +287,9 @@ static void R_InitColormaps(void)
|
|||
// Load in the light tables
|
||||
lump = W_GetNumForName("COLORMAP");
|
||||
len = W_LumpLength(lump);
|
||||
colormaps = Z_MallocAlign(len * 2, PU_STATIC, NULL, 8); // * 2 for encore
|
||||
if (len < COLORMAP_SIZE*2) // accomodate encore mode later
|
||||
len = COLORMAP_SIZE*2;
|
||||
colormaps = Z_MallocAlign(len, PU_STATIC, NULL, 8);
|
||||
W_ReadLump(lump, colormaps);
|
||||
// no need to init encoremap at this stage
|
||||
|
||||
|
|
@ -330,9 +332,9 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap)
|
|||
encoremap = Z_MallocAlign(256 + 10, PU_LEVEL, NULL, 8);
|
||||
W_ReadLump(newencoremap, encoremap);
|
||||
colormap_p = colormap_p2 = colormaps;
|
||||
colormap_p += (256 * 32);
|
||||
colormap_p += COLORMAP_REMAPOFFSET;
|
||||
|
||||
for (p = 0; p < 32; p++)
|
||||
for (p = 0; p < LIGHTLEVELS; p++)
|
||||
{
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
|
|
@ -731,12 +733,12 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
|
|||
|
||||
// Now allocate memory for the actual colormap array itself!
|
||||
// aligned on 8 bit for asm code
|
||||
colormap_p = Z_MallocAlign((256 * (encoremap ? 64 : 32)) + 10, PU_LEVEL, NULL, 8);
|
||||
colormap_p = Z_MallocAlign((COLORMAP_SIZE * (encoremap ? 2 : 1)) + 10, PU_LEVEL, NULL, 8);
|
||||
lighttable = (UINT8 *)colormap_p;
|
||||
|
||||
// Calculate the palette index for each palette index, for each light level
|
||||
// (as well as the two unused colormap lines we inherited from Doom)
|
||||
for (p = 0; p < 32; p++)
|
||||
for (p = 0; p < LIGHTLEVELS; p++)
|
||||
{
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
|
|
@ -776,7 +778,7 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
|
|||
{
|
||||
lighttable_t *colormap_p2 = lighttable;
|
||||
|
||||
for (p = 0; p < 32; p++)
|
||||
for (p = 0; p < LIGHTLEVELS; p++)
|
||||
{
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1698,7 +1698,7 @@ void R_DrawColumnShadowed_8(void)
|
|||
{
|
||||
dc_colormap = dc_lightlist[i].rcolormap;
|
||||
if (encoremap)
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
if (solid && dc_yl < bheight)
|
||||
dc_yl = bheight;
|
||||
continue;
|
||||
|
|
@ -1716,7 +1716,7 @@ void R_DrawColumnShadowed_8(void)
|
|||
|
||||
dc_colormap = dc_lightlist[i].rcolormap;
|
||||
if (encoremap)
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
}
|
||||
dc_yh = realyh;
|
||||
if (dc_yl <= realyh)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ extern size_t validcount, linecount, loopcount, framecount;
|
|||
|
||||
// Lighting constants.
|
||||
// Now with 32 levels.
|
||||
#define LIGHTLEVELS 32
|
||||
// LIGHTLEVELS is now defined in r_state.h
|
||||
#define LIGHTSEGSHIFT 3
|
||||
|
||||
#define MAXLIGHTSCALE 48
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
|
|||
ds_colormap = planezlight[pindex];
|
||||
|
||||
if (encoremap && !currentplane->noencore)
|
||||
ds_colormap += (256*32);
|
||||
ds_colormap += COLORMAP_REMAPOFFSET;
|
||||
|
||||
if (currentplane->extra_colormap)
|
||||
ds_colormap = currentplane->extra_colormap->colormap + (ds_colormap - colormaps);
|
||||
|
|
@ -645,7 +645,7 @@ static void R_DrawSkyPlane(visplane_t *pl)
|
|||
// by sector colormaps (INVUL inverse mapping is not implemented in SRB2 so is irrelevant).
|
||||
dc_colormap = colormaps;
|
||||
if (encoremap)
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
dc_texturemid = skytexturemid;
|
||||
dc_texheight = textureheight[skytexture]
|
||||
>>FRACBITS;
|
||||
|
|
|
|||
16
src/r_segs.c
16
src/r_segs.c
|
|
@ -203,7 +203,7 @@ static void R_DrawWallSplats(void)
|
|||
pindex = MAXLIGHTSCALE - 1;
|
||||
dc_colormap = walllights[pindex];
|
||||
if (encoremap && !(seg->linedef->flags & ML_TFERLINE))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
|
||||
if (frontsector->extra_colormap)
|
||||
dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps);
|
||||
|
|
@ -578,7 +578,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
|||
{
|
||||
dc_colormap = rlight->rcolormap;
|
||||
if (encoremap && !(ldef->flags & ML_TFERLINE))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -599,7 +599,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
|||
windowtop = windowbottom + 1;
|
||||
dc_colormap = rlight->rcolormap;
|
||||
if (encoremap && !(ldef->flags & ML_TFERLINE))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
}
|
||||
windowbottom = realbot;
|
||||
if (windowtop < windowbottom)
|
||||
|
|
@ -617,7 +617,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
|||
|
||||
dc_colormap = walllights[pindex];
|
||||
if (encoremap && !(ldef->flags & ML_TFERLINE))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
|
||||
if (frontsector->extra_colormap)
|
||||
dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps);
|
||||
|
|
@ -1163,7 +1163,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
|
|||
{
|
||||
dc_colormap = rlight->rcolormap;
|
||||
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
}
|
||||
if (solid && windowtop < bheight)
|
||||
windowtop = bheight;
|
||||
|
|
@ -1195,7 +1195,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
|
|||
{
|
||||
dc_colormap = rlight->rcolormap;
|
||||
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
}
|
||||
}
|
||||
windowbottom = sprbotscreen;
|
||||
|
|
@ -1216,7 +1216,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
|
|||
dc_colormap = walllights[pindex];
|
||||
|
||||
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
|
||||
if (pfloor->flags & FF_FOG && pfloor->master->frontsector->extra_colormap)
|
||||
dc_colormap = pfloor->master->frontsector->extra_colormap->colormap + (dc_colormap - colormaps);
|
||||
|
|
@ -1476,7 +1476,7 @@ static void R_RenderSegLoop (void)
|
|||
|
||||
dc_colormap = walllights[pindex];
|
||||
if (encoremap && !(curline->linedef->flags & ML_TFERLINE))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
dc_x = rw_x;
|
||||
dc_iscale = 0xffffffffu / (unsigned)rw_scale;
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,10 @@ extern UINT8 *encoremap;
|
|||
extern UINT8 invertmap[256];
|
||||
#endif
|
||||
|
||||
#define LIGHTLEVELS 32
|
||||
#define COLORMAP_SIZE (256*LIGHTLEVELS)
|
||||
#define COLORMAP_REMAPOFFSET COLORMAP_SIZE
|
||||
|
||||
// Boom colormaps.
|
||||
extern extracolormap_t *extra_colormaps;
|
||||
|
||||
|
|
|
|||
|
|
@ -863,7 +863,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
|
|||
dc_colormap = colormaps;
|
||||
|
||||
if (encoremap && !vis->mobj->color && !(vis->mobj->flags & MF_DONTENCOREMAP))
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
|
||||
dc_texturemid = vis->texturemid;
|
||||
dc_texheight = 0;
|
||||
|
|
@ -993,7 +993,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
|
|||
|
||||
dc_colormap = colormaps;
|
||||
if (encoremap)
|
||||
dc_colormap += (256*32);
|
||||
dc_colormap += COLORMAP_REMAPOFFSET;
|
||||
|
||||
dc_iscale = FixedDiv(FRACUNIT, vis->scale);
|
||||
dc_texturemid = vis->texturemid;
|
||||
|
|
|
|||
|
|
@ -1454,7 +1454,7 @@ void V_DrawCustomFadeScreen(const char *lump, UINT8 strength)
|
|||
|
||||
if (lumpnum != LUMPERROR)
|
||||
{
|
||||
clm = Z_MallocAlign((256 * 32), PU_STATIC, NULL, 8);
|
||||
clm = Z_MallocAlign(COLORMAP_SIZE, PU_STATIC, NULL, 8);
|
||||
W_ReadLump(lumpnum, clm);
|
||||
|
||||
if (clm != NULL)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue