Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 8232 → Rev 8231

/programs/demos/3DS/3STENCIL.INC
File deleted
/programs/demos/3DS/VIEW3DS.ASM
1,5 → 1,5
 
; application : View3ds ver. 0.071 - tiny .3ds and .asc files viewer
; application : View3ds ver. 0.070 - tiny .3ds and .asc files viewer
; with a few graphics effects demonstration.
; compiler : FASM
; system : KolibriOS
16,7 → 16,7
; I tried optimizing it a bit, but don't know if it was successful. The objects
; can be:
; 1) Read from a file (*.3DS standard)
; 2) Written in manually (at the end of the code) ; now not exist
; 2) Written in manually (at the end of the code)
 
 
SIZE_X equ 512
37,10 → 37,10
SSE = 2
SSE2 = 3
SSE3 = 4
Ext = SSE3 ;Ext={ NON | MMX | SSE | SSE2 | SSE3 }
Ext = SSE2 ;Ext={ NON | MMX | SSE | SSE2 }
 
; 0 for short names (Menuet-compatible), 1 for long names (Kolibri features)
USE_LFN = 1 ; App is Kolibri only now.
USE_LFN = 1
 
use32
org 0x0
63,7 → 63,6
 
shr ax,2
movzx ebx,ax
movzx ebx,ax
lea ebx,[ebx*3]
push ebx
fninit
76,8 → 75,8
shr ax,1
mov [vect_x],ax
 
; mov eax, 20 shl 16 + 20
mov [x_start],dword 20 shl 16 + 20 ;eax
mov eax, 20 shl 16 + 20
mov [x_start],eax
 
 
call alloc_buffer_mem
132,8 → 131,6
;mov eax,40 ; set events mask
;mov ebx,1100000000000000000000000100111b
;int 0x40
 
 
still:
cmp [edit_flag],1
jne @f
319,8 → 316,7
cmp ah,15
jne @f
cmp [emboss_flag],1
; call init_envmap2
call do_emboss
call init_envmap2
@@:
; cmp ah,17
; jne .next_m
336,8 → 332,8
jne .next_m2
 
mov [re_alloc_flag],1 ; reallocate memory
mov [triangles_count_var],20000
mov [points_count_var],20000
mov [triangles_count_var],1000
mov [points_count_var],1000
call alloc_mem_for_tp
mov [re_alloc_flag],0
 
351,7 → 347,7
@@:
cmp bl,4
jg @f
movzx eax,bl ; eax < - object number
movzx ax,bl ; ax < - object number
call generate_object2
jmp .calc_norm
@@:
614,8 → 610,7
movzx ecx,word[size_y_var]
movzx eax,word[size_x_var]
mul ecx
lea ecx,[eax*4]
 
lea ecx,[eax*3]
if (Ext = MMX)|(Ext = SSE)
mov bh,bl
push bx
673,7 → 668,7
movzx eax,word[size_x_var]
movzx ecx,word[size_y_var]
mul ecx
lea ecx,[eax*4]
lea ecx,[eax*3]
if (Ext = MMX)|(Ext = SSE)
mov bh,bl
push bx
741,7 → 736,7
; mov ecx,SIZE_X shl 16 + SIZE_Y
mov edx,[offset_y] ;5 shl 16 + 25
cmp [dr_flag],12
jge .ff
je .ff
int 0x40
jmp .f
.ff:
780,11 → 775,15
;--------------------------------------------------------------------------------
;-------------------------PROCEDURES---------------------------------------------
;--------------------------------------------------------------------------------
;include "TEX3.INC"
include "FLAT_CAT.INC"
include "TEX_CAT.INC"
include "BUMP_CAT.INC"
include "3DMATH.INC"
include "GRD_LINE.INC"
;include "GRD3.INC"
;include "FLAT3.INC"
;include "BUMP3.INC"
include "B_PROCS.INC"
include "A_PROCS.INC"
include "GRD_CAT.INC"
794,8 → 793,6
include "ASC.INC"
if Ext >= SSE3
include "3R_PHG.INC"
include '3STENCIL.INC'
include '3GLASS.INC'
end if
clear_vertices_index:
mov edi,[vertices_index_ptr]
830,7 → 827,7
lea ebx,[ebx*3]
 
