Debian Codegraph @

prboom2/src/r_drawcolumn.inl

raw
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 & RDC_TRANSLATED)
32 #define GETCOL_MAPPED(col) (translation[(col)])
33 #else
34 #define GETCOL_MAPPED(col) (col)
35 #endif
36
37 #if (R_DRAWCOLUMN_PIPELINE & RDC_NOCOLMAP)
38 #define GETCOL_DEPTH(col) GETCOL_MAPPED(col)
39 #else
40 #define GETCOL_DEPTH(col) colormap[GETCOL_MAPPED(col)]
41 #endif
42
43 #define GETCOL(frac) GETCOL_DEPTH(source[(frac)>>FRACBITS])
44
45 #if (R_DRAWCOLUMN_PIPELINE & RDC_TRANSLUCENT)
46 #define COLTYPE (COL_TRANS)
47 #elif (R_DRAWCOLUMN_PIPELINE & RDC_FUZZ)
48 #define COLTYPE (COL_FUZZ)
49 #else
50 #define COLTYPE (COL_OPAQUE)
51 #endif
52
53 static void R_DRAWCOLUMN_FUNCNAME(draw_column_vars_t *dcvars)
54 {
55 int count;
56
57 #if (!(R_DRAWCOLUMN_PIPELINE & RDC_FUZZ))
58 byte *dest; // killough
59 fixed_t frac;
60 const fixed_t fracstep = dcvars->iscale;
61 #endif
62
63 #if (R_DRAWCOLUMN_PIPELINE & RDC_FUZZ)
64 // Adjust borders. Low...
65 if (!dcvars->yl)
66 dcvars->yl = 1;
67
68 // .. and high.
69 if (dcvars->yh == viewheight-1)
70 dcvars->yh = viewheight - 2;
71 #endif
72
73 // leban 1/17/99:
74 // removed the + 1 here, adjusted the if test, and added an increment
75 // later. this helps a compiler pipeline a bit better. the x86
76 // assembler also does this.
77
78 count = dcvars->yh - dcvars->yl;
79
80 // leban 1/17/99:
81 // this case isn't executed too often. depending on how many instructions
82 // there are between here and the second if test below, this case could
83 // be moved down and might save instructions overall. since there are
84 // probably different wads that favor one way or the other, i'll leave
85 // this alone for now.
86 if (count < 0) // Zero length, column does not exceed a pixel.
87 return;
88
89 #ifdef RANGECHECK
90 if (dcvars->x >= SCREENWIDTH
91 || dcvars->yl < 0
92 || dcvars->yh >= SCREENHEIGHT)
93 I_Error("R_DrawColumn: %i to %i at %i", dcvars->yl, dcvars->yh, dcvars->x);
94 #endif
95
96 #if (!(R_DRAWCOLUMN_PIPELINE & RDC_FUZZ))
97 if (dcvars->flags & DRAW_COLUMN_ISPATCH)
98 frac = ((dcvars->yl - dcvars->dy) * fracstep) & 0xFFFF;
99 else
100 frac = dcvars->texturemid + (dcvars->yl-centery)*fracstep;
101 #endif
102
103 // Framebuffer destination address.
104 // SoM: MAGIC
105 {
106 // haleyjd: reordered predicates
107 if(temp_x == 4 ||
108 (temp_x && (temptype != COLTYPE || temp_x + startx != dcvars->x)))
109 R_FlushColumns();
110
111 if(!temp_x)
112 {
113 startx = dcvars->x;
114 tempyl[0] = commontop = dcvars->yl;
115 tempyh[0] = commonbot = dcvars->yh;
116 temptype = COLTYPE;
117 #if (R_DRAWCOLUMN_PIPELINE & RDC_TRANSLUCENT)
118 temptranmap = tranmap;
119 #elif (R_DRAWCOLUMN_PIPELINE & RDC_FUZZ)
120 tempfuzzmap = fullcolormap; // SoM 7-28-04: Fix the fuzz problem.
121 #endif
122 R_FlushWholeColumns = R_FLUSHWHOLE_FUNCNAME;
123 R_FlushHTColumns = R_FLUSHHEADTAIL_FUNCNAME;
124 R_FlushQuadColumn = R_FLUSHQUAD_FUNCNAME;
125 #if (!(R_DRAWCOLUMN_PIPELINE & RDC_FUZZ))
126 dest = &tempbuf[dcvars->yl << 2];
127 #endif
128 } else {
129 tempyl[temp_x] = dcvars->yl;
130 tempyh[temp_x] = dcvars->yh;
131
132 if(dcvars->yl > commontop)
133 commontop = dcvars->yl;
134 if(dcvars->yh < commonbot)
135 commonbot = dcvars->yh;
136 #if (!(R_DRAWCOLUMN_PIPELINE & RDC_FUZZ))
137 dest = &tempbuf[(dcvars->yl << 2) + temp_x];
138 #endif
139 }
140 temp_x += 1;
141 }
142
143 // do nothing else when drawin fuzz columns
144 #if (!(R_DRAWCOLUMN_PIPELINE & RDC_FUZZ))
145 {
146 const byte *source = dcvars->source;
147
148 #if (!(R_DRAWCOLUMN_PIPELINE & RDC_NOCOLMAP))
149 const lighttable_t *colormap = dcvars->colormap;
150 #endif
151
152 #if (R_DRAWCOLUMN_PIPELINE & RDC_TRANSLATED)
153 const byte *translation = dcvars->translation;
154 #endif
155
156 count++;
157
158 // Inner loop that does the actual texture mapping,
159 // e.g. a DDA-lile scaling.
160 // This is as fast as it gets. (Yeah, right!!! -- killough)
161 //
162 // killough 2/1/98: more performance tuning
163
164 if (dcvars->texheight == 128) {
165 #define FIXEDT_128MASK ((127<<FRACBITS)|0xffff)
166 while(count--) {
167 *dest = GETCOL(frac & FIXEDT_128MASK);
168 dest += 4;
169 frac += fracstep;
170 }
171 } else if (dcvars->texheight == 0) {
172 /* cph - another special case */
173 while (count--) {
174 *dest = GETCOL(frac);
175 dest += 4;
176 frac += fracstep;
177 }
178 } else {
179 unsigned heightmask = dcvars->texheight-1; // CPhipps - specify type
180 if (! (dcvars->texheight & heightmask) ) { // power of 2 -- killough
181 fixed_t fixedt_heightmask = (heightmask<<FRACBITS)|0xffff;
182 while ((count-=2)>=0) { // texture height is a power of 2 -- killough
183 *dest = GETCOL(frac & fixedt_heightmask);
184 dest += 4;
185 frac += fracstep;
186 *dest = GETCOL(frac & fixedt_heightmask);
187 dest += 4;
188 frac += fracstep;
189 }
190 if (count & 1)
191 *dest = GETCOL(frac & fixedt_heightmask);
192 } else {
193 heightmask++;
194 heightmask <<= FRACBITS;
195
196 if (frac < 0)
197 while ((frac += heightmask) < 0);
198 else
199 while (frac >= (int)heightmask)
200 frac -= heightmask;
201
202 while (count--) {
203 // Re-map color indices from wall texture column
204 // using a lighting/special effects LUT.
205
206 // heightmask is the Tutti-Frutti fix -- killough
207
208 *dest = GETCOL(frac);
209 dest += 4;
210 if ((frac += fracstep) >= (int)heightmask)
211 frac -= heightmask;
212 }
213 }
214 }
215 }
216 #endif // (!(R_DRAWCOLUMN_PIPELINE & RDC_FUZZ))
217 }
218
219 #undef GETCOL_MAPPED
220 #undef GETCOL_DEPTH
221 #undef GETCOL
222 #undef COLTYPE
223 #undef R_DRAWCOLUMN_FUNCNAME
224 #undef R_DRAWCOLUMN_PIPELINE