1 ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
2 ;SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
3 ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
4 ;ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
5 ;IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
6 ;SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
7 ;FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
8 ;CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
9 ;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
10 ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
13 ; Perspective texture mapper inner loop.
19 global _asm_tmap_scanline_per
20 global asm_tmap_scanline_per
22 %include "tmap_inc.asm"
26 ;extern _per2_flag;:dword
28 ; Cater for ELF compilers...
30 %define _loop_count loop_count
31 %define _new_end new_end
32 %define _scan_doubling_flag scan_doubling_flag
33 %define _linear_if_far_flag linear_if_far_flag
39 global _scan_doubling_flag
40 global _linear_if_far_flag
51 ; _min_ecx dd 55555555h
52 _new_end dd 1 ; if set, use new, but slower, way of finishing off extra pixels on scanline, 01/10/95 --MK
54 _scan_doubling_flag dd 0
55 _linear_if_far_flag dd 0
57 ;---------- local variables
72 ; --------------------------------------------------------------------------------------------------
74 ; _xleft fixed point left x coordinate
75 ; _xright fixed point right x coordinate
76 ; _y fixed point y coordinate
77 ; _pixptr address of source pixel map
78 ; _u fixed point initial u coordinate
79 ; _v fixed point initial v coordinate
80 ; _z fixed point initial z coordinate
81 ; _du_dx fixed point du/dx
82 ; _dv_dx fixed point dv/dx
83 ; _dz_dx fixed point dz/dx
85 ; for (x = (int) xleft; x <= (int) xright; x++) {
86 ; _setcolor(read_pixel_from_tmap(srcb,((int) (u/z)) & 63,((int) (v/z)) & 63));
96 _asm_tmap_scanline_per:
97 asm_tmap_scanline_per:
101 ;---------------------------- setup for loop ---------------------------------
102 ; Setup for loop: _loop_count iterations = (int) xright - (int) xleft
103 ; esi source pixel pointer = pixptr
104 ; edi initial row pointer = y*320+x
105 ; NOTE: fx_xright and fx_xleft changed from fix to int by mk on 12/01/94.
107 ; set esi = pointer to start of texture map data
109 ; set edi = address of first pixel to modify
111 ; mov es,[_pixel_data_selector] ; selector[0*2]
113 mov edi,[_y_pointers+edi*4]
119 ebx_ok: add edi,[_write_buffer]
122 ; set _loop_count = # of iterations
126 mov [_loop_count],eax
128 ; lighting values are passed in fixed point, but need to be in 8 bit integer, 8 bit fraction so we can easily
129 ; get the integer by reading %bh
131 sar dword [_fx_dl_dx],8
133 inc dword [_fx_dl_dx] ; round towards 0 for negative deltas
141 test dword [_per2_flag],-1
144 test dword [_Lighting_on], -1
145 je near _tmap_loop_fast_nolight
147 ;tmap_loop_fast_nolight_jumper:
148 ; jmp tmap_loop_fast_nolight
150 ;================ PERSPECTIVE TEXTURE MAP INNER LOOPS ========================
152 ; Usage in loop: eax division, pixel value
157 ; esi source pixel pointer
158 ; edi destination pixel pointer
160 ;-------------------- NORMAL PERSPECTIVE TEXTURE MAP LOOP -----------------
162 mov esi, ebx ; esi becomes u coordinate
167 ; compute v coordinate
171 idiv ecx ; eax = (v/z)
173 and eax,3fh ; mask with height-1
176 ; compute u coordinate
180 idiv ecx ; eax = (u/z)
183 shld ebx,eax,6 ; esi = v*64+u
188 test dword [_Lighting_on], -1
189 mov al, [ebx] ; get pixel from source bitmap
193 mov ebx, [_fx_l] ; get temp copy of lighting value
194 mov ah, bh ; get lighting level
195 add ebx, [_fx_dl_dx] ; update lighting value
196 mov al, [_gr_fade_table+eax] ; xlat pixel thru lighting tables
197 mov [_fx_l], ebx ; save temp copy of lighting value
210 je _div_0_abort ; would be dividing by 0, so abort
212 dec dword [_loop_count]
220 ; We detected a z=0 condition, which seems pretty bogus, don't you think?
221 ; So, we abort, but maybe we want to know about it.
225 ;-------------------------- PER/4 TMAPPER ----------------
228 ; U0 = u/w; V0 = v/w;
230 ; u += du_dx*4; v+= dv_dx*4
231 ; U1 = u/w; V1 = v/w;
232 ; DUDX = (U1-U0)/4; DVDX = (V1-V0)/4;
235 ; pixels = texmap[V0*64+U0];
236 ; U0 += DUDX; V0 += DVDX
238 ; pixels = (pixels<<8)+texmap[V0*64+U0];
239 ; U0 += DUDX; V0 += DVDX
241 ; pixels = (pixels<<8)+texmap[V0*64+U0];
242 ; U0 += DUDX; V0 += DVDX
244 ; pixels = (pixels<<8)+texmap[V0*64+U0];
250 NBITS equ 4 ; 2^NBITS pixels plotted per divide
251 ZSHIFT equ 4 ; precision used in PDIV macro
255 ; Returns EAX/ECX in 16.16 format in EAX. Trashes EDX
260 ; idiv ecx ; eax = (v/z)
264 global _tmap_loop_fast
266 ; -------------------------------------- Start of Getting Dword Aligned ----------------------------------------------
277 ; compute v coordinate
281 idiv ecx ; eax = (v/z)
283 and eax,3fh ; mask with height-1
286 ; compute u coordinate
290 idiv ecx ; eax = (u/z)
293 shld ebx,eax,6 ; esi = v*64+u
298 mov al, [ebx] ; get pixel from source bitmap
301 mov ebx, [_fx_l] ; get temp copy of lighting value
302 mov ah, bh ; get lighting level
303 add ebx, [_fx_dl_dx] ; update lighting value
304 mov [_fx_l], ebx ; save temp copy of lighting value
308 je skip2 ; this pixel is transparent, so don't write it (or light it)
310 mov al, [_gr_fade_table+eax] ; xlat pixel thru lighting tables
320 je _div_0_abort ; would be dividing by 0, so abort
322 dec dword [_loop_count]
327 ; -------------------------------------- End of Getting Dword Aligned ----------------------------------------------
331 mov eax, [_loop_count]
332 mov ebx, esi ; get fx_u [pentium pipelining]
335 and esi, (1 << NBITS) - 1
337 mov [num_left_over], esi
338 je near tmap_loop ; there are no 2^NBITS chunks, do divide/pixel for whole scanline
339 mov [_loop_count], eax ; _loop_count = pixels / NPIXS
341 ; compute initial v coordinate
346 idiv ecx ; eax = (v/z)
350 ; compute initial u coordinate
355 idiv ecx ; eax = (v/z)
359 ; Set deltas to NPIXS pixel increments
375 je near _div_0_abort ; would be dividing by 0, so abort
377 ; Done with ebx, ebp, ecx until next iteration
388 idiv ecx ; eax = (v/z)
390 mov ebx, eax ; ebx = U1 until pop's
397 idiv ecx ; eax = (v/z)
399 mov ecx, [U0] ; ecx = U0 until pop's
400 mov edi, [V0] ; edi = V0 until pop's
403 mov ebp, eax ; ebp = V1 until pop's
405 ; Make ESI = V0:U0 in 6:10,6:10 format
412 ; Make EDX = DV:DU in 6:10,6:10 format
418 shl edx, 10-NBITS ; EDX = V1-V0/ 4 in 6:10 int:frac
419 mov dx, ax ; put delta u in low word
421 ; Save the U1 and V1 so we don't have to divide on the next iteration
425 pop edi ; Restore EDI before using it
431 test dword [_Transparency_on],-1
435 mov eax, esi ; get u,v
436 shr eax, 26 ; shift out all but int(v)
437 shld ax,si,6 ; shift in u, shifting up v
438 add esi, edx ; inc u,v
440 movzx eax, byte [eax] ; get pixel from source bitmap
443 mov ah, bh ; form lighting table lookup value
444 add ebx, ebp ; update lighting value
445 mov al, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
451 mov eax, esi ; get u,v
452 shr eax, 26 ; shift out all but int(v)
453 shld ax,si,6 ; shift in u, shifting up v
454 add esi, edx ; inc u,v
456 movzx eax, byte [eax] ; get pixel from source bitmap
459 mov ah, bh ; form lighting table lookup value
460 add ebx, ebp ; update lighting value
461 mov al, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
468 %rep (2 << (NBITS-2))
469 ; local skip3,no_trans1
470 ; local skipa1,skipa2
476 ; -------------------------------------------------------
480 mov eax, esi ; get u,v
481 shr eax, 26 ; shift out all but int(v)
482 shld ax,si,6 ; shift in u, shifting up v
483 add esi, edx ; inc u,v
485 movzx eax, byte [eax] ; get pixel from source bitmap
486 mov ah, bh ; form lighting table lookup value
487 add ebx, ebp ; update lighting value
488 mov cl, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
491 mov eax, esi ; get u,v
492 shr eax, 26 ; shift out all but int(v)
493 shld ax,si,6 ; shift in u, shifting up v
494 add esi, edx ; inc u,v
496 movzx eax, byte [eax] ; get pixel from source bitmap
497 mov ah, bh ; form lighting table lookup value
498 add ebx, ebp ; update lighting value
499 mov ch, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
501 ; ----- This is about 1% faster than the above, and could probably be optimized more.
502 ; ----- Problem is, it gets the u,v coordinates backwards. What you would need to do
503 ; ----- is switch the packing of the u,v coordinates above (about 95 lines up).
504 ;----------; mov eax, esi
505 ;----------; shr ax, 10
506 ;----------; rol eax, 6
507 ;----------; mov dx, ax
508 ;----------; add esi, mem_edx
509 ;----------; mov dl, es:[edx]
510 ;----------; mov dh, bh
511 ;----------; add ebx, ebp
512 ;----------; mov cl, _gr_fade_table[edx]
514 ;----------; mov eax, esi
515 ;----------; shr ax, 10
516 ;----------; rol eax, 6
517 ;----------; mov dx, ax
518 ;----------; add esi, mem_edx
519 ;----------; mov dl, es:[edx]
520 ;----------; mov dh, bh
521 ;----------; add ebx, ebp
522 ;----------; mov ch, _gr_fade_table[edx]
524 ror ecx, 16 ; move to next double dest pixel position
527 %rep (1 << (NBITS-2))
532 mov [edi],ecx ; Draw 4 pixels to display
538 ; -------------------------------------------------------
545 dec dword [_loop_count]
549 test dword [num_left_over], -1
552 ; ----------------------------------------- Start of LeftOver Pixels ------------------------------------------
569 test dword [_new_end],-1
570 jne near NewDoEndPixels
580 ; this can happen because we added DZ1 to the current z, but dz1 represents dz for perhaps 16 pixels
581 ; though we might only plot one more pixel.
584 dep_loop: mov eax, [DU1]
603 push edi ; use edi as a temporary variable
605 cmp ecx,1 << (ZSHIFT+1)
607 mov ecx, 1 << (ZSHIFT+1)
616 idiv ecx ; eax = (v/z)
619 mov ebx, eax ; ebx = U1 until pop's
627 idiv ecx ; eax = (v/z)
630 mov ebp, eax ; ebp = V1 until pop's
632 mov ecx, [U0] ; ecx = U0 until pop's
633 mov edi, [V0] ; edi = V0 until pop's
635 ; Make ESI = V0:U0 in 6:10,6:10 format
642 ; Make EDX = DV:DU in 6:10,6:10 format
648 shl edx, 10-NBITS ; EDX = V1-V0/ 4 in 6:10 int:frac
649 mov dx, ax ; put delta u in low word
651 pop edi ; Restore EDI before using it
653 mov ecx, [num_left_over]
663 mov eax, esi ; get u,v
664 shr eax, 26 ; shift out all but int(v)
665 shld ax,si,6 ; shift in u, shifting up v
667 movzx eax, byte [eax] ; get pixel from source bitmap
668 add esi, edx ; inc u,v
669 mov ah, bh ; form lighting table lookup value
670 add ebx, ebp ; update lighting value
673 mov al, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
674 mov [edi+ITERATION], al ; write pixel
679 mov eax, esi ; get u,v
680 shr eax, 26 ; shift out all but int(v)
681 shld ax,si,6 ; shift in u, shifting up v
683 movzx eax, byte [eax] ; get pixel from source bitmap
684 add esi, edx ; inc u,v
685 mov ah, bh ; form lighting table lookup value
686 add ebx, [_fx_dl_dx] ; update lighting value
689 mov al, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
690 mov [edi+ITERATION+1], al ; write pixel
695 %rep (1 << (NBITS-1))
698 %assign ITERATION ITERATION + 2
702 ; Should never get here!!!!
706 ; ----------------------------------------- End of LeftOver Pixels ------------------------------------------
708 ; --BUGGY NEW--NewDoEndPixels:
709 ; --BUGGY NEW-- mov eax, num_left_over
710 ; --BUGGY NEW-- and num_left_over, 3
711 ; --BUGGY NEW-- shr eax, 2
712 ; --BUGGY NEW-- je NDEP_1
713 ; --BUGGY NEW-- mov _loop_count, eax
715 ; --BUGGY NEW--; do 4 pixels per hunk, not 16, so div deltas by 4 (16/4=4)
716 ; --BUGGY NEW-- shr DU1,2
717 ; --BUGGY NEW-- shr DV1,2
718 ; --BUGGY NEW-- shr DZ1,2
720 ; --BUGGY NEW--NDEP_TopOfLoop4:
721 ; --BUGGY NEW-- add ebx, DU1
722 ; --BUGGY NEW-- add ebp, DV1
723 ; --BUGGY NEW-- add ecx, DZ1
724 ; --BUGGY NEW-- je _div_0_abort ; would be dividing by 0, so abort
726 ; --BUGGY NEW--; Done with ebx, ebp, ecx until next iteration
727 ; --BUGGY NEW-- push ebx
728 ; --BUGGY NEW-- push ecx
729 ; --BUGGY NEW-- push ebp
730 ; --BUGGY NEW-- push edi
732 ; --BUGGY NEW--; Find fixed U1
733 ; --BUGGY NEW-- mov eax, ebx
734 ; --BUGGY NEW-- mov edx,ebx
735 ; --BUGGY NEW-- shl eax,(ZSHIFT-2)
736 ; --BUGGY NEW-- sar edx,32-(ZSHIFT-2)
737 ; --BUGGY NEW-- idiv ecx ; eax = (v/z)
738 ; --BUGGY NEW-- shl eax, 16-(ZSHIFT-2)
739 ; --BUGGY NEW-- mov ebx, eax ; ebx = U1 until pop's
741 ; --BUGGY NEW--; Find fixed V1
742 ; --BUGGY NEW-- mov eax, ebp
743 ; --BUGGY NEW-- mov edx, ebp
744 ; --BUGGY NEW-- shl eax,(ZSHIFT-2)
745 ; --BUGGY NEW-- sar edx,32-(ZSHIFT-2)
746 ; --BUGGY NEW-- idiv ecx ; eax = (v/z)
748 ; --BUGGY NEW-- mov ecx, U0 ; ecx = U0 until pop's
749 ; --BUGGY NEW-- mov edi, V0 ; edi = V0 until pop's
751 ; --BUGGY NEW-- shl eax, 16-(ZSHIFT-2)
752 ; --BUGGY NEW-- mov ebp, eax ; ebp = V1 until pop's
754 ; --BUGGY NEW--; Make ESI = V0:U0 in 6:10,6:10 format
755 ; --BUGGY NEW-- mov eax, ecx
756 ; --BUGGY NEW-- shr eax, 6
757 ; --BUGGY NEW-- mov esi, edi
758 ; --BUGGY NEW-- shl esi, 10
759 ; --BUGGY NEW-- mov si, ax
761 ; --BUGGY NEW--; Make EDX = DV:DU in 6:10,6:10 format
762 ; --BUGGY NEW-- mov eax, ebx
763 ; --BUGGY NEW-- sub eax, ecx
764 ; --BUGGY NEW-- sar eax, (NBITS-2)+6
765 ; --BUGGY NEW-- mov edx, ebp
766 ; --BUGGY NEW-- sub edx, edi
767 ; --BUGGY NEW-- shl edx, 10-(NBITS-2) ; EDX = V1-V0/ 4 in 6:10 int:frac
768 ; --BUGGY NEW-- mov dx, ax ; put delta u in low word
770 ; --BUGGY NEW--; Save the U1 and V1 so we don't have to divide on the next iteration
771 ; --BUGGY NEW-- mov U0, ebx
772 ; --BUGGY NEW-- mov V0, ebp
774 ; --BUGGY NEW-- pop edi ; Restore EDI before using it
776 ; --BUGGY NEW--; LIGHTING CODE
777 ; --BUGGY NEW-- mov ebx, _fx_l
778 ; --BUGGY NEW-- mov ebp, _fx_dl_dx
780 ; --BUGGY NEW--;** test _Transparency_on,-1
781 ; --BUGGY NEW--;** je NDEP_no_trans1
783 ; --BUGGY NEW-- REPT 2
784 ; --BUGGY NEW-- local NDEP_skipa1, NDEP_skipa2
786 ; --BUGGY NEW-- mov eax, esi ; get u,v
787 ; --BUGGY NEW-- shr eax, 26 ; shift out all but int(v)
788 ; --BUGGY NEW-- shld ax,si,6 ; shift in u, shifting up v
789 ; --BUGGY NEW-- add esi, edx ; inc u,v
790 ; --BUGGY NEW-- mov al, es:[eax] ; get pixel from source bitmap
791 ; --BUGGY NEW-- cmp al,255
792 ; --BUGGY NEW-- je NDEP_skipa1
793 ; --BUGGY NEW-- mov ah, bh ; form lighting table lookup value
794 ; --BUGGY NEW-- add ebx, ebp ; update lighting value
795 ; --BUGGY NEW-- mov al, _gr_fade_table[eax] ; xlat thru lighting table into dest buffer
796 ; --BUGGY NEW-- mov [edi],al
797 ; --BUGGY NEW--NDEP_skipa1:
798 ; --BUGGY NEW-- inc edi
800 ; --BUGGY NEW--; Do odd pixel
801 ; --BUGGY NEW-- mov eax, esi ; get u,v
802 ; --BUGGY NEW-- shr eax, 26 ; shift out all but int(v)
803 ; --BUGGY NEW-- shld ax,si,6 ; shift in u, shifting up v
804 ; --BUGGY NEW-- add esi, edx ; inc u,v
805 ; --BUGGY NEW-- mov al, es:[eax] ; get pixel from source bitmap
806 ; --BUGGY NEW-- cmp al,255
807 ; --BUGGY NEW-- je NDEP_skipa2
808 ; --BUGGY NEW-- mov ah, bh ; form lighting table lookup value
809 ; --BUGGY NEW-- add ebx, ebp ; update lighting value
810 ; --BUGGY NEW-- mov al, _gr_fade_table[eax] ; xlat thru lighting table into dest buffer
811 ; --BUGGY NEW-- mov [edi],al
812 ; --BUGGY NEW--NDEP_skipa2:
813 ; --BUGGY NEW-- inc edi
817 ; --BUGGY NEW-- mov _fx_l, ebx
818 ; --BUGGY NEW-- pop ebp
819 ; --BUGGY NEW-- pop ecx
820 ; --BUGGY NEW-- pop ebx
821 ; --BUGGY NEW-- dec _loop_count
822 ; --BUGGY NEW-- jnz NDEP_TopOfLoop4
824 ; --BUGGY NEW-- test num_left_over, -1
825 ; --BUGGY NEW-- je _none_to_do
827 ; --BUGGY NEW--NDEP_1:
828 ; --BUGGY NEW-- mov esi,ebx
830 ; --BUGGY NEW-- align 4
831 ; --BUGGY NEW--NDEP_loop:
833 ; --BUGGY NEW--; compute v coordinate
834 ; --BUGGY NEW-- mov eax, ebp ; get v
835 ; --BUGGY NEW-- mov edx, eax
836 ; --BUGGY NEW-- sar edx, 31
837 ; --BUGGY NEW-- idiv ecx ; eax = (v/z)
839 ; --BUGGY NEW-- and eax,3fh ; mask with height-1
840 ; --BUGGY NEW-- mov ebx,eax
842 ; --BUGGY NEW--; compute u coordinate
843 ; --BUGGY NEW-- mov eax, esi ; get u
844 ; --BUGGY NEW-- mov edx, eax
845 ; --BUGGY NEW-- sar edx, 31
846 ; --BUGGY NEW-- idiv ecx ; eax = (u/z)
848 ; --BUGGY NEW-- shl eax,26
849 ; --BUGGY NEW-- shld ebx,eax,6 ; esi = v*64+u
851 ; --BUGGY NEW--; read 1 pixel
852 ; --BUGGY NEW-- xor eax, eax
853 ; --BUGGY NEW-- mov al, es:[ebx] ; get pixel from source bitmap
855 ; --BUGGY NEW--; lighting code
856 ; --BUGGY NEW-- mov ebx, _fx_l ; get temp copy of lighting value
857 ; --BUGGY NEW-- mov ah, bh ; get lighting level
858 ; --BUGGY NEW-- add ebx, _fx_dl_dx ; update lighting value
859 ; --BUGGY NEW-- mov _fx_l, ebx ; save temp copy of lighting value
861 ; --BUGGY NEW--; transparency check
862 ; --BUGGY NEW-- cmp al,255
863 ; --BUGGY NEW-- je NDEP_skip2 ; this pixel is transparent, so don't write it (or light it)
865 ; --BUGGY NEW-- mov al, _gr_fade_table[eax] ; xlat pixel thru lighting tables
867 ; --BUGGY NEW--; write 1 pixel
868 ; --BUGGY NEW-- mov [edi],al
869 ; --BUGGY NEW--NDEP_skip2: inc edi
871 ; --BUGGY NEW--; update deltas
872 ; --BUGGY NEW-- add ebp,_fx_dv_dx
873 ; --BUGGY NEW-- add esi,_fx_du_dx
874 ; --BUGGY NEW-- add ecx,_fx_dz_dx
875 ; --BUGGY NEW-- je _div_0_abort ; would be dividing by 0, so abort
877 ; --BUGGY NEW-- dec num_left_over
878 ; --BUGGY NEW-- jne NDEP_loop
880 ; --BUGGY NEW-- jmp _none_to_do
888 ; compute v coordinate
892 idiv ecx ; eax = (v/z)
894 and eax,3fh ; mask with height-1
897 ; compute u coordinate
901 idiv ecx ; eax = (u/z)
904 shld ebx,eax,6 ; esi = v*64+u
909 mov al, [ebx] ; get pixel from source bitmap
912 mov ebx, [_fx_l] ; get temp copy of lighting value
913 mov ah, bh ; get lighting level
914 add ebx, [_fx_dl_dx] ; update lighting value
915 mov [_fx_l], ebx ; save temp copy of lighting value
919 je NDEP_skip2 ; this pixel is transparent, so don't write it (or light it)
921 mov al, [_gr_fade_table+eax] ; xlat pixel thru lighting tables
931 je near _div_0_abort ; would be dividing by 0, so abort
933 dec dword [num_left_over]
938 ; ==================================================== No Lighting Code ======================================================
939 global _tmap_loop_fast_nolight
940 _tmap_loop_fast_nolight:
944 NotDwordAligned1_nolight:
946 jz DwordAligned1_nolight
948 ; compute v coordinate
952 idiv ecx ; eax = (v/z)
954 and eax,3fh ; mask with height-1
957 ; compute u coordinate
961 idiv ecx ; eax = (u/z)
964 shld ebx,eax,6 ; esi = v*64+u
968 mov al,[ebx] ; get pixel from source bitmap
980 je near _div_0_abort ; would be dividing by 0, so abort
982 dec dword [_loop_count]
983 jns NotDwordAligned1_nolight
986 DwordAligned1_nolight:
989 mov eax, [_loop_count]
991 mov [num_left_over], eax
995 je near tmap_loop ; no 2^NBITS chunks, do divide/pixel for whole scanline
997 mov [_loop_count], eax ; _loop_count = pixels / NPIXS
999 sub [num_left_over], eax ; num_left_over = obvious
1001 ; compute initial v coordinate
1007 idiv ecx ; eax = (v/z)
1012 ; compute initial u coordinate
1018 idiv ecx ; eax = (v/z)
1023 ; Set deltas to NPIXS pixel increments
1024 mov eax, [_fx_du_dx]
1027 mov eax, [_fx_dv_dx]
1030 mov eax, [_fx_dz_dx]
1039 je near _div_0_abort
1041 ; Done with ebx, ebp, ecx until next iteration
1053 idiv ecx ; eax = (v/z)
1056 mov ebx, eax ; ebx = U1 until pop's
1064 idiv ecx ; eax = (v/z)
1067 mov ebp, eax ; ebp = V1 until pop's
1069 mov ecx, [U0] ; ecx = U0 until pop's
1070 mov edi, [V0] ; edi = V0 until pop's
1072 ; Make ESI = V0:U0 in 6:10,6:10 format
1079 ; Make EDX = DV:DU in 6:10,6:10 format
1085 shl edx, 10-NBITS ; EDX = V1-V0/ 4 in 6:10 int:frac
1086 mov dx, ax ; put delta u in low word
1088 ; Save the U1 and V1 so we don't have to divide on the next iteration
1092 pop edi ; Restore EDI before using it
1096 mov eax, esi ; get u,v
1097 shr eax, 26 ; shift out all but int(v)
1098 shld ax,si,6 ; shift in u, shifting up v
1099 add esi, edx ; inc u,v
1101 mov cl, [eax] ; load into buffer register
1103 mov eax, esi ; get u,v
1104 shr eax, 26 ; shift out all but int(v)
1105 shld ax,si,6 ; shift in u, shifting up v
1107 mov ch, [eax] ; load into buffer register
1108 add esi, edx ; inc u,v
1109 ror ecx, 16 ; move to next dest pixel
1111 mov eax, esi ; get u,v
1112 shr eax, 26 ; shift out all but int(v)
1113 shld ax,si,6 ; shift in u, shifting up v
1115 mov cl, [eax] ; load into buffer register
1116 add esi, edx ; inc u,v
1118 mov eax, esi ; get u,v
1119 shr eax, 26 ; shift out all but int(v)
1120 shld ax,si,6 ; shift in u, shifting up v
1122 mov ch, [eax] ; load into buffer register
1123 add esi, edx ; inc u,v
1124 ror ecx, 16 ;-- can get rid of this, just write in different order below -- ; move to next dest pixel
1126 test dword [_Transparency_on],-1
1155 mov [edi],ecx ; Draw 4 pixels to display
1159 %rep (1 << (NBITS-2))
1160 ;local skip7, no_trans2, skip1q, skip2q, skip3q, skip4q
1168 dec dword [_loop_count]
1169 jnz near TopOfLoop4_nolight
1173 test dword [num_left_over], -1
1176 DoEndPixels_nolight:
1180 je near _div_0_abort
1181 push edi ; use edi as a temporary variable
1188 idiv ecx ; eax = (v/z)
1190 mov ebx, eax ; ebx = U1 until pop's
1197 idiv ecx ; eax = (v/z)
1199 mov ebp, eax ; ebp = V1 until pop's
1201 mov ecx, [U0] ; ecx = U0 until pop's
1202 mov edi, [V0] ; edi = V0 until pop's
1204 ; Make ESI = V0:U0 in 6:10,6:10 format
1211 ; Make EDX = DV:DU in 6:10,6:10 format
1217 shl edx, 10-NBITS ; EDX = V1-V0/ 4 in 6:10 int:frac
1218 mov dx, ax ; put delta u in low word
1220 pop edi ; Restore EDI before using it
1222 mov ecx, [num_left_over]
1227 mov eax, esi ; get u,v
1228 shr eax, 26 ; shift out all but int(v)
1229 shld ax,si,6 ; shift in u, shifting up v
1231 movzx eax, byte [eax] ; load into buffer register
1232 add esi, edx ; inc u,v
1235 mov [edi+ITERATION], al ; write pixel
1243 %assign ITERATION ITERATION + 1
1246 ; Should never get here!!!!!