diff options
Diffstat (limited to 'src/r_draw.c')
-rw-r--r-- | src/r_draw.c | 1128 |
1 files changed, 1128 insertions, 0 deletions
diff --git a/src/r_draw.c b/src/r_draw.c new file mode 100644 index 0000000..388bd76 --- /dev/null +++ b/src/r_draw.c | |||
@@ -0,0 +1,1128 @@ | |||
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 | * DESCRIPTION: | ||
30 | * The actual span/column drawing functions. | ||
31 | * Here find the main potential for optimization, | ||
32 | * e.g. inline assembly, different algorithms. | ||
33 | * | ||
34 | *-----------------------------------------------------------------------------*/ | ||
35 | |||
36 | #include "doomstat.h" | ||
37 | #include "w_wad.h" | ||
38 | #include "r_main.h" | ||
39 | #include "r_draw.h" | ||
40 | #include "r_filter.h" | ||
41 | #include "v_video.h" | ||
42 | #include "st_stuff.h" | ||
43 | #include "g_game.h" | ||
44 | #include "am_map.h" | ||
45 | #include "lprintf.h" | ||
46 | |||
47 | // | ||
48 | // All drawing to the view buffer is accomplished in this file. | ||
49 | // The other refresh files only know about ccordinates, | ||
50 | // not the architecture of the frame buffer. | ||
51 | // Conveniently, the frame buffer is a linear one, | ||
52 | // and we need only the base address, | ||
53 | // and the total size == width*height*depth/8., | ||
54 | // | ||
55 | |||
56 | byte *viewimage; | ||
57 | int viewwidth; | ||
58 | int scaledviewwidth; | ||
59 | int viewheight; | ||
60 | int viewwindowx; | ||
61 | int viewwindowy; | ||
62 | |||
63 | // Color tables for different players, | ||
64 | // translate a limited part to another | ||
65 | // (color ramps used for suit colors). | ||
66 | // | ||
67 | |||
68 | // CPhipps - made const*'s | ||
69 | const byte *tranmap; // translucency filter maps 256x256 // phares | ||
70 | const byte *main_tranmap; // killough 4/11/98 | ||
71 | |||
72 | // | ||
73 | // R_DrawColumn | ||
74 | // Source is the top of the column to scale. | ||
75 | // | ||
76 | |||
77 | // SoM: OPTIMIZE for ANYRES | ||
78 | typedef enum | ||
79 | { | ||
80 | COL_NONE, | ||
81 | COL_OPAQUE, | ||
82 | COL_TRANS, | ||
83 | COL_FLEXTRANS, | ||
84 | COL_FUZZ, | ||
85 | COL_FLEXADD | ||
86 | } columntype_e; | ||
87 | |||
88 | static int temp_x = 0; | ||
89 | static int tempyl[4], tempyh[4]; | ||
90 | static byte byte_tempbuf[MAX_SCREENHEIGHT * 4]; | ||
91 | static unsigned short short_tempbuf[MAX_SCREENHEIGHT * 4]; | ||
92 | static unsigned int int_tempbuf[MAX_SCREENHEIGHT * 4]; | ||
93 | static int startx = 0; | ||
94 | static int temptype = COL_NONE; | ||
95 | static int commontop, commonbot; | ||
96 | static const byte *temptranmap = NULL; | ||
97 | // SoM 7-28-04: Fix the fuzz problem. | ||
98 | static const byte *tempfuzzmap; | ||
99 | |||
100 | // | ||
101 | // Spectre/Invisibility. | ||
102 | // | ||
103 | |||
104 | #define FUZZTABLE 50 | ||
105 | // proff 08/17/98: Changed for high-res | ||
106 | //#define FUZZOFF (SCREENWIDTH) | ||
107 | #define FUZZOFF 1 | ||
108 | |||
109 | static const int fuzzoffset_org[FUZZTABLE] = { | ||
110 | FUZZOFF,-FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF, | ||
111 | FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF, | ||
112 | FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF, | ||
113 | FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF, | ||
114 | FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF, | ||
115 | FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF, | ||
116 | FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF | ||
117 | }; | ||
118 | |||
119 | static int fuzzoffset[FUZZTABLE]; | ||
120 | |||
121 | static int fuzzpos = 0; | ||
122 | |||
123 | // render pipelines | ||
124 | #define RDC_STANDARD 1 | ||
125 | #define RDC_TRANSLUCENT 2 | ||
126 | #define RDC_TRANSLATED 4 | ||
127 | #define RDC_FUZZ 8 | ||
128 | // no color mapping | ||
129 | #define RDC_NOCOLMAP 16 | ||
130 | // filter modes | ||
131 | #define RDC_DITHERZ 32 | ||
132 | #define RDC_BILINEAR 64 | ||
133 | #define RDC_ROUNDED 128 | ||
134 | |||
135 | draw_vars_t drawvars = { | ||
136 | NULL, // byte_topleft | ||
137 | NULL, // short_topleft | ||
138 | NULL, // int_topleft | ||
139 | 0, // byte_pitch | ||
140 | 0, // short_pitch | ||
141 | 0, // int_pitch | ||
142 | RDRAW_FILTER_POINT, // filterwall | ||
143 | RDRAW_FILTER_POINT, // filterfloor | ||
144 | RDRAW_FILTER_POINT, // filtersprite | ||
145 | RDRAW_FILTER_POINT, // filterz | ||
146 | RDRAW_FILTER_POINT, // filterpatch | ||
147 | |||
148 | RDRAW_MASKEDCOLUMNEDGE_SQUARE, // sprite_edges | ||
149 | RDRAW_MASKEDCOLUMNEDGE_SQUARE, // patch_edges | ||
150 | |||
151 | // 49152 = FRACUNIT * 0.75 | ||
152 | // 81920 = FRACUNIT * 1.25 | ||
153 | 49152 // mag_threshold | ||
154 | }; | ||
155 | |||
156 | // | ||
157 | // Error functions that will abort if R_FlushColumns tries to flush | ||
158 | // columns without a column type. | ||
159 | // | ||
160 | |||
161 | static void R_FlushWholeError(void) | ||
162 | { | ||
163 | I_Error("R_FlushWholeColumns called without being initialized.\n"); | ||
164 | } | ||
165 | |||
166 | static void R_FlushHTError(void) | ||
167 | { | ||
168 | I_Error("R_FlushHTColumns called without being initialized.\n"); | ||
169 | } | ||
170 | |||
171 | static void R_QuadFlushError(void) | ||
172 | { | ||
173 | I_Error("R_FlushQuadColumn called without being initialized.\n"); | ||
174 | } | ||
175 | |||
176 | static void (*R_FlushWholeColumns)(void) = R_FlushWholeError; | ||
177 | static void (*R_FlushHTColumns)(void) = R_FlushHTError; | ||
178 | static void (*R_FlushQuadColumn)(void) = R_QuadFlushError; | ||
179 | |||
180 | static void R_FlushColumns(void) | ||
181 | { | ||
182 | if(temp_x != 4 || commontop >= commonbot) | ||
183 | R_FlushWholeColumns(); | ||
184 | else | ||
185 | { | ||
186 | R_FlushHTColumns(); | ||
187 | R_FlushQuadColumn(); | ||
188 | } | ||
189 | temp_x = 0; | ||
190 | } | ||
191 | |||
192 | // | ||
193 | // R_ResetColumnBuffer | ||
194 | // | ||
195 | // haleyjd 09/13/04: new function to call from main rendering loop | ||
196 | // which gets rid of the unnecessary reset of various variables during | ||
197 | // column drawing. | ||
198 | // | ||
199 | void R_ResetColumnBuffer(void) | ||
200 | { | ||
201 | // haleyjd 10/06/05: this must not be done if temp_x == 0! | ||
202 | if(temp_x) | ||
203 | R_FlushColumns(); | ||
204 | temptype = COL_NONE; | ||
205 | R_FlushWholeColumns = R_FlushWholeError; | ||
206 | R_FlushHTColumns = R_FlushHTError; | ||
207 | R_FlushQuadColumn = R_QuadFlushError; | ||
208 | } | ||
209 | |||
210 | #define R_DRAWCOLUMN_PIPELINE RDC_STANDARD | ||
211 | #define R_DRAWCOLUMN_PIPELINE_BITS 8 | ||
212 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole8 | ||
213 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT8 | ||
214 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuad8 | ||
215 | #include "r_drawflush.inl" | ||
216 | |||
217 | #define R_DRAWCOLUMN_PIPELINE RDC_TRANSLUCENT | ||
218 | #define R_DRAWCOLUMN_PIPELINE_BITS 8 | ||
219 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeTL8 | ||
220 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTTL8 | ||
221 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuadTL8 | ||
222 | #include "r_drawflush.inl" | ||
223 | |||
224 | #define R_DRAWCOLUMN_PIPELINE RDC_FUZZ | ||
225 | #define R_DRAWCOLUMN_PIPELINE_BITS 8 | ||
226 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeFuzz8 | ||
227 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTFuzz8 | ||
228 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuadFuzz8 | ||
229 | #include "r_drawflush.inl" | ||
230 | |||
231 | #define R_DRAWCOLUMN_PIPELINE RDC_STANDARD | ||
232 | #define R_DRAWCOLUMN_PIPELINE_BITS 15 | ||
233 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole15 | ||
234 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT15 | ||
235 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuad15 | ||
236 | #include "r_drawflush.inl" | ||
237 | |||
238 | #define R_DRAWCOLUMN_PIPELINE RDC_TRANSLUCENT | ||
239 | #define R_DRAWCOLUMN_PIPELINE_BITS 15 | ||
240 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeTL15 | ||
241 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTTL15 | ||
242 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuadTL15 | ||
243 | #include "r_drawflush.inl" | ||
244 | |||
245 | #define R_DRAWCOLUMN_PIPELINE RDC_FUZZ | ||
246 | #define R_DRAWCOLUMN_PIPELINE_BITS 15 | ||
247 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeFuzz15 | ||
248 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTFuzz15 | ||
249 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuadFuzz15 | ||
250 | #include "r_drawflush.inl" | ||
251 | |||
252 | #define R_DRAWCOLUMN_PIPELINE RDC_STANDARD | ||
253 | #define R_DRAWCOLUMN_PIPELINE_BITS 16 | ||
254 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole16 | ||
255 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT16 | ||
256 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuad16 | ||
257 | #include "r_drawflush.inl" | ||
258 | |||
259 | #define R_DRAWCOLUMN_PIPELINE RDC_TRANSLUCENT | ||
260 | #define R_DRAWCOLUMN_PIPELINE_BITS 16 | ||
261 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeTL16 | ||
262 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTTL16 | ||
263 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuadTL16 | ||
264 | #include "r_drawflush.inl" | ||
265 | |||
266 | #define R_DRAWCOLUMN_PIPELINE RDC_FUZZ | ||
267 | #define R_DRAWCOLUMN_PIPELINE_BITS 16 | ||
268 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeFuzz16 | ||
269 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTFuzz16 | ||
270 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuadFuzz16 | ||
271 | #include "r_drawflush.inl" | ||
272 | |||
273 | #define R_DRAWCOLUMN_PIPELINE RDC_STANDARD | ||
274 | #define R_DRAWCOLUMN_PIPELINE_BITS 32 | ||
275 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole32 | ||
276 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT32 | ||
277 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuad32 | ||
278 | #include "r_drawflush.inl" | ||
279 | |||
280 | #define R_DRAWCOLUMN_PIPELINE RDC_TRANSLUCENT | ||
281 | #define R_DRAWCOLUMN_PIPELINE_BITS 32 | ||
282 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeTL32 | ||
283 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTTL32 | ||
284 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuadTL32 | ||
285 | #include "r_drawflush.inl" | ||
286 | |||
287 | #define R_DRAWCOLUMN_PIPELINE RDC_FUZZ | ||
288 | #define R_DRAWCOLUMN_PIPELINE_BITS 32 | ||
289 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeFuzz32 | ||
290 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTFuzz32 | ||
291 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuadFuzz32 | ||
292 | #include "r_drawflush.inl" | ||
293 | |||
294 | // | ||
295 | // R_DrawColumn | ||
296 | // | ||
297 | |||
298 | // | ||
299 | // A column is a vertical slice/span from a wall texture that, | ||
300 | // given the DOOM style restrictions on the view orientation, | ||
301 | // will always have constant z depth. | ||
302 | // Thus a special case loop for very fast rendering can | ||
303 | // be used. It has also been used with Wolfenstein 3D. | ||
304 | // | ||
305 | |||
306 | byte *translationtables; | ||
307 | |||
308 | #define R_DRAWCOLUMN_PIPELINE_TYPE RDC_PIPELINE_STANDARD | ||
309 | #define R_DRAWCOLUMN_PIPELINE_BASE RDC_STANDARD | ||
310 | |||
311 | #define R_DRAWCOLUMN_PIPELINE_BITS 8 | ||
312 | #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawColumn8 ## postfix | ||
313 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole8 | ||
314 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT8 | ||
315 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuad8 | ||
316 | #include "r_drawcolpipeline.inl" | ||
317 | |||
318 | #define R_DRAWCOLUMN_PIPELINE_BITS 15 | ||
319 | #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawColumn15 ## postfix | ||
320 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole15 | ||
321 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT15 | ||
322 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuad15 | ||
323 | #include "r_drawcolpipeline.inl" | ||
324 | |||
325 | #define R_DRAWCOLUMN_PIPELINE_BITS 16 | ||
326 | #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawColumn16 ## postfix | ||
327 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole16 | ||
328 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT16 | ||
329 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuad16 | ||
330 | #include "r_drawcolpipeline.inl" | ||
331 | |||
332 | #define R_DRAWCOLUMN_PIPELINE_BITS 32 | ||
333 | #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawColumn32 ## postfix | ||
334 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole32 | ||
335 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT32 | ||
336 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuad32 | ||
337 | #include "r_drawcolpipeline.inl" | ||
338 | |||
339 | #undef R_DRAWCOLUMN_PIPELINE_BASE | ||
340 | #undef R_DRAWCOLUMN_PIPELINE_TYPE | ||
341 | |||
342 | // Here is the version of R_DrawColumn that deals with translucent // phares | ||
343 | // textures and sprites. It's identical to R_DrawColumn except // | | ||
344 | // for the spot where the color index is stuffed into *dest. At // V | ||
345 | // that point, the existing color index and the new color index | ||
346 | // are mapped through the TRANMAP lump filters to get a new color | ||
347 | // index whose RGB values are the average of the existing and new | ||
348 | // colors. | ||
349 | // | ||
350 | // Since we're concerned about performance, the 'translucent or | ||
351 | // opaque' decision is made outside this routine, not down where the | ||
352 | // actual code differences are. | ||
353 | |||
354 | #define R_DRAWCOLUMN_PIPELINE_TYPE RDC_PIPELINE_TRANSLUCENT | ||
355 | #define R_DRAWCOLUMN_PIPELINE_BASE RDC_TRANSLUCENT | ||
356 | |||
357 | #define R_DRAWCOLUMN_PIPELINE_BITS 8 | ||
358 | #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawTLColumn8 ## postfix | ||
359 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeTL8 | ||
360 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTTL8 | ||
361 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuadTL8 | ||
362 | #include "r_drawcolpipeline.inl" | ||
363 | |||
364 | #define R_DRAWCOLUMN_PIPELINE_BITS 15 | ||
365 | #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawTLColumn15 ## postfix | ||
366 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeTL15 | ||
367 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTTL15 | ||
368 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuadTL15 | ||
369 | #include "r_drawcolpipeline.inl" | ||
370 | |||
371 | #define R_DRAWCOLUMN_PIPELINE_BITS 16 | ||
372 | #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawTLColumn16 ## postfix | ||
373 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeTL16 | ||
374 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTTL16 | ||
375 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuadTL16 | ||
376 | #include "r_drawcolpipeline.inl" | ||
377 | |||
378 | #define R_DRAWCOLUMN_PIPELINE_BITS 32 | ||
379 | #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawTLColumn32 ## postfix | ||
380 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeTL32 | ||
381 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTTL32 | ||
382 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuadTL32 | ||
383 | #include "r_drawcolpipeline.inl" | ||
384 | |||
385 | #undef R_DRAWCOLUMN_PIPELINE_BASE | ||
386 | #undef R_DRAWCOLUMN_PIPELINE_TYPE | ||
387 | |||
388 | // | ||
389 | // R_DrawTranslatedColumn | ||
390 | // Used to draw player sprites | ||
391 | // with the green colorramp mapped to others. | ||
392 | // Could be used with different translation | ||
393 | // tables, e.g. the lighter colored version | ||
394 | // of the BaronOfHell, the HellKnight, uses | ||
395 | // identical sprites, kinda brightened up. | ||
396 | // | ||
397 | |||
398 | #define R_DRAWCOLUMN_PIPELINE_TYPE RDC_PIPELINE_TRANSLATED | ||
399 | #define R_DRAWCOLUMN_PIPELINE_BASE RDC_TRANSLATED | ||
400 | |||
401 | #define R_DRAWCOLUMN_PIPELINE_BITS 8 | ||
402 | #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawTranslatedColumn8 ## postfix | ||
403 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole8 | ||
404 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT8 | ||
405 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuad8 | ||
406 | #include "r_drawcolpipeline.inl" | ||
407 | |||
408 | #define R_DRAWCOLUMN_PIPELINE_BITS 15 | ||
409 | #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawTranslatedColumn15 ## postfix | ||
410 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole15 | ||
411 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT15 | ||
412 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuad15 | ||
413 | #include "r_drawcolpipeline.inl" | ||
414 | |||
415 | #define R_DRAWCOLUMN_PIPELINE_BITS 16 | ||
416 | #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawTranslatedColumn16 ## postfix | ||
417 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole16 | ||
418 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT16 | ||
419 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuad16 | ||
420 | #include "r_drawcolpipeline.inl" | ||
421 | |||
422 | #define R_DRAWCOLUMN_PIPELINE_BITS 32 | ||
423 | #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawTranslatedColumn32 ## postfix | ||
424 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWhole32 | ||
425 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHT32 | ||
426 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuad32 | ||
427 | #include "r_drawcolpipeline.inl" | ||
428 | |||
429 | #undef R_DRAWCOLUMN_PIPELINE_BASE | ||
430 | #undef R_DRAWCOLUMN_PIPELINE_TYPE | ||
431 | |||
432 | // | ||
433 | // Framebuffer postprocessing. | ||
434 | // Creates a fuzzy image by copying pixels | ||
435 | // from adjacent ones to left and right. | ||
436 | // Used with an all black colormap, this | ||
437 | // could create the SHADOW effect, | ||
438 | // i.e. spectres and invisible players. | ||
439 | // | ||
440 | |||
441 | #define R_DRAWCOLUMN_PIPELINE_TYPE RDC_PIPELINE_FUZZ | ||
442 | #define R_DRAWCOLUMN_PIPELINE_BASE RDC_FUZZ | ||
443 | |||
444 | #define R_DRAWCOLUMN_PIPELINE_BITS 8 | ||
445 | #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawFuzzColumn8 ## postfix | ||
446 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeFuzz8 | ||
447 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTFuzz8 | ||
448 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuadFuzz8 | ||
449 | #include "r_drawcolpipeline.inl" | ||
450 | |||
451 | #define R_DRAWCOLUMN_PIPELINE_BITS 15 | ||
452 | #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawFuzzColumn15 ## postfix | ||
453 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeFuzz15 | ||
454 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTFuzz15 | ||
455 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuadFuzz15 | ||
456 | #include "r_drawcolpipeline.inl" | ||
457 | |||
458 | #define R_DRAWCOLUMN_PIPELINE_BITS 16 | ||
459 | #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawFuzzColumn16 ## postfix | ||
460 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeFuzz16 | ||
461 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTFuzz16 | ||
462 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuadFuzz16 | ||
463 | #include "r_drawcolpipeline.inl" | ||
464 | |||
465 | #define R_DRAWCOLUMN_PIPELINE_BITS 32 | ||
466 | #define R_DRAWCOLUMN_FUNCNAME_COMPOSITE(postfix) R_DrawFuzzColumn32 ## postfix | ||
467 | #define R_FLUSHWHOLE_FUNCNAME R_FlushWholeFuzz32 | ||
468 | #define R_FLUSHHEADTAIL_FUNCNAME R_FlushHTFuzz32 | ||
469 | #define R_FLUSHQUAD_FUNCNAME R_FlushQuadFuzz32 | ||
470 | #include "r_drawcolpipeline.inl" | ||
471 | |||
472 | #undef R_DRAWCOLUMN_PIPELINE_BASE | ||
473 | #undef R_DRAWCOLUMN_PIPELINE_TYPE | ||
474 | |||
475 | static R_DrawColumn_f drawcolumnfuncs[VID_MODEMAX][RDRAW_FILTER_MAXFILTERS][RDRAW_FILTER_MAXFILTERS][RDC_PIPELINE_MAXPIPELINES] = { | ||
476 | { | ||
477 | { | ||
478 | {NULL, NULL, NULL, NULL,}, | ||
479 | {R_DrawColumn8_PointUV, | ||
480 | R_DrawTLColumn8_PointUV, | ||
481 | R_DrawTranslatedColumn8_PointUV, | ||
482 | R_DrawFuzzColumn8_PointUV,}, | ||
483 | {R_DrawColumn8_LinearUV, | ||
484 | R_DrawTLColumn8_LinearUV, | ||
485 | R_DrawTranslatedColumn8_LinearUV, | ||
486 | R_DrawFuzzColumn8_LinearUV,}, | ||
487 | {R_DrawColumn8_RoundedUV, | ||
488 | R_DrawTLColumn8_RoundedUV, | ||
489 | R_DrawTranslatedColumn8_RoundedUV, | ||
490 | R_DrawFuzzColumn8_RoundedUV,}, | ||
491 | }, | ||
492 | { | ||
493 | {NULL, NULL, NULL, NULL,}, | ||
494 | {R_DrawColumn8_PointUV_PointZ, | ||
495 | R_DrawTLColumn8_PointUV_PointZ, | ||
496 | R_DrawTranslatedColumn8_PointUV_PointZ, | ||
497 | R_DrawFuzzColumn8_PointUV_PointZ,}, | ||
498 | {R_DrawColumn8_LinearUV_PointZ, | ||
499 | R_DrawTLColumn8_LinearUV_PointZ, | ||
500 | R_DrawTranslatedColumn8_LinearUV_PointZ, | ||
501 | R_DrawFuzzColumn8_LinearUV_PointZ,}, | ||
502 | {R_DrawColumn8_RoundedUV_PointZ, | ||
503 | R_DrawTLColumn8_RoundedUV_PointZ, | ||
504 | R_DrawTranslatedColumn8_RoundedUV_PointZ, | ||
505 | R_DrawFuzzColumn8_RoundedUV_PointZ,}, | ||
506 | }, | ||
507 | { | ||
508 | {NULL, NULL, NULL, NULL,}, | ||
509 | {R_DrawColumn8_PointUV_LinearZ, | ||
510 | R_DrawTLColumn8_PointUV_LinearZ, | ||
511 | R_DrawTranslatedColumn8_PointUV_LinearZ, | ||
512 | R_DrawFuzzColumn8_PointUV_LinearZ,}, | ||
513 | {R_DrawColumn8_LinearUV_LinearZ, | ||
514 | R_DrawTLColumn8_LinearUV_LinearZ, | ||
515 | R_DrawTranslatedColumn8_LinearUV_LinearZ, | ||
516 | R_DrawFuzzColumn8_LinearUV_LinearZ,}, | ||
517 | {R_DrawColumn8_RoundedUV_LinearZ, | ||
518 | R_DrawTLColumn8_RoundedUV_LinearZ, | ||
519 | R_DrawTranslatedColumn8_RoundedUV_LinearZ, | ||
520 | R_DrawFuzzColumn8_RoundedUV_LinearZ,}, | ||
521 | }, | ||
522 | }, | ||
523 | { | ||
524 | { | ||
525 | {NULL, NULL, NULL, NULL,}, | ||
526 | {R_DrawColumn15_PointUV, | ||
527 | R_DrawTLColumn15_PointUV, | ||
528 | R_DrawTranslatedColumn15_PointUV, | ||
529 | R_DrawFuzzColumn15_PointUV,}, | ||
530 | {R_DrawColumn15_LinearUV, | ||
531 | R_DrawTLColumn15_LinearUV, | ||
532 | R_DrawTranslatedColumn15_LinearUV, | ||
533 | R_DrawFuzzColumn15_LinearUV,}, | ||
534 | {R_DrawColumn15_RoundedUV, | ||
535 | R_DrawTLColumn15_RoundedUV, | ||
536 | R_DrawTranslatedColumn15_RoundedUV, | ||
537 | R_DrawFuzzColumn15_RoundedUV,}, | ||
538 | }, | ||
539 | { | ||
540 | {NULL, NULL, NULL, NULL,}, | ||
541 | {R_DrawColumn15_PointUV_PointZ, | ||
542 | R_DrawTLColumn15_PointUV_PointZ, | ||
543 | R_DrawTranslatedColumn15_PointUV_PointZ, | ||
544 | R_DrawFuzzColumn15_PointUV_PointZ,}, | ||
545 | {R_DrawColumn15_LinearUV_PointZ, | ||
546 | R_DrawTLColumn15_LinearUV_PointZ, | ||
547 | R_DrawTranslatedColumn15_LinearUV_PointZ, | ||
548 | R_DrawFuzzColumn15_LinearUV_PointZ,}, | ||
549 | {R_DrawColumn15_RoundedUV_PointZ, | ||
550 | R_DrawTLColumn15_RoundedUV_PointZ, | ||
551 | R_DrawTranslatedColumn15_RoundedUV_PointZ, | ||
552 | R_DrawFuzzColumn15_RoundedUV_PointZ,}, | ||
553 | }, | ||
554 | { | ||
555 | {NULL, NULL, NULL, NULL,}, | ||
556 | {R_DrawColumn15_PointUV_LinearZ, | ||
557 | R_DrawTLColumn15_PointUV_LinearZ, | ||
558 | R_DrawTranslatedColumn15_PointUV_LinearZ, | ||
559 | R_DrawFuzzColumn15_PointUV_LinearZ,}, | ||
560 | {R_DrawColumn15_LinearUV_LinearZ, | ||
561 | R_DrawTLColumn15_LinearUV_LinearZ, | ||
562 | R_DrawTranslatedColumn15_LinearUV_LinearZ, | ||
563 | R_DrawFuzzColumn15_LinearUV_LinearZ,}, | ||
564 | {R_DrawColumn15_RoundedUV_LinearZ, | ||
565 | R_DrawTLColumn15_RoundedUV_LinearZ, | ||
566 | R_DrawTranslatedColumn15_RoundedUV_LinearZ, | ||
567 | R_DrawFuzzColumn15_RoundedUV_LinearZ,}, | ||
568 | }, | ||
569 | }, | ||
570 | { | ||
571 | { | ||
572 | {NULL, NULL, NULL, NULL,}, | ||
573 | {R_DrawColumn16_PointUV, | ||
574 | R_DrawTLColumn16_PointUV, | ||
575 | R_DrawTranslatedColumn16_PointUV, | ||
576 | R_DrawFuzzColumn16_PointUV,}, | ||
577 | {R_DrawColumn16_LinearUV, | ||
578 | R_DrawTLColumn16_LinearUV, | ||
579 | R_DrawTranslatedColumn16_LinearUV, | ||
580 | R_DrawFuzzColumn16_LinearUV,}, | ||
581 | {R_DrawColumn16_RoundedUV, | ||
582 | R_DrawTLColumn16_RoundedUV, | ||
583 | R_DrawTranslatedColumn16_RoundedUV, | ||
584 | R_DrawFuzzColumn16_RoundedUV,}, | ||
585 | }, | ||
586 | { | ||
587 | {NULL, NULL, NULL, NULL,}, | ||
588 | {R_DrawColumn16_PointUV_PointZ, | ||
589 | R_DrawTLColumn16_PointUV_PointZ, | ||
590 | R_DrawTranslatedColumn16_PointUV_PointZ, | ||
591 | R_DrawFuzzColumn16_PointUV_PointZ,}, | ||
592 | {R_DrawColumn16_LinearUV_PointZ, | ||
593 | R_DrawTLColumn16_LinearUV_PointZ, | ||
594 | R_DrawTranslatedColumn16_LinearUV_PointZ, | ||
595 | R_DrawFuzzColumn16_LinearUV_PointZ,}, | ||
596 | {R_DrawColumn16_RoundedUV_PointZ, | ||
597 | R_DrawTLColumn16_RoundedUV_PointZ, | ||
598 | R_DrawTranslatedColumn16_RoundedUV_PointZ, | ||
599 | R_DrawFuzzColumn16_RoundedUV_PointZ,}, | ||
600 | }, | ||
601 | { | ||
602 | {NULL, NULL, NULL, NULL,}, | ||
603 | {R_DrawColumn16_PointUV_LinearZ, | ||
604 | R_DrawTLColumn16_PointUV_LinearZ, | ||
605 | R_DrawTranslatedColumn16_PointUV_LinearZ, | ||
606 | R_DrawFuzzColumn16_PointUV_LinearZ,}, | ||
607 | {R_DrawColumn16_LinearUV_LinearZ, | ||
608 | R_DrawTLColumn16_LinearUV_LinearZ, | ||
609 | R_DrawTranslatedColumn16_LinearUV_LinearZ, | ||
610 | R_DrawFuzzColumn16_LinearUV_LinearZ,}, | ||
611 | {R_DrawColumn16_RoundedUV_LinearZ, | ||
612 | R_DrawTLColumn16_RoundedUV_LinearZ, | ||
613 | R_DrawTranslatedColumn16_RoundedUV_LinearZ, | ||
614 | R_DrawFuzzColumn16_RoundedUV_LinearZ,}, | ||
615 | }, | ||
616 | }, | ||
617 | { | ||
618 | { | ||
619 | {NULL, NULL, NULL, NULL,}, | ||
620 | {R_DrawColumn32_PointUV, | ||
621 | R_DrawTLColumn32_PointUV, | ||
622 | R_DrawTranslatedColumn32_PointUV, | ||
623 | R_DrawFuzzColumn32_PointUV,}, | ||
624 | {R_DrawColumn32_LinearUV, | ||
625 | R_DrawTLColumn32_LinearUV, | ||
626 | R_DrawTranslatedColumn32_LinearUV, | ||
627 | R_DrawFuzzColumn32_LinearUV,}, | ||
628 | {R_DrawColumn32_RoundedUV, | ||
629 | R_DrawTLColumn32_RoundedUV, | ||
630 | R_DrawTranslatedColumn32_RoundedUV, | ||
631 | R_DrawFuzzColumn32_RoundedUV,}, | ||
632 | }, | ||
633 | { | ||
634 | {NULL, NULL, NULL, NULL,}, | ||
635 | {R_DrawColumn32_PointUV_PointZ, | ||
636 | R_DrawTLColumn32_PointUV_PointZ, | ||
637 | R_DrawTranslatedColumn32_PointUV_PointZ, | ||
638 | R_DrawFuzzColumn32_PointUV_PointZ,}, | ||
639 | {R_DrawColumn32_LinearUV_PointZ, | ||
640 | R_DrawTLColumn32_LinearUV_PointZ, | ||
641 | R_DrawTranslatedColumn32_LinearUV_PointZ, | ||
642 | R_DrawFuzzColumn32_LinearUV_PointZ,}, | ||
643 | {R_DrawColumn32_RoundedUV_PointZ, | ||
644 | R_DrawTLColumn32_RoundedUV_PointZ, | ||
645 | R_DrawTranslatedColumn32_RoundedUV_PointZ, | ||
646 | R_DrawFuzzColumn32_RoundedUV_PointZ,}, | ||
647 | }, | ||
648 | { | ||
649 | {NULL, NULL, NULL, NULL,}, | ||
650 | {R_DrawColumn32_PointUV_LinearZ, | ||
651 | R_DrawTLColumn32_PointUV_LinearZ, | ||
652 | R_DrawTranslatedColumn32_PointUV_LinearZ, | ||
653 | R_DrawFuzzColumn32_PointUV_LinearZ,}, | ||
654 | {R_DrawColumn32_LinearUV_LinearZ, | ||
655 | R_DrawTLColumn32_LinearUV_LinearZ, | ||
656 | R_DrawTranslatedColumn32_LinearUV_LinearZ, | ||
657 | R_DrawFuzzColumn32_LinearUV_LinearZ,}, | ||
658 | {R_DrawColumn32_RoundedUV_LinearZ, | ||
659 | R_DrawTLColumn32_RoundedUV_LinearZ, | ||
660 | R_DrawTranslatedColumn32_RoundedUV_LinearZ, | ||
661 | R_DrawFuzzColumn32_RoundedUV_LinearZ,}, | ||
662 | }, | ||
663 | }, | ||
664 | }; | ||
665 | |||
666 | R_DrawColumn_f R_GetDrawColumnFunc(enum column_pipeline_e type, | ||
667 | enum draw_filter_type_e filter, | ||
668 | enum draw_filter_type_e filterz) { | ||
669 | R_DrawColumn_f result = drawcolumnfuncs[V_GetMode()][filterz][filter][type]; | ||
670 | if (result == NULL) | ||
671 | I_Error("R_GetDrawColumnFunc: undefined function (%d, %d, %d)", | ||
672 | type, filter, filterz); | ||
673 | return result; | ||
674 | } | ||
675 | |||
676 | void R_SetDefaultDrawColumnVars(draw_column_vars_t *dcvars) { | ||
677 | dcvars->x = dcvars->yl = dcvars->yh = dcvars->z = 0; | ||
678 | dcvars->iscale = dcvars->texturemid = dcvars->texheight = dcvars->texu = 0; | ||
679 | dcvars->source = dcvars->prevsource = dcvars->nextsource = NULL; | ||
680 | dcvars->colormap = dcvars->nextcolormap = colormaps[0]; | ||
681 | dcvars->translation = NULL; | ||
682 | dcvars->edgeslope = dcvars->drawingmasked = 0; | ||
683 | dcvars->edgetype = drawvars.sprite_edges; | ||
684 | } | ||
685 | |||
686 | // | ||
687 | // R_InitTranslationTables | ||
688 | // Creates the translation tables to map | ||
689 | // the green color ramp to gray, brown, red. | ||
690 | // Assumes a given structure of the PLAYPAL. | ||
691 | // Could be read from a lump instead. | ||
692 | // | ||
693 | |||
694 | byte playernumtotrans[MAXPLAYERS]; | ||
695 | extern lighttable_t *(*c_zlight)[LIGHTLEVELS][MAXLIGHTZ]; | ||
696 | |||
697 | void R_InitTranslationTables (void) | ||
698 | { | ||
699 | int i, j; | ||
700 | #define MAXTRANS 3 | ||
701 | byte transtocolour[MAXTRANS]; | ||
702 | |||
703 | // killough 5/2/98: | ||
704 | // Remove dependency of colormaps aligned on 256-byte boundary | ||
705 | |||
706 | if (translationtables == NULL) // CPhipps - allow multiple calls | ||
707 | translationtables = Z_Malloc(256*MAXTRANS, PU_STATIC, 0); | ||
708 | |||
709 | for (i=0; i<MAXTRANS; i++) transtocolour[i] = 255; | ||
710 | |||
711 | for (i=0; i<MAXPLAYERS; i++) { | ||
712 | byte wantcolour = mapcolor_plyr[i]; | ||
713 | playernumtotrans[i] = 0; | ||
714 | if (wantcolour != 0x70) // Not green, would like translation | ||
715 | for (j=0; j<MAXTRANS; j++) | ||
716 | if (transtocolour[j] == 255) { | ||
717 | transtocolour[j] = wantcolour; playernumtotrans[i] = j+1; break; | ||
718 | } | ||
719 | } | ||
720 | |||
721 | // translate just the 16 green colors | ||
722 | for (i=0; i<256; i++) | ||
723 | if (i >= 0x70 && i<= 0x7f) | ||
724 | { | ||
725 | // CPhipps - configurable player colours | ||
726 | translationtables[i] = colormaps[0][((i&0xf)<<9) + transtocolour[0]]; | ||
727 | translationtables[i+256] = colormaps[0][((i&0xf)<<9) + transtocolour[1]]; | ||
728 | translationtables[i+512] = colormaps[0][((i&0xf)<<9) + transtocolour[2]]; | ||
729 | } | ||
730 | else // Keep all other colors as is. | ||
731 | translationtables[i]=translationtables[i+256]=translationtables[i+512]=i; | ||
732 | } | ||
733 | |||
734 | // | ||
735 | // R_DrawSpan | ||
736 | // With DOOM style restrictions on view orientation, | ||
737 | // the floors and ceilings consist of horizontal slices | ||
738 | // or spans with constant z depth. | ||
739 | // However, rotation around the world z axis is possible, | ||
740 | // thus this mapping, while simpler and faster than | ||
741 | // perspective correct texture mapping, has to traverse | ||
742 | // the texture at an angle in all but a few cases. | ||
743 | // In consequence, flats are not stored by column (like walls), | ||
744 | // and the inner loop has to step in texture space u and v. | ||
745 | // | ||
746 | |||
747 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan8_PointUV_PointZ | ||
748 | #define R_DRAWSPAN_PIPELINE_BITS 8 | ||
749 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD) | ||
750 | #include "r_drawspan.inl" | ||
751 | |||
752 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan8_PointUV_LinearZ | ||
753 | #define R_DRAWSPAN_PIPELINE_BITS 8 | ||
754 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_DITHERZ) | ||
755 | #include "r_drawspan.inl" | ||
756 | |||
757 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan8_LinearUV_PointZ | ||
758 | #define R_DRAWSPAN_PIPELINE_BITS 8 | ||
759 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_BILINEAR) | ||
760 | #include "r_drawspan.inl" | ||
761 | |||
762 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan8_LinearUV_LinearZ | ||
763 | #define R_DRAWSPAN_PIPELINE_BITS 8 | ||
764 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_BILINEAR | RDC_DITHERZ) | ||
765 | #include "r_drawspan.inl" | ||
766 | |||
767 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan8_RoundedUV_PointZ | ||
768 | #define R_DRAWSPAN_PIPELINE_BITS 8 | ||
769 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_ROUNDED) | ||
770 | #include "r_drawspan.inl" | ||
771 | |||
772 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan8_RoundedUV_LinearZ | ||
773 | #define R_DRAWSPAN_PIPELINE_BITS 8 | ||
774 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_ROUNDED | RDC_DITHERZ) | ||
775 | #include "r_drawspan.inl" | ||
776 | |||
777 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan15_PointUV_PointZ | ||
778 | #define R_DRAWSPAN_PIPELINE_BITS 15 | ||
779 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD) | ||
780 | #include "r_drawspan.inl" | ||
781 | |||
782 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan15_PointUV_LinearZ | ||
783 | #define R_DRAWSPAN_PIPELINE_BITS 15 | ||
784 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_DITHERZ) | ||
785 | #include "r_drawspan.inl" | ||
786 | |||
787 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan15_LinearUV_PointZ | ||
788 | #define R_DRAWSPAN_PIPELINE_BITS 15 | ||
789 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_BILINEAR) | ||
790 | #include "r_drawspan.inl" | ||
791 | |||
792 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan15_LinearUV_LinearZ | ||
793 | #define R_DRAWSPAN_PIPELINE_BITS 15 | ||
794 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_BILINEAR | RDC_DITHERZ) | ||
795 | #include "r_drawspan.inl" | ||
796 | |||
797 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan15_RoundedUV_PointZ | ||
798 | #define R_DRAWSPAN_PIPELINE_BITS 15 | ||
799 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_ROUNDED) | ||
800 | #include "r_drawspan.inl" | ||
801 | |||
802 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan15_RoundedUV_LinearZ | ||
803 | #define R_DRAWSPAN_PIPELINE_BITS 15 | ||
804 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_ROUNDED | RDC_DITHERZ) | ||
805 | #include "r_drawspan.inl" | ||
806 | |||
807 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan16_PointUV_PointZ | ||
808 | #define R_DRAWSPAN_PIPELINE_BITS 16 | ||
809 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD) | ||
810 | #include "r_drawspan.inl" | ||
811 | |||
812 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan16_PointUV_LinearZ | ||
813 | #define R_DRAWSPAN_PIPELINE_BITS 16 | ||
814 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_DITHERZ) | ||
815 | #include "r_drawspan.inl" | ||
816 | |||
817 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan16_LinearUV_PointZ | ||
818 | #define R_DRAWSPAN_PIPELINE_BITS 16 | ||
819 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_BILINEAR) | ||
820 | #include "r_drawspan.inl" | ||
821 | |||
822 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan16_LinearUV_LinearZ | ||
823 | #define R_DRAWSPAN_PIPELINE_BITS 16 | ||
824 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_BILINEAR | RDC_DITHERZ) | ||
825 | #include "r_drawspan.inl" | ||
826 | |||
827 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan16_RoundedUV_PointZ | ||
828 | #define R_DRAWSPAN_PIPELINE_BITS 16 | ||
829 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_ROUNDED) | ||
830 | #include "r_drawspan.inl" | ||
831 | |||
832 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan16_RoundedUV_LinearZ | ||
833 | #define R_DRAWSPAN_PIPELINE_BITS 16 | ||
834 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_ROUNDED | RDC_DITHERZ) | ||
835 | #include "r_drawspan.inl" | ||
836 | |||
837 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan32_PointUV_PointZ | ||
838 | #define R_DRAWSPAN_PIPELINE_BITS 32 | ||
839 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD) | ||
840 | #include "r_drawspan.inl" | ||
841 | |||
842 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan32_PointUV_LinearZ | ||
843 | #define R_DRAWSPAN_PIPELINE_BITS 32 | ||
844 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_DITHERZ) | ||
845 | #include "r_drawspan.inl" | ||
846 | |||
847 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan32_LinearUV_PointZ | ||
848 | #define R_DRAWSPAN_PIPELINE_BITS 32 | ||
849 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_BILINEAR) | ||
850 | #include "r_drawspan.inl" | ||
851 | |||
852 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan32_LinearUV_LinearZ | ||
853 | #define R_DRAWSPAN_PIPELINE_BITS 32 | ||
854 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_BILINEAR | RDC_DITHERZ) | ||
855 | #include "r_drawspan.inl" | ||
856 | |||
857 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan32_RoundedUV_PointZ | ||
858 | #define R_DRAWSPAN_PIPELINE_BITS 32 | ||
859 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_ROUNDED) | ||
860 | #include "r_drawspan.inl" | ||
861 | |||
862 | #define R_DRAWSPAN_FUNCNAME R_DrawSpan32_RoundedUV_LinearZ | ||
863 | #define R_DRAWSPAN_PIPELINE_BITS 32 | ||
864 | #define R_DRAWSPAN_PIPELINE (RDC_STANDARD | RDC_ROUNDED | RDC_DITHERZ) | ||
865 | #include "r_drawspan.inl" | ||
866 | |||
867 | static R_DrawSpan_f drawspanfuncs[VID_MODEMAX][RDRAW_FILTER_MAXFILTERS][RDRAW_FILTER_MAXFILTERS] = { | ||
868 | { | ||
869 | { | ||
870 | NULL, | ||
871 | NULL, | ||
872 | NULL, | ||
873 | NULL, | ||
874 | }, | ||
875 | { | ||
876 | NULL, | ||
877 | R_DrawSpan8_PointUV_PointZ, | ||
878 | R_DrawSpan8_LinearUV_PointZ, | ||
879 | R_DrawSpan8_RoundedUV_PointZ, | ||
880 | }, | ||
881 | { | ||
882 | NULL, | ||
883 | R_DrawSpan8_PointUV_LinearZ, | ||
884 | R_DrawSpan8_LinearUV_LinearZ, | ||
885 | R_DrawSpan8_RoundedUV_LinearZ, | ||
886 | }, | ||
887 | { | ||
888 | NULL, | ||
889 | NULL, | ||
890 | NULL, | ||
891 | NULL, | ||
892 | }, | ||
893 | }, | ||
894 | { | ||
895 | { | ||
896 | NULL, | ||
897 | NULL, | ||
898 | NULL, | ||
899 | NULL, | ||
900 | }, | ||
901 | { | ||
902 | NULL, | ||
903 | R_DrawSpan15_PointUV_PointZ, | ||
904 | R_DrawSpan15_LinearUV_PointZ, | ||
905 | R_DrawSpan15_RoundedUV_PointZ, | ||
906 | }, | ||
907 | { | ||
908 | NULL, | ||
909 | R_DrawSpan15_PointUV_LinearZ, | ||
910 | R_DrawSpan15_LinearUV_LinearZ, | ||
911 | R_DrawSpan15_RoundedUV_LinearZ, | ||
912 | }, | ||
913 | { | ||
914 | NULL, | ||
915 | NULL, | ||
916 | NULL, | ||
917 | NULL, | ||
918 | }, | ||
919 | }, | ||
920 | { | ||
921 | { | ||
922 | NULL, | ||
923 | NULL, | ||
924 | NULL, | ||
925 | NULL, | ||
926 | }, | ||
927 | { | ||
928 | NULL, | ||
929 | R_DrawSpan16_PointUV_PointZ, | ||
930 | R_DrawSpan16_LinearUV_PointZ, | ||
931 | R_DrawSpan16_RoundedUV_PointZ, | ||
932 | }, | ||
933 | { | ||
934 | NULL, | ||
935 | R_DrawSpan16_PointUV_LinearZ, | ||
936 | R_DrawSpan16_LinearUV_LinearZ, | ||
937 | R_DrawSpan16_RoundedUV_LinearZ, | ||
938 | }, | ||
939 | { | ||
940 | NULL, | ||
941 | NULL, | ||
942 | NULL, | ||
943 | NULL, | ||
944 | }, | ||
945 | }, | ||
946 | { | ||
947 | { | ||
948 | NULL, | ||
949 | NULL, | ||
950 | NULL, | ||
951 | NULL, | ||
952 | }, | ||
953 | { | ||
954 | NULL, | ||
955 | R_DrawSpan32_PointUV_PointZ, | ||
956 | R_DrawSpan32_LinearUV_PointZ, | ||
957 | R_DrawSpan32_RoundedUV_PointZ, | ||
958 | }, | ||
959 | { | ||
960 | NULL, | ||
961 | R_DrawSpan32_PointUV_LinearZ, | ||
962 | R_DrawSpan32_LinearUV_LinearZ, | ||
963 | R_DrawSpan32_RoundedUV_LinearZ, | ||
964 | }, | ||
965 | { | ||
966 | NULL, | ||
967 | NULL, | ||
968 | NULL, | ||
969 | NULL, | ||
970 | }, | ||
971 | }, | ||
972 | }; | ||
973 | |||
974 | R_DrawSpan_f R_GetDrawSpanFunc(enum draw_filter_type_e filter, | ||
975 | enum draw_filter_type_e filterz) { | ||
976 | R_DrawSpan_f result = drawspanfuncs[V_GetMode()][filterz][filter]; | ||
977 | if (result == NULL) | ||
978 | I_Error("R_GetDrawSpanFunc: undefined function (%d, %d)", | ||
979 | filter, filterz); | ||
980 | return result; | ||
981 | } | ||
982 | |||
983 | void R_DrawSpan(draw_span_vars_t *dsvars) { | ||
984 | R_GetDrawSpanFunc(drawvars.filterfloor, drawvars.filterz)(dsvars); | ||
985 | } | ||
986 | |||
987 | // | ||
988 | // R_InitBuffer | ||
989 | // Creats lookup tables that avoid | ||
990 | // multiplies and other hazzles | ||
991 | // for getting the framebuffer address | ||
992 | // of a pixel to draw. | ||
993 | // | ||
994 | |||
995 | void R_InitBuffer(int width, int height) | ||
996 | { | ||
997 | int i=0; | ||
998 | // Handle resize, | ||
999 | // e.g. smaller view windows | ||
1000 | // with border and/or status bar. | ||
1001 | |||
1002 | viewwindowx = (SCREENWIDTH-width) >> 1; | ||
1003 | |||
1004 | // Same with base row offset. | ||
1005 | |||
1006 | viewwindowy = width==SCREENWIDTH ? 0 : (SCREENHEIGHT-(ST_SCALED_HEIGHT-1)-height)>>1; | ||
1007 | |||
1008 | drawvars.byte_topleft = screens[0].data + viewwindowy*screens[0].byte_pitch + viewwindowx; | ||
1009 | drawvars.short_topleft = (unsigned short *)(screens[0].data) + viewwindowy*screens[0].short_pitch + viewwindowx; | ||
1010 | drawvars.int_topleft = (unsigned int *)(screens[0].data) + viewwindowy*screens[0].int_pitch + viewwindowx; | ||
1011 | drawvars.byte_pitch = screens[0].byte_pitch; | ||
1012 | drawvars.short_pitch = screens[0].short_pitch; | ||
1013 | drawvars.int_pitch = screens[0].int_pitch; | ||
1014 | |||
1015 | if (V_GetMode() == VID_MODE8) { | ||
1016 | for (i=0; i<FUZZTABLE; i++) | ||
1017 | fuzzoffset[i] = fuzzoffset_org[i]*screens[0].byte_pitch; | ||
1018 | } else if ((V_GetMode() == VID_MODE15) || (V_GetMode() == VID_MODE16)) { | ||
1019 | for (i=0; i<FUZZTABLE; i++) | ||
1020 | fuzzoffset[i] = fuzzoffset_org[i]*screens[0].short_pitch; | ||
1021 | } else if (V_GetMode() == VID_MODE32) { | ||
1022 | for (i=0; i<FUZZTABLE; i++) | ||
1023 | fuzzoffset[i] = fuzzoffset_org[i]*screens[0].int_pitch; | ||
1024 | } | ||
1025 | } | ||
1026 | |||
1027 | // | ||
1028 | // R_FillBackScreen | ||
1029 | // Fills the back screen with a pattern | ||
1030 | // for variable screen sizes | ||
1031 | // Also draws a beveled edge. | ||
1032 | // | ||
1033 | // CPhipps - patch drawing updated | ||
1034 | |||
1035 | void R_FillBackScreen (void) | ||
1036 | { | ||
1037 | int x,y; | ||
1038 | |||
1039 | if (scaledviewwidth == SCREENWIDTH) | ||
1040 | return; | ||
1041 | |||
1042 | V_DrawBackground(gamemode == commercial ? "GRNROCK" : "FLOOR7_2", 1); | ||
1043 | |||
1044 | for (x=0; x<scaledviewwidth; x+=8) | ||
1045 | V_DrawNamePatch(viewwindowx+x,viewwindowy-8,1,"brdr_t", CR_DEFAULT, VPT_NONE); | ||
1046 | |||
1047 | for (x=0; x<scaledviewwidth; x+=8) | ||
1048 | V_DrawNamePatch(viewwindowx+x,viewwindowy+viewheight,1,"brdr_b", CR_DEFAULT, VPT_NONE); | ||
1049 | |||
1050 | for (y=0; y<viewheight; y+=8) | ||
1051 | V_DrawNamePatch(viewwindowx-8,viewwindowy+y,1,"brdr_l", CR_DEFAULT, VPT_NONE); | ||
1052 | |||
1053 | for (y=0; y<viewheight; y+=8) | ||
1054 | V_DrawNamePatch(viewwindowx+scaledviewwidth,viewwindowy+y,1,"brdr_r", CR_DEFAULT, VPT_NONE); | ||
1055 | |||
1056 | // Draw beveled edge. | ||
1057 | V_DrawNamePatch(viewwindowx-8,viewwindowy-8,1,"brdr_tl", CR_DEFAULT, VPT_NONE); | ||
1058 | |||
1059 | V_DrawNamePatch(viewwindowx+scaledviewwidth,viewwindowy-8,1,"brdr_tr", CR_DEFAULT, VPT_NONE); | ||
1060 | |||
1061 | V_DrawNamePatch(viewwindowx-8,viewwindowy+viewheight,1,"brdr_bl", CR_DEFAULT, VPT_NONE); | ||
1062 | |||
1063 | V_DrawNamePatch(viewwindowx+scaledviewwidth,viewwindowy+viewheight,1,"brdr_br", CR_DEFAULT, VPT_NONE); | ||
1064 | } | ||
1065 | |||
1066 | // | ||
1067 | // Copy a screen buffer. | ||
1068 | // | ||
1069 | |||
1070 | void R_VideoErase(int x, int y, int count) | ||
1071 | { | ||
1072 | if (V_GetMode() != VID_MODEGL) | ||
1073 | memcpy(screens[0].data+y*screens[0].byte_pitch+x*V_GetPixelDepth(), | ||
1074 | screens[1].data+y*screens[1].byte_pitch+x*V_GetPixelDepth(), | ||
1075 | count*V_GetPixelDepth()); // LFB copy. | ||
1076 | } | ||
1077 | |||
1078 | // | ||
1079 | // R_DrawViewBorder | ||
1080 | // Draws the border around the view | ||
1081 | // for different size windows? | ||
1082 | // | ||
1083 | |||
1084 | void R_DrawViewBorder(void) | ||
1085 | { | ||
1086 | int top, side, i; | ||
1087 | |||
1088 | if (V_GetMode() == VID_MODEGL) { | ||
1089 | // proff 11/99: we don't have a backscreen in OpenGL from where we can copy this | ||
1090 | R_FillBackScreen(); | ||
1091 | return; | ||
1092 | } | ||
1093 | |||
1094 | if ((SCREENHEIGHT != viewheight) || | ||
1095 | ((automapmode & am_active) && ! (automapmode & am_overlay))) | ||
1096 | { | ||
1097 | // erase left and right of statusbar | ||
1098 | side= ( SCREENWIDTH - ST_SCALED_WIDTH ) / 2; | ||
1099 | |||
1100 | if (side > 0) { | ||
1101 | for (i = (SCREENHEIGHT - ST_SCALED_HEIGHT); i < SCREENHEIGHT; i++) | ||
1102 | { | ||
1103 | R_VideoErase (0, i, side); | ||
1104 | R_VideoErase (ST_SCALED_WIDTH+side, i, side); | ||
1105 | } | ||
1106 | } | ||
1107 | } | ||
1108 | |||
1109 | if ( viewheight >= ( SCREENHEIGHT - ST_SCALED_HEIGHT )) | ||
1110 | return; // if high-res, donīt go any further! | ||
1111 | |||
1112 | top = ((SCREENHEIGHT-ST_SCALED_HEIGHT)-viewheight)/2; | ||
1113 | side = (SCREENWIDTH-scaledviewwidth)/2; | ||
1114 | |||
1115 | // copy top | ||
1116 | for (i = 0; i < top; i++) | ||
1117 | R_VideoErase (0, i, SCREENWIDTH); | ||
1118 | |||
1119 | // copy sides | ||
1120 | for (i = top; i < (top+viewheight); i++) { | ||
1121 | R_VideoErase (0, i, side); | ||
1122 | R_VideoErase (viewwidth+side, i, side); | ||
1123 | } | ||
1124 | |||
1125 | // copy bottom | ||
1126 | for (i = top+viewheight; i < (SCREENHEIGHT - ST_SCALED_HEIGHT); i++) | ||
1127 | R_VideoErase (0, i, SCREENWIDTH); | ||
1128 | } | ||