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.
12 ; $Source: /cvs/cvsroot/d2x/texmap/tmap_per.asm,v $
13 ; $Revision: 1.1.1.1 $
15 ; $Date: 2001-01-19 03:30:16 $
17 ; Perspective texture mapper inner loop.
19 ; $Log: not supported by cvs2svn $
20 ; Revision 1.1.1.1 1999/06/14 22:14:01 donut
21 ; Import of d1x 1.37 source.
23 ; Revision 1.26 1995/02/20 18:22:55 john
24 ; Put all the externs in the assembly modules into tmap_inc.asm.
25 ; Also, moved all the C versions of the inner loops into a new module,
28 ; Revision 1.25 1995/02/20 17:09:08 john
29 ; Added code so that you can build the tmapper with no assembly!
31 ; Revision 1.24 1995/01/10 09:32:07 mike
32 ; mostly fix garbage at end of scanline, but slow down by 1-4%.
34 ; Revision 1.23 1994/12/02 23:29:57 mike
37 ; Revision 1.22 1994/11/30 00:57:00 mike
40 ; Revision 1.21 1994/11/21 13:57:42 mike
41 ; fix right side shear bug
43 ; Revision 1.20 1994/11/12 16:41:09 mike
46 ; Revision 1.19 1994/10/27 19:40:00 john
47 ; Made lighting table lookup be _gr_fade_table[eax] instead
48 ; of fs:[eax], which gets rig of a segment override that
49 ; supposedly costs 1 clock on a 486. Mainly, I wanted to verify
50 ; that the only reason we need selectors is for the source texture
53 ; Revision 1.18 1994/05/03 11:08:32 mike
54 ; Trap divide overflows.
56 ; Revision 1.17 1994/04/21 15:03:41 mike
59 ; Revision 1.16 1994/04/08 16:46:57 john
60 ; Made 32 fade levels. Hacked.
62 ; Revision 1.15 1994/03/31 08:35:18 mike
63 ; Fix quantized-by-4 bug in inner loop.
65 ; Revision 1.14 1994/03/14 17:41:14 mike
66 ; Fix bug in unlighted version.
68 ; Revision 1.13 1994/03/14 15:45:14 mike
71 ; Revision 1.12 1994/01/14 14:01:58 mike
72 ; *** empty log message ***
74 ; Revision 1.11 1993/12/18 14:43:44 john
75 ; Messed around with doing 1/z, the u*(1/z) and v*(1/z)
76 ; (Went from 23 fps to 21 fps... not good! )
78 ; Revision 1.10 1993/12/17 16:14:17 john
79 ; Split lighted/nonlighted, so there is no cmp lighting
82 ; Revision 1.9 1993/12/17 12:34:29 john
83 ; Made leftover bytes use linear approx instead of correct...
84 ; should save about 8 divides per scanline on average.
85 ; Also, took out anti-aliasing code and rearranged to
86 ; order of some instructions to help on 486 pipelining.
87 ; (The anti-aliasing code did *not* look good, so I
88 ; figure there was no reason to keep it in. )
90 ; Revision 1.8 1993/12/16 18:37:52 mike
91 ; Align some stuff on 4 byte boundaries.
93 ; Revision 1.7 1993/11/30 08:44:18 john
94 ; Made selector set check for < 64*64 bitmaps.
96 ; Revision 1.6 1993/11/23 17:25:26 john
97 ; Added safety "and eax, 0fffh" in lighting lookup.
99 ; Revision 1.5 1993/11/23 15:08:52 mike
100 ; Fixed lighting bug.
102 ; Revision 1.4 1993/11/23 14:38:50 john
103 ; optimized NORMAL code by switching EBX and ESI, so BH can be used in
104 ; the lighting process.
106 ; Revision 1.3 1993/11/23 14:30:53 john
107 ; Made the perspective tmapper do 1/8 divides; added lighting.
109 ; Revision 1.2 1993/11/22 10:24:59 mike
110 ; *** empty log message ***
112 ; Revision 1.1 1993/09/08 17:29:53 mike
120 global _asm_tmap_scanline_per
121 global asm_tmap_scanline_per
123 %include "tmap_inc.asm"
127 ;extern _per2_flag;:dword
129 ; Cater for linux ELF compilers...
131 %define _loop_count loop_count
132 %define _new_end new_end
133 %define _scan_doubling_flag scan_doubling_flag
134 %define _linear_if_far_flag linear_if_far_flag
140 global _scan_doubling_flag
141 global _linear_if_far_flag
152 ; _min_ecx dd 55555555h
153 _new_end dd 1 ; if set, use new, but slower, way of finishing off extra pixels on scanline, 01/10/95 --MK
155 _scan_doubling_flag dd 0
156 _linear_if_far_flag dd 0
158 ;---------- local variables
173 ; --------------------------------------------------------------------------------------------------
175 ; _xleft fixed point left x coordinate
176 ; _xright fixed point right x coordinate
177 ; _y fixed point y coordinate
178 ; _pixptr address of source pixel map
179 ; _u fixed point initial u coordinate
180 ; _v fixed point initial v coordinate
181 ; _z fixed point initial z coordinate
182 ; _du_dx fixed point du/dx
183 ; _dv_dx fixed point dv/dx
184 ; _dz_dx fixed point dz/dx
186 ; for (x = (int) xleft; x <= (int) xright; x++) {
187 ; _setcolor(read_pixel_from_tmap(srcb,((int) (u/z)) & 63,((int) (v/z)) & 63));
197 _asm_tmap_scanline_per:
198 asm_tmap_scanline_per:
202 ;---------------------------- setup for loop ---------------------------------
203 ; Setup for loop: _loop_count iterations = (int) xright - (int) xleft
204 ; esi source pixel pointer = pixptr
205 ; edi initial row pointer = y*320+x
206 ; NOTE: fx_xright and fx_xleft changed from fix to int by mk on 12/01/94.
208 ; set esi = pointer to start of texture map data
210 ; set edi = address of first pixel to modify
212 ; mov es,[_pixel_data_selector] ; selector[0*2]
214 mov edi,[_y_pointers+edi*4]
220 ebx_ok: add edi,[_write_buffer]
223 ; set _loop_count = # of iterations
227 mov [_loop_count],eax
229 ; lighting values are passed in fixed point, but need to be in 8 bit integer, 8 bit fraction so we can easily
230 ; get the integer by reading %bh
232 sar dword [_fx_dl_dx],8
234 inc dword [_fx_dl_dx] ; round towards 0 for negative deltas
242 test dword [_per2_flag],-1
245 test dword [_Lighting_on], -1
246 je near _tmap_loop_fast_nolight
248 ;tmap_loop_fast_nolight_jumper:
249 ; jmp tmap_loop_fast_nolight
251 ;================ PERSPECTIVE TEXTURE MAP INNER LOOPS ========================
253 ; Usage in loop: eax division, pixel value
258 ; esi source pixel pointer
259 ; edi destination pixel pointer
261 ;-------------------- NORMAL PERSPECTIVE TEXTURE MAP LOOP -----------------
263 mov esi, ebx ; esi becomes u coordinate
268 ; compute v coordinate
272 idiv ecx ; eax = (v/z)
274 and eax,3fh ; mask with height-1
277 ; compute u coordinate
281 idiv ecx ; eax = (u/z)
284 shld ebx,eax,6 ; esi = v*64+u
289 test dword [_Lighting_on], -1
290 mov al, [ebx] ; get pixel from source bitmap
294 mov ebx, [_fx_l] ; get temp copy of lighting value
295 mov ah, bh ; get lighting level
296 add ebx, [_fx_dl_dx] ; update lighting value
297 mov al, [_gr_fade_table+eax] ; xlat pixel thru lighting tables
298 mov [_fx_l], ebx ; save temp copy of lighting value
311 je _div_0_abort ; would be dividing by 0, so abort
313 dec dword [_loop_count]
321 ; We detected a z=0 condition, which seems pretty bogus, don't you think?
322 ; So, we abort, but maybe we want to know about it.
326 ;-------------------------- PER/4 TMAPPER ----------------
329 ; U0 = u/w; V0 = v/w;
331 ; u += du_dx*4; v+= dv_dx*4
332 ; U1 = u/w; V1 = v/w;
333 ; DUDX = (U1-U0)/4; DVDX = (V1-V0)/4;
336 ; pixels = texmap[V0*64+U0];
337 ; U0 += DUDX; V0 += DVDX
339 ; pixels = (pixels<<8)+texmap[V0*64+U0];
340 ; U0 += DUDX; V0 += DVDX
342 ; pixels = (pixels<<8)+texmap[V0*64+U0];
343 ; U0 += DUDX; V0 += DVDX
345 ; pixels = (pixels<<8)+texmap[V0*64+U0];
351 NBITS equ 4 ; 2^NBITS pixels plotted per divide
352 ZSHIFT equ 4 ; precision used in PDIV macro
356 ; Returns EAX/ECX in 16.16 format in EAX. Trashes EDX
361 ; idiv ecx ; eax = (v/z)
365 global _tmap_loop_fast
367 ; -------------------------------------- Start of Getting Dword Aligned ----------------------------------------------
378 ; compute v coordinate
382 idiv ecx ; eax = (v/z)
384 and eax,3fh ; mask with height-1
387 ; compute u coordinate
391 idiv ecx ; eax = (u/z)
394 shld ebx,eax,6 ; esi = v*64+u
399 mov al, [ebx] ; get pixel from source bitmap
402 mov ebx, [_fx_l] ; get temp copy of lighting value
403 mov ah, bh ; get lighting level
404 add ebx, [_fx_dl_dx] ; update lighting value
405 mov [_fx_l], ebx ; save temp copy of lighting value
409 je skip2 ; this pixel is transparent, so don't write it (or light it)
411 mov al, [_gr_fade_table+eax] ; xlat pixel thru lighting tables
421 je _div_0_abort ; would be dividing by 0, so abort
423 dec dword [_loop_count]
428 ; -------------------------------------- End of Getting Dword Aligned ----------------------------------------------
432 mov eax, [_loop_count]
433 mov ebx, esi ; get fx_u [pentium pipelining]
436 and esi, (1 << NBITS) - 1
438 mov [num_left_over], esi
439 je near tmap_loop ; there are no 2^NBITS chunks, do divide/pixel for whole scanline
440 mov [_loop_count], eax ; _loop_count = pixels / NPIXS
442 ; compute initial v coordinate
447 idiv ecx ; eax = (v/z)
451 ; compute initial u coordinate
456 idiv ecx ; eax = (v/z)
460 ; Set deltas to NPIXS pixel increments
476 je near _div_0_abort ; would be dividing by 0, so abort
478 ; Done with ebx, ebp, ecx until next iteration
489 idiv ecx ; eax = (v/z)
491 mov ebx, eax ; ebx = U1 until pop's
498 idiv ecx ; eax = (v/z)
500 mov ecx, [U0] ; ecx = U0 until pop's
501 mov edi, [V0] ; edi = V0 until pop's
504 mov ebp, eax ; ebp = V1 until pop's
506 ; Make ESI = V0:U0 in 6:10,6:10 format
513 ; Make EDX = DV:DU in 6:10,6:10 format
519 shl edx, 10-NBITS ; EDX = V1-V0/ 4 in 6:10 int:frac
520 mov dx, ax ; put delta u in low word
522 ; Save the U1 and V1 so we don't have to divide on the next iteration
526 pop edi ; Restore EDI before using it
532 test dword [_Transparency_on],-1
536 mov eax, esi ; get u,v
537 shr eax, 26 ; shift out all but int(v)
538 shld ax,si,6 ; shift in u, shifting up v
539 add esi, edx ; inc u,v
541 movzx eax, byte [eax] ; get pixel from source bitmap
544 mov ah, bh ; form lighting table lookup value
545 add ebx, ebp ; update lighting value
546 mov al, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
552 mov eax, esi ; get u,v
553 shr eax, 26 ; shift out all but int(v)
554 shld ax,si,6 ; shift in u, shifting up v
555 add esi, edx ; inc u,v
557 movzx eax, byte [eax] ; get pixel from source bitmap
560 mov ah, bh ; form lighting table lookup value
561 add ebx, ebp ; update lighting value
562 mov al, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
569 %rep (2 << (NBITS-2))
570 ; local skip3,no_trans1
571 ; local skipa1,skipa2
577 ; -------------------------------------------------------
581 mov eax, esi ; get u,v
582 shr eax, 26 ; shift out all but int(v)
583 shld ax,si,6 ; shift in u, shifting up v
584 add esi, edx ; inc u,v
586 movzx eax, byte [eax] ; get pixel from source bitmap
587 mov ah, bh ; form lighting table lookup value
588 add ebx, ebp ; update lighting value
589 mov cl, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
592 mov eax, esi ; get u,v
593 shr eax, 26 ; shift out all but int(v)
594 shld ax,si,6 ; shift in u, shifting up v
595 add esi, edx ; inc u,v
597 movzx eax, byte [eax] ; get pixel from source bitmap
598 mov ah, bh ; form lighting table lookup value
599 add ebx, ebp ; update lighting value
600 mov ch, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
602 ; ----- This is about 1% faster than the above, and could probably be optimized more.
603 ; ----- Problem is, it gets the u,v coordinates backwards. What you would need to do
604 ; ----- is switch the packing of the u,v coordinates above (about 95 lines up).
605 ;----------; mov eax, esi
606 ;----------; shr ax, 10
607 ;----------; rol eax, 6
608 ;----------; mov dx, ax
609 ;----------; add esi, mem_edx
610 ;----------; mov dl, es:[edx]
611 ;----------; mov dh, bh
612 ;----------; add ebx, ebp
613 ;----------; mov cl, _gr_fade_table[edx]
615 ;----------; mov eax, esi
616 ;----------; shr ax, 10
617 ;----------; rol eax, 6
618 ;----------; mov dx, ax
619 ;----------; add esi, mem_edx
620 ;----------; mov dl, es:[edx]
621 ;----------; mov dh, bh
622 ;----------; add ebx, ebp
623 ;----------; mov ch, _gr_fade_table[edx]
625 ror ecx, 16 ; move to next double dest pixel position
628 %rep (1 << (NBITS-2))
633 mov [edi],ecx ; Draw 4 pixels to display
639 ; -------------------------------------------------------
646 dec dword [_loop_count]
650 test dword [num_left_over], -1
653 ; ----------------------------------------- Start of LeftOver Pixels ------------------------------------------
670 test dword [_new_end],-1
671 jne near NewDoEndPixels
681 ; this can happen because we added DZ1 to the current z, but dz1 represents dz for perhaps 16 pixels
682 ; though we might only plot one more pixel.
685 dep_loop: mov eax, [DU1]
704 push edi ; use edi as a temporary variable
706 cmp ecx,1 << (ZSHIFT+1)
708 mov ecx, 1 << (ZSHIFT+1)
717 idiv ecx ; eax = (v/z)
720 mov ebx, eax ; ebx = U1 until pop's
728 idiv ecx ; eax = (v/z)
731 mov ebp, eax ; ebp = V1 until pop's
733 mov ecx, [U0] ; ecx = U0 until pop's
734 mov edi, [V0] ; edi = V0 until pop's
736 ; Make ESI = V0:U0 in 6:10,6:10 format
743 ; Make EDX = DV:DU in 6:10,6:10 format
749 shl edx, 10-NBITS ; EDX = V1-V0/ 4 in 6:10 int:frac
750 mov dx, ax ; put delta u in low word
752 pop edi ; Restore EDI before using it
754 mov ecx, [num_left_over]
764 mov eax, esi ; get u,v
765 shr eax, 26 ; shift out all but int(v)
766 shld ax,si,6 ; shift in u, shifting up v
768 movzx eax, byte [eax] ; get pixel from source bitmap
769 add esi, edx ; inc u,v
770 mov ah, bh ; form lighting table lookup value
771 add ebx, ebp ; update lighting value
774 mov al, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
775 mov [edi+ITERATION], al ; write pixel
780 mov eax, esi ; get u,v
781 shr eax, 26 ; shift out all but int(v)
782 shld ax,si,6 ; shift in u, shifting up v
784 movzx eax, byte [eax] ; get pixel from source bitmap
785 add esi, edx ; inc u,v
786 mov ah, bh ; form lighting table lookup value
787 add ebx, [_fx_dl_dx] ; update lighting value
790 mov al, [_gr_fade_table+eax] ; xlat thru lighting table into dest buffer
791 mov [edi+ITERATION+1], al ; write pixel
796 %rep (1 << (NBITS-1))
799 %assign ITERATION ITERATION + 2
803 ; Should never get here!!!!
807 ; ----------------------------------------- End of LeftOver Pixels ------------------------------------------
809 ; --BUGGY NEW--NewDoEndPixels:
810 ; --BUGGY NEW-- mov eax, num_left_over
811 ; --BUGGY NEW-- and num_left_over, 3
812 ; --BUGGY NEW-- shr eax, 2
813 ; --BUGGY NEW-- je NDEP_1
814 ; --BUGGY NEW-- mov _loop_count, eax
816 ; --BUGGY NEW--; do 4 pixels per hunk, not 16, so div deltas by 4 (16/4=4)
817 ; --BUGGY NEW-- shr DU1,2
818 ; --BUGGY NEW-- shr DV1,2
819 ; --BUGGY NEW-- shr DZ1,2
821 ; --BUGGY NEW--NDEP_TopOfLoop4:
822 ; --BUGGY NEW-- add ebx, DU1
823 ; --BUGGY NEW-- add ebp, DV1
824 ; --BUGGY NEW-- add ecx, DZ1
825 ; --BUGGY NEW-- je _div_0_abort ; would be dividing by 0, so abort
827 ; --BUGGY NEW--; Done with ebx, ebp, ecx until next iteration
828 ; --BUGGY NEW-- push ebx
829 ; --BUGGY NEW-- push ecx
830 ; --BUGGY NEW-- push ebp
831 ; --BUGGY NEW-- push edi
833 ; --BUGGY NEW--; Find fixed U1
834 ; --BUGGY NEW-- mov eax, ebx
835 ; --BUGGY NEW-- mov edx,ebx
836 ; --BUGGY NEW-- shl eax,(ZSHIFT-2)
837 ; --BUGGY NEW-- sar edx,32-(ZSHIFT-2)
838 ; --BUGGY NEW-- idiv ecx ; eax = (v/z)
839 ; --BUGGY NEW-- shl eax, 16-(ZSHIFT-2)
840 ; --BUGGY NEW-- mov ebx, eax ; ebx = U1 until pop's
842 ; --BUGGY NEW--; Find fixed V1
843 ; --BUGGY NEW-- mov eax, ebp
844 ; --BUGGY NEW-- mov edx, ebp
845 ; --BUGGY NEW-- shl eax,(ZSHIFT-2)
846 ; --BUGGY NEW-- sar edx,32-(ZSHIFT-2)
847 ; --BUGGY NEW-- idiv ecx ; eax = (v/z)
849 ; --BUGGY NEW-- mov ecx, U0 ; ecx = U0 until pop's
850 ; --BUGGY NEW-- mov edi, V0 ; edi = V0 until pop's
852 ; --BUGGY NEW-- shl eax, 16-(ZSHIFT-2)
853 ; --BUGGY NEW-- mov ebp, eax ; ebp = V1 until pop's
855 ; --BUGGY NEW--; Make ESI = V0:U0 in 6:10,6:10 format
856 ; --BUGGY NEW-- mov eax, ecx
857 ; --BUGGY NEW-- shr eax, 6
858 ; --BUGGY NEW-- mov esi, edi
859 ; --BUGGY NEW-- shl esi, 10
860 ; --BUGGY NEW-- mov si, ax
862 ; --BUGGY NEW--; Make EDX = DV:DU in 6:10,6:10 format
863 ; --BUGGY NEW-- mov eax, ebx
864 ; --BUGGY NEW-- sub eax, ecx
865 ; --BUGGY NEW-- sar eax, (NBITS-2)+6
866 ; --BUGGY NEW-- mov edx, ebp
867 ; --BUGGY NEW-- sub edx, edi
868 ; --BUGGY NEW-- shl edx, 10-(NBITS-2) ; EDX = V1-V0/ 4 in 6:10 int:frac
869 ; --BUGGY NEW-- mov dx, ax ; put delta u in low word
871 ; --BUGGY NEW--; Save the U1 and V1 so we don't have to divide on the next iteration
872 ; --BUGGY NEW-- mov U0, ebx
873 ; --BUGGY NEW-- mov V0, ebp
875 ; --BUGGY NEW-- pop edi ; Restore EDI before using it
877 ; --BUGGY NEW--; LIGHTING CODE
878 ; --BUGGY NEW-- mov ebx, _fx_l
879 ; --BUGGY NEW-- mov ebp, _fx_dl_dx
881 ; --BUGGY NEW--;** test _Transparency_on,-1
882 ; --BUGGY NEW--;** je NDEP_no_trans1
884 ; --BUGGY NEW-- REPT 2
885 ; --BUGGY NEW-- local NDEP_skipa1, NDEP_skipa2
887 ; --BUGGY NEW-- mov eax, esi ; get u,v
888 ; --BUGGY NEW-- shr eax, 26 ; shift out all but int(v)
889 ; --BUGGY NEW-- shld ax,si,6 ; shift in u, shifting up v
890 ; --BUGGY NEW-- add esi, edx ; inc u,v
891 ; --BUGGY NEW-- mov al, es:[eax] ; get pixel from source bitmap
892 ; --BUGGY NEW-- cmp al,255
893 ; --BUGGY NEW-- je NDEP_skipa1
894 ; --BUGGY NEW-- mov ah, bh ; form lighting table lookup value
895 ; --BUGGY NEW-- add ebx, ebp ; update lighting value
896 ; --BUGGY NEW-- mov al, _gr_fade_table[eax] ; xlat thru lighting table into dest buffer
897 ; --BUGGY NEW-- mov [edi],al
898 ; --BUGGY NEW--NDEP_skipa1:
899 ; --BUGGY NEW-- inc edi
901 ; --BUGGY NEW--; Do odd pixel
902 ; --BUGGY NEW-- mov eax, esi ; get u,v
903 ; --BUGGY NEW-- shr eax, 26 ; shift out all but int(v)
904 ; --BUGGY NEW-- shld ax,si,6 ; shift in u, shifting up v
905 ; --BUGGY NEW-- add esi, edx ; inc u,v
906 ; --BUGGY NEW-- mov al, es:[eax] ; get pixel from source bitmap
907 ; --BUGGY NEW-- cmp al,255
908 ; --BUGGY NEW-- je NDEP_skipa2
909 ; --BUGGY NEW-- mov ah, bh ; form lighting table lookup value
910 ; --BUGGY NEW-- add ebx, ebp ; update lighting value
911 ; --BUGGY NEW-- mov al, _gr_fade_table[eax] ; xlat thru lighting table into dest buffer
912 ; --BUGGY NEW-- mov [edi],al
913 ; --BUGGY NEW--NDEP_skipa2:
914 ; --BUGGY NEW-- inc edi
918 ; --BUGGY NEW-- mov _fx_l, ebx
919 ; --BUGGY NEW-- pop ebp
920 ; --BUGGY NEW-- pop ecx
921 ; --BUGGY NEW-- pop ebx
922 ; --BUGGY NEW-- dec _loop_count
923 ; --BUGGY NEW-- jnz NDEP_TopOfLoop4
925 ; --BUGGY NEW-- test num_left_over, -1
926 ; --BUGGY NEW-- je _none_to_do
928 ; --BUGGY NEW--NDEP_1:
929 ; --BUGGY NEW-- mov esi,ebx
931 ; --BUGGY NEW-- align 4
932 ; --BUGGY NEW--NDEP_loop:
934 ; --BUGGY NEW--; compute v coordinate
935 ; --BUGGY NEW-- mov eax, ebp ; get v
936 ; --BUGGY NEW-- mov edx, eax
937 ; --BUGGY NEW-- sar edx, 31
938 ; --BUGGY NEW-- idiv ecx ; eax = (v/z)
940 ; --BUGGY NEW-- and eax,3fh ; mask with height-1
941 ; --BUGGY NEW-- mov ebx,eax
943 ; --BUGGY NEW--; compute u coordinate
944 ; --BUGGY NEW-- mov eax, esi ; get u
945 ; --BUGGY NEW-- mov edx, eax
946 ; --BUGGY NEW-- sar edx, 31
947 ; --BUGGY NEW-- idiv ecx ; eax = (u/z)
949 ; --BUGGY NEW-- shl eax,26
950 ; --BUGGY NEW-- shld ebx,eax,6 ; esi = v*64+u
952 ; --BUGGY NEW--; read 1 pixel
953 ; --BUGGY NEW-- xor eax, eax
954 ; --BUGGY NEW-- mov al, es:[ebx] ; get pixel from source bitmap
956 ; --BUGGY NEW--; lighting code
957 ; --BUGGY NEW-- mov ebx, _fx_l ; get temp copy of lighting value
958 ; --BUGGY NEW-- mov ah, bh ; get lighting level
959 ; --BUGGY NEW-- add ebx, _fx_dl_dx ; update lighting value
960 ; --BUGGY NEW-- mov _fx_l, ebx ; save temp copy of lighting value
962 ; --BUGGY NEW--; transparency check
963 ; --BUGGY NEW-- cmp al,255
964 ; --BUGGY NEW-- je NDEP_skip2 ; this pixel is transparent, so don't write it (or light it)
966 ; --BUGGY NEW-- mov al, _gr_fade_table[eax] ; xlat pixel thru lighting tables
968 ; --BUGGY NEW--; write 1 pixel
969 ; --BUGGY NEW-- mov [edi],al
970 ; --BUGGY NEW--NDEP_skip2: inc edi
972 ; --BUGGY NEW--; update deltas
973 ; --BUGGY NEW-- add ebp,_fx_dv_dx
974 ; --BUGGY NEW-- add esi,_fx_du_dx
975 ; --BUGGY NEW-- add ecx,_fx_dz_dx
976 ; --BUGGY NEW-- je _div_0_abort ; would be dividing by 0, so abort
978 ; --BUGGY NEW-- dec num_left_over
979 ; --BUGGY NEW-- jne NDEP_loop
981 ; --BUGGY NEW-- jmp _none_to_do
989 ; compute v coordinate
993 idiv ecx ; eax = (v/z)
995 and eax,3fh ; mask with height-1
998 ; compute u coordinate
1002 idiv ecx ; eax = (u/z)
1005 shld ebx,eax,6 ; esi = v*64+u
1010 mov al, [ebx] ; get pixel from source bitmap
1013 mov ebx, [_fx_l] ; get temp copy of lighting value
1014 mov ah, bh ; get lighting level
1015 add ebx, [_fx_dl_dx] ; update lighting value
1016 mov [_fx_l], ebx ; save temp copy of lighting value
1018 ; transparency check
1020 je NDEP_skip2 ; this pixel is transparent, so don't write it (or light it)
1022 mov al, [_gr_fade_table+eax] ; xlat pixel thru lighting tables
1032 je near _div_0_abort ; would be dividing by 0, so abort
1034 dec dword [num_left_over]
1039 ; ==================================================== No Lighting Code ======================================================
1040 global _tmap_loop_fast_nolight
1041 _tmap_loop_fast_nolight:
1045 NotDwordAligned1_nolight:
1047 jz DwordAligned1_nolight
1049 ; compute v coordinate
1053 idiv ecx ; eax = (v/z)
1055 and eax,3fh ; mask with height-1
1058 ; compute u coordinate
1059 mov eax, esi ; get u
1062 idiv ecx ; eax = (u/z)
1065 shld ebx,eax,6 ; esi = v*64+u
1069 mov al,[ebx] ; get pixel from source bitmap
1081 je near _div_0_abort ; would be dividing by 0, so abort
1083 dec dword [_loop_count]
1084 jns NotDwordAligned1_nolight
1087 DwordAligned1_nolight:
1090 mov eax, [_loop_count]
1092 mov [num_left_over], eax
1096 je near tmap_loop ; no 2^NBITS chunks, do divide/pixel for whole scanline
1098 mov [_loop_count], eax ; _loop_count = pixels / NPIXS
1100 sub [num_left_over], eax ; num_left_over = obvious
1102 ; compute initial v coordinate
1108 idiv ecx ; eax = (v/z)
1113 ; compute initial u coordinate
1119 idiv ecx ; eax = (v/z)
1124 ; Set deltas to NPIXS pixel increments
1125 mov eax, [_fx_du_dx]
1128 mov eax, [_fx_dv_dx]
1131 mov eax, [_fx_dz_dx]
1140 je near _div_0_abort
1142 ; Done with ebx, ebp, ecx until next iteration
1154 idiv ecx ; eax = (v/z)
1157 mov ebx, eax ; ebx = U1 until pop's
1165 idiv ecx ; eax = (v/z)
1168 mov ebp, eax ; ebp = V1 until pop's
1170 mov ecx, [U0] ; ecx = U0 until pop's
1171 mov edi, [V0] ; edi = V0 until pop's
1173 ; Make ESI = V0:U0 in 6:10,6:10 format
1180 ; Make EDX = DV:DU in 6:10,6:10 format
1186 shl edx, 10-NBITS ; EDX = V1-V0/ 4 in 6:10 int:frac
1187 mov dx, ax ; put delta u in low word
1189 ; Save the U1 and V1 so we don't have to divide on the next iteration
1193 pop edi ; Restore EDI before using it
1197 mov eax, esi ; get u,v
1198 shr eax, 26 ; shift out all but int(v)
1199 shld ax,si,6 ; shift in u, shifting up v
1200 add esi, edx ; inc u,v
1202 mov cl, [eax] ; load into buffer register
1204 mov eax, esi ; get u,v
1205 shr eax, 26 ; shift out all but int(v)
1206 shld ax,si,6 ; shift in u, shifting up v
1208 mov ch, [eax] ; load into buffer register
1209 add esi, edx ; inc u,v
1210 ror ecx, 16 ; move to next dest pixel
1212 mov eax, esi ; get u,v
1213 shr eax, 26 ; shift out all but int(v)
1214 shld ax,si,6 ; shift in u, shifting up v
1216 mov cl, [eax] ; load into buffer register
1217 add esi, edx ; inc u,v
1219 mov eax, esi ; get u,v
1220 shr eax, 26 ; shift out all but int(v)
1221 shld ax,si,6 ; shift in u, shifting up v
1223 mov ch, [eax] ; load into buffer register
1224 add esi, edx ; inc u,v
1225 ror ecx, 16 ;-- can get rid of this, just write in different order below -- ; move to next dest pixel
1227 test dword [_Transparency_on],-1
1256 mov [edi],ecx ; Draw 4 pixels to display
1260 %rep (1 << (NBITS-2))
1261 ;local skip7, no_trans2, skip1q, skip2q, skip3q, skip4q
1269 dec dword [_loop_count]
1270 jnz near TopOfLoop4_nolight
1274 test dword [num_left_over], -1
1277 DoEndPixels_nolight:
1281 je near _div_0_abort
1282 push edi ; use edi as a temporary variable
1289 idiv ecx ; eax = (v/z)
1291 mov ebx, eax ; ebx = U1 until pop's
1298 idiv ecx ; eax = (v/z)
1300 mov ebp, eax ; ebp = V1 until pop's
1302 mov ecx, [U0] ; ecx = U0 until pop's
1303 mov edi, [V0] ; edi = V0 until pop's
1305 ; Make ESI = V0:U0 in 6:10,6:10 format
1312 ; Make EDX = DV:DU in 6:10,6:10 format
1318 shl edx, 10-NBITS ; EDX = V1-V0/ 4 in 6:10 int:frac
1319 mov dx, ax ; put delta u in low word
1321 pop edi ; Restore EDI before using it
1323 mov ecx, [num_left_over]
1328 mov eax, esi ; get u,v
1329 shr eax, 26 ; shift out all but int(v)
1330 shld ax,si,6 ; shift in u, shifting up v
1332 movzx eax, byte [eax] ; load into buffer register
1333 add esi, edx ; inc u,v
1336 mov [edi+ITERATION], al ; write pixel
1344 %assign ITERATION ITERATION + 1
1347 ; Should never get here!!!!!