cmp [dr_flag],12
jl @f
jne @f
add ebx,[esp]
@@:
add esp,4
949,13 → 946,9
shl edi,2
add edi,[points_ptr]
lea esi,[.points_rotated]
mov ecx,3
cld
movsd
movsd
movsd
; mov ecx,3
; cld
; rep movsd
rep movsd
 
 
mov dword[edit_end_x],0
989,6 → 982,7
mov ebx,20
mov edx,[screen_ptr]
int 0x40
; and eax,0xfffffff0
mov [screen_ptr],eax
 
mov ecx,[.temp]
998,6 → 992,7
mov ebx,20
mov edx,[Zbuffer_ptr]
int 0x40
; and eax,0xfffffff0
mov [Zbuffer_ptr],eax
 
 
1008,6 → 1003,7
mov ebx,20
mov edx,[vertices_index_ptr]
int 0x40
; and eax,0xfffffff0
mov [vertices_index_ptr],eax
 
mov esp,ebp
1421,78 → 1417,7
mov esp,ebp
pop ebp
ret
if Ext >= SSE3
init_point_normals:
.z equ dword [ebp-8]
.y equ dword [ebp-12]
.x equ [ebp-16]
.point_number equ dword [ebp-28]
.hit_faces equ dword [ebp-32]
 
fninit
push ebp
mov ebp,esp
sub esp,64
and ebp,-16
mov edi,[points_normals_ptr]
mov .point_number,0
.ipn_loop:
movd xmm0,.point_number
pshufd xmm0,xmm0,0
mov .hit_faces,0
mov .x,dword 0
mov .y,0
mov .z,0
mov esi,[triangles_ptr]
xor ecx,ecx ; ecx - triangle number
.ipn_check_face:
movdqu xmm1,[esi]
pcmpeqd xmm1,xmm0
pmovmskb eax,xmm1
and eax,0xfff
or eax,eax
jz .ipn_next_face
push esi
mov esi,ecx
lea esi,[esi*3]
shl esi,2
add esi,[triangles_normals_ptr]
movups xmm7,[esi]
addps xmm7,.x
movaps .x,xmm7
pop esi
inc .hit_faces
 
.ipn_next_face:
add esi,12
inc ecx
cmp ecx,[triangles_count_var]
jne .ipn_check_face
cvtsi2ss xmm6,.hit_faces
movaps xmm7,.x
rcpss xmm6,xmm6
shufps xmm6,xmm6,11000000b
mulps xmm7,xmm6
movaps xmm6,xmm7
mulps xmm6,xmm6
andps xmm6,[zero_hgst_dd]
haddps xmm6,xmm6
haddps xmm6,xmm6
rsqrtps xmm6,xmm6
mulps xmm7,xmm6
movlps [edi],xmm7
movhlps xmm7,xmm7
movss [edi+8],xmm7
add edi,12
inc .point_number
mov edx,.point_number
cmp edx,[points_count_var]
jne .ipn_loop
 
add esp,64
pop ebp
ret
else
init_point_normals:
.x equ dword [ebp-4]
.y equ dword [ebp-8]
1566,7 → 1491,7
mov esp,ebp
ret
;===============================================================
end if
 
init_triangles_normals2:
mov ebx,[triangles_normals_ptr]
mov ebp,[triangles_ptr]
1702,68 → 1627,11
paddw mm1,mm0
movd dword[eax],mm1
@@:
if Ext >= SSE3
cmp [dr_flag],13
jne .no_stencil
mov esi,[triangles_ptr]
mov ecx,[triangles_count_var]
@@:
push esi
push ecx
 
mov eax,[esi]
mov ebx,[esi+4]
mov ecx,[esi+8]
imul eax,[i12]
imul ebx,[i12]
imul ecx,[i12]
add eax,[points_rotated_ptr]
add ebx,[points_rotated_ptr]
add ecx,[points_rotated_ptr]
push dword[ecx+8]
push dword[ebx+8]
push dword[eax+8]
movups xmm0,[esp]
add esp,12
andps xmm0,[zero_hgst_dd]
 
 
mov eax,[esi]
mov ebx,[esi+4]
mov ecx,[esi+8]
shl eax,1
shl ebx,1
shl ecx,1
lea eax,[eax*3]
lea ebx,[ebx*3]
lea ecx,[ecx*3]
add eax,[points_translated_ptr]
add ebx,[points_translated_ptr]
add ecx,[points_translated_ptr]
mov eax,[eax]
mov ebx,[ebx]
mov ecx,[ecx]
ror eax,16
ror ebx,16
ror ecx,16
 
 
mov esi,[Zbuffer_ptr]
 
