2012-10-10 10:46:24 +02:00
|
|
|
do_sinus:
|
2020-06-01 17:44:39 +02:00
|
|
|
.x equ [ebp-8]
|
|
|
|
.y equ [ebp-12]
|
|
|
|
.new_y equ [ebp-16]
|
|
|
|
.temp equ [ebp-20]
|
2012-10-10 10:46:24 +02:00
|
|
|
push ebp
|
2020-06-01 17:44:39 +02:00
|
|
|
mov ebp,esp
|
|
|
|
sub esp,64
|
|
|
|
mov dword .x,0
|
|
|
|
mov dword .y,0
|
|
|
|
mov esi,[screen_ptr]
|
|
|
|
mov edi,[Zbuffer_ptr]
|
2012-10-10 10:46:24 +02:00
|
|
|
push edi
|
|
|
|
; clear Zbuffer temporally used as image buffer
|
2016-10-27 11:39:38 +02:00
|
|
|
movzx ecx,word[size_x_var]
|
|
|
|
movzx eax,word[size_y_var]
|
|
|
|
imul ecx,eax ;SIZE_X*SIZE_Y
|
2020-06-01 17:44:39 +02:00
|
|
|
xor eax,eax
|
2012-10-10 10:46:24 +02:00
|
|
|
cld
|
2020-06-01 17:44:39 +02:00
|
|
|
rep stosd
|
|
|
|
pop edi
|
2012-10-10 10:46:24 +02:00
|
|
|
; 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
|
2020-06-01 17:44:39 +02:00
|
|
|
mov eax, .temp
|
2012-10-10 10:46:24 +02:00
|
|
|
; mov bx, [angle_x]
|
|
|
|
; add bx, [angle_y]
|
|
|
|
; movzx ebx,bx
|
|
|
|
; shr ebx,1 ; change phase
|
|
|
|
; add eax,ebx
|
|
|
|
|
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
and eax, 0x000000ff
|
2012-10-10 10:46:24 +02:00
|
|
|
|
|
|
|
; cdq
|
|
|
|
; mul [sin_frq]
|
|
|
|
; and eax,0x000000ff
|
|
|
|
; and ax,0x00ff
|
|
|
|
; cwde
|
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
fld dword [sin_tab+eax*4]
|
2012-10-10 10:46:24 +02:00
|
|
|
fimul dword [sin_amplitude]
|
|
|
|
fiadd dword .y
|
|
|
|
fistp dword .new_y
|
|
|
|
end if
|
2020-06-01 17:44:39 +02:00
|
|
|
mov eax,.new_y
|
|
|
|
or eax,eax
|
|
|
|
jl .skip
|
2016-10-27 11:39:38 +02:00
|
|
|
movzx ebx,word[size_y_var]
|
2020-06-01 17:44:39 +02:00
|
|
|
cmp eax,ebx ;SIZE_Y
|
|
|
|
jg .skip
|
2016-10-27 11:39:38 +02:00
|
|
|
movzx edx,word[size_x_var]
|
2020-06-01 17:44:39 +02:00
|
|
|
mul edx
|
2016-10-27 11:39:38 +02:00
|
|
|
; shl eax,9
|
2020-06-01 17:44:39 +02:00
|
|
|
add eax,dword .x
|
2020-07-13 13:09:09 +02:00
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
lea ebx,[eax*3]
|
2020-07-13 13:09:09 +02:00
|
|
|
cmp [dr_flag],12 ; 32 bit col cause
|
2020-11-21 14:41:20 +01:00
|
|
|
jl @f
|
2020-07-13 13:09:09 +02:00
|
|
|
add ebx,eax
|
|
|
|
@@:
|
2020-06-01 17:44:39 +02:00
|
|
|
mov eax,[esi]
|
|
|
|
mov [edi+ebx],eax
|
2012-10-10 10:46:24 +02:00
|
|
|
.skip:
|
2020-06-01 17:44:39 +02:00
|
|
|
add esi,3
|
2020-07-13 13:09:09 +02:00
|
|
|
cmp [dr_flag],12
|
2020-11-21 14:41:20 +01:00
|
|
|
jl @f
|
2020-07-13 13:09:09 +02:00
|
|
|
inc esi
|
|
|
|
@@:
|
2020-06-01 17:44:39 +02:00
|
|
|
inc dword .x
|
2016-10-27 11:39:38 +02:00
|
|
|
movzx edx,word[size_x_var]
|
2020-06-01 17:44:39 +02:00
|
|
|
cmp dword .x,edx ;SIZE_X
|
|
|
|
jl .again
|
|
|
|
mov dword .x,0
|
|
|
|
inc dword .y
|
2016-10-27 11:39:38 +02:00
|
|
|
movzx edx,word[size_y_var]
|
2020-06-01 17:44:39 +02:00
|
|
|
cmp dword .y,edx ;SIZE_Y
|
|
|
|
jl .again
|
2012-10-10 10:46:24 +02:00
|
|
|
|
|
|
|
; copy from temporary buffer -> Zbuffer to screen
|
2020-06-01 17:44:39 +02:00
|
|
|
mov esi,[Zbuffer_ptr]
|
|
|
|
mov edi,[screen_ptr]
|
2016-10-27 11:39:38 +02:00
|
|
|
movzx ecx,word[size_x_var]
|
|
|
|
movzx eax,word[size_y_var]
|
|
|
|
imul ecx,eax
|
2020-11-21 14:41:20 +01:00
|
|
|
cmp [dr_flag],12
|
|
|
|
jge @f
|
2020-06-01 17:44:39 +02:00
|
|
|
lea ecx,[ecx*3]
|
|
|
|
shr ecx,2
|
2016-10-27 11:39:38 +02:00
|
|
|
; mov ecx,SIZE_X*SIZE_Y*3/4
|
2020-07-13 13:09:09 +02:00
|
|
|
@@:
|
2012-10-10 10:46:24 +02:00
|
|
|
cld
|
2020-06-01 17:44:39 +02:00
|
|
|
rep movsd
|
2012-10-10 10:46:24 +02:00
|
|
|
|
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
mov esp,ebp
|
|
|
|
pop ebp
|
2012-10-10 10:46:24 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
2009-10-31 23:01:20 +01:00
|
|
|
draw_dots:
|
2020-06-01 17:44:39 +02:00
|
|
|
mov esi,[points_translated_ptr]
|
|
|
|
mov ecx,[points_count_var]
|
2009-10-31 23:01:20 +01:00
|
|
|
.drw:
|
|
|
|
@@:
|
|
|
|
lodsd
|
2020-06-01 17:44:39 +02:00
|
|
|
add esi,2 ; skip z
|
2009-10-31 23:01:20 +01:00
|
|
|
movzx ebx,ax
|
2020-06-01 17:44:39 +02:00
|
|
|
shr eax,16 ; bx = x , ax = y
|
|
|
|
or ax,ax
|
|
|
|
jl @f
|
|
|
|
or bx,bx
|
|
|
|
jl @f
|
|
|
|
cmp ax,[size_y_var] ;SIZE_Y
|
|
|
|
jge @f
|
|
|
|
cmp bx,[size_x_var] ;SIZE_X
|
|
|
|
jge @f
|
2016-10-27 11:39:38 +02:00
|
|
|
movzx edx,word[size_x_var] ;SIZE_X ; SIZE_X not only power of 2 -> 256,512,...
|
2020-06-01 17:44:39 +02:00
|
|
|
mul edx
|
|
|
|
add eax,ebx
|
|
|
|
mov edi,[screen_ptr]
|
|
|
|
lea eax,[eax*3]
|
|
|
|
add edi,eax
|
|
|
|
xor eax,eax
|
|
|
|
not eax
|
2009-10-31 23:01:20 +01:00
|
|
|
stosd
|
|
|
|
@@:
|
|
|
|
loop .drw
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
2016-10-27 11:39:38 +02:00
|
|
|
do_emboss: ; sse2 version only
|
|
|
|
if Ext >= SSE2
|
|
|
|
movzx ecx,[bumps_deep_flag]
|
|
|
|
inc ecx
|
|
|
|
call blur_screen ;blur n times
|
|
|
|
|
|
|
|
mov eax,[size_y_var] ;load both x, y
|
|
|
|
mov ebx,eax
|
|
|
|
shr ebx,16
|
|
|
|
cwde
|
|
|
|
mul ebx
|
|
|
|
mov ecx,eax
|
|
|
|
sub ecx,ebx
|
|
|
|
sub ecx,ebx
|
|
|
|
mov esi,[screen_ptr]
|
|
|
|
mov edi,[Zbuffer_ptr]
|
2020-07-13 13:09:09 +02:00
|
|
|
cmp [dr_flag],12
|
2020-11-21 14:41:20 +01:00
|
|
|
jge @f
|
2016-10-27 11:39:38 +02:00
|
|
|
lea ebx,[ebx*3]
|
2020-07-13 13:09:09 +02:00
|
|
|
jmp .f
|
|
|
|
@@:
|
|
|
|
shl ebx,2
|
|
|
|
.f:
|
2016-10-27 11:39:38 +02:00
|
|
|
mov edx,esi
|
|
|
|
add esi,ebx
|
|
|
|
lea ebx,[ebx+esi]
|
|
|
|
pxor xmm0,xmm0
|
|
|
|
push eax
|
2020-07-13 13:09:09 +02:00
|
|
|
.emb:
|
|
|
|
cmp [dr_flag],12
|
2020-11-21 14:41:20 +01:00
|
|
|
jge @f
|
2016-10-27 11:39:38 +02:00
|
|
|
movlps xmm1,[esi+3]
|
|
|
|
movhps xmm1,[esi+6]
|
|
|
|
movlps xmm2,[esi-3]
|
|
|
|
movhps xmm2,[esi]
|
|
|
|
movlps xmm3,[ebx]
|
|
|
|
movhps xmm3,[ebx+3]
|
|
|
|
movlps xmm4,[edx]
|
|
|
|
movhps xmm4,[edx+3]
|
2020-07-13 13:09:09 +02:00
|
|
|
jmp .ff
|
|
|
|
@@:
|
|
|
|
movlps xmm1,[esi+4]
|
|
|
|
movhps xmm1,[esi+8]
|
|
|
|
movlps xmm2,[esi-4]
|
|
|
|
movhps xmm2,[esi]
|
|
|
|
movlps xmm3,[ebx]
|
|
|
|
movhps xmm3,[ebx+4]
|
|
|
|
movlps xmm4,[edx]
|
|
|
|
movhps xmm4,[edx+4]
|
|
|
|
.ff:
|
|
|
|
punpcklbw xmm1,xmm0
|
|
|
|
punpcklbw xmm2,xmm0
|
2016-10-27 11:39:38 +02:00
|
|
|
punpcklbw xmm3,xmm0
|
|
|
|
punpcklbw xmm4,xmm0
|
|
|
|
psubsw xmm1,xmm2
|
2020-06-01 17:44:39 +02:00
|
|
|
paddw xmm1,[emboss_bias]
|
2016-10-27 11:39:38 +02:00
|
|
|
psubsw xmm3,xmm4
|
2020-06-01 17:44:39 +02:00
|
|
|
paddw xmm3,[emboss_bias]
|
2016-10-27 11:39:38 +02:00
|
|
|
pmulhw xmm1,xmm3
|
|
|
|
movaps xmm7,xmm1
|
|
|
|
movaps xmm6,xmm1
|
2020-06-01 17:44:39 +02:00
|
|
|
psrlq xmm7,2*8
|
|
|
|
psrlq xmm6,4*8
|
2016-10-27 11:39:38 +02:00
|
|
|
pmaxsw xmm1,xmm7
|
|
|
|
pmaxsw xmm1,xmm6
|
|
|
|
|
|
|
|
if 0
|
|
|
|
movaps xmm7,xmm3
|
|
|
|
movaps xmm6,xmm3
|
2020-06-01 17:44:39 +02:00
|
|
|
psrlq xmm7,2*8
|
|
|
|
psrlq xmm6,4*8
|
2016-10-27 11:39:38 +02:00
|
|
|
pmaxsw xmm3,xmm7
|
|
|
|
pmaxsw xmm3,xmm6
|
|
|
|
end if
|
|
|
|
pmaxsw xmm1,xmm3
|
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
movd eax,xmm1
|
|
|
|
movzx eax,al
|
2020-07-13 13:09:09 +02:00
|
|
|
; cmp [dr_flag],12
|
|
|
|
; je @f
|
2020-06-01 17:44:39 +02:00
|
|
|
lea eax,[eax*3+envmap_cub]
|
2020-07-13 13:09:09 +02:00
|
|
|
; jmp .fff
|
|
|
|
;@@:
|
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
mov eax,[eax]
|
|
|
|
mov [edi],eax ;xmm1
|
2016-10-27 11:39:38 +02:00
|
|
|
psrldq xmm1,8
|
2020-06-01 17:44:39 +02:00
|
|
|
movd eax,xmm1
|
|
|
|
movzx eax,al
|
|
|
|
lea eax,[eax*3+envmap_cub]
|
|
|
|
mov eax,[eax]
|
|
|
|
mov [edi+4],eax
|
2016-10-27 11:39:38 +02:00
|
|
|
|
2020-07-13 13:09:09 +02:00
|
|
|
cmp [dr_flag],12
|
2020-11-21 14:41:20 +01:00
|
|
|
jl @f
|
2020-07-13 13:09:09 +02:00
|
|
|
add esi,2
|
|
|
|
add ebx,2
|
|
|
|
add edx,2
|
|
|
|
@@:
|
2016-10-27 11:39:38 +02:00
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
add edi,8
|
|
|
|
add esi,6
|
|
|
|
add ebx,6
|
|
|
|
add edx,6
|
|
|
|
sub ecx,2
|
2020-07-13 13:09:09 +02:00
|
|
|
jnc .emb
|
2016-10-27 11:39:38 +02:00
|
|
|
|
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
pop ecx ;,eax
|
|
|
|
mov edi,[screen_ptr]
|
|
|
|
mov esi,[Zbuffer_ptr]
|
2020-07-13 13:09:09 +02:00
|
|
|
cmp [dr_flag],12
|
2020-11-21 14:41:20 +01:00
|
|
|
jge .e
|
2016-10-27 11:39:38 +02:00
|
|
|
@@:
|
|
|
|
movsd
|
2020-06-01 17:44:39 +02:00
|
|
|
dec edi
|
|
|
|
loop @b
|
2020-07-13 13:09:09 +02:00
|
|
|
.e:
|
|
|
|
rep movsd
|
|
|
|
|
2016-10-27 11:39:38 +02:00
|
|
|
end if
|
2020-07-13 13:09:09 +02:00
|
|
|
|
2016-10-27 11:39:38 +02:00
|
|
|
ret
|
|
|
|
|
2016-11-30 11:24:07 +01:00
|
|
|
;align 16
|
|
|
|
; emboss_bias:
|
|
|
|
; dw 128, 128, 128, 128, 128, 128, 128, 128
|
2016-10-27 11:39:38 +02:00
|
|
|
|
|
|
|
if 0 ; old emb proc
|
|
|
|
|
2009-10-31 23:01:20 +01:00
|
|
|
; emboss - after drawing all,
|
|
|
|
; transfer screen buffer into bump map
|
|
|
|
; and draw two bump triangles
|
|
|
|
; *************************************
|
2020-06-01 17:44:39 +02:00
|
|
|
mov esi,screen
|
|
|
|
mov edi,bumpmap2
|
|
|
|
mov ecx,TEXTURE_SIZE/3
|
|
|
|
cld
|
2009-10-31 23:01:20 +01:00
|
|
|
if Ext=NON
|
2020-06-01 17:44:39 +02:00
|
|
|
xor eax,eax
|
|
|
|
xor bh,bh
|
|
|
|
xor dh,dh
|
2009-10-31 23:01:20 +01:00
|
|
|
@@:
|
2020-06-01 17:44:39 +02:00
|
|
|
lodsb
|
|
|
|
movzx bx,al
|
|
|
|
lodsb
|
|
|
|
movzx dx,al
|
|
|
|
lodsb
|
|
|
|
add ax,bx
|
|
|
|
add ax,dx
|
2009-10-31 23:01:20 +01:00
|
|
|
; cwd
|
|
|
|
; div [i3]
|
|
|
|
;; push ax
|
|
|
|
;; pop bx
|
|
|
|
;; shr bx,3
|
|
|
|
;; shr ax,2
|
|
|
|
;; add ax,bx
|
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
lea eax,[eax*5]
|
|
|
|
shr ax,4
|
2009-10-31 23:01:20 +01:00
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
stosb
|
|
|
|
loop @b
|
2009-10-31 23:01:20 +01:00
|
|
|
else
|
2020-06-01 17:44:39 +02:00
|
|
|
emms
|
|
|
|
pxor mm1,mm1
|
|
|
|
mov ebx,0x0000ffff
|
2009-10-31 23:01:20 +01:00
|
|
|
@@:
|
2020-06-01 17:44:39 +02:00
|
|
|
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
|
2009-10-31 23:01:20 +01:00
|
|
|
|
|
|
|
end if
|
2020-06-01 17:44:39 +02:00
|
|
|
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
|
2009-10-31 23:01:20 +01:00
|
|
|
ret
|
2016-10-27 11:39:38 +02:00
|
|
|
end if
|
2009-10-31 23:01:20 +01:00
|
|
|
;********************************EMBOSS DONE*******************************
|
|
|
|
|
|
|
|
|
|
|
|
generate_object2: ; torus
|
|
|
|
;in ax - figure number 2=torus, 3=loop, 4=loop
|
|
|
|
;locals
|
|
|
|
; counter dw ?
|
|
|
|
; sin dd ?
|
|
|
|
; cos dd ?
|
|
|
|
;endl
|
|
|
|
.counter equ word[ebp-2]
|
2020-06-01 17:44:39 +02:00
|
|
|
.sin equ dword[ebp-6]
|
|
|
|
.cos equ dword[ebp-10]
|
|
|
|
.sin2 equ dword[ebp-14]
|
|
|
|
.cos2 equ dword[ebp-18]
|
2009-10-31 23:01:20 +01:00
|
|
|
.piD180m3 equ dword[ebp-22]
|
2020-06-01 17:44:39 +02:00
|
|
|
.cD2 equ word[ebp-24]
|
|
|
|
push ebp
|
|
|
|
mov ebp,esp
|
|
|
|
sub esp,24
|
|
|
|
|
|
|
|
push ax
|
|
|
|
|
|
|
|
fninit
|
|
|
|
mov edi,[points_ptr]
|
|
|
|
xor eax,eax
|
|
|
|
; init seed -> 4 3d points
|
|
|
|
mov dword[edi],-1.0 ; x
|
|
|
|
add edi,4
|
|
|
|
stosd ; y
|
|
|
|
stosd ; z
|
|
|
|
mov dword[edi],-0.9 ; x1
|
|
|
|
mov dword[edi+4],0.1 ; y1
|
|
|
|
add edi,8
|
|
|
|
stosd ; z1
|
|
|
|
mov dword[edi],-0.8
|
|
|
|
add edi,4
|
|
|
|
stosd
|
|
|
|
stosd
|
|
|
|
mov dword[edi],-0.9 ; x3
|
|
|
|
mov dword[edi+4],-0.1 ; y3
|
|
|
|
add edi,8
|
|
|
|
stosd ; z3
|
|
|
|
mov [points_count_var],4
|
|
|
|
|
|
|
|
fld [piD180]
|
|
|
|
fidiv [i3]
|
|
|
|
fstp .piD180m3
|
|
|
|
mov .cD2,5
|
|
|
|
|
|
|
|
pop ax
|
|
|
|
mov ecx,1
|
|
|
|
mov edx,9
|
|
|
|
.next: ; calc angle and rotate seed 4 points
|
|
|
|
mov .counter,cx
|
|
|
|
mov ebx,[points_ptr]
|
|
|
|
fld .piD180m3
|
|
|
|
fimul .counter
|
|
|
|
fld st
|
|
|
|
fsincos
|
|
|
|
fstp .sin
|
|
|
|
fstp .cos
|
|
|
|
fadd st,st0
|
|
|
|
fsincos
|
|
|
|
fstp .sin2
|
|
|
|
fstp .cos2
|
|
|
|
|
|
|
|
.rotor: ; next 4
|
|
|
|
; rotary y
|
|
|
|
fld dword[ebx] ; x
|
|
|
|
fld .sin
|
|
|
|
fmul dword[ebx+8] ; z * sinbeta
|
|
|
|
fchs
|
|
|
|
fld .cos
|
|
|
|
fmul dword[ebx] ; x * cosbeta
|
|
|
|
faddp
|
|
|
|
fstp dword[edi] ; new x
|
|
|
|
fmul .sin ; old x * sinbeta
|
|
|
|
fld .cos
|
|
|
|
fmul dword[ebx+8] ; z * cosbeta
|
|
|
|
faddp
|
|
|
|
dec dx
|
|
|
|
or dx,dx
|
|
|
|
jnz @f
|
2009-10-31 23:01:20 +01:00
|
|
|
; mov .counter,dx
|
2020-06-01 17:44:39 +02:00
|
|
|
fld st
|
|
|
|
fidiv [i3]
|
|
|
|
faddp
|
2009-10-31 23:01:20 +01:00
|
|
|
@@:
|
2020-06-01 17:44:39 +02:00
|
|
|
fstp dword[edi+8] ; new z
|
|
|
|
fld dword[ebx+4]
|
|
|
|
or dx,dx
|
|
|
|
jnz @f
|
2009-10-31 23:01:20 +01:00
|
|
|
; fld1
|
|
|
|
; faddp
|
|
|
|
; fld st
|
2020-06-01 17:44:39 +02:00
|
|
|
fadd st,st0
|
|
|
|
fadd st,st0
|
2009-10-31 23:01:20 +01:00
|
|
|
; fxch
|
|
|
|
; fimul [i3]
|
|
|
|
; fsin
|
|
|
|
; faddp
|
2020-06-01 17:44:39 +02:00
|
|
|
mov dx,9
|
2009-10-31 23:01:20 +01:00
|
|
|
@@:
|
2020-06-01 17:44:39 +02:00
|
|
|
fstp dword[edi+4]
|
|
|
|
; rotary x
|
|
|
|
cmp al,3
|
|
|
|
jl .end_rot
|
|
|
|
fld dword[edi+4] ;y
|
|
|
|
fld .sin2
|
|
|
|
fmul dword[edi+8] ;z
|
|
|
|
fld .cos2
|
|
|
|
fmul dword[edi+4] ;y
|
|
|
|
faddp
|
|
|
|
fstp dword[edi+4] ; new y
|
|
|
|
fmul .sin2 ; sinbeta * old y
|
|
|
|
fchs
|
|
|
|
fld .cos2
|
|
|
|
fmul dword[edi+8]
|
|
|
|
faddp
|
|
|
|
fstp dword[edi+8]
|
|
|
|
; rotary z
|
|
|
|
cmp al,4
|
|
|
|
jl .end_rot
|
|
|
|
fld dword[edi] ;x
|
|
|
|
fld .sin
|
|
|
|
fmul dword[edi+4] ;y
|
|
|
|
fld .cos
|
|
|
|
fmul dword[edi] ;x
|
|
|
|
faddp
|
|
|
|
fstp dword[edi] ;new x
|
|
|
|
fmul .sin ; sinbeta * old x
|
|
|
|
fchs
|
|
|
|
fld .cos
|
|
|
|
fmul dword[edi+4] ; cosbeta * y
|
|
|
|
faddp
|
|
|
|
fstp dword[edi+4] ; new y
|
2009-10-31 23:01:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.end_rot:
|
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
add edi,12
|
|
|
|
add ebx,12
|
|
|
|
mov esi,[points_ptr]
|
|
|
|
add esi,12*4
|
|
|
|
cmp ebx,esi
|
|
|
|
jl .rotor
|
2009-10-31 23:01:20 +01:00
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
add [points_count_var],4
|
|
|
|
add cx,18
|
|
|
|
cmp cx,(18*21*3)+1
|
|
|
|
jle .next
|
2009-10-31 23:01:20 +01:00
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
mov edi,[triangles_ptr]
|
|
|
|
mov eax,4
|
|
|
|
mov ebx,4+4
|
|
|
|
mov [triangles_count_var],160*3 ;164*3 ;140
|
2009-10-31 23:01:20 +01:00
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
mov ecx,80*3 ;68
|
2009-10-31 23:01:20 +01:00
|
|
|
@@:
|
2020-06-01 17:44:39 +02:00
|
|
|
stosd ;----
|
|
|
|
mov [edi],ebx ; |
|
|
|
|
add edi,4 ; |
|
|
|
|
inc eax ; |
|
|
|
|
stosd ; |repeat 4 times
|
2009-10-31 23:01:20 +01:00
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
mov [edi],ebx ; |
|
|
|
|
inc ebx
|
|
|
|
add edi,4
|
|
|
|
stosd ; |
|
|
|
|
mov [edi],ebx ; |
|
|
|
|
add edi,4 ;----
|
|
|
|
loop @b
|
2009-10-31 23:01:20 +01:00
|
|
|
|
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
mov dword[edi],-1 ; < - end mark
|
|
|
|
mov [culling_flag],0
|
2009-10-31 23:01:20 +01:00
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
mov esp,ebp
|
|
|
|
pop ebp
|
2009-10-31 23:01:20 +01:00
|
|
|
|
|
|
|
ret
|
|
|
|
generate_object3: ; heart
|
|
|
|
;locals
|
|
|
|
; counter dw ?
|
|
|
|
; sin dd ?
|
|
|
|
; cos dd ?
|
|
|
|
;endl
|
|
|
|
.counter equ word[ebp-2]
|
2020-06-01 17:44:39 +02:00
|
|
|
.sin equ dword[ebp-6]
|
|
|
|
.cos equ dword[ebp-10]
|
|
|
|
.sin2 equ dword[ebp-14]
|
|
|
|
.cos2 equ dword[ebp-18]
|
2009-10-31 23:01:20 +01:00
|
|
|
.piD180m3 equ dword[ebp-22]
|
2020-06-01 17:44:39 +02:00
|
|
|
.cD2 equ word[ebp-24]
|
|
|
|
push ebp
|
|
|
|
mov ebp,esp
|
|
|
|
sub esp,24
|
|
|
|
|
|
|
|
fninit
|
|
|
|
mov edi,[points_ptr]
|
|
|
|
xor eax,eax
|
|
|
|
; init seed -> eight 3d points
|
|
|
|
mov dword[edi],2.0
|
|
|
|
add edi,4
|
|
|
|
stosd
|
|
|
|
stosd
|
|
|
|
|
|
|
|
mov dword[edi],2.0
|
|
|
|
mov dword[edi+4],-0.5
|
|
|
|
add edi,8
|
|
|
|
stosd
|
|
|
|
|
|
|
|
mov dword[edi],1.5
|
|
|
|
mov dword[edi+4],-1.5
|
|
|
|
add edi,8
|
|
|
|
stosd
|
|
|
|
mov dword[edi],1.0
|
|
|
|
mov dword[edi+4],-2.0
|
|
|
|
add edi,8
|
|
|
|
stosd
|
|
|
|
|
|
|
|
stosd
|
|
|
|
mov dword[edi],-2.5
|
|
|
|
add edi,4
|
|
|
|
stosd
|
|
|
|
|
|
|
|
mov [points_count_var],5
|
|
|
|
|
|
|
|
mov ecx,1
|
|
|
|
.next: ; calc angle and rotate seed 4 points
|
|
|
|
mov .counter,cx
|
|
|
|
mov ebx,[points_ptr]
|
|
|
|
fld [piD180]
|
|
|
|
fimul .counter
|
|
|
|
fsincos
|
|
|
|
fstp .sin
|
|
|
|
fstp .cos
|
|
|
|
|
|
|
|
.rotor: ; next 4
|
|
|
|
; rotary y
|
|
|
|
fld dword[ebx] ; x
|
|
|
|
fld .sin
|
|
|
|
fmul dword[ebx+8] ; z * sinbeta
|
|
|
|
fchs
|
|
|
|
fld .cos
|
|
|
|
fmul dword[ebx] ; x * cosbeta
|
|
|
|
faddp
|
|
|
|
fidiv [i3]
|
|
|
|
fstp dword[edi] ; new x
|
|
|
|
fmul .sin ; old x * sinbeta
|
|
|
|
fld .cos
|
|
|
|
fmul dword[ebx+8] ; z * cosbeta
|
|
|
|
faddp
|
|
|
|
fstp dword[edi+8] ; new z
|
|
|
|
|
|
|
|
fld dword[ebx+4] ;y
|
|
|
|
fstp dword[edi+4]
|
2009-10-31 23:01:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
.end_rot:
|
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
add edi,12
|
|
|
|
add ebx,12
|
|
|
|
mov esi,[points_ptr]
|
|
|
|
add esi,12*5
|
|
|
|
cmp ebx,esi ;real_points + (12*5)
|
|
|
|
jl .rotor
|
|
|
|
|
|
|
|
add [points_count_var],5
|
|
|
|
add cx,18
|
|
|
|
cmp cx,(18*21)+1
|
|
|
|
jle .next
|
2009-10-31 23:01:20 +01:00
|
|
|
;last points
|
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
xor eax,eax
|
2009-10-31 23:01:20 +01:00
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
mov dword[edi],0.22
|
|
|
|
mov dword[edi+4],0.77
|
|
|
|
mov dword[edi+8],1.25
|
|
|
|
add edi,12
|
2009-10-31 23:01:20 +01:00
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
mov dword[edi],0.22
|
|
|
|
mov dword[edi+4],0.77
|
|
|
|
mov dword[edi+8],-1.25
|
|
|
|
add edi,12
|
|
|
|
stosd
|
2009-10-31 23:01:20 +01:00
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
add [points_count_var],2
|
2009-10-31 23:01:20 +01:00
|
|
|
|
|
|
|
; init triangles list
|
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
mov edi,[triangles_ptr]
|
|
|
|
mov eax,5
|
|
|
|
mov ebx,5+5
|
|
|
|
mov [triangles_count_var],200 ;204
|
2009-10-31 23:01:20 +01:00
|
|
|
|
2020-06-01 17:44:39 +02:00
|
|
|
mov ecx,100
|
2009-10-31 23:01:20 +01:00
|
|
|
@@:
|
2020-06-01 17:44:39 +02:00
|
|
|
stosd ;----
|
|
|
|
mov [edi],ebx ; |
|
|
|
|
add edi,4 ; |
|
|
|
|
inc eax ; |
|
|
|
|
stosd ; |repeat
|
|
|
|
|
|
|
|
mov [edi],ebx ; |
|
|
|
|
inc ebx
|
|
|
|
add edi,4
|
|
|
|
stosd ; |
|
|
|
|
mov [edi],ebx ; |
|
|
|
|
add edi,4 ;----
|
|
|
|
loop @b
|
|
|
|
|
|
|
|
mov eax,5
|
|
|
|
mov ebx,[points_count_var]
|
|
|
|
sub ebx,2
|
|
|
|
mov dl,2
|
2009-10-31 23:01:20 +01:00
|
|
|
.nx:
|
2020-06-01 17:44:39 +02:00
|
|
|
mov ecx,5
|
|
|
|
add [triangles_count_var],ecx
|
2009-10-31 23:01:20 +01:00
|
|
|
@@:
|
2020-06-01 17:44:39 +02:00
|
|
|
stosd
|
|
|
|
add eax,5
|
|
|
|
stosd
|
|
|
|
mov dword[edi],ebx
|
|
|
|
add edi,4
|
|
|
|
loop @b
|
|
|
|
|
|
|
|
cmp dl,1
|
|
|
|
je @f
|
|
|
|
|
|
|
|
inc ebx
|
|
|
|
jmp .lab
|
2009-10-31 23:01:20 +01:00
|
|
|
@@:
|
2020-06-01 17:44:39 +02:00
|
|
|
dec ebx
|
2009-10-31 23:01:20 +01:00
|
|
|
.lab:
|
2020-06-01 17:44:39 +02:00
|
|
|
mov ecx,5
|
|
|
|
add [triangles_count_var],ecx
|
2009-10-31 23:01:20 +01:00
|
|
|
@@:
|
2020-06-01 17:44:39 +02:00
|
|
|
stosd
|
|
|
|
add eax,5
|
|
|
|
stosd
|
|
|
|
mov dword[edi],ebx
|
|
|
|
add edi,4
|
|
|
|
loop @b
|
|
|
|
|
|
|
|
dec dl
|
|
|
|
or dl,dl
|
|
|
|
jnz .nx
|
|
|
|
|
|
|
|
sub eax,25
|
|
|
|
stosd
|
|
|
|
sub eax,50
|
|
|
|
stosd
|
|
|
|
mov dword[edi],ebx
|
|
|
|
add edi,4
|
|
|
|
|
|
|
|
stosd
|
|
|
|
add eax,50
|
|
|
|
stosd
|
|
|
|
inc ebx
|
|
|
|
mov dword[edi],ebx
|
|
|
|
add edi,4
|
|
|
|
add [triangles_count_var],2
|
|
|
|
|
|
|
|
mov dword[edi],-1 ; < - end mark
|
|
|
|
mov [culling_flag],0
|
|
|
|
|
|
|
|
mov esp,ebp
|
|
|
|
pop ebp
|
2009-10-31 23:01:20 +01:00
|
|
|
|
|
|
|
ret
|
2020-06-01 17:44:39 +02:00
|
|
|
|
2020-11-21 14:41:20 +01:00
|
|
|
|
|
|
|
|