view3ds 0.63 + fixed GUI

git-svn-id: svn://kolibrios.org@2984 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2012-10-10 08:46:24 +00:00
parent 380bfe324d
commit ec3ad22bed
6 changed files with 300 additions and 74 deletions

View File

@ -1,3 +1,104 @@
do_sinus:
.x equ [ebp-8]
.y equ [ebp-12]
.new_y equ [ebp-16]
.temp equ [ebp-20]
push ebp
mov ebp,esp
sub esp,64
mov dword .x,0
mov dword .y,0
mov esi,[screen_ptr]
mov edi,[Zbuffer_ptr]
push edi
; clear Zbuffer temporally used as image buffer
mov ecx,SIZE_X*SIZE_Y
xor eax,eax
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
cmp eax,SIZE_Y
jg .skip
; mov edx,SIZE_X
; mul edx
shl eax,9
add eax,dword .x
lea ebx,[eax*3]
mov eax,[esi]
mov [edi+ebx],eax
.skip:
add esi,3
inc dword .x
cmp dword .x,SIZE_X
jl .again
mov dword .x,0
inc dword .y
cmp dword .y,SIZE_Y
jl .again
; copy from temporary buffer -> Zbuffer to screen
mov esi,[Zbuffer_ptr]
mov edi,[screen_ptr]
mov ecx,SIZE_X*SIZE_Y*3/4
cld
rep movsd
mov esp,ebp
pop ebp
ret
draw_dots: draw_dots:
mov esi,[points_translated_ptr] mov esi,[points_translated_ptr]
movzx ecx,[points_count_var] movzx ecx,[points_count_var]

View File

@ -954,6 +954,19 @@ if Ext>=MMX
movq mm2,.dby movq mm2,.dby
movq mm3,.dey movq mm3,.dey
end if end if
if Ext >= SSE2
mov eax,TEXTURE_SIZE
movd xmm1,eax
shufps xmm1,xmm1,0
push dword TEX_X
push dword -TEX_X
push dword 1
push dword -1
movups xmm2,[esp]
movd xmm3,.bmap
shufps xmm3,xmm3,0
end if
;align 16 ;align 16
.draw: .draw:
; if TEX = SHIFTING ;bump drawing only in shifting mode ; if TEX = SHIFTING ;bump drawing only in shifting mode
@ -977,6 +990,35 @@ end if
shl eax,TEX_SHIFT ;- shl eax,TEX_SHIFT ;-
add esi,eax ;- ; esi - current bump map index add esi,eax ;- ; esi - current bump map index
if Ext = SSE2
movd xmm0,esi
shufps xmm0,xmm0,0
paddd xmm0,xmm2
pand xmm0,xmm1
paddd xmm0,xmm3
movd ebx,xmm0
movzx eax,byte[ebx]
;
; shufps xmm0,xmm0,11100001b
psrldq xmm0,4
movd ebx,xmm0
movzx ebx,byte[ebx]
sub eax,ebx
;
; shufps xmm0,xmm0,11111110b
psrldq xmm0,4
movd ebx,xmm0
movzx edx, byte [ebx]
;
; shufps xmm0,xmm0,11111111b
psrldq xmm0,4
movd ebx,xmm0
movzx ebx, byte [ebx]
sub edx,ebx
;
else
mov ebx,esi mov ebx,esi
dec ebx dec ebx
and ebx,TEXTURE_SIZE and ebx,TEXTURE_SIZE
@ -1004,6 +1046,7 @@ end if
movzx ebx,byte [ebx] movzx ebx,byte [ebx]
sub edx,ebx sub edx,ebx
end if
; eax - horizontal sub ; eax - horizontal sub
; edx - vertical sub ; edx - vertical sub
if Ext = NON if Ext = NON

View File