call stencil_tri
 
pop ecx
pop esi
add esi,12
dec ecx
jnz @b
 
.no_stencil:
end if
 
 
 
mov esi,[triangles_ptr]
mov [edges_counter],0
mov ecx,[triangles_count_var]
.again_dts:
push ecx
1876,7 → 1744,6
 
.no_edit:
end if
 
push esi ;
fninit ; DO culling AT FIRST
cmp [culling_flag],1 ; (if culling_flag = 1)
1923,8 → 1790,6
if Ext >= SSE3
cmp [dr_flag],12
je .r_phg
cmp [dr_flag],13
je .glass
end if ; ****************
mov esi,point_index3 ; do Gouraud shading
mov ecx,3
1937,16 → 1802,15
fld dword[eax] ; x cooficient of normal vector
fimul [correct_tex]
fiadd [correct_tex]
fistp [temp1]
fistp word[esp-2]
; texture y=(rotated point normal -> y * 255)+255
fld dword[eax+4] ; y cooficient
fimul [correct_tex]
fiadd [correct_tex]
fistp [temp2]
fistp word[esp-4]
 
mov eax,[temp2]
mov ebx,[temp1]
and ebx,0xfffffff
movzx eax,word[esp-4]
movzx ebx,word[esp-2]
shl eax,TEX_SHIFT
add eax,ebx
lea eax,[eax*3+color_map]
2009,8 → 1873,8
; push [temp_col]
; push [temp_col]
.rainbow:
; cmp [catmull_flag],1 ; put on stack z coordinate if necessary
; jne @f
cmp [catmull_flag],1 ; put on stack z coordinate if necessary
jne @f
push [zz3]
@@:
mov eax,dword[yy3]
2019,15 → 1883,19
push eax
neg al
push ax
; cmp [catmull_flag],1
; jne @f
push [zz2]
 
; @@:
mov eax,dword[yy2]
and eax,ebx
push eax
neg al
push ax
; cmp [catmull_flag],1
; jne @f
push [zz1]
 
; @@:
mov eax,dword[yy1]
and eax,ebx
push eax
2041,12 → 1909,17
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
; cmp [catmull_flag],0
; je @f
mov esi,[Zbuffer_ptr]
call gouraud_triangle_z
; jmp .end_draw
; @@:
; call gouraud_triangle
jmp .end_draw
 
.flat_draw: ;**************************
fninit ; FLAT DRAWING
; FLAT DRAWING
mov eax,[point_index1]
mov ebx,[point_index2]
mov ecx,[point_index3]
2065,7 → 1938,7
fidiv [i3]
fimul [correct_tex]
fiadd [correct_tex]
fistp [temp1] ;dword[esp-4] ; x temp variables
fistp dword[esp-4] ; x temp variables
fld dword[eax+4] ; y cooficient of normal vector
fadd dword[ebx+4]
fadd dword[ecx+4]
2072,13 → 1945,10
fidiv [i3]
fimul [correct_tex]
fiadd [correct_tex]
fistp [temp2] ;dword[esp-8] ; y
mov edx,[temp2] ;dword[esp-8]
and edx,0xfffffff
and [temp1],0xfffffff
fistp dword[esp-8] ; y
mov edx,dword[esp-8]
shl edx,TEX_SHIFT
add edx,[temp1] ;dword[esp-4]
 
add edx,dword[esp-4]
lea eax,[3*edx]
add eax,color_map
mov edx,dword[eax]
2106,7 → 1976,8
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
 
; cmp [catmull_flag],0
; je @f
mov esi,[Zbuffer_ptr]
push word[zz3]
push word[zz2]
2113,12 → 1984,17
push word[zz1]
call flat_triangle_z
jmp .end_draw
 
; @@:
; call draw_triangle
; jmp .end_draw
.env_mapping:
; fninit
; cmp [catmull_flag],0
; je @f
push [zz3]
push [zz2]
push [zz1]
 
; @@:
mov esi,point_index1
sub esp,12
mov edi,esp
2128,6 → 2004,19
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr] ;point_normals_rotated
; #
; fld dword[eax]
; fmul dword[eax+4]
; fld1
; fld1
; faddp
; fmulp
; fimul [correct_tex]
; fiadd [correct_tex]
; fistp word[edi]
; mov word[edi+2],0
;; fistp word[edi+2]
; # last change
; texture x=(rotated point normal -> x * 255)+255
fld dword[eax]
fimul [correct_tex]
2138,7 → 2027,7
fimul [correct_tex]
fiadd [correct_tex]
fistp word[edi+2]
 
