vkQuake2 doxygen  1.0 dev
r_polyse.c
Go to the documentation of this file.
1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 */
20 // d_polyset.c: routines for drawing sets of polygons sharing the same
21 // texture (used for Alias models)
22 
23 #include "r_local.h"
24 
25 int rand1k[] = {
26 #include "rand1k.h"
27 };
28 
29 #define MASK_1K 0x3FF
30 
31 int rand1k_index = 0;
32 
33 // TODO: put in span spilling to shrink list size
34 // !!! if this is changed, it must be changed in d_polysa.s too !!!
35 #define DPS_MAXSPANS MAXHEIGHT+1
36 // 1 extra for spanpackage that marks end
37 
38 // !!! if this is changed, it must be changed in asm_draw.h too !!!
39 typedef struct {
40  void *pdest;
41  short *pz;
42  int count;
43  byte *ptex;
44  int sfrac, tfrac, light, zi;
45 #ifdef COLMODEL
46  int lightr, lightg, lightb; // leilei - colored lighting
47 #endif
49 
50 typedef struct {
51  int isflattop;
60 } edgetable;
61 
63 
64 int r_p0[9], r_p1[9], r_p2[9];
65 
67 
70 
72 
74  { 0, 1, r_p0, r_p2, NULL, 2, r_p0, r_p1, r_p2 },
75  { 0, 2, r_p1, r_p0, r_p2, 1, r_p1, r_p2, NULL },
76  { 1, 1, r_p0, r_p2, NULL, 1, r_p1, r_p2, NULL },
77  { 0, 1, r_p1, r_p0, NULL, 2, r_p1, r_p2, r_p0 },
78  { 0, 2, r_p0, r_p2, r_p1, 1, r_p0, r_p1, NULL },
79  { 0, 1, r_p2, r_p1, NULL, 1, r_p2, r_p0, NULL },
80  { 0, 1, r_p2, r_p1, NULL, 2, r_p2, r_p0, r_p1 },
81  { 0, 2, r_p2, r_p1, r_p0, 1, r_p2, r_p0, NULL },
82  { 0, 1, r_p1, r_p0, NULL, 1, r_p1, r_p2, NULL },
83  { 1, 1, r_p2, r_p1, NULL, 1, r_p0, r_p1, NULL },
84  { 1, 1, r_p1, r_p0, NULL, 1, r_p2, r_p0, NULL },
85  { 0, 1, r_p0, r_p2, NULL, 1, r_p0, r_p1, NULL },
86 };
87 
88 // FIXME: some of these can become statics
96 
99 static int ystart;
100 byte *d_pdest, *d_ptex;
101 short *d_pz;
109 
110 // leilei - colored lighting
111 
115 
116 
117 typedef struct {
118  int quotient;
120 } adivtab_t;
121 
122 static adivtab_t adivtab[32 * 32] = {
123 #include "adivtab.h"
124 };
125 
128 byte *skinstart;
129 
130 void(*d_pdrawspans)(spanpackage_t *pspanpackage);
131 
132 void R_PolysetDrawSpans8_33(spanpackage_t *pspanpackage);
133 void R_PolysetDrawSpans8_66(spanpackage_t *pspanpackage);
134 //void R_PolysetDrawSpans8_Opaque(spanpackage_t *pspanpackage);
136 
137 void R_PolysetDrawThreshSpans8(spanpackage_t *pspanpackage);
139 void R_DrawNonSubdiv(void);
140 void R_PolysetSetEdgeTable(void);
141 void R_RasterizeAliasPolySmooth(void);
142 void R_PolysetScanLeftEdge(int height);
144 
145 // ======================
146 // PGM
147 // 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
148 byte iractive = 0;
149 byte irtable[256] = { 79, 78, 77, 76, 75, 74, 73, 72, // black/white
150 71, 70, 69, 68, 67, 66, 65, 64,
151 64, 65, 66, 67, 68, 69, 70, 71, // dark taupe
152 72, 73, 74, 75, 76, 77, 78, 79,
153 
154 64, 65, 66, 67, 68, 69, 70, 71, // slate grey
155 72, 73, 74, 75, 76, 77, 78, 79,
156 208, 208, 208, 208, 208, 208, 208, 208, // unused?'
157 64, 66, 68, 70, 72, 74, 76, 78, // dark yellow
158 
159 64, 65, 66, 67, 68, 69, 70, 71, // dark red
160 72, 73, 74, 75, 76, 77, 78, 79,
161 64, 65, 66, 67, 68, 69, 70, 71, // grey/tan
162 72, 73, 74, 75, 76, 77, 78, 79,
163 
164 64, 66, 68, 70, 72, 74, 76, 78, // chocolate
165 68, 67, 66, 65, 64, 65, 66, 67, // mauve / teal
166 68, 69, 70, 71, 72, 73, 74, 75,
167 76, 76, 77, 77, 78, 78, 79, 79,
168 
169 64, 65, 66, 67, 68, 69, 70, 71, // more mauve
170 72, 73, 74, 75, 76, 77, 78, 79,
171 64, 65, 66, 67, 68, 69, 70, 71, // olive
172 72, 73, 74, 75, 76, 77, 78, 79,
173 
174 64, 65, 66, 67, 68, 69, 70, 71, // maroon
175 72, 73, 74, 75, 76, 77, 78, 79,
176 64, 65, 66, 67, 68, 69, 70, 71, // sky blue
177 72, 73, 74, 75, 76, 77, 78, 79,
178 
179 64, 65, 66, 67, 68, 69, 70, 71, // olive again
180 72, 73, 74, 75, 76, 77, 78, 79,
181 64, 65, 66, 67, 68, 69, 70, 71, // nuclear green
182 64, 65, 66, 67, 68, 69, 70, 71, // bright yellow
183 
184 64, 65, 66, 67, 68, 69, 70, 71, // fire colors
185 72, 73, 74, 75, 76, 77, 78, 79,
186 208, 208, 64, 64, 70, 71, 72, 64, // mishmash1
187 66, 68, 70, 64, 65, 66, 67, 68 }; // mishmash2
188 // PGM
189 // ======================
190 
191 /*
192 ================
193 R_PolysetUpdateTables
194 ================
195 */
197 {
198  int i;
199  byte *s;
200 
203  {
206  s = skinstart;
207  for (i = 0; i < MAX_LBM_HEIGHT; i++, s += skinwidth)
208  skintable[i] = s;
209  }
210 }
211 
212 
213 /*
214 ================
215 R_DrawTriangle
216 ================
217 */
218 void R_DrawTriangle(void)
219 {
221 
222  int dv1_ab, dv0_ac;
223  int dv0_ab, dv1_ac;
224 
225  /*
226  d_xdenom = ( aliastriangleparms.a->v[1] - aliastriangleparms.b->v[1] ) * ( aliastriangleparms.a->v[0] - aliastriangleparms.c->v[0] ) -
227  ( aliastriangleparms.a->v[0] - aliastriangleparms.b->v[0] ) * ( aliastriangleparms.a->v[1] - aliastriangleparms.c->v[1] );
228  */
229 
232 
233  if (!(dv0_ab | dv1_ab))
234  return;
235 
238 
239  if (!(dv0_ac | dv1_ac))
240  return;
241 
242  d_xdenom = (dv0_ac * dv1_ab) - (dv0_ab * dv1_ac);
243 
244  if (d_xdenom < 0)
245  {
246  a_spans = spans;
247 
248  r_p0[0] = aliastriangleparms.a->u; // u
249  r_p0[1] = aliastriangleparms.a->v; // v
250  r_p0[2] = aliastriangleparms.a->s; // s
251  r_p0[3] = aliastriangleparms.a->t; // t
252  r_p0[4] = aliastriangleparms.a->l; // light
253  r_p0[5] = aliastriangleparms.a->zi; // iz
254 
255  r_p1[0] = aliastriangleparms.b->u;
256  r_p1[1] = aliastriangleparms.b->v;
257  r_p1[2] = aliastriangleparms.b->s;
258  r_p1[3] = aliastriangleparms.b->t;
259  r_p1[4] = aliastriangleparms.b->l;
260  r_p1[5] = aliastriangleparms.b->zi;
261 
262  r_p2[0] = aliastriangleparms.c->u;
263  r_p2[1] = aliastriangleparms.c->v;
264  r_p2[2] = aliastriangleparms.c->s;
265  r_p2[3] = aliastriangleparms.c->t;
266  r_p2[4] = aliastriangleparms.c->l;
267  r_p2[5] = aliastriangleparms.c->zi;
268 
269  // i crash fixme //...qb: increased array sizes
270  r_p0[6] = aliastriangleparms.a->l; // lightr
271  r_p0[7] = aliastriangleparms.a->l; // lightg
272  r_p0[8] = aliastriangleparms.a->l; // lightb
273  r_p1[6] = aliastriangleparms.b->l; // lightr
274  r_p1[7] = aliastriangleparms.b->l; // lightg
275  r_p1[8] = aliastriangleparms.b->l; // lightb
276  r_p2[6] = aliastriangleparms.c->l; // lightr
277  r_p2[7] = aliastriangleparms.c->l; // lightg
278  r_p2[8] = aliastriangleparms.c->l; // lightb
279 
282  }
283 }
284 
285 
286 /*
287 ===================
288 R_PolysetScanLeftEdge_C
289 ====================
290 */
292 {
293  do
294  {
299 
302 
303  // FIXME: need to clamp l, s, t, at both ends?
305 #ifdef COLMODEL
309 #endif
311 
313 
315  if (errorterm >= 0)
316  {
318  d_pz += d_pzextrastep;
322  d_ptex += d_sfrac >> 16;
323 
324  d_sfrac &= 0xFFFF;
326  if (d_tfrac & 0x10000)
327  {
329  d_tfrac &= 0xFFFF;
330  }
332  d_zi += d_ziextrastep;
334 #ifdef COLMODEL
338 #endif
339  }
340  else
341  {
343  d_pz += d_pzbasestep;
347  d_ptex += d_sfrac >> 16;
348  d_sfrac &= 0xFFFF;
350  if (d_tfrac & 0x10000)
351  {
353  d_tfrac &= 0xFFFF;
354  }
356 #ifdef COLMODEL
360 #endif
361  d_zi += d_zibasestep;
362  }
363  } while (--height);
364 }
365 
366 /*
367 ===================
368 FloorDivMod
369 
370 Returns mathematically correct (floor-based) quotient and remainder for
371 numer and denom, both of which should contain no fractional part. The
372 quotient must fit in 32 bits.
373 FIXME: GET RID OF THIS! (FloorDivMod)
374 ====================
375 */
376 void FloorDivMod(float numer, float denom, int *quotient, int *rem)
377 {
378  int q, r;
379  float x;
380 
381  if (numer >= 0.0)
382  {
383 
384  x = floor(numer / denom);
385  q = (int)x;
386  r = (int)floor(numer - (x * denom));
387  }
388  else
389  {
390  //
391  // perform operations with positive values, and fix mod to make floor-based
392  //
393  x = floor(-numer / denom);
394  q = -(int)x;
395  r = (int)floor(-numer - (x * denom));
396  if (r != 0)
397  {
398  q--;
399  r = (int)denom - r;
400  }
401  }
402 
403  *quotient = q;
404  *rem = r;
405 }
406 
407 
408 /*
409 ===================
410 R_PolysetSetUpForLineScan
411 ====================
412 */
413 void R_PolysetSetUpForLineScan(fixed8_t startvertu, fixed8_t startvertv,
414  fixed8_t endvertu, fixed8_t endvertv)
415 {
416  float dm, dn;
417  int tm, tn;
418  adivtab_t *ptemp;
419 
420  // TODO: implement x86 version
421 
422  errorterm = -1;
423 
424  tm = endvertu - startvertu;
425  tn = endvertv - startvertv;
426 
427  if (((tm <= 16) && (tm >= -15)) &&
428  ((tn <= 16) && (tn >= -15)))
429  {
430  ptemp = &adivtab[((tm + 15) << 5) + (tn + 15)];
431  ubasestep = ptemp->quotient;
432  erroradjustup = ptemp->remainder;
433  erroradjustdown = tn;
434  }
435  else
436  {
437  dm = tm;
438  dn = tn;
439 
440  FloorDivMod(dm, dn, &ubasestep, &erroradjustup);
441 
442  erroradjustdown = dn;
443  }
444 }
445 
446 
447 
448 /*
449 ================
450 R_PolysetCalcGradients
451 ================
452 */
453 //qb: from Frank Sapone
454 #if id386 && !defined __linux__ && !defined __FreeBSD__
456 {
457  static float xstepdenominv, ystepdenominv, t0, t1;
458  static float p01_minus_p21, p11_minus_p21, p00_minus_p20, p10_minus_p20;
459  static float one = 1.0F, negative_one = -1.0F;
460  static unsigned long t0_int, t1_int;
461 
462  extern unsigned long fpu_sp24_ceil_cw, fpu_ceil_cw, fpu_chop_cw;
463 
464  /*
465  p00_minus_p20 = r_p0[0] - r_p2[0];
466  p01_minus_p21 = r_p0[1] - r_p2[1];
467  p10_minus_p20 = r_p1[0] - r_p2[0];
468  p11_minus_p21 = r_p1[1] - r_p2[1];
469  */
470 
471  __asm mov eax, dword ptr[r_p0 + 0]
472  __asm mov ebx, dword ptr[r_p0 + 4]
473  __asm sub eax, dword ptr[r_p2 + 0]
474  __asm sub ebx, dword ptr[r_p2 + 4]
475  __asm mov p00_minus_p20, eax
476  __asm mov p01_minus_p21, ebx
477  __asm fild dword ptr p00_minus_p20
478  __asm fild dword ptr p01_minus_p21
479  __asm mov eax, dword ptr[r_p1 + 0]
480  __asm mov ebx, dword ptr[r_p1 + 4]
481  __asm sub eax, dword ptr[r_p2 + 0]
482  __asm sub ebx, dword ptr[r_p2 + 4]
483  __asm fstp p01_minus_p21
484  __asm fstp p00_minus_p20
485  __asm mov p10_minus_p20, eax
486  __asm mov p11_minus_p21, ebx
487  __asm fild dword ptr p10_minus_p20
488  __asm fild dword ptr p11_minus_p21
489  __asm fstp p11_minus_p21
490  __asm fstp p10_minus_p20
491 
492  /*
493  xstepdenominv = 1.0 / (float)d_xdenom;
494 
495  ystepdenominv = -xstepdenominv;
496  */
497 
498  /*
499  ** put FPU in single precision ceil mode
500  */
501  __asm fldcw word ptr[fpu_sp24_ceil_cw]
502  // __asm fldcw word ptr [fpu_ceil_cw]
503 
504  __asm fild dword ptr d_xdenom; d_xdenom
505  __asm fdivr one; 1 / d_xdenom
506  __asm fst xstepdenominv;
507  __asm fmul negative_one; -(1 / d_xdenom)
508 
509  // ceil () for light so positive steps are exaggerated, negative steps
510  // diminished, pushing us away from underflow toward overflow. Underflow is
511  // very visible, overflow is very unlikely, because of ambient lighting
512  /*
513  t0 = r_p0[4] - r_p2[4];
514  t1 = r_p1[4] - r_p2[4];
515  r_lstepx = (int)
516  ceil((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
517  r_lstepy = (int)
518  ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
519  */
520  __asm mov eax, dword ptr[r_p0 + 16]
521  __asm mov ebx, dword ptr[r_p1 + 16]
522  __asm sub eax, dword ptr[r_p2 + 16]
523  __asm sub ebx, dword ptr[r_p2 + 16]
524 
525  __asm fstp ystepdenominv; (empty)
526 
527  __asm mov t0_int, eax
528  __asm mov t1_int, ebx
529  __asm fild t0_int; t0
530  __asm fild t1_int; t1 | t0
531  __asm fxch st(1); t0 | t1
532  __asm fstp t0; t1
533  __asm fst t1; t1
534  __asm fmul p01_minus_p21; t1 * p01_minus_p21
535  __asm fld t0; t0 | t1 * p01_minus_p21
536  __asm fmul p11_minus_p21; t0 * p11_minus_p21 | t1 * p01_minus_p21
537  __asm fld t1; t1 | t0 * p11_minus_p21 | t1 * p01_minus_p21
538  __asm fmul p00_minus_p20; t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
539  __asm fld t0; t0 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
540  __asm fmul p10_minus_p20; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
541  __asm fxch st(2); t0 * p11_minus_p21 | t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21
542  __asm fsubp st(3), st; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
543  __asm fsubrp st(1), st; t1 * p00_minus_p20 - t0 * p10_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
544  __asm fxch st(1); t1 * p01_minus_p21 - t0 * p11_minus_p21 | t1 * p00_minus_p20 - t0 * p10_minus_p20
545  __asm fmul xstepdenominv; r_lstepx | t1 * p00_minus_p20 - t0 * p10_minus_p20
546  __asm fxch st(1)
547  __asm fmul ystepdenominv; r_lstepy | r_lstepx
548  __asm fxch st(1); r_lstepx | r_lstepy
549  __asm fistp dword ptr[r_lstepx]
550  __asm fistp dword ptr[r_lstepy]
551  /* FS: Start */
552  /*
553  t0 = r_p0[6] - r_p2[6];
554  t1 = r_p1[6] - r_p2[6];
555  r_lrstepx = (int)ceil((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
556  r_lrstepy = (int)ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
557  */
558  __asm fild dword ptr d_xdenom; d_xdenom
559  __asm fdivr one; 1 / d_xdenom
560  __asm fst xstepdenominv;
561  __asm fmul negative_one; -(1 / d_xdenom)
562 
563  __asm mov eax, dword ptr[r_p0 + 24] // 6
564  __asm mov ebx, dword ptr[r_p1 + 24]
565  __asm sub eax, dword ptr[r_p2 + 24]
566  __asm sub ebx, dword ptr[r_p2 + 24]
567 
568  __asm fstp ystepdenominv; (empty)
569 
570  __asm mov t0_int, eax
571  __asm mov t1_int, ebx
572  __asm fild t0_int; t0
573  __asm fild t1_int; t1 | t0
574  __asm fxch st(1); t0 | t1
575  __asm fstp t0; t1
576  __asm fst t1; t1
577  __asm fmul p01_minus_p21; t1 * p01_minus_p21
578  __asm fld t0; t0 | t1 * p01_minus_p21
579  __asm fmul p11_minus_p21; t0 * p11_minus_p21 | t1 * p01_minus_p21
580  __asm fld t1; t1 | t0 * p11_minus_p21 | t1 * p01_minus_p21
581  __asm fmul p00_minus_p20; t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
582  __asm fld t0; t0 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
583  __asm fmul p10_minus_p20; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
584  __asm fxch st(2); t0 * p11_minus_p21 | t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21
585  __asm fsubp st(3), st; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
586  __asm fsubrp st(1), st; t1 * p00_minus_p20 - t0 * p10_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
587  __asm fxch st(1); t1 * p01_minus_p21 - t0 * p11_minus_p21 | t1 * p00_minus_p20 - t0 * p10_minus_p20
588  __asm fmul xstepdenominv; r_lstepx | t1 * p00_minus_p20 - t0 * p10_minus_p20
589  __asm fxch st(1)
590  __asm fmul ystepdenominv; r_lstepy | r_lstepx
591  __asm fxch st(1); r_lstepx | r_lstepy
592  __asm fistp dword ptr[r_lrstepx]
593  __asm fistp dword ptr[r_lrstepy]
594 
595  /* FS: Start */
596  /*
597  t0 = r_p0[7] - r_p2[7];
598  t1 = r_p1[7] - r_p2[7];
599  r_lgstepx = (int)ceil((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
600  r_lgstepy = (int)ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
601  */
602  __asm fild dword ptr d_xdenom; d_xdenom
603  __asm fdivr one; 1 / d_xdenom
604  __asm fst xstepdenominv;
605  __asm fmul negative_one; -(1 / d_xdenom)
606 
607  __asm mov eax, dword ptr[r_p0 + 28] // 7
608  __asm mov ebx, dword ptr[r_p1 + 28]
609  __asm sub eax, dword ptr[r_p2 + 28]
610  __asm sub ebx, dword ptr[r_p2 + 28]
611 
612  __asm fstp ystepdenominv; (empty)
613 
614  __asm mov t0_int, eax
615  __asm mov t1_int, ebx
616  __asm fild t0_int; t0
617  __asm fild t1_int; t1 | t0
618  __asm fxch st(1); t0 | t1
619  __asm fstp t0; t1
620  __asm fst t1; t1
621  __asm fmul p01_minus_p21; t1 * p01_minus_p21
622  __asm fld t0; t0 | t1 * p01_minus_p21
623  __asm fmul p11_minus_p21; t0 * p11_minus_p21 | t1 * p01_minus_p21
624  __asm fld t1; t1 | t0 * p11_minus_p21 | t1 * p01_minus_p21
625  __asm fmul p00_minus_p20; t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
626  __asm fld t0; t0 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
627  __asm fmul p10_minus_p20; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
628  __asm fxch st(2); t0 * p11_minus_p21 | t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21
629  __asm fsubp st(3), st; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
630  __asm fsubrp st(1), st; t1 * p00_minus_p20 - t0 * p10_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
631  __asm fxch st(1); t1 * p01_minus_p21 - t0 * p11_minus_p21 | t1 * p00_minus_p20 - t0 * p10_minus_p20
632  __asm fmul xstepdenominv; r_lstepx | t1 * p00_minus_p20 - t0 * p10_minus_p20
633  __asm fxch st(1)
634  __asm fmul ystepdenominv; r_lstepy | r_lstepx
635  __asm fxch st(1); r_lstepx | r_lstepy
636  __asm fistp dword ptr[r_lgstepx]
637  __asm fistp dword ptr[r_lgstepy]
638 
639  /* FS: Start */
640  /*
641  t0 = r_p0[8] - r_p2[8];
642  t1 = r_p1[8] - r_p2[8];
643  r_lbstepy = (int)ceil((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
644  r_lbstepy = (int)ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
645  */
646  __asm fild dword ptr d_xdenom; d_xdenom
647  __asm fdivr one; 1 / d_xdenom
648  __asm fst xstepdenominv;
649  __asm fmul negative_one; -(1 / d_xdenom)
650 
651  __asm mov eax, dword ptr[r_p0 + 32] // 8
652  __asm mov ebx, dword ptr[r_p1 + 32]
653  __asm sub eax, dword ptr[r_p2 + 32]
654  __asm sub ebx, dword ptr[r_p2 + 32]
655 
656  __asm fstp ystepdenominv; (empty)
657 
658  __asm mov t0_int, eax
659  __asm mov t1_int, ebx
660  __asm fild t0_int; t0
661  __asm fild t1_int; t1 | t0
662  __asm fxch st(1); t0 | t1
663  __asm fstp t0; t1
664  __asm fst t1; t1
665  __asm fmul p01_minus_p21; t1 * p01_minus_p21
666  __asm fld t0; t0 | t1 * p01_minus_p21
667  __asm fmul p11_minus_p21; t0 * p11_minus_p21 | t1 * p01_minus_p21
668  __asm fld t1; t1 | t0 * p11_minus_p21 | t1 * p01_minus_p21
669  __asm fmul p00_minus_p20; t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
670  __asm fld t0; t0 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
671  __asm fmul p10_minus_p20; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
672  __asm fxch st(2); t0 * p11_minus_p21 | t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21
673  __asm fsubp st(3), st; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
674  __asm fsubrp st(1), st; t1 * p00_minus_p20 - t0 * p10_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
675  __asm fxch st(1); t1 * p01_minus_p21 - t0 * p11_minus_p21 | t1 * p00_minus_p20 - t0 * p10_minus_p20
676  __asm fmul xstepdenominv; r_lstepx | t1 * p00_minus_p20 - t0 * p10_minus_p20
677  __asm fxch st(1)
678  __asm fmul ystepdenominv; r_lstepy | r_lstepx
679  __asm fxch st(1); r_lstepx | r_lstepy
680  __asm fistp dword ptr[r_lbstepx]
681  __asm fistp dword ptr[r_lbstepy]
682 
683  /*
684  ** put FPU back into extended precision chop mode
685  */
686  __asm fldcw word ptr[fpu_chop_cw]
687 
688  /*
689  t0 = r_p0[2] - r_p2[2];
690  t1 = r_p1[2] - r_p2[2];
691  r_sstepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) *
692  xstepdenominv);
693  r_sstepy = (int)((t1 * p00_minus_p20 - t0* p10_minus_p20) *
694  ystepdenominv);
695  */
696  __asm mov eax, dword ptr[r_p0 + 8]
697  __asm mov ebx, dword ptr[r_p1 + 8]
698  __asm sub eax, dword ptr[r_p2 + 8]
699  __asm sub ebx, dword ptr[r_p2 + 8]
700  __asm mov t0_int, eax
701  __asm mov t1_int, ebx
702  __asm fild t0_int; t0
703  __asm fild t1_int; t1 | t0
704  __asm fxch st(1); t0 | t1
705  __asm fstp t0; t1
706  __asm fst t1; (empty)
707 
708  __asm fmul p01_minus_p21; t1 * p01_minus_p21
709  __asm fld t0; t0 | t1 * p01_minus_p21
710  __asm fmul p11_minus_p21; t0 * p11_minus_p21 | t1 * p01_minus_p21
711  __asm fld t1; t1 | t0 * p11_minus_p21 | t1 * p01_minus_p21
712  __asm fmul p00_minus_p20; t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
713  __asm fld t0; t0 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
714  __asm fmul p10_minus_p20; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
715  __asm fxch st(2); t0 * p11_minus_p21 | t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21
716  __asm fsubp st(3), st; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
717  __asm fsubrp st(1), st; t1 * p00_minus_p20 - t0 * p10_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
718  __asm fxch st(1); t1 * p01_minus_p21 - t0 * p11_minus_p21 | t1 * p00_minus_p20 - t0 * p10_minus_p20
719  __asm fmul xstepdenominv; r_lstepx | t1 * p00_minus_p20 - t0 * p10_minus_p20
720  __asm fxch st(1)
721  __asm fmul ystepdenominv; r_lstepy | r_lstepx
722  __asm fxch st(1); r_lstepx | r_lstepy
723  __asm fistp dword ptr[r_sstepx]
724  __asm fistp dword ptr[r_sstepy]
725 
726  /*
727  t0 = r_p0[3] - r_p2[3];
728  t1 = r_p1[3] - r_p2[3];
729  r_tstepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) *
730  xstepdenominv);
731  r_tstepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) *
732  ystepdenominv);
733  */
734  __asm mov eax, dword ptr[r_p0 + 12]
735  __asm mov ebx, dword ptr[r_p1 + 12]
736  __asm sub eax, dword ptr[r_p2 + 12]
737  __asm sub ebx, dword ptr[r_p2 + 12]
738 
739  __asm mov t0_int, eax
740  __asm mov t1_int, ebx
741  __asm fild t0_int; t0
742  __asm fild t1_int; t1 | t0
743  __asm fxch st(1); t0 | t1
744  __asm fstp t0; t1
745  __asm fst t1; (empty)
746 
747  __asm fmul p01_minus_p21; t1 * p01_minus_p21
748  __asm fld t0; t0 | t1 * p01_minus_p21
749  __asm fmul p11_minus_p21; t0 * p11_minus_p21 | t1 * p01_minus_p21
750  __asm fld t1; t1 | t0 * p11_minus_p21 | t1 * p01_minus_p21
751  __asm fmul p00_minus_p20; t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
752  __asm fld t0; t0 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
753  __asm fmul p10_minus_p20; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
754  __asm fxch st(2); t0 * p11_minus_p21 | t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21
755  __asm fsubp st(3), st; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
756  __asm fsubrp st(1), st; t1 * p00_minus_p20 - t0 * p10_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
757  __asm fxch st(1); t1 * p01_minus_p21 - t0 * p11_minus_p21 | t1 * p00_minus_p20 - t0 * p10_minus_p20
758  __asm fmul xstepdenominv; r_lstepx | t1 * p00_minus_p20 - t0 * p10_minus_p20
759  __asm fxch st(1)
760  __asm fmul ystepdenominv; r_lstepy | r_lstepx
761  __asm fxch st(1); r_lstepx | r_lstepy
762  __asm fistp dword ptr[r_tstepx]
763  __asm fistp dword ptr[r_tstepy]
764 
765  /*
766  t0 = r_p0[5] - r_p2[5];
767  t1 = r_p1[5] - r_p2[5];
768  r_zistepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) *
769  xstepdenominv);
770  r_zistepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) *
771  ystepdenominv);
772  */
773  __asm mov eax, dword ptr[r_p0 + 20]
774  __asm mov ebx, dword ptr[r_p1 + 20]
775  __asm sub eax, dword ptr[r_p2 + 20]
776  __asm sub ebx, dword ptr[r_p2 + 20]
777 
778  __asm mov t0_int, eax
779  __asm mov t1_int, ebx
780  __asm fild t0_int; t0
781  __asm fild t1_int; t1 | t0
782  __asm fxch st(1); t0 | t1
783  __asm fstp t0; t1
784  __asm fst t1; (empty)
785 
786  __asm fmul p01_minus_p21; t1 * p01_minus_p21
787  __asm fld t0; t0 | t1 * p01_minus_p21
788  __asm fmul p11_minus_p21; t0 * p11_minus_p21 | t1 * p01_minus_p21
789  __asm fld t1; t1 | t0 * p11_minus_p21 | t1 * p01_minus_p21
790  __asm fmul p00_minus_p20; t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
791  __asm fld t0; t0 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
792  __asm fmul p10_minus_p20; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t0 * p11_minus_p21 | t1 * p01_minus_p21
793  __asm fxch st(2); t0 * p11_minus_p21 | t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21
794  __asm fsubp st(3), st; t0 * p10_minus_p20 | t1 * p00_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
795  __asm fsubrp st(1), st; t1 * p00_minus_p20 - t0 * p10_minus_p20 | t1 * p01_minus_p21 - t0 * p11_minus_p21
796  __asm fxch st(1); t1 * p01_minus_p21 - t0 * p11_minus_p21 | t1 * p00_minus_p20 - t0 * p10_minus_p20
797  __asm fmul xstepdenominv; r_lstepx | t1 * p00_minus_p20 - t0 * p10_minus_p20
798  __asm fxch st(1)
799  __asm fmul ystepdenominv; r_lstepy | r_lstepx
800  __asm fxch st(1); r_lstepx | r_lstepy
801  __asm fistp dword ptr[r_zistepx]
802  __asm fistp dword ptr[r_zistepy]
803 
804  /*
805  #if id386ALIAS
806  a_sstepxfrac = r_sstepx << 16;
807  a_tstepxfrac = r_tstepx << 16;
808  #else
809  a_sstepxfrac = r_sstepx & 0xFFFF;
810  a_tstepxfrac = r_tstepx & 0xFFFF;
811  #endif
812  */
813  __asm mov eax, d_pdrawspans
814  __asm cmp eax, offset R_PolysetDrawSpans8_Opaque_Coloured
815  __asm mov eax, r_sstepx
816  __asm mov ebx, r_tstepx
817  __asm jne translucent
818  //#if id386ALIAS
819  __asm shl eax, 16
820  __asm shl ebx, 16
821  __asm jmp done_with_steps
822  //#else
823 translucent :
824  __asm and eax, 0ffffh
825  __asm and ebx, 0ffffh
826  //#endif
827 done_with_steps :
828  __asm mov a_sstepxfrac, eax
829  __asm mov a_tstepxfrac, ebx
830 
831  /*
832  a_ststepxwhole = skinwidth * (r_tstepx >> 16) + (r_sstepx >> 16);
833  */
834  __asm mov ebx, r_tstepx
835  __asm mov ecx, r_sstepx
836  __asm sar ebx, 16
837  __asm mov eax, skinwidth
838  __asm mul ebx
839  __asm sar ecx, 16
840  __asm add eax, ecx
841  __asm mov a_ststepxwhole, eax
842 }
843 #else
845 {
846  float xstepdenominv, ystepdenominv, t0, t1;
847  float p01_minus_p21, p11_minus_p21, p00_minus_p20, p10_minus_p20;
848 
849  p00_minus_p20 = r_p0[0] - r_p2[0];
850  p01_minus_p21 = r_p0[1] - r_p2[1];
851  p10_minus_p20 = r_p1[0] - r_p2[0];
852  p11_minus_p21 = r_p1[1] - r_p2[1];
853 
854  xstepdenominv = 1.0 / (float)d_xdenom;
855 
856  ystepdenominv = -xstepdenominv;
857 
858  // ceil () for light so positive steps are exaggerated, negative steps
859  // diminished, pushing us away from underflow toward overflow. Underflow is
860  // very visible, overflow is very unlikely, because of ambient lighting
861  t0 = r_p0[4] - r_p2[4];
862  t1 = r_p1[4] - r_p2[4];
863  r_lstepx = (int)ceil((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
864  r_lstepy = (int)ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
865 
866  //qb: use ceil
867  t0 = r_p0[6] - r_p2[6];
868  t1 = r_p1[6] - r_p2[6];
869  r_lrstepx = (int)ceil((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
870  r_lrstepy = (int)ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
871 
872  t0 = r_p0[7] - r_p2[7];
873  t1 = r_p1[7] - r_p2[7];
874  r_lgstepx = (int)ceil((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
875  r_lgstepy = (int)ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
876 
877  t0 = r_p0[8] - r_p2[8];
878  t1 = r_p1[8] - r_p2[8];
879  r_lbstepx = (int)ceil((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
880  r_lbstepy = (int)ceil((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
881 
882 
883  t0 = r_p0[2] - r_p2[2];
884  t1 = r_p1[2] - r_p2[2];
885  r_sstepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
886  r_sstepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
887 
888  t0 = r_p0[3] - r_p2[3];
889  t1 = r_p1[3] - r_p2[3];
890  r_tstepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
891  r_tstepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
892 
893  t0 = r_p0[5] - r_p2[5];
894  t1 = r_p1[5] - r_p2[5];
895  r_zistepx = (int)((t1 * p01_minus_p21 - t0 * p11_minus_p21) * xstepdenominv);
896  r_zistepy = (int)((t1 * p00_minus_p20 - t0 * p10_minus_p20) * ystepdenominv);
897 
898  //#if id386ALIAS
899 #if id386
901  {
902  a_sstepxfrac = r_sstepx << 16;
903  a_tstepxfrac = r_tstepx << 16;
904  }
905  else
906 #endif
907  {
908  //#else
909  a_sstepxfrac = r_sstepx & 0xFFFF;
910  a_tstepxfrac = r_tstepx & 0xFFFF;
911  }
912  //#endif
913 
914  a_ststepxwhole = skinwidth * (r_tstepx >> 16) + (r_sstepx >> 16);
915 }
916 #endif /* !id386 */
917 
918 
919 //qb: staticized
920 static int lcount;
921 static int lsfrac, ltfrac;
922 static byte *lpdest;
923 static byte *lptex;
924 static int llight;
925 static int lzi;
926 static short *lpz;
927 static unsigned char *pix24; // leilei - colored lighting
928 static int trans[3]; // leilei - colored lighting
929 
930 /*
931 ================
932 R_PolysetDrawThreshSpans8
933 
934 Random fizzle fade rasterizer
935 ================
936 */
938 {
939 
940  do
941  {
942  lcount = d_aspancount - pspanpackage->count;
943 
945  if (errorterm >= 0)
946  {
949  }
950  else
951  {
953  }
954 
955  if (lcount)
956  {
957  lpdest = pspanpackage->pdest;
958  lptex = pspanpackage->ptex;
959  lpz = pspanpackage->pz;
960  lsfrac = pspanpackage->sfrac;
961  ltfrac = pspanpackage->tfrac;
962  llight = pspanpackage->light;
963  lzi = pspanpackage->zi;
964 
965  do
966  {
967  if ((lzi >> 16) >= *lpz)
968  {
970 
972  {
973  *lpdest = ((byte *)vid.colormap)[*lptex + (llight & 0xFF00)];
974  *lpz = lzi >> 16;
975  }
976  }
977 
978  lpdest++;
979  lzi += r_zistepx;
980  lpz++;
981  llight += r_lstepx;
983  lsfrac += a_sstepxfrac;
984  lptex += lsfrac >> 16;
985  lsfrac &= 0xFFFF;
986  ltfrac += a_tstepxfrac;
987  if (ltfrac & 0x10000)
988  {
990  ltfrac &= 0xFFFF;
991  }
992  } while (--lcount);
993  }
994 
995  pspanpackage++;
996  } while (pspanpackage->count != -999999);
997 }
998 
999 
1000 /*
1001 ================
1002 R_PolysetDrawSpans8
1003 ================
1004 */
1006 {
1007  do
1008  {
1009  lcount = d_aspancount - pspanpackage->count;
1010 
1012  if (errorterm >= 0)
1013  {
1016  }
1017  else
1018  {
1020  }
1021 
1022  if (lcount)
1023  {
1024  lpdest = pspanpackage->pdest;
1025  lptex = pspanpackage->ptex;
1026  lpz = pspanpackage->pz;
1027  lsfrac = pspanpackage->sfrac;
1028  ltfrac = pspanpackage->tfrac;
1029  llight = pspanpackage->light;
1030  lzi = pspanpackage->zi;
1031 
1032  do
1033  {
1034  if ((lzi >> 16) >= *lpz)
1035  {
1036  int temp = vid.colormap[*lptex + ( llight & 0xFF00 )];
1037 
1038  *lpdest = vid.alphamap[temp + *lpdest * 256];
1039  }
1040  lpdest++;
1041  lzi += r_zistepx;
1042  lpz++;
1043  llight += r_lstepx;
1044  lptex += a_ststepxwhole;
1045  lsfrac += a_sstepxfrac;
1046  lptex += lsfrac >> 16;
1047  lsfrac &= 0xFFFF;
1048  ltfrac += a_tstepxfrac;
1049  if (ltfrac & 0x10000)
1050  {
1052  ltfrac &= 0xFFFF;
1053  }
1054  } while (--lcount);
1055  }
1056 
1057  pspanpackage++;
1058  } while (pspanpackage->count != -999999);
1059 }
1060 
1062 {
1063  do
1064  {
1065  lcount = d_aspancount - pspanpackage->count;
1066 
1068  if (errorterm >= 0)
1069  {
1072  }
1073  else
1074  {
1076  }
1077 
1078  if (lcount)
1079  {
1080  lpdest = pspanpackage->pdest;
1081  lpz = pspanpackage->pz;
1082  lzi = pspanpackage->zi;
1083 
1084  do
1085  {
1086  if ((lzi >> 16) >= *lpz)
1087  {
1089  }
1090  lpdest++;
1091  lzi += r_zistepx;
1092  lpz++;
1093  } while (--lcount);
1094  }
1095 
1096  pspanpackage++;
1097  } while (pspanpackage->count != -999999);
1098 }
1099 
1101 {
1102  do
1103  {
1104  lcount = d_aspancount - pspanpackage->count;
1105 
1107  if (errorterm >= 0)
1108  {
1111  }
1112  else
1113  {
1115  }
1116 
1117  if (lcount)
1118  {
1119  lpdest = pspanpackage->pdest;
1120  lptex = pspanpackage->ptex;
1121  lpz = pspanpackage->pz;
1122  lsfrac = pspanpackage->sfrac;
1123  ltfrac = pspanpackage->tfrac;
1124  llight = pspanpackage->light;
1125  lzi = pspanpackage->zi;
1126  do
1127  {
1128  if ((lzi >> 16) >= *lpz)
1129  {
1130  int temp = vid.colormap[*lptex + (llight & 0xFF00)];
1131  *lpdest = vid.alphamap[temp * 256 + *lpdest];
1132  *lpz = lzi >> 16;
1133  }
1134  lpdest++;
1135  lzi += r_zistepx;
1136  lpz++;
1137  llight += r_lstepx;
1138  lptex += a_ststepxwhole;
1139  lsfrac += a_sstepxfrac;
1140  lptex += lsfrac >> 16;
1141  lsfrac &= 0xFFFF;
1142  ltfrac += a_tstepxfrac;
1143  if (ltfrac & 0x10000)
1144  {
1146  ltfrac &= 0xFFFF;
1147  }
1148  } while (--lcount);
1149  }
1150 
1151  pspanpackage++;
1152  } while (pspanpackage->count != -999999);
1153 }
1154 
1155 
1157 {
1158  do
1159  {
1160  lcount = d_aspancount - pspanpackage->count;
1161 
1163  if (errorterm >= 0)
1164  {
1167  }
1168  else
1169  {
1171  }
1172 
1173  if (lcount)
1174  {
1175  lpdest = pspanpackage->pdest;
1176  lpz = pspanpackage->pz;
1177  lzi = pspanpackage->zi;
1178 
1179  do
1180  {
1181  if ((lzi >> 16) >= *lpz)
1182  {
1184  }
1185  lpdest++;
1186  lzi += r_zistepx;
1187  lpz++;
1188  } while (--lcount);
1189  }
1190 
1191  pspanpackage++;
1192  } while (pspanpackage->count != -999999);
1193 }
1194 
1195 #if 1 //qb: no asm colored light support was- !id386
1196 // leilei - colored lighting
1197 
1199 {
1200 
1201  do
1202  {
1203  lcount = d_aspancount - pspanpackage->count;
1204 
1206  if (errorterm >= 0)
1207  {
1210  }
1211  else
1212  {
1214  }
1215 
1216  if (lcount)
1217  {
1218  lpdest = pspanpackage->pdest;
1219  lptex = pspanpackage->ptex;
1220  lpz = pspanpackage->pz;
1221  lsfrac = pspanpackage->sfrac;
1222  ltfrac = pspanpackage->tfrac;
1223  llight = pspanpackage->light;
1224  lzi = pspanpackage->zi;
1225  do
1226  {
1227  if ((lzi >> 16) >= *lpz)
1228  {
1229  //PGM
1231  *lpdest = ((byte *)vid.colormap)[irtable[*lptex]];
1232  // leilei - colored lights begin
1233  else if (coloredlights)
1234  {
1235  int lptemp = *lptex;
1236  pix24 = (unsigned char *)&d_8to24table[lptemp];
1237  //qb: works now...
1238  trans[0] = CLAMP((int)(pix24[0] * (pspanpackage->lightr * shadelight[0])) >> 15, 0, 63);
1239  trans[1] = CLAMP((int)(pix24[1] * (pspanpackage->lightg * shadelight[1])) >> 15, 0, 63);
1240  trans[2] = CLAMP((int)(pix24[2] * (pspanpackage->lightb * shadelight[2])) >> 15, 0, 63);
1241 
1242  *lpdest = palmap2[trans[0]][trans[1]][trans[2]];
1243  } // leilei - colored lights end
1244  else *lpdest = ((byte *)vid.colormap)[*lptex + (llight & 0xFF00)];
1245 
1246  //PGM
1247  *lpz = lzi >> 16;
1248  }
1249  lpdest++;
1250  lzi += r_zistepx;
1251  lpz++;
1252  llight += r_lstepx;
1253  lptex += a_ststepxwhole;
1254  lsfrac += a_sstepxfrac;
1255  lptex += lsfrac >> 16;
1256  lsfrac &= 0xFFFF;
1257  ltfrac += a_tstepxfrac;
1258  if (ltfrac & 0x10000)
1259  {
1261  ltfrac &= 0xFFFF;
1262  }
1263  } while (--lcount);
1264  }
1265 
1266  pspanpackage++;
1267  } while (pspanpackage->count != -999999);
1268 }
1269 #endif
1270 
1271 
1272 /*
1273 ================
1274 R_PolysetFillSpans8
1275 ================
1276 */
1278 {
1279  int color;
1280 
1281  // FIXME: do z buffering
1282 
1283  color = d_aflatcolor++;
1284 
1285  while (1)
1286  {
1287  int lcount;
1288  byte *lpdest;
1289 
1290  lcount = pspanpackage->count;
1291 
1292  if (lcount == -1)
1293  return;
1294 
1295  if (lcount)
1296  {
1297  lpdest = pspanpackage->pdest;
1298 
1299  do
1300  {
1301  *lpdest++ = color;
1302  } while (--lcount);
1303  }
1304 
1305  pspanpackage++;
1306  }
1307 }
1308 
1309 /*
1310 ================
1311 R_RasterizeAliasPolySmooth
1312 ================
1313 */
1315 {
1316  int initialleftheight, initialrightheight;
1317  int *plefttop, *prighttop, *pleftbottom, *prightbottom;
1318  int working_lstepx, originalcount;
1319  int working_lrstepx;
1320  int working_lgstepx;
1321  int working_lbstepx;
1322 
1323  plefttop = pedgetable->pleftedgevert0;
1324  prighttop = pedgetable->prightedgevert0;
1325 
1326  pleftbottom = pedgetable->pleftedgevert1;
1327  prightbottom = pedgetable->prightedgevert1;
1328 
1329  initialleftheight = pleftbottom[1] - plefttop[1];
1330  initialrightheight = prightbottom[1] - prighttop[1];
1331 
1332 
1333 
1334  //
1335  // set the s, t, and light gradients, which are consistent across the triangle
1336  // because being a triangle, things are affine
1337  //
1339  //
1340  // rasterize the polygon
1341  //
1342 
1343  //
1344  // scan out the top (and possibly only) part of the left edge
1345  //
1347 
1348  ystart = plefttop[1];
1349  d_aspancount = plefttop[0] - prighttop[0];
1350 
1351  d_ptex = (byte *)r_affinetridesc.pskin + (plefttop[2] >> 16) +
1352  (plefttop[3] >> 16) * r_affinetridesc.skinwidth;
1353  //#if id386ALIAS
1354 #if id386
1356  {
1357  d_sfrac = (plefttop[2] & 0xFFFF) << 16;
1358  d_tfrac = (plefttop[3] & 0xFFFF) << 16;
1359  }
1360  //#else
1361  else
1362 #endif
1363  {
1364  d_sfrac = plefttop[2] & 0xFFFF;
1365  d_tfrac = plefttop[3] & 0xFFFF;
1366  }
1367  //#endif
1368  d_light = plefttop[4];
1369  d_zi = plefttop[5];
1370 #ifdef COLMODEL
1371  d_lightr = plefttop[6];
1372  d_lightg = plefttop[7];
1373  d_lightb = plefttop[8];
1374 #endif
1375  d_pdest = (byte *)d_viewbuffer +
1376  ystart * r_screenwidth + plefttop[0];
1377  d_pz = d_pzbuffer + ystart * d_zwidth + plefttop[0];
1378 
1379  if (initialleftheight == 1)
1380  {
1385 
1388 
1389  // FIXME: need to clamp l, s, t, at both ends?
1391 #ifdef COLMODEL
1395 #endif
1397 
1399  }
1400  else
1401  {
1402  R_PolysetSetUpForLineScan(plefttop[0], plefttop[1],
1403  pleftbottom[0], pleftbottom[1]);
1404 
1405  //#if id386ALIAS
1406 #if id386
1408  {
1409  d_pzbasestep = (d_zwidth + ubasestep) << 1;
1411  }
1412  //#else
1413  else
1414 #endif
1415  {
1418  }
1419  //#endif
1420 
1423 
1424  // TODO: can reuse partial expressions here
1425 
1426  // for negative steps in x along left edge, bias toward overflow rather than
1427  // underflow (sort of turning the floor () we did in the gradient calcs into
1428  // ceil (), but plus a little bit)
1429  if (ubasestep < 0){
1430  working_lstepx = r_lstepx - 1;
1431  working_lrstepx = r_lrstepx - 1;
1432  working_lgstepx = r_lgstepx - 1;
1433  working_lbstepx = r_lbstepx - 1;
1434  }
1435  else
1436  {
1437  working_lstepx = r_lstepx;
1438  working_lrstepx = r_lrstepx;
1439  working_lgstepx = r_lgstepx;
1440  working_lbstepx = r_lbstepx;
1441 
1442 
1443  }
1444 
1446  d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> 16) +
1447  ((r_tstepy + r_tstepx * ubasestep) >> 16) *
1449  //#if id386ALIAS
1450 #if id386
1452  {
1455  }
1456  else
1457 #endif
1458  {
1459  //#else
1460  d_sfracbasestep = (r_sstepy + r_sstepx * ubasestep) & 0xFFFF;
1461  d_tfracbasestep = (r_tstepy + r_tstepx * ubasestep) & 0xFFFF;
1462  }
1463  //#endif
1464  d_lightbasestep = r_lstepy + working_lstepx * ubasestep;
1466 
1467  d_lightbasestepr = r_lrstepy + working_lrstepx * ubasestep;
1468  d_lightbasestepg = r_lgstepy + working_lgstepx * ubasestep;
1469  d_lightbasestepb = r_lbstepy + working_lbstepx * ubasestep;
1470 
1471 
1472 
1474  ((r_tstepy + r_tstepx * d_countextrastep) >> 16) *
1476  //#if id386ALIAS
1477 #if id386
1479  {
1482  }
1483  else
1484 #endif
1485  {
1486  //#else
1489  }
1490  //#endif
1491  d_lightextrastep = d_lightbasestep + working_lstepx;
1493 
1494  d_lightextrastepr = d_lightbasestepr + working_lrstepx;
1495  d_lightextrastepg = d_lightbasestepg + working_lgstepx;
1496  d_lightextrastepb = d_lightbasestepb + working_lbstepx;
1497 
1498 #if id386
1500  {
1501  R_PolysetScanLeftEdge(initialleftheight);
1502  }
1503  else
1504 #endif
1505  {
1506  R_PolysetScanLeftEdge_C(initialleftheight);
1507  }
1508  }
1509 
1510  //
1511  // scan out the bottom part of the left edge, if it exists
1512  //
1513  if (pedgetable->numleftedges == 2)
1514  {
1515  int height;
1516 
1517  plefttop = pleftbottom;
1518  pleftbottom = pedgetable->pleftedgevert2;
1519 
1520  height = pleftbottom[1] - plefttop[1];
1521 
1522  // TODO: make this a function; modularize this function in general
1523 
1524  ystart = plefttop[1];
1525  d_aspancount = plefttop[0] - prighttop[0];
1526  d_ptex = (byte *)r_affinetridesc.pskin + (plefttop[2] >> 16) +
1527  (plefttop[3] >> 16) * r_affinetridesc.skinwidth;
1528  d_sfrac = 0;
1529  d_tfrac = 0;
1530  d_light = plefttop[4];
1531  d_zi = plefttop[5];
1532 #ifdef COLMODEL
1533  d_lightr = plefttop[6];
1534  d_lightg = plefttop[7];
1535  d_lightb = plefttop[8];
1536 #endif
1537  d_pdest = (byte *)d_viewbuffer + ystart * r_screenwidth + plefttop[0];
1538  d_pz = d_pzbuffer + ystart * d_zwidth + plefttop[0];
1539 
1540  if (height == 1)
1541  {
1546 
1549 
1550  // FIXME: need to clamp l, s, t, at both ends?
1552 #ifdef COLMODEL
1556 #endif
1558 
1560  }
1561  else
1562  {
1563  R_PolysetSetUpForLineScan(plefttop[0], plefttop[1],
1564  pleftbottom[0], pleftbottom[1]);
1565 
1568 
1569  //#if id386ALIAS
1570 #if id386
1572  {
1573  d_pzbasestep = (d_zwidth + ubasestep) << 1;
1575  }
1576  //#else
1577  else
1578 #endif
1579  {
1582  }
1583  //#endif
1584 
1585  if (ubasestep < 0){
1586  working_lstepx = r_lstepx - 1;
1587  working_lrstepx = r_lrstepx - 1;
1588  working_lgstepx = r_lgstepx - 1;
1589  working_lbstepx = r_lbstepx - 1;
1590  }
1591  else{
1592 
1593  working_lstepx = r_lstepx;
1594  working_lrstepx = r_lrstepx;
1595  working_lgstepx = r_lgstepx;
1596  working_lbstepx = r_lbstepx;
1597  }
1598 
1600  d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> 16) +
1601  ((r_tstepy + r_tstepx * ubasestep) >> 16) *
1603  //#if id386ALIAS
1604 #if id386
1606  {
1609  }
1610  //#else
1611  else
1612 #endif
1613  {
1614  d_sfracbasestep = (r_sstepy + r_sstepx * ubasestep) & 0xFFFF;
1615  d_tfracbasestep = (r_tstepy + r_tstepx * ubasestep) & 0xFFFF;
1616  }
1617  //#endif
1618  d_lightbasestep = r_lstepy + working_lstepx * ubasestep;
1620 
1621  d_lightbasestepr = r_lrstepy + working_lrstepx * ubasestep;
1622  d_lightbasestepg = r_lgstepy + working_lgstepx * ubasestep;
1623  d_lightbasestepb = r_lbstepy + working_lbstepx * ubasestep;
1624 
1626 
1628  ((r_tstepy + r_tstepx * d_countextrastep) >> 16) *
1630  //#if id386ALIAS
1631 #if id386
1633  {
1634  d_sfracextrastep = ((r_sstepy + r_sstepx*d_countextrastep) & 0xFFFF) << 16;
1635  d_tfracextrastep = ((r_tstepy + r_tstepx*d_countextrastep) & 0xFFFF) << 16;
1636  }
1637  else
1638 #endif
1639  //#endif
1640  {
1643  }
1644  //#endif
1645  d_lightextrastep = d_lightbasestep + working_lstepx;
1647 
1648  d_lightextrastepr = d_lightbasestepr + working_lrstepx;
1649  d_lightextrastepg = d_lightbasestepg + working_lgstepx;
1650  d_lightextrastepb = d_lightbasestepb + working_lbstepx;
1651 
1652 #if id386
1654  {
1656  }
1657  else
1658 #endif
1659  {
1661  }
1662  }
1663  }
1664 
1665  // scan out the top (and possibly only) part of the right edge, updating the
1666  // count field
1668 
1669  R_PolysetSetUpForLineScan(prighttop[0], prighttop[1],
1670  prightbottom[0], prightbottom[1]);
1671  d_aspancount = 0;
1673  originalcount = a_spans[initialrightheight].count;
1674  a_spans[initialrightheight].count = -999999; // mark end of the spanpackages
1675  (*d_pdrawspans) (a_spans);
1676 
1677  // scan out the bottom part of the right edge, if it exists
1678  if (pedgetable->numrightedges == 2)
1679  {
1680  int height;
1681  spanpackage_t *pstart;
1682 
1683  pstart = a_spans + initialrightheight;
1684  pstart->count = originalcount;
1685 
1686  d_aspancount = prightbottom[0] - prighttop[0];
1687 
1688  prighttop = prightbottom;
1689  prightbottom = pedgetable->prightedgevert2;
1690 
1691  height = prightbottom[1] - prighttop[1];
1692 
1693  R_PolysetSetUpForLineScan(prighttop[0], prighttop[1],
1694  prightbottom[0], prightbottom[1]);
1695 
1697  a_spans[initialrightheight + height].count = -999999;
1698  // mark end of the spanpackages
1699  (*d_pdrawspans) (pstart);
1700  }
1701 }
1702 
1703 
1704 
1705 
1706 /*
1707 ================
1708 R_PolysetSetEdgeTable
1709 ================
1710 */
1712 {
1713  int edgetableindex;
1714 
1715  edgetableindex = 0; // assume the vertices are already in
1716  // top to bottom order
1717 
1718  //
1719  // determine which edges are right & left, and the order in which
1720  // to rasterize them
1721  //
1722  if (r_p0[1] >= r_p1[1])
1723  {
1724  if (r_p0[1] == r_p1[1])
1725  {
1726  if (r_p0[1] < r_p2[1])
1727  pedgetable = &edgetables[2];
1728  else
1729  pedgetable = &edgetables[5];
1730 
1731  return;
1732  }
1733  else
1734  {
1735  edgetableindex = 1;
1736  }
1737  }
1738 
1739  if (r_p0[1] == r_p2[1])
1740  {
1741  if (edgetableindex)
1742  pedgetable = &edgetables[8];
1743  else
1744  pedgetable = &edgetables[9];
1745 
1746  return;
1747  }
1748  else if (r_p1[1] == r_p2[1])
1749  {
1750  if (edgetableindex)
1751  pedgetable = &edgetables[10];
1752  else
1753  pedgetable = &edgetables[11];
1754 
1755  return;
1756  }
1757 
1758  if (r_p0[1] > r_p2[1])
1759  edgetableindex += 2;
1760 
1761  if (r_p1[1] > r_p2[1])
1762  edgetableindex += 4;
1763 
1764  pedgetable = &edgetables[edgetableindex];
1765 }
1766 
1767 
R_PolysetDrawSpans8_Opaque_Coloured
void R_PolysetDrawSpans8_Opaque_Coloured(spanpackage_t *pspanpackage)
Definition: r_polyse.c:1198
d_xdenom
int d_xdenom
Definition: r_polyse.c:69
R_PolysetDrawSpans8_33
void R_PolysetDrawSpans8_33(spanpackage_t *pspanpackage)
Definition: r_polyse.c:1005
r_zistepx
int r_zistepx
Definition: r_polyse.c:91
spanpackage_t::count
int count
Definition: r_polyse.c:42
height
GLsizei height
Definition: qgl_win.c:69
errorterm
int errorterm
Definition: r_edge.c:80
d_lightb
int d_lightb
Definition: r_polyse.c:114
d_lightr
int d_lightr
Definition: r_polyse.c:114
RF_IR_VISIBLE
#define RF_IR_VISIBLE
Definition: q_shared.h:614
d_aflatcolor
int d_aflatcolor
Definition: r_polyse.c:68
d_pzbasestep
int d_pzbasestep
Definition: r_polyse.c:108
r_sstepx
int r_sstepx
Definition: r_polyse.c:90
int
CONST PIXELFORMATDESCRIPTOR int
Definition: qgl_win.c:35
finalvert_s::u
int u
Definition: r_local.h:293
edgetable::pleftedgevert2
int * pleftedgevert2
Definition: r_polyse.c:55
ltfrac
static int ltfrac
Definition: r_polyse.c:921
d_zi
int d_zi
Definition: r_polyse.c:102
skinwidth
int skinwidth
Definition: r_polyse.c:127
aliastriangleparms_t::b
finalvert_t * b
Definition: r_local.h:772
R_PolysetSetUpForLineScan
void R_PolysetSetUpForLineScan(fixed8_t startvertu, fixed8_t startvertv, fixed8_t endvertu, fixed8_t endvertv)
Definition: r_polyse.c:413
R_PolysetUpdateTables
void R_PolysetUpdateTables(void)
Definition: r_polyse.c:196
d_ptexbasestep
int d_ptexbasestep
Definition: r_polyse.c:105
d_sfracextrastep
int d_sfracextrastep
Definition: r_polyse.c:103
st
spawn_temp_t st
Definition: g_main.c:27
R_PolysetDrawSpans8_66
void R_PolysetDrawSpans8_66(spanpackage_t *pspanpackage)
Definition: r_polyse.c:1100
CLAMP
#define CLAMP(x, low, high)
Definition: r_local.h:47
d_zibasestep
int d_zibasestep
Definition: r_polyse.c:107
x
GLint GLenum GLint x
Definition: qgl_win.c:116
id386
#define id386
Definition: q_shared.h:46
i
int i
Definition: q_shared.c:305
d_viewbuffer
pixel_t * d_viewbuffer
Definition: r_main.c:196
d_ziextrastep
int d_ziextrastep
Definition: r_polyse.c:107
r_p0
int r_p0[9]
Definition: r_polyse.c:64
r_lstepy
int r_lstepy
Definition: r_polyse.c:90
COLMODEL
#define COLMODEL
Definition: r_local.h:35
q
GLdouble GLdouble GLdouble q
Definition: qgl_win.c:344
irtable
byte irtable[256]
Definition: r_polyse.c:149
d_pdrawspans
void(* d_pdrawspans)(spanpackage_t *pspanpackage)
Definition: r_polyse.c:130
refdef_t::rdflags
int rdflags
Definition: ref.h:110
finalvert_s::t
int t
Definition: r_local.h:293
entity_s::flags
int flags
Definition: ref.h:76
currententity
entity_t * currententity
Definition: r_bsp.c:28
r_local.h
erroradjustup
int erroradjustup
Definition: r_edge.c:80
d_tfracextrastep
int d_tfracextrastep
Definition: r_polyse.c:104
r_lbstepx
int r_lbstepx
Definition: r_polyse.c:94
spanpackage_t::lightg
int lightg
Definition: r_polyse.c:46
spanpackage_t::lightb
int lightb
Definition: r_polyse.c:46
spanpackage_t::tfrac
int tfrac
Definition: r_polyse.c:44
edgetable::numleftedges
int numleftedges
Definition: r_polyse.c:52
r_tstepy
int r_tstepy
Definition: r_polyse.c:90
spanpackage_t::lightr
int lightr
Definition: r_polyse.c:46
finalvert_s::v
int v
Definition: r_local.h:293
r_lgstepx
int r_lgstepx
Definition: r_polyse.c:93
edgetable::prightedgevert1
int * prightedgevert1
Definition: r_polyse.c:58
d_lightextrastep
int d_lightextrastep
Definition: r_polyse.c:104
R_PolysetDrawSpansConstant8_33
void R_PolysetDrawSpansConstant8_33(spanpackage_t *pspanpackage)
Definition: r_polyse.c:1061
pix24
static unsigned char * pix24
Definition: r_polyse.c:927
r
GLdouble GLdouble r
Definition: qgl_win.c:336
r_zistepy
int r_zistepy
Definition: r_polyse.c:91
spanpackage_t::pz
short * pz
Definition: r_polyse.c:41
R_PolysetFillSpans8
void R_PolysetFillSpans8(spanpackage_t *pspanpackage)
Definition: r_polyse.c:1277
MASK_1K
#define MASK_1K
Definition: r_polyse.c:29
lptex
static byte * lptex
Definition: r_polyse.c:923
d_tfrac
int d_tfrac
Definition: r_polyse.c:102
lsfrac
static int lsfrac
Definition: r_polyse.c:921
d_pdestextrastep
int d_pdestextrastep
Definition: r_polyse.c:104
RDF_IRGOGGLES
#define RDF_IRGOGGLES
Definition: q_shared.h:625
R_RasterizeAliasPolySmooth
void R_RasterizeAliasPolySmooth(void)
Definition: r_polyse.c:1314
pedgetable
edgetable * pedgetable
Definition: r_polyse.c:71
d_pzextrastep
int d_pzextrastep
Definition: r_polyse.c:108
r_affinetridesc
affinetridesc_t r_affinetridesc
Definition: r_alias.c:34
d_lightbasestepb
int d_lightbasestepb
Definition: r_polyse.c:112
r_lstepx
int r_lstepx
Definition: r_polyse.c:89
adivtab_t::remainder
int remainder
Definition: r_polyse.c:119
spanpackage_t::sfrac
int sfrac
Definition: r_polyse.c:44
r_newrefdef
refdef_t r_newrefdef
Definition: r_main.c:38
palmap2
byte palmap2[64][64][64]
Definition: r_draw.c:91
adivtab
static adivtab_t adivtab[32 *32]
Definition: r_polyse.c:122
d_pcolormap
byte * d_pcolormap
Definition: r_polyse.c:66
r_p2
int r_p2[9]
Definition: r_polyse.c:64
d_lightg
int d_lightg
Definition: r_polyse.c:114
skinstart
byte * skinstart
Definition: r_polyse.c:128
r_p1
int r_p1[9]
Definition: r_polyse.c:64
adivtab.h
edgetable::numrightedges
int numrightedges
Definition: r_polyse.c:56
NULL
#define NULL
Definition: q_shared.h:67
lzi
static int lzi
Definition: r_polyse.c:925
d_sfracbasestep
int d_sfracbasestep
Definition: r_polyse.c:106
d_ptex
byte * d_ptex
Definition: r_polyse.c:100
finalvert_s::zi
int zi
Definition: r_local.h:295
edgetable::isflattop
int isflattop
Definition: r_polyse.c:51
edgetable::prightedgevert0
int * prightedgevert0
Definition: r_polyse.c:57
r_screenwidth
int r_screenwidth
Definition: r_main.c:87
R_PolysetScanLeftEdge_C
void R_PolysetScanLeftEdge_C(int height)
Definition: r_polyse.c:291
edgetable
Definition: r_polyse.c:50
coloredlights
int coloredlights
Definition: r_main.c:156
d_pdest
byte * d_pdest
Definition: r_polyse.c:100
d_tfracbasestep
int d_tfracbasestep
Definition: r_polyse.c:106
R_PolysetDrawSpansConstant8_66
void R_PolysetDrawSpansConstant8_66(spanpackage_t *pspanpackage)
Definition: r_polyse.c:1156
a_tstepxfrac
int a_tstepxfrac
Definition: r_polyse.c:89
affinetridesc_t::skinwidth
int skinwidth
Definition: r_local.h:330
MAX_LBM_HEIGHT
#define MAX_LBM_HEIGHT
Definition: r_local.h:184
spanpackage_t
Definition: r_polyse.c:39
d_countextrastep
int d_countextrastep
Definition: r_polyse.c:95
lpdest
static byte * lpdest
Definition: r_polyse.c:922
d_lightextrastepr
int d_lightextrastepr
Definition: r_polyse.c:113
s
static fixed16_t s
Definition: r_scan.c:30
aliastriangleparms_t
Definition: r_local.h:770
a_spans
spanpackage_t * a_spans
Definition: r_polyse.c:97
d_lightbasestepr
int d_lightbasestepr
Definition: r_polyse.c:112
ystart
static int ystart
Definition: r_polyse.c:99
d_pdestbasestep
int d_pdestbasestep
Definition: r_polyse.c:105
R_PolysetScanLeftEdge
void R_PolysetScanLeftEdge(int height)
rand1k.h
d_ptexextrastep
int d_ptexextrastep
Definition: r_polyse.c:103
edgetable::pleftedgevert0
int * pleftedgevert0
Definition: r_polyse.c:53
aliastriangleparms_t::a
finalvert_t * a
Definition: r_local.h:772
R_PolysetDrawThreshSpans8
void R_PolysetDrawThreshSpans8(spanpackage_t *pspanpackage)
Definition: r_polyse.c:937
R_DrawNonSubdiv
void R_DrawNonSubdiv(void)
r_sstepy
int r_sstepy
Definition: r_polyse.c:90
llight
static int llight
Definition: r_polyse.c:924
trans
static int trans[3]
Definition: r_polyse.c:928
d_8to24table
unsigned d_8to24table[256]
Definition: r_main.c:27
d_pedgespanpackage
spanpackage_t * d_pedgespanpackage
Definition: r_polyse.c:98
edgetables
edgetable edgetables[12]
Definition: r_polyse.c:73
affinetridesc_t::vis_thresh
int vis_thresh
Definition: r_local.h:338
r_lgstepy
int r_lgstepy
Definition: r_polyse.c:93
spanpackage_t::pdest
void * pdest
Definition: r_polyse.c:40
d_lightextrastepg
int d_lightextrastepg
Definition: r_polyse.c:113
d_lightbasestep
int d_lightbasestep
Definition: r_polyse.c:105
finalvert_s::s
int s
Definition: r_local.h:293
fixed8_t
int fixed8_t
Definition: q_shared.h:138
FloorDivMod
void FloorDivMod(float numer, float denom, int *quotient, int *rem)
Definition: r_polyse.c:376
edgetable::pleftedgevert1
int * pleftedgevert1
Definition: r_polyse.c:54
d_lightextrastepb
int d_lightextrastepb
Definition: r_polyse.c:113
d_zwidth
unsigned int d_zwidth
Definition: r_local.h:538
aliastriangleparms_t::c
finalvert_t * c
Definition: r_local.h:772
adivtab_t
Definition: r_polyse.c:117
d_pz
short * d_pz
Definition: r_polyse.c:101
d_lightbasestepg
int d_lightbasestepg
Definition: r_polyse.c:112
iractive
byte iractive
Definition: r_polyse.c:148
d_light
int d_light
Definition: r_polyse.c:102
DPS_MAXSPANS
#define DPS_MAXSPANS
Definition: r_polyse.c:35
spanpackage_t::zi
int zi
Definition: r_polyse.c:44
R_PolysetSetEdgeTable
void R_PolysetSetEdgeTable(void)
Definition: r_polyse.c:1711
a_sstepxfrac
int a_sstepxfrac
Definition: r_polyse.c:89
spanpackage_t::ptex
byte * ptex
Definition: r_polyse.c:43
skintable
byte * skintable[MAX_LBM_HEIGHT]
Definition: r_polyse.c:126
d_sfrac
int d_sfrac
Definition: r_polyse.c:102
r_aliasblendcolor
int r_aliasblendcolor
Definition: r_alias.c:47
lpz
static short * lpz
Definition: r_polyse.c:926
r_lbstepy
int r_lbstepy
Definition: r_polyse.c:94
a_ststepxwhole
int a_ststepxwhole
Definition: r_polyse.c:89
R_DrawTriangle
void R_DrawTriangle(void)
Definition: r_polyse.c:218
r_tstepx
int r_tstepx
Definition: r_polyse.c:90
adivtab_t::quotient
int quotient
Definition: r_polyse.c:118
viddef_t::colormap
pixel_t * colormap
Definition: r_local.h:95
r_lrstepy
int r_lrstepy
Definition: r_polyse.c:92
d_pzbuffer
short * d_pzbuffer
Definition: r_main.c:197
edgetable::prightedgevert2
int * prightedgevert2
Definition: r_polyse.c:59
d_aspancount
int d_aspancount
Definition: r_polyse.c:95
lcount
static int lcount
Definition: r_polyse.c:920
viddef_t::alphamap
pixel_t * alphamap
Definition: r_local.h:96
spanpackage_t::light
int light
Definition: r_polyse.c:44
erroradjustdown
int erroradjustdown
Definition: r_edge.c:80
aliastriangleparms
aliastriangleparms_t aliastriangleparms
Definition: r_polyse.c:62
rand1k
int rand1k[]
Definition: r_polyse.c:25
rand1k_index
int rand1k_index
Definition: r_polyse.c:31
finalvert_s::l
int l
Definition: r_local.h:294
ubasestep
int ubasestep
Definition: r_edge.c:80
void
void(APIENTRY *qglAccum)(GLenum op
r_lrstepx
int r_lrstepx
Definition: r_polyse.c:92
affinetridesc_t::pskin
void * pskin
Definition: r_local.h:328
R_PolysetCalcGradients
void R_PolysetCalcGradients(int skinwidth)
Definition: r_polyse.c:844
vid
viddef_t vid
Definition: r_main.c:24
shadelight
float shadelight[3]
Definition: r_local.h:645