view3ds 076 by macgub

git-svn-id: svn://kolibrios.org@9512 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2021-12-28 08:18:43 +00:00
parent e94c9d2b32
commit ec81f654c0
15 changed files with 3823 additions and 3871 deletions

View File

@ -245,7 +245,7 @@ ret
;---------------------- out : none ------------------------ ;---------------------- out : none ------------------------
make_vector_r: make_vector_r:
if Ext < SSE2 if Ext < SSE
fninit fninit
fld dword[edi] ;edi+x3d fld dword[edi] ;edi+x3d
fsub dword[esi] ;esi+x3d fsub dword[esi] ;esi+x3d
@ -297,6 +297,7 @@ cross_product:
fstp dword [ebx+vec_z] fstp dword [ebx+vec_z]
ret ret
cross_aligned: cross_aligned:
; params as above cross_p
movaps xmm0,[esi] movaps xmm0,[esi]
movaps xmm1,[esi] movaps xmm1,[esi]
movaps xmm2,[edi] movaps xmm2,[edi]
@ -607,6 +608,19 @@ ret
;---------------------------------------------- ;----------------------------------------------
; esi - pointer to 3x3 matrix ; esi - pointer to 3x3 matrix
add_scale_to_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 fninit
fld [rsscale] fld [rsscale]
fld dword[esi] ;----- fld dword[esi] ;-----
@ -639,14 +653,19 @@ add_scale_to_matrix:
fld dword[esi+32] fld dword[esi+32]
fmulp st1,st fmulp st1,st
fstp dword[esi+32] ;------ fstp dword[esi+32] ;------
end if
ret ret
;in esi - offset to 3d points (point as 3 dwords float) ;in esi - offset to 3d points (point as 3 dwords float)
; edi - offset to 2d points ( as 3 words integer) ; edi - offset to 2d points ( as 3 words integer)
; ecx - number of points ; ecx - number of points
translate_points: ; just convert into integer; z coord still needed translate_points: ; just convert into integer; z coord still needed
if Ext < SSE
fninit fninit
else
; movaps xmm1,[vect_x]
end if
.again: .again:
if 0 if 0
fld dword[esi+8] fld dword[esi+8]
@ -676,7 +695,18 @@ translate_points: ; just convert into integer; z coord still needed
fiadd [vect_y] fiadd [vect_y]
fistp word[edi+2] fistp word[edi+2]
end if 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 ; cvtps2dq xmm0,xmm0
; packsdw xmm0,xmm0 ; packsdw xmm0,xmm0
; movq [edi] ; movq [edi]
@ -688,9 +718,12 @@ translate_points: ; just convert into integer; z coord still needed
fistp word[edi+2] fistp word[edi+2]
fld dword[esi+8] fld dword[esi+8]
fistp word[edi+4] fistp word[edi+4]
end if
add esi,12 add esi,12
add edi,6 add edi,6
dec ecx ; dec ecx
jnz .again ; jnz .again
loop .again
ret ret

View File

@ -341,7 +341,6 @@ end if
pop ebp pop ebp
ret ret
align 16
real_phong_line_z: real_phong_line_z:
; in: ; in:
; xmm0 - normal vector 1 ; xmm0 - normal vector 1
@ -456,7 +455,7 @@ real_phong_line_z:
sub ecx,.lx1 sub ecx,.lx1
movaps xmm0,.n1 movaps xmm0,.n1
movss xmm2,.z1 movss xmm2,.z1
align 16
.ddraw: .ddraw:
movss xmm7,xmm2 movss xmm7,xmm2
cmpnltss xmm7,dword[esi] cmpnltss xmm7,dword[esi]

View File

@ -353,7 +353,7 @@ end if
ret ret
align 16
ray_shd_l: ray_shd_l:
; in: ; in:
; xmm0 - normal vector 1 ; xmm0 - normal vector 1
@ -392,7 +392,7 @@ ray_shd_l:
.dn equ [ebp-96] .dn equ [ebp-96]
.dz equ [ebp-100] .dz equ [ebp-100]
.y equ [ebp-104] .y equ [ebp-104]
; .cur_tri equ [ebp-108] .startx equ [ebp-108]
.cnv equ [ebp-128] .cnv equ [ebp-128]
.Rlen equ [ebp-128-16] .Rlen equ [ebp-128-16]
.r1 equ [ebp-128-32] .r1 equ [ebp-128-32]
@ -431,6 +431,7 @@ ray_shd_l:
movaps .n1,xmm0 movaps .n1,xmm0
movaps .n2,xmm1 movaps .n2,xmm1
mov .lx1,eax mov .lx1,eax
; mov .startx,eax
mov .lx2,ebx mov .lx2,ebx
movlps .z1,xmm3 movlps .z1,xmm3
@ -546,9 +547,15 @@ end if
mov edi,[triangles_ptr] mov edi,[triangles_ptr]
xor ecx,ecx xor ecx,ecx
.nx_tri: ; next triangle .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 cmp ecx,.cur_tri ; prevent self shadowing
je .skipp je .skipp
@@:
if 0 if 0
mov edi,ecx mov edi,ecx
imul edi,[i12] imul edi,[i12]

View File

@ -16,22 +16,22 @@ stencil_tri:
.y3 equ [ebp-12] .y3 equ [ebp-12]
.dx12 equ dword[ebp-20] .dx12 equ dword[ebp-20]
.dx13 equ dword[ebp-24] .dz12 equ dword[ebp-24]
.dx23 equ dword[ebp-28] .dx13 equ dword[ebp-28]
.dz12 equ dword[ebp-32] .dz13 equ dword[ebp-32]
.dz13 equ dword[ebp-36] .dx23 equ dword[ebp-36]
.dz23 equ dword[ebp-40] .dz23 equ dword[ebp-40]
.zz2 equ [ebp-44] .zz2 equ [ebp-44]
.zz1 equ [ebp-48] .zz1 equ [ebp-48]
.z3 equ [ebp-56] .z3 equ [ebp-56]
.z2 equ [ebp-60] .z2 equ [ebp-60]
.z1 equ [ebp-64] .z1 equ [ebp-64]
.s_buff equ [ebp-68] ;.s_buff equ [ebp-68]
push ebp push ebp
mov ebp,esp mov ebp,esp
sub esp,128 ; sub esp,128
and ebp,0xfffffff0 ; and ebp,0xfffffff0
.sort2: .sort2:
cmp ax,bx cmp ax,bx
jle .sort1 jle .sort1
@ -44,19 +44,24 @@ stencil_tri:
shufps xmm0,xmm0,11011000b shufps xmm0,xmm0,11011000b
jmp .sort2 jmp .sort2
.sort3: .sort3:
mov .y1,eax ; store triangle coordinates in user friendly variables ; mov .y1,eax ; store triangle coordinates in user friendly variables
mov .y2,ebx ; mov .y2,ebx
mov .y3,ecx ; mov .y3,ecx
push eax
push ebx
push ecx
sub esp,60
; mov edx,100.11 ; mov edx,100.11
; movd xmm0,edx ; movd xmm0,edx
; shufps xmm0,xmm0,11100000b ; shufps xmm0,xmm0,11100000b
movaps .z1,xmm0 movups .z1,xmm0
; mov dword .z1,edx ; mov dword .z1,edx
; mov .z2,edx ; mov .z2,edx
; mov .z3,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 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 and edx,ebx ; if *all* of them are negative a sign flag is raised
@ -157,7 +162,7 @@ stencil_tri:
; mov edx,0.11 ; mov edx,0.11
; movd xmm0,edx ; movd xmm0,edx
; shufps xmm0,xmm0,11100000b ; shufps xmm0,xmm0,11100000b
mov esi,.s_buff ; mov esi,.s_buff
call stencil_line call stencil_line
@ -192,7 +197,7 @@ stencil_tri:
sar ebx,ROUND2 sar ebx,ROUND2
sar eax,ROUND2 sar eax,ROUND2
movlps xmm0,.zz1 movlps xmm0,.zz1
mov esi,.s_buff ; mov esi,.s_buff
call stencil_line call stencil_line
@ -215,7 +220,7 @@ stencil_tri:
jl .loop2 jl .loop2
.loop2_end: .loop2_end:
add esp,128 mov esp,ebp
pop ebp pop ebp
ret ret
@ -312,17 +317,19 @@ stencil_line:
sub ecx,.x1 sub ecx,.x1
movss xmm2,.z1 ; cz movss xmm2,.z1 ; cz
.ccalc: .ccalc:
movss xmm1,xmm2 ; movss xmm1,xmm2
cmpltss xmm1,dword[esi] ; cmpltss xmm1,dword[esi]
movd eax,xmm1 ; movd eax,xmm1
cmp eax,-1 ; cmp eax,-1
jnz @f comiss xmm2,[esi]
ja @f
movss dword[esi],xmm2 movss dword[esi],xmm2
@@: @@:
add esi,4 add esi,4
addss xmm2,.dz addss xmm2,.dz
sub ecx,1 ; sub ecx,1
jnz .ccalc ; jnz .ccalc
loop .ccalc
.l_quit: .l_quit:
mov esp,ebp mov esp,ebp
pop ebp pop ebp

