Skip to content

Commit

Permalink
Merge pull request #1051 from fabiangreffrath/secret-automap-colors
Browse files Browse the repository at this point in the history
Adjust secret automap colors in case PLAYPAL was not loaded from vanilla DOOM (2) IWAD or FreeD(OO)M
  • Loading branch information
SoDOOManiac committed Apr 15, 2023
2 parents a009910 + 76ad151 commit 4c0a56a
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/doom/am_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
// Needs access to LFB.
#include "v_video.h"

// V_GetPaletteIndex
#include "v_trans.h"

// State.
#include "doomstat.h"
#include "r_state.h"
Expand Down Expand Up @@ -79,9 +82,8 @@ extern boolean inhelpscreens; // [crispy]
#define CDWALLRANGE YELLOWRANGE
#define THINGCOLORS GREENS
#define THINGRANGE GREENRANGE
#define SECRETWALLCOLORS 252 // [crispy] purple
#define SECRETWALLCOLORS WALLCOLORS
#define CRISPY_HIGHLIGHT_REVEALED_SECRETS
#define REVEALEDSECRETWALLCOLORS 112 // [crispy] green
#define SECRETWALLRANGE WALLRANGE
#define GRIDCOLORS (GRAYS + GRAYSRANGE/2)
#define GRIDRANGE 0
Expand Down Expand Up @@ -127,6 +129,10 @@ static int m_zoomin_mouse;
static int m_zoomout_mouse;
static boolean mousewheelzoom;

// [JN] Make wall colors of secret sectors palette-independent.
static int secretwallcolors = -1;
static int revealedsecretwallcolors = -1;

// translates between frame-buffer and map distances
// [crispy] fix int overflow that causes map and grid lines to disappear
#define FTOM(x) (((int64_t)((x)<<FRACBITS) * scale_ftom) >> FRACBITS)
Expand Down Expand Up @@ -656,9 +662,11 @@ void AM_LevelInit(boolean reinit)

f_h_old = f_h;

// [crispy] Precalculate color lookup tables for antialised line drawing using COLORMAP
// [crispy] Precalculate color lookup tables for antialiased line drawing using COLORMAP
if (!precalc_once)
{
unsigned char *playpal = W_CacheLumpName("PLAYPAL", PU_STATIC);

precalc_once = 1;
for (int color = 0; color < 256; ++color)
{
Expand All @@ -674,6 +682,12 @@ void AM_LevelInit(boolean reinit)
color_shades[color * NUMSHADES + shade] = colormaps[shade_index[shade]];
}
}

// [crispy] Make secret wall colors independent from PLAYPAL color indexes
secretwallcolors = V_GetPaletteIndex(playpal, 255, 0, 255);

This comment has been minimized.

Copy link
@fabiangreffrath

fabiangreffrath Apr 16, 2023

Owner

Dammit, could you guys please check if this breaks the truecolor build?

This comment has been minimized.

Copy link
@JNechaevsky

JNechaevsky Apr 16, 2023

Collaborator

Can confirm that there is no problems with CRISPY_TRUECOLOR:BOOL=ON in both original and BTSX PLAYPALs.

This comment has been minimized.

Copy link
@fabiangreffrath

fabiangreffrath Apr 16, 2023

Owner

Cool, thanks!

revealedsecretwallcolors = V_GetPaletteIndex(playpal, 119, 255, 111);

W_ReleaseLumpName("PLAYPAL");
}
}

Expand Down Expand Up @@ -1672,13 +1686,13 @@ void AM_drawWalls(void)
// [crispy] draw 1S secret sector boundaries in purple
if (crispy->extautomap &&
cheating && (lines[i].frontsector->special == 9))
AM_drawMline(&l, SECRETWALLCOLORS);
AM_drawMline(&l, secretwallcolors);
#if defined CRISPY_HIGHLIGHT_REVEALED_SECRETS
// [crispy] draw revealed secret sector boundaries in green
else
if (crispy->extautomap &&
crispy->secretmessage && (lines[i].frontsector->oldspecial == 9))
AM_drawMline(&l, REVEALEDSECRETWALLCOLORS);
AM_drawMline(&l, revealedsecretwallcolors);
#endif
else
AM_drawMline(&l, WALLCOLORS+lightlev);
Expand All @@ -1697,7 +1711,7 @@ void AM_drawWalls(void)
{
// [crispy] NB: Choco has this check, but (SECRETWALLCOLORS == WALLCOLORS)
// Boom/PrBoom+ does not have this check at all
if (false && cheating) AM_drawMline(&l, SECRETWALLCOLORS + lightlev);
if (false && cheating) AM_drawMline(&l, secretwallcolors + lightlev);
else AM_drawMline(&l, WALLCOLORS+lightlev);
}
#if defined CRISPY_HIGHLIGHT_REVEALED_SECRETS
Expand All @@ -1706,15 +1720,15 @@ void AM_drawWalls(void)
(lines[i].backsector->oldspecial == 9 ||
lines[i].frontsector->oldspecial == 9))
{
AM_drawMline(&l, REVEALEDSECRETWALLCOLORS);
AM_drawMline(&l, revealedsecretwallcolors);
}
#endif
// [crispy] draw 2S secret sector boundaries in purple
else if (crispy->extautomap && cheating &&
(lines[i].backsector->special == 9 ||
lines[i].frontsector->special == 9))
{
AM_drawMline(&l, SECRETWALLCOLORS);
AM_drawMline(&l, secretwallcolors);
}
else if (lines[i].backsector->floorheight
!= lines[i].frontsector->floorheight) {
Expand Down

2 comments on commit 4c0a56a

@SoDOOManiac
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, my fault with the commit message, the condition "in case PLAYPAL was not loaded from vanilla DOOM (2) IWAD or FreeD(OO)M" was actually removed.

@fabiangreffrath
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, my fault with the commit message, the condition "in case PLAYPAL was not loaded from vanilla DOOM (2) IWAD or FreeD(OO)M" was actually removed.

No problem! 🤷

Please sign in to comment.