; # end of last ch.
add edi,4
add esi,4
loop @b
2151,17 → 2040,24
ror ecx,16
mov edi,[screen_ptr]
mov esi,envmap
; cmp [catmull_flag],0
; je @f
 
mov edx,[Zbuffer_ptr]
call tex_triangle_z
 
; jmp .end_draw
; @@:
; call tex_triangle
jmp .end_draw
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.cubic_env_mapping:
; fninit
; cmp [catmull_flag],0
; je @f
push [zz3]
push [zz2]
push [zz1]
 
; @@:
mov esi,point_index1
sub esp,12
mov edi,esp
2170,8 → 2066,8
mov eax,dword[esi]
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr]
 
add eax,[points_normals_rot_ptr] ;point_normals_rotated
; #
fld dword[eax]
fmul dword[eax+4]
fld1
2207,21 → 2103,27
ror ecx,16
mov edi,[screen_ptr]
mov esi,envmap_cub
; cmp [catmull_flag],0
; je @f
mov edx,[Zbuffer_ptr]
 
call tex_triangle_z
 
; jmp .end_draw
; @@:
; call tex_triangle
jmp .end_draw
 
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
.bump_mapping:
; fninit
; cmp [catmull_flag],0
; je @f
 
push [Zbuffer_ptr]
push [zz3]
push [zz2]
push [zz1]
 
; @@:
mov esi,point_index1
sub esp,12
mov edi,esp
2275,12 → 2177,19
mov esi,envmap
mov edx,bumpmap ;BUMP_MAPPING
 
; cmp [catmull_flag],0
; je @f
call bump_triangle_z
 
; jmp .end_draw
; @@:
; call bump_triangle
jmp .end_draw
 
.tex_mapping:
 
; fninit
; cmp [catmull_flag],0
; je @f
push [zz3]
push [zz2]
push [zz1]
2306,10 → 2215,13
ror ecx,16
mov edi,[screen_ptr]
mov esi,texmap
; cmp [catmull_flag],0
; je @f
mov edx,[Zbuffer_ptr]
 
call tex_triangle_z
 
; jmp .end_draw
; @@:
; call tex_triangle
jmp .end_draw
; .ray:
; grd_triangle according to points index
2371,7 → 2283,7
 
lea edx,[ecx*3]
push word[edx*2+xx1-2] ; zz1 ,2 ,3
fninit
 
mov eax,dword[esi]
shl eax,2
lea eax,[eax*3] ;+point_normals_rotated]
2380,20 → 2292,18
fld dword[eax] ; x cooficient of normal vector
fimul [correct_tex]
fiadd [correct_tex]
fistp [temp1] ;word[ebp-2]
fistp word[ebp-2]
; texture y=(rotated point normal -> y * 255)+255
fld dword[eax+4] ; y cooficient
fimul [correct_tex]
fiadd [correct_tex]
fistp [temp2] ;word[ebp-4]
fistp word[ebp-4]
 
mov eax,[temp2] ;word[ebp-4]
mov ebx,[temp1] ;word[ebp-2]
and ebx,0xfffffff ; some onjects need thid 'and'
movzx eax,word[ebp-4]
movzx ebx,word[ebp-2]
shl eax,TEX_SHIFT
add eax,ebx
lea eax,[eax*3]
add eax,color_map
lea eax,[eax*3+color_map]
mov eax,dword[eax]
 
ror eax,16 ; eax -0xxxrrggbb -> 0xggbbxxrr
2460,13 → 2370,12
fimul [correct_tex]
fiadd [correct_tex]
fistp word[edi]
 
; texture y=(rotated point normal -> y * 255)+255
fld dword[eax+4]
fimul [correct_tex]
fiadd [correct_tex]
fistp word[edi+2]
and word[edi+2],0x7fff ; some objects need it
 
add edi,4
add esi,4
loop @b
2579,16 → 2488,15
fld dword[eax] ; x cooficient of normal vector
fimul [correct_tex]
fiadd [correct_tex]
fistp [temp1] ;word[esp-2]
fistp word[esp-2]
; texture y=(rotated point normal -> y * 255)+255
fld dword[eax+4] ; y cooficient
fimul [correct_tex]
fiadd [correct_tex]
fistp [temp2] ;word[esp-4]
fistp word[esp-4]
 
