Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 372afde46e
Fetching contributors…

Cannot retrieve contributors at this time

file 812 lines (683 sloc) 18.057 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812
 .386P
 .model FLAT
;
; d_polysa.s
; x86 assembly-language polygon model drawing code
;

include qasm.inc
include d_if.inc

if id386

; !!! if this is changed, it must be changed in d_polyse.c too !!!
;DPS_MAXSPANS equ (MAXHEIGHT+1)
; 1 extra for spanpackage that marks end

;SPAN_SIZE equ (((DPS_MAXSPANS + 1 + ((CACHE_SIZE - 1) / spanpackage_t_size)) + 1) * spanpackage_t_size)

MASK_1K equ 03FFh

_DATA SEGMENT

 align 4
;p10_minus_p20 dd 0
;p01_minus_p21 dd 0
;temp0 dd 0
;temp1 dd 0
;Ltemp dd 0

aff8entryvec_table dd LDraw8, LDraw7, LDraw6, LDraw5
 dd LDraw4, LDraw3, LDraw2, LDraw1, LDraw8IR, LDraw7IR, LDraw6IR, LDraw5IR, LDraw4IR, LDraw3IR, LDraw2IR, LDraw1IR

lzistepx dd 0

 externdef _rand1k:dword
 externdef _rand1k_index:dword
 externdef _alias_colormap:dword

;PGM
 externdef _irtable:dword
 externdef _iractive:byte
;PGM

_DATA ENDS
_TEXT SEGMENT


;----------------------------------------------------------------------
; 8-bpp horizontal span drawing code for affine polygons, with smooth
; shading and no transparency
;----------------------------------------------------------------------

;===================================
;===================================

pspans equ 4+8

 public _D_PolysetAff8Start
_D_PolysetAff8Start:

 public _R_PolysetDrawSpans8_Opaque
_R_PolysetDrawSpans8_Opaque:

 push esi ; preserve register variables
 push ebx

 mov esi,ds:dword ptr[pspans+esp] ; point to the first span descriptor
 mov ecx,ds:dword ptr[_r_zistepx]

 push ebp ; preserve caller's stack frame
 push edi

 ror ecx,16 ; put high 16 bits of 1/z step in low word
 mov edx,ds:dword ptr[spanpackage_t_count+esi]

 mov ds:dword ptr[lzistepx],ecx

LSpanLoop:

; lcount = d_aspancount - pspanpackage->count;
;
; errorterm += erroradjustup;
; if (errorterm >= 0)
; {
; d_aspancount += d_countextrastep;
; errorterm -= erroradjustdown;
; }
; else
; {
; d_aspancount += ubasestep;
; }

 mov eax,ds:dword ptr[_d_aspancount]
 sub eax,edx

 mov edx,ds:dword ptr[_erroradjustup]
 mov ebx,ds:dword ptr[_errorterm]
 add ebx,edx
 js LNoTurnover

 mov edx,ds:dword ptr[_erroradjustdown]
 mov edi,ds:dword ptr[_d_countextrastep]
 sub ebx,edx
 mov ebp,ds:dword ptr[_d_aspancount]
 mov ds:dword ptr[_errorterm],ebx
 add ebp,edi
 mov ds:dword ptr[_d_aspancount],ebp
 jmp LRightEdgeStepped

LNoTurnover:
 mov edi,ds:dword ptr[_d_aspancount]
 mov edx,ds:dword ptr[_ubasestep]
 mov ds:dword ptr[_errorterm],ebx
 add edi,edx
 mov ds:dword ptr[_d_aspancount],edi

LRightEdgeStepped:
 cmp eax,1

 jl LNextSpan
 jz LExactlyOneLong

;
; set up advancetable
;
 mov ecx,ds:dword ptr[_a_ststepxwhole]
 mov edx,ds:dword ptr[_r_affinetridesc+atd_skinwidth]

 mov ds:dword ptr[advancetable+4],ecx ; advance base in t
 add ecx,edx

 mov ds:dword ptr[advancetable],ecx ; advance extra in t
 mov ecx,ds:dword ptr[_a_tstepxfrac]

 mov cx,ds:word ptr[_r_lstepx]
 mov edx,eax ; count

 mov ds:dword ptr[tstep],ecx
 add edx,7

 shr edx,3 ; count of full and partial loops
 mov ebx,ds:dword ptr[spanpackage_t_sfrac+esi]

 mov bx,dx
 mov ecx,ds:dword ptr[spanpackage_t_pz+esi]

 neg eax

 mov edi,ds:dword ptr[spanpackage_t_pdest+esi]
 and eax,7 ; 0->0, 1->7, 2->6, ... , 7->1

 sub edi,eax ; compensate for hardwired offsets
 sub ecx,eax

 sub ecx,eax
 mov edx,ds:dword ptr[spanpackage_t_tfrac+esi]

 mov dx,ds:word ptr[spanpackage_t_light+esi]
 mov ebp,ds:dword ptr[spanpackage_t_zi+esi]

 ror ebp,16 ; put high 16 bits of 1/z in low word
 push esi

 push eax
 mov al, [_iractive]
 cmp al, 0
 pop eax
 jne IRInsert
 
 mov esi,ds:dword ptr[spanpackage_t_ptex+esi]
 jmp dword ptr[aff8entryvec_table+eax*4]

