Rev 2736 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2736 | Rev 2881 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ; application : View3ds ver. 0.061 - tiny .3ds files viewer. |
1 | ; application : View3ds ver. 0.062 - 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 33... | Line 33... | ||
33 | NON = 0 ; -/ \- |
33 | NON = 0 ; -/ \- |
34 | MMX = 1 |
34 | MMX = 1 |
35 | SSE = 2 |
35 | SSE = 2 |
36 | SSE2 = 3 |
36 | SSE2 = 3 |
37 | Ext = SSE2 ;Ext={ NON | MMX | SSE | SSE2 } |
37 | Ext = SSE2 ;Ext={ NON | MMX | SSE | SSE2 } |
38 | 38 | ||
Line 39... | Line 39... | ||
39 | ; 0 for short names (Menuet-compatible), 1 for long names (Kolibri features) |
39 | ; 0 for short names (Menuet-compatible), 1 for long names (Kolibri features) |
40 | USE_LFN = 1 |
40 | USE_LFN = 1 |
Line 41... | Line 41... | ||
41 | 41 | ||
Line 663... | Line 663... | ||
663 | mov esi,10 ; text length |
663 | mov esi,10 ; text length |
664 | int 40h |
664 | int 40h |
665 | 665 | ||
Line -... | Line 666... | ||
- | 666 | ||
- | 667 | ; addsubps xmm0,xmm0 |
|
Line 666... | Line 668... | ||
666 | 668 | ||
Line 667... | Line 669... | ||
667 | 669 | ||
668 | jmp still |
670 | jmp still |
Line 674... | Line 676... | ||
674 | include "FLAT_CAT.INC" |
676 | include "FLAT_CAT.INC" |
675 | include "TEX_CAT.INC" |
677 | include "TEX_CAT.INC" |
676 | include "BUMP_CAT.INC" |
678 | include "BUMP_CAT.INC" |
677 | include "3DMATH.INC" |
679 | include "3DMATH.INC" |
678 | include "GRD3.INC" |
680 | include "GRD_LINE.INC" |
- | 681 | include "GRD3.INC" |
|
679 | include "FLAT3.INC" |
682 | include "FLAT3.INC" |
680 | include "BUMP3.INC" |
683 | include "BUMP3.INC" |
681 | include "B_PROCS.INC" |
684 | include "B_PROCS.INC" |
682 | include "A_PROCS.INC" |
685 | include "A_PROCS.INC" |
683 | include "GRD_CAT.INC" |
686 | include "GRD_CAT.INC" |
Line 685... | Line 688... | ||
685 | include "GRD_TEX.INC" |
688 | include "GRD_TEX.INC" |
686 | include "TWO_TEX.INC" |
689 | include "TWO_TEX.INC" |
687 | 690 | ||
Line -... | Line 691... | ||
- | 691 | ||
688 | 692 | ||
689 | alloc_buffer_mem: |
693 | alloc_buffer_mem: |
690 | movzx ecx,[size_x] |
694 | movzx ecx,[size_x] |
691 | movzx eax,[size_y] |
695 | movzx eax,[size_y] |
692 | mul ecx |
696 | mul ecx |
Line 1583... | Line 1587... | ||
1583 | 1587 | ||
Line 1584... | Line 1588... | ||
1584 | 1588 | ||
1585 | draw_triangles: |
1589 | draw_triangles: |
- | 1590 | mov esi,[triangles_ptr] |
|
1586 | mov esi,[triangles_ptr] |
1591 | mov [edges_counter],0 |
1587 | .again_dts: |
1592 | .again_dts: |
1588 | mov ebp,[points_translated_ptr] |
1593 | mov ebp,[points_translated_ptr] |
1589 | if Ext=NON |
1594 | if Ext=NON |
1590 | movzx eax,word[esi] |
1595 | movzx eax,word[esi] |
Line 1688... | Line 1693... | ||
1688 | cmp [dr_flag],9 |
1693 | cmp [dr_flag],9 |
1689 | je .bump_tex |
1694 | je .bump_tex |
1690 | cmp [dr_flag],10 |
1695 | cmp [dr_flag],10 |
1691 | je .cubic_env_mapping |
1696 | je .cubic_env_mapping |
1692 | ; **************** |
1697 | cmp [dr_flag],11 |
- | 1698 | je .draw_smooth_line |
|
- | 1699 | ; **************** |
|
1693 | mov esi,point_index3 ; do Gouraud shading |
1700 | mov esi,point_index3 ; do Gouraud shading |
1694 | mov ecx,3 |
1701 | mov ecx,3 |
1695 | .again_grd_draw: |
1702 | .again_grd_draw: |
1696 | movzx eax,word[esi] |
1703 | movzx eax,word[esi] |
1697 | shl eax,2 |
1704 | shl eax,2 |
Line 2377... | Line 2384... | ||
2377 | mov edx,bumpmap |
2384 | mov edx,bumpmap |
2378 | 2385 | ||
Line 2379... | Line 2386... | ||
2379 | call bump_tex_triangle_z |
2386 | call bump_tex_triangle_z |
Line -... | Line 2387... | ||
- | 2387 | ||
- | 2388 | jmp .end_draw |
|
- | 2389 | ||
- | 2390 | .draw_smooth_line: |
|
- | 2391 | mov esi,point_index3 |
|
- | 2392 | mov ecx,3 |
|
- | 2393 | .again_line_param: |
|
- | 2394 | movzx eax,word[esi] |
|
- | 2395 | shl eax,2 |
|
- | 2396 | lea eax,[eax*3] |
|
- | 2397 | add eax,[points_normals_rot_ptr] |
|
- | 2398 | ; texture ;x=(rotated point normal -> x * 255)+255 |
|
- | 2399 | fld dword[eax] ; x cooficient of normal vector |
|
- | 2400 | fimul [correct_tex] |
|
- | 2401 | fiadd [correct_tex] |
|
- | 2402 | fistp word[esp-2] |
|
- | 2403 | ; texture y=(rotated point normal -> y * 255)+255 |
|
- | 2404 | fld dword[eax+4] ; y cooficient |
|
- | 2405 | fimul [correct_tex] |
|
- | 2406 | fiadd [correct_tex] |
|
- | 2407 | fistp word[esp-4] |
|
- | 2408 | ||
- | 2409 | movzx eax,word[esp-4] |
|
- | 2410 | movzx ebx,word[esp-2] |
|
- | 2411 | shl eax,TEX_SHIFT |
|
- | 2412 | add eax,ebx |
|
- | 2413 | lea eax,[eax*3+color_map] |
|
- | 2414 | mov eax,dword[eax] |
|
- | 2415 | lea ebx,[ecx-1] |
|
- | 2416 | shl ebx,2 |
|
- | 2417 | mov [ebx+col1],eax |
|
- | 2418 | ||
- | 2419 | sub esi,2 |
|
- | 2420 | dec ecx |
|
- | 2421 | jnz .again_line_param |
|
- | 2422 | ||
- | 2423 | mov eax,[edges_ptr] |
|
- | 2424 | add eax,[edges_counter] |
|
- | 2425 | mov bl,[eax] |
|
- | 2426 | test bl,00000001b |
|
- | 2427 | jz @f |
|
- | 2428 | mov edi,screen |
|
- | 2429 | mov esi,[Zbuffer_ptr] |
|
- | 2430 | ||
- | 2431 | mov eax,[col1] |
|
- | 2432 | movzx bx,al |
|
- | 2433 | push bx ; b |
|
- | 2434 | movzx bx,ah |
|
- | 2435 | push bx |
|
- | 2436 | rol eax,16 |
|
- | 2437 | xor ah,ah |
|
- | 2438 | push ax |
|
- | 2439 | push [zz1] |
|
- | 2440 | push [yy1] |
|
- | 2441 | push [xx1] |
|
- | 2442 | ||
- | 2443 | mov eax,[col2] |
|
- | 2444 | movzx bx,al |
|
- | 2445 | push bx ; b |
|
- | 2446 | movzx bx,ah |
|
- | 2447 | push bx |
|
- | 2448 | rol eax,16 |
|
- | 2449 | xor ah,ah |
|
- | 2450 | push ax |
|
- | 2451 | push [zz2] |
|
- | 2452 | push [yy2] |
|
- | 2453 | push [xx2] |
|
- | 2454 | ||
- | 2455 | call smooth_line |
|
- | 2456 | @@: |
|
- | 2457 | mov eax,[edges_ptr] |
|
- | 2458 | add eax,[edges_counter] |
|
- | 2459 | mov bl,[eax] |
|
- | 2460 | test bl,00000010b |
|
- | 2461 | jz @f |
|
- | 2462 | ||
- | 2463 | mov edi,screen |
|
- | 2464 | mov esi,[Zbuffer_ptr] |
|
- | 2465 | ||
- | 2466 | mov eax,[col1] |
|
- | 2467 | movzx bx,al |
|
- | 2468 | push bx ; b |
|
- | 2469 | movzx bx,ah |
|
- | 2470 | push bx |
|
- | 2471 | rol eax,16 |
|
- | 2472 | xor ah,ah |
|
- | 2473 | push ax |
|
- | 2474 | push [zz1] |
|
- | 2475 | push [yy1] |
|
- | 2476 | push [xx1] |
|
- | 2477 | ||
- | 2478 | mov eax,[col3] |
|
- | 2479 | movzx bx,al |
|
- | 2480 | push bx ; b |
|
- | 2481 | movzx bx,ah |
|
- | 2482 | push bx |
|
- | 2483 | rol eax,16 |
|
- | 2484 | xor ah,ah |
|
- | 2485 | push ax |
|
- | 2486 | push [zz3] |
|
- | 2487 | push [yy3] |
|
- | 2488 | push [xx3] |
|
- | 2489 | ||
- | 2490 | call smooth_line |
|
- | 2491 | @@: |
|
- | 2492 | ||
- | 2493 | mov eax,[edges_ptr] |
|
- | 2494 | add eax,[edges_counter] |
|
- | 2495 | mov bl,[eax] |
|
- | 2496 | test bl,00000100b |
|
- | 2497 | jz @f |
|
- | 2498 | ||
- | 2499 | mov edi,screen |
|
- | 2500 | mov esi,[Zbuffer_ptr] |
|
- | 2501 | ||
- | 2502 | mov eax,[col3] |
|
- | 2503 | movzx bx,al |
|
- | 2504 | push bx ; b |
|
- | 2505 | movzx bx,ah |
|
- | 2506 | push bx |
|
- | 2507 | rol eax,16 |
|
- | 2508 | xor ah,ah |
|
- | 2509 | push ax |
|
- | 2510 | push [zz3] |
|
- | 2511 | push [yy3] |
|
- | 2512 | push [xx3] |
|
- | 2513 | ||
- | 2514 | mov eax,[col2] |
|
- | 2515 | movzx bx,al |
|
- | 2516 | push bx ; b |
|
- | 2517 | movzx bx,ah |
|
- | 2518 | push bx |
|
- | 2519 | rol eax,16 |
|
- | 2520 | xor ah,ah |
|
- | 2521 | push ax |
|
- | 2522 | push [zz2] |
|
- | 2523 | push [yy2] |
|
- | 2524 | push [xx2] |
|
- | 2525 | ||
- | 2526 | call smooth_line |
|
- | 2527 | @@: |
|
2380 | 2528 | ||
2381 | .end_draw: |
2529 | .end_draw: |
2382 | pop esi |
2530 | pop esi |
- | 2531 | add esi,6 |
|
2383 | add esi,6 |
2532 | inc [edges_counter] |
2384 | cmp dword[esi],-1 |
2533 | cmp dword[esi],-1 |
2385 | jne .again_dts |
2534 | jne .again_dts |
Line 2417... | Line 2566... | ||
2417 | add eax,esi |
2566 | add eax,esi |
2418 | mov [EndFile],eax ; |
2567 | mov [EndFile],eax ; |
Line 2419... | Line 2568... | ||
2419 | 2568 | ||
- | 2569 | add esi,6 |
|
2420 | add esi,6 |
2570 | mov eax,[edges_ptr] |
2421 | @@: |
2571 | @@: |
2422 | cmp [esi],word 3D3Dh |
2572 | cmp [esi],word 3D3Dh |
2423 | je @f |
2573 | je @f |
2424 | add esi,[esi+2] |
2574 | add esi,[esi+2] |
Line 2501... | Line 2651... | ||
2501 | movsw |
2651 | movsw |
2502 | add word[edi-6],bp |
2652 | add word[edi-6],bp |
2503 | add word[edi-4],bp |
2653 | add word[edi-4],bp |
2504 | add word[edi-2],bp |
2654 | add word[edi-2],bp |
2505 | add esi,2 |
2655 | mov dl,byte[esi] |
- | 2656 | mov [eax],dl |
|
- | 2657 | inc eax |
|
- | 2658 | add esi,2 |
|
2506 | dec ecx |
2659 | dec ecx |
2507 | jnz @b |
2660 | jnz @b |
2508 | add ebp,edx |
2661 | add ebp,edx |
2509 | jmp .find4k |
2662 | jmp .find4k |
2510 | mov eax,-1 ;<---mark if OK |
2663 | mov eax,-1 ;<---mark if OK |
Line 2618... | Line 2771... | ||
2618 | jmp .alloc |
2771 | jmp .alloc |
2619 | @@: |
2772 | @@: |
2620 | mov ebx,20 |
2773 | mov ebx,20 |
2621 | .alloc: |
2774 | .alloc: |
2622 | movzx ecx, [triangles_count_var] |
2775 | |
- | 2776 | movzx ecx, [triangles_count_var] |
|
2623 | inc ecx |
2777 | inc ecx |
2624 | lea ecx, [ecx*3] |
2778 | lea ecx, [ecx*3] |
2625 | add ecx, ecx |
2779 | add ecx, ecx |
2626 | mov edx,[triangles_ptr] |
2780 | mov edx,[triangles_ptr] |
2627 | int 0x40 ; -> allocate memory to triangles |
2781 | int 0x40 ; -> allocate memory to triangles |
2628 | mov [triangles_ptr], eax ; -> eax = pointer to allocated mem |
2782 | mov [triangles_ptr], eax ; -> eax = pointer to allocated mem |
2629 | 2783 | ||
Line -... | Line 2784... | ||
- | 2784 | mov eax, 68 |
|
- | 2785 | movzx ecx, [triangles_count_var] |
|
- | 2786 | inc ecx |
|
- | 2787 | mov edx,[edges_ptr] |
|
- | 2788 | int 0x40 ; -> allocate memory to edges |
|
- | 2789 | mov [edges_ptr], eax ; -> eax = pointer to allocated mem |
|
- | 2790 | ||
- | 2791 | ||
2630 | ; mov eax, 68 |
2792 | ; mov eax, 68 |
2631 | ; mov ebx, 12 |
2793 | ; mov ebx, 12 |
2632 | ; movzx ecx, [triangles_count_var] |
2794 | ; movzx ecx, [triangles_count_var] |
2633 | ; shl ecx, 4 |
2795 | ; shl ecx, 4 |
2634 | ; int 0x40 |
2796 | ; int 0x40 |