view3ds 0073 by macgub

git-svn-id: svn://kolibrios.org@8719 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2021-05-12 00:26:00 +00:00
parent 1c24cac315
commit 73122f1cb1
9 changed files with 7546 additions and 7756 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,327 +1,329 @@
ROUND2 equ 10 ROUND2 equ 10
stencil_tri: stencil_tri:
; procedure calculate triangle in stencil buffer ; procedure calculate triangle in stencil buffer
; ----------------in - eax - x1 shl 16 + y1 ---------------------- ; ----------------in - eax - x1 shl 16 + y1 ----------------------
; -------------------- ebx - x2 shl 16 + y2 ---------------------- ; -------------------- ebx - x2 shl 16 + y2 ----------------------
; -------------------- ecx - x3 shl 16 + y3 ---------------------- ; -------------------- ecx - x3 shl 16 + y3 ----------------------
; -------------------- esi - pointer to s-buffer ----------------- ; -------------------- esi - pointer to s-buffer -----------------
; -------------------- xmm0 - lo -> hi z1, z2, z3 as dword float ; -------------------- xmm0 - lo -> hi z1, z2, z3 as dword float
.x1 equ [ebp-2] .x1 equ [ebp-2]
.y1 equ [ebp-4] .y1 equ [ebp-4]
.x2 equ [ebp-6] .x2 equ [ebp-6]
.y2 equ [ebp-8] .y2 equ [ebp-8]
.x3 equ [ebp-10] .x3 equ [ebp-10]
.y3 equ [ebp-12] .y3 equ [ebp-12]
.dx12 equ dword[ebp-20] .dx12 equ dword[ebp-20]
.dx13 equ dword[ebp-24] .dx13 equ dword[ebp-24]
.dx23 equ dword[ebp-28] .dx23 equ dword[ebp-28]
.dz12 equ dword[ebp-32] .dz12 equ dword[ebp-32]
.dz13 equ dword[ebp-36] .dz13 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
xchg eax,ebx xchg eax,ebx
shufps xmm0,xmm0,11100001b shufps xmm0,xmm0,11100001b
.sort1: .sort1:
cmp bx,cx cmp bx,cx
jle .sort3 jle .sort3
xchg ebx,ecx xchg ebx,ecx
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
; 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 movaps .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
and edx,ecx and edx,ecx
and edx,eax and edx,eax
test edx,80008000h ; Check both X&Y at once test edx,80008000h ; Check both X&Y at once
jne .loop2_end jne .loop2_end
mov bx,.y2 ; calc delta 12 mov bx,.y2 ; calc delta 12
sub bx,.y1 sub bx,.y1
jnz .dx12_make jnz .dx12_make
mov .dx12,0 mov .dx12,0
mov .dz12,0 mov .dz12,0
jmp .dx12_done jmp .dx12_done
.dx12_make: .dx12_make:
mov ax,.x2 mov ax,.x2
sub ax,.x1 sub ax,.x1
cwde cwde
movsx ebx,bx movsx ebx,bx
shl eax,ROUND2 shl eax,ROUND2
cdq cdq
idiv ebx idiv ebx
mov .dx12,eax mov .dx12,eax
movss xmm1,.z2 movss xmm1,.z2
cvtsi2ss xmm2,ebx cvtsi2ss xmm2,ebx
subss xmm1,.z1 subss xmm1,.z1
divss xmm1,xmm2 divss xmm1,xmm2
movss .dz12,xmm1 movss .dz12,xmm1
; mov .dz12, dword 0.11 ; mov .dz12, dword 0.11
.dx12_done: .dx12_done:
mov bx,.y3 ; calc delta 13 mov bx,.y3 ; calc delta 13
sub bx,.y1 sub bx,.y1
jnz .dx13_make jnz .dx13_make
mov .dx13,0 mov .dx13,0
mov .dz13,0 mov .dz13,0
jmp .dx13_done jmp .dx13_done
.dx13_make: .dx13_make:
mov ax,.x3 mov ax,.x3
sub ax,.x1 sub ax,.x1
cwde cwde
movsx ebx,bx movsx ebx,bx
shl eax,ROUND2 shl eax,ROUND2
cdq cdq
idiv ebx idiv ebx
mov .dx13,eax mov .dx13,eax
movss xmm1,.z3 movss xmm1,.z3
cvtsi2ss xmm2,ebx cvtsi2ss xmm2,ebx
subss xmm1,.z1 subss xmm1,.z1
divss xmm1,xmm2 divss xmm1,xmm2
movss .dz13,xmm1 movss .dz13,xmm1
; mov .dz13, dword 0.11 ; mov .dz13, dword 0.11
.dx13_done: .dx13_done:
mov bx,.y3 ; calc delta 23 mov bx,.y3 ; calc delta 23
sub bx,.y2 sub bx,.y2
jnz .dx23_make jnz .dx23_make
mov .dx23,0 mov .dx23,0
mov .dz23,0 mov .dz23,0
jmp .dx23_done jmp .dx23_done
.dx23_make: .dx23_make:
mov ax,.x3 mov ax,.x3
sub ax,.x2 sub ax,.x2
cwde cwde
movsx ebx,bx movsx ebx,bx
shl eax,ROUND2 shl eax,ROUND2
cdq cdq
idiv ebx idiv ebx
mov .dx23,eax mov .dx23,eax
movss xmm1,.z3 movss xmm1,.z3
cvtsi2ss xmm2,ebx cvtsi2ss xmm2,ebx
subss xmm1,.z2 subss xmm1,.z2
divss xmm1,xmm2 divss xmm1,xmm2
movss .dz23,xmm1 movss .dz23,xmm1
.dx23_done: .dx23_done:
mov edx,.z1 mov edx,.z1
mov .zz1,edx mov .zz1,edx
mov .zz2,edx mov .zz2,edx
movsx eax,word .x1 movsx eax,word .x1
shl eax,ROUND2 ; eax - cur x1 shl eax,ROUND2 ; eax - cur x1
mov ebx,eax ; ebx - cur x2 mov ebx,eax ; ebx - cur x2
mov cx,.y1 mov cx,.y1
cmp cx,.y2 cmp cx,.y2
jge .loop1_end jge .loop1_end
.loop1: .loop1:
pushad pushad
sar ebx,ROUND2 sar ebx,ROUND2
sar eax,ROUND2 sar eax,ROUND2
; movq xmm0,.zz1 ; movq xmm0,.zz1
movlps xmm0,.zz1 movlps xmm0,.zz1
; 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
popad popad
add eax,.dx13 add eax,.dx13
add ebx,.dx12 add ebx,.dx12
movss xmm1,.zz1 movss xmm1,.zz1
movss xmm2,.zz2 movss xmm2,.zz2
addss xmm1,.dz13 addss xmm1,.dz13
addss xmm2,.dz12 addss xmm2,.dz12
movss .zz1,xmm1 movss .zz1,xmm1
movss .zz2,xmm2 movss .zz2,xmm2
add cx,1 add cx,1
cmp cx,.y2 cmp cx,.y2
jl .loop1 jl .loop1
.loop1_end: .loop1_end:
mov edx,.z2 mov edx,.z2
mov .zz2,edx mov .zz2,edx
movsx ebx,word .x2 movsx ebx,word .x2
shl ebx,ROUND2 shl ebx,ROUND2
mov cx,.y2 mov cx,.y2
cmp cx,.y3 cmp cx,.y3
jge .loop2_end jge .loop2_end
.loop2: .loop2:
pushad pushad
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
popad popad
add eax,.dx13 add eax,.dx13
add ebx,.dx23 add ebx,.dx23
movss xmm1,.zz1 movss xmm1,.zz1
movss xmm2,.zz2 movss xmm2,.zz2
addss xmm1,.dz13 addss xmm1,.dz13
addss xmm2,.dz23 addss xmm2,.dz23
movss .zz1,xmm1 movss .zz1,xmm1
movss .zz2,xmm2 movss .zz2,xmm2
add cx,1 add cx,1
cmp cx,.y3 cmp cx,.y3
jl .loop2 jl .loop2
.loop2_end: .loop2_end:
add esp,128 add esp,128
pop ebp pop ebp
ret ret
stencil_line: stencil_line:
;---------------------------------------------------- ;----------------------------------------------------
;-------------in xmm0 - lo -> hi z1, z2 ;-------------in xmm0 - lo -> hi z1, z2
;--------------- eax - x1 --------------------------- ;--------------- eax - x1 ---------------------------
;--------------- ebx - x2 --------------------------- ;--------------- ebx - x2 ---------------------------
;--------------- ecx - y----------------------------- ;--------------- ecx - y-----------------------------
;--------------- esi - pointer to s-buffer ;--------------- esi - pointer to s-buffer
.dz equ [ebp-4] .dz equ [ebp-4]
.z2 equ [ebp-8] .z2 equ [ebp-8]
.z1 equ [ebp-12] .z1 equ [ebp-12]
.x2 equ [ebp-16] .x2 equ [ebp-16]
.x1 equ [ebp-20] .x1 equ [ebp-20]
.s_buf equ [ebp-24] .s_buf equ [ebp-24]
; cmp eax,ebx ; cmp eax,ebx
; je @f ; je @f
; int3 ; int3
; @@: ; @@:
push ebp push ebp
mov ebp,esp mov ebp,esp
sub esp,64 sub esp,64
; cmp eax,0 ; cmp eax,0
; jg @f ; jg @f
; ;
; @@: ; @@:
or cx,cx or cx,cx
jle .l_quit jle .l_quit
cmp cx,[size_y_var] cmp cx,[size_y_var]
jge .l_quit jge .l_quit
movzx ecx,cx movzx ecx,cx
mov .s_buf,esi mov .s_buf,esi
cmp eax,ebx cmp eax,ebx
je .l_quit je .l_quit
jl .l_ok jl .l_ok
xchg eax,ebx xchg eax,ebx
shufps xmm0,xmm0,11100001b shufps xmm0,xmm0,11100001b
.l_ok: .l_ok:
cmp ax,[size_x_var] cmp ax,[size_x_var]
jge .l_quit jge .l_quit
cmp bx,0 cmp bx,0
jle .l_quit jle .l_quit
movlps .z1,xmm0 movlps .z1,xmm0
mov .x1,eax mov .x1,eax
mov .x2,ebx mov .x2,ebx
sub ebx,eax sub ebx,eax
movss xmm0,.z2 movss xmm0,.z2
cvtsi2ss xmm1,ebx cvtsi2ss xmm1,ebx
subss xmm0,.z1 subss xmm0,.z1
divss xmm0,xmm1 divss xmm0,xmm1
movss .dz,xmm0 movss .dz,xmm0
movzx edx,word[size_x_var] movzx edx,word[size_x_var]
cmp eax,1 cmp eax,1
jge @f jge @f
mov eax,.x1 mov eax,.x1
neg eax neg eax
cvtsi2ss xmm2,eax cvtsi2ss xmm2,eax
mulss xmm2,.dz mulss xmm2,.dz
addss xmm2,.z1 addss xmm2,.z1
movss .z1,xmm2 movss .z1,xmm2
mov dword .x1,0 mov dword .x1,0
movzx edx,word[size_x_var] movzx edx,word[size_x_var]
sub edx,1 sub edx,1
@@: @@:
cmp .x2,edx cmp .x2,edx
jl @f jl @f
mov .x2,edx mov .x2,edx
@@: @@:
; mov eax,.x1 ; mov eax,.x1
; cmp .x2,eax ; cmp .x2,eax
; je .l_quit ; je .l_quit
movzx edx,word[size_x_var] movzx edx,word[size_x_var]
mov esi,.s_buf mov esi,.s_buf
mov eax,ecx ; y mov eax,ecx ; y
mul edx mul edx
add eax,.x1 add eax,.x1
shl eax,2 shl eax,2
add esi,eax add esi,eax
mov ecx,.x2 mov ecx,.x2
sub ecx,.x1 sub ecx,.x1
movss xmm2,.z1 ; cz movss xmm2,.z1 ; cz
.ccalc: .ccalc:
; movss xmm1,xmm2 movss xmm1,xmm2
comiss xmm2,dword[esi] cmpltss xmm1,dword[esi]
jg @f movd eax,xmm1
movss dword[esi],xmm2 cmp eax,-1
@@: jnz @f
add esi,4 movss dword[esi],xmm2
addss xmm2,.dz @@:
sub ecx,1 add esi,4
jnz .ccalc addss xmm2,.dz
.l_quit: sub ecx,1
mov esp,ebp jnz .ccalc
pop ebp .l_quit:
ret mov esp,ebp
pop ebp
ret

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,643 +1,115 @@
;-procedure draws smooth shaded lines (I mean interpolation 24 bit-- ; Line drawing procedure by Pablo Reda.
;-color), with z coord interpolation-------------------------------- ; Gouraud extension by Maciej Guba.
;-author: Maciej Guba (www.macgub.hekko.pl)------------------------- ;****************************************************
;-in : ------------------------------------------------------------- line_grd: ; eax=x1 ebx=y1 ecx=x2 edx=y2
;----- edi - pointer to screen buffer ------------------------------ ; xmm0 - color1 argb as 4 dword float
;----- esi - pointer to Z buffer ----------------------------------- ; xmm1 - color2 argb as 4 dword float
;------ constans : SIZE_X, SIZE_Y - screen width and height--------- ; xmm2 - z1 as dword float
;----------------- ROUND - fixed point shift------------------------ ; xmm3 - z2 as dword float
;------ other parameters via stack---------------------------------- ; mm0 - Z buffer
smooth_line: ; mm1 - screen buffer
.x1 equ ebp+4 ; mm2 - screen width
.y1 equ ebp+6
.z1 equ ebp+8
.r1 equ ebp+10 cmp ebx,edx
.g1 equ ebp+12 ; je horizontal_grd
.b1 equ ebp+14 jg .noswap
.x2 equ ebp+16 xchg eax,ecx
.y2 equ ebp+18 xchg ebx,edx
.z2 equ ebp+20 movaps xmm7,xmm0
.r2 equ ebp+22 movaps xmm0,xmm1
.g2 equ ebp+24 movaps xmm1,xmm7
.b2 equ ebp+26 movaps xmm7,xmm2
movaps xmm2,xmm3
movaps xmm3,xmm7
.line_lenght equ ebp-2 .noswap:
.delta equ ebp-6
.delta_x equ ebp-10 cvtsi2ss xmm7,eax
.delta_y equ ebp-14 cvtsi2ss xmm6,ebx
.dr equ ebp-18 cvtsi2ss xmm5,ecx
.dg equ ebp-22 cvtsi2ss xmm4,edx
.db equ ebp-26 subss xmm7,xmm5
.dz equ ebp-30 subss xmm6,xmm4
.cr equ ebp-34 andps xmm7,[abs_mask] ; 0x7fff
.cg equ ebp-38 andps xmm6,[abs_mask] ; 0x7fff
.cb equ ebp-42 maxss xmm7,xmm6 ; xmm7 - delta
.cz equ ebp-46 shufps xmm7,xmm7,0
movaps xmm6,xmm3
;.line_lenght equ ebp-48 rcpps xmm7,xmm7
.screen equ ebp-52 subss xmm6,xmm2
.zbuffer equ ebp-56 mulss xmm6,xmm7 ; xmm6 - delta z
.ccoord equ ebp-60 ;current coordinate movaps xmm5,xmm1
.czbuf equ ebp-64 subps xmm5,xmm0
.cscr equ ebp-68 mulps xmm5,xmm7 ; xmm5 - delta col argb
.xres equ ebp-72
.yres equ ebp-76
.xresm1 equ ebp-80 shl eax,16
.yresm1 equ ebp-84 shl ecx,16
.xresp1 equ ebp-88 sub eax,ecx
.yresp1 equ ebp-92 push ebx
.xres3 equ ebp-96 push edx
.xres4 equ ebp-100 sub ebx,edx
add ebx,1
macro .update_cur_var cdq
{ idiv ebx
if Ext=NON mov esi,eax
mov ebx,[.dz] add ecx,$7fff
add [.cz],ebx pop ebx
mov ebx,[.dr] pop edx
add [.cr],ebx .lineas:
mov ebx,[.dg] mov eax,ecx
add [.cg],ebx add eax,esi
mov ebx,[.db] push ebx
add [.cb],ebx push eax
elseif Ext=MMX push edx
movq mm0,[.cz] shr ecx,16
movq mm1,[.cg] shr eax,16
paddd mm0,mm2 ;[.dz] call horizontal_grd
paddd mm1,mm3 ;[.dg] pop edx
movq [.cz],mm0 pop ecx
movq [.cg],mm1 pop ebx
elseif Ext >= SSE2 add ebx,1
; movups xmm1,[.cz] cmp ebx,edx
paddd xmm1,xmm0 jle .lineas
; movups [.cz],xmm1 ret
end if
} horizontal_grd: ; eax=x1 ebx=y1 ecx=x2
macro .draw_pixel cmp ecx,eax
{ jg .m
mov [esi],ebx ; actualize Z buffer xchg ecx,eax
if Ext>=SSE2 .m:
movaps xmm7,xmm1 ;[.cb] ;;xmm1 sub ecx,eax
shufps xmm7,xmm7,00111001b jnz .nn
psrld xmm7,ROUND add ecx,1
packssdw xmm7,xmm7 .nn:
packuswb xmm7,xmm7 movd edx,mm2
pand xmm7,xmm6 ;[.mask] imul ebx,edx
movd [edi],xmm7 add eax,ebx
else movd edi,mm1
lea edi,[edi+eax*4]
mov eax,[.cb] push eax
sar eax,ROUND push ebx
mov [edi],al movd ebx,mm0
; and eax,0x000000ff ; clean unused bits lea ebx,[ebx+eax*4]
mov ebx,[.cg] .l:
sar ebx,ROUND ; movss xmm4,xmm2 ; xmm2 - cur z
mov [edi+1],bl ; cmpnltss xmm4,[ebx]
; mov ah,bl ; movd eax,xmm4
mov edx,[.cr] ; or eax,eax
sar edx,ROUND ; jnz @f
mov [edi+2],dl comiss xmm2,[ebx]
end if jng @f
; shl ebx,16 movaps xmm4,xmm0 ; xmm0 - cur col
; or eax,ebx cvtps2dq xmm4,xmm4
; mov [edi],eax packssdw xmm4,xmm4
} packuswb xmm4,xmm4
macro .sort movd [edi],xmm4
{ @@:
addss xmm2,xmm6
if Ext >= MMX addps xmm0,xmm5
movq mm0,[.x1] add edi,4
movq mm1,[.x2] sub ecx,1
movq [.x1],mm1 jnz .l
movq [.x2],mm0 pop ebx
else pop eax
mov edx,[.x1] ret
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
}
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
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
ret
.mask:
dq 0xffffffff00ffffff
dq 0xffffffffffffffff

