From 6f032ce9c89864c3a9ad6465ae59cffa6cca156e Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Fri, 24 Jan 2025 16:57:44 +0100 Subject: [PATCH 01/11] Revert "2.1 palette pt 1" This reverts commit d22db7540903ed76b28ac099fb316507d6ad8b2f. --- src/console.c | 117 +++++++++++++++++++++-------------------- src/d_clisrv.c | 6 +-- src/d_main.cpp | 2 +- src/deh_tables.c | 6 +-- src/g_demo.c | 2 +- src/hardware/hw_defs.h | 4 +- src/hu_stuff.c | 4 +- src/k_color.c | 2 +- src/k_color.h | 2 +- src/k_kart.c | 21 +++++++- src/m_menu.c | 2 +- src/p_enemy.c | 18 +++---- src/p_mobj.c | 2 +- src/r_draw.cpp | 4 ++ src/r_draw.h | 2 +- src/r_skins.c | 6 +-- src/tmap.nas | 2 +- src/tmap_mmx.nas | 2 +- src/v_video.h | 6 +-- 19 files changed, 117 insertions(+), 93 deletions(-) diff --git a/src/console.c b/src/console.c index 519490e9b..5b34b6537 100644 --- a/src/console.c +++ b/src/console.c @@ -162,25 +162,25 @@ consvar_t cons_backcolor = CVAR_INIT ("con_backcolor", "Black", CV_CALL|CV_SAVE, static CV_PossibleValue_t menuhighlight_cons_t[] = { - {0, "Gametype Default"}, - {V_YELLOWMAP, "Always Yellow"}, - {V_PURPLEMAP, "Always Purple"}, - {V_GREENMAP, "Always Green"}, - {V_BLUEMAP, "Always Blue"}, - {V_REDMAP, "Always Red"}, - {V_GRAYMAP, "Always Gray"}, - {V_ORANGEMAP, "Always Orange"}, - {V_SKYMAP, "Always Sky-Blue"}, - {V_GOLDMAP, "Always Gold"}, - {V_LAVENDERMAP, "Always Lavender"}, - {V_TEAMAP, "Always Tea-Green"}, - {V_STEELMAP, "Always Steel-Blue"}, - {V_PINKMAP, "Always Pink"}, - {V_BROWNMAP, "Always Brown"}, - {V_PEACHMAP, "Always Peach"}, + {0, "Game type"}, + {V_YELLOWMAP, "Always yellow"}, + {V_PURPLEMAP, "Always purple"}, + {V_GREENMAP, "Always green"}, + {V_BLUEMAP, "Always blue"}, + {V_REDMAP, "Always red"}, + {V_GRAYMAP, "Always gray"}, + {V_ORANGEMAP, "Always orange"}, + {V_SKYMAP, "Always sky-blue"}, + {V_GOLDMAP, "Always gold"}, + {V_LAVENDERMAP, "Always lavender"}, + {V_AQUAMAP, "Always aqua-green"}, + {V_MAGENTAMAP, "Always magenta"}, + {V_PINKMAP, "Always pink"}, + {V_BROWNMAP, "Always brown"}, + {V_TANMAP, "Always tan"}, {0, NULL} }; -consvar_t cons_menuhighlight = CVAR_INIT ("menuhighlight", "Gametype Default", CV_SAVE, menuhighlight_cons_t, NULL); +consvar_t cons_menuhighlight = CVAR_INIT ("menuhighlight", "Game type", CV_SAVE, menuhighlight_cons_t, NULL); static void CON_Print(char *msg); @@ -365,8 +365,10 @@ static void CONS_ChooseWeighted_f(void) // Font colormap colors // TODO: This could probably be improved somehow... // These colormaps are 99% identical, with just a few changed bytes +// This could EASILY be handled by modifying a centralised colormap +// for software depending on the prior state - but yknow, OpenGL... UINT8 *yellowmap, *purplemap, *greenmap, *bluemap, *graymap, *redmap, *orangemap,\ - *skymap, *goldmap, *lavendermap, *teamap, *steelmap, *pinkmap, *brownmap, *peachmap; + *skymap, *goldmap, *lavendermap, *aquamap, *magentamap, *pinkmap, *brownmap, *tanmap; // Console BG color UINT8 *consolebgmap = NULL; @@ -385,30 +387,29 @@ void CON_SetupBackColormapEx(INT32 color, boolean prompt) shift = 6; // 12 colors -- shift of 7 means 6 colors - switch (cons_backcolor.value) + switch (color) { case 0: palindex = 15; break; // White - case 1: palindex = 31; break; // Gray - case 2: palindex = 47; break; // Sepia - case 3: palindex = 63; break; // Brown - case 4: palindex = 150; shift = 7; break; // Pink - case 5: palindex = 127; shift = 7; break; // Raspberry - case 6: palindex = 143; break; // Red - case 7: palindex = 86; shift = 7; break; // Creamsicle - case 8: palindex = 95; break; // Orange - case 9: palindex = 119; shift = 7; break; // Gold - case 10: palindex = 111; break; // Yellow - case 11: palindex = 191; shift = 7; break; // Emerald - case 12: palindex = 175; break; // Green - case 13: palindex = 219; break; // Cyan - case 14: palindex = 207; shift = 7; break; // Steel - case 15: palindex = 230; shift = 7; break; // Periwinkle - case 16: palindex = 239; break; // Blue - case 17: palindex = 199; shift = 7; break; // Purple - case 18: palindex = 255; shift = 7; break; // Lavender + case 1: palindex = 31; break; // Black + case 2: palindex = 251; break; // Sepia + case 3: palindex = 239; break; // Brown + case 4: palindex = 215; shift = 7; break; // Pink + case 5: palindex = 37; shift = 7; break; // Raspberry + case 6: palindex = 47; shift = 7; break; // Red + case 7: palindex = 53; shift = 7; break; // Creamsicle + case 8: palindex = 63; break; // Orange + case 9: palindex = 56; shift = 7; break; // Gold + case 10: palindex = 79; shift = 7; break; // Yellow + case 11: palindex = 119; shift = 7; break; // Emerald + case 12: palindex = 111; break; // Green + case 13: palindex = 136; shift = 7; break; // Cyan + case 14: palindex = 175; shift = 7; break; // Steel + case 15: palindex = 166; shift = 7; break; // Periwinkle + case 16: palindex = 159; break; // Blue + case 17: palindex = 187; shift = 7; break; // Purple + case 18: palindex = 199; shift = 7; break; // Lavender // Default green - default: palindex = 175; break; - + default: palindex = 111; break; } if (prompt) @@ -461,11 +462,11 @@ static void CON_SetupColormaps(void) skymap = (orangemap+256); lavendermap = (skymap+256); goldmap = (lavendermap+256); - teamap = (goldmap+256); - steelmap = (teamap+256); - pinkmap = (steelmap+256); + aquamap = (goldmap+256); + magentamap = (aquamap+256); + pinkmap = (magentamap+256); brownmap = (pinkmap+256); - peachmap = (brownmap+256); + tanmap = (brownmap+256); // setup the other colormaps, for console text @@ -475,21 +476,21 @@ static void CON_SetupColormaps(void) for (i = 0; i < (256*15); i++, ++memorysrc) *memorysrc = (UINT8)(i & 0xFF); // remap each color to itself... - purplemap[120] = (UINT8)194; - yellowmap[120] = (UINT8)103; - greenmap[120] = (UINT8)162; - bluemap[120] = (UINT8)228; - redmap[120] = (UINT8)126; // battle - graymap[120] = (UINT8)10; - orangemap[120] = (UINT8)85; // record attack - skymap[120] = (UINT8)214; // race - lavendermap[120] = (UINT8)248; - goldmap[120] = (UINT8)114; - teamap[120] = (UINT8)177; - steelmap[120] = (UINT8)201; - pinkmap[120] = (UINT8)145; - brownmap[120] = (UINT8)48; - peachmap[120] = (UINT8)69; // nice + purplemap[0] = (UINT8)163; + yellowmap[0] = (UINT8)73; + greenmap[0] = (UINT8)98; + bluemap[0] = (UINT8)148; + redmap[0] = (UINT8)34; // battle + graymap[0] = (UINT8)10; + orangemap[0] = (UINT8)52; // record attack + skymap[0] = (UINT8)132; // race + lavendermap[0] = (UINT8)192; + goldmap[0] = (UINT8)65; + aquamap[0] = (UINT8)121; + magentamap[0] = (UINT8)182; + pinkmap[0] = (UINT8)210; + brownmap[0] = (UINT8)224; + tanmap[0] = (UINT8)217; // no longer nice :( // Init back colormap CON_SetupBackColormap(); diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 500db3d2e..57bc4c1f0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -588,7 +588,7 @@ static inline void CL_DrawConnectionStatus(void) ) { INT32 i, animtime = ((ccstime / 4) & 15) + 16; - UINT8 palstart = (cl_mode == CL_SEARCHING) ? 128 : 160; + UINT8 palstart = (cl_mode == CL_SEARCHING) ? 32 : 96; // 15 pal entries total. const char *cltext; @@ -717,8 +717,8 @@ static inline void CL_DrawConnectionStatus(void) if (dldlength > 256) dldlength = 256; - V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, 256, 8, 175); - V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, dldlength, 8, 160); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, 256, 8, 111); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, dldlength, 8, 96); memset(tempname, 0, sizeof(tempname)); // offset filename to just the name only part diff --git a/src/d_main.cpp b/src/d_main.cpp index 5768fb544..4f8d50e98 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -613,7 +613,7 @@ static bool D_Display(void) } if (demo.rewinding) - V_DrawFadeScreen(TC_RAINBOW, (leveltime & 0x20) ? SKINCOLOR_PASTEL : SKINCOLOR_MOONSLAM); + V_DrawFadeScreen(TC_RAINBOW, (leveltime & 0x20) ? SKINCOLOR_PASTEL : SKINCOLOR_MOONSET); // vid size change is now finished if it was on... vid.recalc = 0; diff --git a/src/deh_tables.c b/src/deh_tables.c index 2e485983d..8e7721317 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -1199,11 +1199,11 @@ struct int_const_s const INT_CONST[] = { {"V_SKYMAP",V_SKYMAP}, {"V_LAVENDERMAP",V_LAVENDERMAP}, {"V_GOLDMAP",V_GOLDMAP}, - {"V_TEAMAP",V_TEAMAP}, - {"V_STEELMAP",V_STEELMAP}, + {"V_AQUAMAP",V_AQUAMAP}, + {"V_MAGENTAMAP",V_MAGENTAMAP}, {"V_PINKMAP",V_PINKMAP}, {"V_BROWNMAP",V_BROWNMAP}, - {"V_PEACHMAP",V_PEACHMAP}, + {"V_TANMAP",V_TANMAP}, {"V_TRANSLUCENT",V_TRANSLUCENT}, {"V_10TRANS",V_10TRANS}, diff --git a/src/g_demo.c b/src/g_demo.c index ff6d47072..e8f771747 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -1371,7 +1371,7 @@ skippedghosttic: g->mo->color = skin->supercolor; } else - g->mo->color = SKINCOLOR_SUPER1; + g->mo->color = SKINCOLOR_SUPERGOLD1; g->mo->color += abs( ( (signed)( (unsigned)leveltime >> 1 ) % 9) - 4); break; case GHC_INVINCIBLE: // Mario invincibility (P_CheckInvincibilityTimer) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index c75155f3e..6f279af85 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -40,8 +40,8 @@ typedef unsigned char FBOOLEAN; // ========================================================================== // byte value for paletted graphics, which represent the transparent color -#define HWR_PATCHES_CHROMAKEY_COLORINDEX 247 -//#define HWR_CHROMAKEY_EQUIVALENTCOLORINDEX 220 +#define HWR_PATCHES_CHROMAKEY_COLORINDEX 255 +//#define HWR_CHROMAKEY_EQUIVALENTCOLORINDEX 130 // the chroma key color shows on border sprites, set it to black #define HWR_PATCHES_CHROMAKEY_COLORVALUE (0x00000000) //RGBA format as in grSstWinOpen() diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 9c2350df2..972faab56 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -793,7 +793,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) { UINT16 chatcolor = skincolors[players[playernum].skincolor].chatcolor; - if (chatcolor > V_PEACHMAP) + if (chatcolor > V_TANMAP) { sprintf(color_prefix, "%c", '\x80'); } @@ -832,7 +832,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) { UINT16 chatcolor = skincolors[players[playernum].skincolor].chatcolor; - if (chatcolor > V_PEACHMAP) + if (chatcolor > V_TANMAP) { sprintf(color_prefix, "%c", '\x80'); } diff --git a/src/k_color.c b/src/k_color.c index a71faaa4c..d5ce16bba 100644 --- a/src/k_color.c +++ b/src/k_color.c @@ -121,7 +121,7 @@ void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, skincolornum_t if (skinnum == TC_BOSS) dest_colormap[31] = 0; else if (skinnum == TC_METALSONIC) - dest_colormap[239] = 0; + dest_colormap[143] = 0; return; } diff --git a/src/k_color.h b/src/k_color.h index a3c566cf2..2f002c6e6 100644 --- a/src/k_color.h +++ b/src/k_color.h @@ -20,7 +20,7 @@ extern "C" { #endif #define SKIN_RAMP_LENGTH 16 -#define DEFAULT_STARTTRANSCOLOR 160 +#define DEFAULT_STARTTRANSCOLOR 96 #define NUM_PALETTE_ENTRIES 256 /*-------------------------------------------------- diff --git a/src/k_kart.c b/src/k_kart.c index a71ccd339..8fcd48c15 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2297,7 +2297,26 @@ void K_SpawnNormalSpeedLines(player_t *player) P_SetScale(fast, 3*fast->scale/2); } - if (player->tripwireLeniency) + if (player->eggmanexplode) + { + // Make it red when you have the eggman speed boost + fast->color = SKINCOLOR_RED; + fast->colorized = true; + } + else if (player->invincibilitytimer) + { + const tic_t defaultTime = itemtime+(2*TICRATE); + if (player->invincibilitytimer > defaultTime) + { + fast->color = player->mo->color; + } + else + { + fast->color = SKINCOLOR_INVINCFLASH; + } + fast->colorized = true; + } + else if (player->tripwireLeniency) { // Make it pink+blue+big when you can go through tripwire fast->color = (leveltime & 1) ? SKINCOLOR_LILAC : SKINCOLOR_JAWZ; diff --git a/src/m_menu.c b/src/m_menu.c index 35b13182d..e84014d09 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3755,7 +3755,7 @@ static void M_DrawSlider(INT32 x, INT32 y, const consvar_t *cv, boolean ontop) void M_DrawTextBox(INT32 x, INT32 y, INT32 width, INT32 boxlines) { // Solid color textbox. - V_DrawFill(x+5, y+5, width*8+6, boxlines*8+6, 239); + V_DrawFill(x+5, y+5, width*8+6, boxlines*8+6, 159); //V_DrawFill(x+8, y+8, width*8, boxlines*8, 31); /* patch_t *p; diff --git a/src/p_enemy.c b/src/p_enemy.c index 7fee92e8e..4ab8ca3e0 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -2534,16 +2534,16 @@ void A_Boss1Laser(mobj_t *actor) tic_t dur; static const UINT8 LASERCOLORS[] = { - SKINCOLOR_KSUPER3, - SKINCOLOR_KSUPER4, - SKINCOLOR_KSUPER5, + SKINCOLOR_SUPERRED3, + SKINCOLOR_SUPERRED4, + SKINCOLOR_SUPERRED5, SKINCOLOR_KETCHUP, SKINCOLOR_RED, SKINCOLOR_RED, SKINCOLOR_KETCHUP, - SKINCOLOR_KSUPER5, - SKINCOLOR_KSUPER4, - SKINCOLOR_KSUPER3, + SKINCOLOR_SUPERRED5, + SKINCOLOR_SUPERRED4, + SKINCOLOR_SUPERRED3, }; if (LUA_CallAction(A_BOSS1LASER, actor)) @@ -10232,8 +10232,8 @@ void P_InternalFlickySetColor(mobj_t *actor, UINT8 color) SKINCOLOR_BEIGE, SKINCOLOR_LAVENDER, SKINCOLOR_RUBY, - SKINCOLOR_ORANGE, - SKINCOLOR_SUNSET, + SKINCOLOR_BLOSSOM, + SKINCOLOR_SUNSLAM, SKINCOLOR_ORANGE, SKINCOLOR_YELLOW, }; @@ -12706,7 +12706,7 @@ void A_RolloutSpawn(mobj_t *actor) if (actor->target->flags2 & MF2_AMBUSH) { - actor->target->color = SKINCOLOR_BROWN; + actor->target->color = SKINCOLOR_SUPERRUST3; actor->target->colorized = true; } } diff --git a/src/p_mobj.c b/src/p_mobj.c index 447b24fe0..1597642af 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9418,7 +9418,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->flags2 |= MF2_INVERTAIMABLE; break; case MT_FLICKY_08: - mobj->color = (P_RandomChance(FRACUNIT/2) ? SKINCOLOR_RED : SKINCOLOR_ULTRAMARINE); + mobj->color = (P_RandomChance(FRACUNIT/2) ? SKINCOLOR_RED : SKINCOLOR_AQUAMARINE); break; case MT_BALLOON: { diff --git a/src/r_draw.cpp b/src/r_draw.cpp index e063c57ee..588c1cb99 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -153,6 +153,10 @@ float zeroheight; #define DEFAULT_STARTTRANSCOLOR 160 #define NUM_PALETTE_ENTRIES 256 +#define SKIN_RAMP_LENGTH 16 +#define DEFAULT_STARTTRANSCOLOR 96 +#define NUM_PALETTE_ENTRIES 256 + static UINT8 **translationtablecache[TT_CACHE_SIZE] = {NULL}; UINT8 skincolor_modified[MAXSKINCOLORS]; diff --git a/src/r_draw.h b/src/r_draw.h index 7a070ccdd..a7bc1bec8 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -188,7 +188,7 @@ void R_FillBackScreen(void); void R_DrawViewBorder(void); #endif -#define TRANSPARENTPIXEL 247 +#define TRANSPARENTPIXEL 255 #define BRIGHTPIXEL 0 // ----------------- diff --git a/src/r_skins.c b/src/r_skins.c index 2ba8b57ed..0ef47fd61 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -109,9 +109,9 @@ static void Sk_SetDefaultValue(skin_t *skin) skin->flags = 0; strcpy(skin->realname, "Someone"); - skin->starttranscolor = 160; + skin->starttranscolor = 96; skin->prefcolor = SKINCOLOR_GREEN; - skin->supercolor = SKINCOLOR_SUPER1; + skin->supercolor = SKINCOLOR_SUPERGOLD1; skin->prefoppositecolor = 0; // use tables skin->kartspeed = 5; @@ -459,7 +459,7 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value) else if (!stricmp(stoken, "supercolor")) { UINT16 color = R_GetSuperColorByName(value); - skin->supercolor = (color ? color : SKINCOLOR_SUPER1); + skin->supercolor = (color ? color : SKINCOLOR_SUPERGOLD1); } #define GETFLOAT(field) else if (!stricmp(stoken, #field)) skin->field = FLOAT_TO_FIXED(atof(value)); diff --git a/src/tmap.nas b/src/tmap.nas index dddb1de54..69282d0b4 100644 --- a/src/tmap.nas +++ b/src/tmap.nas @@ -17,7 +17,7 @@ [BITS 32] %define FRACBITS 16 -%define TRANSPARENTPIXEL 247 +%define TRANSPARENTPIXEL 255 %ifdef LINUX %macro cextern 1 diff --git a/src/tmap_mmx.nas b/src/tmap_mmx.nas index 5b82338ee..15b97499d 100644 --- a/src/tmap_mmx.nas +++ b/src/tmap_mmx.nas @@ -18,7 +18,7 @@ [BITS 32] %define FRACBITS 16 -%define TRANSPARENTPIXEL 247 +%define TRANSPARENTPIXEL 255 %ifdef LINUX %macro cextern 1 diff --git a/src/v_video.h b/src/v_video.h index 01cb33ae6..0d3304472 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -119,11 +119,11 @@ void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue); #define V_SKYMAP 0x00008000 #define V_LAVENDERMAP 0x00009000 #define V_GOLDMAP 0x0000A000 -#define V_TEAMAP 0x0000B000 -#define V_STEELMAP 0x0000C000 +#define V_AQUAMAP 0x0000B000 +#define V_MAGENTAMAP 0x0000C000 #define V_PINKMAP 0x0000D000 #define V_BROWNMAP 0x0000E000 -#define V_PEACHMAP 0x0000F000 +#define V_TANMAP 0x0000F000 // use bits 17-20 for alpha transparency #define V_ALPHASHIFT 16 From 4e188f4cae89957ae71567b83050af854098b3cf Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Fri, 24 Jan 2025 17:08:26 +0100 Subject: [PATCH 02/11] Revert "2.1 palette pt 2: Menu stuff" This reverts commit 771938161ada5f94aa21f90516cf70837b82ec46. --- src/g_game.c | 8 ++++---- src/m_menu.c | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 0a06ac7f2..f520fb34a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3418,15 +3418,15 @@ UINT8 G_GetGametypeColor(INT16 gt) { if (modeattacking // == ATTACKING_TIME || gamestate == GS_TIMEATTACK) - return orangemap[120]; + return orangemap[0]; if (gt == GT_BATTLE) - return redmap[120]; + return redmap[0]; if (gt == GT_RACE) - return skymap[120]; + return skymap[0]; - return 247; // FALLBACK + return 255; // FALLBACK } /** Get the typeoflevel flag needed to indicate support of a gametype. diff --git a/src/m_menu.c b/src/m_menu.c index e84014d09..8884ef382 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4916,10 +4916,10 @@ static void M_DrawTemperature(INT32 x, fixed_t t) t = (FixedMul(h<>FRACBITS); // border - V_DrawFill(x - 1, vpadding, 1, h, 120); - V_DrawFill(x + width, vpadding, 1, h, 120); - V_DrawFill(x - 1, vpadding-1, width+2, 1, 120); - V_DrawFill(x - 1, vpadding+h, width+2, 1, 120); + V_DrawFill(x - 1, vpadding, 1, h, 0); + V_DrawFill(x + width, vpadding, 1, h, 0); + V_DrawFill(x - 1, vpadding-1, width+2, 1, 0); + V_DrawFill(x - 1, vpadding+h, width+2, 1, 0); // bar itself y = h; @@ -5074,14 +5074,14 @@ static void M_DrawAddons(void) x = currentMenu->x; y = currentMenu->y + 1; - hilicol = V_GetStringColormap(highlightflags)[120]; + hilicol = V_GetStringColormap(highlightflags)[0]; V_DrawString(x-21, (y - 16) + (lsheadingheight - 12), highlightflags|V_ALLOWLOWERCASE, M_AddonsHeaderPath()); V_DrawFill(x-21, (y - 16) + (lsheadingheight - 3), MAXSTRINGLENGTH*8+6, 1, hilicol); V_DrawFill(x-21, (y - 16) + (lsheadingheight - 2), MAXSTRINGLENGTH*8+6, 1, 30); m = (BASEVIDHEIGHT - currentMenu->y + 2) - (y - 1); - V_DrawFill(x - 21, y - 1, MAXSTRINGLENGTH*8+6, m, 239); + V_DrawFill(x - 21, y - 1, MAXSTRINGLENGTH*8+6, m, 159); // scrollbar! if (sizedirmenu <= (2*numaddonsshown + 1)) @@ -5809,8 +5809,8 @@ static void M_DrawReplayHut(void) y = sizedirmenu*10 + currentMenu->menuitems[replaylistitem].alphaKey + 30; if (y > SCALEDVIEWHEIGHT-80) { - V_DrawFill(BASEVIDWIDTH-4, 75, 4, SCALEDVIEWHEIGHT-80, V_SNAPTOTOP|V_SNAPTORIGHT|239); - V_DrawFill(BASEVIDWIDTH-3, 76 + (SCALEDVIEWHEIGHT-80) * replayhutmenuy / y, 2, (((SCALEDVIEWHEIGHT-80) * (SCALEDVIEWHEIGHT-80))-1) / y - 1, V_SNAPTOTOP|V_SNAPTORIGHT|229); + V_DrawFill(BASEVIDWIDTH-4, 75, 4, SCALEDVIEWHEIGHT-80, V_SNAPTOTOP|V_SNAPTORIGHT|159); + V_DrawFill(BASEVIDWIDTH-3, 76 + (SCALEDVIEWHEIGHT-80) * replayhutmenuy / y, 2, (((SCALEDVIEWHEIGHT-80) * (SCALEDVIEWHEIGHT-80))-1) / y - 1, V_SNAPTOTOP|V_SNAPTORIGHT|149); } // Draw the cursor @@ -5819,7 +5819,7 @@ static void M_DrawReplayHut(void) V_DrawString(currentMenu->x, cursory, V_SNAPTOTOP|V_SNAPTOLEFT|highlightflags, currentMenu->menuitems[itemOn].text); // Now draw some replay info! - V_DrawFill(10, 10, 300, 60, V_SNAPTOTOP|239); + V_DrawFill(10, 10, 300, 60, V_SNAPTOTOP|159); if (itemOn == replaylistitem) { From 5766bec781c2282c0c66d4ba144d5014e655fb45 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Fri, 24 Jan 2025 17:08:46 +0100 Subject: [PATCH 03/11] Revert "2.1 palette pt 2.5: more menu stuff" This reverts commit 016f16d91fec8cfbb831f2f5a6e025e1ca63852a. --- src/m_menu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 8884ef382..53f59792e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5905,7 +5905,7 @@ static void M_DrawReplayStartMenu(void) } } - V_DrawFill(10, 10, 300, 60, V_SNAPTOTOP|239); + V_DrawFill(10, 10, 300, 60, V_SNAPTOTOP|159); DrawReplayHutReplayInfo(); V_DrawString(10, 72, V_SNAPTOTOP|highlightflags|V_ALLOWLOWERCASE, demolist[dir_on[menudepthleft]].title); @@ -7949,7 +7949,7 @@ void M_DrawTimeAttackMenu(void) time = mainrecords[cv_nextmap.value-1]->time; } - V_DrawFill((BASEVIDWIDTH - dupadjust)>>1, 78, dupadjust, 36, 239); + V_DrawFill((BASEVIDWIDTH - dupadjust)>>1, 78, dupadjust, 36, 159); if (levellistmode != LLM_ITEMBREAKER) { @@ -9140,7 +9140,7 @@ Update the maxplayers label... #ifndef NONET y += MP_MainMenu[8].alphaKey; - V_DrawFill(x+5, y+4+5, /*16*8 + 6,*/ BASEVIDWIDTH - 2*(x+5), 8+6, 239); + V_DrawFill(x+5, y+4+5, /*16*8 + 6,*/ BASEVIDWIDTH - 2*(x+5), 8+6, 159); // draw name string V_DrawString(x+8,y+12, V_ALLOWLOWERCASE, setupm_ip); @@ -9640,7 +9640,7 @@ static void M_DrawSetupMultiPlayerMenu(void) flags |= V_FLIP; // This sprite is left/right flipped! // draw box around guy - V_DrawFill(mx + 43 - (charw/2), my+65, charw, 84, 239); + V_DrawFill(mx + 43 - (charw/2), my+65, charw, 84, 159); // draw player sprite if (setupm_fakecolor->color) // inverse should never happen From be64786d576eda63418b3653e72d7ccd9203b2fa Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Fri, 24 Jan 2025 17:35:45 +0100 Subject: [PATCH 04/11] Update skincolors --- src/doomdef.h | 2 +- src/info/skincolors.h | 262 +++++++++++++----------------------------- 2 files changed, 79 insertions(+), 185 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 3a2c3d502..c24e1000f 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -240,7 +240,7 @@ typedef enum MAXSKINCOLORS, FIRSTRAINBOWCOLOR = SKINCOLOR_PINK, - FIRSTSUPERCOLOR = SKINCOLOR_SUPER1, + FIRSTSUPERCOLOR = SKINCOLOR_SUPERSILVER1, NUMSUPERCOLORS = ((SKINCOLOR_FIRSTFREESLOT - FIRSTSUPERCOLOR)/5) } skincolornum_t; diff --git a/src/info/skincolors.h b/src/info/skincolors.h index 7de0a514c..9c43bb3d9 100644 --- a/src/info/skincolors.h +++ b/src/info/skincolors.h @@ -11,44 +11,39 @@ _(ARTICHOKE) _(PIGEON) _(SEPIA) _(BEIGE) -_(WALNUT) +_(CARAMEL) +_(PEACH) _(BROWN) _(LEATHER) -_(SALMON) _(PINK) _(ROSE) -_(BRICK) _(CINNAMON) _(RUBY) _(RASPBERRY) -_(CHERRY) _(RED) _(CRIMSON) _(MAROON) _(LEMONADE) -_(FLAME) _(SCARLET) _(KETCHUP) _(DAWN) -_(SUNSET) +_(SUNSLAM) _(CREAMSICLE) _(ORANGE) -_(PUMPKIN) _(ROSEWOOD) -_(BURGUNDY) _(TANGERINE) -_(PEACH) -_(CARAMEL) +_(TAN) _(CREAM) _(GOLD) _(ROYAL) _(BRONZE) _(COPPER) -_(QUARRY) _(YELLOW) _(MUSTARD) -_(CROCODILE) +_(BANANA) _(OLIVE) +_(CROCODILE) +_(PERIDOT) _(VOMIT) _(GARDEN) _(LIME) @@ -57,19 +52,19 @@ _(TEA) _(PISTACHIO) _(MOSS) _(CAMOUFLAGE) -_(ROBOHOOD) _(MINT) _(GREEN) _(PINETREE) -_(EMERALD) +_(TURTLE) _(SWAMP) _(DREAM) _(PLAGUE) +_(EMERALD) _(ALGAE) -_(CARIBBEAN) -_(AZURE) -_(AQUA) +_(AQUAMARINE) +_(TURQUOISE) _(TEAL) +_(ROBIN) _(CYAN) _(JAWZ) // Oni's torment _(CERULEAN) @@ -78,20 +73,23 @@ _(PLATINUM) _(SLATE) _(STEEL) _(THUNDER) +_(NOVA) _(RUST) _(WRISTWATCH) _(JET) _(SAPPHIRE) // sweet mother, i cannot weave - slender aphrodite has overcome me with longing for a girl +_(ULTRAMARINE) _(PERIWINKLE) _(BLUE) +_(MIDNIGHT) _(BLUEBERRY) -_(NOVA) -_(PASTEL) -_(MOONSLAM) -_(ULTRAVIOLET) -_(DUSK) -_(BUBBLEGUM) +_(THISTLE) _(PURPLE) +_(PASTEL) +_(MOONSET) +_(DUSK) +_(VIOLET) +_(MAGENTA) _(FUCHSIA) _(TOXIC) _(MAUVE) @@ -99,174 +97,70 @@ _(LAVENDER) _(BYZANTIUM) _(POMEGRANATE) _(LILAC) -_(BONE) // vanilla colors - shoutouts to Sonic Team Jr. -_(CARBON) -_(INK) -_(GHOST) -_(MARBLE) -_(BLUEBELL) -_(CHOCOLATE) -_(TAN) -_(PEACHY) -_(QUAIL) -_(LANTERN) -_(APRICOT) -_(SANDY) -_(BANANA) -_(SUNFLOWER) -_(OLIVINE) -_(PERIDOT) -_(APPLE) -_(SEAFOAM) -_(FOREST) -_(TOPAZ) -_(FROST) -_(WAVE) -_(ICY) -_(PEACOCK) -_(VAPOR) -_(GEMSTONE) -_(NEON) -_(PLUM) -_(VIOLET) -_(MAGENTA) -_(THISTLE) -_(DIAMOND) // custom color expansion begins here -_(RAVEN) -_(MUD) -_(EARTHWORM) -_(YOGURT) -_(PEARL) -_(STRAWBERRY) -_(SODA) -_(BLOODCELL) -_(MAHOGANY) -_(FIERY) -_(SPICE) -_(KING) -_(HOTDOG) -_(CARNATION) -_(CANDY) -_(NEBULA) -_(STEAMPUNK) -_(AMBER) -_(CARROT) -_(CHEESE) -_(DUNE) -_(BRASS) -_(CITRINE) -_(LEMON) -_(CASKET) -_(KHAKI) -_(LIGHT) -_(PEPPERMINT) -_(LASER) -_(ASPARAGUS) -_(ARMY) -_(CROW) -_(CHARTEUSE) -_(SLIME) -_(LEAF) -_(JUNGLE) -_(EVERGREEN) -_(TROPIC) -_(IGUANA) -_(SPEARMINT) -_(PATINA) -_(LAKESIDE) -_(ELECTRIC) -_(TURQUOISE) -_(PEGASUS) -_(PLASMA) -_(COMET) -_(LIGHTNING) -_(VACATION) -_(ULTRAMARINE) -_(DEPTHS) -_(DIANNE) -_(EXOTIC) -_(SNOW) -_(MOON) -_(LUNAR) -_(ONYX) -_(LAPIS) -_(ORCA) -_(STORM) -_(MIDNIGHT) -_(COTTONCANDY) // this color was a pain to get right -_(CYBER) // this one too -_(AMETHYST) -_(IRIS) -_(GOTHIC) -_(GRAPE) -_(INDIGO) -_(SAKURA) -_(DISCO) -_(MULBERRY) -_(BOYSENBERRY) -_(MYSTIC) -_(WICKED) +_(BLOSSOM) +_(TAFFY) // Super special awesome Super flashing colors! -// Super Sonic Yellow -_(SUPER1) -_(SUPER2) -_(SUPER3) -_(SUPER4) -_(SUPER5) +_(SUPERSILVER1) +_(SUPERSILVER2) +_(SUPERSILVER3) +_(SUPERSILVER4) +_(SUPERSILVER5) -// Super Tails Orange -_(TSUPER1) -_(TSUPER2) -_(TSUPER3) -_(TSUPER4) -_(TSUPER5) +_(SUPERRED1) +_(SUPERRED2) +_(SUPERRED3) +_(SUPERRED4) +_(SUPERRED5) -// Super Knuckles Red -_(KSUPER1) -_(KSUPER2) -_(KSUPER3) -_(KSUPER4) -_(KSUPER5) +_(SUPERORANGE1) +_(SUPERORANGE2) +_(SUPERORANGE3) +_(SUPERORANGE4) +_(SUPERORANGE5) -// Hyper Sonic Pink -_(PSUPER1) -_(PSUPER2) -_(PSUPER3) -_(PSUPER4) -_(PSUPER5) +_(SUPERGOLD1) +_(SUPERGOLD2) +_(SUPERGOLD3) +_(SUPERGOLD4) +_(SUPERGOLD5) -// Hyper Sonic Blue -_(BSUPER1) -_(BSUPER2) -_(BSUPER3) -_(BSUPER4) -_(BSUPER5) +_(SUPERPERIDOT1) +_(SUPERPERIDOT2) +_(SUPERPERIDOT3) +_(SUPERPERIDOT4) +_(SUPERPERIDOT5) -// Aqua Super -_(ASUPER1) -_(ASUPER2) -_(ASUPER3) -_(ASUPER4) -_(ASUPER5) +_(SUPERSKY1) +_(SUPERSKY2) +_(SUPERSKY3) +_(SUPERSKY4) +_(SUPERSKY5) -// Hyper Sonic Green -_(GSUPER1) -_(GSUPER2) -_(GSUPER3) -_(GSUPER4) -_(GSUPER5) +_(SUPERPURPLE1) +_(SUPERPURPLE2) +_(SUPERPURPLE3) +_(SUPERPURPLE4) +_(SUPERPURPLE5) -// Hyper Sonic White -_(WSUPER1) -_(WSUPER2) -_(WSUPER3) -_(WSUPER4) -_(WSUPER5) +_(SUPERRUST1) +_(SUPERRUST2) +_(SUPERRUST3) +_(SUPERRUST4) +_(SUPERRUST5) -// Creamy Super (Shadow?) -_(CSUPER1) -_(CSUPER2) -_(CSUPER3) -_(CSUPER4) -_(CSUPER5) +_(SUPERTAN1) +_(SUPERTAN2) +_(SUPERTAN3) +_(SUPERTAN4) +_(SUPERTAN5) + +_(CHAOSEMERALD1) +_(CHAOSEMERALD2) +_(CHAOSEMERALD3) +_(CHAOSEMERALD4) +_(CHAOSEMERALD5) +_(CHAOSEMERALD6) +_(CHAOSEMERALD7) + +_(INVINCFLASH) From d67c9862aee1e690febc2c946ff7a267d90c4bec Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Fri, 24 Jan 2025 17:17:47 +0100 Subject: [PATCH 05/11] Add compatmode flag --- src/d_netcmd.c | 2 ++ src/w_wad.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/w_wad.h | 1 + 3 files changed, 43 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index fde1a4e27..2a488a17c 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4634,6 +4634,8 @@ static void Command_ListWADS_f(void) CONS_Printf("\x82 * %.2d\x80: %s\n", i, tempname); else if (!wadfiles[i]->important) CONS_Printf("\x86 %.2d: %s\n", i, tempname); + else if (wadfiles[i]->compatmode) + CONS_Printf("\x8a %.2d: %s\n", i, tempname); else CONS_Printf(" %.2d: %s\n", i, tempname); } diff --git a/src/w_wad.c b/src/w_wad.c index afc6c2caf..e9f346746 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -291,6 +291,33 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum, boolean mainfile) #endif } +static inline boolean CheckCompatFilename(char *filename) +{ + // check for a K prefix + char *basename = strrchr(filename, *PATHSEP); + return toupper(basename ? basename[1] : filename[0]) == 'K'; +} + +// try to figure out if a PK3 file needs compatmode enabled (palette remap) +static inline boolean CheckCompatZip(UINT16 wadnum) +{ + if (CheckCompatFilename(wadfiles[wadnum]->filename)) + return true; + + // assume RR/2.2 for PK3s so basegame assets work + return false; +} + +// ditto, but for WADs +static inline boolean CheckCompatWad(UINT16 wadnum) +{ + if (CheckCompatFilename(wadfiles[wadnum]->filename)) + return true; + + // assume Kart/2.1 for WADs so basegame assets work + return true; +} + /** Compute MD5 message digest for bytes read from STREAM of this filname. * * The resulting message digest number will be written into the 16 bytes @@ -872,6 +899,19 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) break; } + // check if compatmode is needed + switch (wadfile->type) + { + case RET_WAD: + wadfile->compatmode = CheckCompatWad(numwadfiles - 1); + break; + case RET_PK3: + wadfile->compatmode = CheckCompatZip(numwadfiles - 1); + break; + default: + break; + } + if (refreshdirmenu & REFRESHDIR_GAMEDATA) G_LoadGameData(); DEH_UpdateMaxFreeslots(); diff --git a/src/w_wad.h b/src/w_wad.h index 43aa1b228..27b7174ac 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -128,6 +128,7 @@ struct wadfile_t UINT8 md5sum[16]; boolean important; // also network - !W_VerifyNMUSlumps + boolean compatmode; // TODO: network this too! }; #define WADFILENUM(lumpnum) (UINT16)((lumpnum)>>16) // wad flumpnum>>16) // wad file number in upper word From 63d558725e8c7a8f40eace4f849ea02fd36c83e6 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Fri, 24 Jan 2025 17:51:46 +0100 Subject: [PATCH 06/11] Swap the order of main.pk3 and srb2.srb --- src/d_main.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 4f8d50e98..ae5400116 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1137,7 +1137,7 @@ static void ChangeDirForUrlHandler(void) static boolean AddIWAD(void) { - char * path = va(pandf,srb2path,"main.pk3"); + char * path = va(pandf,srb2path,"srb2.srb"); if (FIL_ReadFileOK(path)) { @@ -1155,7 +1155,7 @@ static void IdentifyVersion(void) const char *srb2waddir = NULL; #if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL) - // change to the directory where 'main.pk3' is found + // change to the directory where 'srb2.srb' is found srb2waddir = I_LocateWad(); #endif @@ -1175,7 +1175,7 @@ static void IdentifyVersion(void) // Load the IWAD if (! AddIWAD()) { - I_Error("main.pk3 not found! Expected in %s\n", srb2waddir); + I_Error("srb2.srb not found! Expected in %s\n", srb2waddir); } // will be overwritten in case of -cdrom or unix/win home @@ -1185,7 +1185,7 @@ static void IdentifyVersion(void) // if you change the ordering of this or add/remove a file, be sure to update the md5 // checking in D_SRB2Main -#define SRB2NAME "srb2.srb" +#define MAINNAME "main.pk3" #define TEXTURESNAME "textures.kart" #define MAPSNAME "maps.kart" #define PATCHNAME "patch.pk3" @@ -1195,7 +1195,7 @@ static void IdentifyVersion(void) #define GRAPHICSNAME "gfx.kart" #define SOUNDSNAME "sounds.kart" - D_AddFile(startupiwads, va(pandf,srb2waddir,SRB2NAME)); + D_AddFile(startupiwads, va(pandf,srb2waddir,MAINNAME)); D_AddFile(startupiwads, va(pandf,srb2waddir,GRAPHICSNAME)); D_AddFile(startupiwads, va(pandf,srb2waddir,TEXTURESNAME)); D_AddFile(startupiwads, va(pandf,srb2waddir,CHARSNAME)); @@ -1205,7 +1205,7 @@ static void IdentifyVersion(void) D_AddFile(startupiwads, va(pandf,srb2waddir,PATCHNAME)); #endif //// -#undef SRB2NAME +#undef MAINNAME #undef TEXTURESNAME #undef MAPSNAME #undef PATCHNAME @@ -1483,8 +1483,8 @@ void D_SRB2Main(void) #ifndef DEVELOP // Check MD5s of autoloaded files // Note: Do not add any files that ignore MD5! - W_VerifyFileMD5(mainwads, ASSET_HASH_MAIN_PK3); // main.pk3 - mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_SRB2_SRB); // gfx.pk3 + W_VerifyFileMD5(mainwads, ASSET_HASH_SRB2_SRB); // srb2.srb + mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_MAIN_PK3); // main.pk3 mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_GFX_KART); // gfx.pk3 mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_TEXTURES_KART); // textures.pk3 mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_CHARS_PK3); // chars.pk3 @@ -1494,7 +1494,7 @@ void D_SRB2Main(void) mainwads++; W_VerifyFileMD5(mainwads, ASSET_HASH_PATCH_PK3); // patch.pk3 #endif #else - mainwads++; // srb2.srb + mainwads++; // main.pk3 mainwads++; // gfx.kart mainwads++; // textures.kart mainwads++; // chars.pk3 From 48bb0ea5ef36b73042e3ee6501f72acad01a030a Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Fri, 24 Jan 2025 18:18:37 +0100 Subject: [PATCH 07/11] The actual palette remapping --- src/d_main.cpp | 2 ++ src/hardware/hw_cache.c | 11 +++++++++++ src/r_data.c | 25 +++++++++++++++++++++++++ src/r_draw.cpp | 19 +++++++++++++++++++ src/r_draw.h | 5 +++++ src/r_textures.c | 36 +++++++++++++++++++++++++++++++++++- src/r_textures.h | 2 ++ src/v_video.c | 32 ++++++++++++++++++++++++++++++-- src/w_wad.c | 20 ++++++++++++++++++++ src/w_wad.h | 1 + 10 files changed, 150 insertions(+), 3 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index ae5400116..dc947187c 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1506,6 +1506,8 @@ void D_SRB2Main(void) #endif //ifndef DEVELOP + R_InitPaletteRemap(); + // now do it again for the SOC colors in main.pk3! M_InitPlayerSetupColors(); diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index c8ae308e4..79fb6f4cb 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -522,12 +522,18 @@ static void HWR_GenerateTexture(GLMapTexture_t *grtex, INT32 texnum, boolean noe #endif #ifdef WALLFLATS if (texture->type == TEXTURETYPE_FLAT) + { + if (W_NeedPaletteRemap()) + R_DoPaletteRemapFlat(pdata, lumplength); realpatch = (softwarepatch_t *)Picture_Convert(PICFMT_FLAT, pdata, PICFMT_DOOMPATCH, 0, NULL, texture->width, texture->height, 0, 0, 0); + } else #endif { (void)lumplength; dealloc = false; + if (W_NeedPaletteRemap()) + R_DoPaletteRemapPatch(realpatch, lumplength); } HWR_DrawTexturePatchInCache(&grtex->mipmap, blockwidth, blockheight, texture, patch, realpatch); @@ -878,6 +884,11 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum), PU_HWRCACHE, &grMipmap->data)); + // palette remapping + // have to do this here since the lump isn't cached + if (wadfiles[WADFILENUM(flatlumpnum)]->compatmode) + R_DoPaletteRemapFlat(grMipmap->data, size); + flat = grMipmap->data; for (steppy = 0; steppy < size; steppy++) if (flat[steppy] != HWR_PATCHES_CHROMAKEY_COLORINDEX) diff --git a/src/r_data.c b/src/r_data.c index 9ac323814..c2ba15c5f 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -292,6 +292,7 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap) char colormap[9] = "COLORMAP"; lumpnum_t lump; const lumpnum_t basecolormaplump = W_GetNumForName(colormap); + boolean remap = false; if (num > 0 && num <= 10000) snprintf(colormap, 8, "CLM%04u", num-1); @@ -301,6 +302,7 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap) lump = basecolormaplump; else { + remap = wadfiles[WADFILENUM(lump)]->compatmode; if (W_LumpLength(lump) != W_LumpLength(basecolormaplump)) { CONS_Alert(CONS_WARNING, "%s lump size does not match COLORMAP, results may be unexpected.\n", colormap); @@ -309,6 +311,19 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap) W_ReadLumpHeader(lump, colormaps, W_LumpLength(basecolormaplump), 0U); + if (remap) + { + lighttable_t *copy = malloc(W_LumpLength(basecolormaplump)); + memcpy(copy, colormaps, W_LumpLength(basecolormaplump)); + for (int p = 0; p < LIGHTLEVELS; p++) + { + for (int i = 0; i < 256; i++) + // 2.2 colormap index to 2.1, then 2.1 palette color to 2.2 + colormaps[p*256 + i] = R_GetPaletteRemap(copy[p*256 + R_InvPaletteRemap(i)]); + } + free(copy); + } + // Encore mode. if (newencoremap != LUMPERROR) { @@ -320,6 +335,16 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap) colormap_p = colormap_p2 = colormaps; colormap_p += COLORMAP_REMAPOFFSET; + remap = wadfiles[WADFILENUM(newencoremap)]->compatmode; + if (remap) + { + UINT8 *copy = malloc(256); + memcpy(copy, encoremap, 256); + for (i = 0; i < 256; i++) + encoremap[i] = R_GetPaletteRemap(copy[R_InvPaletteRemap(i)]); + free(copy); + } + for (p = 0; p < LIGHTLEVELS; p++) { for (i = 0; i < 256; i++) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 588c1cb99..5d6591b02 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -108,6 +108,7 @@ UINT8 r8_flatcolor; UINT8 *transtables; // translucency tables UINT8 *blendtables[NUMBLENDMAPS]; +UINT8 *palremap, *invremap; /** \brief R_DrawTransColumn uses this */ @@ -348,6 +349,24 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel) return transtables + (ClipTransLevel(alphalevel) << FF_TRANSSHIFT); } +void R_InitPaletteRemap(void) +{ + palremap = static_cast(Z_Malloc(256, PU_STATIC, NULL)); + invremap = static_cast(Z_Malloc(256, PU_STATIC, NULL)); + W_ReadLump(W_GetNumForName("PALREMAP"), palremap); + W_ReadLump(W_GetNumForName("INVREMAP"), invremap); +} + +UINT8 R_GetPaletteRemap(UINT8 color) +{ + return palremap[color]; +} + +UINT8 R_InvPaletteRemap(UINT8 color) +{ + return invremap[color]; +} + /** \brief Retrieves a translation colormap from the cache. \param skinnum number of skin, TC_DEFAULT or TC_BOSS diff --git a/src/r_draw.h b/src/r_draw.h index a7bc1bec8..0712ab852 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -167,11 +167,16 @@ enum extern UINT8 *blendtables[NUMBLENDMAPS]; +extern UINT8 *palremap, *invremap; + void R_InitTranslucencyTables(void); void R_GenerateBlendTables(void); +void R_InitPaletteRemap(void); UINT8 *R_GetTranslucencyTable(INT32 alphalevel); UINT8 *R_GetBlendTable(int style, INT32 alphalevel); +UINT8 R_GetPaletteRemap(UINT8 color); +UINT8 R_InvPaletteRemap(UINT8 color); // Color ramp modification should force a recache extern UINT8 skincolor_modified[]; diff --git a/src/r_textures.c b/src/r_textures.c index 9aa7f68ea..d7e6b77bd 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -295,6 +295,28 @@ static boolean R_CheckTextureLumpLength(texture_t *texture, size_t patch) return true; } +void R_DoPaletteRemapPatch(softwarepatch_t *patch, size_t size) +{ + (void)size; + UINT32 *columns = patch->columnofs; + for (INT16 i = 0; i < patch->width; i++) + { + UINT8 *p = (UINT8 *)patch + columns[i]; + while (*p++ != 0xff) // topdelta + { + int length = *p++; + for (length += 2; length--; p++) + *p = R_GetPaletteRemap(*p); + } + } +} + +void R_DoPaletteRemapFlat(UINT8 *data, size_t size) +{ + for (size_t i = 0; i < size; i++, data++) + *data = R_GetPaletteRemap(*data); +} + // // R_GenerateTexture // @@ -363,6 +385,9 @@ UINT8 *R_GenerateTexture(size_t texnum) goto multipatch; #endif + if (W_NeedPaletteRemap()) + R_DoPaletteRemapPatch(realpatch, lumplength); + // Check the patch for holes. if (texture->width > SHORT(realpatch->width) || texture->height > SHORT(realpatch->height)) holey = true; @@ -458,12 +483,18 @@ UINT8 *R_GenerateTexture(size_t texnum) #endif #ifdef WALLFLATS if (texture->type == TEXTURETYPE_FLAT) + { + if (W_NeedPaletteRemap()) + R_DoPaletteRemapFlat(pdata, lumplength); realpatch = (softwarepatch_t *)Picture_Convert(PICFMT_FLAT, pdata, PICFMT_DOOMPATCH, 0, NULL, texture->width, texture->height, 0, 0, 0); + } else #endif { (void)lumplength; dealloc = false; + if (W_NeedPaletteRemap()) + R_DoPaletteRemapPatch(realpatch, lumplength); } x1 = patch->originx; @@ -893,7 +924,10 @@ UINT8 *R_GetBrightmapColumn(fixed_t tex, INT32 col) void *R_GetFlat(lumpnum_t flatlumpnum) { - return W_CacheLumpNum(flatlumpnum, PU_LEVEL); + void *flat = W_CacheLumpNum(flatlumpnum, PU_LEVEL); + if (W_NeedPaletteRemap()) + R_DoPaletteRemapFlat(flat, W_LumpLength(flatlumpnum)); + return flat; } // diff --git a/src/r_textures.h b/src/r_textures.h index 2559766f6..44f1b3d61 100644 --- a/src/r_textures.h +++ b/src/r_textures.h @@ -94,6 +94,8 @@ boolean R_TextureHasBrightmap(INT32 texnum); boolean R_TextureCanRemap(INT32 texnum); void R_CheckTextureCache(INT32 tex); void R_ClearTextureNumCache(boolean btell); +void R_DoPaletteRemapPatch(softwarepatch_t *patch, size_t size); +void R_DoPaletteRemapFlat(UINT8 *data, size_t size); // Retrieve texture data. void *R_GetLevelFlat(drawspandata_t* ds, levelflat_t *levelflat); diff --git a/src/v_video.c b/src/v_video.c index ae032b7bb..9f53cb1de 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -312,6 +312,9 @@ UINT32 V_GammaCorrect(UINT32 input, double power) static void LoadPalette(const char *lumpname) { lumpnum_t lumpnum = W_GetNumForName(lumpname); + boolean remap = wadfiles[WADFILENUM(lumpnum)]->compatmode; + if (remap) // if we're remapping, start with PLAYPAL as a base + lumpnum = W_GetNumForName("PLAYPAL"); size_t i, palsize = W_LumpLength(lumpnum)/3; UINT8 *pal; @@ -329,26 +332,51 @@ static void LoadPalette(const char *lumpname) pLocalPalette = pMasterPalette; pGammaCorrectedPalette = Z_Malloc(sizeof (*pGammaCorrectedPalette)*palsize, PU_STATIC, NULL); + // load the new palette (or PLAYPAL if remapping) pal = W_CacheLumpNum(lumpnum, PU_CACHE); for (i = 0; i < palsize; i++) { - RGBA_t pGCP; pMasterPalette[i].s.red = *pal++; pMasterPalette[i].s.green = *pal++; pMasterPalette[i].s.blue = *pal++; pMasterPalette[i].s.alpha = 0xFF; + } + RGBA_t *target = NULL; + if (remap) + { + // get the target palette we want + lumpnum = W_GetNumForName(lumpname); + pal = W_CacheLumpNum(lumpnum, PU_CACHE); + palsize = W_LumpLength(lumpnum)/3; + target = malloc(sizeof (*target)*palsize); + for (i = 0; i < palsize; i++) + { + target[i].s.red = *pal++; + target[i].s.green = *pal++; + target[i].s.blue = *pal++; + target[i].s.alpha = 0xFF; + } + } + + for (i = 0; i < palsize; i++) + { + if (remap) // now map the target palette (2.1) to master palette (2.2) + pMasterPalette[i].rgba = target[R_InvPaletteRemap(i)].rgba; pGammaCorrectedPalette[i].rgba = V_GammaDecode(pMasterPalette[i].rgba); if (!Cubeapply) continue; // Short hand this so its easier to type - pGCP = pGammaCorrectedPalette[i]; + RGBA_t pGCP = pGammaCorrectedPalette[i]; V_CubeApply(&pGCP.s.red,&pGCP.s.green,&pGCP.s.blue); pLocalPalette[i].rgba = V_GammaEncode(pGammaCorrectedPalette[i].rgba); } + + if (remap) + free(target); } void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue) diff --git a/src/w_wad.c b/src/w_wad.c index e9f346746..49efb9cf2 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1485,6 +1485,18 @@ void zerr(int ret) } #endif +// only do palette swapping ONCE, when caching the whole patch +// dumb hack but it works! +static boolean dopalswap = false; + +// returns true if the most recently loaded lump is freshly cached, AND comes from a compatmode file +boolean W_NeedPaletteRemap(void) +{ + boolean r = dopalswap; + dopalswap = false; + return r; +} + /** Reads bytes from the head of a lump. * Note: If the lump is compressed, the whole thing has to be read anyway. * @@ -1673,11 +1685,15 @@ void *W_CacheLumpNumPwad(UINT16 wad, UINT16 lump, INT32 tag) lumpcache = wadfiles[wad]->lumpcache; if (!lumpcache[lump]) { + dopalswap = wadfiles[wad]->compatmode; void *ptr = Z_Malloc(W_LumpLengthPwad(wad, lump), tag, &lumpcache[lump]); W_ReadLumpHeaderPwad(wad, lump, ptr, 0, 0); // read the lump in full } else + { + dopalswap = false; Z_ChangeTag(lumpcache[lump], tag); + } return lumpcache[lump]; } @@ -1819,6 +1835,10 @@ void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) ptr = Picture_PNGConvert((UINT8 *)lumpdata, PICFMT_DOOMPATCH, NULL, NULL, NULL, NULL, len, &len, 0); #endif + // we already know this is a patch, do palette remapping here + if (wadfiles[wad]->compatmode) + R_DoPaletteRemapPatch(ptr, wadfiles[wad]->lumpinfo[lump].size); + dest = Z_Calloc(sizeof(patch_t), tag, &lumpcache[lump]); Patch_Create(ptr, len, dest); diff --git a/src/w_wad.h b/src/w_wad.h index 27b7174ac..445fe56bc 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -196,6 +196,7 @@ void *W_CacheLumpNumForce(lumpnum_t lumpnum, INT32 tag); boolean W_IsLumpCached(lumpnum_t lump, void *ptr); boolean W_IsPatchCached(lumpnum_t lump, void *ptr); +boolean W_NeedPaletteRemap(void); void *W_CacheLumpName(const char *name, INT32 tag); void *W_CachePatchName(const char *name, INT32 tag); From 71ab72c85e726639f288a987e267f005afb18b99 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Fri, 24 Jan 2025 18:25:04 +0100 Subject: [PATCH 08/11] Add lua_compatmode --- src/lua_hooklib.c | 12 ++++++++++++ src/lua_script.c | 7 +++++++ src/lua_script.h | 1 + src/w_wad.c | 26 +++++++++++++------------- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index a11aac517..b8e05b8b0 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -65,6 +65,9 @@ static int nextid; // After a hook errors once, don't print the error again. static UINT8 * hooksErrored; +// compat mode for each hook +static UINT8 * hookCompat; + static int errorRef; static boolean mobj_hook_available(int hook_type, mobjtype_t mobj_type) @@ -187,10 +190,17 @@ static void add_hook_ref(lua_State *L, int idx) BIT_ARRAY_SIZE (nextid + 1) * sizeof *hooksErrored, PU_STATIC, &hooksErrored); hooksErrored[nextid >> 3] = 0; + Z_Realloc(hookCompat, + BIT_ARRAY_SIZE (nextid + 1) * sizeof *hookCompat, + PU_STATIC, &hookCompat); + hookCompat[nextid >> 3] = 0; } Z_Realloc(hookRefs, (nextid + 1) * sizeof *hookRefs, PU_STATIC, &hookRefs); + if (lua_compatmode) + set_bit_array(hookCompat, nextid); + // set the hook function in the registry. lua_pushvalue(L, idx); hookRefs[nextid++] = luaL_ref(L, LUA_REGISTRYINDEX); @@ -388,6 +398,7 @@ static void init_hook_call static void get_hook(Hook_State *hook, const int *ids, int n) { hook->id = ids[n]; + lua_compatmode = in_bit_array(hookCompat, hook->id); lua_getref(gL, hookRefs[hook->id]); } @@ -396,6 +407,7 @@ static void get_hook_from_table(Hook_State *hook, int n) lua_rawgeti(gL, -1, n); hook->id = lua_tonumber(gL, -1); lua_pop(gL, 1); + lua_compatmode = in_bit_array(hookCompat, hook->id); lua_getref(gL, hookRefs[hook->id]); } diff --git a/src/lua_script.c b/src/lua_script.c index ec2b15dfa..4833e5d9f 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -150,6 +150,8 @@ int LUA_Call(lua_State *L, int nargs, int nresults, int errorhandlerindex) return err; } +boolean lua_compatmode = false; + // Moved here from lib_getenum. int LUA_PushGlobals(lua_State *L, const char *word) { @@ -408,6 +410,9 @@ int LUA_PushGlobals(lua_State *L, const char *word) } else if (fastcmp(word, "gamestate")) { lua_pushinteger(L, gamestate); return 1; + } else if (fastcmp(word, "compatmode")) { + lua_pushboolean(L, lua_compatmode); + return 1; } return 0; @@ -640,6 +645,8 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump, boolean noresults) name[len] = '\0'; } + lua_compatmode = wadfiles[wad]->compatmode; + LUA_LoadFile(&f, name, noresults); // actually load file! // Okay, we've modified the game beyond the point of no return. diff --git a/src/lua_script.h b/src/lua_script.h index 9bfddc875..179171eec 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -48,6 +48,7 @@ void LUA_ClearExtVars(void); void LUA_ClearState(void); extern INT32 lua_lumploading; // is LUA_LoadLump being called? +extern boolean lua_compatmode; // compatmode enabled for this lump/hook? int LUA_GetErrorMessage(lua_State *L); int LUA_Call(lua_State *L, int nargs, int nresults, int errorhandlerindex); diff --git a/src/w_wad.c b/src/w_wad.c index 49efb9cf2..9843958d1 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -879,6 +879,19 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) } #endif // HWRENDER + // check if compatmode is needed + switch (wadfile->type) + { + case RET_WAD: + wadfile->compatmode = CheckCompatWad(numwadfiles - 1); + break; + case RET_PK3: + wadfile->compatmode = CheckCompatZip(numwadfiles - 1); + break; + default: + break; + } + // TODO: HACK ALERT - Load Lua & SOC stuff right here. I feel like this should be out of this place, but... Let's stick with this for now. switch (wadfile->type) { @@ -899,19 +912,6 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) break; } - // check if compatmode is needed - switch (wadfile->type) - { - case RET_WAD: - wadfile->compatmode = CheckCompatWad(numwadfiles - 1); - break; - case RET_PK3: - wadfile->compatmode = CheckCompatZip(numwadfiles - 1); - break; - default: - break; - } - if (refreshdirmenu & REFRESHDIR_GAMEDATA) G_LoadGameData(); DEH_UpdateMaxFreeslots(); From f3176ed7d0cb4ba1d2375c1c234545a35a3aa721 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Fri, 24 Jan 2025 18:25:32 +0100 Subject: [PATCH 09/11] Do palette remapping for drawFill and fadeScreen --- src/lua_hudlib.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 15af98155..9a2861af3 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -838,6 +838,9 @@ static int libd_drawFill(lua_State *L) HUDONLY + if (lua_compatmode) + c = (c & ~0xff) | R_GetPaletteRemap(c & 0xff); + lua_getfield(L, LUA_REGISTRYINDEX, "HUD_DRAW_LIST"); list = (huddrawlist_h) lua_touserdata(L, -1); lua_pop(L, 1); @@ -864,6 +867,9 @@ static int libd_fadeScreen(lua_State *L) if (strength > maxstrength) return luaL_error(L, "%s fade strength %d out of range (0 - %d)", ((color & 0xFF00) ? "COLORMAP" : "TRANSMAP"), strength, maxstrength); + if (lua_compatmode && !(color & 0xFF00)) + color = R_GetPaletteRemap(color); + lua_getfield(L, LUA_REGISTRYINDEX, "HUD_DRAW_LIST"); list = (huddrawlist_h) lua_touserdata(L, -1); lua_pop(L, 1); From f6f43943d7d4a7475687092d73464f8ab6646230 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Fri, 24 Jan 2025 18:26:49 +0100 Subject: [PATCH 10/11] Networked compatmode --- src/d_netcmd.c | 32 +++++++++++++++++++++++++++----- src/d_netfil.c | 8 +++++++- src/d_netfil.h | 1 + src/g_demo.c | 6 +++++- src/p_setup.c | 10 +++++----- src/p_setup.h | 5 +++-- src/w_wad.c | 8 +++++--- src/w_wad.h | 11 +++++++++-- 8 files changed, 62 insertions(+), 19 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 2a488a17c..4b3059ea5 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4381,9 +4381,24 @@ static void Command_Addfile(void) const char *addedfiles[argc]; // list of filenames already processed size_t numfilesadded = 0; // the amount of filenames processed - if (argc < 2) + size_t docompat = COM_CheckPartialParm("-c"); + size_t nocompat = COM_CheckPartialParm("-n"); + wadcompat_t compat = WC_AUTO; + + if (docompat && nocompat) { - CONS_Printf(M_GetText("addfile [filename2...] [...]: Load add-ons\n")); + CONS_Printf(M_GetText("Please specify only one of -c or -n\n")); + return; + } + else if (docompat) + compat = WC_ON; + else if (nocompat) + compat = WC_OFF; + + if (argc < 2 + (docompat || nocompat)) + { + CONS_Printf(M_GetText("addfile [-c|-n] [filename2...]: Load add-ons\n" + "-c forces compatmode, -n disables it.\n")); return; } @@ -4398,6 +4413,9 @@ static void Command_Addfile(void) int musiconly; // W_VerifyNMUSlumps isn't boolean boolean fileadded = false; + if (curarg == docompat || curarg == nocompat) + continue; + fn = COM_Argv(curarg); // For the amount of filenames previously processed... @@ -4445,7 +4463,7 @@ static void Command_Addfile(void) // Add file on your client directly if it is trivial, or you aren't in a netgame. if (!(netgame || multiplayer) || musiconly) { - P_AddWadFile(fn); + P_AddWadFile(fn, compat); addedfiles[numfilesadded++] = fn; continue; } @@ -4504,6 +4522,8 @@ static void Command_Addfile(void) WRITEMEM(buf_p, md5sum, 16); } + WRITEUINT8(buf_p, compat); + addedfiles[numfilesadded++] = fn; if (IsPlayerAdmin(consoleplayer) && (!server)) // Request to add file @@ -4524,6 +4544,7 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) READSTRINGN(*cp, filename, 240); READMEM(*cp, md5sum, 16); + wadcompat_t compat = READUINT8(*cp); // Only the server processes this message. if (client) @@ -4569,7 +4590,7 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) return; } - COM_BufAddText(va("addfile %s\n", filename)); + COM_BufAddText(va("addfile %s %s\n", compat == WC_ON ? "-c" : (compat == WC_OFF ? "-n" : ""), filename)); } static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) @@ -4580,6 +4601,7 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) READSTRINGN(*cp, filename, 240); READMEM(*cp, md5sum, 16); + wadcompat_t compat = READUINT8(*cp); if (playernum != serverplayer) { @@ -4591,7 +4613,7 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) ncs = findfile(filename,md5sum,true); - if (ncs != FS_FOUND || !P_AddWadFile(filename)) + if (ncs != FS_FOUND || !P_AddWadFile(filename, compat)) { Command_ExitGame_f(); if (ncs == FS_FOUND) diff --git a/src/d_netfil.c b/src/d_netfil.c index 8b1636963..5d76a5ef6 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -214,6 +214,7 @@ UINT8 *PutFileNeeded(UINT16 firstfile) WRITEUINT32(p, wadfiles[i]->filesize); WRITESTRINGN(p, wadfilename, MAX_WADPATH); WRITEMEM(p, wadfiles[i]->md5sum, 16); + WRITEUINT8(p, wadfiles[i]->compatmode); } if (netbuffer->packettype == PT_MOREFILESNEEDED) netbuffer->u.filesneededcfg.num = count; @@ -247,6 +248,7 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi fileneeded[i].file = NULL; // The file isn't open yet READSTRINGN(p, fileneeded[i].filename, MAX_WADPATH); // The next bytes are the file name READMEM(p, fileneeded[i].md5sum, 16); // The last 16 bytes are the file checksum + fileneeded[i].compatmode = READUINT8(p); } } @@ -581,6 +583,10 @@ INT32 CL_CheckFiles(void) if (memcmp(wadfiles[j]->md5sum, fileneeded[i].md5sum, 16)) return 2; + // compatmode has to match too! + if (wadfiles[j]->compatmode != fileneeded[i].compatmode) + return 2; + // It's accounted for! let's keep going. CONS_Debug(DBG_NETPLAY, "'%s' accounted for\n", fileneeded[i].filename); fileneeded[i].status = FS_OPEN; @@ -652,7 +658,7 @@ boolean CL_LoadServerFiles(void) continue; // Already loaded else if (fileneeded[i].status == FS_FOUND) { - P_PartialAddWadFile(fileneeded[i].filename); + P_PartialAddWadFile(fileneeded[i].filename, fileneeded[i].compatmode ? WC_ON : WC_OFF); G_SetGameModified(true, false); fileneeded[i].status = FS_OPEN; return false; diff --git a/src/d_netfil.h b/src/d_netfil.h index 2b751a59e..50d130f68 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -48,6 +48,7 @@ struct fileneeded_t UINT8 md5sum[16]; filestatus_t status; // The value returned by recsearch boolean justdownloaded; // To prevent late fragments from causing an I_Error + boolean compatmode; // Used only for download FILE *file; diff --git a/src/g_demo.c b/src/g_demo.c index e8f771747..cf64499e0 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2053,6 +2053,7 @@ void G_BeginRecording(void) nameonly(( filename = va("%s", wadfiles[i]->filename) )); WRITESTRINGN(demobuf.p, filename, MAX_WADPATH); WRITEMEM(demobuf.p, wadfiles[i]->md5sum, 16); + WRITEUINT8(demobuf.p, wadfiles[i]->compatmode); totalfiles++; } @@ -2285,6 +2286,7 @@ static void G_LoadDemoExtraFiles(UINT8 **pp) boolean toomany = false; boolean alreadyloaded; UINT8 i, j; + boolean compatmode; totalfiles = READUINT8((*pp)); for (i = 0; i < totalfiles; ++i) @@ -2297,6 +2299,7 @@ static void G_LoadDemoExtraFiles(UINT8 **pp) SKIPSTRING((*pp)); } READMEM((*pp), md5sum, 16); + compatmode = READUINT8((*pp)); if (!toomany) { @@ -2339,7 +2342,7 @@ static void G_LoadDemoExtraFiles(UINT8 **pp) } else { - P_PartialAddWadFile(filename); + P_PartialAddWadFile(filename, compatmode ? WC_ON : WC_OFF); } } } @@ -2385,6 +2388,7 @@ static UINT8 G_CheckDemoExtraFiles(UINT8 **pp, boolean quick) SKIPSTRING((*pp)); } READMEM((*pp), md5sum, 16); + (void)READUINT8((*pp)); // compatmode if (!toomany) { diff --git a/src/p_setup.c b/src/p_setup.c index 266c03405..3ff6eecba 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -8583,7 +8583,7 @@ boolean P_RunSOC(const char *socfilename) lumpnum_t lump; if (strstr(socfilename, ".soc") != NULL) - return P_AddWadFile(socfilename); + return P_AddWadFile(socfilename, WC_AUTO); lump = W_CheckNumForName(socfilename); if (lump == LUMPERROR) @@ -8665,11 +8665,11 @@ static lumpinfo_t* FindFolder(const char *folName, UINT16 *start, UINT16 *end, l // Add a wadfile to the active wad files, // replace sounds, musics, patches, textures, sprites and maps // -boolean P_AddWadFile(const char *wadfilename) +boolean P_AddWadFile(const char *wadfilename, wadcompat_t compat) { UINT16 wadnum; - if ((wadnum = P_PartialAddWadFile(wadfilename)) == UINT16_MAX) + if ((wadnum = P_PartialAddWadFile(wadfilename, compat)) == UINT16_MAX) return false; P_MultiSetupWadFiles(true); @@ -8680,7 +8680,7 @@ boolean P_AddWadFile(const char *wadfilename) // Add a WAD file and do the per-WAD setup stages. // Call P_MultiSetupWadFiles as soon as possible after any number of these. // -UINT16 P_PartialAddWadFile(const char *wadfilename) +UINT16 P_PartialAddWadFile(const char *wadfilename, wadcompat_t compat) { size_t i, j, sreplaces = 0, mreplaces = 0, digmreplaces = 0; UINT16 numlumps, wadnum; @@ -8702,7 +8702,7 @@ UINT16 P_PartialAddWadFile(const char *wadfilename) // UINT16 mapPos, mapNum = 0; // Init file. - if ((numlumps = W_InitFile(wadfilename, false, false)) == INT16_MAX) + if ((numlumps = W_InitFile(wadfilename, false, false, compat)) == INT16_MAX) { refreshdirmenu |= REFRESHDIR_NOTLOADED; return UINT16_MAX; diff --git a/src/p_setup.h b/src/p_setup.h index 6858d7d20..02ebd29a6 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -18,6 +18,7 @@ #include "doomstat.h" #include "r_defs.h" #include "k_terrain.h" +#include "w_wad.h" #ifdef __cplusplus extern "C" { @@ -110,12 +111,12 @@ void P_PostLoadLevel(void); #ifdef HWRENDER void HWR_LoadLevel(void); #endif -boolean P_AddWadFile(const char *wadfilename); +boolean P_AddWadFile(const char *wadfilename, wadcompat_t compat); // WARNING: The following functions should be grouped as follows: // any amount of PartialAdds followed by MultiSetups until returned true, // as soon as possible. -UINT16 P_PartialAddWadFile(const char *wadfilename); +UINT16 P_PartialAddWadFile(const char *wadfilename, wadcompat_t compat); // Run a single stage of multisetup, or all of them if fullsetup set. // fullsetup true: run everything // otherwise diff --git a/src/w_wad.c b/src/w_wad.c index 9843958d1..1d374c611 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -739,7 +739,7 @@ static UINT16 W_InitFileError (const char *filename, boolean exitworthy) // // Can now load dehacked files (.soc) // -UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) +UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup, wadcompat_t compat) { FILE *handle; lumpinfo_t *lumpinfo = NULL; @@ -880,7 +880,9 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) #endif // HWRENDER // check if compatmode is needed - switch (wadfile->type) + if (compat != WC_AUTO) + wadfile->compatmode = compat == WC_ON ? true : false; + else switch (wadfile->type) { case RET_WAD: wadfile->compatmode = CheckCompatWad(numwadfiles - 1); @@ -941,7 +943,7 @@ INT32 W_InitMultipleFiles(char **filenames, boolean addons) G_SetGameModified(true, false); //CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames); - rc = W_InitFile(*filenames, !addons, true); + rc = W_InitFile(*filenames, !addons, true, WC_AUTO); if (rc == INT16_MAX) CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), *filenames); overallrc &= (rc != INT16_MAX) ? 1 : 0; diff --git a/src/w_wad.h b/src/w_wad.h index 445fe56bc..3b5375ca4 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -128,9 +128,16 @@ struct wadfile_t UINT8 md5sum[16]; boolean important; // also network - !W_VerifyNMUSlumps - boolean compatmode; // TODO: network this too! + boolean compatmode; }; +typedef enum wadcompat +{ + WC_AUTO, // haha WC + WC_ON, + WC_OFF, +} wadcompat_t; + #define WADFILENUM(lumpnum) (UINT16)((lumpnum)>>16) // wad flumpnum>>16) // wad file number in upper word #define LUMPNUM(lumpnum) (UINT16)((lumpnum)&0xFFFF) // lump number for this pwad @@ -144,7 +151,7 @@ void W_Shutdown(void); // Opens a WAD file. Returns the FILE * handle for the file, or NULL if not found or could not be opened FILE *W_OpenWadFile(const char **filename, boolean useerrors); // Load and add a wadfile to the active wad files, returns numbers of lumps, INT16_MAX on error -UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup); +UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup, wadcompat_t compat); // W_InitMultipleFiles returns 1 if all is okay, 0 otherwise, // so that it stops with a message if a file was not found, but not if all is okay. From 6a2556b0be869a3f1ac990575ef165f42c385045 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Fri, 24 Jan 2025 18:27:44 +0100 Subject: [PATCH 11/11] Fix screen fade colors ...and what the hell happened in r_draw? --- src/doomdef.h | 4 ++++ src/p_setup.c | 6 +++--- src/r_draw.cpp | 8 -------- src/st_stuff.c | 4 ++-- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index c24e1000f..bb4beb041 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -217,6 +217,10 @@ extern char logfilename[1024]; #define MAXCOLORNAME 32 #define NUMCOLORFREESLOTS UINT16_MAX +// surely nobody's gonna change the palette a second time :Clueless: +#define FADECOLOR 0 // 120 +#define ENCOREFADECOLOR 209 // 122 + // Master Server compatibility ONLY #define MSCOMPAT_MAXPLAYERS (32) diff --git a/src/p_setup.c b/src/p_setup.c index 3ff6eecba..7fc414157 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -8162,13 +8162,13 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) S_StartSound(NULL, sfx_ruby1); F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 122); + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, ENCOREFADECOLOR); F_WipeEndScreen(); F_RunWipe(wipedefs[wipe_encore_towhite], false); F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 120); + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, FADECOLOR); F_WipeEndScreen(); F_RunWipe(wipedefs[wipe_level_final], false); @@ -8247,7 +8247,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) } } - levelfadecol = (encoremode && !ranspecialwipe ? 122 : 120); + levelfadecol = (encoremode && !ranspecialwipe ? ENCOREFADECOLOR : FADECOLOR); // Let's fade to white here // But only if we didn't do the encore startup wipe diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 5d6591b02..00488b78d 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -150,14 +150,6 @@ float zeroheight; #define INTERMISSION_TT_CACHE_INDEX (MAXSKINS + 8) #define TT_CACHE_SIZE (MAXSKINS + 9) -#define SKIN_RAMP_LENGTH 16 -#define DEFAULT_STARTTRANSCOLOR 160 -#define NUM_PALETTE_ENTRIES 256 - -#define SKIN_RAMP_LENGTH 16 -#define DEFAULT_STARTTRANSCOLOR 96 -#define NUM_PALETTE_ENTRIES 256 - static UINT8 **translationtablecache[TT_CACHE_SIZE] = {NULL}; UINT8 skincolor_modified[MAXSKINCOLORS]; diff --git a/src/st_stuff.c b/src/st_stuff.c index 64a757c83..705d303fa 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -895,9 +895,9 @@ void ST_Drawer(void) if (timeinmap < 15) { if (timeinmap <= 5) - V_DrawFill(0,0,BASEVIDWIDTH,BASEVIDHEIGHT,120); // Pure white on first few frames, to hide SRB2's awful level load artifacts + V_DrawFill(0,0,BASEVIDWIDTH,BASEVIDHEIGHT,FADECOLOR); // Pure white on first few frames, to hide SRB2's awful level load artifacts else - V_DrawFadeScreen(120, 15-timeinmap); // Then gradually fade out from there + V_DrawFadeScreen(FADECOLOR, 15-timeinmap); // Then gradually fade out from there } if (stagetitle)