Rev 8025 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8025 | Rev 8047 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ; application : View3ds ver. 0.069 - tiny .3ds and .asc files viewer |
1 | ; application : View3ds ver. 0.070 - 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 : http://macgub.vxm.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 demos 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 34... | Line 34... | ||
34 | NON = 0 ; -/ \- |
34 | NON = 0 ; -/ \- |
35 | MMX = 1 |
35 | MMX = 1 |
36 | SSE = 2 |
36 | SSE = 2 |
37 | SSE2 = 3 |
37 | SSE2 = 3 |
38 | Ext = SSE2 ;Ext={ NON | MMX | SSE | SSE2 } |
38 | SSE3 = 4 |
- | 39 | Ext = SSE2 ;Ext={ NON | MMX | SSE | SSE2 } |
|
39 | 40 | ||
Line 40... | Line 41... | ||
40 | ; 0 for short names (Menuet-compatible), 1 for long names (Kolibri features) |
41 | ; 0 for short names (Menuet-compatible), 1 for long names (Kolibri features) |
41 | USE_LFN = 1 |
42 | USE_LFN = 1 |
Line 52... | Line 53... | ||
52 | dd 0x0 ; I_Icon |
53 | dd 0x0 ; I_Icon |
53 | 54 | ||
Line 54... | Line 55... | ||
54 | START: ; start of execution |
55 | START: ; start of execution |
55 | cld |
56 | cld |
56 | ; mov eax,14 ; window size according to cur res ... |
- | |
57 | ; int 0x40 |
- | |
58 | ; sub eax,150 shl 16 + 150 |
- | |
59 | mov eax, 500 shl 16 + 600 ; ... or set manually |
57 | mov eax, 500 shl 16 + 600 ; ... or set manually |
60 | mov [size_y_var],ax |
58 | mov [size_y_var],ax |
61 | shr ax,1 |
59 | shr ax,1 |
62 | mov [vect_y],ax |
60 | mov [vect_y],ax |
Line 92... | Line 90... | ||
92 | cmp eax,0 |
90 | cmp eax,0 |
93 | je .gen |
91 | je .gen |
94 | jmp .malloc |
92 | jmp .malloc |
95 | .gen: |
93 | .gen: |
96 | if USE_LFN |
94 | call generate_object |
97 | mov [triangles_count_var],1000 |
- | |
98 | mov [points_count_var],1000 |
- | |
99 | call alloc_mem_for_tp |
- | |
100 | end if |
- | |
101 | call generate_object |
- | |
102 | jmp .opt |
95 | jmp .opt |
103 | .asc: |
96 | .asc: |
104 | mov [triangles_count_var],10000 |
97 | mov [triangles_count_var],10000 ; to do: read asc header |
105 | mov [points_count_var],10000 |
98 | mov [points_count_var],10000 |
106 | call alloc_mem_for_tp |
99 | call alloc_mem_for_tp |
107 | call read_asc |
100 | call read_asc |
108 | jmp .opt |
101 | jmp .opt |
109 | .malloc: |
102 | .malloc: |
110 | if USE_LFN |
103 | if USE_LFN |
Line 113... | Line 106... | ||
113 | call read_from_file |
106 | call read_from_file |
114 | .opt: |
107 | .opt: |
115 | 108 | ||
Line 116... | Line -... | ||
116 | - | ||
Line 117... | Line 109... | ||
117 | ; call alloc_buffer_mem ; alloc memfor screnn and z buffer |
109 | |
118 | 110 | ||
119 | call optimize_object1 ; proc in file b_procs.asm |
111 | call optimize_object1 ; proc in file b_procs.asm |
120 | ; set point(0,0,0) in center and calc all coords |
112 | ; set point(0,0,0) in center and calc all coords |
- | 113 | ; to be in <-1.0,1.0> |
|
- | 114 | call normalize_all_light_vectors |
|
- | 115 | if Ext >= SSE3 |
|
121 | ; to be in <-1.0,1.0> |
116 | call copy_lights ; to aligned float |
122 | call normalize_all_light_vectors |
117 | end if |
123 | call init_triangles_normals2 |
118 | call init_triangles_normals2 |
124 | call init_point_normals |
119 | call init_point_normals |
125 | call init_envmap2 |
120 | call init_envmap2 |
Line 288... | Line 283... | ||
288 | cmp ah,9 ; lights random ; 'flat' 0 |
283 | cmp ah,9 ; lights random ; 'flat' 0 |
289 | jne .next_m5 ; 'grd ' 1 |
284 | jne .next_m5 ; 'grd ' 1 |
290 | call make_random_lights ; 'env ' 2 |
285 | call make_random_lights ; 'env ' 2 |
291 | call normalize_all_light_vectors ; 'bump' 3 |
286 | call normalize_all_light_vectors ; 'bump' 3 |
292 | call do_color_buffer ; intit color_map ; 'tex ' 4 |
287 | if Ext >= SSE3 |
- | 288 | call copy_lights |
|
- | 289 | end if |
|
- | 290 | call do_color_buffer ; intit color_map ; 'tex ' 4 |
|
293 | ; cmp [emboss_flag],1 ; 'pos ' 5 |
291 | ; cmp [emboss_flag],1 ; 'pos ' 5 |
294 | ; je @f ; 'dots' 6 |
292 | ; je @f ; 'dots' 6 |
295 | ; cmp [dr_flag],8 |
293 | ; cmp [dr_flag],8 |
296 | ; jge @f |
294 | ; jge @f |
297 | ; cmp [dr_flag],2 ; 'txgr' 7 |
295 | ; cmp [dr_flag],2 ; 'txgr' 7 |
Line 330... | Line 328... | ||
330 | ; call draw_window ; redraw other labels to navigation buttons |
328 | ; call draw_window ; redraw other labels to navigation buttons |
331 | .next_m: |
329 | .next_m: |
332 | cmp ah,18 |
330 | cmp ah,18 |
333 | jne .next_m2 |
331 | jne .next_m2 |
334 | if USE_LFN |
332 | |
335 | mov [re_alloc_flag],1 ; reallocate memory |
333 | mov [re_alloc_flag],1 ; reallocate memory |
336 | mov [triangles_count_var],1000 |
334 | mov [triangles_count_var],1000 |
337 | mov [points_count_var],1000 |
335 | mov [points_count_var],1000 |
338 | call alloc_mem_for_tp |
336 | call alloc_mem_for_tp |
339 | mov [re_alloc_flag],0 |
337 | mov [re_alloc_flag],0 |
340 | end if |
338 | |
341 | mov bl,[generator_flag] |
339 | mov bl,[generator_flag] |
342 | ; or bl,bl |
340 | ; or bl,bl |
343 | ; jz .next_m2 |
341 | ; jz .next_m2 |
344 | cmp bl,1 |
342 | cmp bl,1 |
345 | jne @f |
343 | jne @f |
346 | call generate_object |
344 | call generate_object |
Line 534... | Line 532... | ||
534 | mov ebx,matrix |
532 | mov ebx,matrix |
535 | mov ecx,[points_count_var] |
533 | mov ecx,[points_count_var] |
536 | call rotary |
534 | call rotary |
537 | 535 | ||
Line 538... | Line -... | ||
538 | ; RDTSC |
- | |
539 | ; pop ebx |
- | |
540 | ; sub eax,ebx |
- | |
541 | ; sub eax,41 |
- | |
542 | ; push eax |
- | |
Line 543... | Line 536... | ||
543 | 536 | ||
544 | mov esi,[points_rotated_ptr] |
537 | mov esi,[points_rotated_ptr] |
545 | mov edi,[points_translated_ptr] |
538 | mov edi,[points_translated_ptr] |
546 | mov ecx,[points_count_var] |
539 | mov ecx,[points_count_var] |
Line 547... | Line -... | ||
547 | call translate_points |
- | |
548 | - | ||
549 | ; cmp [dr_flag],5 |
- | |
550 | ; jne @f |
- | |
551 | ; call calc_attenuation_light |
540 | call translate_points |
552 | ; @@: |
541 | |
553 | cmp [fire_flag],0 |
542 | cmp [fire_flag],0 |
554 | jne @f |
543 | jne @f |
555 | call clrscr ; clear the screen |
544 | call clrscr ; clear the screen |
Line 566... | Line 555... | ||
566 | je .non_f |
555 | je .non_f |
567 | @@: |
556 | @@: |
568 | call fill_Z_buffer ; make background |
557 | call fill_Z_buffer ; make background |
569 | .non_f: |
558 | .non_f: |
570 | ; RDTSC |
559 | cmp [dr_flag],6 |
571 | ; push eax |
- | |
572 | cmp [dr_flag],6 |
- | |
573 | jne @f |
560 | jne @f |
574 | call draw_dots |
561 | call draw_dots |
575 | jmp .blurrr |
562 | jmp .blurrr |
576 | @@: |
563 | @@: |
577 | call draw_triangles ; draw all triangles from the list |
564 | call draw_triangles ; draw all triangles from the list |
Line 740... | Line 727... | ||
740 | mov [STRdata+ecx-1],dl |
727 | mov [STRdata+ecx-1],dl |
741 | loop .dc |
728 | loop .dc |
742 | pop eax |
729 | pop eax |
743 | 730 | ||
Line -... | Line 731... | ||
- | 731 | ||
744 | mov eax,7 ; put image |
732 | mov eax,7 ; put image |
745 | mov ebx,[screen_ptr] |
733 | mov ebx,[screen_ptr] |
746 | mov ecx,[size_y_var] |
734 | mov ecx,[size_y_var] |
747 | ; mov ecx,SIZE_X shl 16 + SIZE_Y |
735 | ; mov ecx,SIZE_X shl 16 + SIZE_Y |
748 | mov edx,[offset_y] ;5 shl 16 + 25 |
736 | mov edx,[offset_y] ;5 shl 16 + 25 |
- | 737 | cmp [dr_flag],12 |
|
- | 738 | je .ff |
|
749 | int 0x40 |
739 | int 0x40 |
- | 740 | jmp .f |
|
- | 741 | .ff: |
|
- | 742 | mov eax,65 |
|
- | 743 | mov esi,32 |
|
- | 744 | xor ebp,ebp |
|
- | 745 | int 0x40 |
|
750 | 746 | .f: |
|
751 | mov eax,13 |
747 | mov eax,13 |
752 | mov bx,[size_x_var] |
748 | mov bx,[size_x_var] |
753 | add ebx,18 |
749 | add ebx,18 |
754 | shl ebx,16 |
750 | shl ebx,16 |
755 | mov bx,60 |
751 | mov bx,60 |
Line 771... | Line 767... | ||
771 | mov esi,10 ; text length |
767 | mov esi,10 ; text length |
772 | int 40h |
768 | int 40h |
773 | 769 | ||
Line 774... | Line -... | ||
774 | - | ||
775 | ; addsubps xmm0,xmm0 |
- | |
Line 776... | Line 770... | ||
776 | 770 | ||
Line 777... | Line 771... | ||
777 | 771 | ||
778 | jmp still |
772 | jmp still |
Line 795... | Line 789... | ||
795 | include "BUMP_TEX.INC" |
789 | include "BUMP_TEX.INC" |
796 | include "GRD_TEX.INC" |
790 | include "GRD_TEX.INC" |
797 | include "TWO_TEX.INC" |
791 | include "TWO_TEX.INC" |
798 | include "ASC.INC" |
792 | include "ASC.INC" |
799 | clear_vertices_index: |
793 | if Ext >= SSE3 |
- | 794 | include "3r_phg.inc" |
|
- | 795 | end if |
|
- | 796 | clear_vertices_index: |
|
800 | mov edi,[vertices_index_ptr] |
797 | mov edi,[vertices_index_ptr] |
801 | movzx eax,word[size_x_var] |
798 | movzx eax,word[size_x_var] |
802 | movzx ecx,word[size_y_var] |
799 | movzx ecx,word[size_y_var] |
803 | imul ecx,eax |
800 | imul ecx,eax |
804 | xor eax,eax |
801 | xor eax,eax |
Line 823... | Line 820... | ||
823 | movzx ecx,word[.y_coord] |
820 | movzx ecx,word[.y_coord] |
824 | movzx edx,word[size_x_var] |
821 | movzx edx,word[size_x_var] |
825 | imul edx,ecx |
822 | imul edx,ecx |
826 | add ebx,edx |
823 | add ebx,edx |
827 | 824 | push ebx |
|
828 | lea ecx,[ebx*2] |
- | |
- | 825 | lea ecx,[ebx*2] |
|
829 | lea ebx,[ebx*3] |
826 | lea ebx,[ebx*3] |
830 | add ebx,[screen_ptr] |
827 | |
- | 828 | cmp [dr_flag],12 |
|
- | 829 | jne @f |
|
- | 830 | add ebx,[esp] |
|
- | 831 | @@: |
|
- | 832 | add esp,4 |
|
- | 833 | add ebx,[screen_ptr] |
|
831 | mov ebx,[ebx] |
834 | mov ebx,[ebx] |
832 | and ebx,0x00ffffff |
835 | and ebx,0x00ffffff |
833 | cmp ebx,0x00ff0000 ; is handle bar ? |
836 | cmp ebx,0x00ff0000 ; is handle bar ? |
834 | } |
837 | } |
835 | 838 | ||
Line 866... | Line 869... | ||
866 | jz .not_press ; check if left mouse button press |
869 | jz .not_press ; check if left mouse button press |
867 | 870 | ||
Line 868... | Line 871... | ||
868 | ; left button pressed |
871 | ; left button pressed |
Line 869... | Line -... | ||
869 | - | ||
870 | ; macro check_bar |
- | |
871 | ; { |
- | |
872 | ; movzx ebx,word[.x_coord] |
- | |
873 | ; movzx ecx,word[.y_coord] |
- | |
874 | ; imul ebx,ecx |
- | |
875 | ; lea ecx,[ebx*2] |
- | |
876 | ; lea ebx,[ebx*3] |
- | |
877 | ; add ebx,[screen_ptr] |
- | |
878 | ; mov ebx,[ebx] |
- | |
879 | ; and ebx,0x00ffffff |
- | |
880 | ; cmp ebx,0x00ff0000 ; is handle bar ? |
- | |
Line 881... | Line 872... | ||
881 | ; } |
872 | |
882 | 873 | ||
883 | check_bar |
874 | check_bar |
884 | jne .no_edit |
875 | jne .no_edit |
Line 983... | Line 974... | ||
983 | movzx eax,word[size_y_var] |
974 | movzx eax,word[size_y_var] |
984 | mul ecx |
975 | mul ecx |
985 | 976 | ||
Line 986... | Line 977... | ||
986 | mov [.temp],eax |
977 | mov [.temp],eax |
987 | lea ecx,[eax*3] |
978 | lea ecx,[eax*4] ; more mem for r_phg cause |
988 | add ecx,256 |
979 | add ecx,256 |
989 | mov eax,68 |
980 | mov eax,68 |
990 | mov ebx,20 |
981 | mov ebx,20 |
991 | mov edx,[screen_ptr] |
982 | mov edx,[screen_ptr] |
992 | int 0x40 |
983 | int 0x40 |
Line 1018... | Line 1009... | ||
1018 | pop ebp |
1009 | pop ebp |
1019 | 1010 | ||
Line 1020... | Line -... | ||
1020 | - | ||
1021 | - | ||
1022 | if 0 |
- | |
1023 | ;old Menuet style alloc |
- | |
1024 | movzx ecx,word[size_x_var] |
- | |
1025 | movzx eax,word[size_y_var] |
- | |
1026 | add eax,200 |
- | |
1027 | mul ecx |
- | |
1028 | lea ecx,[eax*3] |
- | |
1029 | add ecx,16 |
- | |
1030 | and ecx,0xfffffff0 |
- | |
1031 | push ecx |
- | |
1032 | shl eax,2 |
- | |
1033 | add ecx,eax |
- | |
1034 | add ecx,MEM_END |
- | |
1035 | mov ebx,1 |
- | |
1036 | mov eax,64 ; allocate mem - resize app mem |
- | |
1037 | int 0x40 |
- | |
1038 | mov [screen_ptr],MEM_END |
- | |
1039 | mov [Zbuffer_ptr],MEM_END |
- | |
1040 | pop ecx |
- | |
1041 | add [Zbuffer_ptr],ecx |
- | |
Line 1042... | Line 1011... | ||
1042 | end if |
1011 | |
1043 | ret |
1012 | |
1044 | 1013 | ||
1045 | update_flags: |
1014 | update_flags: |
Line 1061... | Line 1030... | ||
1061 | @@: |
1030 | @@: |
1062 | add edi,17 |
1031 | add edi,17 |
1063 | cmp byte[edi],-1 |
1032 | cmp byte[edi],-1 |
1064 | jne .ch_another |
1033 | jne .ch_another |
1065 | .write: |
1034 | jmp .no_write |
- | 1035 | .write: |
|
1066 | ; clreol {pascal never dies} |
1036 | ; clreol {pascal never dies} |
1067 | ; * eax = 13 - function number |
1037 | ; * eax = 13 - function number |
1068 | ; * ebx = [coordinate on axis x]*65536 + [size on axis x] |
1038 | ; * ebx = [coordinate on axis x]*65536 + [size on axis x] |
1069 | ; * ecx = [coordinate on axis y]*65536 + [size on axis y] |
1039 | ; * ecx = [coordinate on axis y]*65536 + [size on axis y] |
1070 | ; * edx = color 0xRRGGBB or 0x80RRGGBB for gradient fill |
1040 | ; * edx = color 0xRRGGBB or 0x80RRGGBB for gradient fill |
Line 1445... | Line 1415... | ||
1445 | .env_done: |
1415 | .env_done: |
1446 | mov esp,ebp |
1416 | mov esp,ebp |
1447 | pop ebp |
1417 | pop ebp |
1448 | ret |
1418 | ret |
1449 | if 0 |
- | |
1450 | init_triangles_normals: |
- | |
1451 | mov ebx,triangles_normals |
- | |
1452 | mov ebp,triangles |
- | |
1453 | @@: |
- | |
1454 | push ebx |
- | |
1455 | mov ebx,vectors |
- | |
1456 | mov esi,dword[ebp] ; first point index |
- | |
1457 | lea esi,[esi*3] |
- | |
1458 | lea esi,[points+esi*2] ; esi - pointer to 1st 3d point |
- | |
1459 | movzx edi,dword[ebp+4] ; second point index |
- | |
1460 | lea edi,[edi*3] |
- | |
1461 | lea edi,[points+edi*2] ; edi - pointer to 2nd 3d point |
- | |
1462 | call make_vector |
- | |
1463 | add ebx,12 |
- | |
1464 | mov esi,edi |
- | |
1465 | movzx edi,dword[ebp+8] ; third point index |
- | |
1466 | lea edi,[edi*3] |
- | |
1467 | lea edi,[points+edi*2] |
- | |
1468 | call make_vector |
- | |
1469 | mov edi,ebx ; edi - pointer to 2nd vector |
- | |
1470 | mov esi,ebx |
- | |
1471 | sub esi,12 ; esi - pointer to 1st vector |
- | |
1472 | pop ebx |
- | |
1473 | call cross_product |
- | |
1474 | mov edi,ebx |
- | |
1475 | call normalize_vector |
- | |
1476 | add ebp,12 |
- | |
1477 | add ebx,12 |
- | |
1478 | cmp dword[ebp],-1 |
- | |
1479 | jne @b |
- | |
1480 | ret |
- | |
1481 | end if |
- | |
Line 1482... | Line 1419... | ||
1482 | 1419 | ||
1483 | init_point_normals: |
1420 | init_point_normals: |
1484 | .x equ dword [ebp-4] |
1421 | .x equ dword [ebp-4] |
1485 | .y equ dword [ebp-8] |
1422 | .y equ dword [ebp-8] |
Line 1597... | Line 1534... | ||
1597 | jnz @b |
1534 | jnz @b |
1598 | ; cmp dword[ebp],-1 |
1535 | ; cmp dword[ebp],-1 |
1599 | ; jne @b |
1536 | ; jne @b |
1600 | ret |
1537 | ret |
1601 | if 0 ; ind 64 but |
1538 | |
1602 | - | ||
1603 | ;================================================================= |
- | |
1604 | sort_triangles: |
- | |
1605 | mov esi,[triangles_ptr] |
- | |
1606 | mov edi,triangles_with_z |
- | |
1607 | mov ebp,[points_translated_ptr] |
- | |
1608 | - | ||
1609 | make_triangle_with_z: ;makes list with triangles and z position |
- | |
1610 | movzx eax,word[esi] |
- | |
1611 | lea eax,[eax*3] |
- | |
1612 | movzx ecx,word[ebp+eax*2+4] |
- | |
1613 | - | ||
1614 | movzx eax,word[esi+2] |
- | |
1615 | lea eax,[eax*3] |
- | |
1616 | add cx,word[ebp+eax*2+4] |
- | |
1617 | - | ||
1618 | movzx eax,word[esi+4] |
- | |
1619 | lea eax,[eax*3] |
- | |
1620 | add cx,word[ebp+eax*2+4] |
- | |
1621 | - | ||
1622 | mov ax,cx |
- | |
1623 | ; cwd |
- | |
1624 | ; idiv word[i3] |
- | |
1625 | movsd ; store vertex coordinates |
- | |
1626 | movsw |
- | |
1627 | stosw ; middle vertex coordinate 'z' in triangles_with_z list |
- | |
1628 | cmp dword[esi],-1 |
- | |
1629 | jne make_triangle_with_z |
- | |
1630 | movsd ; copy end mark |
- | |
1631 | mov eax,4 |
- | |
1632 | lea edx,[edi-8-trizdd] |
- | |
1633 | ; lea edx, [edi-8] |
- | |
1634 | ; sub edx,[triangles_w_z_ptr] |
- | |
1635 | mov [high],edx |
- | |
1636 | call quicksort |
- | |
1637 | mov eax,4 |
- | |
1638 | mov edx,[high] |
- | |
1639 | call insertsort |
- | |
1640 | jmp end_sort |
- | |
1641 | - | ||
1642 | quicksort: |
- | |
1643 | mov ecx,edx |
- | |
1644 | sub ecx,eax |
- | |
1645 | cmp ecx,32 |
- | |
1646 | jc .exit |
- | |
1647 | lea ecx,[eax+edx] |
- | |
1648 | shr ecx,4 |
- | |
1649 | lea ecx,[ecx*8-4]; |
- | |
1650 | ; mov edi,[triangles_w_z_ptr] |
- | |
1651 | ; mov ebx,[edi+eax] |
- | |
1652 | ; mov esi,[edi+ecx] |
- | |
1653 | ; mov edi,[edi+edx] |
- | |
1654 | mov ebx,[trizdd+eax]; trizdd[l] |
- | |
1655 | mov esi,[trizdd+ecx]; trizdd[i] |
- | |
1656 | mov edi,[trizdd+edx]; trizdd[h] |
- | |
1657 | cmp ebx,esi |
- | |
1658 | jg @f ; direction NB! you need to negate these to invert the order |
- | |
1659 | if Ext=NON |
- | |
1660 | mov [trizdd+eax],esi |
- | |
1661 | mov [trizdd+ecx],ebx |
- | |
1662 | mov ebx,[trizdd+eax-4] |
- | |
1663 | mov esi,[trizdd+ecx-4] |
- | |
1664 | mov [trizdd+eax-4],esi |
- | |
1665 | mov [trizdd+ecx-4],ebx |
- | |
1666 | mov ebx,[trizdd+eax] |
- | |
1667 | mov esi,[trizdd+ecx] |
- | |
1668 | else |
- | |
1669 | ; push ebx |
- | |
1670 | ; mov ebx,[triangles_w_z_ptr] |
- | |
1671 | ; movq mm0,[ebx+eax-4] |
- | |
1672 | ; movq mm1,[ebx+ecx-4] |
- | |
1673 | ; movq [ebx+ecx-4],mm0 |
- | |
1674 | ; movq [ebx+eax-4],mm1 |
- | |
1675 | ; pop ebx |
- | |
1676 | movq mm0,[trizdq+eax-4] |
- | |
1677 | movq mm1,[trizdq+ecx-4] |
- | |
1678 | movq [trizdq+ecx-4],mm0 |
- | |
1679 | movq [trizdq+eax-4],mm1 |
- | |
1680 | xchg ebx,esi |
- | |
1681 | end if |
- | |
1682 | @@: |
- | |
1683 | cmp ebx,edi |
- | |
1684 | jg @f ; direction |
- | |
1685 | if Ext=NON |
- | |
1686 | mov [trizdd+eax],edi |
- | |
1687 | mov [trizdd+edx],ebx |
- | |
1688 | mov ebx,[trizdd+eax-4] |
- | |
1689 | mov edi,[trizdd+edx-4] |
- | |
1690 | mov [trizdd+eax-4],edi |
- | |
1691 | mov [trizdd+edx-4],ebx |
- | |
1692 | mov ebx,[trizdd+eax] |
- | |
1693 | mov edi,[trizdd+edx] |
- | |
1694 | else |
- | |
1695 | ; push ebx |
- | |
1696 | ; mov ebx,[triangles_w_z_ptr] |
- | |
1697 | ; movq mm0,[ebx+eax-4] |
- | |
1698 | ; movq mm1,[ebx+edx-4] |
- | |
1699 | ; movq [ebx+edx-4],mm0 |
- | |
1700 | ; movq [ebx+eax-4],mm1 |
- | |
1701 | movq mm0,[trizdq+eax-4] |
- | |
1702 | movq mm1,[trizdq+edx-4] |
- | |
1703 | movq [trizdq+edx-4],mm0 |
- | |
1704 | movq [trizdq+eax-4],mm1 |
- | |
1705 | ; pop ebx |
- | |
1706 | xchg ebx,edi |
- | |
1707 | end if |
- | |
1708 | @@: |
- | |
1709 | cmp esi,edi |
- | |
1710 | jg @f ; direction |
- | |
1711 | if Ext=NON |
- | |
1712 | mov [trizdd+ecx],edi |
- | |
1713 | mov [trizdd+edx],esi |
- | |
1714 | mov esi,[trizdd+ecx-4] |
- | |
1715 | mov edi,[trizdd+edx-4] |
- | |
1716 | mov [trizdd+ecx-4],edi |
- | |
1717 | mov [trizdd+edx-4],esi |
- | |
1718 | else |
- | |
1719 | ; push ebx |
- | |
1720 | ; mov ebx,[triangles_w_z_ptr] |
- | |
1721 | ; movq mm0,[ebx+ecx-4] |
- | |
1722 | ; movq mm1,[ebx+edx-4] |
- | |
1723 | ; movq [ebx+edx-4],mm0 |
- | |
1724 | ; movq [ebx+ecx-4],mm1 |
- | |
1725 | ; pop ebx |
- | |
1726 | - | ||
1727 | movq mm0,[trizdq+ecx-4] |
- | |
1728 | movq mm1,[trizdq+edx-4] |
- | |
1729 | movq [trizdq+edx-4],mm0 |
- | |
1730 | movq [trizdq+ecx-4],mm1 |
- | |
1731 | xchg ebx,esi |
- | |
1732 | end if |
- | |
1733 | @@: |
- | |
1734 | mov ebp,eax ; direction |
- | |
1735 | add ebp,8 ; j |
- | |
1736 | if Ext=NON |
- | |
1737 | mov esi,[trizdd+ebp] |
- | |
1738 | mov edi,[trizdd+ecx] |
- | |
1739 | mov [trizdd+ebp],edi |
- | |
1740 | mov [trizdd+ecx],esi |
- | |
1741 | mov esi,[trizdd+ebp-4] |
- | |
1742 | mov edi,[trizdd+ecx-4] |
- | |
1743 | mov [trizdd+ecx-4],esi |
- | |
1744 | mov [trizdd+ebp-4],edi |
- | |
1745 | else |
- | |
1746 | ; push ebx |
- | |
1747 | ; mov ebx,[triangles_w_z_ptr] |
- | |
1748 | ; movq mm0,[ebx+ebp-4] |
- | |
1749 | ; movq mm1,[ebx+ecx-4] |
- | |
1750 | ; movq [ebx+ecx-4],mm0 |
- | |
1751 | ; movq [ebx+ebp-4],mm1 |
- | |
1752 | ; pop ebx |
- | |
1753 | - | ||
1754 | movq mm0,[trizdq+ebp-4] |
- | |
1755 | movq mm1,[trizdq+ecx-4] |
- | |
1756 | movq [trizdq+ecx-4],mm0 |
- | |
1757 | movq [trizdq+ebp-4],mm1 |
- | |
1758 | end if |
- | |
1759 | mov ecx,edx ; i; direction |
- | |
1760 | mov ebx,[trizdd+ebp]; trizdd[j] |
- | |
1761 | ; mov ebx, [triangles_w_z_ptr] |
- | |
1762 | ; add ebx, ebp |
- | |
1763 | - | ||
Line 1764... | Line -... | ||
1764 | ; push eax |
- | |
1765 | ; mov eax, [triangles_w_z_ptr] |
- | |
1766 | .loop: |
- | |
1767 | sub ecx,8 ; direction |
- | |
1768 | cmp [trizdd+ecx],ebx |
- | |
1769 | ; cmp [eax+ecx],ebx |
- | |
1770 | jl .loop ; direction |
- | |
1771 | @@: |
- | |
1772 | add ebp,8 ; direction |
- | |
1773 | cmp [trizdd+ebp],ebx |
- | |
1774 | ; cmp [eax+ebp],ebx |
- | |
1775 | jg @b ; direction |
- | |
1776 | cmp ebp,ecx |
- | |
1777 | jge @f ; direction |
- | |
1778 | if Ext=NON |
1539 | if Ext >= SSE3 |
1779 | mov esi,[trizdd+ecx] |
- | |
1780 | mov edi,[trizdd+ebp] |
- | |
1781 | mov [trizdd+ebp],esi |
- | |
1782 | mov [trizdd+ecx],edi |
1540 | copy_lights: ; after normalising ! |
1783 | mov edi,[trizdd+ecx-4] |
- | |
1784 | mov esi,[trizdd+ebp-4] |
- | |
1785 | mov [trizdd+ebp-4],edi |
- | |
1786 | mov [trizdd+ecx-4],esi |
- | |
1787 | else |
- | |
1788 | ; movq mm0,[eax+ecx-4] |
- | |
1789 | ; movq mm1,[eax+ebp-4] |
- | |
1790 | ; movq [eax+ebp-4],mm0 |
- | |
1791 | ; movq [eax+ecx-4],mm1 |
- | |
1792 | movq mm0,[trizdq+ecx-4] |
- | |
1793 | movq mm1,[trizdq+ebp-4] |
- | |
1794 | movq [trizdq+ebp-4],mm0 |
- | |
1795 | movq [trizdq+ecx-4],mm1 |
- | |
1796 | end if |
- | |
1797 | jmp .loop |
- | |
1798 | ; pop eax |
- | |
1799 | @@: |
- | |
1800 | if Ext=NON |
- | |
1801 | mov esi,[trizdd+ecx] |
1541 | mov esi,lights |
1802 | mov edi,[trizdd+eax+8] |
- | |
1803 | mov [trizdd+eax+8],esi |
- | |
1804 | mov [trizdd+ecx],edi |
- | |
1805 | mov edi,[trizdd+ecx-4] |
1542 | mov edi,lights_aligned |
1806 | mov esi,[trizdd+eax+4] |
- | |
1807 | mov [trizdd+eax+4],edi |
- | |
1808 | mov [trizdd+ecx-4],esi |
- | |
1809 | else |
- | |
1810 | ; push edx |
- | |
1811 | ; mov edx,[triangles_w_z_ptr] |
- | |
1812 | ; movq mm0,[edx+ecx-4] |
- | |
1813 | ; movq mm1,[edx+eax+4]; dir |
- | |
1814 | ; movq [edx+eax+4],mm0; dir |
- | |
1815 | ; movq [edx+ecx-4],mm1 |
- | |
1816 | ; pop edx |
1543 | mov ecx,3 |
1817 | - | ||
1818 | movq mm0,[trizdq+ecx-4] |
- | |
1819 | movq mm1,[trizdq+eax+4]; dir |
- | |
1820 | movq [trizdq+eax+4],mm0; dir |
- | |
1821 | movq [trizdq+ecx-4],mm1 |
- | |
1822 | end if |
1544 | .again: |
1823 | add ecx,8 |
- | |
1824 | push ecx edx |
1545 | push ecx |
1825 | mov edx,ebp |
1546 | mov ecx,3 |
1826 | call quicksort |
- | |
1827 | pop edx eax |
- | |
1828 | call quicksort |
- | |
1829 | .exit: |
1547 | cld |
1830 | ret |
- | |
1831 | insertsort: |
- | |
1832 | mov esi,eax |
- | |
1833 | .start: |
- | |
1834 | add esi,8 |
- | |
1835 | cmp esi,edx |
1548 | rep movsd |
1836 | ja .exit |
- | |
1837 | mov ebx,[trizdd+esi] |
- | |
1838 | ; mov ebx,[triangles_w_z_ptr] |
- | |
1839 | ; add ebx,esi |
1549 | xor eax,eax |
1840 | if Ext=NON |
- | |
1841 | mov ecx,[trizdd+esi-4] |
- | |
1842 | else |
1550 | stosd |
1843 | ; push ebx |
- | |
1844 | ; mov ebx,[triangles_w_z_ptr] |
- | |
1845 | ; movq mm1,[ebx+esi-4] |
- | |
1846 | movq mm1,[trizdq+esi-4] |
- | |
1847 | ; pop ebx |
- | |
1848 | end if |
- | |
1849 | mov edi,esi |
1551 | mov ecx,3 |
1850 | @@: |
1552 | .b: |
1851 | cmp edi,eax |
- | |
1852 | jna @f |
- | |
1853 | ; push eax |
- | |
1854 | ; mov eax,[triangles_w_z_ptr] |
- | |
1855 | ; cmp [eax+edi-8],ebx |
- | |
1856 | ; pop eax |
- | |
1857 | cmp [trizdd+edi-8],ebx |
- | |
1858 | jg @f ; direction |
- | |
1859 | if Ext=NON |
- | |
1860 | mov ebp,[trizdd+edi-8] |
- | |
1861 | mov [trizdd+edi],ebp |
- | |
1862 | mov ebp,[trizdd+edi-12] |
- | |
1863 | mov [trizdd+edi-4],ebp |
- | |
1864 | else |
- | |
1865 | ; push eax |
1553 | push ecx |
1866 | ; mov eax,[triangles_w_z_ptr] |
- | |
1867 | ; movq mm0,[eax+edi-12] |
- | |
1868 | ; movq [eax+edi-4],mm0 |
- | |
1869 | movq mm0,[trizdq+edi-12] |
- | |
1870 | movq [trizdq+edi-4],mm0 |
- | |
1871 | ; pop eax |
- | |
1872 | end if |
- | |
1873 | sub edi,8 |
1554 | mov ecx,3 |
1874 | jmp @b |
- | |
1875 | @@: |
1555 | @@: |
1876 | if Ext=NON |
1556 | movzx ebx,byte[esi] |
1877 | mov [trizdd+edi],ebx |
1557 | cvtsi2ss xmm0,ebx |
1878 | mov [trizdd+edi-4],ecx |
1558 | movss [edi],xmm0 |
1879 | else |
1559 | inc esi |
1880 | ; push eax |
1560 | add edi,4 |
1881 | ; mov eax,[triangles_w_z_ptr] |
1561 | loop @b |
1882 | ; movq [eax+edi-4],mm1 |
1562 | stosd |
1883 | movq [trizdq+edi-4],mm1 |
1563 | pop ecx |
1884 | ; pop eax |
1564 | loop .b |
1885 | end if |
1565 | inc esi ; skip shiness |
1886 | jmp .start |
1566 | pop ecx |
1887 | .exit: |
1567 | loop .again |
1888 | ret |
1568 | ret |
1889 | end_sort: |
- | |
1890 | ; translate triangles_with_z to sorted_triangles |
- | |
1891 | mov esi,triangles_with_z |
- | |
1892 | ; mov esi,[triangles_w_z_ptr] |
- | |
1893 | ; mov edi,sorted_triangles |
- | |
1894 | mov edi,[triangles_ptr] |
- | |
1895 | again_copy: |
- | |
1896 | if Ext=NON |
- | |
1897 | movsd |
- | |
1898 | movsw |
- | |
1899 | add esi,2 |
- | |
1900 | else |
- | |
1901 | movq mm0,[esi] |
- | |
1902 | movq [edi],mm0 |
- | |
1903 | add esi,8 |
- | |
1904 | add edi,6 |
- | |
1905 | end if |
1569 | end if |
1906 | cmp dword[esi],-1 |
- | |
1907 | jne again_copy |
- | |
1908 | ; if Ext=MMX |
- | |
1909 | ; emms |
- | |
1910 | ; end if |
- | |
1911 | movsd ; copy end mark too |
- | |
1912 | ret |
1570 | |
1913 | end if ; 64 ind |
- | |
1914 | clrscr: |
1571 | clrscr: |
1915 | mov edi,[screen_ptr] |
1572 | mov edi,[screen_ptr] |
1916 | movzx ecx,word[size_x_var] |
1573 | movzx ecx,word[size_x_var] |
1917 | movzx eax,word[size_y_var] |
1574 | movzx eax,word[size_y_var] |
1918 | imul ecx,eax |
1575 | imul ecx,eax |
1919 | lea ecx,[ecx*3] |
- | |
1920 | shr ecx,2 |
- | |
- | 1576 | ||
- | 1577 | ||
1921 | xor eax,eax |
1578 | xor eax,eax |
1922 | if Ext=NON |
1579 | if Ext=NON |
1923 | rep stosd |
1580 | rep stosd |
1924 | else if Ext = MMX |
1581 | else if Ext = MMX |
1925 | pxor mm0,mm0 |
1582 | pxor mm0,mm0 |
Line 2128... | Line 1785... | ||
2128 | cmp [dr_flag],10 |
1785 | cmp [dr_flag],10 |
2129 | je .cubic_env_mapping |
1786 | je .cubic_env_mapping |
2130 | cmp [dr_flag],11 |
1787 | cmp [dr_flag],11 |
2131 | je .draw_smooth_line |
1788 | je .draw_smooth_line |
2132 | ; **************** |
1789 | if Ext >= SSE3 |
- | 1790 | cmp [dr_flag],12 |
|
- | 1791 | je .r_phg |
|
- | 1792 | end if ; **************** |
|
2133 | mov esi,point_index3 ; do Gouraud shading |
1793 | mov esi,point_index3 ; do Gouraud shading |
2134 | mov ecx,3 |
1794 | mov ecx,3 |
2135 | .again_grd_draw: |
1795 | .again_grd_draw: |
2136 | mov eax,dword[esi] |
1796 | mov eax,dword[esi] |
2137 | shl eax,2 |
1797 | shl eax,2 |
2138 | lea eax,[eax*3] |
1798 | lea eax,[eax*3] |
Line 2951... | Line 2611... | ||
2951 | push [yy2] |
2611 | push [yy2] |
2952 | push [xx2] |
2612 | push [xx2] |
2953 | 2613 | ||
Line 2954... | Line 2614... | ||
2954 | call smooth_line |
2614 | call smooth_line |
- | 2615 | jmp .end_draw |
|
2955 | @@: |
2616 | @@: |
- | 2617 | if Ext >= SSE3 |
|
- | 2618 | .r_phg: |
|
- | 2619 | ||
- | 2620 | ||
- | 2621 | movd xmm5,[size_y_var] |
|
- | 2622 | punpcklwd xmm5,[the_zero] |
|
- | 2623 | pshufd xmm5,xmm5,01110011b |
|
- | 2624 | ||
- | 2625 | ||
- | 2626 | mov eax,[point_index1] |
|
- | 2627 | mov ebx,[point_index2] |
|
- | 2628 | mov ecx,[point_index3] |
|
- | 2629 | imul eax,[i12] |
|
- | 2630 | imul ebx,[i12] |
|
- | 2631 | imul ecx,[i12] |
|
- | 2632 | add eax,[points_normals_rot_ptr] |
|
- | 2633 | add ebx,[points_normals_rot_ptr] |
|
- | 2634 | add ecx,[points_normals_rot_ptr] |
|
- | 2635 | movups xmm0,[eax] |
|
- | 2636 | movups xmm1,[ebx] |
|
- | 2637 | movups xmm2,[ecx] |
|
- | 2638 | andps xmm0,[zero_hgst_dd] |
|
- | 2639 | andps xmm1,[zero_hgst_dd] |
|
- | 2640 | andps xmm2,[zero_hgst_dd] |
|
- | 2641 | xorps xmm3,xmm3 |
|
- | 2642 | ||
- | 2643 | mov eax,[point_index1] |
|
- | 2644 | mov ebx,[point_index2] |
|
- | 2645 | mov ecx,[point_index3] |
|
- | 2646 | imul eax,[i12] |
|
- | 2647 | imul ebx,[i12] |
|
- | 2648 | imul ecx,[i12] |
|
- | 2649 | add eax,[points_rotated_ptr] |
|
- | 2650 | add ebx,[points_rotated_ptr] |
|
- | 2651 | add ecx,[points_rotated_ptr] |
|
- | 2652 | push dword[ecx+8] |
|
- | 2653 | push dword[ebx+8] |
|
- | 2654 | push dword[eax+8] |
|
- | 2655 | movups xmm4,[esp] |
|
- | 2656 | add esp,12 |
|
- | 2657 | andps xmm4,[zero_hgst_dd] |
|
- | 2658 | ||
- | 2659 | ||
- | 2660 | ||
- | 2661 | mov eax,dword[xx1] |
|
- | 2662 | ror eax,16 |
|
- | 2663 | mov ebx,dword[xx2] |
|
- | 2664 | ror ebx,16 |
|
- | 2665 | mov ecx,dword[xx3] |
|
- | 2666 | ror ecx,16 |
|
- | 2667 | mov edi,[screen_ptr] |
|
- | 2668 | mov esi,[Zbuffer_ptr] |
|
- | 2669 | ||
- | 2670 | call real_phong_tri_z |
|
- | 2671 | ||
- | 2672 | jmp .end_draw |
|
- | 2673 | end if |
|
- | 2674 | ||
- | 2675 | ||
- | 2676 | ||
- | 2677 | ||
- | 2678 | ||
- | 2679 | ||
- | 2680 | ||
Line 2956... | Line 2681... | ||
2956 | 2681 | ||
2957 | .end_draw: |
2682 | .end_draw: |
2958 | pop esi |
2683 | pop esi |
2959 | add esi,12 |
2684 | add esi,12 |
Line 2988... | Line 2713... | ||
2988 | sub esp,12 |
2713 | sub esp,12 |
2989 | push dword 0 |
2714 | push dword 0 |
2990 | 2715 | ||
Line 2991... | Line 2716... | ||
2991 | movzx eax,word[size_x_var] |
2716 | movzx eax,word[size_x_var] |
- | 2717 | cmp [dr_flag],12 |
|
- | 2718 | je @f |
|
2992 | lea ebx,[eax*3] |
2719 | lea ebx,[eax*3] |
2993 | sub ebx,18 |
2720 | sub ebx,18 |
2994 | add eax,eax |
2721 | add eax,eax |
2995 | sub eax,12 |
2722 | sub eax,12 |
2996 | mov [.xres3m18],ebx |
2723 | mov [.xres3m18],ebx |
2997 | mov [.xres2m12],eax |
2724 | mov [.xres2m12],eax |
- | 2725 | jmp .f |
|
- | 2726 | @@: |
|
- | 2727 | lea ebx,[eax*4] |
|
- | 2728 | sub ebx,4*6 |
|
- | 2729 | add eax,eax |
|
- | 2730 | sub eax,3*4 |
|
- | 2731 | mov [.xres3m18],ebx |
|
- | 2732 | mov [.xres2m12],eax |
|
- | 2733 | .f: |
|
- | 2734 | ||
- | 2735 | ||
Line 2998... | Line 2736... | ||
2998 | 2736 | ||
2999 | mov esi,[points_translated_ptr] |
2737 | mov esi,[points_translated_ptr] |
3000 | .loop: |
2738 | .loop: |
3001 | push esi |
2739 | push esi |
Line 3031... | Line 2769... | ||
3031 | ; sub ebx,3 |
2769 | ; sub ebx,3 |
3032 | ; sub eax,3 |
2770 | ; sub eax,3 |
3033 | imul eax,edx |
2771 | imul eax,edx |
3034 | add eax,ebx |
2772 | add eax,ebx |
3035 | lea edi,[eax*3] |
2773 | push eax |
- | 2774 | lea edi,[eax*3] |
|
3036 | lea eax,[eax*2] |
2775 | cmp [dr_flag],12 |
- | 2776 | jne @f |
|
- | 2777 | add edi,[esp] |
|
- | 2778 | @@: |
|
- | 2779 | add esp,4 |
|
- | 2780 | lea eax,[eax*2] |
|
3037 | ; draw bar 6x6 |
2781 | ; draw bar 6x6 |
3038 | add edi,[screen_ptr] |
2782 | add edi,[screen_ptr] |
3039 | add eax,dword[vertices_index_ptr] |
2783 | add eax,dword[vertices_index_ptr] |
3040 | 2784 | ||
Line 3047... | Line 2791... | ||
3047 | .oop: |
2791 | .oop: |
3048 | push ecx |
2792 | push ecx |
3049 | mov ecx,6 |
2793 | mov ecx,6 |
Line 3050... | Line 2794... | ||
3050 | 2794 | ||
3051 | @@: |
2795 | .do: |
3052 | mov word[edi],0x0000 ;ax |
2796 | mov word[edi],0x0000 ;ax |
3053 | mov byte[edi+2],0xff ;al |
2797 | mov byte[edi+2],0xff ;al |
3054 | mov word[eax],dx |
2798 | mov word[eax],dx |
- | 2799 | add eax,2 |
|
- | 2800 | cmp [dr_flag],12 |
|
- | 2801 | jne @f |
|
- | 2802 | add edi,4 |
|
- | 2803 | loop .do |
|
- | 2804 | jmp .ad |
|
3055 | add eax,2 |
2805 | @@: |
3056 | add edi,3 |
2806 | add edi,3 |
- | 2807 | loop .do |
|
3057 | loop @b |
2808 | .ad: |
3058 | add edi,[.xres3m18] |
2809 | add edi,[.xres3m18] |
3059 | add eax,[.xres2m12] |
2810 | add eax,[.xres2m12] |
3060 | pop ecx |
2811 | pop ecx |
Line 3075... | Line 2826... | ||
3075 | 2826 | ||
Line 3076... | Line 2827... | ||
3076 | 2827 | ||
3077 | fill_Z_buffer: |
2828 | fill_Z_buffer: |
- | 2829 | mov eax,0x70000000 |
|
- | 2830 | cmp [dr_flag],12 |
|
- | 2831 | jne @f |
|
- | 2832 | mov eax,60000.1 |
|
3078 | mov eax,0x70000000 |
2833 | @@: |
3079 | mov edi,[Zbuffer_ptr] |
2834 | mov edi,[Zbuffer_ptr] |
3080 | movzx ecx,word[size_x_var] |
2835 | movzx ecx,word[size_x_var] |
3081 | movzx ebx,word[size_y_var] |
2836 | movzx ebx,word[size_y_var] |
3082 | imul ecx,ebx |
2837 | imul ecx,ebx |