Rev 2984 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2984 | Rev 3066 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ; application : View3ds ver. 0.063 - tiny .3ds files viewer. |
1 | ; application : View3ds ver. 0.064 - tiny .3ds files viewer. |
2 | ; compiler : FASM |
2 | ; compiler : FASM |
3 | ; system : KolibriOS |
3 | ; system : KolibriOS |
4 | ; author : Macgub aka Maciej Guba |
4 | ; author : Macgub aka Maciej Guba |
5 | ; email : macgub3@wp.pl |
5 | ; email : macgub3@wp.pl |
6 | ; web : www.macgub.hekko.pl |
6 | ; web : www.macgub.hekko.pl |
Line 2443... | Line 2443... | ||
2443 | sub esi,2 |
2443 | sub esi,2 |
2444 | dec ecx |
2444 | dec ecx |
2445 | jnz .again_line_param |
2445 | jnz .again_line_param |
Line 2446... | Line 2446... | ||
2446 | 2446 | ||
2447 | mov eax,[edges_ptr] |
2447 | ; mov eax,[edges_ptr] ; this not works correctly |
2448 | add eax,[edges_counter] |
2448 | ; add eax,[edges_counter] ; I mean chosing overlapped edges. |
2449 | mov bl,[eax] |
2449 | ; mov bl,[eax] ; |
2450 | test bl,00000001b |
2450 | ; test bl,00000001b ; |
2451 | jz @f |
2451 | ; jz @f ; |
2452 | mov edi,screen |
2452 | mov edi,screen |
Line 2453... | Line 2453... | ||
2453 | mov esi,[Zbuffer_ptr] |
2453 | mov esi,[Zbuffer_ptr] |
2454 | 2454 | ||
Line 2477... | Line 2477... | ||
2477 | push [xx2] |
2477 | push [xx2] |
2478 | 2478 | ||
Line 2479... | Line 2479... | ||
2479 | call smooth_line |
2479 | call smooth_line |
2480 | @@: |
2480 | @@: |
2481 | mov eax,[edges_ptr] |
2481 | ; mov eax,[edges_ptr] ; this not works correctly |
2482 | add eax,[edges_counter] |
2482 | ; add eax,[edges_counter] |
2483 | mov bl,[eax] |
2483 | ; mov bl,[eax] |
2484 | test bl,00000010b |
2484 | ; test bl,00000010b |
2485 | jz @f |
2485 | ; jz @f |
Line 2486... | Line 2486... | ||
2486 | 2486 | ||
2487 | mov edi,screen |
2487 | mov edi,screen |
Line 2488... | Line 2488... | ||
2488 | mov esi,[Zbuffer_ptr] |
2488 | mov esi,[Zbuffer_ptr] |
Line 2513... | Line 2513... | ||
2513 | 2513 | ||
Line 2514... | Line 2514... | ||
2514 | call smooth_line |
2514 | call smooth_line |
2515 | @@: |
2515 | @@: |
Line 2516... | Line 2516... | ||
2516 | 2516 | ||
2517 | mov eax,[edges_ptr] |
2517 | ; mov eax,[edges_ptr] ; this not works correctly |
2518 | add eax,[edges_counter] |
2518 | ; add eax,[edges_counter] ; |
2519 | mov bl,[eax] |
2519 | ; mov bl,[eax] ; |
2520 | test bl,00000100b |
2520 | ; test bl,00000100b ; |
Line 2521... | Line 2521... | ||
2521 | jz @f |
2521 | ; jz @f ; |
2522 | 2522 | ||
Line 2523... | Line 2523... | ||
2523 | mov edi,screen |
2523 | mov edi,screen |
Line 2566... | Line 2566... | ||
2566 | mov ecx,SIZE_X*SIZE_Y |
2566 | mov ecx,SIZE_X*SIZE_Y |
2567 | rep stosd |
2567 | rep stosd |
2568 | ret |
2568 | ret |
2569 | 2569 | ||
Line 2570... | Line 2570... | ||
2570 | read_from_file: |
2570 | read_tp_variables: ; read [triangles_count_var] and [points_count_var] |
2571 | fninit |
- | |
2572 | mov edi,[triangles_ptr] |
2571 | ; and allocate memory |
2573 | xor ebx,ebx |
2572 | xor ebx,ebx |
2574 | xor ebp,ebp |
2573 | xor ebp,ebp |
2575 | mov [points_count_var],0 |
2574 | mov [points_count_var],bx |
2576 | mov [triangles_count_var],0 |
2575 | mov [triangles_count_var],bx |
2577 | if USE_LFN = 0 |
2576 | if USE_LFN = 0 |
2578 | mov esi,SourceFile |
2577 | mov esi,SourceFile |
2579 | else |
2578 | else |
2580 | mov esi,[fptr] |
2579 | mov esi,[fptr] |
2581 | end if |
2580 | end if |
- | 2581 | ||
2582 | cmp [esi],word 4D4Dh |
2582 | cmp [esi],word 4D4Dh |
2583 | jne .exit ;Must be legal .3DS file |
2583 | je @f ;Must be legal .3DS file |
2584 | ; cmp dword[esi+2],EndFile-SourceFile |
2584 | xor eax,eax |
- | 2585 | ret |
|
2585 | ; jne .exit ;This must tell the length |
2586 | @@: |
2586 | mov eax,dword[esi+2] |
2587 | mov eax,dword[esi+2] |
2587 | ; cmp eax,[fsize] |
2588 | cmp eax,[fsize] ;This must tell the length |
- | 2589 | je @f |
|
2588 | ; jne .exit |
2590 | xor eax,eax |
2589 | 2591 | ret |
|
- | 2592 | @@: |
|
2590 | add eax,esi |
2593 | add eax,esi |
2591 | mov [EndFile],eax ; |
2594 | mov [EndFile],eax ; |
Line 2592... | Line 2595... | ||
2592 | 2595 | ||
2593 | add esi,6 |
- | |
2594 | mov eax,[edges_ptr] |
2596 | add esi,6 |
2595 | @@: |
2597 | @@: |
2596 | cmp [esi],word 3D3Dh |
2598 | cmp [esi],word 3D3Dh |
2597 | je @f |
2599 | je @f |
2598 | add esi,[esi+2] |
2600 | add esi,[esi+2] |
Line 2633... | Line 2635... | ||
2633 | 2635 | ||
Line 2634... | Line 2636... | ||
2634 | mov edx,ecx |
2636 | mov edx,ecx |
2635 | add esi,8 |
2637 | add esi,8 |
2636 | @@: |
2638 | @@: |
2637 | push edi |
- | |
2638 | mov edi,[points_ptr] |
- | |
2639 | push dword[esi+4] |
- | |
2640 | pop dword[edi+ebx*2+0] |
- | |
2641 | push dword[esi+8] |
- | |
2642 | pop dword[edi+ebx*2+4] |
- | |
2643 | push dword[esi+0] |
- | |
2644 | pop dword[edi+ebx*2+8] |
- | |
2645 | pop edi |
- | |
2646 | ; fld dword[esi+4] |
- | |
2647 | ; fstp dword[real_points+ebx*2+0] ; x |
- | |
2648 | ; fld dword[esi+8] |
- | |
2649 | ; fstp dword[real_points+ebx*2+4] ; y |
- | |
2650 | ; fld dword[esi+0] |
- | |
2651 | ; fstp dword[real_points+ebx*2+8] ; z |
- | |
Line 2652... | Line 2639... | ||
2652 | 2639 | ||
2653 | add ebx,6 |
2640 | add ebx,6 |
2654 | add esi,12 |
2641 | add esi,12 |
2655 | dec ecx |
2642 | ; dec ecx |
2656 | jnz @b |
2643 | loop @b |
2657 | @@: |
- | |
2658 | ; mov dword[points+ebx],-1 |
- | |
2659 | push edi |
- | |
2660 | mov edi,[points_ptr] |
- | |
2661 | mov dword[edi+ebx*2],-1 ; end mark (not always in use) |
2644 | @@: |
2662 | pop edi |
2645 | |
2663 | @@: |
2646 | @@: |
2664 | cmp [esi],word 4120h |
2647 | cmp [esi],word 4120h |
2665 | je @f |
2648 | je @f |
2666 | add esi,[esi+2] |
2649 | add esi,[esi+2] |
2667 | jmp @b |
2650 | jmp @b |
2668 | @@: |
2651 | @@: |
2669 | movzx ecx,word[esi+6] |
2652 | movzx ecx,word[esi+6] |
2670 | add [triangles_count_var],cx |
2653 | add [triangles_count_var],cx |
2671 | add esi,8 |
- | |
- | 2654 | add esi,8 |
|
2672 | ;mov edi,triangles |
2655 | |
2673 | @@: |
- | |
2674 | movsd |
- | |
2675 | movsw |
- | |
2676 | add word[edi-6],bp |
- | |
2677 | add word[edi-4],bp |
- | |
2678 | add word[edi-2],bp |
- | |
2679 | mov dl,byte[esi] |
- | |
2680 | mov [eax],dl |
- | |
2681 | inc eax |
2656 | @@: |
2682 | add esi,2 |
2657 | add esi,8 |
2683 | dec ecx |
2658 | dec ecx |
- | 2659 | jnz @b |
|
2684 | jnz @b |
2660 | ; xor ecx,ecx |
2685 | add ebp,edx |
2661 | add ebp,edx |
2686 | jmp .find4k |
2662 | jmp .find4k |
2687 | mov eax,-1 ;<---mark if OK |
2663 | mov eax,-1 ;<---mark if OK |
2688 | .exit: |
- | |
2689 | mov dword[edi],-1 |
2664 | .exit: |
Line 2690... | Line 2665... | ||
2690 | ret |
2665 | ret |
- | 2666 | ||
2691 | 2667 | read_from_file: |
|
2692 | read_tp_variables: ; read [triangles_count_var] and [points_count_var] |
2668 | fninit |
2693 | ; and allocate memory |
2669 | mov edi,[triangles_ptr] |
2694 | xor ebx,ebx |
2670 | xor ebx,ebx |
2695 | xor ebp,ebp |
2671 | xor ebp,ebp |
2696 | mov [points_count_var],bx |
2672 | mov [points_count_var],0 |
2697 | mov [triangles_count_var],bx |
2673 | mov [triangles_count_var],0 |
2698 | if USE_LFN = 0 |
2674 | if USE_LFN = 0 |
2699 | mov esi,SourceFile |
2675 | mov esi,SourceFile |
2700 | else |
2676 | else |
2701 | mov esi,[fptr] |
- | |
2702 | end if |
2677 | mov esi,[fptr] |
2703 | 2678 | end if |
|
2704 | cmp [esi],word 4D4Dh |
2679 | cmp [esi],word 4D4Dh |
2705 | je @f ;Must be legal .3DS file |
- | |
2706 | xor eax,eax |
2680 | jne .exit ;Must be legal .3DS file |
2707 | ret |
2681 | ; cmp dword[esi+2],EndFile-SourceFile |
2708 | @@: |
2682 | ; jne .exit ;This must tell the length |
2709 | mov eax,dword[esi+2] |
- | |
2710 | cmp eax,[fsize] ;This must tell the length |
2683 | mov eax,dword[esi+2] |
2711 | je @f |
2684 | ; cmp eax,[fsize] |
2712 | xor eax,eax |
- | |
2713 | ret |
2685 | ; jne .exit |
2714 | @@: |
2686 | |
Line 2715... | Line 2687... | ||
2715 | add eax,esi |
2687 | add eax,esi |
2716 | mov [EndFile],eax ; |
2688 | mov [EndFile],eax ; |
Line 2757... | Line 2729... | ||
2757 | 2729 | ||
Line 2758... | Line 2730... | ||
2758 | mov edx,ecx |
2730 | mov edx,ecx |
2759 | add esi,8 |
2731 | add esi,8 |
2760 | @@: |
2732 | @@: |
- | 2733 | push edi |
|
- | 2734 | mov edi,[points_ptr] |
|
- | 2735 | push dword[esi+4] |
|
- | 2736 | pop dword[edi+ebx*2+0] |
|
- | 2737 | push dword[esi+8] |
|
- | 2738 | pop dword[edi+ebx*2+4] |
|
- | 2739 | push dword[esi+0] |
|
- | 2740 | pop dword[edi+ebx*2+8] |
|
- | 2741 | pop edi |
|
- | 2742 | ; fld dword[esi+4] |
|
- | 2743 | ; fstp dword[real_points+ebx*2+0] ; x |
|
- | 2744 | ; fld dword[esi+8] |
|
- | 2745 | ; fstp dword[real_points+ebx*2+4] ; y |
|
- | 2746 | ; fld dword[esi+0] |
|
- | 2747 | ; fstp dword[real_points+ebx*2+8] ; z |
|
Line 2761... | Line 2748... | ||
2761 | 2748 | ||
2762 | add ebx,6 |
2749 | add ebx,6 |
2763 | add esi,12 |
2750 | add esi,12 |
2764 | ; dec ecx |
2751 | dec ecx |
2765 | loop @b |
2752 | jnz @b |
- | 2753 | @@: |
|
- | 2754 | ; mov dword[points+ebx],-1 |
|
- | 2755 | push edi |
|
- | 2756 | mov edi,[points_ptr] |
|
2766 | @@: |
2757 | mov dword[edi+ebx*2],-1 ; end mark (not always in use) |
2767 | 2758 | pop edi |
|
2768 | @@: |
2759 | @@: |
2769 | cmp [esi],word 4120h |
2760 | cmp [esi],word 4120h |
2770 | je @f |
2761 | je @f |
2771 | add esi,[esi+2] |
2762 | add esi,[esi+2] |
2772 | jmp @b |
2763 | jmp @b |
2773 | @@: |
2764 | @@: |
2774 | movzx ecx,word[esi+6] |
2765 | movzx ecx,word[esi+6] |
2775 | add [triangles_count_var],cx |
2766 | add [triangles_count_var],cx |
2776 | add esi,8 |
- | |
- | 2767 | add esi,8 |
|
2777 | 2768 | ;mov edi,triangles |
|
- | 2769 | @@: |
|
- | 2770 | movsd |
|
- | 2771 | movsw |
|
- | 2772 | add word[edi-6],bp |
|
- | 2773 | add word[edi-4],bp |
|
2778 | @@: |
2774 | add word[edi-2],bp |
2779 | add esi,8 |
2775 | add esi,2 |
2780 | dec ecx |
2776 | dec ecx |
2781 | jnz @b |
- | |
2782 | ; xor ecx,ecx |
2777 | jnz @b |
2783 | add ebp,edx |
2778 | add ebp,edx |
2784 | jmp .find4k |
2779 | jmp .find4k |
2785 | mov eax,-1 ;<---mark if OK |
2780 | mov eax,-1 ;<---mark if OK |
- | 2781 | .exit: |
|
2786 | .exit: |
2782 | mov dword[edi],-1 |
Line 2787... | Line 2783... | ||
2787 | ret |
2783 | ret |
2788 | 2784 | ||
2789 | if USE_LFN |
2785 | if USE_LFN |
Line 2804... | Line 2800... | ||
2804 | mov edx,[triangles_ptr] |
2800 | mov edx,[triangles_ptr] |
2805 | int 0x40 ; -> allocate memory to triangles |
2801 | int 0x40 ; -> allocate memory to triangles |
2806 | mov [triangles_ptr], eax ; -> eax = pointer to allocated mem |
2802 | mov [triangles_ptr], eax ; -> eax = pointer to allocated mem |
2807 | 2803 | ||
Line 2808... | Line 2804... | ||
2808 | mov eax, 68 |
2804 | ; mov eax, 68 |
2809 | movzx ecx, [triangles_count_var] |
2805 | ; movzx ecx, [triangles_count_var] |
2810 | inc ecx |
2806 | ; inc ecx |
2811 | mov edx,[edges_ptr] |
2807 | ; mov edx,[edges_ptr] |
2812 | int 0x40 ; -> allocate memory to edges |
2808 | ; int 0x40 ; -> allocate memory to edges |
2813 | mov [edges_ptr], eax ; -> eax = pointer to allocated mem |
2809 | ; mov [edges_ptr], eax ; -> eax = pointer to allocated mem |
2814 | 2810 | ||
2815 | mov eax,-1 ; fill edges list |
2811 | ; mov eax,-1 ; fill edges list |
2816 | movzx ecx,[triangles_count_var] ; importand if object generated |
2812 | ; movzx ecx,[triangles_count_var] ; importand if object generated |
2817 | shr ecx,2 |
2813 | ; shr ecx,2 |
2818 | inc ecx |
2814 | ; inc ecx |
2819 | mov edi,[edges_ptr] |
2815 | ; mov edi,[edges_ptr] |
2820 | cld |
2816 | ; cld |
2821 | rep stosd |
2817 | ; rep stosd |
Line 2822... | Line 2818... | ||
2822 | 2818 | ||
2823 | 2819 | ||
2824 | ; mov eax, 68 |
2820 | ; mov eax, 68 |