forked from KolibriOS/kolibrios
view3ds 0.63 + fixed GUI
git-svn-id: svn://kolibrios.org@2984 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
380bfe324d
commit
ec3ad22bed
@ -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:
|
||||
mov esi,[points_translated_ptr]
|
||||
movzx ecx,[points_count_var]
|
||||
|
@ -954,6 +954,19 @@ if Ext>=MMX
|
||||
movq mm2,.dby
|
||||
movq mm3,.dey
|
||||
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
|
||||
.draw:
|
||||
; if TEX = SHIFTING ;bump drawing only in shifting mode
|
||||
@ -977,6 +990,35 @@ end if
|
||||
shl eax,TEX_SHIFT ;-
|
||||
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
|
||||
dec ebx
|
||||
and ebx,TEXTURE_SIZE
|
||||
@ -1004,6 +1046,7 @@ end if
|
||||
movzx ebx,byte [ebx]
|
||||
|
||||
sub edx,ebx
|
||||
end if
|
||||
; eax - horizontal sub
|
||||
; edx - vertical sub
|
||||
if Ext = NON
|
||||
|
@ -1559,18 +1559,18 @@ end if
|
||||
push dword .tx1 ; .ctx
|
||||
push dword .ty1 ; .cty
|
||||
push edi ; .c_scr
|
||||
;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
|
||||
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
|
||||
|
||||
if Ext>=MMX
|
||||
movq mm7,.cty
|
||||
@ -1602,58 +1602,65 @@ end if
|
||||
shl eax,TEX_SHIFT
|
||||
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]
|
||||
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
|
||||
; movd ebx,xmm0
|
||||
; movzx ebx,byte[ebx]
|
||||
; sub eax,ebx
|
||||
psrldq xmm0,4
|
||||
movd ebx,xmm0
|
||||
movzx ebx,byte[ebx]
|
||||
sub eax,ebx
|
||||
;
|
||||
; shufps xmm0,xmm0,11111110b
|
||||
; movd ebx,xmm0
|
||||
; movzx edx, byte [ebx]
|
||||
psrldq xmm0,4
|
||||
movd ebx,xmm0
|
||||
movzx edx, byte [ebx]
|
||||
;
|
||||
; shufps xmm0,xmm0,11111111b
|
||||
; movd ebx,xmm0
|
||||
; movzx ebx, byte [ebx]
|
||||
; sub edx,ebx
|
||||
psrldq xmm0,4
|
||||
movd ebx,xmm0
|
||||
movzx ebx, byte [ebx]
|
||||
sub edx,ebx
|
||||
;
|
||||
;else
|
||||
mov ebx,esi
|
||||
dec ebx
|
||||
else
|
||||
; mov ebx,esi
|
||||
; dec ebx
|
||||
lea ebx,[esi-1]
|
||||
and ebx,TEXTURE_SIZE
|
||||
add ebx,.bmap
|
||||
movzx eax,byte [ebx]
|
||||
|
||||
mov ebx,esi
|
||||
inc ebx
|
||||
; mov ebx,esi
|
||||
; inc ebx
|
||||
lea ebx,[esi+1]
|
||||
and ebx,TEXTURE_SIZE
|
||||
add ebx,.bmap
|
||||
movzx ebx,byte [ebx]
|
||||
sub eax,ebx
|
||||
|
||||
mov ebx,esi
|
||||
sub ebx,TEX_X
|
||||
; mov ebx,esi
|
||||
; sub ebx,TEX_X
|
||||
lea ebx,[esi-TEX_X]
|
||||
and ebx,TEXTURE_SIZE
|
||||
add ebx,.bmap
|
||||
movzx edx,byte [ebx]
|
||||
|
||||
mov ebx,esi
|
||||
add ebx,TEX_X
|
||||
; mov ebx,esi
|
||||
; add ebx,TEX_X
|
||||
lea ebx,[esi+TEX_X]
|
||||
and ebx,TEXTURE_SIZE
|
||||
add ebx,.bmap
|
||||
movzx ebx,byte [ebx]
|
||||
sub edx,ebx
|
||||
;end if
|
||||
end if
|
||||
|
||||
; eax - horizontal sub modificated x coord
|
||||
; edx - vertical sub modificated y coord
|
||||
|
@ -30,6 +30,9 @@
|
||||
angle_x dw 0
|
||||
angle_y dw 0
|
||||
angle_z dw 0
|
||||
sin_amplitude dd 50
|
||||
sin_frq dd 0.7
|
||||
sin_delta dd 0.07 ; wave frequency granularity
|
||||
|
||||
|
||||
menu:
|
||||
@ -125,7 +128,7 @@ fire_flag db 0
|
||||
|
||||
db 17
|
||||
db 'move '
|
||||
db 2
|
||||
db 3
|
||||
move_flag db 0
|
||||
dd move_f
|
||||
|
||||
@ -165,6 +168,12 @@ inc_bright_flag db 0 ;1
|
||||
dec_bright_flag db 0 ;1
|
||||
dd blur_f
|
||||
|
||||
db 24
|
||||
db 'wav effect'
|
||||
db 2
|
||||
sinus_flag db 0
|
||||
dd onoff_f
|
||||
|
||||
; db 24
|
||||
; db 'max '
|
||||
; db 2
|
||||
@ -251,6 +260,7 @@ bumps_d_f: db ' 1 '
|
||||
move_f:
|
||||
db 'obj '
|
||||
db 'camr'
|
||||
db 'wave'
|
||||
; db 'lght'
|
||||
bumps_f:
|
||||
db 'rand'
|
||||
|
@ -61,23 +61,23 @@ elseif Ext=MMX
|
||||
movq [.cz],mm0
|
||||
movq [.cg],mm1
|
||||
elseif Ext >= SSE2
|
||||
movups xmm1,[.cz]
|
||||
; movups xmm1,[.cz]
|
||||
paddd xmm1,xmm0
|
||||
movups [.cz],xmm1
|
||||
; movups [.cz],xmm1
|
||||
end if
|
||||
}
|
||||
macro .draw_pixel
|
||||
{
|
||||
mov [esi],ebx ; actualize Z buffer
|
||||
;if Ext=SSE2
|
||||
; movups xmm2,[.cb]
|
||||
; shufps xmm1,xmm1,11000110b
|
||||
; pand xmm1,[.mask]
|
||||
; psrld xmm2,ROUND
|
||||
; packssdw xmm2,xmm2
|
||||
; packuswb xmm2,xmm2
|
||||
; movss [edi],xmm2
|
||||
;else
|
||||
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
|
||||
@ -90,7 +90,7 @@ macro .draw_pixel
|
||||
mov edx,[.cr]
|
||||
sar edx,ROUND
|
||||
mov [edi+2],dl
|
||||
;end if
|
||||
end if
|
||||
; shl ebx,16
|
||||
; or eax,ebx
|
||||
; mov [edi],eax
|
||||
@ -208,8 +208,15 @@ end if
|
||||
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
|
||||
|
||||
@ -267,8 +274,16 @@ end if
|
||||
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
|
||||
|
||||
@ -331,7 +346,11 @@ end if
|
||||
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
|
||||
|
||||
@ -400,6 +419,9 @@ end if
|
||||
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
|
||||
@ -412,7 +434,11 @@ end if
|
||||
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
|
||||
|
||||
@ -480,6 +506,9 @@ end if
|
||||
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
|
||||
@ -495,7 +524,11 @@ end if
|
||||
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
|
||||
|
||||
@ -553,12 +586,12 @@ if Ext=MMX | Ext = SSE
|
||||
movq mm3,[.dg]
|
||||
else if Ext >= SSE2
|
||||
movups xmm0,[.dz]
|
||||
movups xmm6,[.mask]
|
||||
end if
|
||||
ret
|
||||
;align 16
|
||||
;.mask:
|
||||
; dq 0xffffffffffffffff
|
||||
; dq 0xffffffff00000000
|
||||
.mask:
|
||||
dq 0xffffffff00ffffff
|
||||
dq 0xffffffffffffffff
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
; application : View3ds ver. 0.062 - tiny .3ds files viewer.
|
||||
; application : View3ds ver. 0.063 - tiny .3ds files viewer.
|
||||
; compiler : FASM
|
||||
; system : KolibriOS
|
||||
; author : Macgub aka Maciej Guba
|
||||
@ -265,16 +265,19 @@ still:
|
||||
;
|
||||
cmp ah,30
|
||||
jne .next
|
||||
cmp [move_flag],1
|
||||
je @f
|
||||
cmp [move_flag],0
|
||||
jne @f
|
||||
; cmp [move_flag],2
|
||||
; je .set_light1
|
||||
sub [vect_y],10
|
||||
jmp .next
|
||||
@@:
|
||||
cmp [move_flag],1
|
||||
jne @f
|
||||
sub [yobs],10 ; observator = camera position
|
||||
jmp .next
|
||||
|
||||
@@:
|
||||
sub [sin_amplitude],10
|
||||
;--------------------------------------------------
|
||||
; .set_light1: ; r -
|
||||
; movzx ebx,[light_no_flag] ; * 22
|
||||
@ -296,7 +299,6 @@ still:
|
||||
jne .next1
|
||||
cmp [move_flag],1
|
||||
je @f
|
||||
|
||||
add [vect_z],10
|
||||
jmp .next1
|
||||
@@:
|
||||
@ -304,23 +306,37 @@ still:
|
||||
.next1:
|
||||
cmp ah,33
|
||||
jne .next2
|
||||
cmp [move_flag],1
|
||||
je @f
|
||||
|
||||
cmp [move_flag],0
|
||||
jne @f
|
||||
sub [vect_x],10
|
||||
jmp .next2
|
||||
@@:
|
||||
cmp [move_flag],1
|
||||
jne @f
|
||||
sub [xobs],10 ; observator = camera position
|
||||
jmp .next2
|
||||
@@:
|
||||
fninit
|
||||
fld [sin_frq]
|
||||
fsub [sin_delta]
|
||||
fstp [sin_frq]
|
||||
.next2:
|
||||
cmp ah,32
|
||||
jne .next3
|
||||
cmp [move_flag],1
|
||||
je @f
|
||||
|
||||
cmp [move_flag],0
|
||||
jne @f
|
||||
add [vect_x],10
|
||||
jmp .next3
|
||||
@@:
|
||||
cmp [move_flag],1
|
||||
jne @f
|
||||
add [xobs],10 ; observator = camera position
|
||||
jmp .next3
|
||||
@@:
|
||||
fninit
|
||||
fld [sin_frq] ; change wave effect frequency
|
||||
fadd [sin_delta]
|
||||
fstp [sin_frq]
|
||||
.next3:
|
||||
cmp ah,34
|
||||
jne .next4
|
||||
@ -334,14 +350,18 @@ still:
|
||||
.next4:
|
||||
cmp ah,35
|
||||
jne .next5
|
||||
cmp [move_flag],1
|
||||
je @f
|
||||
|
||||
cmp [move_flag],0
|
||||
jne @f
|
||||
; call add_vector
|
||||
add [vect_y],10
|
||||
jmp .next5
|
||||
@@:
|
||||
cmp [move_flag],1
|
||||
jne @f
|
||||
add [yobs],10 ; observator = camera position
|
||||
jmp .next5
|
||||
@@:
|
||||
add [sin_amplitude],10
|
||||
.next5:
|
||||
|
||||
|
||||
@ -435,6 +455,10 @@ still:
|
||||
@@:
|
||||
call draw_triangles ; draw all triangles from the list
|
||||
.blurrr:
|
||||
cmp [sinus_flag],0
|
||||
je @f
|
||||
call do_sinus
|
||||
@@:
|
||||
cmp [fire_flag],0
|
||||
jne @f
|
||||
cmp [blur_flag],0
|
||||
@ -629,7 +653,7 @@ if Ext >= SSE
|
||||
end if
|
||||
.no_min:
|
||||
end if
|
||||
;========================commented=====================================
|
||||
|
||||
RDTSC
|
||||
sub eax,[esp]
|
||||
sub eax,41
|
||||
@ -648,7 +672,7 @@ end if
|
||||
mov eax,7 ; put image
|
||||
mov ebx,screen
|
||||
mov ecx,SIZE_X shl 16 + SIZE_Y
|
||||
mov edx,5 shl 16 + 23
|
||||
mov edx,5 shl 16 + 25
|
||||
int 0x40
|
||||
|
||||
mov eax,13
|
||||
@ -2789,6 +2813,14 @@ alloc_mem_for_tp:
|
||||
int 0x40 ; -> allocate memory to edges
|
||||
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 ebx, 12
|
||||
@ -2978,7 +3010,7 @@ ret
|
||||
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 bx,[size_x]
|
||||
add bx,114
|
||||
add bx,115
|
||||
mov cx,[size_y]
|
||||
add cx,30
|
||||
mov edx,0x14000000 ; color of work area RRGGBB,8->color gl
|
||||
|
Loading…
Reference in New Issue
Block a user