mov eax,[temp2] ;word[esp-4]
mov ebx,[temp1] ;word[esp-2]
and ebx,0xfffffff
movzx eax,word[esp-4]
movzx ebx,word[esp-2]
shl eax,TEX_SHIFT
add eax,ebx
lea eax,[eax*3+color_map]
2601,6 → 2509,11
dec ecx
jnz .again_line_param
 
; mov eax,[edges_ptr] ; this not works correctly
; add eax,[edges_counter] ; I mean chosing overlapped edges.
; mov bl,[eax] ;
; test bl,00000001b ;
; jz @f ;
mov edi,[screen_ptr]
mov esi,[Zbuffer_ptr]
 
2630,6 → 2543,11
 
call smooth_line
@@:
; mov eax,[edges_ptr] ; this not works correctly
; add eax,[edges_counter]
; mov bl,[eax]
; test bl,00000010b
; jz @f
 
mov edi,[screen_ptr]
mov esi,[Zbuffer_ptr]
2661,6 → 2579,11
call smooth_line
@@:
 
; mov eax,[edges_ptr] ; this not works correctly
; add eax,[edges_counter] ;
; mov bl,[eax] ;
; test bl,00000100b ;
; jz @f ;
 
mov edi,[screen_ptr]
mov esi,[Zbuffer_ptr]
2692,7 → 2615,6
call smooth_line
jmp .end_draw
@@:
 
if Ext >= SSE3
.r_phg:
 
2749,73 → 2671,22
call real_phong_tri_z
 
jmp .end_draw
end if
 
.glass:
 
movd xmm5,[size_y_var]
punpcklwd xmm5,[the_zero]
pshufd xmm5,xmm5,01110011b
 
 
mov eax,[point_index1]
mov ebx,[point_index2]
mov ecx,[point_index3]
imul eax,[i12]
imul ebx,[i12]
imul ecx,[i12]
add eax,[points_normals_rot_ptr]
add ebx,[points_normals_rot_ptr]
add ecx,[points_normals_rot_ptr]
movups xmm0,[eax]
movups xmm1,[ebx]
movups xmm2,[ecx]
andps xmm0,[zero_hgst_dd]
andps xmm1,[zero_hgst_dd]
andps xmm2,[zero_hgst_dd]
xorps xmm3,xmm3
 
mov eax,[point_index1]
mov ebx,[point_index2]
mov ecx,[point_index3]
imul eax,[i12]
imul ebx,[i12]
imul ecx,[i12]
add eax,[points_rotated_ptr]
add ebx,[points_rotated_ptr]
add ecx,[points_rotated_ptr]
push dword[ecx+8]
push dword[ebx+8]
push dword[eax+8]
movups xmm4,[esp]
add esp,12
andps xmm4,[zero_hgst_dd]
 
 
 
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
mov esi,[Zbuffer_ptr]
 
call glass_tri
 
jmp .end_draw
end if
 
 
 
 
.end_draw:
pop esi
add esi,12
 
inc [edges_counter]
pop ecx
sub ecx,1
 
; cmp dword[esi],-1
jnz .again_dts
ret
 
2845,7 → 2716,7
 
movzx eax,word[size_x_var]
cmp [dr_flag],12
jge @f
je @f
lea ebx,[eax*3]
sub ebx,18
add eax,eax
2903,7 → 2774,7
push eax
lea edi,[eax*3]
cmp [dr_flag],12
jl @f
jne @f
add edi,[esp]
@@:
add esp,4
2928,7 → 2799,7
mov word[eax],dx
add eax,2
cmp [dr_flag],12
jl @f
jne @f
add edi,4
loop .do
jmp .ad
3202,6 → 3073,7
mov dword[edi],-1
ret
 
if USE_LFN
alloc_mem_for_tp:
mov eax, 68
cmp [re_alloc_flag],1
3220,6 → 3092,28
int 0x40 ; -> allocate memory to triangles
mov [triangles_ptr], eax ; -> eax = pointer to allocated mem
 
; mov eax, 68
; movzx ecx, [triangles_count_var]
; inc ecx
; mov edx,[edges_ptr]
; int 0x40 ; -> allocate memory to edges
; mov [edges_ptr], eax ; -> eax = pointer to allocated mem
 
