forked from KolibriOS/kolibrios
view3ds 076 by macgub
git-svn-id: svn://kolibrios.org@9512 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
e94c9d2b32
commit
ec81f654c0
@ -245,7 +245,7 @@ ret
|
||||
;---------------------- out : none ------------------------
|
||||
|
||||
make_vector_r:
|
||||
if Ext < SSE2
|
||||
if Ext < SSE
|
||||
fninit
|
||||
fld dword[edi] ;edi+x3d
|
||||
fsub dword[esi] ;esi+x3d
|
||||
@ -297,6 +297,7 @@ cross_product:
|
||||
fstp dword [ebx+vec_z]
|
||||
ret
|
||||
cross_aligned:
|
||||
; params as above cross_p
|
||||
movaps xmm0,[esi]
|
||||
movaps xmm1,[esi]
|
||||
movaps xmm2,[edi]
|
||||
@ -607,6 +608,19 @@ ret
|
||||
;----------------------------------------------
|
||||
; esi - pointer to 3x3 matrix
|
||||
add_scale_to_matrix:
|
||||
if Ext>SSE
|
||||
movss xmm0,[rsscale]
|
||||
shufps xmm0,xmm0,0
|
||||
movups xmm1,[esi]
|
||||
movups xmm2,[esi+16]
|
||||
movss xmm3,[esi+32]
|
||||
mulps xmm1,xmm0
|
||||
mulps xmm2,xmm0
|
||||
mulss xmm3,xmm0
|
||||
movups [esi],xmm1
|
||||
movups [esi+16],xmm2
|
||||
movss [esi+32],xmm3
|
||||
else
|
||||
fninit
|
||||
fld [rsscale]
|
||||
fld dword[esi] ;-----
|
||||
@ -639,14 +653,19 @@ add_scale_to_matrix:
|
||||
fld dword[esi+32]
|
||||
fmulp st1,st
|
||||
fstp dword[esi+32] ;------
|
||||
|
||||
end if
|
||||
ret
|
||||
|
||||
;in esi - offset to 3d points (point as 3 dwords float)
|
||||
; edi - offset to 2d points ( as 3 words integer)
|
||||
; ecx - number of points
|
||||
translate_points: ; just convert into integer; z coord still needed
|
||||
if Ext < SSE
|
||||
fninit
|
||||
else
|
||||
; movaps xmm1,[vect_x]
|
||||
end if
|
||||
|
||||
.again:
|
||||
if 0
|
||||
fld dword[esi+8]
|
||||
@ -676,7 +695,18 @@ translate_points: ; just convert into integer; z coord still needed
|
||||
fiadd [vect_y]
|
||||
fistp word[edi+2]
|
||||
end if
|
||||
; movups xmm0,[esi]
|
||||
if Ext>=SSE
|
||||
movups xmm0,[esi]
|
||||
cvtps2dq xmm0,xmm0
|
||||
packssdw xmm0,xmm0
|
||||
paddw xmm0,[vect_x]
|
||||
movd [edi],xmm0
|
||||
; psrldq xmm0,4
|
||||
; movd eax,xmm0
|
||||
pextrw eax,xmm0,6
|
||||
mov [edi+4],ax
|
||||
else
|
||||
|
||||
; cvtps2dq xmm0,xmm0
|
||||
; packsdw xmm0,xmm0
|
||||
; movq [edi]
|
||||
@ -688,9 +718,12 @@ translate_points: ; just convert into integer; z coord still needed
|
||||
fistp word[edi+2]
|
||||
fld dword[esi+8]
|
||||
fistp word[edi+4]
|
||||
end if
|
||||
|
||||
add esi,12
|
||||
add edi,6
|
||||
dec ecx
|
||||
jnz .again
|
||||
; dec ecx
|
||||
; jnz .again
|
||||
loop .again
|
||||
|
||||
ret
|
||||
|
@ -341,7 +341,6 @@ end if
|
||||
pop ebp
|
||||
|
||||
ret
|
||||
align 16
|
||||
real_phong_line_z:
|
||||
; in:
|
||||
; xmm0 - normal vector 1
|
||||
@ -456,7 +455,7 @@ real_phong_line_z:
|
||||
sub ecx,.lx1
|
||||
movaps xmm0,.n1
|
||||
movss xmm2,.z1
|
||||
align 16
|
||||
|
||||
.ddraw:
|
||||
movss xmm7,xmm2
|
||||
cmpnltss xmm7,dword[esi]
|
||||
|
@ -353,7 +353,7 @@ end if
|
||||
|
||||
|
||||
ret
|
||||
align 16
|
||||
|
||||
ray_shd_l:
|
||||
; in:
|
||||
; xmm0 - normal vector 1
|
||||
@ -392,7 +392,7 @@ ray_shd_l:
|
||||
.dn equ [ebp-96]
|
||||
.dz equ [ebp-100]
|
||||
.y equ [ebp-104]
|
||||
; .cur_tri equ [ebp-108]
|
||||
.startx equ [ebp-108]
|
||||
.cnv equ [ebp-128]
|
||||
.Rlen equ [ebp-128-16]
|
||||
.r1 equ [ebp-128-32]
|
||||
@ -431,6 +431,7 @@ ray_shd_l:
|
||||
movaps .n1,xmm0
|
||||
movaps .n2,xmm1
|
||||
mov .lx1,eax
|
||||
; mov .startx,eax
|
||||
mov .lx2,ebx
|
||||
movlps .z1,xmm3
|
||||
|
||||
@ -546,9 +547,15 @@ end if
|
||||
mov edi,[triangles_ptr]
|
||||
xor ecx,ecx
|
||||
.nx_tri: ; next triangle
|
||||
; mov eax,.lx1
|
||||
; cmp eax,.startx
|
||||
; je @f ; prevent artifact borders on tri
|
||||
; cmp eax,.lx2 ; NOT work as I want !!
|
||||
; je @f
|
||||
|
||||
cmp ecx,.cur_tri ; prevent self shadowing
|
||||
je .skipp
|
||||
@@:
|
||||
if 0
|
||||
mov edi,ecx
|
||||
imul edi,[i12]
|
||||
|
@ -16,22 +16,22 @@ stencil_tri:
|
||||
.y3 equ [ebp-12]
|
||||
|
||||
.dx12 equ dword[ebp-20]
|
||||
.dx13 equ dword[ebp-24]
|
||||
.dx23 equ dword[ebp-28]
|
||||
.dz12 equ dword[ebp-32]
|
||||
.dz13 equ dword[ebp-36]
|
||||
.dz12 equ dword[ebp-24]
|
||||
.dx13 equ dword[ebp-28]
|
||||
.dz13 equ dword[ebp-32]
|
||||
.dx23 equ dword[ebp-36]
|
||||
.dz23 equ dword[ebp-40]
|
||||
.zz2 equ [ebp-44]
|
||||
.zz1 equ [ebp-48]
|
||||
.z3 equ [ebp-56]
|
||||
.z2 equ [ebp-60]
|
||||
.z1 equ [ebp-64]
|
||||
.s_buff equ [ebp-68]
|
||||
;.s_buff equ [ebp-68]
|
||||
|
||||
push ebp
|
||||
mov ebp,esp
|
||||
sub esp,128
|
||||
and ebp,0xfffffff0
|
||||
; sub esp,128
|
||||
; and ebp,0xfffffff0
|
||||
.sort2:
|
||||
cmp ax,bx
|
||||
jle .sort1
|
||||
@ -44,19 +44,24 @@ stencil_tri:
|
||||
shufps xmm0,xmm0,11011000b
|
||||
jmp .sort2
|
||||
.sort3:
|
||||
mov .y1,eax ; store triangle coordinates in user friendly variables
|
||||
mov .y2,ebx
|
||||
mov .y3,ecx
|
||||
; mov .y1,eax ; store triangle coordinates in user friendly variables
|
||||
; mov .y2,ebx
|
||||
; mov .y3,ecx
|
||||
push eax
|
||||
push ebx
|
||||
push ecx
|
||||
sub esp,60
|
||||
|
||||
|
||||
; mov edx,100.11
|
||||
; movd xmm0,edx
|
||||
; shufps xmm0,xmm0,11100000b
|
||||
|
||||
movaps .z1,xmm0
|
||||
movups .z1,xmm0
|
||||
; mov dword .z1,edx
|
||||
; mov .z2,edx
|
||||
; mov .z3,edx
|
||||
mov .s_buff,esi
|
||||
; mov .s_buff,esi
|
||||
|
||||
mov edx,80008000h ; eax,ebx,ecx are ANDd together into edx which means that
|
||||
and edx,ebx ; if *all* of them are negative a sign flag is raised
|
||||
@ -157,7 +162,7 @@ stencil_tri:
|
||||
; mov edx,0.11
|
||||
; movd xmm0,edx
|
||||
; shufps xmm0,xmm0,11100000b
|
||||
mov esi,.s_buff
|
||||
; mov esi,.s_buff
|
||||
|
||||
call stencil_line
|
||||
|
||||
@ -192,7 +197,7 @@ stencil_tri:
|
||||
sar ebx,ROUND2
|
||||
sar eax,ROUND2
|
||||
movlps xmm0,.zz1
|
||||
mov esi,.s_buff
|
||||
; mov esi,.s_buff
|
||||
|
||||
|
||||
call stencil_line
|
||||
@ -215,7 +220,7 @@ stencil_tri:
|
||||
jl .loop2
|
||||
.loop2_end:
|
||||
|
||||
add esp,128
|
||||
mov esp,ebp
|
||||
pop ebp
|
||||
|
||||
ret
|
||||
@ -312,17 +317,19 @@ stencil_line:
|
||||
sub ecx,.x1
|
||||
movss xmm2,.z1 ; cz
|
||||
.ccalc:
|
||||
movss xmm1,xmm2
|
||||
cmpltss xmm1,dword[esi]
|
||||
movd eax,xmm1
|
||||
cmp eax,-1
|
||||
jnz @f
|
||||
; movss xmm1,xmm2
|
||||
; cmpltss xmm1,dword[esi]
|
||||
; movd eax,xmm1
|
||||
; cmp eax,-1
|
||||
comiss xmm2,[esi]
|
||||
ja @f
|
||||
movss dword[esi],xmm2
|
||||
@@:
|
||||
add esi,4
|
||||
addss xmm2,.dz
|
||||
sub ecx,1
|
||||
jnz .ccalc
|
||||
; sub ecx,1
|
||||
; jnz .ccalc
|
||||
loop .ccalc
|
||||
.l_quit:
|
||||
mov esp,ebp
|
||||
pop ebp
|
||||
|
@ -1,4 +1,63 @@
|
||||
;=============================================================
|
||||
|
||||
remove_dead_tri:
|
||||
; push ebp
|
||||
; mov ebp,esp
|
||||
mov edi,-1
|
||||
movd xmm7,edi
|
||||
pshufd xmm7,xmm7,0
|
||||
|
||||
mov esi,[triangles_ptr]
|
||||
mov ecx,[triangles_count_var]
|
||||
.chck:
|
||||
; jecxz .cop
|
||||
mov eax,[esi]
|
||||
; mov ebx,[esi+4]
|
||||
; mov edx,[esi+8]
|
||||
cmp eax,[esi+4]
|
||||
je .tri_fail
|
||||
cmp eax,[esi+8]
|
||||
je .tri_fail
|
||||
mov eax,[esi+4]
|
||||
cmp eax,[esi+8]
|
||||
je .tri_fail
|
||||
|
||||
; cmp ebx,[esi]
|
||||
; je .tri_fail
|
||||
; cmp ebx,[esi+8]
|
||||
; je .tri_fail
|
||||
; cmp edx,[esi]
|
||||
; je .tri_fail
|
||||
; cmp edx,[esi+4]
|
||||
; je .tri_fail
|
||||
add esi,12
|
||||
loop .chck
|
||||
jmp .cop
|
||||
.tri_fail:
|
||||
movq [esi],xmm7
|
||||
movd [esi+8],xmm7
|
||||
add esi,12
|
||||
loop .chck
|
||||
.cop:
|
||||
mov esi,[triangles_ptr]
|
||||
mov edi,[triangles_ptr]
|
||||
mov ecx,[triangles_count_var]
|
||||
xor edx,edx
|
||||
.cp:
|
||||
cmp [esi],dword -1
|
||||
je @f
|
||||
movdqu xmm0,[esi]
|
||||
movq [edi],xmm0
|
||||
movhlps xmm0,xmm0
|
||||
movd [edi+8],xmm0
|
||||
add edi,12
|
||||
inc edx
|
||||
@@:
|
||||
add esi,12
|
||||
loop .cp
|
||||
mov [triangles_count_var],edx
|
||||
ret
|
||||
;========================================================
|
||||
|
||||
if Ext > SSE2
|
||||
;--------------------------------------------------------------------
|
||||
|
File diff suppressed because it is too large
Load Diff
417
programs/demos/view3ds/chunks.inc
Normal file
417
programs/demos/view3ds/chunks.inc
Normal file
@ -0,0 +1,417 @@
|
||||
;=========================================================================
|
||||
detect_chunks:
|
||||
; make pivot table, sort, remove unused vertices, find chunks...
|
||||
; in - some global variables
|
||||
; out:
|
||||
; ebx - chunks list ptr, every chunk as word
|
||||
; ecx - chunks number
|
||||
; esi - tri_ch ; vertices with triangles list
|
||||
; edi - t_ptr ; pointers to tri_ch list
|
||||
|
||||
push ebp
|
||||
mov ebp,esp
|
||||
sub esp,60
|
||||
|
||||
|
||||
.tri_ch equ dword[ebp-4] ; tri chunks list ptr
|
||||
.chunks equ dword[ebp-8] ; chunks ptreach tri chunk No. as word
|
||||
.endt equ dword[ebp-12] ;
|
||||
.t_ptr equ dword[ebp-16] ; pointers list
|
||||
.tri_ch1 equ dword[ebp-20] ;
|
||||
.up equ dword[ebp-24] ; upload ptr
|
||||
.chmr equ dword[ebp-28] ; bit mark list if tri stored
|
||||
.str equ dword[ebp-32] ; store ptr
|
||||
.ltch1 equ dword[ebp-36] ; end of tri_ch1 ptr
|
||||
.ch_cnt equ dword[ebp-40]
|
||||
.cntt equ dword[ebp-44]
|
||||
.cc equ dword[ebp-48]
|
||||
.lsparam equ dword[ebp-52]
|
||||
.fix_mark equ dword[ebp-56]
|
||||
.endVptr equ dword[ebp-60]
|
||||
|
||||
; some triangles have repeated indices of vertices
|
||||
; check and remove such triangles
|
||||
call remove_dead_tri
|
||||
|
||||
mov ecx,[triangles_count_var]
|
||||
shl ecx,3
|
||||
lea ecx,[ecx*3]
|
||||
add ecx,100
|
||||
mov eax,68
|
||||
mov ebx,12
|
||||
int 0x40
|
||||
mov .tri_ch,eax
|
||||
|
||||
|
||||
mov ecx,[triangles_count_var]
|
||||
imul ecx,[i12]
|
||||
add ecx,32
|
||||
mov eax,68
|
||||
mov ebx,12
|
||||
int 0x40
|
||||
mov .tri_ch1,eax
|
||||
|
||||
mov ecx,[points_count_var]
|
||||
shl ecx,2
|
||||
add ecx,1120
|
||||
mov eax,68
|
||||
mov ebx,12
|
||||
int 0x40
|
||||
mov .t_ptr,eax
|
||||
|
||||
mov ecx,[triangles_count_var]
|
||||
shl ecx,1
|
||||
add ecx,20
|
||||
mov eax,68
|
||||
mov ebx,12
|
||||
int 0x40
|
||||
mov .chunks,eax
|
||||
|
||||
mov ecx,[triangles_count_var]
|
||||
shr ecx,3
|
||||
add ecx,20
|
||||
mov eax,68
|
||||
mov ebx,12
|
||||
int 0x40
|
||||
mov .chmr,eax ; chunks mark if bit is set - tri was used
|
||||
|
||||
mov edi,eax
|
||||
pxor xmm0,xmm0
|
||||
mov ecx,[triangles_count_var]
|
||||
shr ecx,7
|
||||
inc ecx
|
||||
@@:
|
||||
movdqa [edi],xmm0
|
||||
add edi,16
|
||||
loop @b
|
||||
|
||||
|
||||
mov eax,[points_count_var]
|
||||
imul eax,[i12]
|
||||
add eax,[points_ptr]
|
||||
mov .endVptr,eax
|
||||
|
||||
; make pivot table
|
||||
|
||||
mov edi,.tri_ch
|
||||
mov esi,[triangles_ptr]
|
||||
xor ecx,ecx
|
||||
@@:
|
||||
movd xmm1,ecx
|
||||
movq xmm0,[esi]
|
||||
pshufd xmm1,xmm1,0
|
||||
movd xmm2,[esi+8]
|
||||
punpckldq xmm0,xmm1
|
||||
punpckldq xmm2,xmm1
|
||||
movdqu [edi],xmm0
|
||||
movq [edi+16],xmm2
|
||||
add esi,12
|
||||
add edi,24
|
||||
inc ecx
|
||||
cmp ecx,[triangles_count_var]
|
||||
jnz @b
|
||||
|
||||
;sort
|
||||
|
||||
mov ebx,.tri_ch
|
||||
mov ecx,[triangles_count_var]
|
||||
lea ecx,[ecx*3]
|
||||
|
||||
mov esi,ecx
|
||||
shl esi,3
|
||||
add esi,ebx
|
||||
mov .endt,esi
|
||||
|
||||
.ccc: ; ebx - vert index
|
||||
mov eax,[ebx+8] ; ebx+4 - tri index
|
||||
cmp eax,[ebx]
|
||||
jge .g
|
||||
movq xmm0,[ebx+8]
|
||||
push ebx
|
||||
.c:
|
||||
cmp ebx,esi
|
||||
jae .done
|
||||
cmp ebx,.tri_ch
|
||||
jb .done
|
||||
cmp eax,[ebx]
|
||||
jae .done
|
||||
movq xmm7,[ebx]
|
||||
movq [ebx+8],xmm7
|
||||
sub ebx,8
|
||||
jnc .c
|
||||
add ebx,8
|
||||
.done:
|
||||
movq [ebx+8],xmm0
|
||||
.p:
|
||||
pop ebx
|
||||
.g:
|
||||
add ebx,8
|
||||
dec ecx
|
||||
cmp ecx,1
|
||||
jnz .ccc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
mov ecx,[points_count_var]
|
||||
mov esi,.tri_ch
|
||||
dec ecx
|
||||
.ptC:
|
||||
mov eax,[esi]
|
||||
add esi,8
|
||||
.ptCff:
|
||||
cmp esi,.endt
|
||||
jae .dnC
|
||||
cmp eax,[esi]
|
||||
je @f
|
||||
lea ebx,[eax+1]
|
||||
cmp ebx,[esi]
|
||||
jne .movt
|
||||
dec ecx
|
||||
jz .dnC ; check done
|
||||
@@:
|
||||
jmp .ptC
|
||||
|
||||
; jmp .dnC
|
||||
|
||||
.movt:
|
||||
|
||||
movd xmm5,esi
|
||||
movd xmm7,ebx
|
||||
mov edi,[esi]
|
||||
sub edi,ebx
|
||||
movd xmm6,edi
|
||||
|
||||
@@:
|
||||
cmp esi,.endt
|
||||
jnb @f
|
||||
sub [esi],edi ; fix .tri_ch pivot table list
|
||||
add esi,8
|
||||
jmp @b
|
||||
@@:
|
||||
|
||||
|
||||
;shrink vert
|
||||
lea ebx,[ebx*3]
|
||||
shl ebx,2
|
||||
add ebx,[points_ptr]
|
||||
imul edi,[i12]
|
||||
add edi,ebx
|
||||
|
||||
cmp edi,.endVptr ; fix points_r list
|
||||
ja .dnV
|
||||
@@:
|
||||
movq xmm0,[edi]
|
||||
movd xmm1,[edi+8]
|
||||
movq [ebx],xmm0
|
||||
movd [ebx+8],xmm1
|
||||
add edi,12
|
||||
add ebx,12
|
||||
cmp edi,.endVptr ; fix point_r list
|
||||
jna @b
|
||||
|
||||
.dnV:
|
||||
|
||||
; recalc tri all indices above ebx - sub edi
|
||||
push ecx
|
||||
|
||||
mov esi,[triangles_ptr]
|
||||
mov ecx,[triangles_count_var]
|
||||
lea ecx,[ecx*3]
|
||||
movd edi,xmm6
|
||||
movd ebx,xmm7
|
||||
.agT:
|
||||
cmp [esi],ebx
|
||||
jb @f
|
||||
sub [esi],edi
|
||||
@@:
|
||||
add esi,4
|
||||
loop .agT
|
||||
|
||||
pop ecx
|
||||
|
||||
movd esi,xmm5
|
||||
|
||||
sub [points_count_var],edi
|
||||
|
||||
dec ecx
|
||||
|
||||
jmp .ptCff ; again check sth found
|
||||
|
||||
|
||||
.dnC: ; check done
|
||||
|
||||
|
||||
|
||||
.do_ch:
|
||||
|
||||
|
||||
;make t_ptr - table with pointers/adresses
|
||||
|
||||
|
||||
mov ecx,[points_count_var]
|
||||
mov esi,.tri_ch
|
||||
mov edi,.t_ptr
|
||||
mov ebx,ecx
|
||||
|
||||
mov [edi],esi
|
||||
add edi,4
|
||||
dec ecx
|
||||
jz .dn
|
||||
.pt:
|
||||
mov eax,[esi] ; [esi] - vert ind
|
||||
add esi,8
|
||||
cmp eax,[esi] ; [esi+4] - tri ind
|
||||
je @f
|
||||
mov [edi],esi
|
||||
add edi,4
|
||||
dec ecx
|
||||
jz .dn
|
||||
@@:
|
||||
cmp esi,.endt
|
||||
jb .pt
|
||||
|
||||
|
||||
.dn:
|
||||
|
||||
|
||||
; each dword position in .t_ptr list - adress of corresponding
|
||||
; triangles indices, each triangles from such index contains this
|
||||
; vertice
|
||||
|
||||
|
||||
mov eax,[triangles_count_var]
|
||||
mov .cntt,eax ; temp help cnt
|
||||
xor ecx,ecx
|
||||
mov .cc,ecx
|
||||
mov esi,[triangles_ptr]
|
||||
mov edi,.tri_ch1
|
||||
imul eax,[i12]
|
||||
add eax,edi
|
||||
mov .ltch1,eax ; last
|
||||
|
||||
mov .up,esi
|
||||
mov .str,edi
|
||||
.lb1: ; nx chunk
|
||||
cmp edi,.ltch1
|
||||
jnb .endl
|
||||
mov edi,.tri_ch1
|
||||
mov .str,edi
|
||||
mov eax,.cc
|
||||
mov edx,.cc
|
||||
inc .cc
|
||||
cmp edx,[triangles_count_var]
|
||||
jz .endl
|
||||
shr eax,3
|
||||
and edx,111b
|
||||
add eax,.chmr
|
||||
|
||||
xor ebx,ebx
|
||||
bt [eax],edx ; mark
|
||||
jc @f ; tri was stored
|
||||
inc ecx
|
||||
or ebx,1b
|
||||
mov esi,.up
|
||||
movdqu xmm0,[esi]
|
||||
movdqu [edi],xmm0
|
||||
add .str,12
|
||||
@@:
|
||||
add .up,12
|
||||
or ebx,ebx
|
||||
jz .lb1
|
||||
|
||||
.lb2:
|
||||
mov eax,[edi]
|
||||
mov edx,[edi] ; edx - vert ind
|
||||
shl eax,2
|
||||
add eax,.t_ptr
|
||||
mov eax,[eax] ; [eax] - t ptr
|
||||
or eax,eax
|
||||
jz .endl
|
||||
.nxt:
|
||||
|
||||
mov esi,[eax+4]
|
||||
mov ebx,[eax+4]
|
||||
shr esi,3
|
||||
and ebx,111b
|
||||
add esi,.chmr
|
||||
bts [esi],ebx ; mark
|
||||
jc @f ; tri was stored
|
||||
dec .cntt
|
||||
je .endl
|
||||
mov esi,[eax+4] ; [eax+4] - tri ind
|
||||
add esi,esi
|
||||
add esi,.chunks
|
||||
mov [esi],cx
|
||||
mov esi,[eax+4]
|
||||
|
||||
imul esi,[i12]
|
||||
add esi,[triangles_ptr]
|
||||
movups xmm0,[esi]
|
||||
mov esi,.str
|
||||
movups [esi],xmm0
|
||||
add .str,12
|
||||
@@:
|
||||
add eax,8
|
||||
cmp edx,[eax]
|
||||
je .nxt
|
||||
add edi,4
|
||||
|
||||
cmp edi,.str
|
||||
jne .lb2
|
||||
jmp .lb1
|
||||
|
||||
.endl:
|
||||
|
||||
mov .ch_cnt,ecx
|
||||
|
||||
|
||||
.end:
|
||||
|
||||
|
||||
|
||||
; mov eax,68
|
||||
; mov ebx,13
|
||||
; mov ecx,.t_ptr
|
||||
; int 0x40
|
||||
|
||||
; mov eax,68
|
||||
; mov ebx,13
|
||||
; mov ecx,.tri_ch
|
||||
; int 0x40
|
||||
|
||||
mov eax,68
|
||||
mov ebx,13
|
||||
mov ecx,.tri_ch1
|
||||
int 0x40
|
||||
|
||||
mov eax,68
|
||||
mov ebx,13
|
||||
mov ecx,.chmr
|
||||
int 0x40
|
||||
; for now free mem - cunks list - unused
|
||||
|
||||
; mov eax,68
|
||||
; mov ebx,13
|
||||
; mov ecx,.chunks
|
||||
; int 0x40
|
||||
|
||||
|
||||
|
||||
; mov ebx,.chunks
|
||||
mov ecx,.ch_cnt
|
||||
|
||||
mov esi,.tri_ch
|
||||
mov edi,.t_ptr
|
||||
|
||||
|
||||
mov esp,ebp
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
; DATA AREA ************************************
|
||||
if Ext > SSE2
|
||||
; if Ext > SSE2
|
||||
isSSE3 db 1
|
||||
end if
|
||||
; end if
|
||||
i3 dw 3
|
||||
i6 dd 6
|
||||
i12 dd 12
|
||||
@ -28,14 +28,15 @@
|
||||
y_offset dw SIZE_Y / 2
|
||||
z_offset dw 0
|
||||
rsscale dd 175.0 ; next real scale
|
||||
vect_x: dw SIZE_X / 2
|
||||
vect_y dw SIZE_Y / 2
|
||||
vect_z dw 0
|
||||
size_y_var:
|
||||
yres_var dw SIZE_Y
|
||||
|
||||
size_x_var:
|
||||
xres_var dw SIZE_X
|
||||
; vect_x: dw SIZE_X / 2
|
||||
; vect_y dw SIZE_Y / 2
|
||||
; vect_z dw 0
|
||||
; size_y_var:
|
||||
; yres_var dw SIZE_Y
|
||||
;
|
||||
; size_x_var:
|
||||
; xres_var dw SIZE_X
|
||||
|
||||
angle_x dw 0
|
||||
angle_y dw 0
|
||||
@ -64,7 +65,7 @@
|
||||
screen_ptr dd 0
|
||||
Zbuffer_ptr dd 0
|
||||
vertices_index_ptr dd 0
|
||||
vertex_edit_no dw 0
|
||||
vertex_edit_no dd -1
|
||||
edit_start_x:
|
||||
dw 0
|
||||
edit_start_y dw 0
|
||||
@ -86,8 +87,9 @@
|
||||
|
||||
db 3
|
||||
db 'shd. model'
|
||||
max_dr_flg:
|
||||
if Ext >= SSE3
|
||||
max_dr_flg db 15
|
||||
db 15
|
||||
else
|
||||
db 12
|
||||
end if
|
||||
@ -290,6 +292,7 @@ flags: ; flags description
|
||||
db 'x+y '
|
||||
db ' x '
|
||||
db 'keys'
|
||||
|
||||
onoff_f:
|
||||
db 'off '
|
||||
db 'on '
|
||||
@ -354,7 +357,7 @@ base_vector:
|
||||
if Ext=SSE3
|
||||
db ' (SSE3)'
|
||||
end if
|
||||
db ' 0.075',0
|
||||
db ' 0.076',0
|
||||
labellen:
|
||||
STRdata db '-1 '
|
||||
lab_vert:
|
||||
@ -367,6 +370,9 @@ base_vector:
|
||||
db 'Edges count: '
|
||||
lab_ed_end:
|
||||
|
||||
db 'Chunks detected:'
|
||||
|
||||
|
||||
|
||||
all_lights_size dw lightsend-lights
|
||||
|
||||
@ -483,6 +489,17 @@ end if
|
||||
times 4 dd 1.0
|
||||
|
||||
eps: times 4 dd 0.00000
|
||||
|
||||
vect_x: dw SIZE_X / 2
|
||||
vect_y dw SIZE_Y / 2
|
||||
vect_z dw 0
|
||||
size_y_var:
|
||||
yres_var dw SIZE_Y
|
||||
|
||||
size_x_var:
|
||||
xres_var dw SIZE_X
|
||||
|
||||
|
||||
epsone dd 1.0001
|
||||
aprox dd 0.0001
|
||||
epsminus dd -0.0001
|
||||
@ -496,7 +513,7 @@ end if
|
||||
fptr dd 0 ;workarea
|
||||
file_name:
|
||||
db '/rd/1/3d/house.3ds',0
|
||||
; db '/tmp0/1/ant.3ds',0
|
||||
; db '/tmp0/1/sc.3ds',0
|
||||
|
||||
rb 256
|
||||
|
||||
@ -521,7 +538,9 @@ align 8
|
||||
points_count_var dd ? ;
|
||||
triangles_count_var dd ? ; dont change order
|
||||
edges_count dd ? ;
|
||||
chunks_number dd ?
|
||||
tex_points_ptr dd ?
|
||||
chunks_ptr dd ?
|
||||
|
||||
temp_col dw ?
|
||||
high dd ?
|
||||
|
@ -26,22 +26,14 @@ flat_triangle_z:
|
||||
.y3 equ word[ebp-16]
|
||||
|
||||
.dx12 equ dword[ebp-20]
|
||||
;.dz12 equ dword[ebp-24]
|
||||
.dx13 equ dword[ebp-24]
|
||||
.dz13 equ dword[ebp-28]
|
||||
.dz12 equ dword[ebp-32]
|
||||
;.dz13 equ dword[ebp-32]
|
||||
.dz12 equ dword[ebp-24]
|
||||
.dx13 equ dword[ebp-28]
|
||||
.dz13 equ dword[ebp-32]
|
||||
.dx23 equ dword[ebp-36]
|
||||
.dz13M equ [ebp-40]
|
||||
.dz23 equ dword[ebp-44]
|
||||
.zz1 equ dword[ebp-48]
|
||||
.zz2 equ dword[ebp-52]
|
||||
.zz2M equ qword[ebp-52]
|
||||
.dz12M equ qword[ebp-32]
|
||||
.dz23M equ qword[ebp-44]
|
||||
;if Ext>=MMX
|
||||
; emms
|
||||
;end if
|
||||
.dz23 equ dword[ebp-40]
|
||||
.zz1 equ dword[ebp-44]
|
||||
.zz2 equ dword[ebp-48]
|
||||
|
||||
mov ebp,esp
|
||||
|
||||
push edx ; store edx in variable .col
|
||||
@ -87,13 +79,13 @@ flat_triangle_z:
|
||||
; jle @f
|
||||
; jmp .ft_loop2_end
|
||||
;@@:
|
||||
sub esp,52-12
|
||||
; sub esp,52-12
|
||||
|
||||
mov bx,.y2 ; calc delta 12
|
||||
sub bx,.y1
|
||||
jnz .ft_dx12_make
|
||||
mov .dx12,0
|
||||
mov .dz12,0
|
||||
push dword 0
|
||||
push dword 0
|
||||
jmp .ft_dx12_done
|
||||
.ft_dx12_make:
|
||||
mov ax,.x2
|
||||
@ -103,7 +95,7 @@ flat_triangle_z:
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
mov .dx12,eax
|
||||
push eax
|
||||
|
||||
mov ax,.z2
|
||||
sub ax,.z1
|
||||
@ -111,14 +103,13 @@ flat_triangle_z:
|
||||
shl eax,CATMULL_SHIFT
|
||||
cdq
|
||||
idiv ebx
|
||||
mov .dz12,eax
|
||||
push eax
|
||||
.ft_dx12_done:
|
||||
mov bx,.y3 ; calc delta 13
|
||||
sub bx,.y1
|
||||
jnz .ft_dx13_make
|
||||
mov .dx13,0
|
||||
mov .dz13,0
|
||||
mov dword .dz13M,0
|
||||
push dword 0
|
||||
push dword 0
|
||||
jmp .ft_dx13_done
|
||||
.ft_dx13_make:
|
||||
mov ax,.x3
|
||||
@ -128,7 +119,7 @@ flat_triangle_z:
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
mov .dx13,eax
|
||||
push eax
|
||||
|
||||
mov ax,.z3
|
||||
sub ax,.z1
|
||||
@ -136,14 +127,17 @@ flat_triangle_z:
|
||||
shl eax,CATMULL_SHIFT
|
||||
cdq
|
||||
idiv ebx
|
||||
mov .dz13,eax
|
||||
mov dword .dz13M,eax
|
||||
push eax
|
||||
|
||||
.ft_dx13_done:
|
||||
; sub esp,48
|
||||
mov bx,.y3 ; calc delta 23
|
||||
sub bx,.y2
|
||||
jnz .gt_dx23_make
|
||||
mov .dx23,0
|
||||
mov .dz23,0
|
||||
push dword 0
|
||||
push dword 0
|
||||
; mov .dx23,0
|
||||
; mov .dz23,0
|
||||
jmp .gt_dx23_done
|
||||
.gt_dx23_make:
|
||||
mov ax,.x3
|
||||
@ -153,7 +147,7 @@ flat_triangle_z:
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
mov .dx23,eax
|
||||
push eax
|
||||
|
||||
mov ax,.z3
|
||||
sub ax,.z2
|
||||
@ -161,19 +155,18 @@ flat_triangle_z:
|
||||
shl eax,CATMULL_SHIFT
|
||||
cdq
|
||||
idiv ebx
|
||||
mov .dz23,eax
|
||||
push eax
|
||||
; mov .dz23,eax
|
||||
.gt_dx23_done:
|
||||
|
||||
movsx edx,.z1
|
||||
shl edx,CATMULL_SHIFT
|
||||
mov .zz1,edx
|
||||
mov .zz2,edx
|
||||
push edx
|
||||
push edx
|
||||
|
||||
movsx eax,.x1
|
||||
shl eax,ROUND ; eax - x1
|
||||
mov ebx,eax ; ebx - x2
|
||||
;if Ext>=MMX
|
||||
; movq mm0,.zz2M
|
||||
;end if
|
||||
mov cx,.y1
|
||||
cmp cx,.y2
|
||||
jge .ft_loop1_end
|
||||
@ -187,22 +180,15 @@ flat_triangle_z:
|
||||
push bx ; x2
|
||||
sar eax,ROUND
|
||||
push ax ; x1
|
||||
;if Ext>=MMX
|
||||
; sub esp,8
|
||||
; movq [esp],mm0
|
||||
;else
|
||||
push .zz2 ; z2 shl CATMULL_SHIFT
|
||||
push .zz1 ; z1 shl CATMULL_SHIFT
|
||||
;end if
|
||||
|
||||
call flat_line_z
|
||||
|
||||
popad
|
||||
|
||||
add eax,.dx13
|
||||
add ebx,.dx12
|
||||
;if Ext>=MMX
|
||||
; paddd mm0,.dz12M
|
||||
;else
|
||||
|
||||
mov edx,.dz13
|
||||
add .zz1,edx
|
||||
@ -219,13 +205,7 @@ flat_triangle_z:
|
||||
mov .zz2,edx
|
||||
movsx ebx,.x2
|
||||
shl ebx,ROUND
|
||||
;if Ext>=MMX
|
||||
; movq mm0,.zz2M
|
||||
;; push .dz13 ; exchange
|
||||
;; pop .dz12
|
||||
;; push .dz23 ; exchange
|
||||
;; pop .dz13
|
||||
;end if
|
||||
|
||||
mov cx,.y2
|
||||
cmp cx,.y3
|
||||
jge .ft_loop2_end
|
||||
@ -238,32 +218,22 @@ flat_triangle_z:
|
||||
push bx
|
||||
sar eax,ROUND
|
||||
push ax ; x1
|
||||
;if Ext>=MMX
|
||||
; sub esp,8
|
||||
; movq [esp],mm0
|
||||
;else
|
||||
|
||||
push .zz2 ; z2 shl CATMULL_SHIFT
|
||||
push .zz1 ; z1 shl CATMULL_SHIFT
|
||||
;end if
|
||||
|
||||
call flat_line_z
|
||||
|
||||
popad
|
||||
|
||||
add eax,.dx13
|
||||
add ebx,.dx23
|
||||
;if Ext>=MMX
|
||||
; paddd mm0,.dz23M
|
||||
;else
|
||||
|
||||
mov edx,.dz13
|
||||
add .zz1,edx
|
||||
mov edx,.dz23
|
||||
add .zz2,edx
|
||||
|
||||
; mov edx,.dz13
|
||||
; add .zz1,edx
|
||||
; mov edx,.dz12
|
||||
; add .zz2,edx
|
||||
;end if
|
||||
inc cx
|
||||
cmp cx,.y3
|
||||
jl .ft_loop2
|
||||
@ -374,13 +344,15 @@ flat_line_z:
|
||||
; cmovl [edi],eax
|
||||
; cmovl [esi],ebx
|
||||
jge @f
|
||||
stosd
|
||||
dec edi
|
||||
mov dword[esi],ebx
|
||||
jmp .no_skip
|
||||
mov [edi],eax
|
||||
mov [esi],ebx
|
||||
; stosd ; less branches
|
||||
; dec edi
|
||||
; mov dword[esi],ebx
|
||||
; jmp .no_skip
|
||||
@@:
|
||||
add edi,3
|
||||
.no_skip:
|
||||
; .no_skip:
|
||||
add esi,4
|
||||
add ebx,edx
|
||||
loop .ddraw
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,18 @@
|
||||
View3ds 0.075 - XII 2021
|
||||
1. Cusom rotate using keys and mouse scroll support by Leency.
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
View3ds 0.074 - IX 2021
|
||||
1. Fixed emboss bug in grd lines displaying model.
|
||||
2. Grd line exceedes screen problem fix.
|
||||
3. New rendering model - ray casted shadows and appropiate button to
|
||||
set 'on' this option. Note that is non real time model, especially when
|
||||
complex object is computed. I took effort to introduce accelerating
|
||||
structure - AABB (Axis Aligned Bounding Boxes).. but it is disabled
|
||||
|
||||
for now - seems to work incorrect(slow).
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
View3ds 0.073 - may 2021
|
||||
1. I introduced procedure for searching nonredundand edges.
|
||||
2. Writing some info about object: vertices, triangles unique edges
|
||||
|
@ -1,18 +1,33 @@
|
||||
View3ds 0.074 - tiny viewer to .3ds and .asc files with several graphics
|
||||
View3ds 0.076 - tiny viewer to .3ds and .asc files with several graphics
|
||||
effects implementation.
|
||||
|
||||
What's new?
|
||||
1. Fixed emboss bug in grd lines displaying model.
|
||||
2. Grd line exceedes screen problem fix.
|
||||
3. New rendering model - ray casted shadows and appropiate button to
|
||||
set 'on' this option. Note that is non real time model, especially when
|
||||
complex object is computed. I took effort to introduce accelerating
|
||||
structure - AABB (Axis Aligned Bounding Boxes).. but it is disabled
|
||||
for now - seems to work incorrect(slow).
|
||||
1. Detecting manifold chunks procedure based on kind of sorted pivot
|
||||
table. Chunks are counted and this number displayed.
|
||||
2. New calculating normal vectors proc that use some data produced
|
||||
by new chunks routine. Now big object loading is fast. I load object that
|
||||
contains ~500000 vertices, ~700000 faces and ~2000 0000 unique edges
|
||||
in few seconds on i5 2cond gen. Earlier such objects calculating was
|
||||
rather above time limits.
|
||||
3. On http://board.flatassembler.net occasionaly there are some disccusions
|
||||
about optimizing. Some clever people, wich skills and competence I trust,
|
||||
claims - for CPU's manufactured last ~15 years size of code is crucial
|
||||
for speed. (Better utilize CPU cache).
|
||||
So I wrote some 'movsd' mnemonics instead 'mov [edi],sth'; 'loop' instead
|
||||
'dec ecx,jnz sth'. Moreover I come back to init some local varibles
|
||||
by 'push' (flat_cat.inc). I took effort to change divisions to
|
||||
multiplications two_tex.inc (works ok in fpu only Ext = NON mode and
|
||||
of course in Ext = SSE3 mode), grd_tex.inc (single line not parallel
|
||||
muls, whole drawing routine 4 divs instead 27 divisions),
|
||||
bump_tex.inc - 3 divs in SSE2 mode.s See sources for details.
|
||||
4. Editor button allows now editing by vertex all above 65535 vert objects.
|
||||
|
||||
|
||||
|
||||
|
||||
Buttons description:
|
||||
1. rotary: choosing rotary axle: x, y, x+y.
|
||||
1. rotary: choosing rotary axle: x, y, x+y, keys - for object translate
|
||||
using keyboard. .
|
||||
2. shd. model: choosing shading model: flat, grd (smooth), env (spherical
|
||||
environment mapping, bump (bump mapping), tex (texture mapping),
|
||||
pos (position shading depend), dots (app draws only points - nodes of object),
|
||||
@ -46,4 +61,4 @@ Buttons description:
|
||||
decrease whole handlers count by enable culling (using appropriate button) - some
|
||||
back handlers become hidden.
|
||||
|
||||
Maciej Guba IX 2021
|
||||
Maciej Guba XII 2021
|
||||
|
@ -452,7 +452,11 @@ textured_line_z:
|
||||
|
||||
xchg ax,.x2 ; sort params
|
||||
mov .x1,ax
|
||||
if Ext >= MMX
|
||||
if Ext >= SSE2
|
||||
movdqu xmm0,[.tex_x1]
|
||||
pshufd xmm0,xmm0,01001110b
|
||||
movdqu [.tex_x1],xmm0
|
||||
else if Ext >= MMX
|
||||
movq mm0,[.tex_x1]
|
||||
movq mm1,[.tex_x2]
|
||||
movq [.tex_x2],mm0
|
||||
|
@ -5,14 +5,18 @@
|
||||
;TEX_X equ 512
|
||||
;TEX_Y equ 512
|
||||
;TEXTURE_SIZE EQU (512*512)-1
|
||||
|
||||
;TEX_SHIFT EQU 9
|
||||
|
||||
;CATMULL_SHIFT equ 8
|
||||
;TEXTURE_SIZE EQU (TEX_X * TEX_Y)-1
|
||||
;Ext = SSE
|
||||
;SSE = 3
|
||||
CATMULL_SHIFT equ 8
|
||||
TEXTURE_SIZE EQU (TEX_X * TEX_Y)-1
|
||||
|
||||
;SSE3 = 4
|
||||
;SSE2 = 3
|
||||
;SSE = 2
|
||||
;MMX = 1
|
||||
;NON = 0
|
||||
;Ext = NON
|
||||
;use32
|
||||
;------- Big thanks to Majuma (www.majuma.xt.pl) for absolutely great---
|
||||
;------- DOS 13h mode demos --------------------------------------------
|
||||
@ -32,18 +36,18 @@ two_tex_triangle_z:
|
||||
;---------------------- pointer io Z buffer-----
|
||||
;-- Z-buffer - filled with coordinates as dword --------
|
||||
;-- (Z coor. as word) shl CATMULL_SHIFT ----------------
|
||||
.b_x1 equ ebp+4 ; procedure don't save registers !!!
|
||||
.b_y1 equ ebp+6 ; each coordinate as word
|
||||
.b_x2 equ ebp+8
|
||||
.b_y2 equ ebp+10 ; b - first texture
|
||||
.b_x3 equ ebp+12
|
||||
.b_y3 equ ebp+14 ; e - second texture
|
||||
.e_x1 equ ebp+16
|
||||
.e_y1 equ ebp+18
|
||||
.e_x2 equ ebp+20
|
||||
.e_y2 equ ebp+22
|
||||
.e_x3 equ ebp+24
|
||||
.e_y3 equ ebp+26
|
||||
.e_x1 equ ebp+4 ; procedure don't save registers !!!
|
||||
.e_y1 equ ebp+6 ; each coordinate as word
|
||||
.b_x1 equ ebp+8
|
||||
.b_y1 equ ebp+10
|
||||
.e_x2 equ ebp+12
|
||||
.e_y2 equ ebp+14
|
||||
.b_x2 equ ebp+16
|
||||
.b_y2 equ ebp+18 ; b - first texture
|
||||
.e_x3 equ ebp+20
|
||||
.e_y3 equ ebp+22 ; e - second texture
|
||||
.b_x3 equ ebp+24
|
||||
.b_y3 equ ebp+26
|
||||
.z1 equ word[ebp+28]
|
||||
.z2 equ word[ebp+30]
|
||||
.z3 equ word[ebp+32]
|
||||
@ -60,31 +64,31 @@ two_tex_triangle_z:
|
||||
.y3 equ word[ebp-20]
|
||||
|
||||
.dx12 equ dword[ebp-24]
|
||||
.dbx12 equ dword[ebp-28]
|
||||
.dbx12 equ [ebp-28]
|
||||
.dby12 equ dword[ebp-32]
|
||||
.dby12q equ [ebp-32]
|
||||
.dex12 equ dword[ebp-36]
|
||||
.dey12 equ dword[ebp-40]
|
||||
.dey12q equ [ebp-40]
|
||||
.dz12 equ dword[ebp-44]
|
||||
.dz12 equ [ebp-44]
|
||||
|
||||
.dx13 equ dword[ebp-48]
|
||||
.dbx13 equ dword[ebp-52]
|
||||
.dbx13 equ [ebp-52]
|
||||
.dby13 equ dword[ebp-56]
|
||||
.dby13q equ [ebp-56]
|
||||
.dex13 equ dword[ebp-60]
|
||||
.dey13 equ dword[ebp-64]
|
||||
.dey13q equ [ebp-64]
|
||||
.dz13 equ dword[ebp-68]
|
||||
.dz13 equ [ebp-68]
|
||||
|
||||
.dx23 equ dword[ebp-72]
|
||||
.dbx23 equ dword[ebp-76]
|
||||
.dbx23 equ [ebp-76]
|
||||
.dby23 equ dword[ebp-80]
|
||||
.dby23q equ [ebp-80]
|
||||
.dex23 equ dword[ebp-84]
|
||||
.dey23 equ dword[ebp-88]
|
||||
.dey23q equ [ebp-88]
|
||||
.dz23 equ dword[ebp-92]
|
||||
.dz23 equ [ebp-92]
|
||||
|
||||
.cx1 equ dword[ebp-96] ; current variables
|
||||
.cx2 equ dword[ebp-100]
|
||||
@ -138,8 +142,6 @@ two_tex_triangle_z:
|
||||
jmp .sort3
|
||||
.sort2:
|
||||
push eax ebx ecx ; store triangle coords in variables
|
||||
; push ebx
|
||||
; push ecx
|
||||
|
||||
mov edx,80008000h ; eax,ebx,ecx are ANDd together into edx which means that
|
||||
and edx,ebx ; if *all* of them are negative a sign flag is raised
|
||||
@ -159,8 +161,8 @@ two_tex_triangle_z:
|
||||
; jg .loop23_done
|
||||
; cmp .x3,SIZE_X
|
||||
; jg .loop23_done ; {
|
||||
|
||||
|
||||
; sub esp,18*4
|
||||
; pxor xmm7,xmm7
|
||||
mov bx,.y2 ; calc delta 12
|
||||
sub bx,.y1
|
||||
jnz .bt_dx12_make
|
||||
@ -171,142 +173,80 @@ two_tex_triangle_z:
|
||||
loop @b
|
||||
jmp .bt_dx12_done
|
||||
.bt_dx12_make:
|
||||
|
||||
movsx ebx,bx
|
||||
mov eax,1 shl 15
|
||||
cdq
|
||||
idiv ebx
|
||||
mov ebx,eax
|
||||
|
||||
mov ax,.x2
|
||||
sub ax,.x1
|
||||
cwde
|
||||
movsx ebx,bx
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
; mov .dx12,eax
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
push eax
|
||||
; mov .dx12,eax
|
||||
|
||||
if Ext=SSE
|
||||
|
||||
sub esp,16
|
||||
cvtsi2ss xmm3,ebx ;rcps
|
||||
; mov eax,255
|
||||
cvtsi2ss xmm4,[i255d] ;eax
|
||||
divss xmm3,xmm4
|
||||
rcpss xmm3,xmm3
|
||||
; mulss xmm3,xmm4
|
||||
shufps xmm3,xmm3,0
|
||||
|
||||
movd mm0,[.b_x1]
|
||||
movd mm1,[.b_x2]
|
||||
movd mm2,[.e_x1]
|
||||
movd mm3,[.e_x2]
|
||||
; psubsw mm3,mm2
|
||||
; psubsw mm1,mm0
|
||||
pxor mm4,mm4
|
||||
punpcklwd mm0,mm4
|
||||
punpcklwd mm1,mm4
|
||||
punpcklwd mm2,mm4
|
||||
punpcklwd mm3,mm4
|
||||
; pslld mm0,ROUND
|
||||
; pslld mm1,ROUND
|
||||
; pslld mm2,ROUND
|
||||
; pslld mm3,ROUND
|
||||
cvtpi2ps xmm0,mm0
|
||||
movlhps xmm0,xmm0
|
||||
cvtpi2ps xmm0,mm2
|
||||
cvtpi2ps xmm1,mm1
|
||||
movlhps xmm1,xmm1
|
||||
cvtpi2ps xmm1,mm3
|
||||
subps xmm1,xmm0
|
||||
|
||||
; pxor mm4,mm4
|
||||
; movq mm5,mm1
|
||||
; movq mm6,mm1
|
||||
; pcmpeqb mm5,mm4
|
||||
; psubd mm1,mm0
|
||||
; psubd mm3,mm2
|
||||
|
||||
; movq mm0,[.b_x1] ; bx1 by1 bx2 by2
|
||||
; movq mm1,[.e_x1] ; ex1 ey1 ex2 ey2
|
||||
; pxor
|
||||
; punpcklhd mm0,mm1 ; lwd ;
|
||||
; psubw mm1,mm0 ; mm1, mm0
|
||||
; pxor mm2,mm2
|
||||
; pmovmaskb eax,mm1
|
||||
; and eax,10101010b
|
||||
; pcmpgtw mm2,mm1
|
||||
; punpcklwd mm1,mm2
|
||||
; psllw mm0,ROUND
|
||||
; psllw mm1,ROUND
|
||||
; movq mm2,mm0
|
||||
; psrlq mm0,32
|
||||
|
||||
; cvtpi2ps xmm0,mm1
|
||||
; movlhps xmm0,xmm0
|
||||
; cvtpi2ps xmm0,mm3
|
||||
; divps xmm1,xmm3
|
||||
mulps xmm1,xmm3
|
||||
shufps xmm1,xmm1,10110001b
|
||||
cvtps2pi mm0,xmm1 ; mm0 -> 2 delta dwords
|
||||
movhlps xmm1,xmm1
|
||||
cvtps2pi mm1,xmm1
|
||||
movq .dey12q,mm0
|
||||
movq .dby12q,mm1
|
||||
|
||||
; movd .dex12,mm0
|
||||
; psrlq mm0,32
|
||||
; movd .dey12,mm0
|
||||
; movhlps xmm1,xmm1
|
||||
; cvtps2pi mm0,xmm1
|
||||
; movd .dbx12,mm0
|
||||
; psrlq mm0,32
|
||||
; movd .dby12,mm0
|
||||
|
||||
if Ext >= SSE2
|
||||
sub esp,4*4
|
||||
movd xmm0,ebx
|
||||
pshuflw xmm0,xmm0,0
|
||||
movq xmm1,[.e_x1]
|
||||
movq xmm2,[.e_x2]
|
||||
psubw xmm2,xmm1
|
||||
movdqa xmm3,xmm2
|
||||
pmullw xmm2,xmm0
|
||||
pmulhw xmm3,xmm0
|
||||
punpcklwd xmm2,xmm3
|
||||
psrad xmm2,15 - ROUND
|
||||
pshufd xmm2,xmm2,10110001b
|
||||
movdqu .dey12q,xmm2
|
||||
else
|
||||
|
||||
mov ax,word[.b_x2]
|
||||
sub ax,word[.b_x1]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
; mov .dbx12,eax
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
; mov .dbx23,eax
|
||||
push eax
|
||||
|
||||
mov ax,word[.b_y2]
|
||||
sub ax,word[.b_y1]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
; mov .dby12,eax
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
; mov .dbx23,eax
|
||||
push eax
|
||||
|
||||
; mov eax,.dbx12
|
||||
; mov ebx,.dby12
|
||||
; int3
|
||||
|
||||
mov ax,word[.e_x2]
|
||||
sub ax,word[.e_x1]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
; mov .dex12,eax
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
; mov .dbx23,eax
|
||||
push eax
|
||||
|
||||
mov ax,word[.e_y2]
|
||||
sub ax,word[.e_y1]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
; mov .dey12,eax
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
; mov .dbx23,eax
|
||||
push eax
|
||||
end if
|
||||
|
||||
|
||||
end if
|
||||
mov ax,.z2
|
||||
sub ax,.z1
|
||||
cwde
|
||||
shl eax,CATMULL_SHIFT
|
||||
cdq
|
||||
idiv ebx
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
push eax
|
||||
; mov .dz12,eax
|
||||
|
||||
|
||||
.bt_dx12_done:
|
||||
|
||||
mov bx,.y3 ; calc delta13
|
||||
@ -317,107 +257,90 @@ end if
|
||||
@@:
|
||||
push edx ;dword 0
|
||||
loop @b
|
||||
; movq .dbx13,xmm7
|
||||
; movdqu .dz13,xmm7
|
||||
jmp .bt_dx13_done
|
||||
.bt_dx13_make:
|
||||
; sub esp,6*4
|
||||
|
||||
movsx ebx,bx
|
||||
mov eax,1 shl 15
|
||||
cdq
|
||||
idiv ebx
|
||||
; push eax
|
||||
mov ebx,eax
|
||||
|
||||
|
||||
mov ax,.x3
|
||||
sub ax,.x1
|
||||
cwde
|
||||
movsx ebx,bx
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
; mov .dx13,eax
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
push eax
|
||||
|
||||
if Ext=SSE
|
||||
|
||||
cvtsi2ss xmm3,ebx
|
||||
; mov eax,255
|
||||
cvtsi2ss xmm4,[i255d]
|
||||
divss xmm3,xmm4
|
||||
rcpss xmm3,xmm3
|
||||
; mulss xmm3,xmm4
|
||||
shufps xmm3,xmm3,0
|
||||
sub esp,16
|
||||
|
||||
movd mm0,[.b_x1]
|
||||
movd mm1,[.b_x3]
|
||||
movd mm2,[.e_x1]
|
||||
movd mm3,[.e_x3]
|
||||
|
||||
pxor mm4,mm4
|
||||
punpcklwd mm0,mm4
|
||||
punpcklwd mm1,mm4
|
||||
punpcklwd mm2,mm4
|
||||
punpcklwd mm3,mm4
|
||||
|
||||
cvtpi2ps xmm0,mm0
|
||||
movlhps xmm0,xmm0
|
||||
cvtpi2ps xmm0,mm2
|
||||
cvtpi2ps xmm1,mm1
|
||||
movlhps xmm1,xmm1
|
||||
cvtpi2ps xmm1,mm3
|
||||
subps xmm1,xmm0
|
||||
|
||||
; divps xmm1,xmm3
|
||||
mulps xmm1,xmm3
|
||||
shufps xmm1,xmm1,10110001b
|
||||
cvtps2pi mm0,xmm1 ; mm0 -> 2 delta dwords
|
||||
movhlps xmm1,xmm1
|
||||
cvtps2pi mm1,xmm1
|
||||
movq .dey13q,mm0
|
||||
movq .dby13q,mm1
|
||||
|
||||
; mov .dx13,eax
|
||||
if 1
|
||||
sub esp,4*4
|
||||
movd xmm0,ebx
|
||||
pshuflw xmm0,xmm0,0
|
||||
movq xmm1,[.e_x1]
|
||||
movq xmm2,[.e_x3]
|
||||
psubw xmm2,xmm1
|
||||
movdqa xmm3,xmm2
|
||||
pmullw xmm2,xmm0
|
||||
pmulhw xmm3,xmm0
|
||||
punpcklwd xmm2,xmm3
|
||||
psrad xmm2,15 - ROUND
|
||||
pshufd xmm2,xmm2,10110001b
|
||||
movdqu .dey13q,xmm2
|
||||
; punpcklwd xmm4,xmm5
|
||||
; psrad xmm4,15 - ROUND
|
||||
; movq .tex_dx12,xmm4
|
||||
else
|
||||
|
||||
mov ax,word[.b_x3]
|
||||
sub ax,word[.b_x1]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
; mov .dbx13,eax
|
||||
; shl eax,ROUND
|
||||
; cdq
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
; mov .dbx23,eax
|
||||
push eax
|
||||
|
||||
mov ax,word[.b_y3]
|
||||
sub ax,word[.b_y1]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
; mov .dby13,eax
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
; mov .dbx23,eax
|
||||
push eax
|
||||
|
||||
mov ax,word[.e_x3]
|
||||
sub ax,word[.e_x1]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
; mov .dex13,eax
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
; mov .dbx23,eax
|
||||
push eax
|
||||
|
||||
mov ax,word[.e_y3]
|
||||
sub ax,word[.e_y1]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
; mov .dey13,eax
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
; mov .dbx23,eax
|
||||
push eax
|
||||
|
||||
end if
|
||||
|
||||
end if
|
||||
mov ax,.z3
|
||||
sub ax,.z1
|
||||
cwde
|
||||
shl eax,CATMULL_SHIFT
|
||||
cdq
|
||||
idiv ebx
|
||||
; mov .dz13,eax
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
push eax
|
||||
; mov .dz13,eax
|
||||
|
||||
.bt_dx13_done:
|
||||
|
||||
|
||||
mov bx,.y3 ; calc delta23
|
||||
sub bx,.y2
|
||||
jnz .bt_dx23_make
|
||||
@ -426,108 +349,113 @@ end if
|
||||
@@:
|
||||
push edx ;dword 0
|
||||
loop @b
|
||||
; movq .dbx23,xmm7
|
||||
; movdqu .dz23,xmm7
|
||||
|
||||
jmp .bt_dx23_done
|
||||
.bt_dx23_make:
|
||||
|
||||
|
||||
movsx ebx,bx
|
||||
mov eax,1 shl 15
|
||||
cdq
|
||||
idiv ebx
|
||||
; push eax
|
||||
mov ebx,eax
|
||||
|
||||
|
||||
mov ax,.x3
|
||||
sub ax,.x2
|
||||
cwde
|
||||
movsx ebx,bx
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
; mov .dx23,eax
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
push eax
|
||||
; mov .dx23,eax
|
||||
|
||||
if Ext=SSE
|
||||
|
||||
cvtsi2ss xmm3,ebx
|
||||
; mov eax,255
|
||||
cvtsi2ss xmm4,[i255d] ;eax
|
||||
divss xmm3,xmm4
|
||||
shufps xmm3,xmm3,0
|
||||
sub esp,16
|
||||
|
||||
movd mm0,[.b_x2]
|
||||
movd mm1,[.b_x3]
|
||||
movd mm2,[.e_x2]
|
||||
movd mm3,[.e_x3]
|
||||
|
||||
pxor mm4,mm4
|
||||
punpcklwd mm0,mm4
|
||||
punpcklwd mm1,mm4
|
||||
punpcklwd mm2,mm4
|
||||
punpcklwd mm3,mm4
|
||||
|
||||
cvtpi2ps xmm0,mm0
|
||||
movlhps xmm0,xmm0
|
||||
cvtpi2ps xmm0,mm2
|
||||
cvtpi2ps xmm1,mm1
|
||||
movlhps xmm1,xmm1
|
||||
cvtpi2ps xmm1,mm3
|
||||
subps xmm1,xmm0
|
||||
|
||||
divps xmm1,xmm3
|
||||
shufps xmm1,xmm1,10110001b
|
||||
cvtps2pi mm0,xmm1 ; mm0 -> 2 delta dwords
|
||||
movhlps xmm1,xmm1
|
||||
cvtps2pi mm1,xmm1
|
||||
movq .dey23q,mm0
|
||||
movq .dby23q,mm1
|
||||
|
||||
if Ext >= SSE2
|
||||
sub esp,4*4
|
||||
movd xmm0,ebx
|
||||
pshuflw xmm0,xmm0,0
|
||||
movq xmm1,[.e_x2]
|
||||
movq xmm2,[.e_x3]
|
||||
psubw xmm2,xmm1
|
||||
movdqa xmm3,xmm2
|
||||
pmullw xmm2,xmm0
|
||||
pmulhw xmm3,xmm0
|
||||
punpcklwd xmm2,xmm3
|
||||
psrad xmm2,15 - ROUND
|
||||
pshufd xmm2,xmm2,10110001b
|
||||
movdqu .dey23q,xmm2
|
||||
else
|
||||
|
||||
mov ax,word[.b_x3]
|
||||
sub ax,word[.b_x2]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
; shl eax,ROUND
|
||||
; cdq
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
; mov .dbx23,eax
|
||||
push eax
|
||||
|
||||
mov ax,word[.b_y3]
|
||||
sub ax,word[.b_y2]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
; mov .dby23,eax
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
; mov .dbx23,eax
|
||||
push eax
|
||||
|
||||
mov ax,word[.e_x3]
|
||||
sub ax,word[.e_x2]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
; mov .dex23,eax
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
; mov .dbx23,eax
|
||||
push eax
|
||||
|
||||
mov ax,word[.e_y3]
|
||||
sub ax,word[.e_y2]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
; mov .dey23,eax
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
; mov .dbx23,eax
|
||||
push eax
|
||||
end if
|
||||
|
||||
|
||||
mov ax,.z3
|
||||
sub ax,.z2
|
||||
cwde
|
||||
shl eax,CATMULL_SHIFT
|
||||
cdq
|
||||
idiv ebx
|
||||
; mov .dz23,eax
|
||||
imul ebx
|
||||
sar eax,15 - ROUND
|
||||
push eax
|
||||
; sub esp,40
|
||||
; mov .dz23,eax
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.bt_dx23_done:
|
||||
|
||||
movsx eax,.x1
|
||||
shl eax,ROUND
|
||||
; mov .cx1,eax
|
||||
; mov .cx2,eax
|
||||
push eax eax
|
||||
; push eax
|
||||
sub esp,32
|
||||
; push eax eax
|
||||
;push eax
|
||||
|
||||
movsx eax,.z1
|
||||
shl eax,CATMULL_SHIFT
|
||||
; mov .cz1,eax
|
||||
; mov .cz2,eax
|
||||
push eax eax
|
||||
;push eax
|
||||
|
||||
movsx eax,word[.b_x1]
|
||||
shl eax,ROUND
|
||||
@ -554,16 +482,6 @@ end if
|
||||
shl eax,ROUND
|
||||
mov .cey1,eax
|
||||
mov .cey2,eax
|
||||
sub esp,32
|
||||
; push eax eax
|
||||
;push eax
|
||||
|
||||
movsx eax,.z1
|
||||
shl eax,CATMULL_SHIFT
|
||||
; mov .cz1,eax
|
||||
; mov .cz2,eax
|
||||
push eax eax
|
||||
;push eax
|
||||
|
||||
movsx ecx,.y1
|
||||
cmp cx,.y2
|
||||
@ -874,6 +792,11 @@ if Ext >= SSE
|
||||
|
||||
else
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
mov eax,.bx2 ; calc .dbx
|
||||
sub eax,.bx1
|
||||
cdq
|
||||
@ -1102,4 +1025,8 @@ end if
|
||||
.bl_end:
|
||||
mov esp,ebp
|
||||
ret 56
|
||||
;Ext = SSE2
|
||||
;the_zero:
|
||||
;size_y_var:
|
||||
;size_x_var:
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
|
||||
; application : View3ds ver. 0.075 - tiny .3ds and .asc files viewer
|
||||
; application : View3ds ver. 0.076 - tiny .3ds and .asc files viewer
|
||||
; with a few graphics effects demonstration.
|
||||
; compiler : FASM
|
||||
; system : KolibriOS
|
||||
; author : Macgub aka Maciej Guba
|
||||
; email : macgub3@wp.pl
|
||||
; web : http://macgub.co.pl, http://macgub.j.pl
|
||||
; web : http://macgub.co.pl
|
||||
; Fell free to use this intro in your own distribution of KolibriOS.
|
||||
; Special greetings to KolibriOS team .
|
||||
; I hope because my demos Christian Belive will be near to each of You.
|
||||
@ -18,7 +18,6 @@
|
||||
; 1) Read from a file (*.3DS standard)
|
||||
; 2) Written in manually (at the end of the code) ; now not exist
|
||||
|
||||
format binary as ""
|
||||
|
||||
SIZE_X equ 512
|
||||
SIZE_Y equ 512 ; ///// I want definitely
|
||||
@ -39,13 +38,11 @@ SSE = 2
|
||||
SSE2 = 3
|
||||
SSE3 = 4
|
||||
Ext = SSE3 ;Ext={ NON | MMX | SSE | SSE2 | SSE3 }
|
||||
|
||||
; For now correct only SSE2 and SSE3 versions. if you have older CPU
|
||||
; use older versions of app. Probably ver 005 will be OK but it need
|
||||
; re-edit to support new Kolibri features.
|
||||
|
||||
; 0 for short names (Menuet-compatible), 1 for long names (Kolibri features)
|
||||
USE_LFN = 1 ; App is Kolibri only now.
|
||||
|
||||
use32
|
||||
org 0x0
|
||||
db 'MENUET01' ; 8 byte id
|
||||
@ -98,7 +95,19 @@ START: ; start of execution
|
||||
call normalize_all_light_vectors
|
||||
call copy_lights ; to aligned float
|
||||
call init_triangles_normals2
|
||||
|
||||
if Ext >= SSE2
|
||||
call detect_chunks
|
||||
mov [chunks_number],ecx
|
||||
mov [chunks_ptr],ebx
|
||||
|
||||
; esi - tri_ch
|
||||
; edi - t_ptr - every vertice index - pointer to to all triangles
|
||||
; that have this index
|
||||
end if
|
||||
|
||||
call init_point_normals
|
||||
|
||||
call init_envmap2
|
||||
call init_envmap_cub
|
||||
call generate_texture2
|
||||
@ -118,12 +127,13 @@ START: ; start of execution
|
||||
cpuid
|
||||
bt ecx,0 ; is sse3 on board?
|
||||
jc @f
|
||||
mov [max_dr_flg],12
|
||||
mov byte[max_dr_flg],12
|
||||
mov [isSSE3],0
|
||||
@@:
|
||||
end if
|
||||
|
||||
still:
|
||||
|
||||
still:
|
||||
cmp [edit_flag],1
|
||||
jne @f
|
||||
mov eax,40 ; set events mask
|
||||
@ -828,6 +838,7 @@ end if
|
||||
|
||||
jmp still
|
||||
|
||||
|
||||
;--------------------------------------------------------------------------------
|
||||
;-------------------------PROCEDURES---------------------------------------------
|
||||
;--------------------------------------------------------------------------------
|
||||
@ -838,6 +849,7 @@ include "3dmath.inc"
|
||||
include "grd_line.inc"
|
||||
include "b_procs.inc"
|
||||
include "a_procs.inc"
|
||||
include "chunks.inc"
|
||||
include "grd_cat.inc"
|
||||
include "bump_tex.inc"
|
||||
include "grd_tex.inc"
|
||||
@ -879,7 +891,9 @@ edit: ; mmx required, edit mesh by vertex
|
||||
imul edx,ecx
|
||||
add ebx,edx
|
||||
push ebx
|
||||
lea ecx,[ebx*2]
|
||||
mov ecx,ebx
|
||||
shl ecx,2
|
||||
; lea ecx,[ebx*2]
|
||||
lea ebx,[ebx*3]
|
||||
|
||||
cmp [dr_flag],12
|
||||
@ -931,11 +945,12 @@ edit: ; mmx required, edit mesh by vertex
|
||||
check_bar
|
||||
jne .no_edit
|
||||
add ecx,[vertices_index_ptr]
|
||||
mov cx,word[ecx]
|
||||
inc cx
|
||||
mov ecx,[ecx]
|
||||
; cmp ecx,-1
|
||||
; je .no_edit
|
||||
|
||||
|
||||
mov [vertex_edit_no],cx ;if vert_edit_no = 0, no vertex selected
|
||||
mov [vertex_edit_no],ecx ;if vert_edit_no = -1, no vertex selected
|
||||
|
||||
mov eax,dword[.x_coord]
|
||||
mov dword[edit_end_x],eax
|
||||
@ -949,7 +964,7 @@ edit: ; mmx required, edit mesh by vertex
|
||||
; add ecx,[vertices_index_ptr]
|
||||
; mov cx,[ecx]
|
||||
; inc cx
|
||||
cmp [vertex_edit_no],0 ; cx ; vertex number
|
||||
cmp [vertex_edit_no],-1 ; cx ; vertex number
|
||||
je .end
|
||||
push dword[.x_coord]
|
||||
pop dword[edit_end_x]
|
||||
@ -961,8 +976,8 @@ edit: ; mmx required, edit mesh by vertex
|
||||
check_bar
|
||||
jne .end
|
||||
|
||||
movzx esi,[vertex_edit_no]
|
||||
dec esi
|
||||
mov esi,[vertex_edit_no]
|
||||
; dec esi
|
||||
lea esi,[esi*3]
|
||||
add esi,esi
|
||||
add esi,[points_translated_ptr]
|
||||
@ -996,8 +1011,8 @@ edit: ; mmx required, edit mesh by vertex
|
||||
call rotary
|
||||
|
||||
; inject into vertex list
|
||||
movzx edi,[vertex_edit_no]
|
||||
dec edi
|
||||
mov edi,[vertex_edit_no]
|
||||
; dec edi
|
||||
lea edi,[edi*3]
|
||||
shl edi,2
|
||||
add edi,[points_ptr]
|
||||
@ -1012,7 +1027,7 @@ edit: ; mmx required, edit mesh by vertex
|
||||
|
||||
|
||||
mov dword[edit_end_x],0
|
||||
mov [vertex_edit_no],0
|
||||
mov [vertex_edit_no],-1
|
||||
|
||||
.no_edit:
|
||||
.end:
|
||||
@ -1055,7 +1070,7 @@ alloc_buffer_mem:
|
||||
|
||||
|
||||
mov ecx,[.temp]
|
||||
add ecx,ecx
|
||||
shl ecx,2
|
||||
add ecx,256
|
||||
mov eax,68
|
||||
mov ebx,20
|
||||
@ -1477,18 +1492,84 @@ ret
|
||||
|
||||
if Ext >= SSE2
|
||||
init_point_normals:
|
||||
;in:
|
||||
; esi - tri_ch
|
||||
; edi - t_ptr
|
||||
.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]
|
||||
.t_ptr equ dword [ebp-36]
|
||||
.tri_ch equ dword [ebp-40]
|
||||
.max_val equ dword [ebp-44]
|
||||
|
||||
push ebp
|
||||
mov ebp,esp
|
||||
sub esp,64
|
||||
and ebp,-16
|
||||
mov .t_ptr,edi
|
||||
mov .tri_ch,esi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
mov ecx,[triangles_count_var]
|
||||
shl ecx,3
|
||||
lea ecx,[ecx*3]
|
||||
add ecx,.tri_ch
|
||||
mov .max_val,ecx
|
||||
xor edx,edx
|
||||
|
||||
.lp1:
|
||||
mov ebx,edx
|
||||
shl ebx,2
|
||||
add ebx,.t_ptr
|
||||
mov esi,[ebx]
|
||||
or esi,esi
|
||||
jz .old
|
||||
|
||||
xorps xmm1,xmm1
|
||||
xor ecx,ecx
|
||||
@@:
|
||||
mov eax,[esi+4] ; eax - tri index
|
||||
mov ebx,[esi]
|
||||
imul eax,[i12]
|
||||
add eax,[triangles_normals_ptr]
|
||||
movups xmm0,[eax]
|
||||
inc ecx
|
||||
addps xmm1,xmm0
|
||||
add esi,8
|
||||
cmp esi,.max_val ; some objects need this check
|
||||
ja .old ;old method
|
||||
cmp ebx,[esi]
|
||||
je @b
|
||||
|
||||
cvtsi2ss xmm2,ecx
|
||||
rcpss xmm2,xmm2
|
||||
shufps xmm2,xmm2,0
|
||||
mulps xmm1,xmm2
|
||||
mov edi,edx
|
||||
imul edi,[i12]
|
||||
add edi,[points_normals_ptr]
|
||||
movlps [edi],xmm1
|
||||
movhlps xmm1,xmm1
|
||||
movss [edi+8],xmm1
|
||||
call normalize_vector
|
||||
|
||||
inc edx
|
||||
cmp edx,[points_count_var]
|
||||
jnz .lp1
|
||||
|
||||
jmp .end
|
||||
|
||||
|
||||
.old:
|
||||
|
||||
mov edi,[points_normals_ptr]
|
||||
mov .point_number,0
|
||||
mov .point_number,edx
|
||||
.ipn_loop:
|
||||
movd xmm0,.point_number
|
||||
pshufd xmm0,xmm0,0
|
||||
@ -1547,6 +1628,20 @@ init_point_normals:
|
||||
mov edx,.point_number
|
||||
cmp edx,[points_count_var]
|
||||
jne .ipn_loop
|
||||
.end:
|
||||
|
||||
mov eax,68
|
||||
mov ebx,13
|
||||
mov ecx,.t_ptr
|
||||
int 0x40
|
||||
|
||||
mov eax,68
|
||||
mov ebx,13
|
||||
mov ecx,.tri_ch
|
||||
int 0x40
|
||||
|
||||
|
||||
|
||||
|
||||
add esp,64
|
||||
pop ebp
|
||||
@ -1776,10 +1871,10 @@ draw_triangles:
|
||||
|
||||
emms
|
||||
; update translated list MMX required
|
||||
cmp [vertex_edit_no],0
|
||||
cmp [vertex_edit_no],-1
|
||||
je @f
|
||||
movzx eax,[vertex_edit_no]
|
||||
dec eax
|
||||
mov eax,[vertex_edit_no]
|
||||
; dec eax
|
||||
movd mm0,[edit_end_x]
|
||||
psubw mm0,[edit_start_x]
|
||||
lea eax,[eax*3]
|
||||
@ -2383,42 +2478,36 @@ draw_triangles:
|
||||
push word .zz2
|
||||
push word .zz1
|
||||
|
||||
mov esi, .point_index3 ; tex map coords
|
||||
shl esi,2
|
||||
add esi,[tex_points_ptr]
|
||||
push dword[esi]
|
||||
mov esi, .point_index2
|
||||
shl esi,2
|
||||
add esi,[tex_points_ptr]
|
||||
push dword[esi]
|
||||
mov esi, .point_index1
|
||||
shl esi,2
|
||||
add esi,[tex_points_ptr]
|
||||
push dword[esi]
|
||||
|
||||
lea esi, .point_index1 ; env coords
|
||||
sub esp,12
|
||||
fninit
|
||||
lea esi, .point_index3 ; env coords
|
||||
mov edi,esp
|
||||
sub esp,24
|
||||
mov ecx,3
|
||||
@@:
|
||||
mov eax,dword[esi]
|
||||
lea eax,[eax*3]
|
||||
shl eax,2
|
||||
mov ebx,eax
|
||||
; mov ebx,eax
|
||||
add ebx,[tex_points_ptr]
|
||||
mov ebx,[ebx]
|
||||
mov [edi-8],ebx
|
||||
lea eax,[eax*3]
|
||||
add eax,[points_normals_rot_ptr]
|
||||
; texture x=(rotated point normal -> x * 255)+255
|
||||
fld dword[eax]
|
||||
fimul [correct_tex]
|
||||
fiadd [correct_tex]
|
||||
fistp word[edi]
|
||||
|
||||
fistp word[edi-4]
|
||||
and word[edi-4],0x7fff ; some objects need it
|
||||
; 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
|
||||
fistp word[edi-2]
|
||||
and word[edi-2],0x7fff ; some objects need it
|
||||
|
||||
sub edi,8
|
||||
sub esi,4
|
||||
loop @b
|
||||
|
||||
mov eax, .xx1
|
||||
@ -2434,18 +2523,7 @@ draw_triangles:
|
||||
|
||||
.bump_tex:
|
||||
push ebp
|
||||
mov esi, .point_index3 ; tex map coords
|
||||
shl esi,2
|
||||
add esi,[tex_points_ptr]
|
||||
push dword[esi]
|
||||
mov esi, .point_index2
|
||||
shl esi,2
|
||||
add esi,[tex_points_ptr]
|
||||
push dword[esi]
|
||||
mov esi, .point_index1
|
||||
shl esi,2
|
||||
add esi,[tex_points_ptr]
|
||||
push dword[esi]
|
||||
fninit
|
||||
|
||||
push dword texmap
|
||||
|
||||
@ -2455,41 +2533,37 @@ draw_triangles:
|
||||
push word .zz2
|
||||
push word .zz1
|
||||
|
||||
lea esi, .index1x12 ; env coords
|
||||
sub esp,12
|
||||
|
||||
lea ebx, .point_index1
|
||||
sub esp,36
|
||||
mov edi,esp
|
||||
mov ecx,3
|
||||
@@:
|
||||
mov eax,dword[esi]
|
||||
add eax,[points_normals_rot_ptr]
|
||||
mov eax,[ebx]
|
||||
shl eax,2
|
||||
mov esi,eax
|
||||
lea esi,[esi*3]
|
||||
add eax,[tex_points_ptr]
|
||||
mov eax,[eax]
|
||||
ror eax,16
|
||||
mov [edi],eax
|
||||
mov [edi+8],eax
|
||||
|
||||
add esi,[points_normals_rot_ptr]
|
||||
; texture x=(rotated point normal -> x * 255)+255
|
||||
fld dword[eax]
|
||||
fld dword[esi]
|
||||
fimul [correct_tex]
|
||||
fiadd [correct_tex]
|
||||
fistp word[edi]
|
||||
fistp word[edi+6] ; env coords
|
||||
; texture y=(rotated point normal -> y * 255)+255
|
||||
fld dword[eax+4]
|
||||
fld dword[esi+4]
|
||||
fimul [correct_tex]
|
||||
fiadd [correct_tex]
|
||||
fistp word[edi+2]
|
||||
|
||||
add edi,4
|
||||
add esi,4
|
||||
fistp word[edi+4]
|
||||
add ebx,4
|
||||
add edi,12
|
||||
loop @b
|
||||
|
||||
mov esi, .point_index3 ; bump map coords
|
||||
shl esi,2
|
||||
add esi,[tex_points_ptr]
|
||||
push dword[esi]
|
||||
mov esi, .point_index2
|
||||
shl esi,2
|
||||
add esi,[tex_points_ptr]
|
||||
push dword[esi]
|
||||
mov esi, .point_index1
|
||||
shl esi,2
|
||||
add esi,[tex_points_ptr]
|
||||
push dword[esi]
|
||||
|
||||
mov eax,dword .xx1
|
||||
mov ebx,dword .xx2
|
||||
mov ecx,dword .xx3
|
||||
@ -2861,138 +2935,110 @@ end if
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
draw_handlers:
|
||||
|
||||
; in eax - render model
|
||||
push ebp
|
||||
mov ebp,esp
|
||||
|
||||
.counter equ ebp-16
|
||||
.xres3m18 equ ebp-8
|
||||
.xres2m12 equ ebp-12
|
||||
; emms
|
||||
.fac equ dword[ebp-16]
|
||||
.xplus_scr equ ebp-8
|
||||
.xplus_index equ ebp-12
|
||||
.dr_model equ dword[ebp-4]
|
||||
|
||||
|
||||
; init counter
|
||||
sub esp,12
|
||||
push dword 0
|
||||
sub esp,16
|
||||
mov .dr_model,eax
|
||||
|
||||
movzx eax,word[size_x_var]
|
||||
cmp .dr_model,12
|
||||
jge @f
|
||||
lea ebx,[eax*3]
|
||||
sub ebx,18
|
||||
add eax,eax
|
||||
sub eax,12
|
||||
mov [.xres3m18],ebx
|
||||
mov [.xres2m12],eax
|
||||
jmp .f
|
||||
sub ebx,3*6
|
||||
mov [.xplus_scr],ebx ; for scr 1st cause
|
||||
mov .fac,3
|
||||
jmp .in_r
|
||||
@@:
|
||||
lea ebx,[eax*4] ; for scr 2cond cause
|
||||
sub ebx,4*6
|
||||
mov [.xplus_scr],ebx
|
||||
mov .fac,4
|
||||
.in_r:
|
||||
|
||||
lea ebx,[eax*4]
|
||||
sub ebx,4*6
|
||||
add eax,eax
|
||||
sub eax,3*4
|
||||
mov [.xres3m18],ebx
|
||||
mov [.xres2m12],eax
|
||||
.f:
|
||||
mov [.xplus_index],ebx ; index
|
||||
|
||||
xor ecx,ecx
|
||||
mov eax,4 shl 16 + 4
|
||||
movd xmm0,[size_y_var]
|
||||
movd xmm1,eax
|
||||
psubw xmm0,xmm1
|
||||
pshuflw xmm0,xmm0,00000001b
|
||||
|
||||
|
||||
mov esi,[points_translated_ptr]
|
||||
.loop:
|
||||
push esi
|
||||
; DO culling AT FIRST
|
||||
.l:
|
||||
push ecx
|
||||
cmp [culling_flag],1 ; (if culling_flag = 1)
|
||||
jne .no_culling
|
||||
mov edi,[.counter] ; *********************************
|
||||
mov edi,ecx ; *********************************
|
||||
lea edi,[edi*3]
|
||||
shl edi,2
|
||||
add edi,[points_normals_rot_ptr]
|
||||
mov eax,[edi+8] ; check sign of z coof
|
||||
shr eax,31
|
||||
cmp eax,1
|
||||
jnz .skip
|
||||
bt dword[edi+8],31
|
||||
jnc .skip
|
||||
.no_culling:
|
||||
mov eax,[esi]
|
||||
movzx ebx,ax ; ebx - x
|
||||
shr eax,16 ; eax - y
|
||||
cmp eax,4 ; check if markers not exceedes screen
|
||||
jle .skip
|
||||
cmp ebx,4
|
||||
jle .skip
|
||||
movzx edx,word[size_x_var]
|
||||
sub edx,4
|
||||
movzx ecx,word[size_y_var]
|
||||
sub ecx,4
|
||||
cmp ebx,edx
|
||||
jge .skip
|
||||
cmp eax,ecx
|
||||
jge .skip
|
||||
mov esi,ecx
|
||||
lea esi,[esi*3]
|
||||
add esi,esi
|
||||
add esi,[points_translated_ptr]
|
||||
movd xmm2,[esi]
|
||||
movd xmm3,[esi]
|
||||
pcmpgtw xmm2,xmm0
|
||||
pcmpgtw xmm3,xmm1
|
||||
pxor xmm3,xmm2
|
||||
movd eax,xmm3
|
||||
cmp eax,-1
|
||||
jne .skip
|
||||
|
||||
movzx edx,word[size_x_var]
|
||||
; sub ebx,3
|
||||
; sub eax,3
|
||||
imul eax,edx
|
||||
add eax,ebx
|
||||
push eax
|
||||
lea edi,[eax*3]
|
||||
cmp .dr_model,12
|
||||
jl @f
|
||||
add edi,[esp]
|
||||
@@:
|
||||
add esp,4
|
||||
lea eax,[eax*2]
|
||||
; draw bar 6x6
|
||||
add edi,[screen_ptr]
|
||||
add eax,dword[vertices_index_ptr]
|
||||
|
||||
|
||||
|
||||
|
||||
mov edx,[.counter]
|
||||
movzx eax,word[esi]
|
||||
movzx ebx,word[esi+2]
|
||||
sub eax,2
|
||||
sub ebx,2
|
||||
movzx edx, word[size_x_var]
|
||||
imul ebx,edx
|
||||
add ebx,eax
|
||||
mov edi,ebx
|
||||
imul ebx,.fac
|
||||
shl edi,2
|
||||
add ebx,[screen_ptr]
|
||||
add edi,[vertices_index_ptr]
|
||||
mov eax,ecx
|
||||
cld
|
||||
mov ecx,6
|
||||
|
||||
.oop:
|
||||
.l2:
|
||||
push ecx
|
||||
mov ecx,6
|
||||
|
||||
.do:
|
||||
mov word[edi],0x0000 ;ax
|
||||
mov byte[edi+2],0xff ;al
|
||||
mov word[eax],dx
|
||||
add eax,2
|
||||
cmp .dr_model,12
|
||||
jl @f
|
||||
add edi,4
|
||||
loop .do
|
||||
jmp .ad
|
||||
@@:
|
||||
add edi,3
|
||||
loop .do
|
||||
.ad:
|
||||
add edi,[.xres3m18]
|
||||
add eax,[.xres2m12]
|
||||
mov ecx,6 ; draw bar
|
||||
.l1:
|
||||
mov word[ebx],0
|
||||
mov byte[ebx+2],0xff
|
||||
stosd
|
||||
add ebx,.fac
|
||||
loop .l1
|
||||
add ebx,[.xplus_scr]
|
||||
add edi,[.xplus_index]
|
||||
pop ecx
|
||||
loop .oop
|
||||
|
||||
loop .l2
|
||||
.skip:
|
||||
pop esi
|
||||
add esi,6
|
||||
inc dword[.counter]
|
||||
mov ecx,[.counter]
|
||||
pop ecx
|
||||
inc ecx
|
||||
cmp ecx,[points_count_var]
|
||||
jng .loop
|
||||
jna .l
|
||||
|
||||
mov esp,ebp
|
||||
pop ebp
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
fill_Z_buffer:
|
||||
mov eax,0x70000000
|
||||
cmp [dr_flag],11
|
||||
@ -3033,11 +3079,7 @@ read_tp_variables: ; read [triangles_count_var] and [points_count_va
|
||||
xor ebp,ebp
|
||||
mov [points_count_var],ebx
|
||||
mov [triangles_count_var],ebx
|
||||
if USE_LFN = 0
|
||||
mov esi,SourceFile
|
||||
else
|
||||
mov esi,[fptr]
|
||||
end if
|
||||
|
||||
cmp [esi],word 4D4Dh
|
||||
je @f ;Must be legal .3DS file
|
||||
@ -3096,11 +3138,13 @@ read_tp_variables: ; read [triangles_count_var] and [points_count_va
|
||||
mov edx,ecx
|
||||
add esi,8
|
||||
@@:
|
||||
|
||||
add ebx,6
|
||||
add esi,12
|
||||
lea ecx,[ecx*3]
|
||||
add ecx,ecx
|
||||
add ebx,ecx
|
||||
add ecx,ecx
|
||||
add esi,ecx
|
||||
; dec ecx
|
||||
loop @b
|
||||
; loop @b
|
||||
@@:
|
||||
|
||||
@@:
|
||||
@ -3114,9 +3158,11 @@ read_tp_variables: ; read [triangles_count_var] and [points_count_va
|
||||
add esi,8
|
||||
|
||||
@@:
|
||||
add esi,8
|
||||
dec ecx
|
||||
jnz @b
|
||||
shl ecx,3
|
||||
add esi,ecx
|
||||
; dec ecx
|
||||
; jnz @b
|
||||
; loop @b
|
||||
; xor ecx,ecx
|
||||
add ebp,edx
|
||||
jmp .find4k
|
||||
@ -3198,8 +3244,9 @@ read_from_file:
|
||||
|
||||
add ebx,6
|
||||
add esi,12
|
||||
dec ecx
|
||||
jnz @b
|
||||
; dec ecx
|
||||
; jnz @b
|
||||
loop @b
|
||||
@@:
|
||||
; mov dword[points+ebx],-1
|
||||
push edi
|
||||
@ -3227,14 +3274,17 @@ read_from_file:
|
||||
add dword[edi-8],ebp
|
||||
add dword[edi-4],ebp
|
||||
add esi,8
|
||||
dec ecx
|
||||
jnz @b
|
||||
; dec ecx
|
||||
; jnz @b
|
||||
loop @b
|
||||
add ebp,edx
|
||||
jmp .find4k
|
||||
mov eax,-1 ;<---mark if OK
|
||||
.exit:
|
||||
mov dword[edi],-1
|
||||
ret
|
||||
|
||||
|
||||
alloc_mem_for_tp:
|
||||
mov eax, 68
|
||||
cmp [re_alloc_flag],1
|
||||
@ -3265,7 +3315,7 @@ alloc_mem_for_tp:
|
||||
|
||||
mov eax, 68
|
||||
mov ecx, [triangles_count_var]
|
||||
lea ecx, [3+ecx*3]
|
||||
lea ecx, [6+ecx*3]
|
||||
shl ecx, 2
|
||||
mov edx,[triangles_normals_ptr]
|
||||
int 0x40 ; -> allocate memory for triangles normals
|
||||
@ -3274,7 +3324,7 @@ alloc_mem_for_tp:
|
||||
|
||||
mov eax, 68
|
||||
mov ecx, [points_count_var]
|
||||
lea ecx,[3+ecx*3]
|
||||
lea ecx,[6+ecx*3]
|
||||
shl ecx, 2
|
||||
mov edx,[points_normals_ptr]
|
||||
int 0x40
|
||||
@ -3284,13 +3334,14 @@ alloc_mem_for_tp:
|
||||
mov eax, 68
|
||||
; mov ebx, 12
|
||||
mov ecx, [points_count_var]
|
||||
lea ecx,[3+ecx*3]
|
||||
lea ecx,[10+ecx*3]
|
||||
shl ecx, 2
|
||||
mov edx,[points_normals_rot_ptr]
|
||||
int 0x40
|
||||
mov [points_normals_rot_ptr], eax
|
||||
|
||||
mov eax, 68
|
||||
|
||||
mov edx,[points_ptr]
|
||||
int 0x40
|
||||
mov [points_ptr], eax
|
||||
@ -3304,13 +3355,14 @@ alloc_mem_for_tp:
|
||||
mov ebx, 12
|
||||
mov ecx, [points_count_var]
|
||||
shl ecx,2
|
||||
add ecx,32
|
||||
mov edx,[tex_points_ptr]
|
||||
int 0x40
|
||||
mov [tex_points_ptr], eax
|
||||
|
||||
mov eax, 68
|
||||
mov ecx, [points_count_var]
|
||||
inc ecx
|
||||
add ecx,10
|
||||
shl ecx, 3
|
||||
mov edx,[points_translated_ptr]
|
||||
int 0x40
|
||||
@ -3417,7 +3469,7 @@ write_info:
|
||||
mov bx,[size_x_var]
|
||||
shl ebx,16
|
||||
add ebx,120*65536+70 ; [x start] *65536 + [y start]
|
||||
mov ecx,30 shl 16 + 100
|
||||
mov ecx,30 shl 16 + 150
|
||||
xor edx,edx
|
||||
int 0x40
|
||||
|
||||
@ -3467,7 +3519,7 @@ write_info:
|
||||
int 40h
|
||||
pop esi
|
||||
add esi,4
|
||||
cmp esi,12
|
||||
cmp esi,16
|
||||
jnz .nxxx
|
||||
ret
|
||||
; *********************************************
|
||||
|
Loading…
Reference in New Issue
Block a user