Rev 6648 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6648 | Rev 6769 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ; application : View3ds ver. 0.067 - tiny .3ds and .asc files viewer |
1 | ; application : View3ds ver. 0.068 - tiny .3ds and .asc files viewer |
2 | ; with a few graphics effects demonstration. |
2 | ; with a few graphics effects demonstration. |
3 | ; compiler : FASM |
3 | ; compiler : FASM |
4 | ; system : KolibriOS |
4 | ; system : KolibriOS |
5 | ; author : Macgub aka Maciej Guba |
5 | ; author : Macgub aka Maciej Guba |
6 | ; email : macgub3@wp.pl |
6 | ; email : macgub3@wp.pl |
7 | ; web : www.macgub.hekko.pl |
7 | ; web : www.macgub.hekko.pl |
8 | ; Fell free to use this intro in your own distribution of KolibriOS. |
8 | ; Fell free to use this intro in your own distribution of KolibriOS. |
9 | ; Special greetings to KolibriOS team . |
9 | ; Special greetings to KolibriOS team . |
10 | ; I hope because my intros Christian Belive will be near to each of You. |
10 | ; I hope because my demos Christian Belive will be near to each of You. |
Line 11... | Line 11... | ||
11 | 11 | ||
12 | 12 | ||
13 | ; Some adjustments made by Madis Kalme |
13 | ; Some adjustments made by Madis Kalme |
Line 55... | Line 55... | ||
55 | cld |
55 | cld |
56 | ; mov eax,14 ; window size according to cur res ... |
56 | ; mov eax,14 ; window size according to cur res ... |
57 | ; int 0x40 |
57 | ; int 0x40 |
58 | ; sub eax,150 shl 16 + 150 |
58 | ; sub eax,150 shl 16 + 150 |
59 | mov eax, 600 shl 16 + 600 ; ... or set manually |
59 | mov eax, 500 shl 16 + 600 ; ... or set manually |
60 | mov [size_y_var],ax |
60 | mov [size_y_var],ax |
61 | shr ax,1 |
61 | shr ax,1 |
62 | mov [vect_y],ax |
62 | mov [vect_y],ax |
63 | 63 | ||
Line 130... | Line 130... | ||
130 | mov edi,bumpmap |
130 | mov edi,bumpmap |
131 | call calc_bumpmap |
131 | call calc_bumpmap |
132 | call calc_bumpmap_coords ; bump and texture mapping |
132 | call calc_bumpmap_coords ; bump and texture mapping |
133 | call draw_window |
133 | call draw_window |
134 | mov [draw_win_at_first],0 |
134 | ; mov [draw_win_at_first],0 |
135 | 135 | ; mov eax,40 ; set events mask |
|
- | 136 | ; mov ebx,1100000000000000000000000100111b |
|
- | 137 | ; int 0x40 |
|
136 | still: |
138 | still: |
137 | 139 | cmp [edit_flag],1 |
|
- | 140 | jne @f |
|
- | 141 | mov eax,40 ; set events mask |
|
- | 142 | mov ebx,1100000000000000000000000100111b |
|
- | 143 | jmp .int |
|
- | 144 | @@: |
|
- | 145 | mov eax,40 ; set events mask |
|
- | 146 | mov ebx,111b |
|
- | 147 | .int: |
|
- | 148 | int 0x40 |
|
- | 149 | ||
Line 138... | Line 150... | ||
138 | mov eax,23 ; wait here for event with timeout |
150 | mov eax,23 |
139 | mov ebx,TIMEOUT |
151 | mov ebx,TIMEOUT |
140 | cmp [speed_flag],1 |
152 | cmp [speed_flag],0 |
141 | jne .skip |
153 | je .skip |
142 | mov eax,11 |
154 | mov eax,11 |
143 | .skip: |
155 | .skip: |
- | 156 | cmp [edit_flag],1 |
|
- | 157 | jne @f |
|
- | 158 | mov eax,10 |
|
- | 159 | ||
- | 160 | @@: |
|
144 | int 0x40 |
161 | int 0x40 |
Line 145... | Line 162... | ||
145 | 162 | ||
146 | cmp eax,1 ; redraw request ? |
163 | cmp eax,1 ; redraw request ? |
147 | je red |
164 | je red |
148 | cmp eax,2 ; key in buffer ? |
165 | cmp eax,2 ; key in buffer ? |
149 | je key |
166 | je key |
150 | cmp eax,3 ; button in buffer ? |
167 | cmp eax,3 ; button in buffer ? |
- | 168 | je button |
|
- | 169 | cmp eax,6 |
|
- | 170 | jne @f |
|
151 | je button |
171 | cmp [edit_flag],1 |
- | 172 | jne @f |
|
- | 173 | mov eax,37 |
|
- | 174 | mov ebx,3 ;read mouse state |
|
- | 175 | int 0x40 |
|
- | 176 | mov [mouse_state],eax |
|
- | 177 | call edit |
|
152 | 178 | @@: |
|
Line 153... | Line 179... | ||
153 | jmp noclose |
179 | jmp noclose |
154 | 180 | ||
155 | red: ; redraw |
181 | red: ; redraw |
Line 214... | Line 240... | ||
214 | .next_m6: |
240 | .next_m6: |
215 | ; ah = 5 -> scale- |
241 | ; ah = 5 -> scale- |
216 | cmp ah,5 |
242 | cmp ah,5 |
217 | jne @f |
243 | jne @f |
218 | mov [scale],0.7 |
244 | mov dword[scale],0.7 |
219 | fninit |
245 | fninit |
220 | fld [rsscale] |
246 | fld [rsscale] |
221 | fmul [scale] |
247 | fmul [scale] |
222 | fstp [rsscale] |
248 | fstp [rsscale] |
223 | 249 | ||
Line 224... | Line 250... | ||
224 | @@: |
250 | @@: |
225 | cmp ah,6 ; ah = 6 -> scale+ |
251 | cmp ah,6 ; ah = 6 -> scale+ |
226 | jne @f |
252 | jne @f |
227 | mov [scale],1.3 |
253 | mov dword[scale],1.3 |
228 | fninit |
254 | fninit |
229 | fld [rsscale] |
255 | fld [rsscale] |
230 | fmul [scale] |
256 | fmul [scale] |
231 | fstp [rsscale] |
257 | fstp [rsscale] |
Line 428... | Line 454... | ||
428 | 454 | ||
Line -... | Line 455... | ||
- | 455 | ||
- | 456 | noclose: |
|
429 | 457 | ||
430 | noclose: |
458 | cmp [edit_flag],1 |
431 | 459 | jz .end_rot |
|
432 | cmp [r_flag],2 |
460 | cmp [r_flag],2 |
433 | jne .no_x |
461 | jne .no_x |
Line 514... | Line 542... | ||
514 | call draw_dots |
542 | call draw_dots |
515 | jmp .blurrr |
543 | jmp .blurrr |
516 | @@: |
544 | @@: |
517 | call draw_triangles ; draw all triangles from the list |
545 | call draw_triangles ; draw all triangles from the list |
518 | .blurrr: |
546 | cmp [edit_flag],0 |
- | 547 | jz .no_edit |
|
- | 548 | call clear_vertices_index |
|
- | 549 | call draw_handlers |
|
- | 550 | ; call edit |
|
- | 551 | ||
- | 552 | ||
- | 553 | ||
- | 554 | ||
- | 555 | ||
- | 556 | ||
- | 557 | .no_edit: |
|
- | 558 | ||
- | 559 | .blurrr: |
|
519 | cmp [sinus_flag],0 |
560 | cmp [sinus_flag],0 |
520 | je @f |
561 | je @f |
521 | call do_sinus |
562 | call do_sinus |
522 | @@: |
563 | @@: |
523 | cmp [fire_flag],0 |
564 | cmp [fire_flag],0 |
Line 650... | Line 691... | ||
650 | sub ecx,16 |
691 | sub ecx,16 |
651 | jnc .oop1 |
692 | jnc .oop1 |
652 | end if |
693 | end if |
653 | .no_dec_bright: |
694 | .no_dec_bright: |
654 | ;======================================commmented==================== |
695 | |
655 | if 0 |
- | |
656 | if Ext >= SSE |
- | |
657 | cmp [max_flag],0 |
- | |
658 | je .no_max |
- | |
659 | ;movzx ebx,[max_flag] |
- | |
660 | .again_max: |
- | |
661 | ; push ecx |
- | |
662 | mov edi,screen |
- | |
663 | mov ecx,SIZE_X*3/4 |
- | |
664 | ; ; pxor mm5,mm5 |
- | |
665 | xor eax,eax |
- | |
666 | rep stosd |
- | |
667 | - | ||
Line 668... | Line -... | ||
668 | mov ecx,(SIZE_X*(SIZE_Y-3))*3/8 |
- | |
669 | .calc_max: |
- | |
670 | @@: |
- | |
671 | movq mm0,[edi+SIZE_X*3] |
- | |
672 | movq mm1,[edi-SIZE_X*3] |
- | |
673 | movq mm2,[edi-3] |
- | |
674 | movq mm3,[edi+3] |
- | |
675 | - | ||
676 | pmaxub mm0,mm1 |
- | |
677 | pmaxub mm2,mm3 |
- | |
678 | pmaxub mm0,mm2 |
- | |
679 | - | ||
680 | movq [edi],mm0 |
- | |
681 | add edi,8 |
- | |
682 | loop @b |
- | |
683 | - | ||
684 | xor eax,eax |
- | |
685 | mov ecx,SIZE_X*3/4 |
- | |
686 | rep stosd |
- | |
687 | end if |
- | |
688 | - | ||
689 | .no_max: |
- | |
690 | - | ||
691 | if Ext >= SSE |
- | |
692 | cmp [min_flag],0 |
- | |
693 | je .no_min |
- | |
694 | ; push ecx |
- | |
695 | mov edi,screen |
- | |
696 | mov ecx,SIZE_X*3/4 |
- | |
697 | ; ; pxor mm5,mm5 |
- | |
698 | xor eax,eax |
- | |
699 | rep stosd |
- | |
700 | - | ||
701 | mov ecx,(SIZE_X*(SIZE_Y-3))*3/8 |
- | |
702 | @@: |
- | |
703 | movq mm0,[edi+SIZE_X*3] |
- | |
704 | movq mm1,[edi-SIZE_X*3] |
- | |
705 | movq mm2,[edi-3] |
- | |
706 | movq mm3,[edi+3] |
- | |
707 | - | ||
708 | pminub mm0,mm1 |
- | |
709 | pminub mm2,mm3 |
- | |
710 | pminub mm0,mm2 |
- | |
711 | - | ||
712 | movq [edi],mm0 |
- | |
713 | add edi,8 |
- | |
714 | loop @b |
- | |
715 | - | ||
716 | xor eax,eax |
- | |
717 | - | ||
718 | mov ecx,SIZE_X*3/4 |
- | |
719 | rep stosd |
- | |
720 | end if |
- | |
721 | .no_min: |
- | |
722 | end if |
- | |
Line 723... | Line 696... | ||
723 | 696 | ||
724 | RDTSC |
697 | RDTSC |
725 | sub eax,[esp] |
698 | sub eax,[esp] |
726 | sub eax,41 |
699 | sub eax,41 |
Line 739... | Line 712... | ||
739 | mov eax,7 ; put image |
712 | mov eax,7 ; put image |
740 | mov ebx,[screen_ptr] |
713 | mov ebx,[screen_ptr] |
741 | mov ecx,[size_y_var] |
714 | mov ecx,[size_y_var] |
742 | ; mov ecx,SIZE_X shl 16 + SIZE_Y |
715 | ; mov ecx,SIZE_X shl 16 + SIZE_Y |
743 | mov edx,5 shl 16 + 25 |
716 | mov edx,[offset_y] ;5 shl 16 + 25 |
744 | int 0x40 |
717 | int 0x40 |
Line 745... | Line 718... | ||
745 | 718 | ||
746 | mov eax,13 |
719 | mov eax,13 |
747 | mov bx,[size_x_var] |
720 | mov bx,[size_x_var] |
Line 790... | Line 763... | ||
790 | include "BUMP_TEX.INC" |
763 | include "BUMP_TEX.INC" |
791 | include "GRD_TEX.INC" |
764 | include "GRD_TEX.INC" |
792 | include "TWO_TEX.INC" |
765 | include "TWO_TEX.INC" |
793 | include "ASC.INC" |
766 | include "ASC.INC" |
794 | 767 | clear_vertices_index: |
|
- | 768 | mov edi,[vertices_index_ptr] |
|
- | 769 | movzx eax,word[size_x_var] |
|
- | 770 | movzx ecx,word[size_y_var] |
|
- | 771 | imul ecx,eax |
|
- | 772 | xor eax,eax |
|
- | 773 | shr ecx,1 |
|
- | 774 | rep stosd |
|
- | 775 | ret |
|
- | 776 | edit: ; mmx required, edit mesh by vertex |
|
- | 777 | push ebp |
|
- | 778 | mov ebp,esp |
|
- | 779 | sub esp,128 |
|
- | 780 | ||
- | 781 | .y_coord equ ebp-2 |
|
- | 782 | .x_coord equ ebp-4 |
|
- | 783 | .points_translated equ ebp-10 |
|
- | 784 | .points equ ebp-22 |
|
- | 785 | .points_rotated equ ebp-34 |
|
- | 786 | .mx equ ebp-70 |
|
- | 787 | ||
- | 788 | macro check_bar |
|
- | 789 | { |
|
- | 790 | movzx ebx,word[.x_coord] |
|
- | 791 | movzx ecx,word[.y_coord] |
|
- | 792 | movzx edx,word[size_x_var] |
|
- | 793 | imul edx,ecx |
|
- | 794 | add ebx,edx |
|
- | 795 | ||
- | 796 | lea ecx,[ebx*2] |
|
- | 797 | lea ebx,[ebx*3] |
|
- | 798 | add ebx,[screen_ptr] |
|
- | 799 | mov ebx,[ebx] |
|
- | 800 | and ebx,0x00ffffff |
|
- | 801 | cmp ebx,0x00ff0000 ; is handle bar ? |
|
- | 802 | } |
|
- | 803 | ||
- | 804 | emms |
|
- | 805 | mov eax,37 ; get mouse state |
|
- | 806 | mov ebx,1 ; x = 5, y = 25 - offsets |
|
- | 807 | int 0x40 |
|
- | 808 | ||
- | 809 | mov ebx,[offset_y] ;5 shl 16 + 25 |
|
- | 810 | movd mm0,ebx |
|
- | 811 | movd mm1,eax |
|
- | 812 | movd mm3,[size_y_var] |
|
- | 813 | pcmpgtw mm0,mm1 |
|
- | 814 | pcmpgtw mm3,mm1 |
|
- | 815 | pxor mm3,mm0 |
|
- | 816 | movd eax,mm3 |
|
- | 817 | mov cx,ax |
|
- | 818 | shr eax,16 |
|
- | 819 | and ax,cx |
|
- | 820 | or ax,ax |
|
- | 821 | jz .no_edit |
|
- | 822 | ||
- | 823 | ||
- | 824 | movd mm0,ebx |
|
- | 825 | psubw mm1,mm0 |
|
- | 826 | movd eax,mm1 |
|
- | 827 | ||
- | 828 | ; store both x and y coordinates |
|
- | 829 | ror eax,16 |
|
- | 830 | ; push eax |
|
- | 831 | ; sub esp,256 |
|
- | 832 | mov [.x_coord],eax |
|
- | 833 | test word[mouse_state],100000000b |
|
- | 834 | jz .not_press ; check if left mouse button press |
|
- | 835 | ||
- | 836 | ; left button pressed |
|
- | 837 | ||
- | 838 | ; macro check_bar |
|
- | 839 | ; { |
|
- | 840 | ; movzx ebx,word[.x_coord] |
|
- | 841 | ; movzx ecx,word[.y_coord] |
|
- | 842 | ; imul ebx,ecx |
|
- | 843 | ; lea ecx,[ebx*2] |
|
- | 844 | ; lea ebx,[ebx*3] |
|
- | 845 | ; add ebx,[screen_ptr] |
|
- | 846 | ; mov ebx,[ebx] |
|
- | 847 | ; and ebx,0x00ffffff |
|
- | 848 | ; cmp ebx,0x00ff0000 ; is handle bar ? |
|
- | 849 | ; } |
|
- | 850 | ||
- | 851 | check_bar |
|
- | 852 | jne .no_edit |
|
- | 853 | add ecx,[vertices_index_ptr] |
|
- | 854 | mov cx,word[ecx] |
|
- | 855 | inc cx |
|
- | 856 | ||
- | 857 | ||
- | 858 | mov [vertex_edit_no],cx ;if vert_edit_no = 0, no vertex selected |
|
- | 859 | ||
- | 860 | mov eax,dword[.x_coord] |
|
- | 861 | mov dword[edit_end_x],eax |
|
- | 862 | mov dword[edit_start_x],eax |
|
- | 863 | jmp .end |
|
- | 864 | .not_press: |
|
- | 865 | test byte[mouse_state],1b ; check if left button is held |
|
- | 866 | jz .not_held |
|
- | 867 | ; check_bar |
|
- | 868 | ; jne .no_edit |
|
- | 869 | ; add ecx,[vertices_index_ptr] |
|
- | 870 | ; mov cx,[ecx] |
|
- | 871 | ; inc cx |
|
- | 872 | cmp [vertex_edit_no],0 ; cx ; vertex number |
|
- | 873 | je .end |
|
- | 874 | push dword[.x_coord] |
|
- | 875 | pop dword[edit_end_x] |
|
- | 876 | jmp .end |
|
- | 877 | .not_held: |
|
- | 878 | shr [mouse_state],16 |
|
- | 879 | test byte[mouse_state],1b ; test if left button released |
|
- | 880 | jz .end |
|
- | 881 | check_bar |
|
- | 882 | jne .end |
|
- | 883 | ||
- | 884 | movzx esi,[vertex_edit_no] |
|
- | 885 | dec esi |
|
- | 886 | lea esi,[esi*3] |
|
- | 887 | add esi,esi |
|
- | 888 | add esi,[points_translated_ptr] |
|
- | 889 | emms |
|
- | 890 | ||
- | 891 | movd mm1,dword[esi] |
|
- | 892 | paddw mm1,mm0 |
|
- | 893 | psubw mm1,qword[vect_x] |
|
- | 894 | movd dword[esi],mm1 |
|
- | 895 | ||
- | 896 | lea edi,[.points] |
|
- | 897 | ; detranslate |
|
- | 898 | fninit |
|
- | 899 | fild word[esi+4] |
|
- | 900 | fstp dword[edi+8] |
|
- | 901 | fild word[esi+2] |
|
- | 902 | fisub word[offset_x] |
|
- | 903 | fstp dword[edi+4] |
|
- | 904 | fild word[esi] |
|
- | 905 | fisub word[offset_y] ; proteza |
|
- | 906 | fstp dword[edi] |
|
- | 907 | ||
- | 908 | mov esi,matrix |
|
- | 909 | lea edi,[.mx] |
|
- | 910 | call reverse_mx_3x3 |
|
- | 911 | ||
Line -... | Line 912... | ||
- | 912 | lea esi,[.points] |
|
- | 913 | lea edi,[.points_rotated] |
|
- | 914 | lea ebx,[.mx] |
|
- | 915 | mov ecx,1 |
|
- | 916 | call rotary |
|
- | 917 | ||
- | 918 | ; inject into vertex list |
|
- | 919 | movzx edi,[vertex_edit_no] |
|
- | 920 | dec edi |
|
- | 921 | lea edi,[edi*3] |
|
- | 922 | shl edi,2 |
|
- | 923 | add edi,[points_ptr] |
|
- | 924 | lea esi,[.points_rotated] |
|
- | 925 | mov ecx,3 |
|
- | 926 | cld |
|
- | 927 | rep movsd |
|
Line -... | Line 928... | ||
- | 928 | ||
- | 929 | ||
- | 930 | mov dword[edit_end_x],0 |
|
- | 931 | mov [vertex_edit_no],0 |
|
- | 932 | ||
- | 933 | .no_edit: |
|
- | 934 | .end: |
|
- | 935 | mov esp,ebp |
|
- | 936 | pop ebp |
|
795 | 937 | ret |
|
- | 938 | ||
- | 939 | alloc_buffer_mem: |
|
- | 940 | push ebp |
|
- | 941 | mov ebp,esp |
|
- | 942 | .temp equ ebp-4 |
|
796 | 943 | push dword 0 |
|
797 | alloc_buffer_mem: |
944 | |
798 | mov eax, 68 |
945 | mov eax, 68 |
Line 799... | Line 946... | ||
799 | mov ebx, 11 |
946 | mov ebx, 11 |
800 | int 0x40 ; -> create heap, to be sure |
947 | int 0x40 ; -> create heap, to be sure |
801 | 948 | ||
- | 949 | ||
802 | 950 | movzx ecx,word[size_x_var] |
|
803 | movzx ecx,word[size_x_var] |
- | |
804 | movzx eax,word[size_y_var] |
951 | movzx eax,word[size_y_var] |
- | 952 | mul ecx |
|
805 | mul ecx |
953 | |
806 | ; add eax,100 |
954 | mov [.temp],eax |
807 | push eax |
955 | lea ecx,[eax*3] |
808 | lea ecx,[eax*3] |
- | |
809 | mov eax,68 |
- | |
810 | mov ebx,20 |
- | |
811 | mov edx,[screen_ptr] |
- | |
812 | cmp [draw_win_at_first],1 |
956 | add ecx,256 |
- | 957 | mov eax,68 |
|
813 | jne @f |
958 | mov ebx,20 |
Line 814... | Line 959... | ||
814 | xor edx,edx |
959 | mov edx,[screen_ptr] |
815 | @@: |
960 | int 0x40 |
- | 961 | ; and eax,0xfffffff0 |
|
816 | int 0x40 |
962 | mov [screen_ptr],eax |
817 | mov [screen_ptr],eax |
963 | |
818 | 964 | mov ecx,[.temp] |
|
819 | pop ecx |
- | |
820 | shl ecx,2 |
- | |
821 | mov eax,68 |
- | |
822 | mov ebx,20 |
- | |
823 | mov edx,[Zbuffer_ptr] |
965 | shl ecx,2 |
- | 966 | add ecx,256 |
|
824 | cmp [draw_win_at_first],1 |
967 | mov eax,68 |
Line -... | Line 968... | ||
- | 968 | mov ebx,20 |
|
- | 969 | mov edx,[Zbuffer_ptr] |
|
- | 970 | int 0x40 |
|
- | 971 | ; and eax,0xfffffff0 |
|
- | 972 | mov [Zbuffer_ptr],eax |
|
- | 973 | ||
- | 974 | ||
- | 975 | mov ecx,[.temp] |
|
- | 976 | add ecx,ecx |
|
- | 977 | add ecx,256 |
|
- | 978 | mov eax,68 |
|
- | 979 | mov ebx,20 |
|
- | 980 | mov edx,[vertices_index_ptr] |
|
- | 981 | int 0x40 |
|
- | 982 | ; and eax,0xfffffff0 |
|
- | 983 | mov [vertices_index_ptr],eax |
|
825 | jne @f |
984 | |
826 | xor edx,edx |
985 | mov esp,ebp |
827 | @@: |
986 | pop ebp |
828 | int 0x40 |
987 | |
829 | mov [Zbuffer_ptr],eax |
988 | |
Line 1755... | Line 1914... | ||
1755 | ret |
1914 | ret |
Line 1756... | Line 1915... | ||
1756 | 1915 | ||
- | 1916 | ||
- | 1917 | draw_triangles: |
|
- | 1918 | ||
- | 1919 | emms |
|
- | 1920 | ; update translated list MMX required |
|
- | 1921 | cmp [vertex_edit_no],0 |
|
- | 1922 | je @f |
|
- | 1923 | movzx eax,[vertex_edit_no] |
|
- | 1924 | dec eax |
|
- | 1925 | movd mm0,[edit_end_x] |
|
- | 1926 | psubw mm0,[edit_start_x] |
|
- | 1927 | lea eax,[eax*3] |
|
- | 1928 | add eax,eax |
|
- | 1929 | add eax,[points_translated_ptr] |
|
- | 1930 | movd mm1,dword[eax] |
|
- | 1931 | paddw mm1,mm0 |
|
- | 1932 | movd dword[eax],mm1 |
|
- | 1933 | @@: |
|
- | 1934 | ||
1757 | 1935 | ||
1758 | draw_triangles: |
1936 | |
1759 | mov esi,[triangles_ptr] |
1937 | mov esi,[triangles_ptr] |
1760 | mov [edges_counter],0 |
1938 | mov [edges_counter],0 |
1761 | .again_dts: |
1939 | .again_dts: |
Line 1767... | Line 1945... | ||
1767 | add eax,eax |
1945 | add eax,eax |
1768 | push ebp |
1946 | push ebp |
1769 | add ebp,eax |
1947 | add ebp,eax |
1770 | mov eax,[ebp] |
1948 | mov eax,[ebp] |
1771 | mov dword[xx1],eax |
1949 | cmp [vertex_edit_no],0 |
- | 1950 | jne @f |
|
- | 1951 | ||
- | 1952 | @@: |
|
- | 1953 | mov dword[xx1],eax |
|
1772 | mov eax,[ebp+4] |
1954 | mov eax,[ebp+4] |
1773 | mov [zz1],ax |
1955 | mov [zz1],ax |
1774 | pop ebp |
1956 | pop ebp |
1775 | 1957 | ||
Line 1821... | Line 2003... | ||
1821 | movq qword[xx2],mm1 |
2003 | movq qword[xx2],mm1 |
1822 | movq qword[xx3],mm2 |
2004 | movq qword[xx3],mm2 |
1823 | ; emms |
2005 | ; emms |
1824 | end if ; ********************************* |
2006 | end if ; ********************************* |
1825 | push esi ; |
2007 | if 0 |
- | 2008 | cmp [vertex_edit_no],0 |
|
- | 2009 | jne .no_edit |
|
- | 2010 | mov ax,[vertex_edit_no] |
|
- | 2011 | dec ax |
|
- | 2012 | cmp ax,[point_index1] |
|
- | 2013 | jne @f |
|
- | 2014 | movd mm0,[edit_start_x] |
|
- | 2015 | psubw mm0,[edit_end_x] |
|
- | 2016 | movd mm1,dword[xx1] |
|
- | 2017 | paddw mm1,mm0 |
|
- | 2018 | movd dword[xx1],mm1 |
|
- | 2019 | jmp .no_edit |
|
- | 2020 | @@: |
|
- | 2021 | ||
- | 2022 | cmp ax,[point_index2] |
|
- | 2023 | jne @f |
|
- | 2024 | movd mm0,[edit_start_x] |
|
- | 2025 | psubw mm0,[edit_end_x] |
|
- | 2026 | movd mm1,dword[xx2] |
|
- | 2027 | paddw mm1,mm0 |
|
- | 2028 | movd dword[xx2],mm1 |
|
- | 2029 | jmp .no_edit |
|
- | 2030 | @@: |
|
- | 2031 | ||
- | 2032 | cmp ax,[point_index3] |
|
- | 2033 | jne @f |
|
- | 2034 | movd mm0,[edit_start_x] |
|
- | 2035 | psubw mm0,[edit_end_x] |
|
- | 2036 | movd mm1,dword[xx3] |
|
- | 2037 | paddw mm1,mm0 |
|
- | 2038 | movd dword[xx3],mm1 |
|
- | 2039 | jmp .no_edit |
|
- | 2040 | @@: |
|
- | 2041 | ||
- | 2042 | ||
- | 2043 | .no_edit: |
|
- | 2044 | end if |
|
- | 2045 | push esi ; |
|
1826 | fninit ; DO culling AT FIRST |
2046 | fninit ; DO culling AT FIRST |
1827 | cmp [culling_flag],1 ; (if culling_flag = 1) |
2047 | cmp [culling_flag],1 ; (if culling_flag = 1) |
1828 | jne .no_culling |
2048 | jne .no_culling |
1829 | mov esi,point_index1 ; ********************************* |
2049 | mov esi,point_index1 ; ********************************* |
1830 | mov ecx,3 ; |
2050 | mov ecx,3 ; |
Line 2703... | Line 2923... | ||
2703 | jne .again_dts |
2923 | jne .again_dts |
2704 | ret |
2924 | ret |
2705 | 2925 | ||
Line -... | Line 2926... | ||
- | 2926 | ||
- | 2927 | ||
- | 2928 | ||
- | 2929 | ||
- | 2930 | ||
- | 2931 | ||
- | 2932 | draw_handlers: |
|
- | 2933 | ||
- | 2934 | push ebp |
|
- | 2935 | mov ebp,esp |
|
- | 2936 | ||
- | 2937 | .counter equ ebp-16 |
|
- | 2938 | .xres3m18 equ ebp-8 |
|
- | 2939 | .xres2m12 equ ebp-12 |
|
- | 2940 | ||
- | 2941 | ||
- | 2942 | ; init counter |
|
- | 2943 | sub esp,12 |
|
- | 2944 | push dword 0 |
|
- | 2945 | ||
- | 2946 | movzx eax,word[size_x_var] |
|
- | 2947 | lea ebx,[eax*3] |
|
- | 2948 | sub ebx,18 |
|
- | 2949 | add eax,eax |
|
- | 2950 | sub eax,12 |
|
- | 2951 | mov [.xres3m18],ebx |
|
- | 2952 | mov [.xres2m12],eax |
|
- | 2953 | ||
- | 2954 | mov esi,[points_translated_ptr] |
|
- | 2955 | .loop: |
|
- | 2956 | push esi |
|
- | 2957 | ; DO culling AT FIRST |
|
- | 2958 | cmp [culling_flag],1 ; (if culling_flag = 1) |
|
- | 2959 | jne .no_culling |
|
- | 2960 | mov edi,[.counter] ; ********************************* |
|
- | 2961 | lea edi,[edi*3] |
|
- | 2962 | shl edi,2 |
|
- | 2963 | add edi,[points_normals_rot_ptr] |
|
- | 2964 | mov eax,[edi+8] ; check sign of z coof |
|
- | 2965 | shr eax,31 |
|
- | 2966 | cmp eax,1 |
|
- | 2967 | jnz .skip |
|
- | 2968 | .no_culling: |
|
- | 2969 | mov eax,[esi] |
|
- | 2970 | movzx ebx,ax ; ebx - x |
|
- | 2971 | shr eax,16 ; eax - y |
|
- | 2972 | cmp eax,4 ; check if markers not exceedes screen |
|
- | 2973 | jle .skip |
|
- | 2974 | cmp ebx,4 |
|
- | 2975 | jle .skip |
|
- | 2976 | movzx edx,word[size_x_var] |
|
- | 2977 | sub edx,4 |
|
- | 2978 | movzx ecx,word[size_y_var] |
|
- | 2979 | sub ecx,4 |
|
- | 2980 | cmp ebx,edx |
|
- | 2981 | jge .skip |
|
- | 2982 | cmp eax,ecx |
|
- | 2983 | jge .skip |
|
- | 2984 | ||
- | 2985 | movzx edx,word[size_x_var] |
|
- | 2986 | ; sub ebx,3 |
|
- | 2987 | ; sub eax,3 |
|
- | 2988 | imul eax,edx |
|
- | 2989 | add eax,ebx |
|
- | 2990 | lea edi,[eax*3] |
|
- | 2991 | lea eax,[eax*2] |
|
- | 2992 | ; draw bar 6x6 |
|
- | 2993 | add edi,[screen_ptr] |
|
- | 2994 | add eax,dword[vertices_index_ptr] |
|
- | 2995 | ||
- | 2996 | ||
- | 2997 | ||
- | 2998 | ||
- | 2999 | mov edx,[.counter] |
|
- | 3000 | mov ecx,6 |
|
- | 3001 | ||
- | 3002 | .oop: |
|
- | 3003 | push ecx |
|
- | 3004 | mov ecx,6 |
|
- | 3005 | ||
- | 3006 | @@: |
|
- | 3007 | mov word[edi],0x0000 ;ax |
|
- | 3008 | mov byte[edi+2],0xff ;al |
|
- | 3009 | mov word[eax],dx |
|
- | 3010 | add eax,2 |
|
- | 3011 | add edi,3 |
|
- | 3012 | loop @b |
|
- | 3013 | add edi,[.xres3m18] |
|
- | 3014 | add eax,[.xres2m12] |
|
- | 3015 | pop ecx |
|
- | 3016 | loop .oop |
|
- | 3017 | ||
- | 3018 | .skip: |
|
- | 3019 | pop esi |
|
- | 3020 | add esi,6 |
|
- | 3021 | inc dword[.counter] |
|
- | 3022 | mov ecx,[.counter] |
|
- | 3023 | cmp cx,[points_count_var] |
|
- | 3024 | jng .loop |
|
- | 3025 | ||
- | 3026 | mov esp,ebp |
|
- | 3027 | pop ebp |
|
- | 3028 | ||
- | 3029 | ret |
|
- | 3030 | ||
2706 | 3031 | ||
2707 | fill_Z_buffer: |
3032 | fill_Z_buffer: |
2708 | mov eax,0x70000000 |
3033 | mov eax,0x70000000 |
2709 | mov edi,[Zbuffer_ptr] |
3034 | mov edi,[Zbuffer_ptr] |
2710 | movzx ecx,word[size_x_var] |
3035 | movzx ecx,word[size_x_var] |
Line 2898... | Line 3223... | ||
2898 | add esi,8 |
3223 | add esi,8 |
2899 | @@: |
3224 | @@: |
2900 | push edi |
3225 | push edi |
2901 | mov edi,[points_ptr] |
3226 | mov edi,[points_ptr] |
2902 | push dword[esi+4] |
3227 | push dword[esi+0] |
2903 | pop dword[edi+ebx*2+0] |
3228 | pop dword[edi+ebx*2+0] |
2904 | push dword[esi+8] |
3229 | push dword[esi+4] |
2905 | pop dword[edi+ebx*2+4] |
3230 | pop dword[edi+ebx*2+4] |
2906 | push dword[esi+0] |
3231 | push dword[esi+8] |
2907 | pop dword[edi+ebx*2+8] |
3232 | pop dword[edi+ebx*2+8] |
2908 | pop edi |
3233 | pop edi |
2909 | ; fld dword[esi+4] |
3234 | ; fld dword[esi+4] |
2910 | ; fstp dword[real_points+ebx*2+0] ; x |
3235 | ; fstp dword[real_points+ebx*2+0] ; x |
2911 | ; fld dword[esi+8] |
3236 | ; fld dword[esi+8] |
2912 | ; fstp dword[real_points+ebx*2+4] ; y |
3237 | ; fstp dword[real_points+ebx*2+4] ; y |
Line 2999... | Line 3324... | ||
2999 | mov edx,[triangles_normals_ptr] |
3324 | mov edx,[triangles_normals_ptr] |
3000 | int 0x40 ; -> allocate memory for triangles normals |
3325 | int 0x40 ; -> allocate memory for triangles normals |
3001 | mov [triangles_normals_ptr], eax ; -> eax = pointer to allocated mem |
3326 | mov [triangles_normals_ptr], eax ; -> eax = pointer to allocated mem |
3002 | 3327 | ||
Line -... | Line 3328... | ||
- | 3328 | ; mov eax, 68 |
|
- | 3329 | ; movzx ecx,[points_count_var] |
|
- | 3330 | ; lea ecx,[2+ecx*2] |
|
- | 3331 | ; mov edx,dword [vertices_index_ptr] |
|
- | 3332 | ; int 0x40 |
|
- | 3333 | ; mov dword[vertices_index_ptr], eax |
|
- | 3334 | ||
3003 | mov eax, 68 |
3335 | mov eax, 68 |
3004 | movzx ecx, [points_count_var] |
3336 | movzx ecx, [points_count_var] |
3005 | lea ecx,[3+ecx*3] |
3337 | lea ecx,[3+ecx*3] |
3006 | shl ecx, 2 |
3338 | shl ecx, 2 |
3007 | mov edx,[points_normals_ptr] |
3339 | mov edx,[points_normals_ptr] |
3008 | int 0x40 |
3340 | int 0x40 |
3009 | mov [points_normals_ptr], eax |
3341 | mov [points_normals_ptr], eax |
- | 3342 | ; int3 |
|
- | 3343 | ||
- | 3344 | ||
- | 3345 | ; int3 |
|
- | 3346 | ||
Line 3010... | Line 3347... | ||
3010 | 3347 | ||
3011 | mov eax, 68 |
3348 | mov eax, 68 |
3012 | ; mov ebx, 12 |
3349 | ; mov ebx, 12 |
3013 | movzx ecx, [points_count_var] |
3350 | movzx ecx, [points_count_var] |
Line 3065... | Line 3402... | ||
3065 | mov dword[ebx],0 |
3402 | mov dword[ebx],0 |
3066 | int 0x40 ; -> read file |
3403 | int 0x40 ; -> read file |
3067 | 3404 | ||
Line 3068... | Line 3405... | ||
3068 | mov [fsize],ebx |
3405 | mov [fsize],ebx |
3069 | - | ||
3070 | cmp eax,6 |
3406 | cmp eax,6 |
3071 | jnz @f |
3407 | jnz @f |
3072 | xor eax,eax ;;;;--- |
3408 | xor eax,eax ;;;;--- |
3073 | @@: |
3409 | @@: |
3074 | else |
3410 | else |
Line 3079... | Line 3415... | ||
3079 | mov eax,ebx |
3415 | mov eax,ebx |
3080 | shr eax,9 |
3416 | shr eax,9 |
3081 | inc eax |
3417 | inc eax |
3082 | mov [fsize],eax |
3418 | mov [fsize],eax |
- | 3419 | ||
- | 3420 | ||
- | 3421 | ||
3083 | ; mov ecx,ebx |
3422 | ; mov ecx,ebx |
3084 | ; add ecx,MEM_END |
3423 | ; add ecx,MEM_END |
3085 | ; mov ebx,1 |
3424 | ; mov ebx,1 |
3086 | ; mov eax,64 ; allocate mem - resize app mem |
3425 | ; mov eax,64 ; allocate mem - resize app mem |
3087 | ; for points and triangles |
3426 | ; for points and triangles |
Line 3190... | Line 3529... | ||
3190 | int 0x40 |
3529 | int 0x40 |
3191 | 3530 | ||
Line 3192... | Line 3531... | ||
3192 | call buttons ; more buttons |
3531 | call buttons ; more buttons |
Line 3193... | Line 3532... | ||
3193 | 3532 | ||
Line 3194... | Line 3533... | ||
3194 | .Y_ADD equ 1 ;-> offset of 'add vector' buttons |
3533 | .Y_ADD equ 2 ;-> offset of 'add vector' buttons |
3195 | 3534 | ||
3196 | ; ADD VECTOR LABEL ; add vector buttons - 30 ++ |
3535 | ; ADD VECTOR LABEL ; add vector buttons - 30 ++ |
3197 | mov eax,4 ; function 4 : write text to window |
3536 | mov eax,4 ; function 4 : write text to window |