; mov eax,-1 ; fill edges list
; movzx ecx,[triangles_count_var] ; importand if object generated
; shr ecx,2
; inc ecx
; mov edi,[edges_ptr]
; cld
; rep stosd
 
 
; mov eax, 68
; mov ebx, 12
; movzx ecx, [triangles_count_var]
; shl ecx, 4
; int 0x40
; mov [triangles_w_z_ptr], eax ; for trainagles_with_z list
; ststic memory
 
mov eax, 68
3230,6 → 3124,12
int 0x40 ; -> allocate memory for triangles normals
mov [triangles_normals_ptr], eax ; -> eax = pointer to allocated mem
 
; mov eax, 68
; movzx ecx,[points_count_var]
; lea ecx,[2+ecx*2]
; mov edx,dword [vertices_index_ptr]
; int 0x40
; mov dword[vertices_index_ptr], eax
 
mov eax, 68
mov ecx, [points_count_var]
3238,8 → 3138,12
mov edx,[points_normals_ptr]
int 0x40
mov [points_normals_ptr], eax
; int3
 
 
; int3
 
 
mov eax, 68
; mov ebx, 12
mov ecx, [points_count_var]
3267,9 → 3171,9
int 0x40
mov [points_translated_ptr], eax
ret
end if
 
 
 
read_from_disk:
if USE_LFN
;-
/programs/demos/3DS/A_PROCS.INC
79,7 → 79,7
 
lea ebx,[eax*3]
cmp [dr_flag],12 ; 32 bit col cause
jl @f
jne @f
add ebx,eax
@@:
mov eax,[esi]
87,7 → 87,7
.skip:
add esi,3
cmp [dr_flag],12
jl @f
jne @f
inc esi
@@:
inc dword .x
107,7 → 107,7
movzx eax,word[size_y_var]
imul ecx,eax
cmp [dr_flag],12
jge @f
je @f
lea ecx,[ecx*3]
shr ecx,2
; mov ecx,SIZE_X*SIZE_Y*3/4
169,7 → 169,7
mov esi,[screen_ptr]
mov edi,[Zbuffer_ptr]
cmp [dr_flag],12
jge @f
je @f
lea ebx,[ebx*3]
jmp .f
@@:
182,7 → 182,7
push eax
.emb:
cmp [dr_flag],12
jge @f
je @f
movlps xmm1,[esi+3]
movhps xmm1,[esi+6]
movlps xmm2,[esi-3]
246,7 → 246,7
mov [edi+4],eax
 
cmp [dr_flag],12
jl @f
jne @f
add esi,2
add ebx,2
add edx,2
264,7 → 264,7
mov edi,[screen_ptr]
mov esi,[Zbuffer_ptr]
cmp [dr_flag],12
jge .e
je .e
@@:
movsd
dec edi
562,6 → 562,8
pop ebp
 
ret
 
 
generate_object3: ; heart
;locals
; counter dw ?
753,5 → 755,3
 
ret
 
 
 
/programs/demos/3DS/B_PROCS.INC
751,7 → 751,7
movzx ecx,word[size_x_var] ;SIZE_X*3/4
 
cmp [dr_flag],12
jge @f
je @f
lea ecx,[ecx*3+1]
shr ecx,2
@@:
764,7 → 764,7
sub ecx,3
imul ecx,ebx
cmp [dr_flag],12 ; 32 bit per pix cause
jge @f
je @f
lea ecx,[ecx*3]
shr ecx,4
lea ebx,[ebx *3]
782,7 → 782,7
sub ecx,ebx
movups xmm1,[ecx]
cmp [dr_flag],12
jge @f
je @f
movups xmm2,[edi-3]
movups xmm3,[edi+3]
jmp .f
803,7 → 803,7
xor eax,eax
movzx ecx,word[size_x_var]
cmp [dr_flag],12
jge @f
je @f
lea ecx,[ecx*3]
shr ecx,2
@@:
/programs/demos/3DS/DATA.INC
13,6 → 13,8
xobs dw 0 ;SIZE_X / 2 ;200 ;observer = camera
yobs dw 0 ;SIZE_Y / 2 ;200 ;coordinates
zobs dw -1000
; size_x dw SIZE_X
; size_y dw SIZE_Y
 
