1 // SONIC ROBO BLAST 2
2 //-----------------------------------------------------------------------------
3 // Copyright (C) 1993-1996 by id Software, Inc.
4 // Copyright (C) 1998-2000 by DooM Legacy Team.
5 // Copyright (C) 1999-2020 by Sonic Team Junior.
6 //
7 // This program is free software distributed under the
8 // terms of the GNU General Public License, version 2.
9 // See the 'LICENSE' file for more details.
10 //-----------------------------------------------------------------------------
11 /// \file  r_data.h
12 /// \brief Refresh module, data I/O, caching, retrieval of graphics by name
13 
14 #ifndef __R_DATA__
15 #define __R_DATA__
16 
17 #include "r_defs.h"
18 #include "r_state.h"
19 #include "p_setup.h" // levelflats
20 
21 #ifdef __GNUG__
22 #pragma interface
23 #endif
24 
25 // Store lists of lumps for F_START/F_END etc.
26 typedef struct
27 {
28 	UINT16 wadfile;
29 	UINT16 firstlump;
30 	size_t numlumps;
31 } lumplist_t;
32 
33 // Possible alpha types for a patch.
34 enum patchalphastyle {AST_COPY, AST_TRANSLUCENT, AST_ADD, AST_SUBTRACT, AST_REVERSESUBTRACT, AST_MODULATE, AST_OVERLAY};
35 
36 UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha);
37 UINT32 ASTBlendTexturePixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha);
38 UINT8 ASTBlendPaletteIndexes(UINT8 background, UINT8 foreground, int style, UINT8 alpha);
39 
40 extern INT32 ASTTextureBlendingThreshold[2];
41 
42 extern INT16 color8to16[256]; // remap color index to highcolor
43 extern INT16 *hicolormaps; // remap high colors to high colors..
44 
45 extern CV_PossibleValue_t Color_cons_t[];
46 
47 // I/O, setting up the stuff.
48 void R_InitData(void);
49 void R_PrecacheLevel(void);
50 
51 extern size_t flatmemory, spritememory, texturememory;
52 
53 // Extra Colormap lumps (C_START/C_END) are not used anywhere
54 // Uncomment to enable
55 //#define EXTRACOLORMAPLUMPS
56 
57 // Uncomment to make extra_colormaps order Newest -> Oldest
58 //#define COLORMAPREVERSELIST
59 
60 void R_ReInitColormaps(UINT16 num);
61 void R_ClearColormaps(void);
62 extracolormap_t *R_CreateDefaultColormap(boolean lighttable);
63 extracolormap_t *R_GetDefaultColormap(void);
64 extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable);
65 void R_AddColormapToList(extracolormap_t *extra_colormap);
66 
67 #ifdef EXTRACOLORMAPLUMPS
68 boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams,
69 	INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags, lumpnum_t lump);
70 extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags, lumpnum_t lump);
71 #else
72 boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams,
73 	INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags);
74 extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags);
75 #endif
76 boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams);
77 boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, boolean checkrgba, boolean checkfadergba, boolean checkparams);
78 extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap);
79 
80 typedef enum
81 {
82 	TMCF_RELATIVE     = 1,
83 	TMCF_SUBLIGHTR    = 1<<1,
84 	TMCF_SUBLIGHTG    = 1<<2,
85 	TMCF_SUBLIGHTB    = 1<<3,
86 	TMCF_SUBLIGHTA    = 1<<4,
87 	TMCF_SUBFADER     = 1<<5,
88 	TMCF_SUBFADEG     = 1<<6,
89 	TMCF_SUBFADEB     = 1<<7,
90 	TMCF_SUBFADEA     = 1<<8,
91 	TMCF_SUBFADESTART = 1<<9,
92 	TMCF_SUBFADEEND   = 1<<10,
93 	TMCF_IGNOREFLAGS  = 1<<11,
94 	TMCF_FROMBLACK    = 1<<12,
95 	TMCF_OVERRIDE     = 1<<13,
96 } textmapcolormapflags_t;
97 
98 lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap);
99 extracolormap_t * R_CreateColormapFromLinedef(char *p1, char *p2, char *p3);
100 extracolormap_t* R_CreateColormap(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags);
101 extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend,
102 	boolean subR, boolean subG, boolean subB, boolean subA,
103 	boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA,
104 	boolean subFadeStart, boolean subFadeEnd, boolean ignoreFlags,
105 	boolean lighttable);
106 #ifdef EXTRACOLORMAPLUMPS
107 extracolormap_t *R_ColormapForName(char *name);
108 const char *R_NameForColormap(extracolormap_t *extra_colormap);
109 #endif
110 
111 #define R_GetRgbaR(rgba) (rgba & 0xFF)
112 #define R_GetRgbaG(rgba) ((rgba >> 8) & 0xFF)
113 #define R_GetRgbaB(rgba) ((rgba >> 16) & 0xFF)
114 #define R_GetRgbaA(rgba) ((rgba >> 24) & 0xFF)
115 #define R_GetRgbaRGB(rgba) (rgba & 0xFFFFFF)
116 #define R_PutRgbaR(r) (r)
117 #define R_PutRgbaG(g) (g << 8)
118 #define R_PutRgbaB(b) (b << 16)
119 #define R_PutRgbaA(a) (a << 24)
120 #define R_PutRgbaRGB(r, g, b) (R_PutRgbaR(r) + R_PutRgbaG(g) + R_PutRgbaB(b))
121 #define R_PutRgbaRGBA(r, g, b, a) (R_PutRgbaRGB(r, g, b) + R_PutRgbaA(a))
122 
123 UINT8 NearestPaletteColor(UINT8 r, UINT8 g, UINT8 b, RGBA_t *palette);
124 #define NearestColor(r, g, b) NearestPaletteColor(r, g, b, NULL)
125 
126 #endif
127