1 ; $Id: tmap_per.asm,v 1.5 2004-08-28 23:17:46 schaffner Exp $
2 ;THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 ;SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 ;END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ;ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 ;IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 ;SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 ;FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 ;CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 ;AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 ;COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
14 ; Perspective texture mapper inner loop.
20 global _asm_tmap_scanline_per
21 global asm_tmap_scanline_per
23 %include "tmap_inc.asm"
27 ;extern _per2_flag;:dword
29 ; Cater for ELF compilers...
31 %define _loop_count loop_count
32 %define _new_end new_end
33 %define _scan_doubling_flag scan_doubling_flag
34 %define _linear_if_far_flag linear_if_far_flag
40 global _scan_doubling_flag
41 global _linear_if_far_flag
52 ; _min_ecx dd 55555555h
53 _new_end dd 1 ; if set, use new, but slower, way of finishing off extra pixels on scanline, 01/10/95 --MK
55 _scan_doubling_flag dd 0
56 _linear_if_far_flag dd 0
58 ;---------- local variables
73 ; --------------------------------------------------------------------------------------------------
75 ; _xleft fixed point left x coordinate
76 ; _xright fixed point right x coordinate
77 ; _y fixed point y coordinate
78 ; _pixptr address of source pixel map
79 ; _u fixed point initial u coordinate
80 ; _v fixed point initial v coordinate
81 ; _z fixed point initial z coordinate
82 ; _du_dx fixed point du/dx
83 ; _dv_dx fixed point dv/dx
84 ; _dz_dx fixed point dz/dx
86 ; for (x = (int) xleft; x <= (int) xright; x++) {
87 ; _setcolor(read_pixel_from_tmap(srcb,((int) (u/z)) & 63,((int) (v/z)) & 63));
97 _asm_tmap_scanline_per:
98 asm_tmap_scanline_per:
102 ;---------------------------- setup for loop ---------------------------------
103 ; Setup for loop: _loop_count iterations = (int) xright - (int) xleft
104 ; esi source pixel pointer = pixptr
105 ; edi initial row pointer = y*320+x
106 ; NOTE: fx_xright and fx_xleft changed from fix to int by mk on 12/01/94.
108 ; set esi = pointer to start of texture map data
110 ; set edi = address of first pixel to modify
112 ; mov es,[_pixel_data_selector] ; selector[0*2]
114 mov edi,[_y_pointers+edi*4]
120 ebx_ok: add edi,[_write_buffer]
123 ; set _loop_count = # of iterations
127 mov [_loop_count],eax
129 ; lighting values are passed in fixed point, but need to be in 8 bit integer, 8 bit fraction so we can easily
130 ; get the integer by reading %bh
132 sar dword [_fx_dl_dx],8
134 inc dword [_fx_dl_dx] ; round towards 0 for negative deltas
142 test dword [_per2_flag],-1
145 test dword [_Lighting_on], -1
146 je near _tmap_loop_fast_nolight
148 ;tmap_loop_fast_nolight_jumper:
149 ; jmp tmap_loop_fast_nolight
151 ;================ PERSPECTIVE TEXTURE MAP INNER LOOPS ========================
153 ; Usage in loop: eax division, pixel value
158 ; esi source pixel pointer
159 ; edi destination pixel pointer
161 ;-------------------- NORMAL PERSPECTIVE TEXTURE MAP LOOP -----------------
163 mov esi, ebx ; esi becomes u coordinate
168 ; compute v coordinate
172 idiv ecx ; eax = (v/z)
174 and eax,3fh ; mask with height-1
177 ; compute u coordinate
181 idiv ecx ; eax = (u/z)
184 shld ebx,eax,6 ; esi = v*64+u
189 test dword [_Lighting_on], -1
190 mov al, [ebx] ; get pixel from source bitmap
194 mov ebx, [_fx_l] ; get temp copy of lighting value
195 mov ah, bh ; get lighting level
196 add ebx, [_fx_dl_dx] ; update lighting value
197 mov al, [_gr_fade_table+eax] ; xlat pixel thru lighting tables
198 mov [_fx_l], ebx ; save temp copy of lighting value
211 je _div_0_abort ; would be dividing by 0, so abort
213 dec dword [_loop_count]
221 ; We detected a z=0 condition, which seems pretty bogus, don't you think?
222 ; So, we abort, but maybe we want to know about it.
226 ;-------------------------- PER/4 TMAPPER ----------------
229 ; U0 = u/w; V0 = v/w;
231 ; u += du_dx*4; v+= dv_dx*4
232 ; U1 = u/w; V1 = v/w;
233 ; DUDX = (U1-U0)/4; DVDX = (V1-V0)/4;
236 ; pixels = texmap[V0*64+U0];
237 ; U0 += DUDX; V0 += DVDX
239 ; pixels = (pixels<<8)+texmap[V0*64+U0];
240 ; U0 += DUDX; V0 += DVDX
242 ; pixels = (pixels<<8)+texmap[V0*64+U0];
243 ; U0 += DUDX; V0 += DVDX
245 ; pixels = (pixels<<8)+texmap[V0*64+U0];
251 NBITS equ 4 ; 2^NBITS pixels plotted per divide
252 ZSHIFT equ 4 ; precision used in PDIV macro
256 ; Returns EAX/ECX in 16.16 format in EAX. Trashes EDX
261 ; idiv ecx ; eax = (v/z)
265 global _tmap_loop_fast
267 ; -------------------------------------- Start of Getting Dword Aligned ----------------------------------------------
278 ; compute v coordinate
282 idiv ecx ; eax = (v/z)
284 and eax,3fh ; mask with height-1
287 ; compute u coordinate
291 idiv ecx ; eax = (u/z)
294 shld ebx,eax,6 ; esi = v*64+u
299 mov al, [ebx] ; get pixel from source bitmap
302 mov ebx, [_fx_l] ; get temp copy of lighting value
303 mov ah, bh ; get lighting level
304 add ebx, [_fx_dl_dx] ; update lighting value
305 mov [_fx_l], ebx ; save temp copy of lighting value
309 je skip2 ; this pixel is transparent, so don't write it (or light it)
311 mov al, [_gr_fade_table+eax] ; xlat pixel thru lighting tables
321 je _div_0_abort ; would be dividing by 0, so abort
323 dec dword [_loop_count]
328 ; -------------------------------------- End of Getting Dword Aligned ----------------------------------------------
332 mov eax, [_loop_count]
333 mov ebx, esi ; get fx_u [pentium pipelining]
336 and esi, (1 << NBITS) - 1
338 mov [num_left_over], esi
339 je near tmap_loop ; there are no 2^NBITS chunks, do divide/pixel for whole scanline
340 mov [_loop_count], eax ; _loop_count = pixels / NPIXS
342 ; compute initial v coordinate
347 idiv ecx ; eax = (v/z)
351 ; compute initial u coordinate
356 idiv ecx ; eax = (v/z)
360 ; Set deltas to NPIXS pixel increments
376 je near _div_0_abort ; would be dividing by 0, so abort
378 ; Done with ebx, ebp, ecx until next iteration
389 idiv ecx ; eax = (v/z)
391 mov ebx, eax ; ebx = U1 until pop's
398 idiv ecx ; eax = (v/z)
400 mov ecx, [U0] ; ecx = U0 until pop's
401 mov edi, [V0] ; edi = V0 until pop's
404 mov ebp, eax ; ebp = V1 until pop's
406 ; Make ESI = V0:U0 in 6:10,6:10 format
413 ; Make EDX = DV:DU in 6:10,6:10 format
419 shl edx, 10-NBITS ; EDX = V1-V0/ 4 in 6:10 int:frac
420 mov dx, ax ; put delta u in low word
422 ; Save the U1 and V1 so we don't have to divide on the next iteration
426 pop edi ; Restore EDI before using it
432 test dword [_Transparency_on],-1
436 mov eax, esi ; get u,v
437 shr eax, 26 ; shift out all but int(v)
438 shld ax,si,6 ; shift in u, shifting up v
439 add esi, edx ; inc u,v
441 movzx eax, byte [eax] ; get pixel from source bitmap
444 mov ah, bh ; form lighting table lookup value
445 add ebx, ebp ; update lighting value
446 mov al, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
452 mov eax, esi ; get u,v
453 shr eax, 26 ; shift out all but int(v)
454 shld ax,si,6 ; shift in u, shifting up v
455 add esi, edx ; inc u,v
457 movzx eax, byte [eax] ; get pixel from source bitmap
460 mov ah, bh ; form lighting table lookup value
461 add ebx, ebp ; update lighting value
462 mov al, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
469 %rep (2 << (NBITS-2))
470 ; local skip3,no_trans1
471 ; local skipa1,skipa2
477 ; -------------------------------------------------------
481 mov eax, esi ; get u,v
482 shr eax, 26 ; shift out all but int(v)
483 shld ax,si,6 ; shift in u, shifting up v
484 add esi, edx ; inc u,v
486 movzx eax, byte [eax] ; get pixel from source bitmap
487 mov ah, bh ; form lighting table lookup value
488 add ebx, ebp ; update lighting value
489 mov cl, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
492 mov eax, esi ; get u,v
493 shr eax, 26 ; shift out all but int(v)
494 shld ax,si,6 ; shift in u, shifting up v
495 add esi, edx ; inc u,v
497 movzx eax, byte [eax] ; get pixel from source bitmap
498 mov ah, bh ; form lighting table lookup value
499 add ebx, ebp ; update lighting value
500 mov ch, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
502 ; ----- This is about 1% faster than the above, and could probably be optimized more.
503 ; ----- Problem is, it gets the u,v coordinates backwards. What you would need to do
504 ; ----- is switch the packing of the u,v coordinates above (about 95 lines up).
505 ;----------; mov eax, esi
506 ;----------; shr ax, 10
507 ;----------; rol eax, 6
508 ;----------; mov dx, ax
509 ;----------; add esi, mem_edx
510 ;----------; mov dl, es:[edx]
511 ;----------; mov dh, bh
512 ;----------; add ebx, ebp
513 ;----------; mov cl, _gr_fade_table[edx]
515 ;----------; mov eax, esi
516 ;----------; shr ax, 10
517 ;----------; rol eax, 6
518 ;----------; mov dx, ax
519 ;----------; add esi, mem_edx
520 ;----------; mov dl, es:[edx]
521 ;----------; mov dh, bh
522 ;----------; add ebx, ebp
523 ;----------; mov ch, _gr_fade_table[edx]
525 ror ecx, 16 ; move to next double dest pixel position
528 %rep (1 << (NBITS-2))
533 mov [edi],ecx ; Draw 4 pixels to display
539 ; -------------------------------------------------------
546 dec dword [_loop_count]
550 test dword [num_left_over], -1
553 ; ----------------------------------------- Start of LeftOver Pixels ------------------------------------------
570 test dword [_new_end],-1
571 jne near NewDoEndPixels
581 ; this can happen because we added DZ1 to the current z, but dz1 represents dz for perhaps 16 pixels
582 ; though we might only plot one more pixel.
585 dep_loop: mov eax, [DU1]
604 push edi ; use edi as a temporary variable
606 cmp ecx,1 << (ZSHIFT+1)
608 mov ecx, 1 << (ZSHIFT+1)
617 idiv ecx ; eax = (v/z)
620 mov ebx, eax ; ebx = U1 until pop's
628 idiv ecx ; eax = (v/z)
631 mov ebp, eax ; ebp = V1 until pop's
633 mov ecx, [U0] ; ecx = U0 until pop's
634 mov edi, [V0] ; edi = V0 until pop's
636 ; Make ESI = V0:U0 in 6:10,6:10 format
643 ; Make EDX = DV:DU in 6:10,6:10 format
649 shl edx, 10-NBITS ; EDX = V1-V0/ 4 in 6:10 int:frac
650 mov dx, ax ; put delta u in low word
652 pop edi ; Restore EDI before using it
654 mov ecx, [num_left_over]
664 mov eax, esi ; get u,v
665 shr eax, 26 ; shift out all but int(v)
666 shld ax,si,6 ; shift in u, shifting up v
668 movzx eax, byte [eax] ; get pixel from source bitmap
669 add esi, edx ; inc u,v
670 mov ah, bh ; form lighting table lookup value
671 add ebx, ebp ; update lighting value
674 mov al, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
675 mov [edi+ITERATION], al ; write pixel
680 mov eax, esi ; get u,v
681 shr eax, 26 ; shift out all but int(v)
682 shld ax,si,6 ; shift in u, shifting up v
684 movzx eax, byte [eax] ; get pixel from source bitmap
685 add esi, edx ; inc u,v
686 mov ah, bh ; form lighting table lookup value
687 add ebx, [_fx_dl_dx] ; update lighting value
690 mov al, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
691 mov [edi+ITERATION+1], al ; write pixel
696 %rep (1 << (NBITS-1))
699 %assign ITERATION ITERATION + 2
703 ; Should never get here!!!!
707 ; ----------------------------------------- End of LeftOver Pixels ------------------------------------------
709 ; --BUGGY NEW--NewDoEndPixels:
710 ; --BUGGY NEW-- mov eax, num_left_over
711 ; --BUGGY NEW-- and num_left_over, 3
712 ; --BUGGY NEW-- shr eax, 2
713 ; --BUGGY NEW-- je NDEP_1
714 ; --BUGGY NEW-- mov _loop_count, eax
716 ; --BUGGY NEW--; do 4 pixels per hunk, not 16, so div deltas by 4 (16/4=4)
717 ; --BUGGY NEW-- shr DU1,2
718 ; --BUGGY NEW-- shr DV1,2
719 ; --BUGGY NEW-- shr DZ1,2
721 ; --BUGGY NEW--NDEP_TopOfLoop4:
722 ; --BUGGY NEW-- add ebx, DU1
723 ; --BUGGY NEW-- add ebp, DV1
724 ; --BUGGY NEW-- add ecx, DZ1
725 ; --BUGGY NEW-- je _div_0_abort ; would be dividing by 0, so abort
727 ; --BUGGY NEW--; Done with ebx, ebp, ecx until next iteration
728 ; --BUGGY NEW-- push ebx
729 ; --BUGGY NEW-- push ecx
730 ; --BUGGY NEW-- push ebp
731 ; --BUGGY NEW-- push edi
733 ; --BUGGY NEW--; Find fixed U1
734 ; --BUGGY NEW-- mov eax, ebx
735 ; --BUGGY NEW-- mov edx,ebx
736 ; --BUGGY NEW-- shl eax,(ZSHIFT-2)
737 ; --BUGGY NEW-- sar edx,32-(ZSHIFT-2)
738 ; --BUGGY NEW-- idiv ecx ; eax = (v/z)
739 ; --BUGGY NEW-- shl eax, 16-(ZSHIFT-2)
740 ; --BUGGY NEW-- mov ebx, eax ; ebx = U1 until pop's
742 ; --BUGGY NEW--; Find fixed V1
743 ; --BUGGY NEW-- mov eax, ebp
744 ; --BUGGY NEW-- mov edx, ebp
745 ; --BUGGY NEW-- shl eax,(ZSHIFT-2)
746 ; --BUGGY NEW-- sar edx,32-(ZSHIFT-2)
747 ; --BUGGY NEW-- idiv ecx ; eax = (v/z)
749 ; --BUGGY NEW-- mov ecx, U0 ; ecx = U0 until pop's
750 ; --BUGGY NEW-- mov edi, V0 ; edi = V0 until pop's
752 ; --BUGGY NEW-- shl eax, 16-(ZSHIFT-2)
753 ; --BUGGY NEW-- mov ebp, eax ; ebp = V1 until pop's
755 ; --BUGGY NEW--; Make ESI = V0:U0 in 6:10,6:10 format
756 ; --BUGGY NEW-- mov eax, ecx
757 ; --BUGGY NEW-- shr eax, 6
758 ; --BUGGY NEW-- mov esi, edi
759 ; --BUGGY NEW-- shl esi, 10
760 ; --BUGGY NEW-- mov si, ax
762 ; --BUGGY NEW--; Make EDX = DV:DU in 6:10,6:10 format
763 ; --BUGGY NEW-- mov eax, ebx
764 ; --BUGGY NEW-- sub eax, ecx
765 ; --BUGGY NEW-- sar eax, (NBITS-2)+6
766 ; --BUGGY NEW-- mov edx, ebp
767 ; --BUGGY NEW-- sub edx, edi
768 ; --BUGGY NEW-- shl edx, 10-(NBITS-2) ; EDX = V1-V0/ 4 in 6:10 int:frac
769 ; --BUGGY NEW-- mov dx, ax ; put delta u in low word
771 ; --BUGGY NEW--; Save the U1 and V1 so we don't have to divide on the next iteration
772 ; --BUGGY NEW-- mov U0, ebx
773 ; --BUGGY NEW-- mov V0, ebp
775 ; --BUGGY NEW-- pop edi ; Restore EDI before using it
777 ; --BUGGY NEW--; LIGHTING CODE
778 ; --BUGGY NEW-- mov ebx, _fx_l
779 ; --BUGGY NEW-- mov ebp, _fx_dl_dx
781 ; --BUGGY NEW--;** test _Transparency_on,-1
782 ; --BUGGY NEW--;** je NDEP_no_trans1
784 ; --BUGGY NEW-- REPT 2
785 ; --BUGGY NEW-- local NDEP_skipa1, NDEP_skipa2
787 ; --BUGGY NEW-- mov eax, esi ; get u,v
788 ; --BUGGY NEW-- shr eax, 26 ; shift out all but int(v)
789 ; --BUGGY NEW-- shld ax,si,6 ; shift in u, shifting up v
790 ; --BUGGY NEW-- add esi, edx ; inc u,v
791 ; --BUGGY NEW-- mov al, es:[eax] ; get pixel from source bitmap
792 ; --BUGGY NEW-- cmp al,255
793 ; --BUGGY NEW-- je NDEP_skipa1
794 ; --BUGGY NEW-- mov ah, bh ; form lighting table lookup value
795 ; --BUGGY NEW-- add ebx, ebp ; update lighting value
796 ; --BUGGY NEW-- mov al, _gr_fade_table[eax] ; xlat thru lighting table into dest buffer
797 ; --BUGGY NEW-- mov [edi],al
798 ; --BUGGY NEW--NDEP_skipa1:
799 ; --BUGGY NEW-- inc edi
801 ; --BUGGY NEW--; Do odd pixel
802 ; --BUGGY NEW-- mov eax, esi ; get u,v
803 ; --BUGGY NEW-- shr eax, 26 ; shift out all but int(v)
804 ; --BUGGY NEW-- shld ax,si,6 ; shift in u, shifting up v
805 ; --BUGGY NEW-- add esi, edx ; inc u,v
806 ; --BUGGY NEW-- mov al, es:[eax] ; get pixel from source bitmap
807 ; --BUGGY NEW-- cmp al,255
808 ; --BUGGY NEW-- je NDEP_skipa2
809 ; --BUGGY NEW-- mov ah, bh ; form lighting table lookup value
810 ; --BUGGY NEW-- add ebx, ebp ; update lighting value
811 ; --BUGGY NEW-- mov al, _gr_fade_table[eax] ; xlat thru lighting table into dest buffer
812 ; --BUGGY NEW-- mov [edi],al
813 ; --BUGGY NEW--NDEP_skipa2:
814 ; --BUGGY NEW-- inc edi
818 ; --BUGGY NEW-- mov _fx_l, ebx
819 ; --BUGGY NEW-- pop ebp
820 ; --BUGGY NEW-- pop ecx
821 ; --BUGGY NEW-- pop ebx
822 ; --BUGGY NEW-- dec _loop_count
823 ; --BUGGY NEW-- jnz NDEP_TopOfLoop4
825 ; --BUGGY NEW-- test num_left_over, -1
826 ; --BUGGY NEW-- je _none_to_do
828 ; --BUGGY NEW--NDEP_1:
829 ; --BUGGY NEW-- mov esi,ebx
831 ; --BUGGY NEW-- align 4
832 ; --BUGGY NEW--NDEP_loop:
834 ; --BUGGY NEW--; compute v coordinate
835 ; --BUGGY NEW-- mov eax, ebp ; get v
836 ; --BUGGY NEW-- mov edx, eax
837 ; --BUGGY NEW-- sar edx, 31
838 ; --BUGGY NEW-- idiv ecx ; eax = (v/z)
840 ; --BUGGY NEW-- and eax,3fh ; mask with height-1
841 ; --BUGGY NEW-- mov ebx,eax
843 ; --BUGGY NEW--; compute u coordinate
844 ; --BUGGY NEW-- mov eax, esi ; get u
845 ; --BUGGY NEW-- mov edx, eax
846 ; --BUGGY NEW-- sar edx, 31
847 ; --BUGGY NEW-- idiv ecx ; eax = (u/z)
849 ; --BUGGY NEW-- shl eax,26
850 ; --BUGGY NEW-- shld ebx,eax,6 ; esi = v*64+u
852 ; --BUGGY NEW--; read 1 pixel
853 ; --BUGGY NEW-- xor eax, eax
854 ; --BUGGY NEW-- mov al, es:[ebx] ; get pixel from source bitmap
856 ; --BUGGY NEW--; lighting code
857 ; --BUGGY NEW-- mov ebx, _fx_l ; get temp copy of lighting value
858 ; --BUGGY NEW-- mov ah, bh ; get lighting level
859 ; --BUGGY NEW-- add ebx, _fx_dl_dx ; update lighting value
860 ; --BUGGY NEW-- mov _fx_l, ebx ; save temp copy of lighting value
862 ; --BUGGY NEW--; transparency check
863 ; --BUGGY NEW-- cmp al,255
864 ; --BUGGY NEW-- je NDEP_skip2 ; this pixel is transparent, so don't write it (or light it)
866 ; --BUGGY NEW-- mov al, _gr_fade_table[eax] ; xlat pixel thru lighting tables
868 ; --BUGGY NEW--; write 1 pixel
869 ; --BUGGY NEW-- mov [edi],al
870 ; --BUGGY NEW--NDEP_skip2: inc edi
872 ; --BUGGY NEW--; update deltas
873 ; --BUGGY NEW-- add ebp,_fx_dv_dx
874 ; --BUGGY NEW-- add esi,_fx_du_dx
875 ; --BUGGY NEW-- add ecx,_fx_dz_dx
876 ; --BUGGY NEW-- je _div_0_abort ; would be dividing by 0, so abort
878 ; --BUGGY NEW-- dec num_left_over
879 ; --BUGGY NEW-- jne NDEP_loop
881 ; --BUGGY NEW-- jmp _none_to_do
889 ; compute v coordinate
893 idiv ecx ; eax = (v/z)
895 and eax,3fh ; mask with height-1
898 ; compute u coordinate
902 idiv ecx ; eax = (u/z)
905 shld ebx,eax,6 ; esi = v*64+u
910 mov al, [ebx] ; get pixel from source bitmap
913 mov ebx, [_fx_l] ; get temp copy of lighting value
914 mov ah, bh ; get lighting level
915 add ebx, [_fx_dl_dx] ; update lighting value
916 mov [_fx_l], ebx ; save temp copy of lighting value
920 je NDEP_skip2 ; this pixel is transparent, so don't write it (or light it)
922 mov al, [_gr_fade_table+eax] ; xlat pixel thru lighting tables
932 je near _div_0_abort ; would be dividing by 0, so abort
934 dec dword [num_left_over]
939 ; ==================================================== No Lighting Code ======================================================
940 global _tmap_loop_fast_nolight
941 _tmap_loop_fast_nolight:
945 NotDwordAligned1_nolight:
947 jz DwordAligned1_nolight
949 ; compute v coordinate
953 idiv ecx ; eax = (v/z)
955 and eax,3fh ; mask with height-1
958 ; compute u coordinate
962 idiv ecx ; eax = (u/z)
965 shld ebx,eax,6 ; esi = v*64+u
969 mov al,[ebx] ; get pixel from source bitmap
981 je near _div_0_abort ; would be dividing by 0, so abort
983 dec dword [_loop_count]
984 jns NotDwordAligned1_nolight
987 DwordAligned1_nolight:
990 mov eax, [_loop_count]
992 mov [num_left_over], eax
996 je near tmap_loop ; no 2^NBITS chunks, do divide/pixel for whole scanline
998 mov [_loop_count], eax ; _loop_count = pixels / NPIXS
1000 sub [num_left_over], eax ; num_left_over = obvious
1002 ; compute initial v coordinate
1008 idiv ecx ; eax = (v/z)
1013 ; compute initial u coordinate
1019 idiv ecx ; eax = (v/z)
1024 ; Set deltas to NPIXS pixel increments
1025 mov eax, [_fx_du_dx]
1028 mov eax, [_fx_dv_dx]
1031 mov eax, [_fx_dz_dx]
1040 je near _div_0_abort
1042 ; Done with ebx, ebp, ecx until next iteration
1054 idiv ecx ; eax = (v/z)
1057 mov ebx, eax ; ebx = U1 until pop's
1065 idiv ecx ; eax = (v/z)
1068 mov ebp, eax ; ebp = V1 until pop's
1070 mov ecx, [U0] ; ecx = U0 until pop's
1071 mov edi, [V0] ; edi = V0 until pop's
1073 ; Make ESI = V0:U0 in 6:10,6:10 format
1080 ; Make EDX = DV:DU in 6:10,6:10 format
1086 shl edx, 10-NBITS ; EDX = V1-V0/ 4 in 6:10 int:frac
1087 mov dx, ax ; put delta u in low word
1089 ; Save the U1 and V1 so we don't have to divide on the next iteration
1093 pop edi ; Restore EDI before using it
1097 mov eax, esi ; get u,v
1098 shr eax, 26 ; shift out all but int(v)
1099 shld ax,si,6 ; shift in u, shifting up v
1100 add esi, edx ; inc u,v
1102 mov cl, [eax] ; load into buffer register
1104 mov eax, esi ; get u,v
1105 shr eax, 26 ; shift out all but int(v)
1106 shld ax,si,6 ; shift in u, shifting up v
1108 mov ch, [eax] ; load into buffer register
1109 add esi, edx ; inc u,v
1110 ror ecx, 16 ; move to next dest pixel
1112 mov eax, esi ; get u,v
1113 shr eax, 26 ; shift out all but int(v)
1114 shld ax,si,6 ; shift in u, shifting up v
1116 mov cl, [eax] ; load into buffer register
1117 add esi, edx ; inc u,v
1119 mov eax, esi ; get u,v
1120 shr eax, 26 ; shift out all but int(v)
1121 shld ax,si,6 ; shift in u, shifting up v
1123 mov ch, [eax] ; load into buffer register
1124 add esi, edx ; inc u,v
1125 ror ecx, 16 ;-- can get rid of this, just write in different order below -- ; move to next dest pixel
1127 test dword [_Transparency_on],-1
1156 mov [edi],ecx ; Draw 4 pixels to display
1160 %rep (1 << (NBITS-2))
1161 ;local skip7, no_trans2, skip1q, skip2q, skip3q, skip4q
1169 dec dword [_loop_count]
1170 jnz near TopOfLoop4_nolight
1174 test dword [num_left_over], -1
1177 DoEndPixels_nolight:
1181 je near _div_0_abort
1182 push edi ; use edi as a temporary variable
1189 idiv ecx ; eax = (v/z)
1191 mov ebx, eax ; ebx = U1 until pop's
1198 idiv ecx ; eax = (v/z)
1200 mov ebp, eax ; ebp = V1 until pop's
1202 mov ecx, [U0] ; ecx = U0 until pop's
1203 mov edi, [V0] ; edi = V0 until pop's
1205 ; Make ESI = V0:U0 in 6:10,6:10 format
1212 ; Make EDX = DV:DU in 6:10,6:10 format
1218 shl edx, 10-NBITS ; EDX = V1-V0/ 4 in 6:10 int:frac
1219 mov dx, ax ; put delta u in low word
1221 pop edi ; Restore EDI before using it
1223 mov ecx, [num_left_over]
1228 mov eax, esi ; get u,v
1229 shr eax, 26 ; shift out all but int(v)
1230 shld ax,si,6 ; shift in u, shifting up v
1232 movzx eax, byte [eax] ; load into buffer register
1233 add esi, edx ; inc u,v
1236 mov [edi+ITERATION], al ; write pixel
1244 %assign ITERATION ITERATION + 1
1247 ; Should never get here!!!!!