re_alloc_flag db 0
angle_counter dw 0
54,6 → 56,7
vertices_index_ptr dd 0
 
 
; draw_win_at_first db 1
vertex_edit_no dw 0
edit_start_x:
dw 0
73,7 → 76,7
db 3
db 'shd. model'
if Ext >= SSE3
db 14
db 13
else
db 12
end if
266,7 → 269,6
db 'cenv'
db 'grdl'
db 'rphg'
db 'glas'
spd_f:
db 'idle'
db 'full'
277,7 → 279,16
onoff_f:
db 'off '
db 'on '
; light_component_f:
; db 'norm ' ; diffuse |
; db 'min' ; specular | or sth. like this
; db 'max ' ; emmisive |
 
;; color_component_f:
;; db ' r '
;; db ' g '
;; db ' b '
 
blur_f: ; blur, fire
db 'off '
bumps_d_f: db ' 1 '
323,6 → 334,14
db 'y +'
labelyplusend:
 
;navigation_size = $ - labelvector
; db 'set color '
; db 'r -'
; db 'g +'
; db 'b -'
; db 'b +'
; db 'g -'
; db 'r +'
 
labelt:
db 'DEUS CARITAS EST'
338,12 → 357,13
if Ext=SSE3
db ' (SSE3)'
end if
db ' 0.071',0
db ' 0.070',0
labellen:
STRdata db '-1 '
 
all_lights_size dw lightsend-lights
 
if USE_LFN
 
file_info:
dd 0
353,8 → 373,21
fptr dd 0 ;workarea
file_name:
db '/rd/1/3d/house.3ds',0
; db '/tmp0/1/ant.3ds',0
 
else
 
file_info:
dd 0
dd 0
fsize dd 1
dd workarea
dd hash_table
file_name:
db '/rd/1/teapot.3ds',0
end if
 
;I_END:
 
rb 256
 
;=============================================
415,8 → 448,14
times 4 dd 0.0
 
I_END:
if USE_LFN = 0
hash_table rb 4096
SourceFile:
workarea rb 180000
else
SourceFile:
workarea rb 180
end if
EndFile dd ?
align 8
sinbeta dd ?;+32
439,16 → 478,29
col2 dd ?
col3 dd ?
scale dd ? ; help scale variable
 
edges_counter dd ?
;==
triangles_count_var dd ?
points_count_var dd ?
 
; triangles_ptr dd ?
; triangles_w_z_ptr dd ?
; triangles_normals_ptr dd ?
; points_normals_ptr dd ?
; points_normals_rot_ptr dd ?
; points_ptr dd ?
; points_rotated_ptr dd ?
; points_translated_ptr dd ?
; screen_ptr dd ?
; Zbuffer_ptr dd ?
; vertices_index_ptr dd ?
; edit_start_x:
dw ? ; don't change order
; edit_start_y dw ?
; edges_ptr dd ?
size_y_var:
yres_var dw ?
 
dw ?
size_x_var:
xres_var dw ?
dw ?
x_start:
dw ?
y_start:
460,8 → 512,6
point_index2 dd ? ; } don't change order
point_index3 dd ? ;-/
temp_col dw ?
temp1 dd ?
temp2 dd ?
high dd ?
rand_seed dw ?
align 8
481,9 → 531,32
 
align 16
 
if USE_LFN = 0
points:
rw (EndFile-SourceFile)/12*3
points_count = ($-points)/6
triangles:
rw (EndFile-SourceFile)/12*3
triangles_count = ($-triangles)/6
align 16
real_points rd points_count*3 + 1
align 16
rotated_points_r rd points_count*3 + 1
align 16
points_rotated rw points_count*3 + 2 ;means translated
align 16
triangles_normals rb triangles_count * 12 ;
align 16
point_normals rb points_count * 12 ;one 3dvector - triple float dword x,y,z
align 16
point_normals_rotated rb points_count * 12
align 16
triangles_normals_rotated rb triangles_count * 12
 
else
points_count = 180000/6*3
triangles_count = 180000 / 6 ;($-triangles)/6
end if
align 16
label trizdd dword
label trizdq qword
490,6 → 563,9
triangles_with_z rw triangles_count*4 + 2 ; triangles triple dw + z position
align 16
vectors rb 24
;align 16
; points_color rb 6*points_count ; each color as word
; sorted_triangles rw triangles_count*3 + 2
align 16
bumpmap rb TEXTURE_SIZE + 1
align 16
501,7 → 577,7
align 16
texmap rb (TEXTURE_SIZE +1) * 3
align 16
color_map rb (TEXTURE_SIZE +100) * 3
color_map rb (TEXTURE_SIZE +1) * 3
align 16
tex_points rb points_count * 4 ; bump_map and texture coords
; each point word x, word y
/programs/demos/3DS/History.txt
1,12 → 1,3
 
