35 #define DPS_MAXSPANS MAXHEIGHT+1
44 int sfrac, tfrac, light,
zi;
149 byte irtable[256] = { 79, 78, 77, 76, 75, 74, 73, 72,
150 71, 70, 69, 68, 67, 66, 65, 64,
151 64, 65, 66, 67, 68, 69, 70, 71,
152 72, 73, 74, 75, 76, 77, 78, 79,
154 64, 65, 66, 67, 68, 69, 70, 71,
155 72, 73, 74, 75, 76, 77, 78, 79,
156 208, 208, 208, 208, 208, 208, 208, 208,
157 64, 66, 68, 70, 72, 74, 76, 78,
159 64, 65, 66, 67, 68, 69, 70, 71,
160 72, 73, 74, 75, 76, 77, 78, 79,
161 64, 65, 66, 67, 68, 69, 70, 71,
162 72, 73, 74, 75, 76, 77, 78, 79,
164 64, 66, 68, 70, 72, 74, 76, 78,
165 68, 67, 66, 65, 64, 65, 66, 67,
166 68, 69, 70, 71, 72, 73, 74, 75,
167 76, 76, 77, 77, 78, 78, 79, 79,
169 64, 65, 66, 67, 68, 69, 70, 71,
170 72, 73, 74, 75, 76, 77, 78, 79,
171 64, 65, 66, 67, 68, 69, 70, 71,
172 72, 73, 74, 75, 76, 77, 78, 79,
174 64, 65, 66, 67, 68, 69, 70, 71,
175 72, 73, 74, 75, 76, 77, 78, 79,
176 64, 65, 66, 67, 68, 69, 70, 71,
177 72, 73, 74, 75, 76, 77, 78, 79,
179 64, 65, 66, 67, 68, 69, 70, 71,
180 72, 73, 74, 75, 76, 77, 78, 79,
181 64, 65, 66, 67, 68, 69, 70, 71,
182 64, 65, 66, 67, 68, 69, 70, 71,
184 64, 65, 66, 67, 68, 69, 70, 71,
185 72, 73, 74, 75, 76, 77, 78, 79,
186 208, 208, 64, 64, 70, 71, 72, 64,
187 66, 68, 70, 64, 65, 66, 67, 68 };
233 if (!(dv0_ab | dv1_ab))
239 if (!(dv0_ac | dv1_ac))
242 d_xdenom = (dv0_ac * dv1_ab) - (dv0_ab * dv1_ac);
376 void FloorDivMod(
float numer,
float denom,
int *quotient,
int *rem)
384 x = floor(numer / denom);
386 r = (
int)floor(numer - (
x * denom));
393 x = floor(-numer / denom);
395 r = (
int)floor(-numer - (
x * denom));
424 tm = endvertu - startvertu;
425 tn = endvertv - startvertv;
427 if (((tm <= 16) && (tm >= -15)) &&
428 ((tn <= 16) && (tn >= -15)))
430 ptemp = &
adivtab[((tm + 15) << 5) + (tn + 15)];
454 #if id386 && !defined __linux__ && !defined __FreeBSD__
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;
462 extern unsigned long fpu_sp24_ceil_cw, fpu_ceil_cw, fpu_chop_cw;
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
501 __asm fldcw word ptr[fpu_sp24_ceil_cw]
506 __asm fst xstepdenominv;
507 __asm fmul negative_one; -(1 /
d_xdenom)
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]
525 __asm fstp ystepdenominv; (empty)
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
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
560 __asm fst xstepdenominv;
561 __asm fmul negative_one; -(1 /
d_xdenom)
563 __asm mov eax, dword ptr[
r_p0 + 24]
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]
568 __asm fstp ystepdenominv; (empty)
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
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
604 __asm fst xstepdenominv;
605 __asm fmul negative_one; -(1 /
d_xdenom)
607 __asm mov eax, dword ptr[
r_p0 + 28]
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]
612 __asm fstp ystepdenominv; (empty)
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
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
648 __asm fst xstepdenominv;
649 __asm fmul negative_one; -(1 /
d_xdenom)
651 __asm mov eax, dword ptr[
r_p0 + 32]
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]
656 __asm fstp ystepdenominv; (empty)
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
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
686 __asm fldcw word ptr[fpu_chop_cw]
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
706 __asm fst t1; (empty)
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
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]
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
745 __asm fst t1; (empty)
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
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]
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
784 __asm fst t1; (empty)
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
817 __asm jne translucent
821 __asm jmp done_with_steps
824 __asm and eax, 0ffffh
825 __asm and ebx, 0ffffh
846 float xstepdenominv, ystepdenominv, t0, t1;
847 float p01_minus_p21, p11_minus_p21, p00_minus_p20, p10_minus_p20;
854 xstepdenominv = 1.0 / (float)
d_xdenom;
856 ystepdenominv = -xstepdenominv;
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);
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);
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);
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);
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);
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);
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);
959 lpz = pspanpackage->
pz;
963 lzi = pspanpackage->
zi;
996 }
while (pspanpackage->
count != -999999);
1026 lpz = pspanpackage->
pz;
1030 lzi = pspanpackage->
zi;
1058 }
while (pspanpackage->
count != -999999);
1081 lpz = pspanpackage->
pz;
1082 lzi = pspanpackage->
zi;
1097 }
while (pspanpackage->
count != -999999);
1121 lpz = pspanpackage->
pz;
1125 lzi = pspanpackage->
zi;
1152 }
while (pspanpackage->
count != -999999);
1176 lpz = pspanpackage->
pz;
1177 lzi = pspanpackage->
zi;
1192 }
while (pspanpackage->
count != -999999);
1195 #if 1 //qb: no asm colored light support was- !id386
1220 lpz = pspanpackage->
pz;
1224 lzi = pspanpackage->
zi;
1235 int lptemp = *
lptex;
1267 }
while (pspanpackage->
count != -999999);
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;
1329 initialleftheight = pleftbottom[1] - plefttop[1];
1330 initialrightheight = prightbottom[1] - prighttop[1];
1357 d_sfrac = (plefttop[2] & 0xFFFF) << 16;
1358 d_tfrac = (plefttop[3] & 0xFFFF) << 16;
1364 d_sfrac = plefttop[2] & 0xFFFF;
1365 d_tfrac = plefttop[3] & 0xFFFF;
1379 if (initialleftheight == 1)
1403 pleftbottom[0], pleftbottom[1]);
1517 plefttop = pleftbottom;
1520 height = pleftbottom[1] - plefttop[1];
1564 pleftbottom[0], pleftbottom[1]);
1670 prightbottom[0], prightbottom[1]);
1683 pstart =
a_spans + initialrightheight;
1684 pstart->
count = originalcount;
1688 prighttop = prightbottom;
1691 height = prightbottom[1] - prighttop[1];
1694 prightbottom[0], prightbottom[1]);
1699 (*d_pdrawspans) (pstart);
1759 edgetableindex += 2;
1762 edgetableindex += 4;