IRInsert:
 mov esi,ds:dword ptr[spanpackage_t_ptex+esi]
 add eax, 8
 jmp dword ptr[aff8entryvec_table+eax*4]

; %bx = count of full and partial loops
; %ebx high word = sfrac
; %ecx = pz
; %dx = light
; %edx high word = tfrac
; %esi = ptex
; %edi = pdest
; %ebp = 1/z
; tstep low word = C(r_lstepx)
; tstep high word = C(a_tstepxfrac)
; C(a_sstepxfrac) low word = 0
; C(a_sstepxfrac) high word = C(a_sstepxfrac)

;===
;Standard Draw Loop
;===
LDrawLoop:

 mov al,[_iractive]
 cmp al,0
 jne LDrawLoopIR

; FIXME: do we need to clamp light? We may need at least a buffer bit to
; keep it from poking into tfrac and causing problems

LDraw8:
 cmp bp,ds:word ptr[ecx]
 jl Lp1
 xor eax,eax
 mov ah,dh
 mov al,ds:byte ptr[esi]
 mov ds:word ptr[ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch8:
 mov ds:byte ptr[edi],al
Lp1:
 add edx,ds:dword ptr[tstep]
 sbb eax,eax
 add ebp,ds:dword ptr[lzistepx]
 adc ebp,0
 add ebx,ds:dword ptr[_a_sstepxfrac]
 adc esi,ds:dword ptr[advancetable+4+eax*4]

LDraw7:
 cmp bp,ds:word ptr[2+ecx]
 jl Lp2
 xor eax,eax
 mov ah,dh
 mov al,ds:byte ptr[esi]
 mov ds:word ptr[2+ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch7:
 mov ds:byte ptr[1+edi],al
Lp2:
 add edx,ds:dword ptr[tstep]
 sbb eax,eax
 add ebp,ds:dword ptr[lzistepx]
 adc ebp,0
 add ebx,ds:dword ptr[_a_sstepxfrac]
 adc esi,ds:dword ptr[advancetable+4+eax*4]

LDraw6:
 cmp bp,ds:word ptr[4+ecx]
 jl Lp3
 xor eax,eax
 mov ah,dh
 mov al,ds:byte ptr[esi]
 mov ds:word ptr[4+ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch6:
 mov ds:byte ptr[2+edi],al
Lp3:
 add edx,ds:dword ptr[tstep]
 sbb eax,eax
 add ebp,ds:dword ptr[lzistepx]
 adc ebp,0
 add ebx,ds:dword ptr[_a_sstepxfrac]
 adc esi,ds:dword ptr[advancetable+4+eax*4]

LDraw5:
 cmp bp,ds:word ptr[6+ecx]
 jl Lp4
 xor eax,eax
 mov ah,dh
 mov al,ds:byte ptr[esi]
 mov ds:word ptr[6+ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch5:
 mov ds:byte ptr[3+edi],al
Lp4:
 add edx,ds:dword ptr[tstep]
 sbb eax,eax
 add ebp,ds:dword ptr[lzistepx]
 adc ebp,0
 add ebx,ds:dword ptr[_a_sstepxfrac]
 adc esi,ds:dword ptr[advancetable+4+eax*4]

LDraw4:
 cmp bp,ds:word ptr[8+ecx]
 jl Lp5
 xor eax,eax
 mov ah,dh
 mov al,ds:byte ptr[esi]
 mov ds:word ptr[8+ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch4:
 mov ds:byte ptr[4+edi],al
Lp5:
 add edx,ds:dword ptr[tstep]
 sbb eax,eax
 add ebp,ds:dword ptr[lzistepx]
 adc ebp,0
 add ebx,ds:dword ptr[_a_sstepxfrac]
 adc esi,ds:dword ptr[advancetable+4+eax*4]

LDraw3:
 cmp bp,ds:word ptr[10+ecx]
 jl Lp6
 xor eax,eax
 mov ah,dh
 mov al,ds:byte ptr[esi]
 mov ds:word ptr[10+ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch3:
 mov ds:byte ptr[5+edi],al
Lp6:
 add edx,ds:dword ptr[tstep]
 sbb eax,eax
 add ebp,ds:dword ptr[lzistepx]
 adc ebp,0
 add ebx,ds:dword ptr[_a_sstepxfrac]
 adc esi,ds:dword ptr[advancetable+4+eax*4]

LDraw2:
 cmp bp,ds:word ptr[12+ecx]
 jl Lp7
 xor eax,eax
 mov ah,dh
 mov al,ds:byte ptr[esi]
 mov ds:word ptr[12+ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch2:
 mov ds:byte ptr[6+edi],al
Lp7:
 add edx,ds:dword ptr[tstep]
 sbb eax,eax
 add ebp,ds:dword ptr[lzistepx]
 adc ebp,0
 add ebx,ds:dword ptr[_a_sstepxfrac]
 adc esi,ds:dword ptr[advancetable+4+eax*4]

LDraw1:
 cmp bp,ds:word ptr[14+ecx]
 jl Lp8
 xor eax,eax
 mov ah,dh
 mov al,ds:byte ptr[esi]
 mov ds:word ptr[14+ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch1:
 mov ds:byte ptr[7+edi],al
Lp8:
 add edx,ds:dword ptr[tstep]
 sbb eax,eax
 add ebp,ds:dword ptr[lzistepx]
 adc ebp,0
 add ebx,ds:dword ptr[_a_sstepxfrac]
 adc esi,ds:dword ptr[advancetable+4+eax*4]

 add edi,8
 add ecx,16

 dec bx
 jnz LDrawLoop

 pop esi ; restore spans pointer
LNextSpan:
 add esi,offset spanpackage_t_size ; point to next span
LNextSpanESISet:
 mov edx,ds:dword ptr[spanpackage_t_count+esi]
 cmp edx,offset -999999 ; any more spans?
 jnz LSpanLoop ; yes

 pop edi
 pop ebp ; restore the caller's stack frame
 pop ebx ; restore register variables
 pop esi
 ret

;=======
; IR active draw loop
;=======
LDrawLoopIR:

; FIXME: do we need to clamp light? We may need at least a buffer bit to
; keep it from poking into tfrac and causing problems

LDraw8IR:
 cmp bp,ds:word ptr[ecx]
 jl Lp1IR
 xor eax,eax
 mov al,ds:byte ptr[esi]
 mov al,ds:byte ptr[_irtable+eax]
 mov ds:word ptr[ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch8IR:
 mov ds:byte ptr[edi],al
Lp1IR:
 add edx,ds:dword ptr[tstep]
 sbb eax,eax
 add ebp,ds:dword ptr[lzistepx]
 adc ebp,0
 add ebx,ds:dword ptr[_a_sstepxfrac]
 adc esi,ds:dword ptr[advancetable+4+eax*4]

LDraw7IR:
 cmp bp,ds:word ptr[2+ecx]
 jl Lp2IR
 xor eax,eax
 mov al,ds:byte ptr[esi]
 mov al,ds:byte ptr[_irtable+eax]
 mov ds:word ptr[2+ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch7IR:
 mov ds:byte ptr[1+edi],al
Lp2IR:
 add edx,ds:dword ptr[tstep]
 sbb eax,eax
 add ebp,ds:dword ptr[lzistepx]
 adc ebp,0
 add ebx,ds:dword ptr[_a_sstepxfrac]
 adc esi,ds:dword ptr[advancetable+4+eax*4]

LDraw6IR:
 cmp bp,ds:word ptr[4+ecx]
 jl Lp3IR
 xor eax,eax
 mov al,ds:byte ptr[esi]
 mov al,ds:byte ptr[_irtable+eax]
 mov ds:word ptr[4+ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch6IR:
 mov ds:byte ptr[2+edi],al
Lp3IR:
 add edx,ds:dword ptr[tstep]
 sbb eax,eax
 add ebp,ds:dword ptr[lzistepx]
 adc ebp,0
 add ebx,ds:dword ptr[_a_sstepxfrac]
 adc esi,ds:dword ptr[advancetable+4+eax*4]

LDraw5IR:
 cmp bp,ds:word ptr[6+ecx]
 jl Lp4IR
 xor eax,eax
 mov al,ds:byte ptr[esi]
 mov al,ds:byte ptr[_irtable+eax]
 mov ds:word ptr[6+ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch5IR:
 mov ds:byte ptr[3+edi],al
Lp4IR:
 add edx,ds:dword ptr[tstep]
 sbb eax,eax
 add ebp,ds:dword ptr[lzistepx]
 adc ebp,0
 add ebx,ds:dword ptr[_a_sstepxfrac]
 adc esi,ds:dword ptr[advancetable+4+eax*4]

LDraw4IR:
 cmp bp,ds:word ptr[8+ecx]
 jl Lp5IR
 xor eax,eax
 mov al,ds:byte ptr[esi]
 mov al,ds:byte ptr[_irtable+eax]
 mov ds:word ptr[8+ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch4IR:
 mov ds:byte ptr[4+edi],al
Lp5IR:
 add edx,ds:dword ptr[tstep]
 sbb eax,eax
 add ebp,ds:dword ptr[lzistepx]
 adc ebp,0
 add ebx,ds:dword ptr[_a_sstepxfrac]
 adc esi,ds:dword ptr[advancetable+4+eax*4]

LDraw3IR:
 cmp bp,ds:word ptr[10+ecx]
 jl Lp6IR
 xor eax,eax
 mov al,ds:byte ptr[esi]
 mov al,ds:byte ptr[_irtable+eax]
 mov ds:word ptr[10+ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch3IR:
 mov ds:byte ptr[5+edi],al
Lp6IR:
 add edx,ds:dword ptr[tstep]
 sbb eax,eax
 add ebp,ds:dword ptr[lzistepx]
 adc ebp,0
 add ebx,ds:dword ptr[_a_sstepxfrac]
 adc esi,ds:dword ptr[advancetable+4+eax*4]

LDraw2IR:
 cmp bp,ds:word ptr[12+ecx]
 jl Lp7IR
 xor eax,eax
 mov al,ds:byte ptr[esi]
 mov al,ds:byte ptr[_irtable+eax]
 mov ds:word ptr[12+ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch2IR:
 mov ds:byte ptr[6+edi],al
Lp7IR:
 add edx,ds:dword ptr[tstep]
 sbb eax,eax
 add ebp,ds:dword ptr[lzistepx]
 adc ebp,0
 add ebx,ds:dword ptr[_a_sstepxfrac]
 adc esi,ds:dword ptr[advancetable+4+eax*4]

LDraw1IR:
 cmp bp,ds:word ptr[14+ecx]
 jl Lp8IR
 xor eax,eax
 mov al,ds:byte ptr[esi]
 mov al,ds:byte ptr[_irtable+eax]
 mov ds:word ptr[14+ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch1IR:
 mov ds:byte ptr[7+edi],al
Lp8IR:
 add edx,ds:dword ptr[tstep]
 sbb eax,eax
 add ebp,ds:dword ptr[lzistepx]
 adc ebp,0
 add ebx,ds:dword ptr[_a_sstepxfrac]
 adc esi,ds:dword ptr[advancetable+4+eax*4]

 add edi,8
 add ecx,16

 dec bx
 jnz LDrawLoopIR

 pop esi ; restore spans pointer
LNextSpanIR:
 add esi,offset spanpackage_t_size ; point to next span
LNextSpanESISetIR:
 mov edx,ds:dword ptr[spanpackage_t_count+esi]
 cmp edx,offset -999999 ; any more spans?
 jnz LSpanLoop ; yes

 pop edi
 pop ebp ; restore the caller's stack frame
 pop ebx ; restore register variables
 pop esi
 ret

;=======
; Standard One-Long Draw
;=======
; draw a one-long span

LExactlyOneLong:
 mov al,[_iractive]
 cmp al,0
 jne LExactlyOneLongIR

 mov ecx,ds:dword ptr[spanpackage_t_pz+esi]
 mov ebp,ds:dword ptr[spanpackage_t_zi+esi]

 ror ebp,16 ; put high 16 bits of 1/z in low word
 mov ebx,ds:dword ptr[spanpackage_t_ptex+esi]

 cmp bp,ds:word ptr[ecx]
 jl LNextSpan
 xor eax,eax
 mov edi,ds:dword ptr[spanpackage_t_pdest+esi]
 mov ah,ds:byte ptr[spanpackage_t_light+1+esi]
 add esi,offset spanpackage_t_size ; point to next span
 mov al,ds:byte ptr[ebx]
 mov ds:word ptr[ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch9:
 mov ds:byte ptr[edi],al

 jmp LNextSpanESISet


;========
;========
; draw a one-long span

LExactlyOneLongIR:

 mov ecx,ds:dword ptr[spanpackage_t_pz+esi]
 mov ebp,ds:dword ptr[spanpackage_t_zi+esi]

 ror ebp,16 ; put high 16 bits of 1/z in low word
 mov ebx,ds:dword ptr[spanpackage_t_ptex+esi]

 cmp bp,ds:word ptr[ecx]
 jl LNextSpanIR
 xor eax,eax
 mov edi,ds:dword ptr[spanpackage_t_pdest+esi]
 add esi,offset spanpackage_t_size ; point to next span
 mov al,ds:byte ptr[ebx]
 mov al,ds:byte ptr[_irtable+eax]
 mov ds:word ptr[ecx],bp
 mov al,ds:byte ptr[12345678h+eax]
LPatch9IR:
 mov ds:byte ptr[edi],al

 jmp LNextSpanESISetIR

;===================================
;===================================
 public _D_Aff8Patch
_D_Aff8Patch:
 mov eax,[_alias_colormap]
 mov ds:dword ptr[LPatch1-4],eax
 mov ds:dword ptr[LPatch2-4],eax
 mov ds:dword ptr[LPatch3-4],eax
 mov ds:dword ptr[LPatch4-4],eax
 mov ds:dword ptr[LPatch5-4],eax
 mov ds:dword ptr[LPatch6-4],eax
 mov ds:dword ptr[LPatch7-4],eax
 mov ds:dword ptr[LPatch8-4],eax
 mov ds:dword ptr[LPatch9-4],eax
 mov ds:dword ptr[LPatch1IR-4],eax
 mov ds:dword ptr[LPatch2IR-4],eax
 mov ds:dword ptr[LPatch3IR-4],eax
 mov ds:dword ptr[LPatch4IR-4],eax
 mov ds:dword ptr[LPatch5IR-4],eax
 mov ds:dword ptr[LPatch6IR-4],eax
 mov ds:dword ptr[LPatch7IR-4],eax
 mov ds:dword ptr[LPatch8IR-4],eax
 mov ds:dword ptr[LPatch9IR-4],eax

 ret



;===================================
;===================================

height equ 4+16

 public _R_PolysetScanLeftEdge
_R_PolysetScanLeftEdge:
 push ebp ; preserve caller stack frame pointer
 push esi ; preserve register variables
 push edi
 push ebx

 mov eax,ds:dword ptr[height+esp]
 mov ecx,ds:dword ptr[_d_sfrac]

 and eax,0FFFFh
 mov ebx,ds:dword ptr[_d_ptex]
 or ecx,eax
 mov esi,ds:dword ptr[_d_pedgespanpackage]
 mov edx,ds:dword ptr[_d_tfrac]
 mov edi,ds:dword ptr[_d_light]
 mov ebp,ds:dword ptr[_d_zi]

; %eax: scratch
; %ebx: d_ptex
; %ecx: d_sfrac in high word, count in low word
; %edx: d_tfrac
; %esi: d_pedgespanpackage, errorterm, scratch alternately
; %edi: d_light
; %ebp: d_zi

; do
; {

LScanLoop:

; d_pedgespanpackage->ptex = ptex;
; d_pedgespanpackage->pdest = d_pdest;
; d_pedgespanpackage->pz = d_pz;
; d_pedgespanpackage->count = d_aspancount;
; d_pedgespanpackage->light = d_light;
; d_pedgespanpackage->zi = d_zi;
; d_pedgespanpackage->sfrac = d_sfrac << 16;
; d_pedgespanpackage->tfrac = d_tfrac << 16;
 mov ds:dword ptr[spanpackage_t_ptex+esi],ebx
 mov eax,ds:dword ptr[_d_pdest]
 mov ds:dword ptr[spanpackage_t_pdest+esi],eax
 mov eax,ds:dword ptr[_d_pz]
 mov ds:dword ptr[spanpackage_t_pz+esi],eax
 mov eax,ds:dword ptr[_d_aspancount]
 mov ds:dword ptr[spanpackage_t_count+esi],eax
 mov ds:dword ptr[spanpackage_t_light+esi],edi
 mov ds:dword ptr[spanpackage_t_zi+esi],ebp
 mov ds:dword ptr[spanpackage_t_sfrac+esi],ecx
 mov ds:dword ptr[spanpackage_t_tfrac+esi],edx

; pretouch the next cache line
 mov al,ds:byte ptr[spanpackage_t_size+esi]

; d_pedgespanpackage++;
 add esi,offset spanpackage_t_size
 mov eax,ds:dword ptr[_erroradjustup]
 mov ds:dword ptr[_d_pedgespanpackage],esi

; errorterm += erroradjustup;
 mov esi,ds:dword ptr[_errorterm]
 add esi,eax
 mov eax,ds:dword ptr[_d_pdest]

; if (errorterm >= 0)
; {
 js LNoLeftEdgeTurnover

; errorterm -= erroradjustdown;
; d_pdest += d_pdestextrastep;
 sub esi,ds:dword ptr[_erroradjustdown]
 add eax,ds:dword ptr[_d_pdestextrastep]
 mov ds:dword ptr[_errorterm],esi
 mov ds:dword ptr[_d_pdest],eax

; d_pz += d_pzextrastep;
; d_aspancount += d_countextrastep;
; d_ptex += d_ptexextrastep;
; d_sfrac += d_sfracextrastep;
; d_ptex += d_sfrac >> 16;
; d_sfrac &= 0xFFFF;
; d_tfrac += d_tfracextrastep;
 mov eax,ds:dword ptr[_d_pz]
 mov esi,ds:dword ptr[_d_aspancount]
 add eax,ds:dword ptr[_d_pzextrastep]
 add ecx,ds:dword ptr[_d_sfracextrastep]
 adc ebx,ds:dword ptr[_d_ptexextrastep]
 add esi,ds:dword ptr[_d_countextrastep]
 mov ds:dword ptr[_d_pz],eax
 mov eax,ds:dword ptr[_d_tfracextrastep]
 mov ds:dword ptr[_d_aspancount],esi
 add edx,eax

; if (d_tfrac & 0x10000)
; {
 jnc LSkip1

; d_ptex += r_affinetridesc.skinwidth;
; d_tfrac &= 0xFFFF;
 add ebx,ds:dword ptr[_r_affinetridesc+atd_skinwidth]

; }

LSkip1:

; d_light += d_lightextrastep;
; d_zi += d_ziextrastep;
 add edi,ds:dword ptr[_d_lightextrastep]
 add ebp,ds:dword ptr[_d_ziextrastep]

; }
 mov esi,ds:dword ptr[_d_pedgespanpackage]
 dec ecx
 test ecx,0FFFFh
 jnz LScanLoop

 pop ebx
 pop edi
 pop esi
 pop ebp
 ret

; else
; {

LNoLeftEdgeTurnover:
 mov ds:dword ptr[_errorterm],esi

; d_pdest += d_pdestbasestep;
 add eax,ds:dword ptr[_d_pdestbasestep]
 mov ds:dword ptr[_d_pdest],eax

; d_pz += d_pzbasestep;
; d_aspancount += ubasestep;
; d_ptex += d_ptexbasestep;
; d_sfrac += d_sfracbasestep;
; d_ptex += d_sfrac >> 16;
; d_sfrac &= 0xFFFF;
 mov eax,ds:dword ptr[_d_pz]
 mov esi,ds:dword ptr[_d_aspancount]
 add eax,ds:dword ptr[_d_pzbasestep]
 add ecx,ds:dword ptr[_d_sfracbasestep]
 adc ebx,ds:dword ptr[_d_ptexbasestep]
 add esi,ds:dword ptr[_ubasestep]
 mov ds:dword ptr[_d_pz],eax
 mov ds:dword ptr[_d_aspancount],esi

; d_tfrac += d_tfracbasestep;
 mov esi,ds:dword ptr[_d_tfracbasestep]
 add edx,esi

; if (d_tfrac & 0x10000)
; {
 jnc LSkip2

; d_ptex += r_affinetridesc.skinwidth;
; d_tfrac &= 0xFFFF;
 add ebx,ds:dword ptr[_r_affinetridesc+atd_skinwidth]

; }

LSkip2:

; d_light += d_lightbasestep;
; d_zi += d_zibasestep;
 add edi,ds:dword ptr[_d_lightbasestep]
 add ebp,ds:dword ptr[_d_zibasestep]

; }
; } while (--height);
 mov esi,ds:dword ptr[_d_pedgespanpackage]
 dec ecx
 test ecx,0FFFFh
 jnz LScanLoop

 pop ebx
 pop edi
 pop esi
 pop ebp
 ret

_TEXT ENDS
endif ;id386
 END
Something went wrong with that request. Please try again.