1 #ifndef HIGHTILE_PRIV_H
2 #define HIGHTILE_PRIV_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 struct hicskybox_t {
9 char *face[6];
10 };
11
12 typedef struct hicreplc_t {
13 struct hicreplc_t *next;
14 char *filename;
15 struct hicskybox_t *skybox;
16 vec2f_t scale;
17 float alphacut, specpower, specfactor;
18 char palnum, flags;
19 } hicreplctyp;
20
21 typedef struct {
22 polytintflags_t f;
23 uint8_t r, g, b;
24 uint8_t sr, sg, sb;
25 } polytint_t;
26
27 extern polytint_t hictinting[MAXPALOOKUPS];
28 extern hicreplctyp *hicreplc[MAXTILES];
29 extern int32_t hicinitcounter;
30
31 typedef struct texcachehead_t
32 {
33 char magic[4]; // 'PMST', was 'Polymost'
34 int xdim, ydim; // of image, unpadded
35 int flags; // 1 = !2^x, 2 = has alpha, 4 = lzw compressed
36 int quality; // r_downsize at the time the cache was written
37 } texcacheheader;
38
39 typedef struct texcachepic_t
40 {
41 int size;
42 int format;
43 int xdim, ydim; // of mipmap (possibly padded)
44 int border, depth;
45 } texcachepicture;
46
47 hicreplctyp * hicfindsubst(int picnum, int palnum, int nozero = 0);
48 hicreplctyp * hicfindskybox(int picnum, int palnum, int nozero = 0);
49
have_basepal_tint(void)50 static inline int have_basepal_tint(void)
51 {
52 polytint_t const & tint = hictinting[MAXPALOOKUPS-1];
53 return (tint.r != 255 ||
54 tint.g != 255 ||
55 tint.b != 255);
56 }
57
hictinting_apply(float * color,int32_t palnum)58 static inline void hictinting_apply(float *color, int32_t palnum)
59 {
60 polytint_t const & tint = hictinting[palnum];
61 color[0] *= (float)tint.r * (1.f/255.f);
62 color[1] *= (float)tint.g * (1.f/255.f);
63 color[2] *= (float)tint.b * (1.f/255.f);
64 }
65
hictinting_apply_ub(uint8_t * color,int32_t palnum)66 static inline void hictinting_apply_ub(uint8_t *color, int32_t palnum)
67 {
68 polytint_t const & tint = hictinting[palnum];
69 color[0] = (uint8_t)(color[0] * (float)tint.r * (1.f/255.f));
70 color[1] = (uint8_t)(color[1] * (float)tint.g * (1.f/255.f));
71 color[2] = (uint8_t)(color[2] * (float)tint.b * (1.f/255.f));
72 }
73
globaltinting_apply(float * color)74 static inline void globaltinting_apply(float *color)
75 {
76 color[0] *= (float)globalr * (1.f/255.f);
77 color[1] *= (float)globalg * (1.f/255.f);
78 color[2] *= (float)globalb * (1.f/255.f);
79 }
80
globaltinting_apply_ub(uint8_t * color)81 static inline void globaltinting_apply_ub(uint8_t *color)
82 {
83 color[0] = (uint8_t)(color[0] * (float)globalr * (1.f/255.f));
84 color[1] = (uint8_t)(color[1] * (float)globalg * (1.f/255.f));
85 color[2] = (uint8_t)(color[2] * (float)globalb * (1.f/255.f));
86 }
87
88 // texcacheheader cachead.flags bits
89 enum
90 {
91 CACHEAD_NONPOW2 = 1,
92 CACHEAD_HASALPHA = 2,
93 CACHEAD_COMPRESSED = 4,
94 CACHEAD_NODOWNSIZE = 8,
95 CACHEAD_HASFULLBRIGHT = 16,
96 CACHEAD_NPOTWALL = 32,
97 };
98
99 // hicreplctyp hicr->flags bits
100 enum
101 {
102 HICR_NOTEXCOMPRESS = 1,
103 HICR_FORCEFILTER = 2,
104
105 HICR_NODOWNSIZE = 16,
106 HICR_ARTIMMUNITY = 32,
107 };
108
109 // hictinting[].f / gloadtile_hi() and mdloadskin() <effect> arg bits
110 enum
111 {
112 HICTINT_GRAYSCALE = 1,
113 HICTINT_INVERT = 2,
114 HICTINT_COLORIZE = 4,
115 HICTINT_USEONART = 8,
116 HICTINT_APPLYOVERPALSWAP = 16,
117 HICTINT_APPLYOVERALTPAL = 32,
118
119 HICTINT_BLEND_MULTIPLY = 0<<6,
120 HICTINT_BLEND_SCREEN = 1<<6,
121 HICTINT_BLEND_OVERLAY = 2<<6,
122 HICTINT_BLEND_HARDLIGHT = 3<<6,
123
124 HICTINT_BLENDMASK = 64|128,
125
126 HICTINT_ALWAYSUSEART = 256,
127 HICTINT_NOFOGSHADE = 512,
128
129 HICTINT_PRECOMPUTED = HICTINT_COLORIZE | HICTINT_BLENDMASK,
130 HICTINT_IN_MEMORY = HICTINT_PRECOMPUTED | HICTINT_GRAYSCALE | HICTINT_INVERT,
131
132 HICTINT_MEMORY_COMBINATIONS = 1<<5,
133 };
134
135 #define GRAYSCALE_COEFF_RED 0.3
136 #define GRAYSCALE_COEFF_GREEN 0.59
137 #define GRAYSCALE_COEFF_BLUE 0.11
138
139 #ifdef __cplusplus
140 }
141 #endif
142
143 #endif
144