Skip to content

Commit

Permalink
Use the 2nd colormap for flats after F_STCOL2
Browse files Browse the repository at this point in the history
  • Loading branch information
viciious committed Dec 23, 2023
1 parent fb36a15 commit 1a60d94
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion marsnew.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ VINT COLOR_WHITE = 0x04;
VINT COLOR_BLACK = 0xF7;

int8_t *dc_colormaps;
int8_t *dc_colormaps_hk;
int8_t *dc_colormaps2;
const byte *new_palette = NULL;

boolean debugscreenactive = false;
Expand Down
31 changes: 21 additions & 10 deletions r_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

boolean spr_rotations;

VINT firstflat, lastflat, numflats;
VINT firstflat, numflats, col2flat;

VINT firstsprite, numsprites;

Expand Down Expand Up @@ -297,25 +297,32 @@ void R_InitTextures (void)

void R_InitFlats (void)
{
int i, j;

int i;
int lastflat;

firstflat = W_GetNumForName ("F_START") + 1;
lastflat = W_GetNumForName ("F_END") - 1;
numflats = lastflat - firstflat + 1;

/* translation table for global animation */
flattranslation = Z_Malloc ((numflats+1)*sizeof(*flattranslation), PU_STATIC);
for (i=0 ; i<numflats ; i++)
flattranslation[i] = i;

flatpixels = Z_Malloc(numflats * sizeof(*flatpixels), PU_STATIC);

col2flat = R_FlatNumForName ("F_STCOL2");
if (col2flat < 0)
col2flat = numflats + 1;

#if MIPLEVELS > 1
// detect mip-maps
if (!texmips)
return;

for (i=0 ; i<numflats ; i++)
{
int j;
int w = 64;
uint8_t *start = R_CheckPixels(firstflat + i);
uint8_t *end = start + W_LumpLength(firstflat + i);
Expand All @@ -335,6 +342,7 @@ void R_InitFlats (void)
w >>= 1;
}
}
#endif
}

/*
Expand Down Expand Up @@ -389,7 +397,7 @@ void R_InitData (void)

int R_FlatNumForName (const char *name)
{
int f = W_CheckRangeForName (name, firstflat, lastflat+1);
int f = W_CheckRangeForName (name, firstflat, firstflat + numflats);
if (f < 0)
return f;
return f - firstflat;
Expand Down Expand Up @@ -833,12 +841,10 @@ void R_InitSpriteDefs(const char** namelist)
}
}

static void *R_LoadColormap(const char *name, boolean doublepix)
static void *R_LoadColormap(int l, boolean doublepix)
{
int l;
void *doomcolormap;

l = W_CheckNumForName(name);
l -= (int)!doublepix;

doomcolormap = W_GetLumpData(l);
Expand All @@ -850,8 +856,13 @@ static void *R_LoadColormap(const char *name, boolean doublepix)

void R_InitColormap(boolean doublepix)
{
dc_colormaps = R_LoadColormap("COLORMAP", doublepix);
dc_colormaps_hk = R_LoadColormap("COLORMHK", doublepix);
int l;

l = W_CheckNumForName("COLORMAP");
dc_colormaps = R_LoadColormap(l, doublepix);

l -= 2;
dc_colormaps2 = R_LoadColormap(l, doublepix);

#ifdef MARS
Mars_CommSlaveClearCache();
Expand Down
4 changes: 2 additions & 2 deletions r_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,12 @@ extern uint8_t *flattranslation; /* for global animation */
extern uint8_t *texturetranslation; /* for global animation */
extern flattex_t *flatpixels;

extern VINT firstflat, numflats;
extern VINT firstflat, numflats, col2flat;

extern VINT firstsprite, numsprites;

extern int8_t* dc_colormaps;
extern int8_t* dc_colormaps_hk;
extern int8_t* dc_colormaps2;

extern uint8_t* dc_playpals;

Expand Down
8 changes: 6 additions & 2 deletions r_phase7.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,6 @@ static void R_DrawPlanes2(void)
if (vd.gsortedvisplanes == NULL)
return;

I_SetThreadLocalVar(DOOMTLS_COLORMAP, dc_colormaps);

lpl.x = vd.viewx;
lpl.y = -vd.viewy;

Expand All @@ -314,6 +312,12 @@ static void R_DrawPlanes2(void)
continue;

flatnum = pl->flatandlight&0xffff;

if (flatnum >= col2flat)
I_SetThreadLocalVar(DOOMTLS_COLORMAP, dc_colormaps2);
else
I_SetThreadLocalVar(DOOMTLS_COLORMAP, dc_colormaps);

lpl.pl = pl;
lpl.ds_source[0] = flatpixels[flatnum].data[0];

Expand Down

0 comments on commit 1a60d94

Please sign in to comment.