Skip to content

Commit

Permalink
Done requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JNechaevsky committed Sep 4, 2024
1 parent 872d4de commit 9af96d5
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 54 deletions.
10 changes: 1 addition & 9 deletions src/doom/m_crispy.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "s_sound.h"
#include "r_defs.h" // [crispy] laserpatch
#include "r_sky.h" // [crispy] R_InitSkyMap()
#include "z_zone.h" // [crispy] Z_Free()

#include "m_crispy.h"

Expand Down Expand Up @@ -518,14 +517,7 @@ static void M_CrispyToggleSmoothLightingHook (void)
crispy->smoothlight = !crispy->smoothlight;

#ifdef CRISPY_TRUECOLOR
// [crispy] zero out colormaps[] array so it can be
// reallocated and recalculated in R_InitColormaps()
if (colormaps != NULL)
{
Z_Free(colormaps);
colormaps = NULL;
}
// [crispy] re-calculate light tables and amount of colormaps
// [crispy] re-calculate amount of colormaps and light tables
R_InitColormaps();
#endif
// [crispy] re-calculate the zlight[][] array
Expand Down
8 changes: 2 additions & 6 deletions src/doom/p_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@


// Index of the special effects (INVUL inverse) map.
#ifndef CRISPY_TRUECOLOR
#define INVERSECOLORMAP 32
#else
// [crispy] parameterized for smooth diminishing lighting
int INVERSECOLORMAP;
#endif
// [crispy] moved to r_main.h for smooth diminishing lighting parameterization
//#define INVERSECOLORMAP NUMCOLORMAPS


//
Expand Down
10 changes: 9 additions & 1 deletion src/doom/r_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -1207,10 +1207,18 @@ void R_InitColormaps (void)
{
NUMCOLORMAPS = 32;
}
// [crispy] Regardless of the number of color maps,
// [crispy] Regardless of the number of colormaps,
// invulnerability is always the last one.
INVERSECOLORMAP = NUMCOLORMAPS;

// [crispy] zero out colormaps[] array so it can be
// reallocated and recalculated with different amount of colormaps
if (colormaps != NULL)
{
Z_Free(colormaps);
colormaps = NULL;
}

if (!colormaps)
{
colormaps = (lighttable_t*) Z_Malloc((NUMCOLORMAPS + 1) * 256 * sizeof(lighttable_t), PU_STATIC, 0);
Expand Down
59 changes: 26 additions & 33 deletions src/doom/r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ lighttable_t*** zlight = NULL;
int extralight;

// [crispy] parameterized for smooth diminishing lighting
#ifdef CRISPY_TRUECOLOR
int NUMCOLORMAPS;
#endif
int LIGHTLEVELS;
int LIGHTSEGSHIFT;
int LIGHTBRIGHT;
Expand Down Expand Up @@ -702,41 +700,36 @@ void R_InitLightTables (void)
// [crispy] smooth diminishing lighting
if (crispy->smoothlight)
{
#ifndef CRISPY_TRUECOLOR
LIGHTLEVELS = 32;
LIGHTSEGSHIFT = 3;
LIGHTBRIGHT = 2;
MAXLIGHTSCALE = 48;
LIGHTSCALESHIFT = 12;
MAXLIGHTZ = 1024;
LIGHTZSHIFT = 17;
#else
if (crispy->truecolor)
{
// [crispy] if in TrueColor mode, use smoothest diminished lighting
LIGHTLEVELS = 256;
LIGHTSEGSHIFT = 0;
LIGHTBRIGHT = 15;
MAXLIGHTSCALE = 376;
LIGHTSCALESHIFT = 9;
MAXLIGHTZ = 1024;
LIGHTZSHIFT = 17;
}
else
{
// [crispy] else, use paletted paletted approach
LIGHTLEVELS = 32;
LIGHTSEGSHIFT = 3;
LIGHTBRIGHT = 2;
MAXLIGHTSCALE = 48;
LIGHTSCALESHIFT = 12;
MAXLIGHTZ = 1024;
LIGHTZSHIFT = 17;
}
#ifdef CRISPY_TRUECOLOR
if (crispy->truecolor)
{
// [crispy] if in TrueColor mode, use smoothest diminished lighting
NUMCOLORMAPS = 256;
LIGHTLEVELS = 256;
LIGHTSEGSHIFT = 0;
LIGHTBRIGHT = 15;
MAXLIGHTSCALE = 376;
LIGHTSCALESHIFT = 9;
MAXLIGHTZ = 1024;
LIGHTZSHIFT = 17;
}
else
#endif
{
// [crispy] else, use paletted approach
NUMCOLORMAPS = 32;
LIGHTLEVELS = 32;
LIGHTSEGSHIFT = 3;
LIGHTBRIGHT = 2;
MAXLIGHTSCALE = 48;
LIGHTSCALESHIFT = 12;
MAXLIGHTZ = 1024;
LIGHTZSHIFT = 17;
}
}
else
{
NUMCOLORMAPS = 32;
LIGHTLEVELS = 16;
LIGHTSEGSHIFT = 4;
LIGHTBRIGHT = 1;
Expand Down
8 changes: 3 additions & 5 deletions src/doom/r_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,11 @@ extern lighttable_t* fixedcolormap;

// Number of diminishing brightness levels.
// There a 0-31, i.e. 32 LUT in the COLORMAP lump.
#ifndef CRISPY_TRUECOLOR
#define NUMCOLORMAPS 32
#else
// [crispy] parameterized for smooth diminishing lighting
extern int NUMCOLORMAPS;
extern int INVERSECOLORMAP;
#endif
// [crispy] index of the special effects (INVUL inverse) map,
// parameterized for smooth diminishing lighting
#define INVERSECOLORMAP NUMCOLORMAPS

// Blocky/low detail mode.
//B remove this?
Expand Down

0 comments on commit 9af96d5

Please sign in to comment.