View3ds 0.070 - VII 2020
 
1. Some keys support by Leency.
2. New displaying model - real Phong - real not fake normal vector interpolation,
normalising it and calculating dot product (one for each light).
It requires SSE3. (by me, Maciej Guba)
-----------------------------------------------------------------------------------
 
View3ds 0.069 - May 2020
1. KPacked files support by Leency.
2. 32bit vertices indexes and ability to load whole RAM limited objects.
14,6 → 5,7
3. I switch off painters algotithm mode (depth sorting). In app impelementetion it has
limited vertices count and produce less quality image than Z buffer Catmull algo.
In addition this switch off reduces app size, (by me).
 
-----------------------------------------------------------------------------------
 
View3ds 0.068 - XI 2016
/programs/demos/3DS/README.TXT
1,12 → 1,11
View3ds 0.071 - tiny viewer to .3ds and .asc files with several graphics
View3ds 0.070 - tiny viewer to .3ds and .asc files with several graphics
effects implementation.
 
 
What's new?
1. New displaying model - glass - it's two pass rendering. First pass calculates
Z position of all front pixels, second render image with adding reflective
component of light only for front pixels. Transparent effect by adding with saturation.
2. I removed bug with performing generation object after choosing 'emboss' option.
1. Some keys support by Leency.
2. New displaying model - real Phong - real not fake normal vector interpolation, normalising it and calculating
dot product (one for each light). It requires SSE3. (by me)
 
Buttons description:
1. rotary: choosing rotary axle: x, y, x+y.
40,4 → 39,4
is released apply current position. You may also decrease whole handlers count by enable culling (using
appropriate button) - some back handlers become hidden.
 
Maciej Guba VIII 2020
Maciej Guba VII 2020
/programs/demos/3DS/3DMATH.INC
11,6 → 11,23
;------------------------ edi - pointer to 2nd 3d point ---
;------------------------ ebx - pointer to result vector --
;---------------------- out : none ------------------------
if 0
make_vector:
fninit
fild word[edi+x3d] ;edi+x3d
fisub word[esi+x3d] ;esi+x3d
fstp dword[ebx+vec_x]
 
fild word[edi+y3d]
fisub word[esi+y3d]
fstp dword[ebx+vec_y]
 
fild word[edi+z3d]
fisub word[esi+z3d]
fstp dword[ebx+vec_z]
 
ret
end if
reverse_mx_3x3:
; esi - source matrix
; edi - desired reversed matrix
198,20 → 215,6
;---------------------------- edi - pointer to vector -----
;----------------------- out : none
normalize_vector:
if Ext >= SSE3
movups xmm0,[edi]
andps xmm0,[zero_hgst_dd]
movups xmm1,xmm0
mulps xmm0,xmm0
haddps xmm0,xmm0
haddps xmm0,xmm0
rsqrtps xmm0,xmm0
mulps xmm0,xmm1
movlps [edi],xmm0
movhlps xmm0,xmm0
movss [edi+8],xmm0
else
 
fninit
fld dword [edi+vec_x]
fmul st, st
241,7 → 244,6
fstp dword [edi+vec_y]
fdivr dword [edi+vec_z]
fstp dword [edi+vec_z]
end if
ret
;------------------in: -------------------------
;------------------ esi - pointer to 1st vector
250,16 → 252,6
;------------------ st0 - dot-product
dot_product:
fninit
;if Ext >=SSE3
; movups xmm0,[esi]
; movups xmm1,[edi]
; andps xmm0,[zero_hgst_dd]
; mulps xmm0,xmm1
; haddps xmm0,xmm0
; haddps xmm0,xmm0
; movss [esp-4],xmm0
; fld dword[esp-4]
;else
fld dword [esi+vec_x]
fmul dword [edi+vec_x]
fld dword [esi+vec_y]
268,7 → 260,6
fmul dword [edi+vec_z]
faddp
faddp
;end if
ret
 
; DOS version Coded by Mikolaj Felix aka Majuma