1 //------------------------------------------------------------------------
2 //  COLORS
3 //------------------------------------------------------------------------
4 //
5 //  Eureka DOOM Editor
6 //
7 //  Copyright (C) 2001-2016 Andrew Apted
8 //  Copyright (C) 1997-2003 André Majorel et al
9 //
10 //  This program is free software; you can redistribute it and/or
11 //  modify it under the terms of the GNU General Public License
12 //  as published by the Free Software Foundation; either version 2
13 //  of the License, or (at your option) any later version.
14 //
15 //  This program is distributed in the hope that it will be useful,
16 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
17 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 //  GNU General Public License for more details.
19 //
20 //------------------------------------------------------------------------
21 //
22 //  Based on Yadex which incorporated code from DEU 5.21 that was put
23 //  in the public domain in 1994 by Raphaël Quinet and Brendon Wyber.
24 //
25 //------------------------------------------------------------------------
26 
27 #ifndef __EUREKA_IM_COLOR_H__
28 #define __EUREKA_IM_COLOR_H__
29 
30 
31 typedef u32_t rgb_color_t;
32 
33 #define RGB_RED(col)    ((col >> 24) & 255)
34 #define RGB_GREEN(col)  ((col >> 16) & 255)
35 #define RGB_BLUE(col)   ((col >>  8) & 255)
36 
37 #define RGB_MAKE(r, g, b)  (((r) << 24) | ((g) << 16) | ((b) << 8))
38 
39 
40 // this is a version of rgb_color_t with an alpha channel
41 // [ currently only used by the TGA loading code ]
42 typedef u32_t rgba_color_t;
43 #define RGBA_ALPHA(col)   ((col) & 255)
44 #define RGBA_MAKE(r, g, b, a)  (((r) << 24) | ((g) << 16) | ((b) << 8) | (a))
45 
46 
47 extern int usegamma;
48 
49 // the palette color closest to what TRANS_PIXEL really is
50 extern int trans_replace;
51 
52 
53 // this palette has the gamma setting applied
54 extern rgb_color_t palette[256];
55 extern rgb_color_t palette_medium[256];
56 
57 extern byte raw_palette[256][3];
58 
59 extern byte raw_colormap[32][256];
60 
61 extern byte rgb555_gamma [32];
62 extern byte rgb555_medium[32];
63 
64 extern int gammatable[5][256];
65 
66 
67 void W_UpdateGamma();
68 
69 void W_LoadPalette();
70 void W_LoadColormap();
71 
72 byte W_FindPaletteColor(int r, int g, int b);
73 
74 void W_CreateBrightMap();
75 
76 // make the color darker
77 rgb_color_t DarkerColor(rgb_color_t col);
78 
79 rgb_color_t ParseColor(const char *str);
80 
81 rgb_color_t SectorLightColor(int light);
82 
83 int HashedPalColor(const char *name, const int *cols);
84 
85 
R_DoomLightingEquation(int L,float dist)86 inline int R_DoomLightingEquation(int L, float dist)
87 {
88 	/* L in the range 0 to 256 */
89 	L >>= 2;
90 
91 	int min_L = CLAMP(0, 36 - L, 31);
92 
93 	int index = (59 - L) - int(1280 / MAX(1, dist));
94 
95 	/* result is colormap index (0 bright .. 31 dark) */
96 	return CLAMP(min_L, index, 31);
97 }
98 
99 
100 //------------------------------------------------------------//
101 
102 
103 #define BLACK           FL_BLACK
104 #define BLUE            FL_BLUE
105 #define GREEN           FL_GREEN
106 #define CYAN            FL_CYAN
107 #define RED             FL_RED
108 #define MAGENTA         FL_MAGENTA
109 #define BROWN           FL_DARK_RED
110 #define YELLOW          fl_rgb_color(255,255,0)
111 #define WHITE           FL_WHITE
112 
113 #define LIGHTGREY       fl_rgb_color(144,144,144)
114 #define DARKGREY        fl_rgb_color(80,80,80)
115 
116 #define LIGHTBLUE       fl_rgb_color(128,128,255)
117 #define LIGHTGREEN      fl_rgb_color(128,255,128)
118 #define LIGHTCYAN       fl_rgb_color(128,255,255)
119 #define LIGHTRED        fl_rgb_color(255,128,128)
120 #define LIGHTMAGENTA    fl_rgb_color(255,128,255)
121 
122 #define OBJECT_NUM_COL  fl_rgb_color(0x44, 0xdd, 0xff)
123 #define CLR_ERROR       fl_rgb_color(0xff, 0,    0)
124 
125 #define SECTOR_TAG      fl_rgb_color(0x00, 0xff, 0x00)
126 #define SECTOR_TAGTYPE  fl_rgb_color(0x00, 0xe0, 0xe0)
127 #define SECTOR_TYPE     fl_rgb_color(0x00, 0x80, 0xff)
128 
129 #define SEL_COL         fl_rgb_color(128,192,255)
130 #define SEL3D_COL       fl_rgb_color(128,255,128)
131 #define HI_COL          fl_rgb_color(255,255,0)
132 #define HI_AND_SEL_COL  fl_rgb_color(255,128,0)
133 
134 #define THING_MODE_COL  fl_rgb_color(255,64,255)
135 #define LINE_MODE_COL   fl_rgb_color(0,160,255)
136 #define SECTOR_MODE_COL fl_rgb_color(255,255,0)
137 #define VERTEX_MODE_COL fl_rgb_color(0,255,128)
138 
139 
140 #endif  /* __EUREKA_IM_COLOR_H__ */
141 
142 //--- editor settings ---
143 // vi:ts=4:sw=4:noexpandtab
144