View File

@ -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 if Ext > SSE2
;-------------------------------------------------------------------- ;--------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View 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

View File

@ -1,7 +1,7 @@
; DATA AREA ************************************ ; DATA AREA ************************************
if Ext > SSE2 ; if Ext > SSE2
isSSE3 db 1 isSSE3 db 1
end if ; end if
i3 dw 3 i3 dw 3
i6 dd 6 i6 dd 6
i12 dd 12 i12 dd 12
@ -28,14 +28,15 @@
y_offset dw SIZE_Y / 2 y_offset dw SIZE_Y / 2
z_offset dw 0 z_offset dw 0
rsscale dd 175.0 ; next real scale 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: ; vect_x: dw SIZE_X / 2
xres_var dw SIZE_X ; 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_x dw 0
angle_y dw 0 angle_y dw 0
@ -64,7 +65,7 @@
screen_ptr dd 0 screen_ptr dd 0
Zbuffer_ptr dd 0 Zbuffer_ptr dd 0
vertices_index_ptr dd 0 vertices_index_ptr dd 0
vertex_edit_no dw 0 vertex_edit_no dd -1
edit_start_x: edit_start_x:
dw 0 dw 0
edit_start_y dw 0 edit_start_y dw 0
@ -86,8 +87,9 @@
db 3 db 3
db 'shd. model' db 'shd. model'
max_dr_flg:
if Ext >= SSE3 if Ext >= SSE3
max_dr_flg db 15 db 15
else else
db 12 db 12
end if end if
@ -290,6 +292,7 @@ flags: ; flags description
db 'x+y ' db 'x+y '
db ' x ' db ' x '
db 'keys' db 'keys'
onoff_f: onoff_f:
db 'off ' db 'off '
db 'on ' db 'on '
@ -354,7 +357,7 @@ base_vector:
if Ext=SSE3 if Ext=SSE3
db ' (SSE3)' db ' (SSE3)'
end if end if
db ' 0.075',0 db ' 0.076',0
labellen: labellen:
STRdata db '-1 ' STRdata db '-1 '
lab_vert: lab_vert:
@ -367,6 +370,9 @@ base_vector:
db 'Edges count: ' db 'Edges count: '
lab_ed_end: lab_ed_end:
db 'Chunks detected:'
all_lights_size dw lightsend-lights all_lights_size dw lightsend-lights
@ -483,6 +489,17 @@ end if
times 4 dd 1.0 times 4 dd 1.0
eps: times 4 dd 0.00000 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 epsone dd 1.0001
aprox dd 0.0001 aprox dd 0.0001
epsminus dd -0.0001 epsminus dd -0.0001
@ -496,7 +513,7 @@ end if
fptr dd 0 ;workarea fptr dd 0 ;workarea
file_name: file_name:
db '/rd/1/3d/house.3ds',0 db '/rd/1/3d/house.3ds',0
; db '/tmp0/1/ant.3ds',0 ; db '/tmp0/1/sc.3ds',0
rb 256 rb 256
@ -521,7 +538,9 @@ align 8
points_count_var dd ? ; points_count_var dd ? ;
triangles_count_var dd ? ; dont change order triangles_count_var dd ? ; dont change order
edges_count dd ? ; edges_count dd ? ;
chunks_number dd ?
tex_points_ptr dd ? tex_points_ptr dd ?
chunks_ptr dd ?
temp_col dw ? temp_col dw ?
high dd ? high dd ?

View File

