forked from KolibriOS/kolibrios
view3ds 0073 by macgub
git-svn-id: svn://kolibrios.org@8719 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
1c24cac315
commit
73122f1cb1
@ -198,24 +198,7 @@ ret
|
||||
;---------------------------- edi - pointer to vector -----
|
||||
;----------------------- out : none
|
||||
normalize_vector:
|
||||
if Ext = SSE2 | Ext = SSE | Ext = SSE3
|
||||
movups xmm0,[edi]
|
||||
andps xmm0,[zero_hgst_dd]
|
||||
movups xmm1,xmm0
|
||||
mulps xmm0,xmm0
|
||||
movhlps xmm2,xmm0
|
||||
addps xmm0,xmm2
|
||||
movaps xmm2,xmm0
|
||||
shufps xmm2,xmm2,11100001b
|
||||
addps xmm0,xmm2
|
||||
shufps xmm0,xmm0,0
|
||||
rsqrtps xmm0,xmm0
|
||||
mulps xmm0,xmm1
|
||||
movlps [edi],xmm0
|
||||
movhlps xmm0,xmm0
|
||||
movss [edi+8],xmm0
|
||||
end if
|
||||
if 0 ; Ext >= SSE3
|
||||
if Ext >= SSE3
|
||||
movups xmm0,[edi]
|
||||
andps xmm0,[zero_hgst_dd]
|
||||
movups xmm1,xmm0
|
||||
@ -227,8 +210,7 @@ if 0 ; Ext >= SSE3
|
||||
movlps [edi],xmm0
|
||||
movhlps xmm0,xmm0
|
||||
movss [edi+8],xmm0
|
||||
end if
|
||||
if Ext < SSE
|
||||
else
|
||||
|
||||
fninit
|
||||
fld dword [edi+vec_x]
|
||||
|
@ -312,9 +312,11 @@ stencil_line:
|
||||
sub ecx,.x1
|
||||
movss xmm2,.z1 ; cz
|
||||
.ccalc:
|
||||
; movss xmm1,xmm2
|
||||
comiss xmm2,dword[esi]
|
||||
jg @f
|
||||
movss xmm1,xmm2
|
||||
cmpltss xmm1,dword[esi]
|
||||
movd eax,xmm1
|
||||
cmp eax,-1
|
||||
jnz @f
|
||||
movss dword[esi],xmm2
|
||||
@@:
|
||||
add esi,4
|
||||
|
@ -1,3 +1,227 @@
|
||||
;===============================================================
|
||||
do_edges_list:
|
||||
push ebp
|
||||
mov ebp,esp
|
||||
sub esp,32
|
||||
|
||||
.ed_cnt equ [ebp-4]
|
||||
.edd_ptr equ [ebp-8]
|
||||
.counter equ [ebp-12]
|
||||
|
||||
|
||||
mov ebx,[edges_ptr]
|
||||
mov eax,[triangles_ptr]
|
||||
mov ecx,[triangles_count_var]
|
||||
@@:
|
||||
movdqu xmm0,[eax]
|
||||
movq [ebx],xmm0
|
||||
pshufd xmm0,xmm0,11001001b
|
||||
movq [ebx+8],xmm0
|
||||
pshufd xmm0,xmm0,11001001b
|
||||
movq [ebx+16],xmm0
|
||||
add ebx,24
|
||||
add eax,12
|
||||
loop @b
|
||||
|
||||
|
||||
mov ebx,[edges_ptr]
|
||||
mov ecx,[triangles_count_var]
|
||||
lea ecx,[ecx*3]
|
||||
.mxd:
|
||||
mov eax,[ebx]
|
||||
cmp eax,[ebx+4]
|
||||
jl @f
|
||||
movq xmm0,[ebx]
|
||||
pshufd xmm0,xmm0,11100001b
|
||||
movq [ebx],xmm0
|
||||
@@:
|
||||
add ebx,8
|
||||
loop .mxd
|
||||
|
||||
|
||||
; insert sort
|
||||
mov ebx,[edges_ptr]
|
||||
mov ecx,[triangles_count_var]
|
||||
lea ecx,[ecx*3]
|
||||
|
||||
mov esi,ecx
|
||||
shl esi,3
|
||||
add esi,ebx
|
||||
|
||||
.ccc:
|
||||
mov eax,[ebx+8]
|
||||
cmp eax,[ebx]
|
||||
jge .g
|
||||
movq xmm0,[ebx+8]
|
||||
push ebx
|
||||
.c:
|
||||
cmp ebx,esi
|
||||
jge .done
|
||||
cmp ebx,[edges_ptr]
|
||||
jl .done
|
||||
cmp eax,[ebx]
|
||||
jge .done
|
||||
movq xmm7,[ebx]
|
||||
movq [ebx+8],xmm7
|
||||
sub ebx,8
|
||||
jnz .c
|
||||
add ebx,8
|
||||
.done:
|
||||
movq [ebx+8],xmm0
|
||||
.p:
|
||||
pop ebx
|
||||
.g:
|
||||
add ebx,8
|
||||
dec ecx
|
||||
cmp ecx,1
|
||||
jnz .ccc
|
||||
|
||||
|
||||
; insert sort again
|
||||
mov ebx,[edges_ptr]
|
||||
mov ecx,[triangles_count_var]
|
||||
lea ecx,[ecx*3]
|
||||
mov esi,ecx
|
||||
shl esi,3
|
||||
add esi,ebx
|
||||
|
||||
.count:
|
||||
push ecx
|
||||
push ebx
|
||||
xor ecx,ecx
|
||||
mov eax,[ebx] ; count
|
||||
.aa:
|
||||
inc ecx
|
||||
add ebx,8
|
||||
cmp ebx,esi
|
||||
jge .br ; break
|
||||
cmp eax,[ebx]
|
||||
je .aa
|
||||
mov .counter,ecx
|
||||
pop ebx
|
||||
mov edi,ebx
|
||||
sub edi,8
|
||||
mov edx,[ebx+8]
|
||||
.ccc2:
|
||||
|
||||
cmp ebx,esi
|
||||
jbe @f
|
||||
add esp,4
|
||||
jmp .ff
|
||||
@@:
|
||||
mov eax,[ebx+12]
|
||||
mov edx,[ebx+8]
|
||||
cmp eax,[ebx+4]
|
||||
jge .gg2
|
||||
movq xmm0,[ebx+8]
|
||||
push ebx
|
||||
.c2:
|
||||
cmp eax,[ebx+4]
|
||||
jge .done2
|
||||
movq xmm7,[ebx]
|
||||
movq [ebx+8],xmm7
|
||||
|
||||
sub ebx,8
|
||||
cmp ebx,edi
|
||||
jz @f
|
||||
cmp [ebx+8],edx
|
||||
jz .c2
|
||||
@@:
|
||||
.done2:
|
||||
add ebx,8
|
||||
movq [ebx],xmm0
|
||||
|
||||
.p2:
|
||||
pop ebx
|
||||
.gg2:
|
||||
add ebx,8
|
||||
dec ecx
|
||||
cmp ecx,1
|
||||
jnz .ccc2
|
||||
|
||||
pop ecx
|
||||
sub ecx,.counter
|
||||
add ebx,8
|
||||
ja .count
|
||||
|
||||
jmp .ff
|
||||
.br: ;break
|
||||
add esp,8
|
||||
.ff:
|
||||
|
||||
; count edges
|
||||
mov ecx,0
|
||||
mov edx,[triangles_count_var]
|
||||
lea edx,[edx*3]
|
||||
mov ebx,[edges_ptr]
|
||||
; mov esi,edx
|
||||
; shl esi,3
|
||||
; add esi,[edges_ptr]
|
||||
.nx:
|
||||
movq xmm0,[ebx]
|
||||
add ebx,8
|
||||
; cmp ebx,esi
|
||||
; jae @f
|
||||
movq xmm1,[ebx]
|
||||
; @@:
|
||||
pcmpeqd xmm0,xmm1
|
||||
pmovmskb eax,xmm0
|
||||
and eax,0xff
|
||||
cmp eax,0xff
|
||||
jz @f
|
||||
inc ecx
|
||||
@@:
|
||||
dec edx
|
||||
jnz .nx
|
||||
|
||||
|
||||
mov .ed_cnt,ecx
|
||||
lea ecx,[ecx*3]
|
||||
shl ecx,2
|
||||
add ecx,65536
|
||||
mov ebx,12
|
||||
mov eax,68
|
||||
mov edx,.edd_ptr
|
||||
int 0x40 ; -> allocate memory to triangles
|
||||
mov .edd_ptr, eax ; -> eax = pointer to allocated mem
|
||||
|
||||
|
||||
|
||||
mov ebx,[edges_ptr]
|
||||
mov ecx,[triangles_count_var]
|
||||
lea ecx,[ecx*3]
|
||||
.seek:
|
||||
movq xmm0,[ebx]
|
||||
movq xmm1,[ebx+8]
|
||||
pcmpeqd xmm1,xmm0
|
||||
pmovmskb edx,xmm1
|
||||
and edx,0xff
|
||||
cmp edx,0xff
|
||||
je @f
|
||||
movq [eax],xmm0
|
||||
add eax,8
|
||||
@@:
|
||||
add ebx,8
|
||||
loop .seek
|
||||
|
||||
mov eax,68
|
||||
mov ebx,13
|
||||
mov ecx,[edges_ptr]
|
||||
int 0x40 ; release old edges ptr
|
||||
|
||||
|
||||
mov eax,.edd_ptr
|
||||
mov ecx,.ed_cnt
|
||||
mov [edges_ptr],eax
|
||||
mov [edges_count],ecx
|
||||
|
||||
mov esp,ebp
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
;=======================
|
||||
|
||||
|
||||
do_sinus:
|
||||
.x equ [ebp-8]
|
||||
.y equ [ebp-12]
|
||||
@ -19,21 +243,53 @@ do_sinus:
|
||||
cld
|
||||
rep stosd
|
||||
pop edi
|
||||
; movzx eax,[sinus_flag]
|
||||
; mov edx,10
|
||||
; mul edx
|
||||
; mov [sin_amplitude],eax
|
||||
; mov [sin_frq],eax
|
||||
fninit
|
||||
;if Ext = SSE2
|
||||
; movups xmm1,[const0123] ; xmm1 - init values
|
||||
; mov eax,0x000000ff
|
||||
; movd xmm2,eax
|
||||
; shufps xmm2,xmm2,0 ; xmm2 - mask value
|
||||
; mov eax,4
|
||||
; movd xmm3,eax
|
||||
; shufps xmm3,xmm3,0
|
||||
.again:
|
||||
if 0
|
||||
fild dword .x
|
||||
fidiv [sin_frq]
|
||||
fsin
|
||||
fimul [sin_amplitude]
|
||||
fiadd dword .y
|
||||
fistp dword .new_y
|
||||
else
|
||||
fild dword .x
|
||||
fmul [sin_frq]
|
||||
fistp dword .temp
|
||||
mov eax, .temp
|
||||
; mov bx, [angle_x]
|
||||
; add bx, [angle_y]
|
||||
; movzx ebx,bx
|
||||
; shr ebx,1 ; change phase
|
||||
; add eax,ebx
|
||||
|
||||
|
||||
and eax, 0x000000ff
|
||||
|
||||
; cdq
|
||||
; mul [sin_frq]
|
||||
; and eax,0x000000ff
|
||||
; and ax,0x00ff
|
||||
; cwde
|
||||
|
||||
fld dword [sin_tab+eax*4]
|
||||
fimul dword [sin_amplitude]
|
||||
fiadd dword .y
|
||||
fistp dword .new_y
|
||||
|
||||
end if
|
||||
mov eax,.new_y
|
||||
or eax,eax
|
||||
jl .skip
|
||||
@ -244,7 +500,109 @@ end if
|
||||
|
||||
ret
|
||||
|
||||
;align 16
|
||||
; emboss_bias:
|
||||
; dw 128, 128, 128, 128, 128, 128, 128, 128
|
||||
|
||||
if 0 ; old emb proc
|
||||
|
||||
; emboss - after drawing all,
|
||||
; transfer screen buffer into bump map
|
||||
; and draw two bump triangles
|
||||
; *************************************
|
||||
mov esi,screen
|
||||
mov edi,bumpmap2
|
||||
mov ecx,TEXTURE_SIZE/3
|
||||
cld
|
||||
if Ext=NON
|
||||
xor eax,eax
|
||||
xor bh,bh
|
||||
xor dh,dh
|
||||
@@:
|
||||
lodsb
|
||||
movzx bx,al
|
||||
lodsb
|
||||
movzx dx,al
|
||||
lodsb
|
||||
add ax,bx
|
||||
add ax,dx
|
||||
; cwd
|
||||
; div [i3]
|
||||
;; push ax
|
||||
;; pop bx
|
||||
;; shr bx,3
|
||||
;; shr ax,2
|
||||
;; add ax,bx
|
||||
|
||||
lea eax,[eax*5]
|
||||
shr ax,4
|
||||
|
||||
stosb
|
||||
loop @b
|
||||
else
|
||||
emms
|
||||
pxor mm1,mm1
|
||||
mov ebx,0x0000ffff
|
||||
@@:
|
||||
movd mm0,[esi]
|
||||
punpcklbw mm0,mm1
|
||||
movq mm2,mm0
|
||||
psrlq mm2,16
|
||||
movq mm3,mm0
|
||||
psrlq mm3,32
|
||||
paddw mm0,mm2
|
||||
paddw mm0,mm3
|
||||
|
||||
|
||||
movd eax,mm0
|
||||
and eax,ebx
|
||||
lea eax,[eax*5]
|
||||
shr ax,4
|
||||
stosb
|
||||
add esi,3
|
||||
loop @b
|
||||
|
||||
end if
|
||||
push ebp
|
||||
|
||||
push dword 0 ; env coords
|
||||
push word 0
|
||||
push word SIZE_X
|
||||
push word SIZE_Y
|
||||
push dword 0
|
||||
push dword 0 ; bump coords
|
||||
push word SIZE_X
|
||||
push word SIZE_Y
|
||||
push word 0
|
||||
mov eax,SIZE_Y
|
||||
mov ebx,SIZE_X*65536+0
|
||||
xor ecx,ecx
|
||||
mov edx,bumpmap2
|
||||
mov esi,envmap
|
||||
mov edi,screen
|
||||
call bump_triangle
|
||||
|
||||
push dword SIZE_X shl 16 + SIZE_Y ; env coords
|
||||
push word 0
|
||||
push word SIZE_X
|
||||
push word SIZE_Y
|
||||
push word 0
|
||||
push dword SIZE_X shl 16 + SIZE_Y ; bump coords
|
||||
push word 0
|
||||
push word SIZE_X
|
||||
push word SIZE_Y
|
||||
push word 0
|
||||
mov eax,SIZE_Y
|
||||
mov ebx,SIZE_X * 65536+0
|
||||
mov ecx,SIZE_X shl 16 + SIZE_Y
|
||||
mov edx,bumpmap2
|
||||
mov esi,envmap
|
||||
mov edi,screen
|
||||
call bump_triangle
|
||||
|
||||
pop ebp
|
||||
ret
|
||||
end if
|
||||
;********************************EMBOSS DONE*******************************
|
||||
|
||||
|
||||
|
@ -60,25 +60,24 @@ calc_one_col:
|
||||
; stack - other parameters
|
||||
; out - eax - 0x00rrggbb
|
||||
.dot_prd equ dword[ebp+4] ; dot product - cos x - not now
|
||||
.min_col_r equ [ebp+8] ; minimum color - ambient
|
||||
.min_col_r equ word[ebp+8] ; minimum color - ambient
|
||||
.min_col_g equ word[ebp+10]
|
||||
.min_col_b equ word[ebp+12]
|
||||
.max_col_r equ [ebp+14] ; maximum color - specular
|
||||
.max_col_r equ word[ebp+14] ; maximum color - specular
|
||||
.max_col_g equ word[ebp+16]
|
||||
.max_col_b equ word[ebp+18]
|
||||
.org_col_r equ [ebp+20] ; orginal color - diffuse
|
||||
.org_col_r equ word[ebp+20] ; orginal color - diffuse
|
||||
.org_col_g equ word[ebp+22]
|
||||
.org_col_b equ word[ebp+24]
|
||||
.n equ word[ebp+26] ; shines - not implemented
|
||||
.temp equ word[ebp-2]
|
||||
.color_sum_r equ [ebp-6]
|
||||
.color_sum_g equ [ebp-10]
|
||||
.color_sum_b equ [ebp-14]
|
||||
.color_sum_r equ dword[ebp-6]
|
||||
.color_sum_g equ dword[ebp-10]
|
||||
.color_sum_b equ dword[ebp-14]
|
||||
; color = ambient+cos(x)*diffuse+(cos(x)^n)*specular
|
||||
mov ebp,esp
|
||||
sub esp,14
|
||||
|
||||
|
||||
mov ax,.min_col_r
|
||||
add ax,.max_col_r
|
||||
add ax,.org_col_r
|
||||
@ -96,38 +95,8 @@ calc_one_col:
|
||||
add ax,.org_col_b
|
||||
cwde
|
||||
mov .color_sum_b,eax
|
||||
if 0
|
||||
|
||||
|
||||
movq xmm0,.min_col_r
|
||||
movq xmm1,.max_col_r
|
||||
movq xmm2,.org_col_r
|
||||
packuswb xmm0,[the_zero]
|
||||
packuswb xmm1,[the_zero]
|
||||
packuswb xmm2,[the_zero]
|
||||
punpcklbw xmm0,xmm1
|
||||
punpcklbw xmm2,[the_zero]
|
||||
packusdw xmm2,[the_zero]
|
||||
cvtdq2ps xmm0,xmm0
|
||||
cvtdq2ps xmm1,xmm1
|
||||
cvtdq2ps xmm2,xmm2
|
||||
haddps xmm0,xmm0
|
||||
haddps xmm1,xmm1
|
||||
haddps xmm2,xmm2
|
||||
haddps xmm0,xmm0
|
||||
haddps xmm1,xmm1
|
||||
haddps xmm2,xmm2
|
||||
|
||||
cvtss2si eax,xmm0
|
||||
cvtss2si ebx,xmm1
|
||||
cvtss2si ecx,xmm2
|
||||
mov .color_sum_r,eax
|
||||
mov .color_sum_g,ebx
|
||||
mov .color_sum_b,ecx
|
||||
|
||||
|
||||
end if
|
||||
|
||||
; fld .dot_prd
|
||||
; fild .n
|
||||
; fxch st1
|
||||
@ -154,7 +123,7 @@ end if
|
||||
faddp ; st0=first piece of col, st1=dot_pr^n..
|
||||
fiadd .min_col_b
|
||||
fimul .max_col_b
|
||||
fidiv dword .color_sum_b
|
||||
fidiv .color_sum_b
|
||||
fistp .temp
|
||||
movzx eax,.temp
|
||||
shl eax,16
|
||||
@ -166,19 +135,19 @@ end if
|
||||
faddp
|
||||
fiadd .min_col_g
|
||||
fimul .max_col_g
|
||||
fidiv dword .color_sum_g
|
||||
fidiv .color_sum_g
|
||||
fistp .temp
|
||||
mov ax,.temp
|
||||
mov ah,al
|
||||
shl eax,8
|
||||
|
||||
fimul word .max_col_r
|
||||
fild word .org_col_r
|
||||
fimul .max_col_r
|
||||
fild .org_col_r
|
||||
fmulp st2,st
|
||||
faddp
|
||||
fiadd word .min_col_r
|
||||
fimul word .max_col_r
|
||||
fidiv dword .color_sum_r
|
||||
fiadd .min_col_r
|
||||
fimul .max_col_r
|
||||
fidiv .color_sum_r
|
||||
fistp .temp
|
||||
mov ax,.temp ;eax - 0xbbgg00rr
|
||||
; mov ah,al
|
||||
|
@ -1,12 +1,15 @@
|
||||
; DATA AREA ************************************
|
||||
|
||||
i3 dw 3
|
||||
i6 dd 6
|
||||
i12 dd 12
|
||||
i36 dd 36
|
||||
i256 dw 256
|
||||
i255d dd 255
|
||||
dot_max dd 1.0 ; dot product max and min
|
||||
dot_min dd 0.0
|
||||
env_const dd 1.05
|
||||
correct_tex dw 255
|
||||
tex_x_div2 dw TEX_X / 2
|
||||
tex_y_div2 dw TEX_Y / 2
|
||||
xobs dw 0 ;SIZE_X / 2 ;200 ;observer = camera
|
||||
@ -54,6 +57,7 @@
|
||||
points_ptr dd 0
|
||||
points_rotated_ptr dd 0
|
||||
points_translated_ptr dd 0
|
||||
edges_ptr dd 0
|
||||
screen_ptr dd 0
|
||||
Zbuffer_ptr dd 0
|
||||
vertices_index_ptr dd 0
|
||||
@ -64,6 +68,9 @@
|
||||
edit_end_x:
|
||||
dw 0
|
||||
edit_end_y dw 0
|
||||
x_start: dw 20
|
||||
y_start: dw 20
|
||||
|
||||
mouse_state dd 0
|
||||
|
||||
|
||||
@ -343,9 +350,19 @@ base_vector:
|
||||
if Ext=SSE3
|
||||
db ' (SSE3)'
|
||||
end if
|
||||
db ' 0.072',0
|
||||
db ' 0.073',0
|
||||
labellen:
|
||||
STRdata db '-1 '
|
||||
lab_vert:
|
||||
db 'Vertices count: '
|
||||
lab_vert_end:
|
||||
lab_tr:
|
||||
db 'Faces count: '
|
||||
lab_tr_end:
|
||||
lab_ed:
|
||||
db 'Edges count: '
|
||||
lab_ed_end:
|
||||
|
||||
|
||||
all_lights_size dw lightsend-lights
|
||||
|
||||
@ -410,6 +427,8 @@ lightsend:
|
||||
|
||||
|
||||
align 16
|
||||
abs_mask:
|
||||
dd 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff
|
||||
emboss_bias:
|
||||
dw 128, 128, 128, 128, 128, 128, 128, 128
|
||||
zero_hgst_dd:
|
||||
@ -465,21 +484,9 @@ align 8
|
||||
col3 dd ?
|
||||
scale dd ? ; help scale variable
|
||||
|
||||
;==
|
||||
triangles_count_var dd ?
|
||||
points_count_var dd ?
|
||||
|
||||
; size_y_var:
|
||||
; yres_var dw ?
|
||||
|
||||
; size_x_var:
|
||||
; xres_var dw ?
|
||||
x_start:
|
||||
dw ?
|
||||
y_start:
|
||||
dw ?
|
||||
|
||||
;===
|
||||
points_count_var dd ? ;
|
||||
triangles_count_var dd ? ; dont change order
|
||||
edges_count dd ? ;
|
||||
|
||||
point_index1 dd ? ;-\
|
||||
point_index2 dd ? ; } don't change order
|
||||
|
@ -1,643 +1,115 @@
|
||||
;-procedure draws smooth shaded lines (I mean interpolation 24 bit--
|
||||
;-color), with z coord interpolation--------------------------------
|
||||
;-author: Maciej Guba (www.macgub.hekko.pl)-------------------------
|
||||
;-in : -------------------------------------------------------------
|
||||
;----- edi - pointer to screen buffer ------------------------------
|
||||
;----- esi - pointer to Z buffer -----------------------------------
|
||||
;------ constans : SIZE_X, SIZE_Y - screen width and height---------
|
||||
;----------------- ROUND - fixed point shift------------------------
|
||||
;------ other parameters via stack----------------------------------
|
||||
smooth_line:
|
||||
.x1 equ ebp+4
|
||||
.y1 equ ebp+6
|
||||
.z1 equ ebp+8
|
||||
.r1 equ ebp+10
|
||||
.g1 equ ebp+12
|
||||
.b1 equ ebp+14
|
||||
.x2 equ ebp+16
|
||||
.y2 equ ebp+18
|
||||
.z2 equ ebp+20
|
||||
.r2 equ ebp+22
|
||||
.g2 equ ebp+24
|
||||
.b2 equ ebp+26
|
||||
; Line drawing procedure by Pablo Reda.
|
||||
; Gouraud extension by Maciej Guba.
|
||||
;****************************************************
|
||||
line_grd: ; eax=x1 ebx=y1 ecx=x2 edx=y2
|
||||
; xmm0 - color1 argb as 4 dword float
|
||||
; xmm1 - color2 argb as 4 dword float
|
||||
; xmm2 - z1 as dword float
|
||||
; xmm3 - z2 as dword float
|
||||
; mm0 - Z buffer
|
||||
; mm1 - screen buffer
|
||||
; mm2 - screen width
|
||||
|
||||
|
||||
.line_lenght equ ebp-2
|
||||
.delta equ ebp-6
|
||||
.delta_x equ ebp-10
|
||||
.delta_y equ ebp-14
|
||||
.dr equ ebp-18
|
||||
.dg equ ebp-22
|
||||
.db equ ebp-26
|
||||
.dz equ ebp-30
|
||||
.cr equ ebp-34
|
||||
.cg equ ebp-38
|
||||
.cb equ ebp-42
|
||||
.cz equ ebp-46
|
||||
cmp ebx,edx
|
||||
; je horizontal_grd
|
||||
jg .noswap
|
||||
xchg eax,ecx
|
||||
xchg ebx,edx
|
||||
movaps xmm7,xmm0
|
||||
movaps xmm0,xmm1
|
||||
movaps xmm1,xmm7
|
||||
movaps xmm7,xmm2
|
||||
movaps xmm2,xmm3
|
||||
movaps xmm3,xmm7
|
||||
.noswap:
|
||||
|
||||
;.line_lenght equ ebp-48
|
||||
.screen equ ebp-52
|
||||
.zbuffer equ ebp-56
|
||||
.ccoord equ ebp-60 ;current coordinate
|
||||
.czbuf equ ebp-64
|
||||
.cscr equ ebp-68
|
||||
.xres equ ebp-72
|
||||
.yres equ ebp-76
|
||||
.xresm1 equ ebp-80
|
||||
.yresm1 equ ebp-84
|
||||
.xresp1 equ ebp-88
|
||||
.yresp1 equ ebp-92
|
||||
.xres3 equ ebp-96
|
||||
.xres4 equ ebp-100
|
||||
|
||||
macro .update_cur_var
|
||||
{
|
||||
if Ext=NON
|
||||
mov ebx,[.dz]
|
||||
add [.cz],ebx
|
||||
mov ebx,[.dr]
|
||||
add [.cr],ebx
|
||||
mov ebx,[.dg]
|
||||
add [.cg],ebx
|
||||
mov ebx,[.db]
|
||||
add [.cb],ebx
|
||||
elseif Ext=MMX
|
||||
movq mm0,[.cz]
|
||||
movq mm1,[.cg]
|
||||
paddd mm0,mm2 ;[.dz]
|
||||
paddd mm1,mm3 ;[.dg]
|
||||
movq [.cz],mm0
|
||||
movq [.cg],mm1
|
||||
elseif Ext >= SSE2
|
||||
; movups xmm1,[.cz]
|
||||
paddd xmm1,xmm0
|
||||
; movups [.cz],xmm1
|
||||
end if
|
||||
}
|
||||
macro .draw_pixel
|
||||
{
|
||||
mov [esi],ebx ; actualize Z buffer
|
||||
if Ext>=SSE2
|
||||
movaps xmm7,xmm1 ;[.cb] ;;xmm1
|
||||
shufps xmm7,xmm7,00111001b
|
||||
psrld xmm7,ROUND
|
||||
packssdw xmm7,xmm7
|
||||
packuswb xmm7,xmm7
|
||||
pand xmm7,xmm6 ;[.mask]
|
||||
movd [edi],xmm7
|
||||
else
|
||||
|
||||
mov eax,[.cb]
|
||||
sar eax,ROUND
|
||||
mov [edi],al
|
||||
; and eax,0x000000ff ; clean unused bits
|
||||
mov ebx,[.cg]
|
||||
sar ebx,ROUND
|
||||
mov [edi+1],bl
|
||||
; mov ah,bl
|
||||
mov edx,[.cr]
|
||||
sar edx,ROUND
|
||||
mov [edi+2],dl
|
||||
end if
|
||||
; shl ebx,16
|
||||
; or eax,ebx
|
||||
; mov [edi],eax
|
||||
}
|
||||
macro .sort
|
||||
{
|
||||
|
||||
if Ext >= MMX
|
||||
movq mm0,[.x1]
|
||||
movq mm1,[.x2]
|
||||
movq [.x1],mm1
|
||||
movq [.x2],mm0
|
||||
else
|
||||
mov edx,[.x1]
|
||||
xchg edx,[.x2]
|
||||
mov [.x1],edx
|
||||
mov edx,[.z1]
|
||||
xchg edx,[.z2]
|
||||
mov [.z1],edx
|
||||
end if
|
||||
mov edx,[.g1]
|
||||
xchg edx,[.g2]
|
||||
mov [.g1],edx
|
||||
}
|
||||
cvtsi2ss xmm7,eax
|
||||
cvtsi2ss xmm6,ebx
|
||||
cvtsi2ss xmm5,ecx
|
||||
cvtsi2ss xmm4,edx
|
||||
subss xmm7,xmm5
|
||||
subss xmm6,xmm4
|
||||
andps xmm7,[abs_mask] ; 0x7fff
|
||||
andps xmm6,[abs_mask] ; 0x7fff
|
||||
maxss xmm7,xmm6 ; xmm7 - delta
|
||||
shufps xmm7,xmm7,0
|
||||
movaps xmm6,xmm3
|
||||
rcpps xmm7,xmm7
|
||||
subss xmm6,xmm2
|
||||
mulss xmm6,xmm7 ; xmm6 - delta z
|
||||
movaps xmm5,xmm1
|
||||
subps xmm5,xmm0
|
||||
mulps xmm5,xmm7 ; xmm5 - delta col argb
|
||||
|
||||
|
||||
|
||||
emms
|
||||
mov ebp,esp
|
||||
sub esp,128
|
||||
mov eax,[.x1] ; check if parameters exceedes screen area
|
||||
mov ebx,[.x2]
|
||||
or eax,ebx
|
||||
test eax,80008000h
|
||||
jne .end_line
|
||||
movzx edx,word [size_x_var]
|
||||
mov [.xres],edx
|
||||
dec edx
|
||||
movzx ecx,word [size_y_var]
|
||||
mov [.yres],ecx
|
||||
dec ecx
|
||||
cmp word[.x1],dx ;SIZE_X
|
||||
jg .end_line
|
||||
cmp word[.x2],dx ;SIZE_X
|
||||
jg .end_line
|
||||
cmp word[.y1],cx ;SIZE_Y
|
||||
jg .end_line
|
||||
cmp word[.y2],cx ;SIZE_Y
|
||||
jg .end_line
|
||||
|
||||
mov edx,[.xres]
|
||||
shl edx,2
|
||||
mov [.xres4],edx
|
||||
shr edx,2
|
||||
lea edx,[edx*3]
|
||||
mov [.xres3],edx
|
||||
mov edx,[.xres]
|
||||
mov ecx,[.yres]
|
||||
dec edx
|
||||
dec ecx
|
||||
mov [.xresm1],edx
|
||||
mov [.yresm1],ecx
|
||||
add edx,2
|
||||
add ecx,2
|
||||
mov [.xresp1],edx
|
||||
mov [.yresp1],ecx
|
||||
|
||||
mov [.screen],edi
|
||||
mov cx,[.x1]
|
||||
cmp cx,[.x2]
|
||||
je .vertical_l
|
||||
mov cx,[.y1]
|
||||
cmp cx,[.y2]
|
||||
je .horizontal_l
|
||||
mov ax,[.x1]
|
||||
sub ax,[.x2]
|
||||
cmp ax,0
|
||||
jg @f
|
||||
neg ax ; calc absolute value
|
||||
@@:
|
||||
mov [.delta_x],ax
|
||||
mov bx,[.y1]
|
||||
sub bx,[.y2]
|
||||
cmp bx,0
|
||||
jg @f
|
||||
neg bx
|
||||
@@:
|
||||
mov [.delta_y],bx
|
||||
cmp ax,bx
|
||||
je .deg45_l
|
||||
jl .more_vertical_l
|
||||
jg .more_horizon_l
|
||||
jmp .end_line
|
||||
;
|
||||
.horizontal_l:
|
||||
mov ax,[.x1]
|
||||
mov bx,[.x2]
|
||||
cmp bx,ax
|
||||
jge @f
|
||||
|
||||
.sort
|
||||
@@:
|
||||
|
||||
mov bx,[.x2]
|
||||
sub bx,[.x1]
|
||||
movsx ebx,bx
|
||||
cmp ebx,0 ;line lenght equql 0
|
||||
je .end_line
|
||||
mov [.delta_x],ebx
|
||||
|
||||
call .calc_delta
|
||||
|
||||
mov eax,[.xres] ;SIZE_X
|
||||
movsx ebx,word[.y1]
|
||||
mul ebx
|
||||
add esi,eax
|
||||
lea eax,[eax*3]
|
||||
add esi,eax
|
||||
add edi,eax
|
||||
movsx eax,word[.x1]
|
||||
add esi,eax
|
||||
lea eax,[eax*3]
|
||||
add edi,eax
|
||||
add esi,eax
|
||||
|
||||
mov ecx,[.delta_x]
|
||||
|
||||
movsx ebx,word[.r1]
|
||||
shl ebx,ROUND
|
||||
mov [.cr],ebx
|
||||
movsx ebx,word[.g1]
|
||||
shl ebx,ROUND
|
||||
mov [.cg],ebx
|
||||
movsx ebx,word[.b1]
|
||||
shl ebx,ROUND
|
||||
mov [.cb],ebx
|
||||
movsx ebx,word[.z1]
|
||||
shl ebx,ROUND
|
||||
mov [.cz],ebx
|
||||
if Ext >= SSE2
|
||||
movups xmm1,[.cz]
|
||||
end if
|
||||
.hdraw:
|
||||
if Ext >= SSE2
|
||||
movd ebx,xmm1
|
||||
else
|
||||
mov ebx,[.cz]
|
||||
end if
|
||||
cmp [esi],ebx
|
||||
jle .skip
|
||||
|
||||
.draw_pixel
|
||||
|
||||
.skip:
|
||||
add edi,3
|
||||
add esi,4
|
||||
|
||||
.update_cur_var
|
||||
|
||||
loop .hdraw
|
||||
jmp .end_line
|
||||
|
||||
.vertical_l:
|
||||
mov ax,[.y1]
|
||||
cmp [.y2],ax
|
||||
jge @f
|
||||
|
||||
.sort
|
||||
@@:
|
||||
mov bx,[.y2]
|
||||
sub bx,[.y1]
|
||||
movsx ebx,bx
|
||||
cmp ebx,0
|
||||
je .end_line
|
||||
mov [.delta_y],ebx
|
||||
|
||||
call .calc_delta
|
||||
|
||||
mov eax,[.xres] ;SIZE_X
|
||||
movsx ebx,word[.y1]
|
||||
mul ebx
|
||||
add esi,eax
|
||||
lea eax,[eax*3]
|
||||
add edi,eax
|
||||
add esi,eax
|
||||
movsx eax,word[.x1]
|
||||
add esi,eax
|
||||
lea eax,[eax*3]
|
||||
add esi,eax
|
||||
add edi,eax
|
||||
|
||||
mov ecx,[.delta_y]
|
||||
|
||||
movsx ebx,word[.r1]
|
||||
shl ebx,ROUND
|
||||
mov [.cr],ebx
|
||||
movsx ebx,word[.g1]
|
||||
shl ebx,ROUND
|
||||
mov [.cg],ebx
|
||||
movsx ebx,word[.b1]
|
||||
shl ebx,ROUND
|
||||
mov [.cb],ebx
|
||||
movsx ebx,word[.z1]
|
||||
shl ebx,ROUND
|
||||
mov [.cz],ebx
|
||||
if Ext >= SSE2
|
||||
movups xmm1,[.cz]
|
||||
end if
|
||||
|
||||
.v_draw:
|
||||
if Ext >= SSE2
|
||||
movd ebx,xmm1
|
||||
else
|
||||
mov ebx,[.cz]
|
||||
end if
|
||||
cmp [esi],ebx
|
||||
jle @f
|
||||
|
||||
.draw_pixel
|
||||
|
||||
@@:
|
||||
add edi,[.xres3]
|
||||
add esi,[.xres4]
|
||||
|
||||
.update_cur_var
|
||||
|
||||
loop .v_draw
|
||||
jmp .end_line
|
||||
.deg45_l:
|
||||
mov word[.line_lenght],ax
|
||||
mov ax,[.x1]
|
||||
cmp [.x2],ax
|
||||
jge @f
|
||||
|
||||
.sort
|
||||
@@:
|
||||
mov bx,[.y2]
|
||||
sub bx,[.y1]
|
||||
movsx ebx,bx
|
||||
cmp ebx,0
|
||||
je .end_line
|
||||
mov [.delta_y],ebx
|
||||
mov bx,[.x2]
|
||||
sub bx,[.x1]
|
||||
movsx ebx,bx
|
||||
mov [.delta_x],ebx
|
||||
|
||||
call .calc_delta
|
||||
|
||||
mov eax,[.xres]
|
||||
movsx ebx,word[.y1] ;calc begin values in screen and Z buffers
|
||||
mul ebx
|
||||
lea ebx,[3*eax]
|
||||
add edi,ebx
|
||||
shl eax,2
|
||||
add esi,eax
|
||||
movsx eax,word[.x1]
|
||||
lea ebx,[eax*3]
|
||||
add edi,ebx
|
||||
shl eax,2
|
||||
add esi,eax
|
||||
|
||||
movzx ecx,word[.line_lenght]
|
||||
|
||||
movsx ebx,word[.r1]
|
||||
shl ebx,ROUND
|
||||
mov [.cr],ebx
|
||||
movsx ebx,word[.g1]
|
||||
shl ebx,ROUND
|
||||
mov [.cg],ebx
|
||||
movsx ebx,word[.b1]
|
||||
shl ebx,ROUND
|
||||
mov [.cb],ebx
|
||||
movsx ebx,word[.z1]
|
||||
shl ebx,ROUND
|
||||
mov [.cz],ebx
|
||||
.d45_draw:
|
||||
if Ext >= SSE2
|
||||
movd ebx,xmm1
|
||||
else
|
||||
mov ebx,[.cz]
|
||||
end if
|
||||
cmp [esi],ebx
|
||||
jle @f
|
||||
|
||||
.draw_pixel
|
||||
|
||||
@@:
|
||||
cmp dword[.delta_y],0
|
||||
jl @f
|
||||
add edi,[.xres3] ;SIZE_X*3+3
|
||||
add edi,3
|
||||
add esi,[.xres4] ;SIZE_X*4+4
|
||||
add esi,4
|
||||
jmp .d45_1
|
||||
@@:
|
||||
sub edi,[.xres3] ;(SIZE_X*3)-3
|
||||
sub edi,3
|
||||
sub esi,[.xres4] ;(SIZE_X*4)-4
|
||||
sub esi,4
|
||||
.d45_1:
|
||||
.update_cur_var
|
||||
|
||||
loop .d45_draw
|
||||
jmp .end_line
|
||||
|
||||
.more_vertical_l:
|
||||
mov word[.line_lenght],bx
|
||||
mov ax,[.y1]
|
||||
cmp [.y2],ax
|
||||
jge @f
|
||||
.sort
|
||||
@@:
|
||||
mov bx,[.y2]
|
||||
sub bx,[.y1]
|
||||
movsx ebx,bx
|
||||
cmp ebx,0
|
||||
je .end_line ;=======================
|
||||
mov [.delta_y],ebx
|
||||
|
||||
mov ax,[.x2]
|
||||
sub ax,[.x1]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
shl eax,16
|
||||
shl ecx,16
|
||||
sub eax,ecx
|
||||
push ebx
|
||||
push edx
|
||||
sub ebx,edx
|
||||
add ebx,1
|
||||
cdq
|
||||
idiv ebx
|
||||
mov [.delta],eax
|
||||
|
||||
call .calc_delta
|
||||
|
||||
mov eax,[.xres] ;SIZE_X
|
||||
movsx ebx,word[.y1] ;calc begin values in screen and Z buffers
|
||||
mul ebx
|
||||
lea ebx,[3*eax]
|
||||
add esi,ebx
|
||||
add esi,eax
|
||||
add edi,ebx
|
||||
mov [.cscr],edi
|
||||
mov [.czbuf],esi
|
||||
|
||||
movzx ecx,word[.line_lenght]
|
||||
|
||||
movsx ebx,word[.r1]
|
||||
shl ebx,ROUND
|
||||
mov [.cr],ebx
|
||||
movsx ebx,word[.g1]
|
||||
shl ebx,ROUND
|
||||
mov [.cg],ebx
|
||||
movsx ebx,word[.b1]
|
||||
shl ebx,ROUND
|
||||
mov [.cb],ebx
|
||||
movsx ebx,word[.z1]
|
||||
shl ebx,ROUND
|
||||
mov [.cz],ebx
|
||||
if Ext >= SSE2
|
||||
movups xmm1,[.cz]
|
||||
end if
|
||||
movsx ebx,word[.x1]
|
||||
shl ebx,ROUND
|
||||
mov [.ccoord],ebx ; .ccoord -> x coordinate
|
||||
.draw_m_v:
|
||||
mov edi,[.cscr]
|
||||
mov esi,[.czbuf]
|
||||
mov eax,[.ccoord]
|
||||
sar eax,ROUND
|
||||
lea ebx,[eax*3]
|
||||
add edi,ebx
|
||||
add esi,ebx
|
||||
add esi,eax
|
||||
if Ext >= SSE2
|
||||
movd ebx,xmm1
|
||||
else
|
||||
mov ebx,[.cz]
|
||||
end if
|
||||
cmp [esi],ebx
|
||||
jle @f
|
||||
|
||||
.draw_pixel
|
||||
|
||||
@@:
|
||||
mov eax,[.delta]
|
||||
mov ebx,[.xres3]
|
||||
add [.ccoord],eax
|
||||
mov eax,[.xres4]
|
||||
add dword[.cscr],ebx ;SIZE_X*3 ;
|
||||
add dword[.czbuf],eax ;SIZE_X*4
|
||||
.d_m_v1:
|
||||
|
||||
.update_cur_var
|
||||
|
||||
dec ecx
|
||||
jnz .draw_m_v
|
||||
jmp .end_line
|
||||
|
||||
.more_horizon_l:
|
||||
mov word[.line_lenght],ax
|
||||
mov ax,[.x1]
|
||||
cmp [.x2],ax
|
||||
jge @f
|
||||
|
||||
.sort
|
||||
@@:
|
||||
mov bx,[.x2]
|
||||
sub bx,[.x1]
|
||||
movsx ebx,bx
|
||||
cmp ebx,0;=======================
|
||||
je .end_line
|
||||
mov [.delta_x],ebx
|
||||
|
||||
mov ax,[.y2]
|
||||
sub ax,[.y1]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
mov [.delta],eax
|
||||
|
||||
call .calc_delta
|
||||
|
||||
;calc begin values in screen and Z buffers
|
||||
movsx ebx,word[.x1]
|
||||
mov eax,ebx
|
||||
add esi,ebx
|
||||
lea ebx,[3*ebx]
|
||||
add esi,ebx
|
||||
add edi,ebx
|
||||
mov [.cscr],edi
|
||||
mov [.czbuf],esi
|
||||
|
||||
movzx ecx,word[.line_lenght]
|
||||
|
||||
movsx ebx,word[.r1]
|
||||
shl ebx,ROUND
|
||||
mov [.cr],ebx
|
||||
movsx ebx,word[.g1]
|
||||
shl ebx,ROUND
|
||||
mov [.cg],ebx
|
||||
movsx ebx,word[.b1]
|
||||
shl ebx,ROUND
|
||||
mov [.cb],ebx
|
||||
movsx ebx,word[.z1]
|
||||
shl ebx,ROUND
|
||||
mov [.cz],ebx
|
||||
if Ext >= SSE2
|
||||
movups xmm1,[.cz]
|
||||
end if
|
||||
movsx ebx,word[.y1]
|
||||
shl ebx,ROUND
|
||||
mov [.ccoord],ebx ; .ccoord -> y coordinate
|
||||
|
||||
.draw_m_h:
|
||||
mov edi,[.cscr]
|
||||
mov esi,[.czbuf]
|
||||
mov eax,[.ccoord] ; ccoord - cur y coordinate
|
||||
sar eax,ROUND
|
||||
mov ebx,[.xres] ;SIZE_X
|
||||
mul ebx
|
||||
add esi,eax
|
||||
lea eax,[eax*3]
|
||||
add esi,eax
|
||||
add edi,eax
|
||||
if Ext >= SSE2
|
||||
movd ebx,xmm1
|
||||
else
|
||||
mov ebx,[.cz]
|
||||
end if
|
||||
cmp [esi],ebx
|
||||
jle @f
|
||||
|
||||
.draw_pixel
|
||||
|
||||
@@:
|
||||
mov eax,[.delta]
|
||||
add [.ccoord],eax
|
||||
add dword[.cscr],3 ;
|
||||
add dword[.czbuf],4
|
||||
|
||||
.update_cur_var
|
||||
|
||||
dec ecx
|
||||
jnz .draw_m_h
|
||||
|
||||
.end_line:
|
||||
mov esp,ebp
|
||||
ret 24
|
||||
|
||||
.calc_delta:
|
||||
mov ax,[.z2]
|
||||
sub ax,[.z1]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
mov [.dz],eax
|
||||
|
||||
mov ax,[.r2]
|
||||
sub ax,[.r1]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
mov [.dr],eax
|
||||
|
||||
mov ax,[.g2]
|
||||
sub ax,[.g1]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
mov [.dg],eax
|
||||
|
||||
mov ax,[.b2]
|
||||
sub ax,[.b1]
|
||||
cwde
|
||||
shl eax,ROUND
|
||||
cdq
|
||||
idiv ebx
|
||||
mov [.db],eax
|
||||
if Ext=MMX | Ext = SSE
|
||||
movq mm2,[.dz]
|
||||
movq mm3,[.dg]
|
||||
else if Ext >= SSE2
|
||||
movups xmm0,[.dz]
|
||||
movups xmm6,[.mask]
|
||||
end if
|
||||
mov esi,eax
|
||||
add ecx,$7fff
|
||||
pop ebx
|
||||
pop edx
|
||||
.lineas:
|
||||
mov eax,ecx
|
||||
add eax,esi
|
||||
push ebx
|
||||
push eax
|
||||
push edx
|
||||
shr ecx,16
|
||||
shr eax,16
|
||||
call horizontal_grd
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
add ebx,1
|
||||
cmp ebx,edx
|
||||
jle .lineas
|
||||
ret
|
||||
.mask:
|
||||
dq 0xffffffff00ffffff
|
||||
dq 0xffffffffffffffff
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
horizontal_grd: ; eax=x1 ebx=y1 ecx=x2
|
||||
cmp ecx,eax
|
||||
jg .m
|
||||
xchg ecx,eax
|
||||
.m:
|
||||
sub ecx,eax
|
||||
jnz .nn
|
||||
add ecx,1
|
||||
.nn:
|
||||
movd edx,mm2
|
||||
imul ebx,edx
|
||||
add eax,ebx
|
||||
movd edi,mm1
|
||||
lea edi,[edi+eax*4]
|
||||
push eax
|
||||
push ebx
|
||||
movd ebx,mm0
|
||||
lea ebx,[ebx+eax*4]
|
||||
.l:
|
||||
; movss xmm4,xmm2 ; xmm2 - cur z
|
||||
; cmpnltss xmm4,[ebx]
|
||||
; movd eax,xmm4
|
||||
; or eax,eax
|
||||
; jnz @f
|
||||
comiss xmm2,[ebx]
|
||||
jng @f
|
||||
movaps xmm4,xmm0 ; xmm0 - cur col
|
||||
cvtps2dq xmm4,xmm4
|
||||
packssdw xmm4,xmm4
|
||||
packuswb xmm4,xmm4
|
||||
movd [edi],xmm4
|
||||
@@:
|
||||
addss xmm2,xmm6
|
||||
addps xmm0,xmm5
|
||||
add edi,4
|
||||
sub ecx,1
|
||||
jnz .l
|
||||
pop ebx
|
||||
pop eax
|
||||
ret
|
||||
|
@ -1,4 +1,14 @@
|
||||
|
||||
View3ds 0.072 - march 2021
|
||||
1. New displaying model - texturing with bilinear filtering and transparency
|
||||
simultanusly. Note that filtering is done only inside polygon. To better
|
||||
quality of image there is a need to use floats coordinates of texture to pass
|
||||
as arguments to single triangle rendering proc.
|
||||
2. Optimizations.
|
||||
3. SSE3 version runs correct on SSE2 cpus, but real phong, glass and
|
||||
transparented texturing with filtering rendering models are disabled.
|
||||
-----------------------------------------------------------------------------------
|
||||
|
||||
View3ds 0.071 - VIII 2020
|
||||
1. New displaying model - glass - it's two pass rendering. First pass calculates
|
||||
Z position of all front pixels, second render image with adding reflective
|
||||
|
@ -1,7 +1,12 @@
|
||||
View3ds 0.072 - tiny viewer to .3ds and .asc files with several graphics
|
||||
View3ds 0.073 - tiny viewer to .3ds and .asc files with several graphics
|
||||
effects implementation.
|
||||
|
||||
What's new?
|
||||
1. I introduced procedure for searching nonredundand edges.
|
||||
2. Writing some info about object: vertices, triangles unique edges
|
||||
count.
|
||||
|
||||
|
||||
1. New displaying model - texturing with bilinear filtering and transparency
|
||||
simultanusly. Note that filtering is done only inside polygon. To better
|
||||
quality of image there is a need to use floats coordinates of texture to pass
|
||||
@ -26,21 +31,23 @@ Buttons description:
|
||||
8. rand. light: Randomize 3 unlinear lights( so called Phong's illumination).
|
||||
9. Blur: blur N times; N=0,1,2,3,4,5
|
||||
10.11,12,13. loseless operations (rotary 90, 180 degrees).
|
||||
12. emboss: Do emboss effect( flat bumps ), use 'bumps deep' button to do edges more deep.
|
||||
12. emboss: Do emboss effect( flat bumps ), use 'bumps deep' button to do edges
|
||||
more deep.
|
||||
13. fire: do motion blur ( looks like fire ).
|
||||
14. move: changes meaning x,y,z +/- buttons -> obj: moving object, camr: moving camera, wave: x,y +/- increase,
|
||||
decrease wave effect frequency and amplitude.
|
||||
14. move: changes meaning x,y,z +/- buttons -> obj: moving object, camr: moving
|
||||
camera, wave: x,y +/- increase, decrease wave effect frequency and amplitude.
|
||||
15. generate: Generates some objects: node, Thorn Crown, heart...
|
||||
16. bumps: random, according to texture.
|
||||
17. bumps deep -> create bumps deeper or lighter.
|
||||
18. re-map tex -> re-map texture and bump map coordinates, to change spherical mapping
|
||||
around axle use 'xchg' and 'mirror' buttons, then press 're-map tex' button.
|
||||
18. re-map tex -> re-map texture and bump map coordinates, to change spherical
|
||||
mapping around axle use 'xchg' and 'mirror' buttons, then press 're-map tex' button.
|
||||
19. bright + -> increase picture brightness.
|
||||
20. bright - -> decrease picture brightness.
|
||||
21. wav effect -> do effect based sine function.
|
||||
22. editor -> setting editing option. If is "on" then red bars are draw according to each vertex, Pressing
|
||||
and moving left mouse button (cursor must be on handler)- change vertex position. If left mouse button
|
||||
is released apply current position. You may also decrease whole handlers count by enable culling (using
|
||||
appropriate button) - some back handlers become hidden.
|
||||
22. editor -> setting editing option. If is "on" then red bars are draw according to each
|
||||
vertex, Pressing and moving left mouse button (cursor must be on handler)- change
|
||||
vertex position. If left mouse button is released apply current position. You may also
|
||||
decrease whole handlers count by enable culling (using appropriate button) - some
|
||||
back handlers become hidden.
|
||||
|
||||
Maciej Guba III 2021
|
||||
Maciej Guba V 2021
|
||||
|
@ -1,11 +1,11 @@
|
||||
|
||||
; application : View3ds ver. 0.072 - tiny .3ds and .asc files viewer
|
||||
; application : View3ds ver. 0.071 - 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.j.pl, http://macgub.co.pl
|
||||
; web : http://macgub.co.pl, http://macgub.j.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.
|
||||
@ -19,8 +19,8 @@
|
||||
; 2) Written in manually (at the end of the code) ; now not exist
|
||||
|
||||
|
||||
SIZE_X equ 500
|
||||
SIZE_Y equ 600 ; ///// I want definitely
|
||||
SIZE_X equ 512
|
||||
SIZE_Y equ 512 ; ///// I want definitely
|
||||
TIMEOUT equ 10 ; ------ say:
|
||||
ROUND equ 10 ; \ @ @/ keep smiling every
|
||||
TEX_X equ 512 ; texture width ; \ ./ / day.
|
||||
@ -61,9 +61,6 @@ START: ; start of execution
|
||||
fstp [rsscale]
|
||||
pop ebx
|
||||
|
||||
mov [x_start],dword 20 shl 16 + 20 ;eax
|
||||
|
||||
|
||||
call alloc_buffer_mem
|
||||
call read_param
|
||||
call read_from_disk ; read, if all is ok eax = 0
|
||||
@ -86,14 +83,9 @@ START: ; start of execution
|
||||
call read_asc
|
||||
jmp .opt
|
||||
.malloc:
|
||||
if USE_LFN
|
||||
call alloc_mem_for_tp
|
||||
end if
|
||||
call read_from_file
|
||||
.opt:
|
||||
|
||||
|
||||
|
||||
call optimize_object1 ; proc in file b_procs.asm
|
||||
; set point(0,0,0) in center and calc all coords
|
||||
; to be in <-1.0,1.0>
|
||||
@ -111,19 +103,13 @@ START: ; start of execution
|
||||
mov edi,bumpmap
|
||||
call calc_bumpmap
|
||||
call calc_bumpmap_coords ; bump and texture mapping
|
||||
call do_edges_list
|
||||
call draw_window
|
||||
;mov [draw_win_at_first],0
|
||||
;mov eax,40 ; set events mask
|
||||
;mov ebx,1100000000000000000000000100111b
|
||||
;int 0x40
|
||||
if Ext >= SSE3
|
||||
mov eax,1
|
||||
cpuid
|
||||
bt ecx,0 ; is sse3 on board?
|
||||
jc @f
|
||||
mov [max_dr_flg],12
|
||||
@@:
|
||||
end if
|
||||
|
||||
|
||||
still:
|
||||
cmp [edit_flag],1
|
||||
@ -184,7 +170,7 @@ still:
|
||||
mov ecx,-1
|
||||
int 0x40
|
||||
mov eax,[procinfo+42] ; read params of window
|
||||
sub eax,115
|
||||
sub eax,225
|
||||
mov [size_x_var],ax
|
||||
shr ax,1
|
||||
mov [vect_x],ax
|
||||
@ -259,29 +245,19 @@ still:
|
||||
jne @f
|
||||
.zoom_out:
|
||||
mov dword[scale],0.7
|
||||
movss xmm0,[rsscale]
|
||||
mulss xmm0,[scale]
|
||||
movss [rsscale],xmm0
|
||||
; fninit
|
||||
; fld [rsscale]
|
||||
; fmul [scale]
|
||||
; fstp [rsscale]
|
||||
|
||||
|
||||
fninit
|
||||
fld [rsscale]
|
||||
fmul [scale]
|
||||
fstp [rsscale]
|
||||
@@:
|
||||
cmp ah,6 ; ah = 6 -> scale+
|
||||
jne @f
|
||||
.zoom_in:
|
||||
mov dword[scale],1.3
|
||||
movss xmm0,[rsscale]
|
||||
mulss xmm0,[scale]
|
||||
movss [rsscale],xmm0
|
||||
|
||||
; fninit
|
||||
; fld [rsscale]
|
||||
; fmul [scale]
|
||||
; fstp [rsscale]
|
||||
|
||||
fninit
|
||||
fld [rsscale]
|
||||
fmul [scale]
|
||||
fstp [rsscale]
|
||||
@@:
|
||||
cmp ah,9 ; lights random ; 'flat' 0
|
||||
jne .next_m5 ; 'grd ' 1
|
||||
@ -291,15 +267,7 @@ still:
|
||||
call copy_lights
|
||||
end if
|
||||
call do_color_buffer ; intit color_map ; 'tex ' 4
|
||||
; cmp [emboss_flag],1 ; 'pos ' 5
|
||||
; je @f ; 'dots' 6
|
||||
; cmp [dr_flag],8
|
||||
; jge @f
|
||||
; cmp [dr_flag],2 ; 'txgr' 7
|
||||
; jl .next_m5 ; '2tex' 8
|
||||
; cmp [dr_flag],3 ; 'btex' 9
|
||||
; jg .next_m5
|
||||
; @@:
|
||||
|
||||
call init_envmap2 ; update env map if shading model = environment or bump
|
||||
.next_m5:
|
||||
cmp ah,11
|
||||
@ -360,7 +328,8 @@ still:
|
||||
call init_triangles_normals2
|
||||
call init_point_normals
|
||||
call calc_bumpmap_coords ; bump and texture mapping
|
||||
|
||||
call do_edges_list
|
||||
call write_info
|
||||
.next_m2:
|
||||
cmp ah,19
|
||||
je @f
|
||||
@ -547,6 +516,10 @@ still:
|
||||
jne @f
|
||||
call clrscr ; clear the screen
|
||||
@@:
|
||||
; cmp [catmull_flag],1 ;non sort if Catmull = on
|
||||
; je .no_sort
|
||||
; 64 indexes call sort_triangles
|
||||
.no_sort:
|
||||
cmp [dr_flag],7 ; fill if 2tex and texgrd
|
||||
jge @f
|
||||
cmp [catmull_flag],0 ;non fill if Catmull = off
|
||||
@ -568,6 +541,11 @@ still:
|
||||
call draw_handlers
|
||||
; call edit
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.no_edit:
|
||||
|
||||
.blurrr:
|
||||
@ -595,6 +573,7 @@ still:
|
||||
|
||||
@@:
|
||||
|
||||
|
||||
cmp [inc_bright_flag],0 ; increase brightness
|
||||
je .no_inc_bright
|
||||
movzx ebx,[inc_bright_flag]
|
||||
@ -727,9 +706,8 @@ end if
|
||||
mov eax,7 ; put image
|
||||
mov ebx,[screen_ptr]
|
||||
mov ecx,[size_y_var]
|
||||
; mov ecx,SIZE_X shl 16 + SIZE_Y
|
||||
mov edx,[offset_y] ;5 shl 16 + 25
|
||||
cmp [dr_flag],12
|
||||
mov edx,[offset_y]
|
||||
cmp [dr_flag],11
|
||||
jge .ff
|
||||
int 0x40
|
||||
jmp .f
|
||||
@ -1235,13 +1213,6 @@ init_envmap2: ; do env_map using many light sources
|
||||
push ax
|
||||
mov al,byte[esi+12] ; r
|
||||
push ax
|
||||
; pxor xmm1,xmm1
|
||||
; movd xmm0,[esi+12]
|
||||
; punpckhbw xmm0,xmm1
|
||||
; sub esp,8
|
||||
; movq [esp],xmm0
|
||||
|
||||
|
||||
mov al,byte[esi+20] ; b max color
|
||||
push ax
|
||||
mov al,byte[esi+19] ; g
|
||||
@ -1418,7 +1389,7 @@ do_color_buffer: ; do color buffer for Gouraud, flat shading
|
||||
mov esp,ebp
|
||||
pop ebp
|
||||
ret
|
||||
if Ext >= SSE2
|
||||
if Ext >= SSE3
|
||||
init_point_normals:
|
||||
.z equ dword [ebp-8]
|
||||
.y equ dword [ebp-12]
|
||||
@ -1426,6 +1397,7 @@ init_point_normals:
|
||||
.point_number equ dword [ebp-28]
|
||||
.hit_faces equ dword [ebp-32]
|
||||
|
||||
fninit
|
||||
push ebp
|
||||
mov ebp,esp
|
||||
sub esp,64
|
||||
@ -1466,25 +1438,19 @@ init_point_normals:
|
||||
jne .ipn_check_face
|
||||
cvtsi2ss xmm6,.hit_faces
|
||||
movaps xmm7,.x
|
||||
|
||||
rcpss xmm6,xmm6
|
||||
shufps xmm6,xmm6,11000000b
|
||||
mulps xmm7,xmm6
|
||||
movaps xmm6,xmm7
|
||||
mulps xmm6,xmm6
|
||||
andps xmm6,[zero_hgst_dd]
|
||||
haddps xmm6,xmm6
|
||||
haddps xmm6,xmm6
|
||||
rsqrtps xmm6,xmm6
|
||||
mulps xmm7,xmm6
|
||||
movlps [edi],xmm7
|
||||
movhlps xmm7,xmm7
|
||||
movss [edi+8],xmm7
|
||||
call normalize_vector
|
||||
; movaps xmm6,xmm7
|
||||
; mulps xmm6,xmm6
|
||||
; andps xmm6,[zero_hgst_dd]
|
||||
; haddps xmm6,xmm6
|
||||
; haddps xmm6,xmm6
|
||||
; rsqrtps xmm6,xmm6
|
||||
; mulps xmm7,xmm6
|
||||
; movlps [edi],xmm7
|
||||
; movhlps xmm7,xmm7
|
||||
; movss [edi+8],xmm7
|
||||
|
||||
add edi,12
|
||||
inc .point_number
|
||||
mov edx,.point_number
|
||||
@ -1764,13 +1730,15 @@ draw_triangles:
|
||||
end if
|
||||
|
||||
|
||||
cmp [dr_flag],11
|
||||
je .draw_smooth_line
|
||||
|
||||
mov esi,[triangles_ptr]
|
||||
mov ecx,[triangles_count_var]
|
||||
.again_dts:
|
||||
push ecx
|
||||
mov ebp,[points_translated_ptr]
|
||||
if Ext = NON
|
||||
if Ext >= SSE2
|
||||
mov eax,dword[esi]
|
||||
mov [point_index1],eax
|
||||
lea eax,[eax*3]
|
||||
@ -1814,7 +1782,7 @@ draw_triangles:
|
||||
mov [zz3],ax
|
||||
else
|
||||
movq mm0,[esi] ; don't know MMX
|
||||
movq qword[point_index1],mm0
|
||||
mov qword[point_index1],mm0
|
||||
; shr eax,16
|
||||
; mov [point_index2],ax
|
||||
mov eax,dword[esi+8]
|
||||
@ -1890,19 +1858,17 @@ end if
|
||||
lea eax,[eax*3]
|
||||
shl eax,2
|
||||
add eax,[points_normals_rot_ptr]
|
||||
bt dword[eax+8],+31
|
||||
jc .no_culling
|
||||
; lea eax,[eax+point_normals_rotated]
|
||||
; fld dword[eax+8] ; *****************************
|
||||
; ftst ; CHECKING OF Z COOFICIENT OF
|
||||
; fstsw ax ; NORMAL VECTOR
|
||||
; sahf
|
||||
; jb @f
|
||||
; ffree st
|
||||
fld dword[eax+8] ; *****************************
|
||||
ftst ; CHECKING OF Z COOFICIENT OF
|
||||
fstsw ax ; NORMAL VECTOR
|
||||
sahf
|
||||
jb @f
|
||||
ffree st
|
||||
loop @b
|
||||
jmp .end_draw ; non visable
|
||||
; @@:
|
||||
; ffree st ;is visable
|
||||
@@:
|
||||
ffree st ;is visable
|
||||
.no_culling:
|
||||
cmp [dr_flag],0 ; draw type flag
|
||||
je .flat_draw
|
||||
@ -1931,7 +1897,6 @@ end if
|
||||
je .glass
|
||||
cmp [dr_flag],14
|
||||
je .glass_tex
|
||||
|
||||
end if ; ****************
|
||||
mov esi,point_index3 ; do Gouraud shading
|
||||
mov ecx,3
|
||||
@ -1940,28 +1905,19 @@ end if
|
||||
shl eax,2
|
||||
lea eax,[eax*3]
|
||||
add eax,[points_normals_rot_ptr]
|
||||
if Ext < SSE
|
||||
; texture x=(rotated point normal -> x * 255)+255
|
||||
fld dword[eax] ; x cooficient of normal vector
|
||||
fmul dword[correct_texf]
|
||||
fadd dword[correct_texf]
|
||||
fimul [correct_tex]
|
||||
fiadd [correct_tex]
|
||||
fistp [temp1]
|
||||
; texture y=(rotated point normal -> y * 255)+255
|
||||
fld dword[eax+4] ; y cooficient
|
||||
fmul dword[correct_texf]
|
||||
fadd dword[correct_texf]
|
||||
fimul [correct_tex]
|
||||
fiadd [correct_tex]
|
||||
fistp [temp2]
|
||||
|
||||
mov eax,[temp2]
|
||||
mov ebx,[temp1]
|
||||
else
|
||||
movlps xmm0,[eax]
|
||||
mulps xmm0,[correct_texf]
|
||||
addps xmm0,[correct_texf]
|
||||
cvtps2dq xmm0,xmm0
|
||||
movd eax,xmm0
|
||||
psrldq xmm0,4
|
||||
movd ebx,xmm0
|
||||
end if
|
||||
and ebx,0xfffffff
|
||||
shl eax,TEX_SHIFT
|
||||
add eax,ebx
|
||||
@ -2066,31 +2022,28 @@ end if
|
||||
mov eax,[point_index1]
|
||||
mov ebx,[point_index2]
|
||||
mov ecx,[point_index3]
|
||||
; shl eax,2
|
||||
imul eax,[i12]
|
||||
imul ebx,[i12]
|
||||
imul ecx,[i12]
|
||||
; shl ebx,2
|
||||
; shl ecx,2
|
||||
; lea eax,[eax*3] ;+point_normals_rotated]
|
||||
shl eax,2
|
||||
shl ebx,2
|
||||
shl ecx,2
|
||||
lea eax,[eax*3] ;+point_normals_rotated]
|
||||
add eax,[points_normals_rot_ptr]
|
||||
; lea ebx,[ebx*3] ;+point_normals_rotated]
|
||||
lea ebx,[ebx*3] ;+point_normals_rotated]
|
||||
add ebx,[points_normals_rot_ptr]
|
||||
; lea ecx,[ecx*3] ;+point_normals_rotated]
|
||||
lea ecx,[ecx*3] ;+point_normals_rotated]
|
||||
add ecx,[points_normals_rot_ptr]
|
||||
fld dword[eax] ; x cooficient of normal vector
|
||||
fadd dword[ebx]
|
||||
fadd dword[ecx]
|
||||
fidiv [i3]
|
||||
fmul dword[correct_texf]
|
||||
fadd dword[correct_texf]
|
||||
fimul [correct_tex]
|
||||
fiadd [correct_tex]
|
||||
fistp [temp1] ;dword[esp-4] ; x temp variables
|
||||
fld dword[eax+4] ; y cooficient of normal vector
|
||||
fadd dword[ebx+4]
|
||||
fadd dword[ecx+4]
|
||||
fidiv [i3]
|
||||
fmul dword[correct_texf]
|
||||
fadd dword[correct_texf]
|
||||
fimul [correct_tex]
|
||||
fiadd [correct_tex]
|
||||
fistp [temp2] ;dword[esp-8] ; y
|
||||
mov edx,[temp2] ;dword[esp-8]
|
||||
and edx,0xfffffff
|
||||
@ -2147,12 +2100,17 @@ end if
|
||||
lea eax,[eax*3]
|
||||
shl eax,2
|
||||
add eax,[points_normals_rot_ptr] ;point_normals_rotated
|
||||
movlps xmm0,[eax]
|
||||
mulps xmm0,[correct_texf]
|
||||
addps xmm0,[correct_texf]
|
||||
cvtps2dq xmm0,xmm0
|
||||
packssdw xmm0,xmm0
|
||||
movd [edi],xmm0
|
||||
; texture x=(rotated point normal -> x * 255)+255
|
||||
fld dword[eax]
|
||||
fimul [correct_tex]
|
||||
fiadd [correct_tex]
|
||||
fistp word[edi]
|
||||
; texture y=(rotated point normal -> y * 255)+255
|
||||
fld dword[eax+4]
|
||||
fimul [correct_tex]
|
||||
fiadd [correct_tex]
|
||||
fistp word[edi+2]
|
||||
|
||||
add edi,4
|
||||
add esi,4
|
||||
loop @b
|
||||
@ -2192,8 +2150,8 @@ end if
|
||||
fld1
|
||||
faddp
|
||||
fmulp
|
||||
fmul dword[correct_texf]
|
||||
fadd dword[correct_texf]
|
||||
fimul [correct_tex]
|
||||
fiadd [correct_tex]
|
||||
fistp word[edi]
|
||||
mov word[edi+2],0
|
||||
; fistp word[edi+2]
|
||||
@ -2244,16 +2202,18 @@ end if
|
||||
mov eax,dword[esi]
|
||||
lea eax,[eax*3]
|
||||
shl eax,2
|
||||
; imul eax,[i12]
|
||||
add eax,[points_normals_rot_ptr] ;point_normals_rotated
|
||||
; texture x=(rotated point normal -> x * 255)+255
|
||||
fld dword[eax]
|
||||
fimul [correct_tex]
|
||||
fiadd [correct_tex]
|
||||
fistp word[edi]
|
||||
; texture y=(rotated point normal -> y * 255)+255
|
||||
fld dword[eax+4]
|
||||
fimul [correct_tex]
|
||||
fiadd [correct_tex]
|
||||
fistp word[edi+2]
|
||||
|
||||
movlps xmm0,[eax]
|
||||
mulps xmm0,[correct_texf]
|
||||
addps xmm0,[correct_texf]
|
||||
cvtps2dq xmm0,xmm0
|
||||
packssdw xmm0,xmm0
|
||||
movd [edi],xmm0
|
||||
add edi,4
|
||||
add esi,4
|
||||
loop @b
|
||||
@ -2265,11 +2225,17 @@ end if
|
||||
mov esi,[point_index2]
|
||||
shl esi,2
|
||||
add esi,tex_points
|
||||
; lea esi,[esi*3]
|
||||
; lea esi,[points+2+esi*2]
|
||||
push dword[esi]
|
||||
; push dword[xx2]
|
||||
mov esi,[point_index1]
|
||||
shl esi,2
|
||||
add esi,tex_points
|
||||
; lea esi,[esi*3]
|
||||
; lea esi,[points+2+esi*2]
|
||||
push dword[esi]
|
||||
; push dword[xx1]
|
||||
|
||||
mov eax,dword[xx1]
|
||||
ror eax,16
|
||||
@ -2377,33 +2343,24 @@ end if
|
||||
|
||||
lea edx,[ecx*3]
|
||||
push word[edx*2+xx1-2] ; zz1 ,2 ,3
|
||||
; fninit
|
||||
fninit
|
||||
mov eax,dword[esi]
|
||||
shl eax,2
|
||||
lea eax,[eax*3] ;+point_normals_rotated]
|
||||
add eax,[points_normals_rot_ptr]
|
||||
if Ext < SSE
|
||||
; texture x=(rotated point normal -> x * 255)+255
|
||||
fld dword[eax] ; x cooficient of normal vector
|
||||
fmul dword[correct_texf]
|
||||
fadd dword[correct_texf]
|
||||
fimul [correct_tex]
|
||||
fiadd [correct_tex]
|
||||
fistp [temp1] ;word[ebp-2]
|
||||
; texture y=(rotated point normal -> y * 255)+255
|
||||
fld dword[eax+4] ; y cooficient
|
||||
fmul dword[correct_texf]
|
||||
fadd dword[correct_texf]
|
||||
fimul [correct_tex]
|
||||
fiadd [correct_tex]
|
||||
fistp [temp2] ;word[ebp-4]
|
||||
mov eax,[temp2]
|
||||
mov ebx,[temp1]
|
||||
else
|
||||
movlps xmm0,[eax]
|
||||
mulps xmm0,[correct_texf]
|
||||
addps xmm0,[correct_texf]
|
||||
cvtps2dq xmm0,xmm0
|
||||
movd eax,xmm0
|
||||
psrldq xmm0,4
|
||||
movd ebx,xmm0
|
||||
end if
|
||||
|
||||
mov eax,[temp2] ;word[ebp-4]
|
||||
mov ebx,[temp1] ;word[ebp-2]
|
||||
and ebx,0xfffffff ; some onjects need thid 'and'
|
||||
shl eax,TEX_SHIFT
|
||||
add eax,ebx
|
||||
@ -2471,22 +2428,16 @@ end if
|
||||
shl eax,2
|
||||
add eax,[points_normals_rot_ptr]
|
||||
; texture x=(rotated point normal -> x * 255)+255
|
||||
movlps xmm0,[eax]
|
||||
mulps xmm0,[correct_texf]
|
||||
addps xmm0,[correct_texf]
|
||||
cvtps2dq xmm0,xmm0
|
||||
packssdw xmm0,xmm0
|
||||
movd [edi],xmm0
|
||||
; fld dword[eax]
|
||||
; fmul dword[correct_texf]
|
||||
; fadd dword[correct_texf]
|
||||
; fistp word[edi]
|
||||
fld dword[eax]
|
||||
fimul [correct_tex]
|
||||
fiadd [correct_tex]
|
||||
fistp word[edi]
|
||||
|
||||
; texture y=(rotated point normal -> y * 255)+255
|
||||
; fld dword[eax+4]
|
||||
; fmul dword[correct_texf]
|
||||
; fadd dword[correct_texf]
|
||||
; fistp word[edi+2]
|
||||
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
|
||||
@ -2537,15 +2488,7 @@ end if
|
||||
lea eax,[eax*3]
|
||||
shl eax,2
|
||||
add eax,[points_normals_rot_ptr]
|
||||
if Ext >= SSE
|
||||
; texture x=(rotated point normal -> x * 255)+255
|
||||
movlps xmm0,[eax]
|
||||
mulps xmm0,[correct_texf]
|
||||
addps xmm0,[correct_texf]
|
||||
cvtps2dq xmm0,xmm0
|
||||
packssdw xmm0,xmm0
|
||||
movd [edi],xmm0
|
||||
else
|
||||
fld dword[eax]
|
||||
fimul [correct_tex]
|
||||
fiadd [correct_tex]
|
||||
@ -2555,7 +2498,7 @@ end if
|
||||
fimul [correct_tex]
|
||||
fiadd [correct_tex]
|
||||
fistp word[edi+2]
|
||||
end if
|
||||
|
||||
add edi,4
|
||||
add esi,4
|
||||
loop @b
|
||||
@ -2596,140 +2539,6 @@ end if
|
||||
|
||||
jmp .end_draw
|
||||
|
||||
.draw_smooth_line:
|
||||
mov esi,point_index3
|
||||
mov ecx,3
|
||||
.again_line_param:
|
||||
mov eax,dword[esi]
|
||||
shl eax,2
|
||||
lea eax,[eax*3]
|
||||
add eax,[points_normals_rot_ptr]
|
||||
if Ext>=SSE2
|
||||
movlps xmm0,[eax]
|
||||
mulps xmm0,[correct_texf]
|
||||
addps xmm0,[correct_texf]
|
||||
cvtps2dq xmm0,xmm0
|
||||
movd eax,xmm0
|
||||
psrldq xmm0,4
|
||||
movd ebx,xmm0
|
||||
else if
|
||||
; texture ;x=(rotated point normal -> x * 255)+255
|
||||
fld dword[eax] ; x cooficient of normal vector
|
||||
fmul dword[correct_texf]
|
||||
fadd dword[correct_texf]
|
||||
fistp [temp1] ;word[esp-2]
|
||||
; texture y=(rotated point normal -> y * 255)+255
|
||||
fld dword[eax+4] ; y cooficient
|
||||
fmul dword[correct_texf]
|
||||
fadd dword[correct_texf]
|
||||
fistp [temp2] ;word[esp-4]
|
||||
mov eax,[temp2] ;word[esp-4]
|
||||
mov ebx,[temp1] ;word[esp-2]
|
||||
end if
|
||||
and ebx,0xfffffff
|
||||
shl eax,TEX_SHIFT
|
||||
add eax,ebx
|
||||
lea eax,[eax*3+color_map]
|
||||
mov eax,dword[eax]
|
||||
lea ebx,[ecx-1]
|
||||
shl ebx,2
|
||||
mov [ebx+col1],eax
|
||||
|
||||
sub esi,4
|
||||
dec ecx
|
||||
jnz .again_line_param
|
||||
|
||||
mov edi,[screen_ptr]
|
||||
mov esi,[Zbuffer_ptr]
|
||||
|
||||
mov eax,[col1]
|
||||
movzx bx,al
|
||||
push bx ; b
|
||||
movzx bx,ah
|
||||
push bx
|
||||
rol eax,16
|
||||
xor ah,ah
|
||||
push ax
|
||||
push [zz1]
|
||||
push [yy1]
|
||||
push [xx1]
|
||||
|
||||
mov eax,[col2]
|
||||
movzx bx,al
|
||||
push bx ; b
|
||||
movzx bx,ah
|
||||
push bx
|
||||
rol eax,16
|
||||
xor ah,ah
|
||||
push ax
|
||||
push [zz2]
|
||||
push [yy2]
|
||||
push [xx2]
|
||||
|
||||
call smooth_line
|
||||
@@:
|
||||
|
||||
mov edi,[screen_ptr]
|
||||
mov esi,[Zbuffer_ptr]
|
||||
|
||||
mov eax,[col1]
|
||||
movzx bx,al
|
||||
push bx ; b
|
||||
movzx bx,ah
|
||||
push bx
|
||||
rol eax,16
|
||||
xor ah,ah
|
||||
push ax
|
||||
push [zz1]
|
||||
push [yy1]
|
||||
push [xx1]
|
||||
|
||||
mov eax,[col3]
|
||||
movzx bx,al
|
||||
push bx ; b
|
||||
movzx bx,ah
|
||||
push bx
|
||||
rol eax,16
|
||||
xor ah,ah
|
||||
push ax
|
||||
push [zz3]
|
||||
push [yy3]
|
||||
push [xx3]
|
||||
|
||||
call smooth_line
|
||||
@@:
|
||||
|
||||
|
||||
mov edi,[screen_ptr]
|
||||
mov esi,[Zbuffer_ptr]
|
||||
|
||||
mov eax,[col3]
|
||||
movzx bx,al
|
||||
push bx ; b
|
||||
movzx bx,ah
|
||||
push bx
|
||||
rol eax,16
|
||||
xor ah,ah
|
||||
push ax
|
||||
push [zz3]
|
||||
push [yy3]
|
||||
push [xx3]
|
||||
|
||||
mov eax,[col2]
|
||||
movzx bx,al
|
||||
push bx ; b
|
||||
movzx bx,ah
|
||||
push bx
|
||||
rol eax,16
|
||||
xor ah,ah
|
||||
push ax
|
||||
push [zz2]
|
||||
push [yy2]
|
||||
push [xx2]
|
||||
|
||||
call smooth_line
|
||||
jmp .end_draw
|
||||
@@:
|
||||
|
||||
if Ext >= SSE3
|
||||
.r_phg:
|
||||
@ -2789,7 +2598,6 @@ if Ext >= SSE3
|
||||
jmp .end_draw
|
||||
|
||||
.glass:
|
||||
|
||||
movd xmm5,[size_y_var]
|
||||
punpcklwd xmm5,[the_zero]
|
||||
pshufd xmm5,xmm5,01110011b
|
||||
@ -2843,6 +2651,7 @@ if Ext >= SSE3
|
||||
call glass_tri
|
||||
jmp .end_draw
|
||||
|
||||
|
||||
.glass_tex:
|
||||
movd xmm5,[size_y_var]
|
||||
punpcklwd xmm5,[the_zero]
|
||||
@ -2917,27 +2726,133 @@ if Ext >= SSE3
|
||||
|
||||
call glass_tex_tri
|
||||
|
||||
jmp .end_draw
|
||||
|
||||
|
||||
end if
|
||||
|
||||
|
||||
|
||||
|
||||
.end_draw:
|
||||
pop esi
|
||||
add esi,12
|
||||
|
||||
pop ecx
|
||||
sub ecx,1
|
||||
dec ecx
|
||||
|
||||
jnz .again_dts
|
||||
ret
|
||||
|
||||
|
||||
.draw_smooth_line:
|
||||
mov esi,[edges_ptr]
|
||||
xor ecx,ecx
|
||||
.again_s_line:
|
||||
push ecx
|
||||
push esi
|
||||
|
||||
mov ecx,2
|
||||
.aga_n:
|
||||
mov eax,[esi]
|
||||
shl eax,2
|
||||
lea eax,[eax*3]
|
||||
add eax,[points_normals_rot_ptr]
|
||||
movups xmm0,[eax]
|
||||
xorps xmm1,xmm1
|
||||
mov edx,lights_aligned
|
||||
.again_cc:
|
||||
movaps xmm3,xmm0 ;.cnv
|
||||
mulps xmm3,[edx]
|
||||
andps xmm3,[zero_hgst_dd]
|
||||
; haddps xmm3,xmm3
|
||||
; haddps xmm3,xmm3 ; xmm3 - dot pr
|
||||
movhlps xmm2,xmm3
|
||||
addps xmm3,xmm2
|
||||
movdqa xmm2,xmm3
|
||||
shufps xmm2,xmm2,01010101b
|
||||
addps xmm3,xmm2
|
||||
shufps xmm3,xmm3,0
|
||||
movaps xmm6,xmm3 ;xmm7
|
||||
mulps xmm6,xmm6
|
||||
mulps xmm6,xmm6
|
||||
mulps xmm6,xmm6
|
||||
mulps xmm6,xmm6
|
||||
mulps xmm6,xmm6
|
||||
mulps xmm6,[edx+48]
|
||||
movaps xmm7,xmm3
|
||||
mulps xmm7,[edx+16]
|
||||
addps xmm7,xmm6
|
||||
addps xmm7,[edx+32]
|
||||
minps xmm7,[mask_255f] ; global
|
||||
|
||||
maxps xmm1,xmm7
|
||||
add edx,64 ; size of one light in aligned list
|
||||
cmp edx,lights_aligned_end
|
||||
jl .again_cc
|
||||
sub esp,16
|
||||
movups [esp],xmm1
|
||||
add esi,4
|
||||
loop .aga_n
|
||||
|
||||
movups xmm0,[esp]
|
||||
movups xmm1,[esp+16]
|
||||
add esp,32
|
||||
sub esi,8
|
||||
|
||||
mov ecx,[esi]
|
||||
mov edx,[esi+4]
|
||||
imul ecx,[i6]
|
||||
imul edx,[i6]
|
||||
add ecx,[points_translated_ptr]
|
||||
add edx,[points_translated_ptr]
|
||||
|
||||
movd xmm7,[ecx]
|
||||
movhps xmm7,[edx]
|
||||
pshufd xmm7,xmm7,11101000b
|
||||
movdqa xmm6,xmm7
|
||||
movd xmm5,[size_y_var]
|
||||
pshuflw xmm5,xmm5,00010001b
|
||||
pcmpgtw xmm7,xmm5
|
||||
pcmpgtw xmm6,[the_zero]
|
||||
pxor xmm7,xmm6
|
||||
pmovmskb eax,xmm7
|
||||
cmp al,-1
|
||||
jnz .skp
|
||||
|
||||
|
||||
|
||||
|
||||
mov eax,[esi]
|
||||
mov ebx,[esi+4]
|
||||
imul eax,[i12]
|
||||
imul ebx,[i12]
|
||||
add eax,[points_rotated_ptr]
|
||||
add ebx,[points_rotated_ptr]
|
||||
movss xmm2,[eax+8]
|
||||
movss xmm3,[ebx+8]
|
||||
|
||||
|
||||
movzx eax,word[ecx]
|
||||
movzx ebx,word[ecx+2]
|
||||
movzx ecx,word[edx]
|
||||
movzx edx,word[edx+2]
|
||||
|
||||
emms
|
||||
movd mm1,[screen_ptr]
|
||||
movd mm0,[Zbuffer_ptr]
|
||||
movzx esi,word[size_x_var]
|
||||
movd mm2,esi
|
||||
|
||||
push ebp
|
||||
call line_grd
|
||||
pop ebp
|
||||
.skp:
|
||||
pop esi
|
||||
pop ecx
|
||||
add esi,8
|
||||
inc ecx
|
||||
cmp ecx,[edges_count]
|
||||
jnz .again_s_line
|
||||
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
@ -3071,8 +2986,8 @@ ret
|
||||
|
||||
fill_Z_buffer:
|
||||
mov eax,0x70000000
|
||||
cmp [dr_flag],12
|
||||
jne @f
|
||||
cmp [dr_flag],11
|
||||
jl @f
|
||||
mov eax,60000.1
|
||||
@@:
|
||||
mov edi,[Zbuffer_ptr]
|
||||
@ -3207,11 +3122,7 @@ read_from_file:
|
||||
xor ebp,ebp
|
||||
mov [points_count_var],0
|
||||
mov [triangles_count_var],0
|
||||
if USE_LFN = 0
|
||||
mov esi,SourceFile
|
||||
else
|
||||
mov esi,[fptr]
|
||||
end if
|
||||
cmp [esi],word 4D4Dh
|
||||
jne .exit ;Must be legal .3DS file
|
||||
; cmp dword[esi+2],EndFile-SourceFile
|
||||
@ -3298,17 +3209,14 @@ read_from_file:
|
||||
;mov edi,triangles
|
||||
@@:
|
||||
movzx eax,word[esi]
|
||||
add eax,ebp
|
||||
stosd
|
||||
movzx eax,word[esi+2]
|
||||
add eax,ebp
|
||||
stosd
|
||||
movzx eax,word[esi+4]
|
||||
add eax,ebp
|
||||
stosd
|
||||
; add dword[edi-12],ebp
|
||||
; add dword[edi-8],ebp
|
||||
; add dword[edi-4],ebp
|
||||
add dword[edi-12],ebp
|
||||
add dword[edi-8],ebp
|
||||
add dword[edi-4],ebp
|
||||
add esi,8
|
||||
dec ecx
|
||||
jnz @b
|
||||
@ -3337,6 +3245,14 @@ alloc_mem_for_tp:
|
||||
int 0x40 ; -> allocate memory to triangles
|
||||
mov [triangles_ptr], eax ; -> eax = pointer to allocated mem
|
||||
|
||||
mov eax, 68
|
||||
mov ecx,[triangles_count_var]
|
||||
imul ecx,[i36]
|
||||
mov edx,[edges_ptr]
|
||||
int 0x40 ; -> allocate memory to triangles
|
||||
mov [edges_ptr], eax ; -> eax = pointer to allocated mem
|
||||
|
||||
|
||||
; ststic memory
|
||||
|
||||
mov eax, 68
|
||||
@ -3410,7 +3326,6 @@ read_from_disk:
|
||||
@@:
|
||||
; eax = 0 -> ok file loaded
|
||||
ret
|
||||
|
||||
read_param:
|
||||
mov esi,I_Param
|
||||
cmp dword[esi],0
|
||||
@ -3482,6 +3397,64 @@ buttons: ; draw some buttons (all but navig
|
||||
cmp byte[edi],-1
|
||||
jnz .again
|
||||
ret
|
||||
write_info:
|
||||
mov eax,13
|
||||
mov bx,[size_x_var]
|
||||
shl ebx,16
|
||||
add ebx,120*65536+70 ; [x start] *65536 + [y start]
|
||||
mov ecx,30 shl 16 + 100
|
||||
xor edx,edx
|
||||
int 0x40
|
||||
|
||||
|
||||
xor esi,esi
|
||||
emms
|
||||
movd mm7,esi
|
||||
.nxxx:
|
||||
push esi
|
||||
movd mm7,esi
|
||||
|
||||
mov eax,4 ; function 4 : write text to window
|
||||
movzx ebx,word[size_x_var]
|
||||
shl ebx,16
|
||||
add ebx,120*65536 ; [x start] *65536 + [y start]
|
||||
mov bx,si
|
||||
shl bx,3
|
||||
add ebx,30
|
||||
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
|
||||
movd edx,mm7
|
||||
shl edx,2
|
||||
add edx,lab_vert ; pointer to text beginning
|
||||
mov esi,lab_vert_end-lab_vert ; text length
|
||||
int 0x40
|
||||
|
||||
movd esi,mm7
|
||||
mov eax,[points_count_var+esi]
|
||||
mov ecx,10
|
||||
.dc:
|
||||
xor edx,edx
|
||||
mov edi,10
|
||||
div edi
|
||||
add dl,30h
|
||||
mov [STRdata+ecx-1],dl
|
||||
loop .dc
|
||||
|
||||
mov eax,4 ; function 4 : write text to window
|
||||
mov bx,[size_x_var]
|
||||
add ebx,120
|
||||
shl ebx,16
|
||||
mov bx,si ; [x start] *65536 + [y start]
|
||||
shl bx,3
|
||||
add bx,45
|
||||
mov ecx,0x00ddeeff
|
||||
mov edx,STRdata ; pointer to text beginning
|
||||
mov esi,10 ; text length
|
||||
int 40h
|
||||
pop esi
|
||||
add esi,4
|
||||
cmp esi,12
|
||||
jnz .nxxx
|
||||
ret
|
||||
; *********************************************
|
||||
; ******* WINDOW DEFINITIONS AND DRAW ********
|
||||
; *********************************************
|
||||
@ -3499,7 +3472,7 @@ ret
|
||||
;ebx - [x start] *65536 + [x size]
|
||||
;ecx - [y start] *65536 + [y size]
|
||||
mov bx,[size_x_var]
|
||||
add bx,115
|
||||
add bx,225
|
||||
mov cx,[size_y_var]
|
||||
add cx,30
|
||||
; @@:
|
||||
@ -3511,6 +3484,16 @@ ret
|
||||
|
||||
.Y_ADD equ 2 ;-> offset of 'add vector' buttons
|
||||
|
||||
; mov eax,47
|
||||
; mov ebx,0000000000111000000000000000b
|
||||
; mov ecx,[points_count_var]
|
||||
; movzx edx,word[size_x_var]
|
||||
; shl edx,16
|
||||
; add edx,130*65536+60 ; [x start] *65536 + [y start]
|
||||
; mov esi,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
|
||||
; int 0x40
|
||||
call write_info
|
||||
|
||||
; ADD VECTOR LABEL ; add vector buttons - 30 ++
|
||||
mov eax,4 ; function 4 : write text to window
|
||||
movzx ebx,word[size_x_var]
|
||||
|
Loading…
Reference in New Issue
Block a user