Skip to content

Commit

Permalink
Merge branch 'fabiangreffrath:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
JROB774 committed Feb 17, 2024
2 parents 2533160 + 8040cde commit a639629
Show file tree
Hide file tree
Showing 43 changed files with 1,286 additions and 284 deletions.
4 changes: 2 additions & 2 deletions src/doom/am_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ AM_drawFline_Vanilla
#ifndef CRISPY_TRUECOLOR
#define PUTDOT(xx,yy,cc) PUTDOT_RAW(xx,yy,cc)
#else
#define PUTDOT(xx,yy,cc) PUTDOT_RAW(xx,yy,(colormaps[(cc)]))
#define PUTDOT(xx,yy,cc) PUTDOT_RAW(xx,yy,(pal_color[(cc)]))
#endif

dx = fl->b.x - fl->a.x;
Expand Down Expand Up @@ -2104,7 +2104,7 @@ static void AM_drawCrosshair(int color, boolean force)
#ifndef CRISPY_TRUECOLOR
fb[(f_w*(f_h+1))/2] = color; // single point for now
#else
fb[(f_w*(f_h+1))/2] = colormaps[color]; // single point for now
fb[(f_w*(f_h+1))/2] = pal_color[color]; // single point for now
#endif
*/

Expand Down
40 changes: 24 additions & 16 deletions src/doom/d_pwad.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ static boolean LoadSigilWad (const char *iwaddir, boolean pwadtexture)
"SIGIL.wad"
};