@ -26,22 +26,14 @@ flat_triangle_z:
.y3 equ word[ebp-16] .y3 equ word[ebp-16]
.dx12 equ dword[ebp-20] .dx12 equ dword[ebp-20]
;.dz12 equ dword[ebp-24] .dz12 equ dword[ebp-24]
.dx13 equ dword[ebp-24] .dx13 equ dword[ebp-28]
.dz13 equ dword[ebp-28] .dz13 equ dword[ebp-32]
.dz12 equ dword[ebp-32]
;.dz13 equ dword[ebp-32]
.dx23 equ dword[ebp-36] .dx23 equ dword[ebp-36]
.dz13M equ [ebp-40] .dz23 equ dword[ebp-40]
.dz23 equ dword[ebp-44] .zz1 equ dword[ebp-44]
.zz1 equ dword[ebp-48] .zz2 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
mov ebp,esp mov ebp,esp
push edx ; store edx in variable .col push edx ; store edx in variable .col
@ -87,13 +79,13 @@ flat_triangle_z:
; jle @f ; jle @f
; jmp .ft_loop2_end ; jmp .ft_loop2_end
;@@: ;@@:
sub esp,52-12 ; sub esp,52-12
mov bx,.y2 ; calc delta 12 mov bx,.y2 ; calc delta 12
sub bx,.y1 sub bx,.y1
jnz .ft_dx12_make jnz .ft_dx12_make
mov .dx12,0 push dword 0
mov .dz12,0 push dword 0
jmp .ft_dx12_done jmp .ft_dx12_done
.ft_dx12_make: .ft_dx12_make:
mov ax,.x2 mov ax,.x2
@ -103,7 +95,7 @@ flat_triangle_z:
shl eax,ROUND shl eax,ROUND
cdq cdq
idiv ebx idiv ebx
mov .dx12,eax push eax
mov ax,.z2 mov ax,.z2
sub ax,.z1 sub ax,.z1
@ -111,14 +103,13 @@ flat_triangle_z:
shl eax,CATMULL_SHIFT shl eax,CATMULL_SHIFT
cdq cdq
idiv ebx idiv ebx
mov .dz12,eax push eax
.ft_dx12_done: .ft_dx12_done:
mov bx,.y3 ; calc delta 13 mov bx,.y3 ; calc delta 13
sub bx,.y1 sub bx,.y1
jnz .ft_dx13_make jnz .ft_dx13_make
mov .dx13,0 push dword 0
mov .dz13,0 push dword 0
mov dword .dz13M,0
jmp .ft_dx13_done jmp .ft_dx13_done
.ft_dx13_make: .ft_dx13_make:
mov ax,.x3 mov ax,.x3
@ -128,7 +119,7 @@ flat_triangle_z:
shl eax,ROUND shl eax,ROUND
cdq cdq
idiv ebx idiv ebx
mov .dx13,eax push eax
mov ax,.z3 mov ax,.z3
sub ax,.z1 sub ax,.z1
@ -136,14 +127,17 @@ flat_triangle_z:
shl eax,CATMULL_SHIFT shl eax,CATMULL_SHIFT
cdq cdq
idiv ebx idiv ebx
mov .dz13,eax push eax
mov dword .dz13M,eax
.ft_dx13_done: .ft_dx13_done:
; sub esp,48
mov bx,.y3 ; calc delta 23 mov bx,.y3 ; calc delta 23
sub bx,.y2 sub bx,.y2
jnz .gt_dx23_make jnz .gt_dx23_make
mov .dx23,0 push dword 0
mov .dz23,0 push dword 0
; mov .dx23,0
; mov .dz23,0
jmp .gt_dx23_done jmp .gt_dx23_done
.gt_dx23_make: .gt_dx23_make:
mov ax,.x3 mov ax,.x3
@ -153,7 +147,7 @@ flat_triangle_z:
shl eax,ROUND shl eax,ROUND
cdq cdq
idiv ebx idiv ebx
mov .dx23,eax push eax
mov ax,.z3 mov ax,.z3
sub ax,.z2 sub ax,.z2
@ -161,19 +155,18 @@ flat_triangle_z:
shl eax,CATMULL_SHIFT shl eax,CATMULL_SHIFT
cdq cdq
idiv ebx idiv ebx
mov .dz23,eax push eax
; mov .dz23,eax
.gt_dx23_done: .gt_dx23_done:
movsx edx,.z1 movsx edx,.z1
shl edx,CATMULL_SHIFT shl edx,CATMULL_SHIFT
mov .zz1,edx push edx
mov .zz2,edx push edx
movsx eax,.x1 movsx eax,.x1
shl eax,ROUND ; eax - x1 shl eax,ROUND ; eax - x1
mov ebx,eax ; ebx - x2 mov ebx,eax ; ebx - x2
;if Ext>=MMX
; movq mm0,.zz2M
;end if
mov cx,.y1 mov cx,.y1
cmp cx,.y2 cmp cx,.y2
jge .ft_loop1_end jge .ft_loop1_end
@ -187,22 +180,15 @@ flat_triangle_z:
push bx ; x2 push bx ; x2
sar eax,ROUND sar eax,ROUND
push ax ; x1 push ax ; x1
;if Ext>=MMX
; sub esp,8
; movq [esp],mm0
;else
push .zz2 ; z2 shl CATMULL_SHIFT push .zz2 ; z2 shl CATMULL_SHIFT
push .zz1 ; z1 shl CATMULL_SHIFT push .zz1 ; z1 shl CATMULL_SHIFT
;end if
call flat_line_z call flat_line_z
popad popad
add eax,.dx13 add eax,.dx13
add ebx,.dx12 add ebx,.dx12
;if Ext>=MMX
; paddd mm0,.dz12M
;else
mov edx,.dz13 mov edx,.dz13
add .zz1,edx add .zz1,edx
@ -219,13 +205,7 @@ flat_triangle_z:
mov .zz2,edx mov .zz2,edx
movsx ebx,.x2 movsx ebx,.x2
shl ebx,ROUND shl ebx,ROUND
;if Ext>=MMX
; movq mm0,.zz2M
;; push .dz13 ; exchange
;; pop .dz12
;; push .dz23 ; exchange
;; pop .dz13
;end if
mov cx,.y2 mov cx,.y2
cmp cx,.y3 cmp cx,.y3
jge .ft_loop2_end jge .ft_loop2_end
@ -238,32 +218,22 @@ flat_triangle_z:
push bx push bx
sar eax,ROUND sar eax,ROUND
push ax ; x1 push ax ; x1
;if Ext>=MMX
; sub esp,8
; movq [esp],mm0
;else
push .zz2 ; z2 shl CATMULL_SHIFT push .zz2 ; z2 shl CATMULL_SHIFT
push .zz1 ; z1 shl CATMULL_SHIFT push .zz1 ; z1 shl CATMULL_SHIFT
;end if
call flat_line_z call flat_line_z
popad popad
add eax,.dx13 add eax,.dx13
add ebx,.dx23 add ebx,.dx23
;if Ext>=MMX
; paddd mm0,.dz23M
;else
mov edx,.dz13 mov edx,.dz13
add .zz1,edx add .zz1,edx
mov edx,.dz23 mov edx,.dz23
add .zz2,edx add .zz2,edx
; mov edx,.dz13
; add .zz1,edx
; mov edx,.dz12
; add .zz2,edx
;end if
inc cx inc cx
cmp cx,.y3 cmp cx,.y3
jl .ft_loop2 jl .ft_loop2
@ -374,13 +344,15 @@ flat_line_z:
; cmovl [edi],eax ; cmovl [edi],eax
; cmovl [esi],ebx ; cmovl [esi],ebx
jge @f jge @f
stosd mov [edi],eax
dec edi mov [esi],ebx
mov dword[esi],ebx ; stosd ; less branches
jmp .no_skip ; dec edi
; mov dword[esi],ebx
; jmp .no_skip
@@: @@:
add edi,3 add edi,3
.no_skip: ; .no_skip:
add esi,4 add esi,4
add ebx,edx add ebx,edx
loop .ddraw loop .ddraw

File diff suppressed because it is too large Load Diff

View File

@ -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 View3ds 0.073 - may 2021
1. I introduced procedure for searching nonredundand edges. 1. I introduced procedure for searching nonredundand edges.
2. Writing some info about object: vertices, triangles unique edges 2. Writing some info about object: vertices, triangles unique edges

View File