@ -1559,18 +1559,18 @@ end if
push dword .tx1 ; .ctx push dword .tx1 ; .ctx
push dword .ty1 ; .cty push dword .ty1 ; .cty
push edi ; .c_scr push edi ; .c_scr
;if Ext = SSE2 if Ext = SSE2
; mov eax,TEXTURE_SIZE mov eax,TEXTURE_SIZE
; movd xmm1,eax movd xmm1,eax
; shufps xmm1,xmm1,0 shufps xmm1,xmm1,0
; push dword TEX_X push dword TEX_X
; push dword -TEX_X push dword -TEX_X
; push dword 1 push dword 1
; push dword -1 push dword -1
; movups xmm2,[esp] movups xmm2,[esp]
; movd xmm3,.bmap movd xmm3,.bmap
; shufps xmm3,xmm3,0 shufps xmm3,xmm3,0
;end if end if
if Ext>=MMX if Ext>=MMX
movq mm7,.cty movq mm7,.cty
@ -1602,58 +1602,65 @@ end if
shl eax,TEX_SHIFT shl eax,TEX_SHIFT
add esi,eax ;- ; esi - current bump map index add esi,eax ;- ; esi - current bump map index
;if Ext = SSE2 if Ext = SSE2
;
; movd xmm0,esi movd xmm0,esi
; shufps xmm0,xmm0,0 shufps xmm0,xmm0,0
; paddd xmm0,xmm2 paddd xmm0,xmm2
; pand xmm0,xmm1 pand xmm0,xmm1
; paddd xmm0,xmm3 paddd xmm0,xmm3
;
; movd ebx,xmm0 movd ebx,xmm0
; movzx eax,byte[ebx] movzx eax,byte[ebx]
; ;
; shufps xmm0,xmm0,11100001b ; shufps xmm0,xmm0,11100001b
; movd ebx,xmm0 psrldq xmm0,4
; movzx ebx,byte[ebx] movd ebx,xmm0
; sub eax,ebx movzx ebx,byte[ebx]
sub eax,ebx
; ;
; shufps xmm0,xmm0,11111110b ; shufps xmm0,xmm0,11111110b
; movd ebx,xmm0 psrldq xmm0,4
; movzx edx, byte [ebx] movd ebx,xmm0
movzx edx, byte [ebx]
; ;
; shufps xmm0,xmm0,11111111b ; shufps xmm0,xmm0,11111111b
; movd ebx,xmm0 psrldq xmm0,4
; movzx ebx, byte [ebx] movd ebx,xmm0
; sub edx,ebx movzx ebx, byte [ebx]
sub edx,ebx
; ;
;else else
mov ebx,esi ; mov ebx,esi
dec ebx ; dec ebx
lea ebx,[esi-1]
and ebx,TEXTURE_SIZE and ebx,TEXTURE_SIZE
add ebx,.bmap add ebx,.bmap
movzx eax,byte [ebx] movzx eax,byte [ebx]
mov ebx,esi ; mov ebx,esi
inc ebx ; inc ebx
lea ebx,[esi+1]
and ebx,TEXTURE_SIZE and ebx,TEXTURE_SIZE
add ebx,.bmap add ebx,.bmap
movzx ebx,byte [ebx] movzx ebx,byte [ebx]
sub eax,ebx sub eax,ebx
mov ebx,esi ; mov ebx,esi
sub ebx,TEX_X ; sub ebx,TEX_X
lea ebx,[esi-TEX_X]
and ebx,TEXTURE_SIZE and ebx,TEXTURE_SIZE
add ebx,.bmap add ebx,.bmap
movzx edx,byte [ebx] movzx edx,byte [ebx]
mov ebx,esi ; mov ebx,esi
add ebx,TEX_X ; add ebx,TEX_X
lea ebx,[esi+TEX_X]
and ebx,TEXTURE_SIZE and ebx,TEXTURE_SIZE
add ebx,.bmap add ebx,.bmap
movzx ebx,byte [ebx] movzx ebx,byte [ebx]
sub edx,ebx sub edx,ebx
;end if end if
; eax - horizontal sub modificated x coord ; eax - horizontal sub modificated x coord
; edx - vertical sub modificated y coord ; edx - vertical sub modificated y coord

View File

