2018-11-05 07:28:01 +00:00
|
|
|
// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
|
|
|
|
// Ken Silverman's official web site: "http://www.advsys.net/ken"
|
|
|
|
// See the included license file "BUILDLIC.TXT" for license info.
|
|
|
|
//
|
|
|
|
// This file has been modified from Ken Silverman's original release
|
|
|
|
// by Jonathon Fowler (jf@jonof.id.au)
|
|
|
|
// by the EDuke32 team (development@voidpoint.com)
|
|
|
|
|
2016-06-21 00:33:06 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifndef palette_h_
|
|
|
|
#define palette_h_
|
|
|
|
|
2019-12-29 20:36:21 +00:00
|
|
|
#include "renderstyle.h"
|
2020-04-11 21:54:33 +00:00
|
|
|
#include "filesystem.h"
|
2020-05-23 12:36:35 +00:00
|
|
|
#include "zstring.h"
|
|
|
|
#include "palentry.h"
|
2023-08-19 16:08:27 +00:00
|
|
|
#include "basics.h"
|
2021-10-30 08:51:03 +00:00
|
|
|
|
2019-03-01 08:51:50 +00:00
|
|
|
|
2021-04-21 15:56:42 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
MAXBASEPALS = 256,
|
|
|
|
MAXPALOOKUPS = 256,
|
|
|
|
MAXBLENDTABS = 256,
|
2021-12-30 09:30:21 +00:00
|
|
|
|
2021-04-21 15:56:42 +00:00
|
|
|
RESERVEDPALS = 4, // don't forget to increment this when adding reserved pals
|
|
|
|
DETAILPAL = (MAXPALOOKUPS - 1),
|
|
|
|
GLOWPAL = (MAXPALOOKUPS - 2),
|
|
|
|
SPECULARPAL = (MAXPALOOKUPS - 3),
|
|
|
|
NORMALPAL = (MAXPALOOKUPS - 4),
|
|
|
|
BRIGHTPAL = (MAXPALOOKUPS),
|
2016-06-21 00:33:06 +00:00
|
|
|
|
2021-04-21 15:56:42 +00:00
|
|
|
MAXREALPAL = MAXPALOOKUPS - RESERVEDPALS
|
2021-04-21 16:34:34 +00:00
|
|
|
};
|
|
|
|
|
2020-05-29 18:15:42 +00:00
|
|
|
// fixme: should use the flags from the PRSFlags enum directly
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
TINTF_GRAYSCALE = 1,
|
|
|
|
TINTF_INVERT = 2,
|
|
|
|
TINTF_COLORIZE = 4,
|
|
|
|
TINTF_USEONART = 8,
|
|
|
|
TINTF_APPLYOVERPALSWAP = 16,
|
|
|
|
TINTF_APPLYOVERALTPAL = 32,
|
|
|
|
|
|
|
|
TINTF_BLEND_MULTIPLY = 0 << 6,
|
|
|
|
TINTF_BLEND_SCREEN = 1 << 6,
|
|
|
|
TINTF_BLEND_OVERLAY = 2 << 6,
|
|
|
|
TINTF_BLEND_HARDLIGHT = 3 << 6,
|
|
|
|
|
|
|
|
TINTF_BLENDMASK = 64 | 128,
|
|
|
|
TINTF_ALWAYSUSEART = 256,
|
|
|
|
TINTF_PRECOMPUTED = TINTF_COLORIZE | TINTF_BLENDMASK,
|
|
|
|
TINTF_ENABLE = 32768
|
|
|
|
};
|
|
|
|
|
2020-05-27 20:19:02 +00:00
|
|
|
struct LookupTable
|
2020-05-23 16:18:36 +00:00
|
|
|
{
|
2020-05-27 20:19:02 +00:00
|
|
|
FString Shades;
|
|
|
|
PalEntry FadeColor = 0;
|
2020-06-05 21:18:21 +00:00
|
|
|
float ShadeFactor = 1.f;
|
2020-05-27 20:19:02 +00:00
|
|
|
float Visibility = 0;
|
|
|
|
bool hasBrightmap = false;
|
|
|
|
bool noFloorPal = false;
|
2020-05-29 18:15:42 +00:00
|
|
|
|
|
|
|
int tintFlags = 0;
|
|
|
|
PalEntry tintColor = 0xffffff;
|
|
|
|
PalEntry tintShade = 0;
|
2020-05-27 20:19:02 +00:00
|
|
|
};
|
2020-05-23 16:18:36 +00:00
|
|
|
|
2020-05-27 20:19:02 +00:00
|
|
|
struct LookupTableInfo
|
2020-05-23 16:18:36 +00:00
|
|
|
{
|
2020-05-27 20:19:02 +00:00
|
|
|
LookupTable tables[MAXPALOOKUPS];
|
|
|
|
|
|
|
|
const uint8_t* getTable(int num)
|
|
|
|
{
|
|
|
|
if (tables[num].Shades.Len() == 0) num = 0;
|
|
|
|
return (const uint8_t*)tables[num].Shades.GetChars();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool checkTable(int num)
|
|
|
|
{
|
|
|
|
return tables[num].Shades.IsNotEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
void copyTable(int dest, int src)
|
|
|
|
{
|
|
|
|
tables[dest].Shades = tables[src].Shades;
|
|
|
|
}
|
|
|
|
|
|
|
|
void clearTable(int dest)
|
|
|
|
{
|
|
|
|
tables[dest].Shades = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
void makeTable(int palnum, const uint8_t* remapbuf, int r, int g, int b, bool noFloorPal);
|
|
|
|
int setTable(int palnum, const uint8_t* remap);
|
|
|
|
void postLoadTables();
|
2023-08-23 18:36:19 +00:00
|
|
|
int loadTable(FileSys::FileReader& fp);
|
2020-05-27 20:19:02 +00:00
|
|
|
void postLoadLookups();
|
|
|
|
void setupDefaultFog();
|
|
|
|
|
|
|
|
void setFadeColor(int num, int r, int g, int b)
|
|
|
|
{
|
|
|
|
tables[num].FadeColor = PalEntry(1, r, g, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
PalEntry getFade(int num)
|
|
|
|
{
|
|
|
|
return tables[num].FadeColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool noFloorPal(int num) const
|
|
|
|
{
|
|
|
|
return tables[num].noFloorPal;
|
|
|
|
}
|
|
|
|
|
2020-05-29 18:15:42 +00:00
|
|
|
void setPaletteTint(int palnum, int r, int g, int b, int sr, int sg, int sb, int flags);
|
|
|
|
|
|
|
|
|
2020-05-27 20:19:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern LookupTableInfo lookups;
|
2020-05-23 12:40:54 +00:00
|
|
|
|
2020-04-12 05:50:24 +00:00
|
|
|
enum
|
|
|
|
{
|
2020-04-05 20:51:53 +00:00
|
|
|
Translation_BasePalettes = 1,
|
2020-04-12 05:50:24 +00:00
|
|
|
Translation_Remap,
|
|
|
|
};
|
|
|
|
|
2016-06-21 00:33:06 +00:00
|
|
|
extern uint8_t curbasepal;
|
2020-05-23 12:36:35 +00:00
|
|
|
extern int32_t r_scenebrightness;
|
2016-06-21 00:33:06 +00:00
|
|
|
|
2019-11-10 20:11:17 +00:00
|
|
|
struct palette_t
|
|
|
|
{
|
2019-09-22 21:15:46 +00:00
|
|
|
uint8_t r, g, b, f;
|
2019-11-10 20:11:17 +00:00
|
|
|
};
|
2018-04-12 21:02:31 +00:00
|
|
|
|
2020-05-23 12:40:54 +00:00
|
|
|
extern PalEntry palfadergb;
|
|
|
|
|
|
|
|
void paletteSetColorTable(int32_t id, uint8_t const* table, bool notransparency, bool twodonly);
|
2020-01-26 09:58:00 +00:00
|
|
|
|
|
|
|
#include "tflags.h"
|
|
|
|
enum ESetPalFlag
|
|
|
|
{
|
|
|
|
Pal_DontResetFade = 1,
|
|
|
|
};
|
|
|
|
|
2020-05-23 12:36:35 +00:00
|
|
|
inline void videoSetBrightness(int brightness)
|
|
|
|
{
|
|
|
|
r_scenebrightness = clamp(brightness, 0, 15);
|
|
|
|
}
|
|
|
|
|
2020-01-26 09:58:00 +00:00
|
|
|
typedef TFlags<ESetPalFlag> ESetPalFlags;
|
|
|
|
DEFINE_TFLAGS_OPERATORS(ESetPalFlags)
|
|
|
|
|
2020-07-07 02:54:12 +00:00
|
|
|
void videoSetPalette(int dapalid);
|
2020-05-23 12:40:54 +00:00
|
|
|
inline void videoFadePalette(uint8_t r, uint8_t g, uint8_t b, uint8_t offset)
|
|
|
|
{
|
|
|
|
palfadergb.r = r;
|
|
|
|
palfadergb.g = g;
|
|
|
|
palfadergb.b = b;
|
|
|
|
palfadergb.a = offset;
|
|
|
|
}
|
2020-05-16 21:55:21 +00:00
|
|
|
inline void videoclearFade()
|
|
|
|
{
|
|
|
|
palfadergb.d = 0;
|
|
|
|
}
|
2020-05-23 12:40:54 +00:00
|
|
|
|
|
|
|
|
2019-09-19 20:02:45 +00:00
|
|
|
void videoTintBlood(int32_t r, int32_t g, int32_t b);
|
2016-06-21 00:33:06 +00:00
|
|
|
|
2021-03-25 08:13:16 +00:00
|
|
|
extern int numshades;
|
2018-04-12 21:03:12 +00:00
|
|
|
extern void paletteLoadFromDisk(void);
|
2016-06-21 00:33:06 +00:00
|
|
|
|
|
|
|
|
2020-09-20 18:39:11 +00:00
|
|
|
struct glblenddef_t
|
2016-10-09 07:55:23 +00:00
|
|
|
{
|
|
|
|
float alpha;
|
|
|
|
uint8_t src, dst, flags;
|
2020-09-20 18:39:11 +00:00
|
|
|
};
|
2016-10-09 07:55:23 +00:00
|
|
|
|
2020-09-20 18:39:11 +00:00
|
|
|
struct glblend_t
|
2016-10-09 07:55:23 +00:00
|
|
|
{
|
|
|
|
glblenddef_t def[2];
|
2020-09-20 18:39:11 +00:00
|
|
|
};
|
2016-10-09 07:55:23 +00:00
|
|
|
|
|
|
|
extern glblend_t const nullglblend, defaultglblend;
|
|
|
|
extern glblend_t glblend[MAXBLENDTABS];
|
|
|
|
|
2022-08-03 13:50:27 +00:00
|
|
|
enum {
|
|
|
|
DAMETH_TRANS1 = 2,
|
|
|
|
DAMETH_TRANS2 = 3,
|
|
|
|
};
|
|
|
|
|
2020-05-23 12:40:54 +00:00
|
|
|
FRenderStyle GetRenderStyle(int blend, int def);
|
|
|
|
float GetAlphaFromBlend(uint32_t maskprops, uint32_t blend);
|
2020-08-30 07:32:34 +00:00
|
|
|
void DrawFullscreenBlends();
|
2019-12-29 20:36:21 +00:00
|
|
|
|
2022-09-30 17:40:37 +00:00
|
|
|
enum {
|
|
|
|
PALETTE_MAIN = 1 << 0,
|
|
|
|
PALETTE_SHADE = 1 << 1,
|
|
|
|
PALETTE_TRANSLUC = 1 << 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
inline uint8_t paletteloaded;
|
|
|
|
|
2016-06-21 00:33:06 +00:00
|
|
|
#endif
|