@ -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. effects implementation.
What's new? What's new?
1. Fixed emboss bug in grd lines displaying model. 1. Detecting manifold chunks procedure based on kind of sorted pivot
2. Grd line exceedes screen problem fix. table. Chunks are counted and this number displayed.
3. New rendering model - ray casted shadows and appropiate button to 2. New calculating normal vectors proc that use some data produced
set 'on' this option. Note that is non real time model, especially when by new chunks routine. Now big object loading is fast. I load object that
complex object is computed. I took effort to introduce accelerating contains ~500000 vertices, ~700000 faces and ~2000 0000 unique edges
structure - AABB (Axis Aligned Bounding Boxes).. but it is disabled in few seconds on i5 2cond gen. Earlier such objects calculating was
for now - seems to work incorrect(slow). 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: 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 2. shd. model: choosing shading model: flat, grd (smooth), env (spherical
environment mapping, bump (bump mapping), tex (texture mapping), environment mapping, bump (bump mapping), tex (texture mapping),
pos (position shading depend), dots (app draws only points - nodes of object), 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 decrease whole handlers count by enable culling (using appropriate button) - some
back handlers become hidden. back handlers become hidden.
Maciej Guba IX 2021 Maciej Guba XII 2021

View File

@ -452,7 +452,11 @@ textured_line_z:
xchg ax,.x2 ; sort params xchg ax,.x2 ; sort params
mov .x1,ax 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 mm0,[.tex_x1]
movq mm1,[.tex_x2] movq mm1,[.tex_x2]
movq [.tex_x2],mm0 movq [.tex_x2],mm0

View File

@ -5,14 +5,18 @@
;TEX_X equ 512 ;TEX_X equ 512
;TEX_Y equ 512 ;TEX_Y equ 512
;TEXTURE_SIZE EQU (512*512)-1 ;TEXTURE_SIZE EQU (512*512)-1
;TEX_SHIFT EQU 9 ;TEX_SHIFT EQU 9
;CATMULL_SHIFT equ 8 CATMULL_SHIFT equ 8
;TEXTURE_SIZE EQU (TEX_X * TEX_Y)-1 TEXTURE_SIZE EQU (TEX_X * TEX_Y)-1
;Ext = SSE
;SSE = 3 ;SSE3 = 4
;SSE2 = 3
;SSE = 2
;MMX = 1 ;MMX = 1
;NON = 0 ;NON = 0
;Ext = NON
;use32 ;use32
;------- Big thanks to Majuma (www.majuma.xt.pl) for absolutely great--- ;------- Big thanks to Majuma (www.majuma.xt.pl) for absolutely great---
;------- DOS 13h mode demos -------------------------------------------- ;------- DOS 13h mode demos --------------------------------------------
@ -32,18 +36,18 @@ two_tex_triangle_z:
;---------------------- pointer io Z buffer----- ;---------------------- pointer io Z buffer-----
;-- Z-buffer - filled with coordinates as dword -------- ;-- Z-buffer - filled with coordinates as dword --------
;-- (Z coor. as word) shl CATMULL_SHIFT ---------------- ;-- (Z coor. as word) shl CATMULL_SHIFT ----------------
.b_x1 equ ebp+4 ; procedure don't save registers !!! .e_x1 equ ebp+4 ; procedure don't save registers !!!
.b_y1 equ ebp+6 ; each coordinate as word .e_y1 equ ebp+6 ; each coordinate as word
.b_x2 equ ebp+8 .b_x1 equ ebp+8
.b_y2 equ ebp+10 ; b - first texture .b_y1 equ ebp+10
.b_x3 equ ebp+12 .e_x2 equ ebp+12
.b_y3 equ ebp+14 ; e - second texture .e_y2 equ ebp+14
.e_x1 equ ebp+16 .b_x2 equ ebp+16
.e_y1 equ ebp+18 .b_y2 equ ebp+18 ; b - first texture
.e_x2 equ ebp+20 .e_x3 equ ebp+20
.e_y2 equ ebp+22 .e_y3 equ ebp+22 ; e - second texture
.e_x3 equ ebp+24 .b_x3 equ ebp+24
.e_y3 equ ebp+26 .b_y3 equ ebp+26
.z1 equ word[ebp+28] .z1 equ word[ebp+28]
.z2 equ word[ebp+30] .z2 equ word[ebp+30]
.z3 equ word[ebp+32] .z3 equ word[ebp+32]
@ -60,31 +64,31 @@ two_tex_triangle_z:
.y3 equ word[ebp-20] .y3 equ word[ebp-20]
.dx12 equ dword[ebp-24] .dx12 equ dword[ebp-24]
.dbx12 equ dword[ebp-28] .dbx12 equ [ebp-28]
.dby12 equ dword[ebp-32] .dby12 equ dword[ebp-32]
.dby12q equ [ebp-32] .dby12q equ [ebp-32]
.dex12 equ dword[ebp-36] .dex12 equ dword[ebp-36]
.dey12 equ dword[ebp-40] .dey12 equ dword[ebp-40]
.dey12q equ [ebp-40] .dey12q equ [ebp-40]
.dz12 equ dword[ebp-44] .dz12 equ [ebp-44]
.dx13 equ dword[ebp-48] .dx13 equ dword[ebp-48]
.dbx13 equ dword[ebp-52] .dbx13 equ [ebp-52]
.dby13 equ dword[ebp-56] .dby13 equ dword[ebp-56]
.dby13q equ [ebp-56] .dby13q equ [ebp-56]
.dex13 equ dword[ebp-60] .dex13 equ dword[ebp-60]
.dey13 equ dword[ebp-64] .dey13 equ dword[ebp-64]
.dey13q equ [ebp-64] .dey13q equ [ebp-64]
.dz13 equ dword[ebp-68] .dz13 equ [ebp-68]
.dx23 equ dword[ebp-72] .dx23 equ dword[ebp-72]
.dbx23 equ dword[ebp-76] .dbx23 equ [ebp-76]
.dby23 equ dword[ebp-80] .dby23 equ dword[ebp-80]
.dby23q equ [ebp-80] .dby23q equ [ebp-80]
.dex23 equ dword[ebp-84] .dex23 equ dword[ebp-84]
.dey23 equ dword[ebp-88] .dey23 equ dword[ebp-88]
.dey23q equ [ebp-88] .dey23q equ [ebp-88]
.dz23 equ dword[ebp-92] .dz23 equ [ebp-92]
.cx1 equ dword[ebp-96] ; current variables .cx1 equ dword[ebp-96] ; current variables
.cx2 equ dword[ebp-100] .cx2 equ dword[ebp-100]
@ -138,8 +142,6 @@ two_tex_triangle_z:
jmp .sort3 jmp .sort3
.sort2: .sort2:
push eax ebx ecx ; store triangle coords in variables 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 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 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 ; jg .loop23_done
; cmp .x3,SIZE_X ; cmp .x3,SIZE_X
; jg .loop23_done ; { ; jg .loop23_done ; {
; sub esp,18*4
; pxor xmm7,xmm7
mov bx,.y2 ; calc delta 12 mov bx,.y2 ; calc delta 12
sub bx,.y1 sub bx,.y1
jnz .bt_dx12_make jnz .bt_dx12_make
@ -171,142 +173,80 @@ two_tex_triangle_z:
loop @b loop @b
jmp .bt_dx12_done jmp .bt_dx12_done
.bt_dx12_make: .bt_dx12_make:
movsx ebx,bx
mov eax,1 shl 15
cdq
idiv ebx
mov ebx,eax
mov ax,.x2 mov ax,.x2
sub ax,.x1 sub ax,.x1
cwde cwde
movsx ebx,bx imul ebx
shl eax,ROUND sar eax,15 - ROUND
cdq
idiv ebx
; mov .dx12,eax
push eax push eax
; mov .dx12,eax
if Ext=SSE if Ext >= SSE2
sub esp,4*4
sub esp,16 movd xmm0,ebx
cvtsi2ss xmm3,ebx ;rcps pshuflw xmm0,xmm0,0
; mov eax,255 movq xmm1,[.e_x1]
cvtsi2ss xmm4,[i255d] ;eax movq xmm2,[.e_x2]
divss xmm3,xmm4 psubw xmm2,xmm1
rcpss xmm3,xmm3 movdqa xmm3,xmm2
; mulss xmm3,xmm4 pmullw xmm2,xmm0
shufps xmm3,xmm3,0 pmulhw xmm3,xmm0
punpcklwd xmm2,xmm3
movd mm0,[.b_x1] psrad xmm2,15 - ROUND
movd mm1,[.b_x2] pshufd xmm2,xmm2,10110001b
movd mm2,[.e_x1] movdqu .dey12q,xmm2
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
else else
mov ax,word[.b_x2] mov ax,word[.b_x2]
sub ax,word[.b_x1] sub ax,word[.b_x1]
cwde cwde
shl eax,ROUND imul ebx
cdq sar eax,15 - ROUND
idiv ebx ; mov .dbx23,eax
; mov .dbx12,eax
push eax push eax
mov ax,word[.b_y2] mov ax,word[.b_y2]
sub ax,word[.b_y1] sub ax,word[.b_y1]
cwde cwde
shl eax,ROUND imul ebx
cdq sar eax,15 - ROUND
idiv ebx ; mov .dbx23,eax
; mov .dby12,eax
push eax push eax
; mov eax,.dbx12
; mov ebx,.dby12
; int3
mov ax,word[.e_x2] mov ax,word[.e_x2]
sub ax,word[.e_x1] sub ax,word[.e_x1]
cwde cwde
shl eax,ROUND imul ebx
cdq sar eax,15 - ROUND
idiv ebx ; mov .dbx23,eax
; mov .dex12,eax
push eax push eax
mov ax,word[.e_y2] mov ax,word[.e_y2]
sub ax,word[.e_y1] sub ax,word[.e_y1]
cwde cwde
shl eax,ROUND imul ebx
cdq sar eax,15 - ROUND
idiv ebx ; mov .dbx23,eax
; mov .dey12,eax
push eax push eax
end if
end if
mov ax,.z2 mov ax,.z2
sub ax,.z1 sub ax,.z1
cwde cwde
shl eax,CATMULL_SHIFT imul ebx
cdq sar eax,15 - ROUND
idiv ebx
push eax push eax
; mov .dz12,eax
.bt_dx12_done: .bt_dx12_done:
mov bx,.y3 ; calc delta13 mov bx,.y3 ; calc delta13
@ -317,107 +257,90 @@ end if
@@: @@:
push edx ;dword 0 push edx ;dword 0
loop @b loop @b
; movq .dbx13,xmm7
; movdqu .dz13,xmm7
jmp .bt_dx13_done jmp .bt_dx13_done
.bt_dx13_make: .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 mov ax,.x3
sub ax,.x1 sub ax,.x1
cwde cwde
movsx ebx,bx imul ebx
shl eax,ROUND sar eax,15 - ROUND
cdq
idiv ebx
; mov .dx13,eax
push eax push eax
; mov .dx13,eax
if Ext=SSE if 1
sub esp,4*4
cvtsi2ss xmm3,ebx movd xmm0,ebx
; mov eax,255 pshuflw xmm0,xmm0,0
cvtsi2ss xmm4,[i255d] movq xmm1,[.e_x1]
divss xmm3,xmm4 movq xmm2,[.e_x3]
rcpss xmm3,xmm3 psubw xmm2,xmm1
; mulss xmm3,xmm4 movdqa xmm3,xmm2
shufps xmm3,xmm3,0 pmullw xmm2,xmm0
sub esp,16 pmulhw xmm3,xmm0
punpcklwd xmm2,xmm3
movd mm0,[.b_x1] psrad xmm2,15 - ROUND
movd mm1,[.b_x3] pshufd xmm2,xmm2,10110001b
movd mm2,[.e_x1] movdqu .dey13q,xmm2
movd mm3,[.e_x3] ; punpcklwd xmm4,xmm5
; psrad xmm4,15 - ROUND
pxor mm4,mm4 ; movq .tex_dx12,xmm4
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
else else
mov ax,word[.b_x3] mov ax,word[.b_x3]
sub ax,word[.b_x1] sub ax,word[.b_x1]
cwde cwde
shl eax,ROUND ; shl eax,ROUND
cdq ; cdq
idiv ebx imul ebx
; mov .dbx13,eax sar eax,15 - ROUND
; mov .dbx23,eax
push eax push eax
mov ax,word[.b_y3] mov ax,word[.b_y3]
sub ax,word[.b_y1] sub ax,word[.b_y1]
cwde cwde
shl eax,ROUND imul ebx
cdq sar eax,15 - ROUND
idiv ebx ; mov .dbx23,eax
; mov .dby13,eax
push eax push eax
mov ax,word[.e_x3] mov ax,word[.e_x3]
sub ax,word[.e_x1] sub ax,word[.e_x1]
cwde cwde
shl eax,ROUND imul ebx
cdq sar eax,15 - ROUND
idiv ebx ; mov .dbx23,eax
; mov .dex13,eax
push eax push eax
mov ax,word[.e_y3] mov ax,word[.e_y3]
sub ax,word[.e_y1] sub ax,word[.e_y1]
cwde cwde
shl eax,ROUND imul ebx
cdq sar eax,15 - ROUND
idiv ebx ; mov .dbx23,eax
; mov .dey13,eax
push eax push eax
end if
end if
mov ax,.z3 mov ax,.z3
sub ax,.z1 sub ax,.z1
cwde cwde
shl eax,CATMULL_SHIFT imul ebx
cdq sar eax,15 - ROUND
idiv ebx
; mov .dz13,eax
push eax push eax
; mov .dz13,eax
.bt_dx13_done: .bt_dx13_done:
mov bx,.y3 ; calc delta23 mov bx,.y3 ; calc delta23
sub bx,.y2 sub bx,.y2
jnz .bt_dx23_make jnz .bt_dx23_make
@ -426,108 +349,113 @@ end if
@@: @@:
push edx ;dword 0 push edx ;dword 0
loop @b loop @b
; movq .dbx23,xmm7
; movdqu .dz23,xmm7
jmp .bt_dx23_done jmp .bt_dx23_done
.bt_dx23_make: .bt_dx23_make:
movsx ebx,bx
mov eax,1 shl 15
cdq
idiv ebx
; push eax
mov ebx,eax
mov ax,.x3 mov ax,.x3
sub ax,.x2 sub ax,.x2
cwde cwde
movsx ebx,bx imul ebx
shl eax,ROUND sar eax,15 - ROUND
cdq
idiv ebx
; mov .dx23,eax
push eax push eax
; mov .dx23,eax
if Ext=SSE if Ext >= SSE2
sub esp,4*4
cvtsi2ss xmm3,ebx movd xmm0,ebx
; mov eax,255 pshuflw xmm0,xmm0,0
cvtsi2ss xmm4,[i255d] ;eax movq xmm1,[.e_x2]
divss xmm3,xmm4 movq xmm2,[.e_x3]
shufps xmm3,xmm3,0 psubw xmm2,xmm1
sub esp,16 movdqa xmm3,xmm2
pmullw xmm2,xmm0
movd mm0,[.b_x2] pmulhw xmm3,xmm0
movd mm1,[.b_x3] punpcklwd xmm2,xmm3
movd mm2,[.e_x2] psrad xmm2,15 - ROUND
movd mm3,[.e_x3] pshufd xmm2,xmm2,10110001b
movdqu .dey23q,xmm2
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
else else
mov ax,word[.b_x3] mov ax,word[.b_x3]
sub ax,word[.b_x2] sub ax,word[.b_x2]
cwde cwde
shl eax,ROUND ; shl eax,ROUND
cdq ; cdq
idiv ebx imul ebx
sar eax,15 - ROUND
; mov .dbx23,eax ; mov .dbx23,eax
push eax push eax
mov ax,word[.b_y3] mov ax,word[.b_y3]
sub ax,word[.b_y2] sub ax,word[.b_y2]
cwde cwde
shl eax,ROUND imul ebx
cdq sar eax,15 - ROUND
idiv ebx ; mov .dbx23,eax
; mov .dby23,eax
push eax push eax
mov ax,word[.e_x3] mov ax,word[.e_x3]
sub ax,word[.e_x2] sub ax,word[.e_x2]
cwde cwde
shl eax,ROUND imul ebx
cdq sar eax,15 - ROUND
idiv ebx ; mov .dbx23,eax
; mov .dex23,eax
push eax push eax
mov ax,word[.e_y3] mov ax,word[.e_y3]
sub ax,word[.e_y2] sub ax,word[.e_y2]
cwde cwde
shl eax,ROUND imul ebx
cdq sar eax,15 - ROUND
idiv ebx ; mov .dbx23,eax
; mov .dey23,eax
push eax push eax
end if end if
mov ax,.z3 mov ax,.z3
sub ax,.z2 sub ax,.z2
cwde cwde
shl eax,CATMULL_SHIFT imul ebx
cdq sar eax,15 - ROUND
idiv ebx
; mov .dz23,eax
push eax push eax
; sub esp,40 ; mov .dz23,eax
.bt_dx23_done: .bt_dx23_done:
movsx eax,.x1 movsx eax,.x1
shl eax,ROUND shl eax,ROUND
; mov .cx1,eax ; mov .cx1,eax
; mov .cx2,eax ; mov .cx2,eax
push eax eax push eax eax
; push 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] movsx eax,word[.b_x1]
shl eax,ROUND shl eax,ROUND
@ -554,16 +482,6 @@ end if
shl eax,ROUND shl eax,ROUND
mov .cey1,eax mov .cey1,eax
mov .cey2,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 movsx ecx,.y1
cmp cx,.y2 cmp cx,.y2
@ -874,6 +792,11 @@ if Ext >= SSE
else else
mov eax,.bx2 ; calc .dbx mov eax,.bx2 ; calc .dbx
sub eax,.bx1 sub eax,.bx1
cdq cdq
@ -1102,4 +1025,8 @@ end if
.bl_end: .bl_end:
mov esp,ebp mov esp,ebp
ret 56 ret 56
;Ext = SSE2
;the_zero:
;size_y_var:
;size_x_var:

View File

@ -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. ; with a few graphics effects demonstration.
; compiler : FASM ; compiler : FASM
; system : KolibriOS ; system : KolibriOS
; author : Macgub aka Maciej Guba ; author : Macgub aka Maciej Guba
; email : macgub3@wp.pl ; 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. ; Fell free to use this intro in your own distribution of KolibriOS.
; Special greetings to KolibriOS team . ; Special greetings to KolibriOS team .
; I hope because my demos Christian Belive will be near to each of You. ; 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) ; 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) ; now not exist
format binary as ""
SIZE_X equ 512 SIZE_X equ 512
SIZE_Y equ 512 ; ///// I want definitely SIZE_Y equ 512 ; ///// I want definitely
@ -39,13 +38,11 @@ SSE = 2
SSE2 = 3 SSE2 = 3
SSE3 = 4 SSE3 = 4
Ext = SSE3 ;Ext={ NON | MMX | SSE | SSE2 | SSE3 } Ext = SSE3 ;Ext={ NON | MMX | SSE | SSE2 | SSE3 }
; For now correct only SSE2 and SSE3 versions. if you have older CPU ; 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 ; use older versions of app. Probably ver 005 will be OK but it need
; re-edit to support new Kolibri features. ; 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 use32
org 0x0 org 0x0
db 'MENUET01' ; 8 byte id db 'MENUET01' ; 8 byte id
@ -98,7 +95,19 @@ START: ; start of execution
call normalize_all_light_vectors call normalize_all_light_vectors
call copy_lights ; to aligned float call copy_lights ; to aligned float
call init_triangles_normals2 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_point_normals
call init_envmap2 call init_envmap2
call init_envmap_cub call init_envmap_cub
call generate_texture2 call generate_texture2
@ -118,12 +127,13 @@ START: ; start of execution
cpuid cpuid
bt ecx,0 ; is sse3 on board? bt ecx,0 ; is sse3 on board?
jc @f jc @f
mov [max_dr_flg],12 mov byte[max_dr_flg],12
mov [isSSE3],0 mov [isSSE3],0
@@: @@:
end if end if
still:
still:
cmp [edit_flag],1 cmp [edit_flag],1
jne @f jne @f
mov eax,40 ; set events mask mov eax,40 ; set events mask
@ -828,6 +838,7 @@ end if
jmp still jmp still
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
;-------------------------PROCEDURES--------------------------------------------- ;-------------------------PROCEDURES---------------------------------------------
;-------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------
@ -838,6 +849,7 @@ include "3dmath.inc"
include "grd_line.inc" include "grd_line.inc"
include "b_procs.inc" include "b_procs.inc"
include "a_procs.inc" include "a_procs.inc"
include "chunks.inc"
include "grd_cat.inc" include "grd_cat.inc"
include "bump_tex.inc" include "bump_tex.inc"
include "grd_tex.inc" include "grd_tex.inc"
@ -879,7 +891,9 @@ edit: ; mmx required, edit mesh by vertex
imul edx,ecx imul edx,ecx
add ebx,edx add ebx,edx
push ebx push ebx
lea ecx,[ebx*2] mov ecx,ebx
shl ecx,2
; lea ecx,[ebx*2]
lea ebx,[ebx*3] lea ebx,[ebx*3]
cmp [dr_flag],12 cmp [dr_flag],12
@ -931,11 +945,12 @@ edit: ; mmx required, edit mesh by vertex
check_bar check_bar
jne .no_edit jne .no_edit
add ecx,[vertices_index_ptr] add ecx,[vertices_index_ptr]
mov cx,word[ecx] mov ecx,[ecx]
inc cx ; 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 eax,dword[.x_coord]
mov dword[edit_end_x],eax mov dword[edit_end_x],eax
@ -949,7 +964,7 @@ edit: ; mmx required, edit mesh by vertex
; add ecx,[vertices_index_ptr] ; add ecx,[vertices_index_ptr]
; mov cx,[ecx] ; mov cx,[ecx]
; inc cx ; inc cx
cmp [vertex_edit_no],0 ; cx ; vertex number cmp [vertex_edit_no],-1 ; cx ; vertex number
je .end je .end
push dword[.x_coord] push dword[.x_coord]
pop dword[edit_end_x] pop dword[edit_end_x]
@ -961,8 +976,8 @@ edit: ; mmx required, edit mesh by vertex
check_bar check_bar
jne .end jne .end
movzx esi,[vertex_edit_no] mov esi,[vertex_edit_no]
dec esi ; dec esi
lea esi,[esi*3] lea esi,[esi*3]
add esi,esi add esi,esi
add esi,[points_translated_ptr] add esi,[points_translated_ptr]
@ -996,8 +1011,8 @@ edit: ; mmx required, edit mesh by vertex
call rotary call rotary
; inject into vertex list ; inject into vertex list
movzx edi,[vertex_edit_no] mov edi,[vertex_edit_no]
dec edi ; dec edi
lea edi,[edi*3] lea edi,[edi*3]
shl edi,2 shl edi,2
add edi,[points_ptr] add edi,[points_ptr]
@ -1012,7 +1027,7 @@ edit: ; mmx required, edit mesh by vertex
mov dword[edit_end_x],0 mov dword[edit_end_x],0
mov [vertex_edit_no],0 mov [vertex_edit_no],-1
.no_edit: .no_edit:
.end: .end:
@ -1055,7 +1070,7 @@ alloc_buffer_mem:
mov ecx,[.temp] mov ecx,[.temp]
add ecx,ecx shl ecx,2
add ecx,256 add ecx,256
mov eax,68 mov eax,68
mov ebx,20 mov ebx,20
@ -1477,18 +1492,84 @@ ret
if Ext >= SSE2 if Ext >= SSE2
init_point_normals: init_point_normals:
;in:
; esi - tri_ch
; edi - t_ptr
.z equ dword [ebp-8] .z equ dword [ebp-8]
.y equ dword [ebp-12] .y equ dword [ebp-12]
.x equ [ebp-16] .x equ [ebp-16]
.point_number equ dword [ebp-28] .point_number equ dword [ebp-28]
.hit_faces equ dword [ebp-32] .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 push ebp
mov ebp,esp mov ebp,esp
sub esp,64 sub esp,64
and ebp,-16 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 edi,[points_normals_ptr]
mov .point_number,0 mov .point_number,edx
.ipn_loop: .ipn_loop:
movd xmm0,.point_number movd xmm0,.point_number
pshufd xmm0,xmm0,0 pshufd xmm0,xmm0,0
@ -1547,6 +1628,20 @@ init_point_normals:
mov edx,.point_number mov edx,.point_number
cmp edx,[points_count_var] cmp edx,[points_count_var]
jne .ipn_loop 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 add esp,64
pop ebp pop ebp
@ -1776,10 +1871,10 @@ draw_triangles:
emms emms
; update translated list MMX required ; update translated list MMX required
cmp [vertex_edit_no],0 cmp [vertex_edit_no],-1
je @f je @f
movzx eax,[vertex_edit_no] mov eax,[vertex_edit_no]
dec eax ; dec eax
movd mm0,[edit_end_x] movd mm0,[edit_end_x]
psubw mm0,[edit_start_x] psubw mm0,[edit_start_x]
lea eax,[eax*3] lea eax,[eax*3]
@ -2383,42 +2478,36 @@ draw_triangles:
push word .zz2 push word .zz2
push word .zz1 push word .zz1
mov esi, .point_index3 ; tex map coords fninit
shl esi,2 lea esi, .point_index3 ; env coords
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
mov edi,esp mov edi,esp
sub esp,24
mov ecx,3 mov ecx,3
@@: @@:
mov eax,dword[esi] mov eax,dword[esi]
lea eax,[eax*3]
shl eax,2 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] add eax,[points_normals_rot_ptr]
; texture x=(rotated point normal -> x * 255)+255 ; texture x=(rotated point normal -> x * 255)+255
fld dword[eax] fld dword[eax]
fimul [correct_tex] fimul [correct_tex]
fiadd [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 ; texture y=(rotated point normal -> y * 255)+255
fld dword[eax+4] fld dword[eax+4]
fimul [correct_tex] fimul [correct_tex]
fiadd [correct_tex] fiadd [correct_tex]
fistp word[edi+2] fistp word[edi-2]
and word[edi+2],0x7fff ; some objects need it and word[edi-2],0x7fff ; some objects need it
add edi,4
add esi,4 sub edi,8
sub esi,4
loop @b loop @b
mov eax, .xx1 mov eax, .xx1
@ -2434,18 +2523,7 @@ draw_triangles:
.bump_tex: .bump_tex:
push ebp push ebp
mov esi, .point_index3 ; tex map coords fninit
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]
push dword texmap push dword texmap
@ -2455,41 +2533,37 @@ draw_triangles:
push word .zz2 push word .zz2
push word .zz1 push word .zz1
lea esi, .index1x12 ; env coords
sub esp,12 lea ebx, .point_index1
sub esp,36
mov edi,esp mov edi,esp
mov ecx,3 mov ecx,3
@@: @@:
mov eax,dword[esi] mov eax,[ebx]
add eax,[points_normals_rot_ptr] 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 ; texture x=(rotated point normal -> x * 255)+255
fld dword[eax] fld dword[esi]
fimul [correct_tex] fimul [correct_tex]
fiadd [correct_tex] fiadd [correct_tex]
fistp word[edi] fistp word[edi+6] ; env coords
; texture y=(rotated point normal -> y * 255)+255 ; texture y=(rotated point normal -> y * 255)+255
fld dword[eax+4] fld dword[esi+4]
fimul [correct_tex] fimul [correct_tex]
fiadd [correct_tex] fiadd [correct_tex]
fistp word[edi+2] fistp word[edi+4]
add ebx,4
add edi,4 add edi,12
add esi,4
loop @b 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 eax,dword .xx1
mov ebx,dword .xx2 mov ebx,dword .xx2
mov ecx,dword .xx3 mov ecx,dword .xx3
@ -2861,138 +2935,110 @@ end if
ret ret
draw_handlers: draw_handlers:
; in eax - render model ; in eax - render model
push ebp push ebp
mov ebp,esp mov ebp,esp
; emms
.counter equ ebp-16 .fac equ dword[ebp-16]
.xres3m18 equ ebp-8 .xplus_scr equ ebp-8
.xres2m12 equ ebp-12 .xplus_index equ ebp-12
.dr_model equ dword[ebp-4] .dr_model equ dword[ebp-4]
sub esp,16
; init counter
sub esp,12
push dword 0
mov .dr_model,eax mov .dr_model,eax
movzx eax,word[size_x_var] movzx eax,word[size_x_var]
cmp .dr_model,12 cmp .dr_model,12
jge @f jge @f
lea ebx,[eax*3] lea ebx,[eax*3]
sub ebx,18 sub ebx,3*6
add eax,eax mov [.xplus_scr],ebx ; for scr 1st cause
sub eax,12 mov .fac,3
mov [.xres3m18],ebx jmp .in_r
mov [.xres2m12],eax
jmp .f
@@: @@:
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] lea ebx,[eax*4]
sub ebx,4*6 sub ebx,4*6
add eax,eax mov [.xplus_index],ebx ; index
sub eax,3*4
mov [.xres3m18],ebx
mov [.xres2m12],eax
.f:
xor ecx,ecx
mov eax,4 shl 16 + 4
movd xmm0,[size_y_var]
movd xmm1,eax
psubw xmm0,xmm1
pshuflw xmm0,xmm0,00000001b
.l:
mov esi,[points_translated_ptr] push ecx
.loop:
push esi
; DO culling AT FIRST
cmp [culling_flag],1 ; (if culling_flag = 1) cmp [culling_flag],1 ; (if culling_flag = 1)
jne .no_culling jne .no_culling
mov edi,[.counter] ; ********************************* mov edi,ecx ; *********************************
lea edi,[edi*3] lea edi,[edi*3]
shl edi,2 shl edi,2
add edi,[points_normals_rot_ptr] add edi,[points_normals_rot_ptr]
mov eax,[edi+8] ; check sign of z coof bt dword[edi+8],31
shr eax,31 jnc .skip
cmp eax,1
jnz .skip
.no_culling: .no_culling:
mov eax,[esi] mov esi,ecx
movzx ebx,ax ; ebx - x lea esi,[esi*3]
shr eax,16 ; eax - y add esi,esi
cmp eax,4 ; check if markers not exceedes screen add esi,[points_translated_ptr]
jle .skip movd xmm2,[esi]
cmp ebx,4 movd xmm3,[esi]
jle .skip pcmpgtw xmm2,xmm0
movzx edx,word[size_x_var] pcmpgtw xmm3,xmm1
sub edx,4 pxor xmm3,xmm2
movzx ecx,word[size_y_var] movd eax,xmm3
sub ecx,4 cmp eax,-1
cmp ebx,edx jne .skip
jge .skip
cmp eax,ecx
jge .skip
movzx edx,word[size_x_var] movzx eax,word[esi]
; sub ebx,3 movzx ebx,word[esi+2]
; sub eax,3 sub eax,2
imul eax,edx sub ebx,2
add eax,ebx movzx edx, word[size_x_var]
push eax imul ebx,edx
lea edi,[eax*3] add ebx,eax
cmp .dr_model,12 mov edi,ebx
jl @f imul ebx,.fac
add edi,[esp] shl edi,2
@@: add ebx,[screen_ptr]
add esp,4 add edi,[vertices_index_ptr]
lea eax,[eax*2] mov eax,ecx
; draw bar 6x6 cld
add edi,[screen_ptr]
add eax,dword[vertices_index_ptr]
mov edx,[.counter]
mov ecx,6 mov ecx,6
.l2:
.oop:
push ecx push ecx
mov ecx,6 mov ecx,6 ; draw bar
.l1:
.do: mov word[ebx],0
mov word[edi],0x0000 ;ax mov byte[ebx+2],0xff
mov byte[edi+2],0xff ;al stosd
mov word[eax],dx add ebx,.fac
add eax,2 loop .l1
cmp .dr_model,12 add ebx,[.xplus_scr]
jl @f add edi,[.xplus_index]
add edi,4
loop .do
jmp .ad
@@:
add edi,3
loop .do
.ad:
add edi,[.xres3m18]
add eax,[.xres2m12]
pop ecx pop ecx
loop .oop loop .l2
.skip: .skip:
pop esi pop ecx
add esi,6 inc ecx
inc dword[.counter]
mov ecx,[.counter]
cmp ecx,[points_count_var] cmp ecx,[points_count_var]
jng .loop jna .l
mov esp,ebp mov esp,ebp
pop ebp pop ebp
ret ret
fill_Z_buffer: fill_Z_buffer:
mov eax,0x70000000 mov eax,0x70000000
cmp [dr_flag],11 cmp [dr_flag],11
@ -3033,11 +3079,7 @@ read_tp_variables: ; read [triangles_count_var] and [points_count_va
xor ebp,ebp xor ebp,ebp
mov [points_count_var],ebx mov [points_count_var],ebx
mov [triangles_count_var],ebx mov [triangles_count_var],ebx
if USE_LFN = 0
mov esi,SourceFile
else
mov esi,[fptr] mov esi,[fptr]
end if
cmp [esi],word 4D4Dh cmp [esi],word 4D4Dh
je @f ;Must be legal .3DS file 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 mov edx,ecx
add esi,8 add esi,8
@@: @@:
lea ecx,[ecx*3]
add ebx,6 add ecx,ecx
add esi,12 add ebx,ecx
add ecx,ecx
add esi,ecx
; dec 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
@@: @@:
add esi,8 shl ecx,3
dec ecx add esi,ecx
jnz @b ; dec ecx
; jnz @b
; loop @b
; xor ecx,ecx ; xor ecx,ecx
add ebp,edx add ebp,edx
jmp .find4k jmp .find4k
@ -3198,8 +3244,9 @@ read_from_file:
add ebx,6 add ebx,6
add esi,12 add esi,12
dec ecx ; dec ecx
jnz @b ; jnz @b
loop @b
@@: @@:
; mov dword[points+ebx],-1 ; mov dword[points+ebx],-1
push edi push edi
@ -3227,14 +3274,17 @@ read_from_file:
add dword[edi-8],ebp add dword[edi-8],ebp
add dword[edi-4],ebp add dword[edi-4],ebp
add esi,8 add esi,8
dec ecx ; dec ecx
jnz @b ; jnz @b
loop @b
add ebp,edx add ebp,edx
jmp .find4k jmp .find4k
mov eax,-1 ;<---mark if OK mov eax,-1 ;<---mark if OK
.exit: .exit:
mov dword[edi],-1 mov dword[edi],-1
ret ret
alloc_mem_for_tp: alloc_mem_for_tp:
mov eax, 68 mov eax, 68
cmp [re_alloc_flag],1 cmp [re_alloc_flag],1
@ -3265,7 +3315,7 @@ alloc_mem_for_tp:
mov eax, 68 mov eax, 68
mov ecx, [triangles_count_var] mov ecx, [triangles_count_var]
lea ecx, [3+ecx*3] lea ecx, [6+ecx*3]
shl ecx, 2 shl ecx, 2
mov edx,[triangles_normals_ptr] mov edx,[triangles_normals_ptr]
int 0x40 ; -> allocate memory for triangles normals int 0x40 ; -> allocate memory for triangles normals
@ -3274,7 +3324,7 @@ alloc_mem_for_tp:
mov eax, 68 mov eax, 68
mov ecx, [points_count_var] mov ecx, [points_count_var]
lea ecx,[3+ecx*3] lea ecx,[6+ecx*3]
shl ecx, 2 shl ecx, 2
mov edx,[points_normals_ptr] mov edx,[points_normals_ptr]
int 0x40 int 0x40
@ -3284,13 +3334,14 @@ alloc_mem_for_tp:
mov eax, 68 mov eax, 68
; mov ebx, 12 ; mov ebx, 12
mov ecx, [points_count_var] mov ecx, [points_count_var]
lea ecx,[3+ecx*3] lea ecx,[10+ecx*3]
shl ecx, 2 shl ecx, 2
mov edx,[points_normals_rot_ptr] mov edx,[points_normals_rot_ptr]
int 0x40 int 0x40
mov [points_normals_rot_ptr], eax mov [points_normals_rot_ptr], eax
mov eax, 68 mov eax, 68
mov edx,[points_ptr] mov edx,[points_ptr]
int 0x40 int 0x40
mov [points_ptr], eax mov [points_ptr], eax
@ -3304,13 +3355,14 @@ alloc_mem_for_tp:
mov ebx, 12 mov ebx, 12
mov ecx, [points_count_var] mov ecx, [points_count_var]
shl ecx,2 shl ecx,2
add ecx,32
mov edx,[tex_points_ptr] mov edx,[tex_points_ptr]
int 0x40 int 0x40
mov [tex_points_ptr], eax mov [tex_points_ptr], eax
mov eax, 68 mov eax, 68
mov ecx, [points_count_var] mov ecx, [points_count_var]
inc ecx add ecx,10
shl ecx, 3 shl ecx, 3
mov edx,[points_translated_ptr] mov edx,[points_translated_ptr]
int 0x40 int 0x40
@ -3417,7 +3469,7 @@ write_info:
mov bx,[size_x_var] mov bx,[size_x_var]
shl ebx,16 shl ebx,16
add ebx,120*65536+70 ; [x start] *65536 + [y start] 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 xor edx,edx
int 0x40 int 0x40
@ -3467,7 +3519,7 @@ write_info:
int 40h int 40h
pop esi pop esi
add esi,4 add esi,4
cmp esi,12 cmp esi,16
jnz .nxxx jnz .nxxx
ret ret
; ********************************************* ; *********************************************