static const struct {
const char *name;
const char new_name[8];
} sigil_lumps [] = {
static const lump_rename_t sigil_lumps [] = {
{"CREDIT", "SIGCREDI"},
{"HELP1", "SIGHELP1"},
{"TITLEPIC", "SIGTITLE"},
Expand Down Expand Up @@ -164,7 +161,7 @@ static boolean LoadSigilWad (const char *iwaddir, boolean pwadtexture)
{
if ((autoload_dir = M_GetAutoloadDir(sigil_basename, false)))
{
W_AutoLoadWADs(autoload_dir);
W_AutoLoadWADsRename(autoload_dir, sigil_lumps, arrlen(sigil_lumps));
DEH_AutoLoadPatches(autoload_dir);
free(autoload_dir);
}
Expand All @@ -185,10 +182,7 @@ static boolean LoadSigil2Wad (const char *iwaddir, boolean pwadtexture)
"SIGIL_II_V1_0.WAD",
};

static const struct {
const char *name;
const char new_name[8];
} sigil2_lumps [] = {
static const lump_rename_t sigil2_lumps [] = {
{"CREDIT", "SG2CREDI"},
{"HELP1", "SG2HELP1"},
{"TITLEPIC", "SG2TITLE"},
Expand Down Expand Up @@ -268,7 +262,7 @@ static boolean LoadSigil2Wad (const char *iwaddir, boolean pwadtexture)
{
if ((autoload_dir = M_GetAutoloadDir(sigil2_basename, false)))
{
W_AutoLoadWADs(autoload_dir);
W_AutoLoadWADsRename(autoload_dir, sigil2_lumps, arrlen(sigil2_lumps));
DEH_AutoLoadPatches(autoload_dir);
free(autoload_dir);
}
Expand Down Expand Up @@ -351,10 +345,7 @@ static void CheckLoadNerve (void)
char *autoload_dir;
int i, j;

static const struct {
const char *name;
const char new_name[8];
} nerve_lumps [] = {
static const lump_rename_t nerve_lumps [] = {
{"TITLEPIC", "NERVEPIC"},
{"INTERPIC", "NERVEINT"},
};
Expand Down Expand Up @@ -423,7 +414,7 @@ static void CheckLoadNerve (void)
{
if ((autoload_dir = M_GetAutoloadDir(nerve_basename, false)))
{
W_AutoLoadWADs(autoload_dir);
W_AutoLoadWADsRename(autoload_dir, nerve_lumps, arrlen(nerve_lumps));
DEH_AutoLoadPatches(autoload_dir);
free(autoload_dir);
}
Expand Down Expand Up @@ -463,6 +454,11 @@ static boolean CheckMasterlevelsLoaded (void)
return false;
}

static const lump_rename_t master_lumps [] = {
{"TITLEPIC", "MASTRPIC"},
{"INTERPIC", "MASTRINT"},
};

// [crispy] auto-load the single MASTERLEVELS.WAD if available
static boolean CheckLoadMasterlevels (void)
{
Expand Down Expand Up @@ -532,7 +528,7 @@ static boolean CheckLoadMasterlevels (void)
{
if ((autoload_dir = M_GetAutoloadDir(master_basename, false)))
{
W_AutoLoadWADs(autoload_dir);
W_AutoLoadWADsRename(autoload_dir, master_lumps, arrlen(master_lumps));
DEH_AutoLoadPatches(autoload_dir);
free(autoload_dir);
}
Expand Down Expand Up @@ -634,6 +630,7 @@ static void LoadMasterlevelsWads (void)
{
int i, j;
char lumpname[9];
char *autoload_dir;

Check warning on line 633 in src/doom/d_pwad.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

src/doom/d_pwad.c:633:8 [cppcoreguidelines-init-variables]

variable 'autoload_dir' is not initialized

const char *const sky_lumps[] = {
"RSKY1",
Expand Down Expand Up @@ -677,6 +674,17 @@ static void LoadMasterlevelsWads (void)
// [crispy] indicate this is not the single MASTERLEVELS.WAD
crispy->havemaster = (char *)-1;

// [crispy] autoload from MASTERLEVELS.WAD autoload directory
if (!M_ParmExists("-noautoload"))
{
if ((autoload_dir = M_GetAutoloadDir("MASTERLEVELS.WAD", false)))

Check warning on line 680 in src/doom/d_pwad.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

src/doom/d_pwad.c:680:21 [bugprone-assignment-in-if-condition]

an assignment within an 'if' condition is bug-prone
{
W_AutoLoadWADsRename(autoload_dir, master_lumps, arrlen(master_lumps));
DEH_AutoLoadPatches(autoload_dir);
free(autoload_dir);
}
}

// [crispy] regenerate the hashtable
W_GenerateHashTable();
return;
Expand Down
2 changes: 1 addition & 1 deletion src/doom/f_finale.c
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ F_DrawPatchCol
#ifndef CRISPY_TRUECOLOR
*dest = source[srccol >> FRACBITS];
#else
*dest = colormaps[source[srccol >> FRACBITS]];
*dest = pal_color[source[srccol >> FRACBITS]];
#endif
srccol += dyi;
dest += SCREENWIDTH;
Expand Down
12 changes: 6 additions & 6 deletions src/doom/hu_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include "dstrings.h"
#include "sounds.h"

#include "r_state.h" // [crispy] colormaps
#include "r_state.h" // [crispy] pal_color
#include "v_video.h" // [crispy] V_DrawPatch() et al.
#include "v_trans.h" // [crispy] colored kills/items/secret/etc. messages

Expand Down Expand Up @@ -782,12 +782,12 @@ void HU_DemoProgressBar (void)
// V_DrawHorizLine(0, SCREENHEIGHT - 2, 1, 4); // [crispy] white start
// V_DrawHorizLine(i - 1, SCREENHEIGHT - 2, 1, 4); // [crispy] white end
#else
// V_DrawHorizLine(0, SCREENHEIGHT - 3, i, colormaps[4]); // [crispy] white
V_DrawHorizLine(0, SCREENHEIGHT - 2, i, colormaps[0]); // [crispy] black
V_DrawHorizLine(0, SCREENHEIGHT - 1, i, colormaps[4]); // [crispy] white
// V_DrawHorizLine(0, SCREENHEIGHT - 3, i, pal_color[4]); // [crispy] white
V_DrawHorizLine(0, SCREENHEIGHT - 2, i, pal_color[0]); // [crispy] black
V_DrawHorizLine(0, SCREENHEIGHT - 1, i, pal_color[4]); // [crispy] white

// V_DrawHorizLine(0, SCREENHEIGHT - 2, 1, colormaps[4]); // [crispy] white start
// V_DrawHorizLine(i - 1, SCREENHEIGHT - 2, 1, colormaps[4]); // [crispy] white end
// V_DrawHorizLine(0, SCREENHEIGHT - 2, 1, pal_color[4]); // [crispy] white start
// V_DrawHorizLine(i - 1, SCREENHEIGHT - 2, 1, pal_color[4]); // [crispy] white end
#endif
}

Expand Down
42 changes: 31 additions & 11 deletions src/doom/r_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ fixed_t* spriteoffset;
fixed_t* spritetopoffset;

lighttable_t *colormaps;
lighttable_t *pal_color; // [crispy] array holding palette colors for true color mode

Check warning on line 171 in src/doom/r_data.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

src/doom/r_data.c:171:15 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'pal_color' is non-const and globally accessible, consider making it const

Check warning on line 171 in src/doom/r_data.c

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

src/doom/r_data.c:171:15 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'pal_color' provides global access to a non-const object; consider making the pointed-to data 'const'

// [FG] check if the lump can be a Doom patch
// taken from PrBoom+ prboom2/src/r_patch.c:L350-L390
Expand Down Expand Up @@ -1189,11 +1190,11 @@ void R_InitColormaps (void)
lump = W_GetNumForName(DEH_String("COLORMAP"));
colormaps = W_CacheLumpNum(lump, PU_STATIC);
#else
byte *playpal;
int c, i, j = 0;
byte r, g, b;

playpal = W_CacheLumpName("PLAYPAL", PU_STATIC);
byte *const playpal = W_CacheLumpName("PLAYPAL", PU_STATIC);
byte *const colormap = W_CacheLumpName("COLORMAP", PU_STATIC);

if (!colormaps)
{
Expand All @@ -1208,9 +1209,11 @@ void R_InitColormaps (void)

for (i = 0; i < 256; i++)
{
r = gamma2table[crispy->gamma][playpal[3 * i + 0]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale;
g = gamma2table[crispy->gamma][playpal[3 * i + 1]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale;
b = gamma2table[crispy->gamma][playpal[3 * i + 2]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale;
const byte k = colormap[i];

r = gamma2table[crispy->gamma][playpal[3 * k + 0]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale;
g = gamma2table[crispy->gamma][playpal[3 * k + 1]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale;
b = gamma2table[crispy->gamma][playpal[3 * k + 2]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale;

colormaps[j++] = 0xff000000 | (r << 16) | (g << 8) | b;
}
Expand All @@ -1230,8 +1233,6 @@ void R_InitColormaps (void)
}
else
{
byte *const colormap = W_CacheLumpName("COLORMAP", PU_STATIC);

for (c = 0; c <= NUMCOLORMAPS; c++)
{
for (i = 0; i < 256; i++)
Expand All @@ -1243,13 +1244,31 @@ void R_InitColormaps (void)
colormaps[j++] = 0xff000000 | (r << 16) | (g << 8) | b;
}
}
}

W_ReleaseLumpName("COLORMAP");

W_ReleaseLumpName("COLORMAP");
if (!pal_color)
{
pal_color = (pixel_t*) Z_Malloc(256 * sizeof(pixel_t), PU_STATIC, 0);
}

for (i = 0, j = 0; i < 256; i++)
{
r = gamma2table[crispy->gamma][playpal[3 * i + 0]];
g = gamma2table[crispy->gamma][playpal[3 * i + 1]];
b = gamma2table[crispy->gamma][playpal[3 * i + 2]];

pal_color[j++] = 0xff000000 | (r << 16) | (g << 8) | b;
}

W_ReleaseLumpName("PLAYPAL");
#endif
}

// [crispy] initialize color translation and color strings tables
{
// [crispy] initialize color translation and color string tables
static void R_InitHSVColors(void)
{
byte *playpal = W_CacheLumpName("PLAYPAL", PU_STATIC);
char c[3];
int i, j;
Expand Down Expand Up @@ -1289,7 +1308,6 @@ void R_InitColormaps (void)
{
cr[CR_RED2BLUE] = W_CacheLumpNum(i, PU_STATIC);
}
}
}


Expand Down Expand Up @@ -1318,6 +1336,8 @@ void R_InitData (void)
// [crispy] Initialize and generate gamma-correction levels.
I_SetGammaTable ();
R_InitColormaps ();
// [crispy] Initialize color translation and color string tables.
R_InitHSVColors ();
#ifndef CRISPY_TRUECOLOR
R_InitTranMap(); // [crispy] prints a mark itself
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/doom/r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ void R_RenderPlayerView (player_t* player)
#ifndef CRISPY_TRUECOLOR
176 + (gametic % 16));
#else
colormaps[176 + (gametic % 16)]);
pal_color[176 + (gametic % 16)]);
#endif
}

Expand Down
1 change: 1 addition & 0 deletions src/doom/r_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ extern fixed_t* spriteoffset;
extern fixed_t* spritetopoffset;

extern lighttable_t* colormaps;
extern lighttable_t* pal_color;

Check warning on line 47 in src/doom/r_state.h

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

src/doom/r_state.h:47:22 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'pal_color' is non-const and globally accessible, consider making it const

Check warning on line 47 in src/doom/r_state.h

View workflow job for this annotation

GitHub Actions / cpp-linter (clang)

src/doom/r_state.h:47:22 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'pal_color' provides global access to a non-const object; consider making the pointed-to data 'const'

extern int viewwidth;
extern int scaledviewwidth;
Expand Down
4 changes: 4 additions & 0 deletions src/doom/wi_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1865,6 +1865,10 @@ static void WI_loadUnloadData(load_callback_t callback)
{
M_StringCopy(name, DEH_String("NERVEINT"), sizeof(name));
}
else if (crispy->havemaster && wbs->epsd == 2 && W_CheckNumForName(DEH_String("MASTRINT")) != -1) // [crispy] gamemission == pack_master
{
M_StringCopy(name, DEH_String("MASTRINT"), sizeof(name));
}
else
{
M_StringCopy(name, DEH_String("INTERPIC"), sizeof(name));
Expand Down
Loading

0 comments on commit a639629

Please sign in to comment.