Rev 5278 | Rev 5418 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5278 | Rev 5353 | ||
---|---|---|---|
Line 11... | Line 11... | ||
11 | offs_X equ 0 |
11 | offs_X equ 0 |
12 | offs_Y equ 4 |
12 | offs_Y equ 4 |
13 | offs_Z equ 8 |
13 | offs_Z equ 8 |
14 | offs_W equ 12 |
14 | offs_W equ 12 |
Line -... | Line 15... | ||
- | 15 | ||
- | 16 | if DEBUG |
|
- | 17 | f_ttv db ' gl_transform_to_viewport',0 |
|
- | 18 | end if |
|
15 | 19 | ||
16 | align 4 |
20 | align 4 |
17 | proc gl_transform_to_viewport uses eax ebx ecx, context:dword,v:dword |
21 | proc gl_transform_to_viewport uses eax ebx ecx, context:dword,v:dword |
18 | locals |
22 | locals |
19 | point dd ? |
23 | point dd ? |
Line 67... | Line 71... | ||
67 | mov ecx,[eax+offs_cont_longcurrent_color+8] |
71 | mov ecx,[eax+offs_cont_longcurrent_color+8] |
68 | mov dword[ebx+offs_vert_zp+offs_zbup_b],ecx |
72 | mov dword[ebx+offs_vert_zp+offs_zbup_b],ecx |
69 | .end_if: |
73 | .end_if: |
Line 70... | Line 74... | ||
70 | 74 | ||
71 | ; texture |
75 | ; texture |
72 | bt dword[eax+offs_cont_texture_2d_enabled],0 |
76 | cmp dword[eax+offs_cont_texture_2d_enabled],0 |
73 | jnc @f |
77 | je @f |
74 | mov dword[point],dword(ZB_POINT_S_MAX - ZB_POINT_S_MIN) |
78 | mov dword[point],dword(ZB_POINT_S_MAX - ZB_POINT_S_MIN) |
75 | fild dword[point] |
79 | fild dword[point] |
76 | fmul dword[ebx+offs_vert_tex_coord] ;st0 *= v.tex_coord.X |
80 | fmul dword[ebx+offs_vert_tex_coord] ;st0 *= v.tex_coord.X |
77 | fistp dword[ebx+offs_vert_zp+offs_zbup_s] |
81 | fistp dword[ebx+offs_vert_zp+offs_zbup_s] |
Line 82... | Line 86... | ||
82 | fmul dword[ebx+offs_vert_tex_coord+4] ;st0 *= v.tex_coord.Y |
86 | fmul dword[ebx+offs_vert_tex_coord+4] ;st0 *= v.tex_coord.Y |
83 | fistp dword[ebx+offs_vert_zp+offs_zbup_t] |
87 | fistp dword[ebx+offs_vert_zp+offs_zbup_t] |
84 | add dword[ebx+offs_vert_zp+offs_zbup_s],ZB_POINT_T_MIN |
88 | add dword[ebx+offs_vert_zp+offs_zbup_s],ZB_POINT_T_MIN |
85 | @@: |
89 | @@: |
86 | if DEBUG ;gl_transform_to_viewport |
90 | if DEBUG ;gl_transform_to_viewport |
87 | push edi |
91 | pushad |
88 | mov ecx,80 |
92 | mov ecx,80 |
89 | mov eax,[ebx+offs_vert_zp] |
93 | mov eax,[ebx+offs_vert_zp] |
90 | lea edi,[buf_param] |
94 | lea edi,[buf_param] |
91 | stdcall convert_int_to_str,ecx |
95 | stdcall convert_int_to_str,ecx |
92 | stdcall str_n_cat,edi,txt_zp_sp,2 |
96 | stdcall str_n_cat,edi,txt_zp_sp,2 |
Line 104... | Line 108... | ||
104 | mov eax,[ebx+offs_vert_zp+offs_zbup_z] |
108 | mov eax,[ebx+offs_vert_zp+offs_zbup_z] |
105 | stdcall convert_int_to_str,ecx |
109 | stdcall convert_int_to_str,ecx |
Line 106... | Line 110... | ||
106 | 110 | ||
107 | stdcall str_n_cat,edi,txt_nl,2 |
111 | stdcall str_n_cat,edi,txt_nl,2 |
108 | stdcall dbg_print,f_ttv,buf_param |
112 | stdcall dbg_print,f_ttv,buf_param |
109 | pop edi |
113 | popad |
110 | end if |
114 | end if |
111 | ret |
115 | ret |
Line 112... | Line 116... | ||
112 | endp |
116 | endp |
Line 168... | Line 172... | ||
168 | mov ebx,[p0] |
172 | mov ebx,[p0] |
169 | mov ecx,[p1] |
173 | mov ecx,[p1] |
170 | fld dword[t] |
174 | fld dword[t] |
Line 171... | Line 175... | ||
171 | 175 | ||
172 | ; интерполяция по координатам |
176 | ; интерполяция по координатам |
173 | fld dword[ecx+offs_vert_pc+offs_X] |
177 | fld dword[ecx+offs_vert_pc] |
174 | fsub dword[ebx+offs_vert_pc+offs_X] |
178 | fsub dword[ebx+offs_vert_pc] |
175 | fmul st0,st1 |
179 | fmul st0,st1 |
176 | fadd dword[ebx+offs_vert_pc+offs_X] |
180 | fadd dword[ebx+offs_vert_pc] |
Line 177... | Line 181... | ||
177 | fstp dword[eax+offs_vert_pc+offs_X] |
181 | fstp dword[eax+offs_vert_pc] ;q.pc.X = p0.pc.X + (p1.pc.X - p0.pc.X) * t |
178 | 182 | ||
179 | fld dword[ecx+offs_vert_pc+offs_Y] |
183 | fld dword[ecx+offs_vert_pc+offs_Y] |
180 | fsub dword[ebx+offs_vert_pc+offs_Y] |
184 | fsub dword[ebx+offs_vert_pc+offs_Y] |
Line 661... | Line 665... | ||
661 | @@: |
665 | @@: |
Line 662... | Line 666... | ||
662 | 666 | ||
663 | stdcall gl_clipcode, [ebx+offs_vert_pc+offs_X],[ebx+offs_vert_pc+offs_Y],\ |
667 | stdcall gl_clipcode, [ebx+offs_vert_pc+offs_X],[ebx+offs_vert_pc+offs_Y],\ |
664 | [ebx+offs_vert_pc+offs_Z],[ebx+offs_vert_pc+offs_W] |
668 | [ebx+offs_vert_pc+offs_Z],[ebx+offs_vert_pc+offs_W] |
665 | mov dword[ebx+offs_vert_clip_code],eax |
669 | mov dword[ebx+offs_vert_clip_code],eax |
666 | cmp eax,0 ;if (q.clip_code==0) |
670 | or eax,eax ;if (q.clip_code==0) |
667 | jne @f |
671 | jnz @f |
668 | stdcall gl_transform_to_viewport,[context],ebx |
672 | stdcall gl_transform_to_viewport,[context],ebx |
669 | mov eax,ebx |
673 | mov eax,ebx |
670 | add eax,offs_vert_zp+offs_zbup_b |
674 | add eax,offs_vert_zp+offs_zbup_b |
671 | push eax |
675 | push eax |
Line 687... | Line 691... | ||
687 | endl |
691 | endl |
688 | pushad |
692 | pushad |
689 | mov ebx,[p0] |
693 | mov ebx,[p0] |
690 | mov ecx,[p1] |
694 | mov ecx,[p1] |
691 | mov edx,[p2] |
695 | mov edx,[p2] |
692 | - | ||
693 | mov edi,[ebx+offs_vert_clip_code] |
696 | mov edi,[ebx+offs_vert_clip_code] |
694 | mov dword[cc],edi |
697 | mov dword[cc],edi |
695 | mov eax,[ecx+offs_vert_clip_code] |
698 | mov eax,[ecx+offs_vert_clip_code] |
696 | mov dword[cc+4],eax |
699 | mov dword[cc+4],eax |
697 | or edi,eax |
700 | or edi,eax |
698 | mov eax,[edx+offs_vert_clip_code] |
701 | mov eax,[edx+offs_vert_clip_code] |
699 | mov dword[cc+8],eax |
702 | mov dword[cc+8],eax |
700 | or edi,eax ;co = cc[0] | cc[1] | cc[2] |
703 | or edi,eax ;co = cc[0] | cc[1] | cc[2] |
Line 701... | Line 704... | ||
701 | 704 | ||
702 | ; we handle the non clipped case here to go faster |
705 | ; we handle the non clipped case here to go faster |
703 | cmp edi,0 ;if (co==0) |
706 | ;or edi,___ - было выше |
- | 707 | jnz .els_0 |
|
704 | jne .els_0 |
708 | ;if (co==0) |
705 | mov edi,dword[edx+offs_vert_zp+offs_zbup_x] |
709 | mov edi,dword[edx+offs_vert_zp+offs_zbup_x] |
706 | sub edi,dword[ebx+offs_vert_zp+offs_zbup_x] |
710 | sub edi,dword[ebx+offs_vert_zp+offs_zbup_x] |
707 | mov dword[norm],edi |
711 | mov dword[norm],edi |
708 | fild dword[norm] |
712 | fild dword[norm] |
Line 726... | Line 730... | ||
726 | fldz |
730 | fldz |
727 | fcompp |
731 | fcompp |
728 | fstsw ax |
732 | fstsw ax |
729 | sahf |
733 | sahf |
730 | je .end_f |
734 | je .end_f |
731 | jb @f |
735 | jbe @f ;jb @f ??? |
732 | inc dword[front] ;front = 0.0 > norm |
736 | inc dword[front] ;front = 0.0 > norm |
733 | @@: |
737 | @@: |
734 | mov edi,[context] |
738 | mov edi,[context] |
735 | mov eax,dword[edi+offs_cont_current_front_face] |
739 | mov eax,dword[edi+offs_cont_current_front_face] |
736 | xor dword[front],eax ;front ^= context.current_front_face |
740 | xor dword[front],eax ;front ^= context.current_front_face |
737 | - | ||
738 | ; back face culling |
741 | ; back face culling |
739 | cmp dword[edi+offs_cont_cull_face_enabled],0 |
742 | cmp dword[edi+offs_cont_cull_face_enabled],0 |
740 | je .els_1 |
743 | je .els_1 |
741 | ; most used case first |
744 | ; most used case first |
742 | cmp dword[edi+offs_cont_current_cull_face],GL_BACK |
745 | cmp dword[edi+offs_cont_current_cull_face],GL_BACK |
Line 763... | Line 766... | ||
763 | jmp .end_f |
766 | jmp .end_f |
764 | .els_0: |
767 | .els_0: |
765 | ;eax = cc[2] |
768 | ;eax = cc[2] |
766 | and eax,[cc] |
769 | and eax,[cc] |
767 | and eax,[cc+4] ;eax = c_and = cc[0] & cc[1] & cc[2] |
770 | and eax,[cc+4] ;eax = c_and = cc[0] & cc[1] & cc[2] |
768 | cmp eax,0 ;if (c_and==0) |
771 | or eax,eax ;if (c_and==0) |
769 | jne .end_f |
772 | jnz .end_f |
770 | stdcall gl_draw_triangle_clip, [context],ebx,ecx,edx,0 |
773 | stdcall gl_draw_triangle_clip, [context],ebx,ecx,edx,0 |
771 | .end_f: |
774 | .end_f: |
772 | popad |
775 | popad |
773 | ret |
776 | ret |
774 | endp |
777 | endp |
Line 797... | Line 800... | ||
797 | mov eax,[edx+offs_vert_clip_code] |
800 | mov eax,[edx+offs_vert_clip_code] |
798 | mov [cc+8],eax |
801 | mov [cc+8],eax |
799 | or edi,eax |
802 | or edi,eax |
800 | mov [co],edi ;co = cc[0] | cc[1] | cc[2] |
803 | mov [co],edi ;co = cc[0] | cc[1] | cc[2] |
Line 801... | Line 804... | ||
801 | 804 | ||
802 | cmp edi,0 ;if (co == 0) |
805 | or edi,edi ;if (co == 0) |
803 | jne .els_0 |
806 | jnz .els_0 |
804 | stdcall gl_draw_triangle, [context],ebx,ecx,edx |
807 | stdcall gl_draw_triangle, [context],ebx,ecx,edx |
805 | jmp .end_f |
808 | jmp .end_f |
806 | .els_0: |
809 | .els_0: |
807 | ;eax = cc[2] |
810 | ;eax = cc[2] |
808 | and eax,[cc] |
811 | and eax,[cc] |
Line 809... | Line 812... | ||
809 | and eax,[cc+4] ;c_and = cc[0] & cc[1] & cc[2] |
812 | and eax,[cc+4] ;c_and = cc[0] & cc[1] & cc[2] |
810 | 813 | ||
811 | ; the triangle is completely outside |
814 | ; the triangle is completely outside |
Line 812... | Line 815... | ||
812 | cmp eax,0 ;if (c_and!=0) return |
815 | or eax,eax ;if (c_and!=0) return |
813 | jne .end_f |
816 | jnz .end_f |
814 | 817 | ||
815 | ; find the next direction to clip |
818 | ; find the next direction to clip |
816 | .cycle_0: ;while (clip_bit < 6 && (co & (1 << clip_bit)) == 0) |
819 | .cycle_0: ;while (clip_bit < 6 && (co & (1 << clip_bit)) == 0) |
817 | cmp dword[clip_bit],6 |
820 | cmp dword[clip_bit],6 |
818 | jge .cycle_0_end |
821 | jge .cycle_0_end |
819 | xor eax,eax |
822 | xor eax,eax |
820 | inc eax |
823 | inc eax |
821 | mov ecx,[clip_bit] |
824 | mov ecx,[clip_bit] |
822 | shl eax,cl |
825 | shl eax,cl |
823 | and eax,[co] |
826 | and eax,[co] |
824 | cmp eax,0 |
827 | or eax,eax |
825 | jne .cycle_0_end |
828 | jnz .cycle_0_end |
Line 826... | Line 829... | ||
826 | inc dword[clip_bit] |
829 | inc dword[clip_bit] |
Line 852... | Line 855... | ||
852 | xor edi,[cc+8] |
855 | xor edi,[cc+8] |
853 | and eax,edi ;eax = co1 = (cc[0] ^ cc[1] ^ cc[2]) & clip_mask |
856 | and eax,edi ;eax = co1 = (cc[0] ^ cc[1] ^ cc[2]) & clip_mask |
Line 854... | Line 857... | ||
854 | 857 | ||
Line 855... | Line 858... | ||
855 | mov ecx,[p1] ;востанавливаем после shl ___,cl |
858 | mov ecx,[p1] ;востанавливаем после shl ___,cl |
856 | 859 | ||
857 | cmp eax,0 ;if (co1) |
860 | or eax,eax ;if (co1) |
858 | je .els_1 |
861 | jz .els_1 |
859 | ; one point outside |
862 | ; one point outside |
860 | mov eax,[cc] |
863 | mov eax,[cc] |
861 | and eax,[clip_mask] |
864 | and eax,[clip_mask] |
862 | cmp eax,0 ;if (cc[0] & clip_mask) |
865 | or eax,eax ;if (cc[0] & clip_mask) |
863 | je .els_2 |
866 | jz .els_2 |
864 | ;q[0]=p0 q[1]=p1 q[2]=p2 |
867 | ;q[0]=p0 q[1]=p1 q[2]=p2 |
865 | mov [q],ebx |
868 | mov [q],ebx |
866 | mov [q+4],ecx |
869 | mov [q+4],ecx |
867 | mov [q+8],edx |
870 | mov [q+8],edx |
868 | jmp .els_2_end |
871 | jmp .els_2_end |
869 | .els_2: |
872 | .els_2: |
870 | mov eax,[cc+4] |
873 | mov eax,[cc+4] |
871 | and eax,[clip_mask] |
874 | and eax,[clip_mask] |
872 | cmp eax,0 ;else if (cc[1] & clip_mask) |
875 | or eax,eax ;else if (cc[1] & clip_mask) |
873 | je .els_3 |
876 | jz .els_3 |
874 | ;q[0]=p1 q[1]=p2 q[2]=p0 |
877 | ;q[0]=p1 q[1]=p2 q[2]=p0 |
875 | mov [q],ecx |
878 | mov [q],ecx |
876 | mov [q+4],edx |
879 | mov [q+4],edx |
Line 915... | Line 918... | ||
915 | sub ebx,offs_vert_pc |
918 | sub ebx,offs_vert_pc |
916 | sub edx,offs_vert_pc |
919 | sub edx,offs_vert_pc |
917 | stdcall updateTmp,[context],edi,ebx,edx,eax ;updateTmp(c,&tmp2,q[0],q[2],tt) |
920 | stdcall updateTmp,[context],edi,ebx,edx,eax ;updateTmp(c,&tmp2,q[0],q[2],tt) |
Line 918... | Line 921... | ||
918 | 921 | ||
919 | mov eax,[ebx+offs_vert_edge_flag] |
922 | mov eax,[ebx+offs_vert_edge_flag] |
920 | mov [tmp1+offs_vert_edge_flag],eax ;q[0].edge_flag |
923 | mov [tmp1.edge_flag],eax ;q[0].edge_flag |
921 | mov eax,[edx+offs_vert_edge_flag] |
924 | mov eax,[edx+offs_vert_edge_flag] |
922 | mov [edge_flag_tmp],eax ;q[2].edge_flag |
925 | mov [edge_flag_tmp],eax ;q[2].edge_flag |
923 | mov dword[edx+offs_vert_edge_flag],0 ;q[2].edge_flag=0 |
926 | mov dword[edx+offs_vert_edge_flag],0 ;q[2].edge_flag=0 |
924 | mov eax,[clip_bit] |
927 | mov eax,[clip_bit] |
Line 990... | Line 993... | ||
990 | sub edi,sizeof.GLVertex-offs_vert_pc |
993 | sub edi,sizeof.GLVertex-offs_vert_pc |
991 | stdcall dword[eax],edi,ebx,edx ;clip_proc[clip_bit](&tmp2.pc,&q[0].pc,&q[2].pc) |
994 | stdcall dword[eax],edi,ebx,edx ;clip_proc[clip_bit](&tmp2.pc,&q[0].pc,&q[2].pc) |
992 | sub edi,offs_vert_pc |
995 | sub edi,offs_vert_pc |
993 | stdcall updateTmp,[context],edi,[q],[q+8],eax |
996 | stdcall updateTmp,[context],edi,[q],[q+8],eax |
Line 994... | Line -... | ||
994 | - | ||
995 | mov edx,[q+8] |
- | |
996 | 997 | ||
997 | mov dword[tmp1+offs_vert_edge_flag],1 |
998 | mov dword[tmp1.edge_flag],1 |
998 | mov eax,[edx+offs_vert_edge_flag] |
999 | mov eax,[edx+offs_vert_edge_flag-offs_vert_pc] |
999 | mov dword[tmp1+offs_vert_edge_flag],eax ;tmp2.edge_flag = q[2].edge_flag |
1000 | mov dword[tmp2.edge_flag],eax ;tmp2.edge_flag = q[2].edge_flag |
1000 | mov eax,[clip_bit] |
1001 | mov eax,[clip_bit] |
1001 | inc eax |
1002 | inc eax |
1002 | push eax |
1003 | push eax |
1003 | push edi |
1004 | push edi |