convert line ends
[canaan.git] / prj / cam / src / portal / ptsurf.asm
blobbd0126607550ccfe033f5e6244ee6578b3566f75
1 ; $Header: r:/t2repos/thief2/src/portal/ptsurf.asm,v 1.15 1998/04/06 12:43:14 MAT Exp $
3 ; PORTAL Texture Mappers
5 ; ptmap.asm
6 ; support functions
9 .486
10 .nolist
12 include macros.inc
13 include lg.inc
14 include fix.inc
15 include thunks.inc
17 .list
19 assume cs:_TEXT, ds:_DATA
21 extd _grd_light_table
23 _DATA segment dword public USE32 'DATA'
25 align 4
27 texture_row dd 0
28 output_row dd 0
29 light_row dd 0
30 didy dd 0
31 didxdy dd 0
32 temp_light1 dd 0
33 temp_light2 dd 0
34 tempy dd 0
37 ; import
38 externdef __portal_surface_texture_row: dword
39 externdef __portal_surface_output_row: dword
40 externdef __portal_surface_lightmap_row: dword
41 externdef __portal_surface_texture: dword
42 externdef __portal_surface_output: dword
43 externdef __portal_surface_lightmap: dword
45 _DATA ends
48 _TEXT segment para public USE32 'CODE'
51 ; eax i
52 ; ebx light table
53 ; ecx bytes being processed
54 ; edx bytes being processed
55 ; esi source
56 ; edi dest
57 ; ebp didx
58 pt_buildspan_8:
59 mov ch,ah
60 add eax,ebp
62 mov cl,[esi]
63 mov dh,ah
65 mov dl,[esi+1]
66 add eax,ebp
68 mov cl,[ebx+ecx]
69 nop
71 mov dl,[ebx+edx]
72 mov [edi],cl
74 mov ch,ah
75 add eax,ebp
77 mov cl,[esi+2]
78 mov dh,ah
80 mov [edi+1],dl
81 mov dl,[esi+3]
83 mov cl,[ebx+ecx]
84 add eax,ebp
86 mov [edi+2],cl
87 mov ch,ah
89 add eax,ebp
90 mov dl,[ebx+edx]
92 mov cl,[esi+4]
93 mov dh,ah
95 mov [edi+3],dl
96 mov dl,[esi+5]
98 mov cl,[ebx+ecx]
99 add eax,ebp
101 mov dl,[ebx+edx]
102 mov [edi+4],cl
104 mov ch,ah
105 add eax,ebp
107 mov cl,[esi+6]
108 mov dh,ah
110 mov [edi+5],dl
111 mov dl,[esi+7]
113 mov cl,[ebx+ecx]
114 add eax,ebp
116 mov [edi+6],cl
117 mov dl,[ebx+edx]
119 mov [edi+7],dl
125 pt_buildspan_8_x:
126 mov ecx,eax
127 add eax,ebp
128 shr ecx,8
130 mov cl,[esi]
131 mov edx,eax
132 shr edx,8
134 mov dl,[esi+1]
135 add eax,ebp
137 mov cl,[ebx+ecx]
140 mov dl,[ebx+edx]
141 mov [edi],cl
143 mov ecx,eax
144 add eax,ebp
145 shr ecx,8
147 mov cl,[esi+2]
148 mov edx,eax
149 shr edx,8
151 mov [edi+1],dl
152 mov dl,[esi+3]
154 mov cl,[ebx+ecx]
155 add eax,ebp
157 mov [edi+2],cl
158 mov ecx,eax
159 shr ecx,8
161 add eax,ebp
162 mov dl,[ebx+edx]
164 mov cl,[esi+4]
165 mov edx,eax
166 shr edx,8
168 mov [edi+3],dl
169 mov dl,[esi+5]
171 mov cl,[ebx+ecx]
172 add eax,ebp
174 mov dl,[ebx+edx]
175 mov [edi+4],cl
177 mov ecx,eax
178 shr ecx,8
179 add eax,ebp
181 mov cl,[esi+6]
182 mov edx,eax
183 shr edx,8
185 mov [edi+5],dl
186 mov dl,[esi+7]
188 mov cl,[ebx+ecx]
189 add eax,ebp
191 mov [edi+6],cl
192 mov dl,[ebx+edx]
194 mov [edi+7],dl
197 ; ESI = texture source
198 ; EDI = output location
199 ; EDX = lightmap source
201 ; EAX = texture row
202 ; EBX = output row
203 ; ECX = lightmap row
204 _FUNCDEF_ASM pt_surfbuild_16
205 push ebp
206 push esi
208 push eax
209 push ebx
211 push ecx
212 push edx
214 push edi
215 mov eax, [__portal_surface_texture_row]
217 mov ebx, [__portal_surface_output_row]
218 mov ebp, [__portal_surface_lightmap_row]
220 mov edx, [__portal_surface_lightmap]
221 sub eax, 8
223 mov esi, [__portal_surface_texture]
224 sub ebx,8
226 mov texture_row, eax
227 mov output_row, ebx
229 mov bl,[edx]
230 mov cl,[edx + ebp + 1]
232 mov bh, [edx + 1]
233 mov ch, [edx + ebp]
235 and ebx, 0f0f0h ; mask off all but upper 4 bits of light levels
236 and ecx, 0f0f0h
238 mov edi, [__portal_surface_output]
239 cmp ebx, ecx
241 jne pt_surfbuild_gouraud_16
243 cmp cl, ch
245 je pt_surfbuild_uniform_16
247 pt_surfbuild_gouraud_16:
248 xor eax,eax
249 xor ebx,ebx
251 mov al, [edx]
252 xor ecx, ecx
254 mov bl, [edx+1]
255 mov cl, [edx+ebp]
257 sub ebx,eax ; ebx == di(0)dx * 16
258 mov dl,[edx+ebp+1]
260 shl eax,4 ; eax == i(0)*16
261 and edx,0ffh
263 sub edx,ecx ; edx == di(16)dx * 16
265 shl ecx,4 ; ecx == i(16)*16
266 sub edx,ebx ; edx == di(0)dxdy * 256
268 shl ebx,4 ; ebx == di(0)dx * 64
269 sub ecx,eax ; ecx == di(0)dy * 256
271 shl eax,4 ; eax == i(0)*256
272 mov didy,ecx
274 xor ecx,ecx
275 mov didxdy,edx
277 mov ebp,ebx
278 mov ebx,_grd_light_table
280 xor edx,edx
281 mov ecx, 16
283 ; eax = 0..15 * 256*16
284 ; eax derived from number from 0..255, so
285 ; eax = 0..255 * 256
287 pt_surf16_looptop:
288 push eax
289 push ecx
291 shr eax, 4
292 mov edx, ebp
294 shr edx, 28 ; round negative didx towards 0
295 push ebp
297 mov cl,[edi] ; cache prefetch
298 add ebp, edx
300 sar ebp, 4
301 call pt_buildspan_8
303 add esi, 8
304 add edi, 8
306 mov cl,[edi] ; cache prefetch
307 call pt_buildspan_8
309 add esi,texture_row
310 add edi,output_row
312 ; wait for 2-cycle instructions
314 pop ebp
315 pop ecx
316 pop eax
318 add eax,didy
319 add ebp,didxdy
321 ; wait for 2-cycle instructions
323 dec ecx
324 jnz pt_surf16_looptop
326 jmp pt_surfbuild_done_16
328 pt_surfbuild_uniform_16:
329 shr ebx, 4
330 mov ebp, _grd_light_table
332 mov eax, ebx
333 mov ecx, ebx
335 mov edx, ebx
336 mov texture_row, 16
338 pt_surfbuild_uniform_16_loop:
339 mov al, [edi] ; prefetch
342 ; first set of 4 texels
343 mov al, [esi]
344 mov bl, [esi + 4]
346 mov cl, [esi + 8]
347 mov dl, [esi + 12]
349 mov al, [eax + ebp]
350 mov bl, [ebx + ebp]
352 mov cl, [ecx + ebp]
353 mov dl, [edx + ebp]
355 mov [edi], al
356 mov [edi + 4], bl
358 mov [edi + 8], cl
359 mov [edi + 12], dl
361 ; second set of 4 texels
362 mov al, [esi + 1]
363 mov bl, [esi + 5]
365 mov cl, [esi + 9]
366 mov dl, [esi + 13]
368 mov al, [eax + ebp]
369 mov bl, [ebx + ebp]
371 mov cl, [ecx + ebp]
372 mov dl, [edx + ebp]
374 mov [edi + 1], al
375 mov [edi + 5], bl
377 mov [edi + 9], cl
378 mov [edi + 13], dl
380 ; third set of 4 texels
381 mov al, [esi + 2]
382 mov bl, [esi + 6]
384 mov cl, [esi + 10]
385 mov dl, [esi + 14]
387 mov al, [eax + ebp]
388 mov bl, [ebx + ebp]
390 mov cl, [ecx + ebp]
391 mov dl, [edx + ebp]
393 mov [edi + 2], al
394 mov [edi + 6], bl
396 mov [edi + 10], cl
397 mov [edi + 14], dl
399 ; fourth set of 4 texels
400 mov al, [esi + 3]
401 mov bl, [esi + 7]
403 mov cl, [esi + 11]
404 mov dl, [esi + 15]
406 mov al, [eax + ebp]
407 mov bl, [ebx + ebp]
409 mov cl, [ecx + ebp]
410 mov dl, [edx + ebp]
412 mov [edi + 3], al
413 mov [edi + 7], bl
415 mov [edi + 11], cl
416 mov [edi + 15], dl
418 add esi, [__portal_surface_texture_row]
419 add edi, __portal_surface_output_row
421 dec texture_row
423 jnz pt_surfbuild_uniform_16_loop
425 pt_surfbuild_done_16:
426 pop edi
427 pop edx
428 pop ecx
429 pop ebx
430 pop eax
431 pop esi
432 pop ebp
438 _FUNCDEF_ASM pt_surfbuild_8
439 push ebp
440 push esi
442 push eax
443 push ebx
445 push ecx
446 push edx
448 push edi
449 mov eax, [__portal_surface_texture_row]
451 mov ebx, [__portal_surface_output_row]
452 mov ebp, [__portal_surface_lightmap_row]
454 mov edx, [__portal_surface_lightmap]
455 mov texture_row,eax
457 mov esi, [__portal_surface_texture]
458 mov output_row, ebx
460 mov bl, [edx]
461 mov cl, [edx + ebp + 1]
463 mov bh, [edx + ebp]
464 mov ch, [edx + 1]
466 and ebx, 0f0f0h
467 and ecx, 0f0f0h
469 mov edi, [__portal_surface_output]
470 cmp ebx, ecx
472 jne pt_surfbuild_gouraud_8
474 cmp cl, ch
476 je pt_surfbuild_uniform_8
478 pt_surfbuild_gouraud_8:
479 xor eax,eax
480 xor ebx,ebx
482 mov al, [edx]
483 xor ecx, ecx
485 mov bl, [edx+1]
486 mov cl, [edx+ebp]
488 sub ebx, eax ; ebx == di(0)dx * 16
489 mov dl, [edx+ebp+1]
491 shl eax, 3 ; eax == i(0)*8
492 and edx, 0ffh
494 sub edx,ecx ; edx == di(16)dx * 16
496 shl ecx,3 ; ecx == i(16)*16
497 sub edx,ebx ; edx == di(0)dxdy * 256
499 shl ebx,3 ; ebx == di(0)dx * 64
500 sub ecx,eax ; ecx == di(0)dy * 256
502 shl eax,3 ; eax == i(0)*256
503 mov didy,ecx
505 xor ecx,ecx
506 mov didxdy,edx
508 mov ebp,ebx
509 mov ebx,_grd_light_table
511 xor edx,edx
512 mov ecx,8
514 pt_surf8_looptop:
515 push eax
516 push ecx
518 shr eax, 2
519 mov edx, ebp
521 shr edx, 30 ; round negative didx towards 0
522 push ebp
524 mov cl,[edi] ; cache prefetch
525 add ebp, edx
527 sar ebp, 2
528 call pt_buildspan_8
530 add esi,texture_row
531 add edi,output_row
533 ; wait for 2-cycle instructions
535 pop ebp
536 pop ecx
537 pop eax
539 add eax,didy
540 add ebp,didxdy
542 ; wait for 2-cycle instructions
544 dec ecx
545 jnz pt_surf8_looptop
547 jmp pt_surfbuild_done_8
549 pt_surfbuild_uniform_8:
550 shr ebx, 4
551 mov ebp, [_grd_light_table]
553 mov eax, ebx
554 mov ecx, ebx
556 mov edx, ebx
557 mov texture_row, 8
559 pt_surfbuild_uniform_8_loop:
560 mov al, [edi] ; prefetch
563 ; first set of 4 texels
564 mov al, [esi]
565 mov bl, [esi + 4]
567 mov cl, [esi + 2]
568 mov dl, [esi + 6]
570 mov al, [eax + ebp]
571 mov bl, [ebx + ebp]
573 mov cl, [ecx + ebp]
574 mov dl, [edx + ebp]
576 mov [edi], al
577 mov [edi + 4], bl
579 mov [edi + 2], cl
580 mov [edi + 6], dl
582 ; second set of 4 texels
583 mov al, [esi + 1]
584 mov bl, [esi + 5]
586 mov cl, [esi + 3]
587 mov dl, [esi + 7]
589 mov al, [eax + ebp]
590 mov bl, [ebx + ebp]
592 mov cl, [ecx + ebp]
593 mov dl, [edx + ebp]
595 mov [edi + 1], al
596 mov [edi + 5], bl
598 mov [edi + 3], cl
599 mov [edi + 7], dl
601 add esi, [__portal_surface_texture_row]
602 add edi, [__portal_surface_output_row]
604 dec texture_row
605 jnz pt_surfbuild_uniform_8_loop
607 pt_surfbuild_done_8:
608 pop edi
609 pop edx
610 pop ecx
611 pop ebx
612 pop eax
613 pop esi
614 pop ebp
618 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
620 ; pt_surfbuild_4
622 _FUNCDEF_ASM pt_surfbuild_4
623 push edx
624 push edi
626 push eax
627 push esi
629 push ecx
630 push ebx
632 push ebp
633 mov edi, [__portal_surface_output]
635 mov ebp, [__portal_surface_lightmap_row]
636 mov al, [edi] ; prefetch first row
638 mov esi, [__portal_surface_texture]
639 mov edx, [__portal_surface_lightmap]
641 ; setup has four light levels-- a---b
642 ; we want our results x16 | |
643 ; for our light table lookups c---d
645 xor eax, eax
646 xor ecx, ecx
648 mov al, [edx]
649 mov cl, [edx + ebp]
651 mov bl, [edx + 1]
652 mov dl, [edx + ebp + 1]
654 and ebx, 0ffh
655 and edx, 0ffh
657 sub edx, ecx
658 mov ebp, ebx
660 sub ecx, eax
661 sub ebp, eax
663 shl ebp, 2 ; initial didx = (-4a + 4b) / 16
664 add edx, eax
666 shl ecx, 2 ; didy = (-4a + 4c) / 16
667 sub edx, ebx ; didxdy = (a - b - c + d) / 16
669 shl eax, 4 ; i0 = (16a) / 16
670 mov [didy], ecx
672 mov [didxdy], edx
673 mov dl, [edi + 0999999h]; prefetch second row
674 row_4_self_mod_1:
676 ; eax left edge intensity
677 ; ebx first point being processed
678 ; ecx second point being processed
679 ; edx output bytes
680 ; esi source texture
681 ; edi surface being built + misc.
682 ; ebp didx
684 lea ebx, [eax + 2 * ebp]
685 lea ecx, [eax + 2 * ebp]
687 mov bl, [esi + 2] ; We process the right-hand texels first
688 add ecx, ebp ; so we can shift them into upper 16 of edx.
690 mov cl, [esi + 3]
691 mov edi, [didxdy]
693 mov dl, [ebx + 0999999h]; self-modifying reference to light table
694 gouraud_4_self_mod_1:
695 mov ebx, eax
697 mov dh, [ecx + 0999999h]
698 gouraud_4_self_mod_2:
699 lea ecx, [eax + ebp]
701 shl edx, 16
702 mov bl, [esi]
704 mov cl, [esi + 1]
705 add ebp, edi ; didx += didxdy
707 mov dl, [ebx + 0999999h]
708 gouraud_4_self_mod_3:
709 mov edi, [__portal_surface_output]
711 mov dh, [ecx + 0999999h]
712 gouraud_4_self_mod_4:
713 mov ebx, [didy]
715 mov ecx, [__portal_surface_texture_row]
716 add eax, ebx ; left edge i += didy
718 mov [edi], edx
719 add esi, ecx ; texture pointer += texture row
721 mov dl, [edi + 0999999h] ; prefetch third row
722 row_4_self_mod_2:
725 ; second row
726 lea ebx, [eax + 2 * ebp]
727 lea ecx, [eax + 2 * ebp]
729 mov bl, [esi + 2] ; We process the second pair of texels first
730 add ecx, ebp ; so we can shift them into upper 16 of edx.
732 mov cl, [esi + 3]
733 mov edi, [didxdy]
735 mov dl, [ebx + 0999999h]; self-modifying reference to light table
736 gouraud_4_self_mod_5:
737 mov ebx, eax
739 mov dh, [ecx + 0999999h]
740 gouraud_4_self_mod_6:
741 lea ecx, [eax + ebp]
743 shl edx, 16
744 mov bl, [esi]
746 mov cl, [esi + 1]
747 add ebp, edi ; didx += didxdy
749 mov dl, [ebx + 0999999h]
750 gouraud_4_self_mod_7:
751 mov edi, [__portal_surface_output]
753 mov dh, [ecx + 0999999h]
754 gouraud_4_self_mod_8:
755 mov ebx, [didy]
757 mov ecx, [__portal_surface_texture_row]
758 add eax, ebx ; left edge i += didy
760 mov [edi + 0999999h], edx
761 row_4_self_mod_3:
762 add esi, ecx ; texture pointer += texture row
764 mov dl, [edi + 0999999h]; prefetch fourth row
765 row_4_self_mod_4:
768 ; third row
769 lea ebx, [eax + 2 * ebp]
770 lea ecx, [eax + 2 * ebp]
772 mov bl, [esi + 2] ; We process the second pair of texels first
773 add ecx, ebp ; so we can shift them into upper 16 of edx.
775 mov cl, [esi + 3]
776 mov edi, [didxdy]
778 mov dl, [ebx + 0999999h]; self-modifying reference to light table
779 gouraud_4_self_mod_9:
780 mov ebx, eax
782 mov dh, [ecx + 0999999h]
783 gouraud_4_self_mod_10:
784 lea ecx, [eax + ebp]
786 shl edx, 16
787 mov bl, [esi]
789 mov cl, [esi + 1]
790 add ebp, edi ; didx += didxdy
792 mov dl, [ebx + 0999999h]
793 gouraud_4_self_mod_11:
794 mov edi, [__portal_surface_output]
796 mov dh, [ecx + 0999999h]
797 gouraud_4_self_mod_12:
798 mov ebx, [didy]
800 mov ecx, [__portal_surface_texture_row]
801 add eax, ebx ; left edge i += didy
803 mov [edi + 0999999h], edx
804 row_4_self_mod_5:
805 add esi, ecx ; texture pointer += texture row
807 ; fourth row
808 lea ebx, [eax + 2 * ebp]
809 lea ecx, [eax + 2 * ebp]
811 mov bl, [esi + 2] ; We process the second pair of texels first
812 add ecx, ebp ; so we can shift them into upper 16 of edx.
814 mov cl, [esi + 3]
817 mov dl, [ebx + 0999999h]; self-modifying reference to light table
818 gouraud_4_self_mod_13:
819 mov ebx, eax
821 mov dh, [ecx + 0999999h]
822 gouraud_4_self_mod_14:
823 lea ecx, [eax + ebp]
825 shl edx, 16
826 mov bl, [esi]
828 mov cl, [esi + 1]
829 pop ebp
831 mov dl, [ebx + 0999999h]
832 gouraud_4_self_mod_15:
833 pop ebx
835 mov dh, [ecx + 0999999h]
836 gouraud_4_self_mod_16:
837 pop ecx
839 pop esi
840 pop eax
842 mov [edi + 0999999h], edx
843 row_4_self_mod_6:
845 pop edi
846 pop edx
850 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
852 ; pt_surfbuild_2
854 _FUNCDEF_ASM pt_surfbuild_2
856 push eax
857 push ebx
859 push ecx
860 push edx
862 push esi
863 push edi
865 xor ecx, ecx
866 xor edx, edx
868 ; We'll build one pixel/light combo in ecx and one in edx.
869 ; While the light for the upper-left pixel is raw data, the
870 ; light for the upper-right is the average of two values.
871 mov edi, [_grd_light_table]
872 mov esi, [__portal_surface_lightmap]
874 mov ebx, [__portal_surface_texture]
875 mov al, [edi] ; prefetch
877 mov cl, [esi]
878 mov dl, [esi + 1]
880 add edx, ecx
881 mov [temp_light1], ecx ; We'll be averaging these light values
883 ; We move our light bytes into ch and dh with bit shifts to
884 ; get them down to 4 bits each.
885 shl ecx, 4
886 mov [temp_light2], edx ; with others for the lower pixels.
888 shl edx, 3 ; average of two lightmap points
889 mov cl, [ebx]
891 mov dl, [ebx + 1]
892 mov cl, [edi + ecx] ; clut upper-left
894 mov eax, [__portal_surface_output]
895 mov dl, [edi + edx] ; clut upper-right
897 mov [eax], cl
898 mov [eax + 1], dl
900 add esi, [__portal_surface_lightmap_row]
902 ; The light for the lower two pixels is a little more involved
903 ; since they are both averages.
904 xor ecx, ecx
905 xor edx, edx
907 mov cl, [esi]
908 mov dl, [esi + 1]
910 add edx, [temp_light2]; average of two right-hand lights
911 add ebx, [__portal_surface_texture_row]
913 add edx, ecx ; lower-right light * 4
914 add eax, [__portal_surface_output_row]
916 add ecx, [temp_light1]; lower-left light * 2
918 shl edx, 2 ; average of four lightmap points
920 shl ecx, 3 ; average of two lightmap points
922 mov cl, [ebx] ; get texture points
923 mov dl, [ebx + 1]
925 mov cl, [edi + ecx] ; clut upper-left
926 mov dl, [edi + edx] ; clut upper-right
928 mov [eax], cl
929 mov [eax + 1], dl
931 pop edi
932 pop esi
933 pop edx
934 pop ecx
935 pop ebx
936 pop eax
941 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
943 ; pt_surfbuild_1
945 ; We prefetch here since this is called on seqential bytes.
947 _FUNCDEF_ASM pt_surfbuild_1
948 push eax
949 push edx
951 push ebx
952 push ecx
954 mov eax, [__portal_surface_lightmap]
955 mov ebx, [__portal_surface_output]
957 xor edx, edx
958 mov ecx, [__portal_surface_texture]
960 mov dh, [eax] ; high byte is light level
961 mov al, [ebx] ; prefetch
963 shr dh, 4 ; 16 levels of shading
964 mov eax, [_grd_light_table]
966 mov dl, [ecx] ; low byte is texture data
968 mov al, [eax + edx] ; translate light
969 pop ecx
971 mov [ebx], al
972 pop ebx
974 pop edx
975 pop eax
980 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
982 ; voif pt_surfbuild_setup (void)
984 ; These set up some self-modifying offsets. Actually, only one of
985 ; them does.
987 _FUNCDEF_ASM pt_surfbuild_setup_1
990 _FUNCDEF_ASM pt_surfbuild_setup_2
993 _FUNCDEF_ASM pt_surfbuild_setup_4
994 push eax
995 push edx
997 mov eax, [_grd_light_table]
998 mov edx, dword ptr ds:[gouraud_4_self_mod_1 - 4]
1000 cmp eax, edx
1001 je pt_surfbuild_setup_4_light_done
1003 mov dword ptr ds:gouraud_4_self_mod_1 - 4, eax
1004 mov dword ptr ds:gouraud_4_self_mod_2 - 4, eax
1005 mov dword ptr ds:gouraud_4_self_mod_3 - 4, eax
1006 mov dword ptr ds:gouraud_4_self_mod_4 - 4, eax
1007 mov dword ptr ds:gouraud_4_self_mod_5 - 4, eax
1008 mov dword ptr ds:gouraud_4_self_mod_6 - 4, eax
1009 mov dword ptr ds:gouraud_4_self_mod_7 - 4, eax
1010 mov dword ptr ds:gouraud_4_self_mod_8 - 4, eax
1011 mov dword ptr ds:gouraud_4_self_mod_9 - 4, eax
1012 mov dword ptr ds:gouraud_4_self_mod_10 - 4, eax
1013 mov dword ptr ds:gouraud_4_self_mod_11 - 4, eax
1014 mov dword ptr ds:gouraud_4_self_mod_12 - 4, eax
1015 mov dword ptr ds:gouraud_4_self_mod_13 - 4, eax
1016 mov dword ptr ds:gouraud_4_self_mod_14 - 4, eax
1017 mov dword ptr ds:gouraud_4_self_mod_15 - 4, eax
1018 mov dword ptr ds:gouraud_4_self_mod_16 - 4, eax
1020 pt_surfbuild_setup_4_light_done:
1021 mov eax, __portal_surface_output_row
1022 mov edx, dword ptr ds:[gouraud_4_self_mod_1 - 4]
1024 cmp eax, edx
1025 je pt_surfbuild_setup_4_row_done
1027 mov dword ptr ds:row_4_self_mod_1 - 4, eax
1028 mov dword ptr ds:row_4_self_mod_3 - 4, eax
1030 lea edx, [eax + eax * 2] ; row * 3
1031 add eax, eax ; row * 2
1033 mov dword ptr ds:row_4_self_mod_4 - 4, edx
1034 mov dword ptr ds:row_4_self_mod_6 - 4, edx
1036 mov dword ptr ds:row_4_self_mod_2 - 4, eax
1037 mov dword ptr ds:row_4_self_mod_5 - 4, eax
1039 pt_surfbuild_setup_4_row_done:
1040 pop edx
1041 pop eax
1046 _FUNCDEF_ASM pt_surfbuild_setup_8
1049 _FUNCDEF_ASM pt_surfbuild_setup_16
1054 ;pt_buildspan_8_pal:
1055 ; mov cl,ah
1056 ; add eax,ebp
1058 ; mov ch,ah
1059 ; add eax,ebp
1061 ; mov dl,ah
1062 ; add eax,ebp
1064 ; mov dh,ah
1065 ; add eax,ebp
1067 ; shl edx,16
1068 ; and ecx,0ffffh
1070 ; or edx,ecx
1071 ; mov ecx,[esi]
1073 ; add edx,ecx
1074 ; mov cl,ah
1076 ; mov [edi],edx
1077 ; add eax,ebp
1079 ; mov ch,ah
1080 ; add eax,ebp
1082 ; mov dl,ah
1083 ; add eax,ebp
1085 ; mov dh,ah
1086 ; add eax,ebp
1088 ; shl edx,16
1089 ; and ecx,0ffffh
1091 ; or edx,ecx
1092 ; mov ecx,[esi]
1094 ; add edx,ecx
1096 ; mov [edi+4],edx
1097 ; ret
1099 ; ; ESI = texture source
1100 ; ; EDI = output location
1101 ; ; EDX = lightmap source
1103 ; ; EAX = texture row
1104 ; ; EBX = output row
1105 ; ; ECX = lightmap row
1106 ;pt_surfbuild_16_pal:
1107 ; push ebp
1108 ; sub eax,8
1110 ; mov texture_row,eax
1111 ; sub ebx,8
1113 ; mov output_row,ebx
1114 ; mov ebp,ecx
1116 ; xor eax,eax
1117 ; xor ebx,ebx
1119 ; mov al,[edx]
1120 ; xor ecx,ecx
1122 ; mov bl,[edx+1]
1123 ; mov cl,[edx+ebp]
1125 ; sub ebx,eax ; ebx == di(0)dx * 16
1126 ; mov dl,[edx+ebp+1]
1128 ; shl eax,4 ; eax == i(0)*16
1129 ; and edx,0ffh
1131 ; sub edx,ecx ; edx == di(16)dx * 16
1133 ; shl ecx,4 ; ecx == i(16)*16
1134 ; sub edx,ebx ; edx == di(0)dxdy * 256
1136 ; shl ebx,4 ; ebx == di(0)dx * 64
1137 ; sub ecx,eax ; ecx == di(0)dy * 256
1139 ; shl eax,4 ; eax == i(0)*256
1140 ; mov didy,ecx
1142 ; shr edx,4
1143 ; xor ecx,ecx
1145 ; shr ebx,4
1146 ; mov didxdy,edx
1148 ; mov ebp,ebx
1149 ; mov ebx,_grd_light_table
1151 ; xor edx,edx
1152 ; mov ecx,16
1154 ;pt_surf16_looptop_pal:
1155 ; push eax
1156 ; push ecx
1158 ; shr eax,5
1159 ; mov cl,[edi]
1160 ; shr ebp,1
1161 ; call pt_buildspan_8_pal
1163 ; add esi,8
1164 ; add edi,8
1166 ; mov cl,[edi]
1167 ; call pt_buildspan_8_pal
1169 ; add esi,texture_row
1170 ; add edi,output_row
1172 ; ; wait for 2-cycle instructions
1174 ; pop ecx
1175 ; pop eax
1177 ; add eax,didy
1178 ; add ebp,didxdy
1180 ; ; wait for 2-cycle instructions
1182 ; dec ecx
1183 ; jnz pt_surf16_looptop_pal
1185 ; pop ebp
1186 ; ret
1188 ;pt_surfbuild_8_pal:
1189 ; push ebp
1190 ; mov texture_row,eax
1192 ; mov output_row,ebx
1193 ; mov ebp,ecx
1195 ; xor eax,eax
1196 ; xor ebx,ebx
1198 ; mov al,[edx]
1199 ; xor ecx,ecx
1201 ; mov bl,[edx+1]
1202 ; mov cl,[edx+ebp]
1204 ; sub ebx,eax ; ebx == di(0)dx * 16
1205 ; mov dl,[edx+ebp+1]
1207 ; shl eax,3 ; eax == i(0)*16
1208 ; and edx,0ffh
1210 ; sub edx,ecx ; edx == di(16)dx * 16
1212 ; shl ecx,3 ; ecx == i(16)*16
1213 ; sub edx,ebx ; edx == di(0)dxdy * 256
1215 ; shl ebx,3 ; ebx == di(0)dx * 64
1216 ; sub ecx,eax ; ecx == di(0)dy * 256
1218 ; shl eax,3 ; eax == i(0)*256
1219 ; mov didy,ecx
1221 ; shr edx,2
1222 ; xor ecx,ecx
1224 ; shr ebx,2
1225 ; mov didxdy,edx
1227 ; mov ebp,ebx
1228 ; mov ebx,_grd_light_table
1230 ; xor edx,edx
1231 ; mov ecx,8
1233 ;pt_surf8_looptop_pal:
1234 ; push eax
1235 ; push ecx
1237 ; shr eax,3
1238 ; mov cl,[edi]
1239 ; shr ebp,1
1240 ; call pt_buildspan_8_pal
1242 ; add esi,texture_row
1243 ; add edi,output_row
1245 ; ; wait for 2-cycle instructions
1247 ; pop ecx
1248 ; pop eax
1250 ; add eax,didy
1251 ; add ebp,didxdy
1253 ; ; wait for 2-cycle instructions
1255 ; dec ecx
1256 ; jnz pt_surf8_looptop_pal
1258 ; pop ebp
1259 ; ret
1261 _TEXT ends