aboutsummaryrefslogtreecommitdiff
path: root/src/r_drawflush.inl
diff options
context:
space:
mode:
Diffstat (limited to 'src/r_drawflush.inl')
-rw-r--r--src/r_drawflush.inl300
1 files changed, 300 insertions, 0 deletions
diff --git a/src/r_drawflush.inl b/src/r_drawflush.inl
new file mode 100644
index 0000000..ab8ce61
--- /dev/null
+++ b/src/r_drawflush.inl
@@ -0,0 +1,300 @@
1/* Emacs style mode select -*- C++ -*-
2 *-----------------------------------------------------------------------------
3 *
4 *
5 * PrBoom: a Doom port merged with LxDoom and LSDLDoom
6 * based on BOOM, a modified and improved DOOM engine
7 * Copyright (C) 1999 by
8 * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
9 * Copyright (C) 1999-2000 by
10 * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
11 * Copyright 2005, 2006 by
12 * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 * 02111-1307, USA.
28 *
29 *-----------------------------------------------------------------------------*/
30
31#if (R_DRAWCOLUMN_PIPELINE_BITS == 8)
32#define SCREENTYPE byte
33#define TOPLEFT byte_topleft
34#define PITCH byte_pitch
35#define TEMPBUF byte_tempbuf
36#elif (R_DRAWCOLUMN_PIPELINE_BITS == 15)
37#define SCREENTYPE unsigned short
38#define TOPLEFT short_topleft
39#define PITCH short_pitch
40#define TEMPBUF short_tempbuf
41#elif (R_DRAWCOLUMN_PIPELINE_BITS == 16)
42#define SCREENTYPE unsigned short
43#define TOPLEFT short_topleft
44#define PITCH short_pitch
45#define TEMPBUF short_tempbuf
46#elif (R_DRAWCOLUMN_PIPELINE_BITS == 32)
47#define SCREENTYPE unsigned int
48#define TOPLEFT int_topleft
49#define PITCH int_pitch
50#define TEMPBUF int_tempbuf
51#endif
52
53#if (R_DRAWCOLUMN_PIPELINE & RDC_TRANSLUCENT)
54#define GETDESTCOLOR8(col1, col2) (temptranmap[((col1)<<8)+(col2)])
55#define GETDESTCOLOR15(col1, col2) (GETBLENDED15_3268((col1), (col2)))
56#define GETDESTCOLOR16(col1, col2) (GETBLENDED16_3268((col1), (col2)))
57#define GETDESTCOLOR32(col1, col2) (GETBLENDED32_3268((col1), (col2)))
58#elif (R_DRAWCOLUMN_PIPELINE & RDC_FUZZ)
59#define GETDESTCOLOR8(col) (tempfuzzmap[6*256+(col)])
60#define GETDESTCOLOR15(col) GETBLENDED15_9406(col, 0)
61#define GETDESTCOLOR16(col) GETBLENDED16_9406(col, 0)
62#define GETDESTCOLOR32(col) GETBLENDED32_9406(col, 0)
63#else
64#define GETDESTCOLOR8(col) (col)
65#define GETDESTCOLOR15(col) (col)
66#define GETDESTCOLOR16(col) (col)
67#define GETDESTCOLOR32(col) (col)
68#endif
69
70#if (R_DRAWCOLUMN_PIPELINE & RDC_TRANSLUCENT)
71 #if (R_DRAWCOLUMN_PIPELINE_BITS == 8)
72 #define GETDESTCOLOR(col1, col2) GETDESTCOLOR8(col1, col2)
73 #elif (R_DRAWCOLUMN_PIPELINE_BITS == 15)
74 #define GETDESTCOLOR(col1, col2) GETDESTCOLOR15(col1, col2)
75 #elif (R_DRAWCOLUMN_PIPELINE_BITS == 16)
76 #define GETDESTCOLOR(col1, col2) GETDESTCOLOR16(col1, col2)
77 #elif (R_DRAWCOLUMN_PIPELINE_BITS == 32)
78 #define GETDESTCOLOR(col1, col2) GETDESTCOLOR32(col1, col2)
79 #endif
80#else
81 #if (R_DRAWCOLUMN_PIPELINE_BITS == 8)
82 #define GETDESTCOLOR(col) GETDESTCOLOR8(col)
83 #elif (R_DRAWCOLUMN_PIPELINE_BITS == 15)
84 #define GETDESTCOLOR(col) GETDESTCOLOR15(col)
85 #elif (R_DRAWCOLUMN_PIPELINE_BITS == 16)
86 #define GETDESTCOLOR(col) GETDESTCOLOR16(col)
87 #elif (R_DRAWCOLUMN_PIPELINE_BITS == 32)
88 #define GETDESTCOLOR(col) GETDESTCOLOR32(col)
89 #endif
90#endif
91
92//
93// R_FlushWholeOpaque
94//
95// Flushes the entire columns in the buffer, one at a time.
96// This is used when a quad flush isn't possible.
97// Opaque version -- no remapping whatsoever.
98//
99static void R_FLUSHWHOLE_FUNCNAME(void)
100{
101 SCREENTYPE *source;
102 SCREENTYPE *dest;
103 int count, yl;
104
105 while(--temp_x >= 0)
106 {
107 yl = tempyl[temp_x];
108 source = &TEMPBUF[temp_x + (yl << 2)];
109 dest = drawvars.TOPLEFT + yl*drawvars.PITCH + startx + temp_x;
110 count = tempyh[temp_x] - yl + 1;
111
112 while(--count >= 0)
113 {
114#if (R_DRAWCOLUMN_PIPELINE & RDC_TRANSLUCENT)
115 *dest = GETDESTCOLOR(*dest, *source);
116#elif (R_DRAWCOLUMN_PIPELINE & RDC_FUZZ)
117 // SoM 7-28-04: Fix the fuzz problem.
118 *dest = GETDESTCOLOR(dest[fuzzoffset[fuzzpos]]);
119
120 // Clamp table lookup index.
121 if(++fuzzpos == FUZZTABLE)
122 fuzzpos = 0;
123#else
124 *dest = *source;
125#endif
126
127 source += 4;
128 dest += drawvars.PITCH;
129 }
130 }
131}
132
133//
134// R_FlushHTOpaque
135//
136// Flushes the head and tail of columns in the buffer in
137// preparation for a quad flush.
138// Opaque version -- no remapping whatsoever.
139//
140static void R_FLUSHHEADTAIL_FUNCNAME(void)
141{
142 SCREENTYPE *source;
143 SCREENTYPE *dest;
144 int count, colnum = 0;
145 int yl, yh;
146
147 while(colnum < 4)
148 {
149 yl = tempyl[colnum];
150 yh = tempyh[colnum];
151
152 // flush column head
153 if(yl < commontop)
154 {
155 source = &TEMPBUF[colnum + (yl << 2)];
156 dest = drawvars.TOPLEFT + yl*drawvars.PITCH + startx + colnum;
157 count = commontop - yl;
158
159 while(--count >= 0)
160 {
161#if (R_DRAWCOLUMN_PIPELINE & RDC_TRANSLUCENT)
162 // haleyjd 09/11/04: use temptranmap here
163 *dest = GETDESTCOLOR(*dest, *source);
164#elif (R_DRAWCOLUMN_PIPELINE & RDC_FUZZ)
165 // SoM 7-28-04: Fix the fuzz problem.
166 *dest = GETDESTCOLOR(dest[fuzzoffset[fuzzpos]]);
167
168 // Clamp table lookup index.
169 if(++fuzzpos == FUZZTABLE)
170 fuzzpos = 0;
171#else
172 *dest = *source;
173#endif
174
175 source += 4;
176 dest += drawvars.PITCH;
177 }
178 }
179
180 // flush column tail
181 if(yh > commonbot)
182 {
183 source = &TEMPBUF[colnum + ((commonbot + 1) << 2)];
184 dest = drawvars.TOPLEFT + (commonbot + 1)*drawvars.PITCH + startx + colnum;
185 count = yh - commonbot;
186
187 while(--count >= 0)
188 {
189#if (R_DRAWCOLUMN_PIPELINE & RDC_TRANSLUCENT)
190 // haleyjd 09/11/04: use temptranmap here
191 *dest = GETDESTCOLOR(*dest, *source);
192#elif (R_DRAWCOLUMN_PIPELINE & RDC_FUZZ)
193 // SoM 7-28-04: Fix the fuzz problem.
194 *dest = GETDESTCOLOR(dest[fuzzoffset[fuzzpos]]);
195
196 // Clamp table lookup index.
197 if(++fuzzpos == FUZZTABLE)
198 fuzzpos = 0;
199#else
200 *dest = *source;
201#endif
202
203 source += 4;
204 dest += drawvars.PITCH;
205 }
206 }
207 ++colnum;
208 }
209}
210
211static void R_FLUSHQUAD_FUNCNAME(void)
212{
213 SCREENTYPE *source = &TEMPBUF[commontop << 2];
214 SCREENTYPE *dest = drawvars.TOPLEFT + commontop*drawvars.PITCH + startx;
215 int count;
216#if (R_DRAWCOLUMN_PIPELINE & RDC_FUZZ)
217 int fuzz1, fuzz2, fuzz3, fuzz4;
218
219 fuzz1 = fuzzpos;
220 fuzz2 = (fuzz1 + tempyl[1]) % FUZZTABLE;
221 fuzz3 = (fuzz2 + tempyl[2]) % FUZZTABLE;
222 fuzz4 = (fuzz3 + tempyl[3]) % FUZZTABLE;
223#endif
224
225 count = commonbot - commontop + 1;
226
227#if (R_DRAWCOLUMN_PIPELINE & RDC_TRANSLUCENT)
228 while(--count >= 0)
229 {
230 dest[0] = GETDESTCOLOR(dest[0], source[0]);
231 dest[1] = GETDESTCOLOR(dest[1], source[1]);
232 dest[2] = GETDESTCOLOR(dest[2], source[2]);
233 dest[3] = GETDESTCOLOR(dest[3], source[3]);
234 source += 4 * sizeof(byte);
235 dest += drawvars.PITCH * sizeof(byte);
236 }
237#elif (R_DRAWCOLUMN_PIPELINE & RDC_FUZZ)
238 while(--count >= 0)
239 {
240 dest[0] = GETDESTCOLOR(dest[0 + fuzzoffset[fuzz1]]);
241 dest[1] = GETDESTCOLOR(dest[1 + fuzzoffset[fuzz2]]);
242 dest[2] = GETDESTCOLOR(dest[2 + fuzzoffset[fuzz3]]);
243 dest[3] = GETDESTCOLOR(dest[3 + fuzzoffset[fuzz4]]);
244 fuzz1 = (fuzz1 + 1) % FUZZTABLE;
245 fuzz2 = (fuzz2 + 1) % FUZZTABLE;
246 fuzz3 = (fuzz3 + 1) % FUZZTABLE;
247 fuzz4 = (fuzz4 + 1) % FUZZTABLE;
248 source += 4 * sizeof(byte);
249 dest += drawvars.PITCH * sizeof(byte);
250 }
251#else
252 #if (R_DRAWCOLUMN_PIPELINE_BITS == 8)
253 if ((sizeof(int) == 4) && (((int)source % 4) == 0) && (((int)dest % 4) == 0)) {
254 while(--count >= 0)
255 {
256 *(int *)dest = *(int *)source;
257 source += 4 * sizeof(byte);
258 dest += drawvars.PITCH * sizeof(byte);
259 }
260 } else {
261 while(--count >= 0)
262 {
263 dest[0] = source[0];
264 dest[1] = source[1];
265 dest[2] = source[2];
266 dest[3] = source[3];
267 source += 4 * sizeof(byte);
268 dest += drawvars.PITCH * sizeof(byte);
269 }
270 }
271 #else
272 while(--count >= 0)
273 {
274 dest[0] = source[0];
275 dest[1] = source[1];
276 dest[2] = source[2];
277 dest[3] = source[3];
278 source += 4;
279 dest += drawvars.PITCH;
280 }
281 #endif
282#endif
283}
284
285#undef GETDESTCOLOR32
286#undef GETDESTCOLOR16
287#undef GETDESTCOLOR15
288#undef GETDESTCOLOR8
289#undef GETDESTCOLOR
290
291#undef TEMPBUF
292#undef PITCH
293#undef TOPLEFT
294#undef SCREENTYPE
295
296#undef R_DRAWCOLUMN_PIPELINE_BITS
297#undef R_DRAWCOLUMN_PIPELINE
298#undef R_FLUSHWHOLE_FUNCNAME
299#undef R_FLUSHHEADTAIL_FUNCNAME
300#undef R_FLUSHQUAD_FUNCNAME