View File

@ -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 View3ds 0.071 - VIII 2020
1. New displaying model - glass - it's two pass rendering. First pass calculates 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 Z position of all front pixels, second render image with adding reflective

View File

@ -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. effects implementation.
What's new? 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 1. New displaying model - texturing with bilinear filtering and transparency
simultanusly. Note that filtering is done only inside polygon. To better 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 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). 8. rand. light: Randomize 3 unlinear lights( so called Phong's illumination).
9. Blur: blur N times; N=0,1,2,3,4,5 9. Blur: blur N times; N=0,1,2,3,4,5
10.11,12,13. loseless operations (rotary 90, 180 degrees). 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 ). 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, 14. move: changes meaning x,y,z +/- buttons -> obj: moving object, camr: moving
decrease wave effect frequency and amplitude. camera, wave: x,y +/- increase, decrease wave effect frequency and amplitude.
15. generate: Generates some objects: node, Thorn Crown, heart... 15. generate: Generates some objects: node, Thorn Crown, heart...
16. bumps: random, according to texture. 16. bumps: random, according to texture.
17. bumps deep -> create bumps deeper or lighter. 17. bumps deep -> create bumps deeper or lighter.
18. re-map tex -> re-map texture and bump map coordinates, to change spherical mapping 18. re-map tex -> re-map texture and bump map coordinates, to change spherical
around axle use 'xchg' and 'mirror' buttons, then press 're-map tex' button. mapping around axle use 'xchg' and 'mirror' buttons, then press 're-map tex' button.
19. bright + -> increase picture brightness. 19. bright + -> increase picture brightness.
20. bright - -> decrease picture brightness. 20. bright - -> decrease picture brightness.
21. wav effect -> do effect based sine function. 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 22. editor -> setting editing option. If is "on" then red bars are draw according to each
and moving left mouse button (cursor must be on handler)- change vertex position. If left mouse button vertex, Pressing and moving left mouse button (cursor must be on handler)- change
is released apply current position. You may also decrease whole handlers count by enable culling (using vertex position. If left mouse button is released apply current position. You may also
appropriate button) - some back handlers become hidden. decrease whole handlers count by enable culling (using appropriate button) - some
back handlers become hidden.
Maciej Guba III 2021 Maciej Guba V 2021

File diff suppressed because it is too large Load Diff