@ -30,6 +30,9 @@
angle_x dw 0 angle_x dw 0
angle_y dw 0 angle_y dw 0
angle_z dw 0 angle_z dw 0
sin_amplitude dd 50
sin_frq dd 0.7
sin_delta dd 0.07 ; wave frequency granularity
menu: menu:
@ -125,7 +128,7 @@ fire_flag db 0
db 17 db 17
db 'move ' db 'move '
db 2 db 3
move_flag db 0 move_flag db 0
dd move_f dd move_f
@ -165,6 +168,12 @@ inc_bright_flag db 0 ;1
dec_bright_flag db 0 ;1 dec_bright_flag db 0 ;1
dd blur_f dd blur_f
db 24
db 'wav effect'
db 2
sinus_flag db 0
dd onoff_f
; db 24 ; db 24
; db 'max ' ; db 'max '
; db 2 ; db 2
@ -251,6 +260,7 @@ bumps_d_f: db ' 1 '
move_f: move_f:
db 'obj ' db 'obj '
db 'camr' db 'camr'
db 'wave'
; db 'lght' ; db 'lght'
bumps_f: bumps_f:
db 'rand' db 'rand'

View File

@ -61,23 +61,23 @@ elseif Ext=MMX
movq [.cz],mm0 movq [.cz],mm0
movq [.cg],mm1 movq [.cg],mm1
elseif Ext >= SSE2 elseif Ext >= SSE2
movups xmm1,[.cz] ; movups xmm1,[.cz]
paddd xmm1,xmm0 paddd xmm1,xmm0
movups [.cz],xmm1 ; movups [.cz],xmm1
end if end if
} }
macro .draw_pixel macro .draw_pixel
{ {
mov [esi],ebx ; actualize Z buffer mov [esi],ebx ; actualize Z buffer
;if Ext=SSE2 if Ext=SSE2
; movups xmm2,[.cb] movaps xmm7,xmm1 ;[.cb] ;;xmm1
; shufps xmm1,xmm1,11000110b shufps xmm7,xmm7,00111001b
; pand xmm1,[.mask] psrld xmm7,ROUND
; psrld xmm2,ROUND packssdw xmm7,xmm7
; packssdw xmm2,xmm2 packuswb xmm7,xmm7
; packuswb xmm2,xmm2 pand xmm7,xmm6 ;[.mask]
; movss [edi],xmm2 movd [edi],xmm7
;else else
mov eax,[.cb] mov eax,[.cb]
sar eax,ROUND sar eax,ROUND
@ -90,7 +90,7 @@ macro .draw_pixel
mov edx,[.cr] mov edx,[.cr]
sar edx,ROUND sar edx,ROUND
mov [edi+2],dl mov [edi+2],dl
;end if end if
; shl ebx,16 ; shl ebx,16
; or eax,ebx ; or eax,ebx
; mov [edi],eax ; mov [edi],eax
@ -208,8 +208,15 @@ end if
movsx ebx,word[.z1] movsx ebx,word[.z1]
shl ebx,ROUND shl ebx,ROUND
mov [.cz],ebx mov [.cz],ebx
if Ext = SSE2
movups xmm1,[.cz]
end if
.hdraw: .hdraw:
if Ext = SSE2
movd ebx,xmm1
else
mov ebx,[.cz] mov ebx,[.cz]
end if
cmp [esi],ebx cmp [esi],ebx
jle .skip jle .skip
@ -267,8 +274,16 @@ end if
movsx ebx,word[.z1] movsx ebx,word[.z1]
shl ebx,ROUND shl ebx,ROUND
mov [.cz],ebx mov [.cz],ebx
if Ext = SSE2
movups xmm1,[.cz]
end if
.v_draw: .v_draw:
if Ext = SSE2
movd ebx,xmm1
else
mov ebx,[.cz] mov ebx,[.cz]
end if
cmp [esi],ebx cmp [esi],ebx
jle @f jle @f
@ -331,7 +346,11 @@ end if
shl ebx,ROUND shl ebx,ROUND
mov [.cz],ebx mov [.cz],ebx
.d45_draw: .d45_draw:
if Ext = SSE2
movd ebx,xmm1
else
mov ebx,[.cz] mov ebx,[.cz]
end if
cmp [esi],ebx cmp [esi],ebx
jle @f jle @f
@ -400,6 +419,9 @@ end if
movsx ebx,word[.z1] movsx ebx,word[.z1]
shl ebx,ROUND shl ebx,ROUND
mov [.cz],ebx mov [.cz],ebx
if Ext = SSE2
movups xmm1,[.cz]
end if
movsx ebx,word[.x1] movsx ebx,word[.x1]
shl ebx,ROUND shl ebx,ROUND
mov [.ccoord],ebx ; .ccoord -> x coordinate mov [.ccoord],ebx ; .ccoord -> x coordinate
@ -412,7 +434,11 @@ end if
add edi,ebx add edi,ebx
add esi,ebx add esi,ebx
add esi,eax add esi,eax
if Ext = SSE2
movd ebx,xmm1
else
mov ebx,[.cz] mov ebx,[.cz]
end if
cmp [esi],ebx cmp [esi],ebx
jle @f jle @f
@ -480,6 +506,9 @@ end if
movsx ebx,word[.z1] movsx ebx,word[.z1]
shl ebx,ROUND shl ebx,ROUND
mov [.cz],ebx mov [.cz],ebx
if Ext = SSE2
movups xmm1,[.cz]
end if
movsx ebx,word[.y1] movsx ebx,word[.y1]
shl ebx,ROUND shl ebx,ROUND
mov [.ccoord],ebx ; .ccoord -> y coordinate mov [.ccoord],ebx ; .ccoord -> y coordinate
@ -495,7 +524,11 @@ end if
lea eax,[eax*3] lea eax,[eax*3]
add esi,eax add esi,eax
add edi,eax add edi,eax
if Ext = SSE2
movd ebx,xmm1
else
mov ebx,[.cz] mov ebx,[.cz]
end if
cmp [esi],ebx cmp [esi],ebx
jle @f jle @f
@ -553,12 +586,12 @@ if Ext=MMX | Ext = SSE
movq mm3,[.dg] movq mm3,[.dg]
else if Ext >= SSE2 else if Ext >= SSE2
movups xmm0,[.dz] movups xmm0,[.dz]
movups xmm6,[.mask]
end if end if
ret ret
;align 16 .mask:
;.mask: dq 0xffffffff00ffffff
; dq 0xffffffffffffffff dq 0xffffffffffffffff
; dq 0xffffffff00000000

View File

@ -1,5 +1,5 @@
; application : View3ds ver. 0.062 - tiny .3ds files viewer. ; application : View3ds ver. 0.063 - tiny .3ds files viewer.
; compiler : FASM ; compiler : FASM
; system : KolibriOS ; system : KolibriOS
; author : Macgub aka Maciej Guba ; author : Macgub aka Maciej Guba
@ -265,16 +265,19 @@ still:
; ;
cmp ah,30 cmp ah,30
jne .next jne .next
cmp [move_flag],1 cmp [move_flag],0
je @f jne @f
; cmp [move_flag],2 ; cmp [move_flag],2
; je .set_light1 ; je .set_light1
sub [vect_y],10 sub [vect_y],10
jmp .next jmp .next
@@: @@:
cmp [move_flag],1
jne @f
sub [yobs],10 ; observator = camera position sub [yobs],10 ; observator = camera position
jmp .next jmp .next
@@:
sub [sin_amplitude],10
;-------------------------------------------------- ;--------------------------------------------------
; .set_light1: ; r - ; .set_light1: ; r -
; movzx ebx,[light_no_flag] ; * 22 ; movzx ebx,[light_no_flag] ; * 22
@ -296,7 +299,6 @@ still:
jne .next1 jne .next1
cmp [move_flag],1 cmp [move_flag],1
je @f je @f
add [vect_z],10 add [vect_z],10
jmp .next1 jmp .next1
@@: @@:
@ -304,23 +306,37 @@ still:
.next1: .next1:
cmp ah,33 cmp ah,33
jne .next2 jne .next2
cmp [move_flag],1 cmp [move_flag],0
je @f jne @f
sub [vect_x],10 sub [vect_x],10
jmp .next2 jmp .next2
@@: @@:
cmp [move_flag],1
jne @f
sub [xobs],10 ; observator = camera position sub [xobs],10 ; observator = camera position
jmp .next2
@@:
fninit
fld [sin_frq]
fsub [sin_delta]
fstp [sin_frq]
.next2: .next2:
cmp ah,32 cmp ah,32
jne .next3 jne .next3
cmp [move_flag],1 cmp [move_flag],0
je @f jne @f
add [vect_x],10 add [vect_x],10
jmp .next3 jmp .next3
@@: @@:
cmp [move_flag],1
jne @f
add [xobs],10 ; observator = camera position add [xobs],10 ; observator = camera position
jmp .next3
@@:
fninit
fld [sin_frq] ; change wave effect frequency
fadd [sin_delta]
fstp [sin_frq]
.next3: .next3:
cmp ah,34 cmp ah,34
jne .next4 jne .next4
@ -334,14 +350,18 @@ still:
.next4: .next4:
cmp ah,35 cmp ah,35
jne .next5 jne .next5
cmp [move_flag],1 cmp [move_flag],0
je @f jne @f
; call add_vector ; call add_vector
add [vect_y],10 add [vect_y],10
jmp .next5 jmp .next5
@@: @@:
cmp [move_flag],1
jne @f
add [yobs],10 ; observator = camera position add [yobs],10 ; observator = camera position
jmp .next5
@@:
add [sin_amplitude],10
.next5: .next5:
@ -435,6 +455,10 @@ still:
@@: @@:
call draw_triangles ; draw all triangles from the list call draw_triangles ; draw all triangles from the list
.blurrr: .blurrr:
cmp [sinus_flag],0
je @f
call do_sinus
@@:
cmp [fire_flag],0 cmp [fire_flag],0
jne @f jne @f
cmp [blur_flag],0 cmp [blur_flag],0
@ -629,7 +653,7 @@ if Ext >= SSE
end if end if
.no_min: .no_min:
end if end if
;========================commented=====================================
RDTSC RDTSC
sub eax,[esp] sub eax,[esp]
sub eax,41 sub eax,41
@ -648,7 +672,7 @@ end if
mov eax,7 ; put image mov eax,7 ; put image
mov ebx,screen mov ebx,screen
mov ecx,SIZE_X shl 16 + SIZE_Y mov ecx,SIZE_X shl 16 + SIZE_Y
mov edx,5 shl 16 + 23 mov edx,5 shl 16 + 25
int 0x40 int 0x40
mov eax,13 mov eax,13
@ -2789,6 +2813,14 @@ alloc_mem_for_tp:
int 0x40 ; -> allocate memory to edges int 0x40 ; -> allocate memory to edges
mov [edges_ptr], eax ; -> eax = pointer to allocated mem mov [edges_ptr], eax ; -> eax = pointer to allocated mem
mov eax,-1 ; fill edges list
movzx ecx,[triangles_count_var] ; importand if object generated
shr ecx,2
inc ecx
mov edi,[edges_ptr]
cld
rep stosd
; mov eax, 68 ; mov eax, 68
; mov ebx, 12 ; mov ebx, 12
@ -2978,7 +3010,7 @@ ret
mov ebx,100*65536;+SIZE_X;+80+30 ; [x start] *65536 + [x size] mov ebx,100*65536;+SIZE_X;+80+30 ; [x start] *65536 + [x size]
mov ecx,100*65536;+SIZE_Y;+30 ; [y start] *65536 + [y size] mov ecx,100*65536;+SIZE_Y;+30 ; [y start] *65536 + [y size]
mov bx,[size_x] mov bx,[size_x]
add bx,114 add bx,115
mov cx,[size_y] mov cx,[size_y]
add cx,30 add cx,30
mov edx,0x14000000 ; color of work area RRGGBB,8->color gl mov edx,0x14000000 ; color of work area RRGGBB,8->color gl