Skip to content

Commit

Permalink
brightmaps: implement brightmaps for select player gun sprites
Browse files Browse the repository at this point in the history
based on the psprite state with support for both Doom and Hacx, thanks
@JNechaevsky for the suggestions!
  • Loading branch information
fabiangreffrath committed Jan 11, 2018
1 parent b0ed83f commit a37f8fc
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 19 deletions.
115 changes: 100 additions & 15 deletions src/doom/r_bmaps.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,26 @@ static byte chexredgreen[256] =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};

static byte hacxlightning[256] =
{
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};

byte *dc_brightmap = nobrightmap;

// [crispy] brightmaps for textures
Expand Down Expand Up @@ -696,17 +716,76 @@ static byte *R_BrightmapForFlatNum_None (const int num)
return nobrightmap;
}

// [crispy] brightmaps for states

static byte *R_BrightmapForState_Doom (const int state)
{
if (crispy->brightmaps & BRIGHTMAPS_SPRITES)
{
switch (state)
{
case S_BFG1:
case S_BFG2:
case S_BFG3:
case S_BFG4:
{
return redonly;
break;
}
}
}

return nobrightmap;
}

static byte *R_BrightmapForState_Hacx (const int state)
{
if (crispy->brightmaps & BRIGHTMAPS_SPRITES)
{
switch (state)
{
case S_SAW2:
case S_SAW3:
{
return hacxlightning;
break;
}
case S_MISSILE:
{
return redandgreen;
break;
}
case S_SAW:
case S_SAWB:
case S_PLASMA:
case S_PLASMA2:
{
return redonly;
break;
}
}
}

return nobrightmap;
}

static byte *R_BrightmapForState_None (const int state)
{
return nobrightmap;
}

// [crispy] initialize brightmaps

byte *(*R_BrightmapForTexName) (const char *texname);
byte *(*R_BrightmapForSprite) (const int type);
byte *(*R_BrightmapForFlatNum) (const int type);
byte *(*R_BrightmapForFlatNum) (const int num);
byte *(*R_BrightmapForState) (const int state);

void R_InitBrightmaps (int pass)
void R_InitBrightmaps (int flats)
{
if (gameversion == exe_hacx)
{
if (pass)
if (flats)
{
bmapflatnum[0] = R_FlatNumForName("FLOOR1_1");
bmapflatnum[1] = R_FlatNumForName("FLOOR1_7");
Expand All @@ -726,27 +805,32 @@ void R_InitBrightmaps (int pass)
R_BrightmapForTexName = R_BrightmapForTexName_Hacx;
R_BrightmapForSprite = R_BrightmapForSprite_Hacx;
R_BrightmapForFlatNum = R_BrightmapForFlatNum_Hacx;
R_BrightmapForState = R_BrightmapForState_Hacx;
}
}
else
if (gameversion == exe_chex && !pass)
if (gameversion == exe_chex)
{
int lump;

// [crispy] detect Chex Quest 2
lump = W_CheckNumForName("INTERPIC");
if (!strcasecmp(lumpinfo[lump]->wad_file->basename, "chex2.wad"))
if (!flats)
{
chex2 = true;
}
int lump;

R_BrightmapForTexName = R_BrightmapForTexName_Chex;
R_BrightmapForSprite = R_BrightmapForSprite_Chex;
R_BrightmapForFlatNum = R_BrightmapForFlatNum_None;
// [crispy] detect Chex Quest 2
lump = W_CheckNumForName("INTERPIC");
if (!strcasecmp(lumpinfo[lump]->wad_file->basename, "chex2.wad"))
{
chex2 = true;
}

R_BrightmapForTexName = R_BrightmapForTexName_Chex;
R_BrightmapForSprite = R_BrightmapForSprite_Chex;
R_BrightmapForFlatNum = R_BrightmapForFlatNum_None;
R_BrightmapForState = R_BrightmapForState_None;
}
}
else
{
if (pass)
if (flats)
{
// [crispy] only three select brightmapped flats
bmapflatnum[0] = R_FlatNumForName("CONS1_1");
Expand All @@ -758,6 +842,7 @@ void R_InitBrightmaps (int pass)
R_BrightmapForTexName = R_BrightmapForTexName_Doom;
R_BrightmapForSprite = R_BrightmapForSprite_Doom;
R_BrightmapForFlatNum = R_BrightmapForFlatNum_Doom;
R_BrightmapForState = R_BrightmapForState_Doom;
}
}
}
5 changes: 3 additions & 2 deletions src/doom/r_bmaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@

#include "doomtype.h"

extern void R_InitBrightmaps (int pass);
extern void R_InitBrightmaps (int flats);

extern byte *(*R_BrightmapForTexName) (const char *texname);
extern byte *(*R_BrightmapForSprite) (const int type);
extern byte *(*R_BrightmapForFlatNum) (const int type);
extern byte *(*R_BrightmapForFlatNum) (const int num);
extern byte *(*R_BrightmapForState) (const int state);

extern byte **texturebrightmap;

Expand Down
5 changes: 3 additions & 2 deletions src/doom/r_things.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,9 +1025,10 @@ void R_DrawPSprite (pspdef_t* psp, psprnum_t psprnum) // [crispy] differentiate
else
{
// local light
vis->colormap[0] = vis->colormap[1] = spritelights[MAXLIGHTSCALE-1];
vis->colormap[0] = spritelights[MAXLIGHTSCALE-1];
vis->colormap[1] = scalelight[LIGHTLEVELS-1][MAXLIGHTSCALE-1];
}
vis->brightmap = dc_brightmap;
vis->brightmap = R_BrightmapForState(state);

// [crispy] translucent gun flash sprites
if (psprnum == ps_flash)
Expand Down

0 comments on commit a37f8fc

Please sign in to comment.