Subversion Repositories Kolibri OS

Compare Revisions

Ignore whitespace Rev 8013 → Rev 8014

/programs/demos/3DS/FLAT3.INC
File deleted
/programs/demos/3DS/BUMP3.INC
File deleted
\ No newline at end of file
/programs/demos/3DS/TEX3.INC
File deleted
/programs/demos/3DS/GRD3.INC
File deleted
/programs/demos/3DS/3DMATH.INC
13,18 → 13,18
;---------------------- out : none ------------------------
if 0
make_vector:
fninit
fild word[edi+x3d] ;edi+x3d
fisub word[esi+x3d] ;esi+x3d
fstp dword[ebx+vec_x]
fninit
fild word[edi+x3d] ;edi+x3d
fisub word[esi+x3d] ;esi+x3d
fstp dword[ebx+vec_x]
 
fild word[edi+y3d]
fisub word[esi+y3d]
fstp dword[ebx+vec_y]
fild word[edi+y3d]
fisub word[esi+y3d]
fstp dword[ebx+vec_y]
 
fild word[edi+z3d]
fisub word[esi+z3d]
fstp dword[ebx+vec_z]
fild word[edi+z3d]
fisub word[esi+z3d]
fstp dword[ebx+vec_z]
 
ret
end if
32,10 → 32,10
; esi - source matrix
; edi - desired reversed matrix
 
push ebp
mov ebp,esp
sub esp,4
.det equ ebp-4
push ebp
mov ebp,esp
sub esp,4
.det equ ebp-4
 
fninit
fld dword[esi]
160,18 → 160,27
ret
 
make_vector_r:
fninit
fld dword[edi] ;edi+x3d
fsub dword[esi] ;esi+x3d
fstp dword[ebx+vec_x]
if Ext < SSE2
fninit
fld dword[edi] ;edi+x3d
fsub dword[esi] ;esi+x3d
fstp dword[ebx+vec_x]
 
fld dword[edi+4]
fsub dword[esi+4]
fstp dword[ebx+vec_y]
fld dword[edi+4]
fsub dword[esi+4]
fstp dword[ebx+vec_y]
 
fld dword[edi+8]
fsub dword[esi+8]
fstp dword[ebx+vec_z]
fld dword[edi+8]
fsub dword[esi+8]
fstp dword[ebx+vec_z]
else
movups xmm0,[esi]
movups xmm1,[edi]
subps xmm1,xmm0
movlps [ebx],xmm1
movhlps xmm1,xmm1
movss [ebx+8],xmm1
end if
 
ret
;---------------------- in: -------------------------------
180,61 → 189,61
;--------------------------- ebx - pointer to result vector
;---------------------- out : none
cross_product:
fninit
fld dword [esi+vec_y]
fmul dword [edi+vec_z]
fld dword [esi+vec_z]
fmul dword [edi+vec_y]
fsubp ;st1 ,st
fstp dword [ebx+vec_x]
fninit
fld dword [esi+vec_y]
fmul dword [edi+vec_z]
fld dword [esi+vec_z]
fmul dword [edi+vec_y]
fsubp ;st1 ,st
fstp dword [ebx+vec_x]
 
fld dword [esi+vec_z]
fmul dword [edi+vec_x]
fld dword [esi+vec_x]
fmul dword [edi+vec_z]
fsubp ;st1 ,st
fstp dword [ebx+vec_y]
fld dword [esi+vec_z]
fmul dword [edi+vec_x]
fld dword [esi+vec_x]
fmul dword [edi+vec_z]
fsubp ;st1 ,st
fstp dword [ebx+vec_y]
 
fld dword [esi+vec_x]
fmul dword [edi+vec_y]
fld dword [esi+vec_y]
fmul dword [edi+vec_x]
fsubp ;st1 ,st
fstp dword [ebx+vec_z]
fld dword [esi+vec_x]
fmul dword [edi+vec_y]
fld dword [esi+vec_y]
fmul dword [edi+vec_x]
fsubp ;st1 ,st
fstp dword [ebx+vec_z]
ret
;----------------------- in: ------------------------------
;---------------------------- edi - pointer to vector -----
;----------------------- out : none
normalize_vector:
fninit
fld dword [edi+vec_x]
fmul st, st
fld dword [edi+vec_y]
fmul st, st
fld dword [edi+vec_z]
fmul st, st
faddp st1, st
faddp st1, st
fsqrt
fninit
fld dword [edi+vec_x]
fmul st, st
fld dword [edi+vec_y]
fmul st, st
fld dword [edi+vec_z]
fmul st, st
faddp st1, st
faddp st1, st
fsqrt
 
ftst
fstsw ax
sahf
jnz @f
ftst
fstsw ax
sahf
jnz @f
 
fst dword [edi+vec_x]
fst dword [edi+vec_y]
fstp dword [edi+vec_z]
ret
fst dword [edi+vec_x]
fst dword [edi+vec_y]
fstp dword [edi+vec_z]
ret
@@:
fld st
fld st
fdivr dword [edi+vec_x]
fstp dword [edi+vec_x]
fdivr dword [edi+vec_y]
fstp dword [edi+vec_y]
fdivr dword [edi+vec_z]
fstp dword [edi+vec_z]
fld st
fld st
fdivr dword [edi+vec_x]
fstp dword [edi+vec_x]
fdivr dword [edi+vec_y]
fstp dword [edi+vec_y]
fdivr dword [edi+vec_z]
fstp dword [edi+vec_z]
ret
;------------------in: -------------------------
;------------------ esi - pointer to 1st vector
242,15 → 251,15
;------------------out: ------------------------
;------------------ st0 - dot-product
dot_product:
fninit
fld dword [esi+vec_x]
fmul dword [edi+vec_x]
fld dword [esi+vec_y]
fmul dword [edi+vec_y]
fld dword [esi+vec_z]
fmul dword [edi+vec_z]
faddp
faddp
fninit
fld dword [esi+vec_x]
fmul dword [edi+vec_x]
fld dword [esi+vec_y]
fmul dword [edi+vec_y]
fld dword [esi+vec_z]
fmul dword [edi+vec_z]
faddp
faddp
ret
 
; DOS version Coded by Mikolaj Felix aka Majuma
258,33 → 267,33
; www.majuma.xt.pl
; into FASM translation by Macgub
init_sincos_tab:
.counter equ dword [ebp-4] ; cur angle
.counter equ dword [ebp-4] ; cur angle
 
push ebp
mov ebp,esp
push ebp
mov ebp,esp
 
xor eax,eax
push eax ; init .counter
mov edi,cos_tab
mov esi,sin_tab
mov ecx,256
xor eax,eax
push eax ; init .counter
mov edi,cos_tab
mov esi,sin_tab
mov ecx,256
fninit
 
fld .counter
fld .counter
@@:
fld st
fld st
fsincos
fstp dword [edi]
fstp dword [esi]
fstp dword [edi]
fstp dword [esi]
; fadd [piD180]
fadd [piD128]
add esi,4
add edi,4
loop @b
ffree st
fadd [piD128]
add esi,4
add edi,4
loop @b
ffree st
 
mov esp,ebp
pop ebp
mov esp,ebp
pop ebp
ret
;------
; esi - offset (pointer) to angles, edi offset to 3x3 matrix
469,36 → 478,36
add_scale_to_matrix:
fninit
fld [rsscale]
fld dword[esi] ;-----
fld dword[esi] ;-----
fmul st,st1
fstp dword[esi]
fld dword[esi+12] ; x scale
fld dword[esi+12] ; x scale
fmul st,st1
fstp dword[esi+12]
fld dword[esi+24]
fmul st,st1
fstp dword[esi+24] ;------
fstp dword[esi+24] ;------
 
fld dword[esi+4] ;-----
fld dword[esi+4] ;-----
fmul st,st1
fstp dword[esi+4]
fld dword[esi+16] ; y scale
fld dword[esi+16] ; y scale
fmul st,st1
fstp dword[esi+16]
fld dword[esi+28]
fmul st,st1
fstp dword[esi+28] ;------
fstp dword[esi+28] ;------
 
 
fld dword[esi+8] ;-----
fld dword[esi+8] ;-----
fmul st,st1
fstp dword[esi+8]
fld dword[esi+20] ; z scale
fld dword[esi+20] ; z scale
fmul st,st1
fstp dword[esi+20]
fld dword[esi+32]
fmulp st1,st
fstp dword[esi+32] ;------
fstp dword[esi+32] ;------
 
ret
 
/programs/demos/3DS/ASC.INC
31,7 → 31,7
mov ebx,eax
push eax
call ascii_to_integer
mov [points_count_var],dx
mov [points_count_var],edx
pop eax
 
@@:
59,7 → 59,7
mov ebx,eax
push eax
call ascii_to_integer
mov [triangles_count_var],dx
mov [triangles_count_var],edx
pop eax
 
@@:
114,7 → 114,7
jne .decode_coord
pop ebx
inc ebx
cmp bx,[points_count_var]
cmp ebx,[points_count_var]
jne .decode_vertices
mov dword[edi],-1
 
175,9 → 175,9
call ascii_to_integer
mov eax,edx
 
stosw
stosd
pop esi
add esi,2
add esi,4
 
pop ecx
inc ecx
185,7 → 185,7
jne .next_vertex_number
pop edx
inc edx
cmp dx,[triangles_count_var]
cmp edx,[triangles_count_var]
jne .decode_face
mov dword[edi],-1 ;dword[triangles+ebx+2],-1 ; end mark
mov eax,1 ;-> mark if ok
/programs/demos/3DS/A_PROCS.INC
1,24 → 1,24
do_sinus:
.x equ [ebp-8]
.y equ [ebp-12]
.new_y equ [ebp-16]
.temp equ [ebp-20]
.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]
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
movzx ecx,word[size_x_var]
movzx eax,word[size_y_var]
imul ecx,eax ;SIZE_X*SIZE_Y
xor eax,eax
xor eax,eax
cld
rep stosd
pop edi
rep stosd
pop edi
; movzx eax,[sinus_flag]
; mov edx,10
; mul edx
45,7 → 45,7
fild dword .x
fmul [sin_frq]
fistp dword .temp
mov eax, .temp
mov eax, .temp
; mov bx, [angle_x]
; add bx, [angle_y]
; movzx ebx,bx
53,7 → 53,7
; add eax,ebx
 
 
and eax, 0x000000ff
and eax, 0x000000ff
 
; cdq
; mul [sin_frq]
61,79 → 61,79
; and ax,0x00ff
; cwde
 
fld dword [sin_tab+eax*4]
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
mov eax,.new_y
or eax,eax
jl .skip
movzx ebx,word[size_y_var]
cmp eax,ebx ;SIZE_Y
jg .skip
cmp eax,ebx ;SIZE_Y
jg .skip
movzx edx,word[size_x_var]
mul edx
mul edx
; shl eax,9
add eax,dword .x
lea ebx,[eax*3]
mov eax,[esi]
mov [edi+ebx],eax
add eax,dword .x
lea ebx,[eax*3]
mov eax,[esi]
mov [edi+ebx],eax
.skip:
add esi,3
inc dword .x
add esi,3
inc dword .x
movzx edx,word[size_x_var]
cmp dword .x,edx ;SIZE_X
jl .again
mov dword .x,0
inc dword .y
cmp dword .x,edx ;SIZE_X
jl .again
mov dword .x,0
inc dword .y
movzx edx,word[size_y_var]
cmp dword .y,edx ;SIZE_Y
jl .again
cmp dword .y,edx ;SIZE_Y
jl .again
 
; copy from temporary buffer -> Zbuffer to screen
mov esi,[Zbuffer_ptr]
mov edi,[screen_ptr]
mov esi,[Zbuffer_ptr]
mov edi,[screen_ptr]
movzx ecx,word[size_x_var]
movzx eax,word[size_y_var]
imul ecx,eax
lea ecx,[ecx*3]
shr ecx,2
lea ecx,[ecx*3]
shr ecx,2
; mov ecx,SIZE_X*SIZE_Y*3/4
cld
rep movsd
rep movsd
 
 
mov esp,ebp
pop ebp
mov esp,ebp
pop ebp
ret
 
 
draw_dots:
mov esi,[points_translated_ptr]
movzx ecx,[points_count_var]
mov esi,[points_translated_ptr]
mov ecx,[points_count_var]
.drw:
@@:
lodsd
add esi,2 ; skip z
add esi,2 ; skip z
movzx ebx,ax
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
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
movzx edx,word[size_x_var] ;SIZE_X ; SIZE_X not only power of 2 -> 256,512,...
mul edx
add eax,ebx
mov edi,[screen_ptr]
lea eax,[eax*3]
add edi,eax
xor eax,eax
not eax
mul edx
add eax,ebx
mov edi,[screen_ptr]
lea eax,[eax*3]
add edi,eax
xor eax,eax
not eax
stosd
@@:
loop .drw
176,14 → 176,14
punpcklbw xmm3,xmm0
punpcklbw xmm4,xmm0
psubsw xmm1,xmm2
paddw xmm1,[emboss_bias]
paddw xmm1,[emboss_bias]
psubsw xmm3,xmm4
paddw xmm3,[emboss_bias]
paddw xmm3,[emboss_bias]
pmulhw xmm1,xmm3
movaps xmm7,xmm1
movaps xmm6,xmm1
psrlq xmm7,2*8
psrlq xmm6,4*8
psrlq xmm7,2*8
psrlq xmm6,4*8
pmaxsw xmm1,xmm7
pmaxsw xmm1,xmm6
 
190,41 → 190,41
if 0
movaps xmm7,xmm3
movaps xmm6,xmm3
psrlq xmm7,2*8
psrlq xmm6,4*8
psrlq xmm7,2*8
psrlq xmm6,4*8
pmaxsw xmm3,xmm7
pmaxsw xmm3,xmm6
end if
pmaxsw xmm1,xmm3
 
movd eax,xmm1
movzx eax,al
lea eax,[eax*3+envmap_cub]
mov eax,[eax]
mov [edi],eax ;xmm1
movd eax,xmm1
movzx eax,al
lea eax,[eax*3+envmap_cub]
mov eax,[eax]
mov [edi],eax ;xmm1
psrldq xmm1,8
movd eax,xmm1
movzx eax,al
lea eax,[eax*3+envmap_cub]
mov eax,[eax]
mov [edi+4],eax
movd eax,xmm1
movzx eax,al
lea eax,[eax*3+envmap_cub]
mov eax,[eax]
mov [edi+4],eax
 
 
add edi,8
add esi,6
add ebx,6
add edx,6
sub ecx,2
jnc @b
add edi,8
add esi,6
add ebx,6
add edx,6
sub ecx,2
jnc @b
 
 
pop ecx ;,eax
mov edi,[screen_ptr]
mov esi,[Zbuffer_ptr]
pop ecx ;,eax
mov edi,[screen_ptr]
mov esi,[Zbuffer_ptr]
@@:
movsd
dec edi
loop @b
dec edi
loop @b
end if
ret
 
238,22 → 238,22
; transfer screen buffer into bump map
; and draw two bump triangles
; *************************************
mov esi,screen
mov edi,bumpmap2
mov ecx,TEXTURE_SIZE/3
cld
mov esi,screen
mov edi,bumpmap2
mov ecx,TEXTURE_SIZE/3
cld
if Ext=NON
xor eax,eax
xor bh,bh
xor dh,dh
xor eax,eax
xor bh,bh
xor dh,dh
@@:
lodsb
movzx bx,al
lodsb
movzx dx,al
lodsb
add ax,bx
add ax,dx
lodsb
movzx bx,al
lodsb
movzx dx,al
lodsb
add ax,bx
add ax,dx
; cwd
; div [i3]
;; push ax
262,73 → 262,73
;; shr ax,2
;; add ax,bx
 
lea eax,[eax*5]
shr ax,4
lea eax,[eax*5]
shr ax,4
 
stosb
loop @b
stosb
loop @b
else
emms
pxor mm1,mm1
mov ebx,0x0000ffff
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 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
movd eax,mm0
and eax,ebx
lea eax,[eax*5]
shr ax,4
stosb
add esi,3
loop @b
 
end if
push ebp
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 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
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
pop ebp
ret
end if
;********************************EMBOSS DONE*******************************
342,176 → 342,176
; cos dd ?
;endl
.counter equ word[ebp-2]
.sin equ dword[ebp-6]
.cos equ dword[ebp-10]
.sin2 equ dword[ebp-14]
.cos2 equ dword[ebp-18]
.sin equ dword[ebp-6]
.cos equ dword[ebp-10]
.sin2 equ dword[ebp-14]
.cos2 equ dword[ebp-18]
.piD180m3 equ dword[ebp-22]
.cD2 equ word[ebp-24]
push ebp
mov ebp,esp
sub esp,24
.cD2 equ word[ebp-24]
push ebp
mov ebp,esp
sub esp,24
 
push ax
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
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
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
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
.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
; mov .counter,dx
fld st
fidiv [i3]
faddp
fld st
fidiv [i3]
faddp
@@:
fstp dword[edi+8] ; new z
fld dword[ebx+4]
or dx,dx
jnz @f
fstp dword[edi+8] ; new z
fld dword[ebx+4]
or dx,dx
jnz @f
; fld1
; faddp
; fld st
fadd st,st0
fadd st,st0
fadd st,st0
fadd st,st0
; fxch
; fimul [i3]
; fsin
; faddp
mov dx,9
mov dx,9
@@:
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
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
 
 
 
.end_rot:
 
add edi,12
add ebx,12
mov esi,[points_ptr]
add esi,12*4
cmp ebx,esi
jl .rotor
add edi,12
add ebx,12
mov esi,[points_ptr]
add esi,12*4
cmp ebx,esi
jl .rotor
 
add [points_count_var],4
add cx,18
cmp cx,(18*21*3)+1
jle .next
add [points_count_var],4
add cx,18
cmp cx,(18*21*3)+1
jle .next
 
mov edi,[triangles_ptr]
mov ax,4
mov bx,4+4
mov [triangles_count_var],164*3 ;140
mov edi,[triangles_ptr]
mov eax,4
mov ebx,4+4
mov [triangles_count_var],160*3 ;164*3 ;140
 
mov cx,80*3 ;68
mov ecx,80*3 ;68
@@:
stosw ;----
mov [edi],bx ; |
add edi,2 ; |
inc ax ; |
stosw ; |repeat 4 times
stosd ;----
mov [edi],ebx ; |
add edi,4 ; |
inc eax ; |
stosd ; |repeat 4 times
 
mov [edi],bx ; |
inc bx
add edi,2
stosw ; |
mov [edi],bx ; |
add edi,2 ;----
loop @b
mov [edi],ebx ; |
inc ebx
add edi,4
stosd ; |
mov [edi],ebx ; |
add edi,4 ;----
loop @b
 
 
mov dword[edi],-1 ; < - end mark
mov [culling_flag],0
mov dword[edi],-1 ; < - end mark
mov [culling_flag],0
 
mov esp,ebp
pop ebp
mov esp,ebp
pop ebp
 
ret
 
523,186 → 523,187
; cos dd ?
;endl
.counter equ word[ebp-2]
.sin equ dword[ebp-6]
.cos equ dword[ebp-10]
.sin2 equ dword[ebp-14]
.cos2 equ dword[ebp-18]
.sin equ dword[ebp-6]
.cos equ dword[ebp-10]
.sin2 equ dword[ebp-14]
.cos2 equ dword[ebp-18]
.piD180m3 equ dword[ebp-22]
.cD2 equ word[ebp-24]
push ebp
mov ebp,esp
sub esp,24
.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
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],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
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
stosd
mov dword[edi],-2.5
add edi,4
stosd
 
mov [points_count_var],5
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
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
.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]
fld dword[ebx+4] ;y
fstp dword[edi+4]
 
 
.end_rot:
 
add edi,12
add ebx,12
mov esi,[points_ptr]
add esi,12*5
cmp ebx,esi ;real_points + (12*5)
jl .rotor
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
add [points_count_var],5
add cx,18
cmp cx,(18*21)+1
jle .next
;last points
 
xor eax,eax
xor eax,eax
 
mov dword[edi],0.22
mov dword[edi+4],0.77
mov dword[edi+8],1.25
add edi,12
mov dword[edi],0.22
mov dword[edi+4],0.77
mov dword[edi+8],1.25
add edi,12
 
mov dword[edi],0.22
mov dword[edi+4],0.77
mov dword[edi+8],-1.25
add edi,12
stosd
mov dword[edi],0.22
mov dword[edi+4],0.77
mov dword[edi+8],-1.25
add edi,12
stosd
 
add [points_count_var],2
add [points_count_var],2
 
; init triangles list
 
mov edi,[triangles_ptr]
mov ax,5
mov bx,5+5
mov [triangles_count_var],204
mov edi,[triangles_ptr]
mov eax,5
mov ebx,5+5
mov [triangles_count_var],200 ;204
 
mov cx,100
mov ecx,100
@@:
stosw ;----
mov [edi],bx ; |
add edi,2 ; |
inc ax ; |
stosw ; |repeat
stosd ;----
mov [edi],ebx ; |
add edi,4 ; |
inc eax ; |
stosd ; |repeat
 
mov [edi],bx ; |
inc bx
add edi,2
stosw ; |
mov [edi],bx ; |
add edi,2 ;----
loop @b
mov [edi],ebx ; |
inc ebx
add edi,4
stosd ; |
mov [edi],ebx ; |
add edi,4 ;----
loop @b
 
mov ax,5
mov bx,[points_count_var]
sub bx,2
mov dl,2
mov eax,5
mov ebx,[points_count_var]
sub ebx,2
mov dl,2
.nx:
mov cx,5
add [triangles_count_var],cx
mov ecx,5
add [triangles_count_var],ecx
@@:
stosw
add ax,5
stosw
mov word[edi],bx
add edi,2
loop @b
stosd
add eax,5
stosd
mov dword[edi],ebx
add edi,4
loop @b
 
cmp dl,1
je @f
cmp dl,1
je @f
 
inc bx
jmp .lab
inc ebx
jmp .lab
@@:
dec bx
dec ebx
.lab:
mov cx,5
add [triangles_count_var],cx
mov ecx,5
add [triangles_count_var],ecx
@@:
stosw
add ax,5
stosw
mov word[edi],bx
add edi,2
loop @b
stosd
add eax,5
stosd
mov dword[edi],ebx
add edi,4
loop @b
 
dec dl
or dl,dl
jnz .nx
dec dl
or dl,dl
jnz .nx
 
sub ax,25
stosw
sub ax,50
stosw
mov word[edi],bx
add edi,2
sub eax,25
stosd
sub eax,50
stosd
mov dword[edi],ebx
add edi,4
 
stosw
add ax,50
stosw
inc bx
mov word[edi],bx
add edi,2
add [triangles_count_var],2
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 dword[edi],-1 ; < - end mark
mov [culling_flag],0
 
mov esp,ebp
pop ebp
mov esp,ebp
pop ebp
 
ret
 
/programs/demos/3DS/B_PROCS.INC
12,46 → 12,46
; cmp eax,511*3
; jl @b
;ret
init_envmap_cub: ; create 512x512 env map
init_envmap_cub: ; create 512x512 env map
.temp equ word [ebp-2]
push ebp
mov ebp,esp
sub esp,2
mov edi,envmap_cub
fninit
push ebp
mov ebp,esp
sub esp,2
mov edi,envmap_cub
fninit
 
mov cx,-256
mov cx,-256
.ie_hor:
mov .temp,cx
fild .temp
fabs
mov .temp,cx
fild .temp
fabs
; fmul st,st0
; fsqrt
mov .temp,255
fisubr .temp
fmul [env_const]
fistp .temp
mov ax,.temp
mov .temp,255
fisubr .temp
fmul [env_const]
fistp .temp
mov ax,.temp
 
or ax,ax
jge .ie_ok1
xor ax,ax
jmp .ie_ok2
or ax,ax
jge .ie_ok1
xor ax,ax
jmp .ie_ok2
.ie_ok1:
cmp ax,255
jle .ie_ok2
mov ax,255
cmp ax,255
jle .ie_ok2
mov ax,255
.ie_ok2:
stosb
stosb
stosb
stosb
stosb
stosb
 
inc cx
cmp cx,256
jne .ie_hor
inc cx
cmp cx,256
jne .ie_hor
 
mov esp,ebp
pop ebp
mov esp,ebp
pop ebp
ret
 
calc_one_col:
59,42 → 59,42
; in - st - dot_product
; stack - other parameters
; out - eax - 0x00rrggbb
.dot_prd equ dword[ebp+4] ; dot product - cos x - not now
.min_col_r equ word[ebp+8] ; minimum color - ambient
.dot_prd equ dword[ebp+4] ; dot product - cos x - not now
.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 word[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 word[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]
.n equ word[ebp+26] ; shines - not implemented
.temp equ word[ebp-2]
.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 ebp,esp
sub esp,14
 
mov ax,.min_col_r
add ax,.max_col_r
add ax,.org_col_r
cwde
mov .color_sum_r,eax
mov ax,.min_col_r
add ax,.max_col_r
add ax,.org_col_r
cwde
mov .color_sum_r,eax
 
mov ax,.min_col_g
add ax,.max_col_g
add ax,.org_col_g
cwde
mov .color_sum_g,eax
mov ax,.min_col_g
add ax,.max_col_g
add ax,.org_col_g
cwde
mov .color_sum_g,eax
 
mov ax,.min_col_b
add ax,.max_col_b
add ax,.org_col_b
cwde
mov .color_sum_b,eax
mov ax,.min_col_b
add ax,.max_col_b
add ax,.org_col_b
cwde
mov .color_sum_b,eax
 
 
; fld .dot_prd
106,78 → 106,78
; fld1
; faddp ; st = dot_product ^ n
 
fld st ; copy dot pr
fmul st,st0
fmul st,st0
fmul st,st0
cmp .n,255 ; .n = 255 -> spot light
jne @f
fmul st,st0
fmul st,st0
fmul st,st0
fld st ; copy dot pr
fmul st,st0
fmul st,st0
fmul st,st0
cmp .n,255 ; .n = 255 -> spot light
jne @f
fmul st,st0
fmul st,st0
fmul st,st0
@@:
fld st ; st0=st1=dot_pr^n, st2=dot_pr
fimul .max_col_b
fild .org_col_b
fmul st,st3
faddp ; st0=first piece of col, st1=dot_pr^n..
fiadd .min_col_b
fimul .max_col_b
fidiv .color_sum_b
fistp .temp
movzx eax,.temp
shl eax,16
fld st ; st0=st1=dot_pr^n, st2=dot_pr
fimul .max_col_b
fild .org_col_b
fmul st,st3
faddp ; st0=first piece of col, st1=dot_pr^n..
fiadd .min_col_b
fimul .max_col_b
fidiv .color_sum_b
fistp .temp
movzx eax,.temp
shl eax,16
 
fld st
fimul .max_col_g
fild .org_col_g
fmul st,st3
faddp
fiadd .min_col_g
fimul .max_col_g
fidiv .color_sum_g
fistp .temp
mov ax,.temp
mov ah,al
shl eax,8
fld st
fimul .max_col_g
fild .org_col_g
fmul st,st3
faddp
fiadd .min_col_g
fimul .max_col_g
fidiv .color_sum_g
fistp .temp
mov ax,.temp
mov ah,al
shl eax,8
 
fimul .max_col_r
fild .org_col_r
fmulp st2,st
faddp
fiadd .min_col_r
fimul .max_col_r
fidiv .color_sum_r
fistp .temp
mov ax,.temp ;eax - 0xbbgg00rr
fimul .max_col_r
fild .org_col_r
fmulp st2,st
faddp
fiadd .min_col_r
fimul .max_col_r
fidiv .color_sum_r
fistp .temp
mov ax,.temp ;eax - 0xbbgg00rr
; mov ah,al
ror eax,16
xchg al,ah ; eax - 0x00rrggbb
mov esp,ebp
ror eax,16
xchg al,ah ; eax - 0x00rrggbb
mov esp,ebp
ret 24
 
calc_bumpmap: ; calculate random bumpmap
calc_bumpmap: ; calculate random bumpmap
;--------------in edi _ pointer to TEX_X x TEX_Y bumpmap
 
push edi
push edi
 
cmp [bumps_flag],0
je .random_bump_map
; else bumps according to texture
mov esi,texmap
mov ecx,TEXTURE_SIZE
cmp [bumps_flag],0
je .random_bump_map
; else bumps according to texture
mov esi,texmap
mov ecx,TEXTURE_SIZE
@@:
movzx ax,byte[esi]
movzx bx,byte[esi+1]
movzx dx,byte[esi+2]
add ax,bx
add ax,dx
cwd
div [i3]
stosb
add esi,3
loop @b
jmp .blur_map
movzx ax,byte[esi]
movzx bx,byte[esi+1]
movzx dx,byte[esi+2]
add ax,bx
add ax,dx
cwd
div [i3]
stosb
add esi,3
loop @b
jmp .blur_map
; push ecx
; mov eax,0x88888888
; mov ecx,16/4
189,78 → 189,78
; loop @b
.random_bump_map:
 
mov ecx,TEXTURE_SIZE
mov ecx,TEXTURE_SIZE
@@:
push ecx
xor ecx,ecx
mov edx,255
call random
stosb
pop ecx
loop @b
push ecx
xor ecx,ecx
mov edx,255
call random
stosb
pop ecx
loop @b
 
.blur_map:
pop edi
movzx ecx,[bumps_deep_flag]
inc cx
pop edi
movzx ecx,[bumps_deep_flag]
inc cx
.blur:
xor esi,esi
mov edx,TEXTURE_SIZE
xor eax,eax
xor ebx,ebx
xor esi,esi
mov edx,TEXTURE_SIZE
xor eax,eax
xor ebx,ebx
@@:
mov ebp,esi
dec ebp
and ebp,TEXTURE_SIZE
mov al,byte[ebp+edi]
mov ebp,esi
dec ebp
and ebp,TEXTURE_SIZE
mov al,byte[ebp+edi]
 
mov ebp,esi
inc ebp
and ebp,TEXTURE_SIZE
mov bl,byte[ebp+edi]
add eax,ebx
mov ebp,esi
inc ebp
and ebp,TEXTURE_SIZE
mov bl,byte[ebp+edi]
add eax,ebx
 
mov ebp,esi
sub ebp,TEX_X
and ebp,TEXTURE_SIZE
mov bl,byte[ebp+edi]
add eax,ebx
mov ebp,esi
sub ebp,TEX_X
and ebp,TEXTURE_SIZE
mov bl,byte[ebp+edi]
add eax,ebx
 
mov ebp,esi
add ebp,TEX_X
and ebp,TEXTURE_SIZE
mov bl,byte[ebp+edi]
add eax,ebx
mov ebp,esi
add ebp,TEX_X
and ebp,TEXTURE_SIZE
mov bl,byte[ebp+edi]
add eax,ebx
 
shr eax,2
mov byte[esi+edi],al
shr eax,2
mov byte[esi+edi],al
 
inc esi
dec edx
jnz @b
inc esi
dec edx
jnz @b
 
loop .blur
loop .blur
ret
random:
; in - ecx - min
; edx - max
; out - eax - random number
mov bx,[rand_seed]
add bx,0x9248
ror bx,3
mov [rand_seed],bx
mov bx,[rand_seed]
add bx,0x9248
ror bx,3
mov [rand_seed],bx
 
mov ax,dx
sub ax,cx
mul bx
mov ax,dx
add ax,cx
cwde
mov ax,dx
sub ax,cx
mul bx
mov ax,dx
add ax,cx
cwde
ret
 
optimize_object1: ; setting point (0,0,0) in center of object
; recalculate all coords , scale object,
;the coords in <-1.0,1.0>
optimize_object1: ; setting point (0,0,0) in center of object
; recalculate all coords , scale object,
;the coords in <-1.0,1.0>
;in : real_points - table filled of real float dd coordinates (x,y,z), end mark dd -1
; _ global variable
; points_count_var - dw integer variable with exactly points count
272,221 → 272,221
.maxxx equ dword[ebp-12]
.center equ dword[ebp-16]
 
mov ebp,esp
sub esp,16
fninit
mov .maxxx,0
mov ecx,3
xor ebx,ebx ; ebx - x,y,z coord in real_points list
.next_c: ; max/min/center x,y,z
mov edi,[points_ptr] ; in real_point list minimum two points
mov dx,[points_count_var]
fld dword[edi+ebx]
fst .max
fstp .min
add edi,12
dec dx
.next_coord: ; next coord from real_points list
fld dword [edi+ebx] ; real_points -> x,y,z
fcom .max ; max_x,y,z
fstsw ax
sahf
jbe @f ; jmp less equal
fstp .max ; new max_x,y,z
jmp .end_coords
mov ebp,esp
sub esp,16
fninit
mov .maxxx,0
mov ecx,3
xor ebx,ebx ; ebx - x,y,z coord in real_points list
.next_c: ; max/min/center x,y,z
mov edi,[points_ptr] ; in real_point list minimum two points
mov edx,[points_count_var]
fld dword[edi+ebx]
fst .max
fstp .min
add edi,12
dec edx
.next_coord: ; next coord from real_points list
fld dword [edi+ebx] ; real_points -> x,y,z
fcom .max ; max_x,y,z
fstsw ax
sahf
jbe @f ; jmp less equal
fstp .max ; new max_x,y,z
jmp .end_coords
@@:
fcom .min ; min_x,y,z
fstsw ax
sahf
jnbe @f ; jmp greater
fst .min ; new min_x
fcom .min ; min_x,y,z
fstsw ax
sahf
jnbe @f ; jmp greater
fst .min ; new min_x
@@:
ffree st
ffree st
.end_coords:
add edi,12
add edi,12
; cmp dword[edi],-1 ; cmp with end mark
dec dx
jnz .next_coord
; ok after this we found max_coord and min_coord
fld .max ; find center point
fadd .min
fld1
fld1
faddp
fdivp st1,st ; st0 - center coord
fstp .center
dec edx
jnz .next_coord
; ok after this we found max_coord and min_coord
fld .max ; find center point
fadd .min
fld1
fld1
faddp
fdivp st1,st ; st0 - center coord
fstp .center
 
fld .max
fsub .center ; st = .max - .center
fcom .maxxx ; maximum of all .max
fstsw ax
sahf
jbe @f ; jmp lower
fst .maxxx ; new maxx
fld .max
fsub .center ; st = .max - .center
fcom .maxxx ; maximum of all .max
fstsw ax
sahf
jbe @f ; jmp lower
fst .maxxx ; new maxx
@@:
ffree st
mov edi,[points_ptr]
mov dx,[points_count_var] ; substraction all coords - center point
ffree st
mov edi,[points_ptr]
mov edx,[points_count_var] ; substraction all coords - center point
@@:
fld dword[edi+ebx]
fsub .center
fstp dword[edi+ebx]
add edi,12
fld dword[edi+ebx]
fsub .center
fstp dword[edi+ebx]
add edi,12
; cmp dword[edi],-1
; jne @b
dec dx
jnz @b
dec edx
jnz @b
 
add ebx,4 ; ebx - x,y,z cooficientes in list real_points
dec ecx
jnz .next_c
add ebx,4 ; ebx - x,y,z cooficientes in list real_points
dec ecx
jnz .next_c
 
fld .maxxx
mov edi,[points_ptr] ; create all coords in <-1.0,1.0>
movzx ecx,[points_count_var]
fld .maxxx
mov edi,[points_ptr] ; create all coords in <-1.0,1.0>
mov ecx,[points_count_var]
@@:
fld dword[edi]
fdiv .maxxx
fstp dword[edi]
fld dword[edi+4]
fdiv .maxxx
fstp dword[edi+4]
fld dword[edi+8]
fdiv .maxxx
fstp dword[edi+8]
add edi,12
loop @b
fld dword[edi]
fdiv .maxxx
fstp dword[edi]
fld dword[edi+4]
fdiv .maxxx
fstp dword[edi+4]
fld dword[edi+8]
fdiv .maxxx
fstp dword[edi+8]
add edi,12
loop @b
; cmp dword[edi],-1
 
; jne @b
 
mov esp,ebp
mov esp,ebp
ret
 
generate_object: ; generate node
.N equ 32
.x equ word[ebp-2]
.Ndiv2 equ word[ebp-10]
generate_object: ; generate node
.N equ 32
.x equ word[ebp-2]
.Ndiv2 equ word[ebp-10]
.MthickSqr equ dword[ebp-14] ; diameter^2
.temp equ dword[ebp-18] ; variable for x <-1;1>
.temp equ dword[ebp-18] ; variable for x <-1;1>
.Hthick equ dword[ebp-22]
.cos_temp equ dword[ebp-26]
.next_const equ dword[ebp-30]
.a equ dword[ebp-34]
.Pi2 equ ebp-38
.a equ dword[ebp-34]
.Pi2 equ ebp-38
 
 
 
mov ebp,esp
sub esp,42
mov ebp,esp
sub esp,42
 
mov .Ndiv2,.N/2
mov .Ndiv2,.N/2
fninit
fldpi
fadd st,st
fst dword[.Pi2]
fidiv .Ndiv2
fst .a ; .Ndiv2*.a=2Pi => .a=2pi/.Ndiv2
fadd st,st
fst dword[.Pi2]
fidiv .Ndiv2
fst .a ; .Ndiv2*.a=2Pi => .a=2pi/.Ndiv2
 
fld [.Mthick] ; inside diameter, (outside daiameter = 1)
fmul st,st0
fstp .MthickSqr
fld [.Mthick] ; inside diameter, (outside daiameter = 1)
fmul st,st0
fstp .MthickSqr
fld1
 
fsub [.Mthick]
fsub [.Mthick]
 
fst .Hthick ; Hthick = 1 - Mthick
fld st
fadd st,st
fst .Hthick ; Hthick = 1 - Mthick
fld st
fadd st,st
faddp
fstp .next_const ; next_const = Hthick * 3
fstp .next_const ; next_const = Hthick * 3
 
 
;init triangles list
mov edi,[triangles_ptr]
mov edi,[triangles_ptr]
 
xor si,si
xor ax,ax
mov bx,.N+1
mov cx,(.N*2)+2 ;--
mov dx,(.N*3)+3 ;---
mov [triangles_count_var],0
xor esi,esi
xor eax,eax
mov ebx,.N+1
mov ecx,(.N*2)+2 ;--
mov edx,(.N*3)+3 ;---
mov [triangles_count_var],0
.again_tri:
stosw ; main wave
mov word[edi],bx
inc ax
add edi,2
stosw
stosw
mov word[edi],bx
inc bx
mov word[edi+2],bx
stosd ; main wave
mov dword[edi],ebx
inc eax
add edi,4
stosd
stosd
mov dword[edi],ebx
inc ebx
mov dword[edi+4],ebx
 
 
add edi,4
add edi,8
 
mov word[edi],cx ;---- ; n2+2 ; xor ax,ax
inc cx ; n2+3 ; mov bx,.N+1
mov word[edi+2],dx ; ; mov cx,(.N*2)+2 ;--
mov word[edi+4],cx ; n3+3 ; mov dx,(.N*3)+3 ;---
mov word[edi+6],dx ; n3+3 ;
inc dx ; ;
mov word[edi+8],dx ; n2+3 ;
mov word[edi+10],cx ; n3+4
add edi,12 ;----
mov dword[edi],ecx ;---- ; n2+2 ; xor ax,ax
inc ecx ; n2+3 ; mov bx,.N+1
mov dword[edi+4],edx ; ; mov cx,(.N*2)+2 ;--
mov dword[edi+8],ecx ; n3+3 ; mov dx,(.N*3)+3 ;---
mov dword[edi+12],edx ; n3+3 ;
inc edx ; ;
mov dword[edi+16],edx ; n2+3 ;
mov dword[edi+20],ecx ; n3+4
add edi,24 ;----
 
dec ax ; border of wave
dec bx
dec cx
dec dx
dec eax ; border of wave
dec ebx
dec ecx
dec edx
 
stosw ; first border
inc ax
stosw
mov word[edi],dx
add edi,2
stosd ; first border
inc eax
stosd
mov dword[edi],edx
add edi,4
 
mov word[edi],dx
add edi,2
stosw
inc dx
mov word[edi],dx
mov dword[edi],edx
add edi,4
stosd
inc edx
mov dword[edi],edx
 
mov word[edi+2],bx ; second border
mov word[edi+4],cx
inc bx
mov word[edi+6],bx
mov dword[edi+4],ebx ; second border
mov dword[edi+8],ecx
inc ebx
mov dword[edi+12],ebx
 
mov word[edi+8],bx
mov word[edi+10],cx
inc cx
mov word[edi+12],cx
add edi,14
mov dword[edi+16],ebx
mov dword[edi+20],ecx
inc ecx
mov dword[edi+24],ecx
add edi,28
 
add [triangles_count_var],8 ;10
inc si
cmp si,.N
jne .again_tri
add [triangles_count_var],8 ;10
inc esi
cmp esi,.N
jne .again_tri
 
add ax,((.N+1)*3)+1
add bx,((.N+1)*3)+1
add cx,((.N+1)*3)+1
add dx,((.N+1)*3)+1
xor si,si
cmp ax,(.N*13)+13 ;;;(.N*23)+23 ; ax,(.N*13)+13
add eax,((.N+1)*3)+1
add ebx,((.N+1)*3)+1
add ecx,((.N+1)*3)+1
add edx,((.N+1)*3)+1
xor esi,esi
cmp eax,(.N*13)+13 ;;;(.N*23)+23 ; ax,(.N*13)+13
jl .again_tri
 
mov dword[edi],-1 ; <--- end mark not always in use
; mov dword[edi],-1 ; <--- end mark not always in use
 
; init real points list
mov .x,-(.N/2)
mov edi,[points_ptr]
lea esi,[edi+(12*(.N+1))]
mov eax,[points_ptr]
mov ebx,eax
add eax,2*12*(.N+1) ;---
add ebx,3*12*(.N+1) ;---
mov [points_count_var],0
mov .x,-(.N/2)
mov edi,[points_ptr]
lea esi,[edi+(12*(.N+1))]
mov eax,[points_ptr]
mov ebx,eax
add eax,2*12*(.N+1) ;---
add ebx,3*12*(.N+1) ;---
mov [points_count_var],0
 
 
.R_P4 equ edi+(4*12*(.N+1))
506,69 → 506,69
 
@@:
; x coordinate
fild .x
fld st
fild .x
fld st
;; fmul .a ; st = <-2pi;2pi> when mul .a
fidiv .Ndiv2
fst .temp ; temporary x in <-1.0;1.0>
fidiv .Ndiv2
fst .temp ; temporary x in <-1.0;1.0>
 
fst dword[edi] ;x coordinate of point
fst dword[esi]
fst dword[eax] ;--
fst dword[edi] ;x coordinate of point
fst dword[esi]
fst dword[eax] ;--
 
 
fst dword[.R_P4]
fst dword[.R_P5]
fst dword[.R_P6]
fst dword[.R_P7]
fst dword[.R_P4]
fst dword[.R_P5]
fst dword[.R_P6]
fst dword[.R_P7]
 
fst dword[.R_P8]
fst dword[.R_P9]
fst dword[.R_P10]
fst dword[.R_P11]
fst dword[.R_P8]
fst dword[.R_P9]
fst dword[.R_P10]
fst dword[.R_P11]
 
fst dword[.R_P12]
fst dword[.R_P13]
fst dword[.R_P14]
fst dword[.R_P15]
fst dword[.R_P12]
fst dword[.R_P13]
fst dword[.R_P14]
fst dword[.R_P15]
 
fstp dword[ebx] ;pop
fstp dword[ebx] ;pop
;*******y coord dword[offset + 4]
fmul .a ; st = <-2pi;2pi>
fmul .a ; st = <-2pi;2pi>
fsincos
fmul .next_const
fst dword[edi+4] ; y coordinate of point
fst dword[esi+4]
fst dword[.R_P4+4]
fst dword[.R_P5+4]
fld .Hthick
fmul .next_const
fst dword[edi+4] ; y coordinate of point
fst dword[esi+4]
fst dword[.R_P4+4]
fst dword[.R_P5+4]
fld .Hthick
faddp
fst dword[.R_P6+4]
fst dword[.R_P7+4]
fst dword[eax+4]
fst dword[ebx+4]
fst dword[.R_P6+4]
fst dword[.R_P7+4]
fst dword[eax+4]
fst dword[ebx+4]
 
fchs
fst dword[.R_P10+4]
fst dword[.R_P11+4]
fst dword[.R_P14+4]
fst dword[.R_P15+4]
fadd .Hthick
fadd .Hthick
fst dword[.R_P8+4]
fst dword[.R_P9+4]
fst dword[.R_P12+4]
fstp dword[.R_P13+4]
fst dword[.R_P10+4]
fst dword[.R_P11+4]
fst dword[.R_P14+4]
fst dword[.R_P15+4]
fadd .Hthick
fadd .Hthick
fst dword[.R_P8+4]
fst dword[.R_P9+4]
fst dword[.R_P12+4]
fstp dword[.R_P13+4]
 
 
fmul .Hthick
fmul .next_const
fstp .cos_temp ; cos_temp = Hthick^2 * 3
fmul .Hthick
fmul .next_const
fstp .cos_temp ; cos_temp = Hthick^2 * 3
 
;***************z coord
fld .temp
fld st
fmul st,st0 ; z coords
fld .temp
fld st
fmul st,st0 ; z coords
fchs
fld1
faddp
576,57 → 576,57
fsqrt
; fld st
; fsub
fld st
fsub .cos_temp
fst dword[esi+8]
fstp dword[eax+8] ;--
fld st
fadd .cos_temp
fst dword[.R_P9+8]
fstp dword[.R_P10+8]
fld st
fsub .cos_temp
fst dword[esi+8]
fstp dword[eax+8] ;--
fld st
fadd .cos_temp
fst dword[.R_P9+8]
fstp dword[.R_P10+8]
fchs
fld st
fsub .cos_temp
fst dword[.R_P6+8]
fstp dword[.R_P5+8]
fadd .cos_temp
fst dword[.R_P13+8]
fstp dword[.R_P14+8]
fld st
fsub .cos_temp
fst dword[.R_P6+8]
fstp dword[.R_P5+8]
fadd .cos_temp
fst dword[.R_P13+8]
fstp dword[.R_P14+8]
 
fmul [.Mthick]
fmul st,st0
fmul [.Mthick]
fmul st,st0
fchs
fld .MthickSqr
fld .MthickSqr
faddp
fabs
fsqrt
fld st
fsub .cos_temp
fst dword[edi+8] ; z coordinate
fstp dword[ebx+8] ;--
fld st
fadd .cos_temp
fst dword[.R_P8+8]
fstp dword[.R_P11+8]
fld st
fsub .cos_temp
fst dword[edi+8] ; z coordinate
fstp dword[ebx+8] ;--
fld st
fadd .cos_temp
fst dword[.R_P8+8]
fstp dword[.R_P11+8]
fchs
fld st
fsub .cos_temp
fst dword[.R_P7+8]
fstp dword[.R_P4+8]
fadd .cos_temp
fst dword[.R_P12+8]
fstp dword[.R_P15+8]
fld st
fsub .cos_temp
fst dword[.R_P7+8]
fstp dword[.R_P4+8]
fadd .cos_temp
fst dword[.R_P12+8]
fstp dword[.R_P15+8]
 
add edi,12
add esi,12
add eax,12 ;--
add ebx,12 ;---
add [points_count_var],24 ;16
inc .x
cmp .x,.N/2
jng @b
add edi,12
add esi,12
add eax,12 ;--
add ebx,12 ;---
add [points_count_var],24 ;16
inc .x
cmp .x,.N/2
jng @b
; mov dword[esi],-1 ; <-- end mark
mov [culling_flag],0
mov [culling_flag],0
mov esp,ebp
ret
.Mthick dd 0.85 ; size-thickness
633,630 → 633,627
 
make_random_lights:
.temp1 equ ebp-4
.temp2 equ ebp-8 ; - light vector generate variables
.temp2 equ ebp-8 ; - light vector generate variables
.temp3 equ ebp-12
.max equ 800
RDTSC
mov [rand_seed],ax
push ebp
mov ebp,esp
sub esp,12
mov edi,lights
fninit
mov dword[.temp2],.max
mov dword[.temp3],.max/2
RDTSC
mov [rand_seed],ax
push ebp
mov ebp,esp
sub esp,12
mov edi,lights
fninit
mov dword[.temp2],.max
mov dword[.temp3],.max/2
 
.again:
xor esi,esi
xor esi,esi
@@:
mov edx,.max
xor ecx,ecx
call random
sub eax,.max/2
mov dword[.temp1],eax
fild dword[.temp1]
fidiv dword[.temp3]
fstp dword[edi+esi*4]
inc esi
cmp esi,2
jne @b
mov edx,.max
xor ecx,ecx
call random
sub eax,.max/2
mov dword[.temp1],eax
fild dword[.temp1]
fidiv dword[.temp3]
fstp dword[edi+esi*4]
inc esi
cmp esi,2
jne @b
 
.max1 equ 1000
mov dword[.temp2],.max1/2
mov edx,.max1
xor ecx,ecx
call random
mov dword[.temp1],eax
fild dword[.temp1]
fchs
fidiv dword[.temp2]
fstp dword[edi+8]
mov dword[.temp2],.max1/2
mov edx,.max1
xor ecx,ecx
call random
mov dword[.temp1],eax
fild dword[.temp1]
fchs
fidiv dword[.temp2]
fstp dword[edi+8]
 
xor esi,esi
xor esi,esi
@@:
mov ecx,220 ; max colors and shine , ecx = 200 - more bright shading
mov edx,255
call random
mov byte[edi+18+esi],al
inc esi
cmp esi,4
jne @b
mov ecx,220 ; max colors and shine , ecx = 200 - more bright shading
mov edx,255
call random
mov byte[edi+18+esi],al
inc esi
cmp esi,4
jne @b
 
 
xor esi,esi
xor esi,esi
@@:
mov ecx,100 ; orginal colors
movzx edx,byte[edi+18+esi]
call random
mov byte[edi+12+esi],al
inc esi
cmp esi,3
jne @b
mov ecx,100 ; orginal colors
movzx edx,byte[edi+18+esi]
call random
mov byte[edi+12+esi],al
inc esi
cmp esi,3
jne @b
 
xor esi,esi
xor esi,esi
@@:
mov ecx,1 ; min cols
movzx edx,byte[edi+12+esi]
call random
mov byte[edi+15+esi],al
inc esi
cmp esi,3
jne @b
mov ecx,1 ; min cols
movzx edx,byte[edi+12+esi]
call random
mov byte[edi+15+esi],al
inc esi
cmp esi,3
jne @b
 
add edi,LIGHT_SIZE ;22
cmp edi,lightsend ; see file View3ds,asm
jne .again
add edi,LIGHT_SIZE ;22
cmp edi,lightsend ; see file View3ds,asm
jne .again
 
mov esp,ebp
pop ebp
mov esp,ebp
pop ebp
ret
 
generate_texture2:
.const equ 32
mov edi,texmap
xor bx,bx
mov edi,texmap
xor bx,bx
.next_line:
xor dx,dx
xor dx,dx
.next2stripes:
mov eax,-1
mov ecx,(TEX_X/.const)*3/4
rep stosd
mov eax,0x00ff0000
mov ecx,(TEX_X/.const)
mov eax,-1
mov ecx,(TEX_X/.const)*3/4
rep stosd
mov eax,0x00ff0000
mov ecx,(TEX_X/.const)
@@:
stosd
dec edi
loop @b
inc dx
cmp dx,.const/2
jl .next2stripes
inc bx
cmp bx,TEX_Y
jl .next_line
stosd
dec edi
loop @b
inc dx
cmp dx,.const/2
jl .next2stripes
inc bx
cmp bx,TEX_Y
jl .next_line
ret
 
blur_screen: ;blur n times ; blur or fire
blur_screen: ;blur n times ; blur or fire
;in - ecx times count
;.counter equ dword[esp-4]
.counter1 equ dword[esp-8]
if Ext>=SSE2
push ebp
mov ebp,esp
push dword 0x01010101
movss xmm5,[esp]
shufps xmm5,xmm5,0
push ebp
mov ebp,esp
push dword 0x01010101
movss xmm5,[esp]
shufps xmm5,xmm5,0
.again_blur:
push ecx
mov edi,[screen_ptr]
movzx ecx,word[size_x_var] ;SIZE_X*3/4
lea ecx,[ecx*3+1]
shr ecx,2
push ecx
mov edi,[screen_ptr]
movzx ecx,word[size_x_var] ;SIZE_X*3/4
lea ecx,[ecx*3+1]
shr ecx,2
 
; mov ecx,SIZE_X*3/4
xor eax,eax
rep stosd
xor eax,eax
rep stosd
if 1
movzx ebx,word[size_x_var]
movzx ecx,word[size_y_var]
sub ecx,3
imul ecx,ebx
lea ecx,[ecx*3]
shr ecx,4
lea ebx,[ebx*3]
movzx ebx,word[size_x_var]
movzx ecx,word[size_y_var]
sub ecx,3
imul ecx,ebx
lea ecx,[ecx*3]
shr ecx,4
lea ebx,[ebx*3]
; mov ecx,(SIZE_X*(SIZE_Y-3))*3/16
.blr:
@@:
push ecx
movups xmm0,[edi+ebx]
mov ecx,edi
sub ecx,ebx
movups xmm1,[ecx]
movups xmm2,[edi-3]
movups xmm3,[edi+3]
push ecx
movups xmm0,[edi+ebx]
mov ecx,edi
sub ecx,ebx
movups xmm1,[ecx]
movups xmm2,[edi-3]
movups xmm3,[edi+3]
 
pavgb xmm0,xmm1
pavgb xmm2,xmm3
pavgb xmm0,xmm2
pavgb xmm0,xmm1
pavgb xmm2,xmm3
pavgb xmm0,xmm2
 
psubusb xmm0,xmm5 ; importand if fire
psubusb xmm0,xmm5 ; importand if fire
 
movups [edi],xmm0
add edi,16
add esi,16
pop ecx
loop .blr
movups [edi],xmm0
add edi,16
add esi,16
pop ecx
loop .blr
end if
xor eax,eax
movzx ecx,word[size_x_var]
lea ecx,[ecx*3]
shr ecx,2
xor eax,eax
movzx ecx,word[size_x_var]
lea ecx,[ecx*3]
shr ecx,2
; mov ecx,SIZE_X*3/4
rep stosd
pop ecx
loop .again_blur
mov esp,ebp
pop ebp
rep stosd
pop ecx
loop .again_blur
mov esp,ebp
pop ebp
end if
 
if Ext=SSE
emms
push ebp
mov ebp,esp
push dword 0x01010101
push dword 0x01010101
movq mm4,[esp]
emms
push ebp
mov ebp,esp
push dword 0x01010101
push dword 0x01010101
movq mm4,[esp]
.again_blur:
push ecx
mov edi,[screen_ptr]
movzx ecx,word[size_x_var] ;SIZE_X*3/4
lea ecx,[ecx*3]
shr ecx,2
push ecx
mov edi,[screen_ptr]
movzx ecx,word[size_x_var] ;SIZE_X*3/4
lea ecx,[ecx*3]
shr ecx,2
; pxor mm5,mm5
xor eax,eax
rep stosd
movzx ebx,word[size_x_var]
movzx ecx,word[size_y_var]
sub ecx,3
imul ecx,ebx
lea ecx,[ecx*3]
shr ecx,3
lea ebx,[ebx*3]
xor eax,eax
rep stosd
movzx ebx,word[size_x_var]
movzx ecx,word[size_y_var]
sub ecx,3
imul ecx,ebx
lea ecx,[ecx*3]
shr ecx,3
lea ebx,[ebx*3]
; mov ecx,(SIZE_X*(SIZE_Y-3))*3/8
.blr:
@@:
push ecx
mov ecx,edi
sub ecx,ebx
movq mm0,[edi+ebx]
movq mm1,[ecx]
movq mm2,[edi-3]
movq mm3,[edi+3]
movq mm0,[edi+ebx]
movq mm1,[edi-ebx]
movq mm2,[edi-3]
movq mm3,[edi+3]
 
pavgb mm0,mm1
pavgb mm2,mm3
pavgb mm0,mm2
pavgb mm0,mm1
pavgb mm2,mm3
pavgb mm0,mm2
 
psubusb mm0,mm4 ; importand if fire
psubusb mm0,mm4 ; importand if fire
 
movq [edi],mm0
add edi,8
add esi,8
pop ecx
loop .blr
movq [edi],mm0
add edi,8
add esi,8
 
xor eax,eax
mov ecx,[size_x_var]
lea ecx,[ecx*3]
shr ecx,2
loop .blr
 
xor eax,eax
mov ecx,[size_x_var]
lea ecx,[ecx*3]
shr ecx,2
; SIZE_X*3/4
rep stosd
pop ecx
loop .again_blur
mov esp,ebp
pop ebp
rep stosd
pop ecx
loop .again_blur
mov esp,ebp
pop ebp
end if
 
if Ext=MMX
emms
push ebp
mov ebp,esp
push dword 0x0
push dword 0x01010101
emms
push ebp
mov ebp,esp
push dword 0x0
push dword 0x01010101
.again_blur:
push ecx
mov edi,[screen_ptr]
mov ecx,SIZE_X*3/4
pxor mm5,mm5
xor eax,eax
rep stosd
push ecx
mov edi,[screen_ptr]
mov ecx,SIZE_X*3/4
pxor mm5,mm5
xor eax,eax
rep stosd
 
mov ecx,(SIZE_X*(SIZE_Y-3))*3/4
mov ecx,(SIZE_X*(SIZE_Y-3))*3/4
.blr:
@@:
 
movd mm0,[edi+SIZE_X*3]
movd mm1,[edi-SIZE_X*3]
movd mm2,[edi-3]
movd mm3,[edi+3]
movd mm0,[edi+SIZE_X*3]
movd mm1,[edi-SIZE_X*3]
movd mm2,[edi-3]
movd mm3,[edi+3]
 
punpcklbw mm0,mm5
punpcklbw mm1,mm5
punpcklbw mm2,mm5
punpcklbw mm3,mm5
paddw mm0,mm1
paddw mm0,mm2
paddw mm0,mm3
psrlw mm0,2
punpcklbw mm0,mm5
punpcklbw mm1,mm5
punpcklbw mm2,mm5
punpcklbw mm3,mm5
paddw mm0,mm1
paddw mm0,mm2
paddw mm0,mm3
psrlw mm0,2
 
packuswb mm0,mm5
psubusb mm0,qword[esp] ; importand if fire
movd eax,mm0
stosd
packuswb mm0,mm5
psubusb mm0,qword[esp] ; importand if fire
movd eax,mm0
stosd
 
loop .blr
loop .blr
 
xor eax,eax
mov ecx,SIZE_X*3/4
rep stosd
pop ecx
loop .again_blur
mov esp,ebp
pop ebp
xor eax,eax
mov ecx,SIZE_X*3/4
rep stosd
pop ecx
loop .again_blur
mov esp,ebp
pop ebp
end if
if Ext=NON
.blur:
push ecx
xor ecx,ecx
push ecx
xor ecx,ecx
.next_col_coof:
xor esi,esi
xor eax,eax
xor ebx,ebx
mov edi,SIZE_X*SIZE_Y
xor esi,esi
xor eax,eax
xor ebx,ebx
mov edi,SIZE_X*SIZE_Y
.next:
mov ebp,esi
dec ebp
mov ebp,esi
dec ebp
 
cmp ebp,SIZE_X*SIZE_Y-1 ; clipping
jl @f
mov ebp,SIZE_X*SIZE_Y-1
cmp ebp,SIZE_X*SIZE_Y-1 ; clipping
jl @f
mov ebp,SIZE_X*SIZE_Y-1
@@:
or ebp,ebp
jg @f
xor ebp,ebp
or ebp,ebp
jg @f
xor ebp,ebp
@@:
lea edx,[ebp*3+screen]
mov al,byte[edx+ecx]
lea edx,[ebp*3+screen]
mov al,byte[edx+ecx]
 
mov ebp,esi
inc ebp
cmp ebp,SIZE_X*SIZE_Y-1 ; clipping
jl @f
mov ebp,SIZE_X*SIZE_Y-1
mov ebp,esi
inc ebp
cmp ebp,SIZE_X*SIZE_Y-1 ; clipping
jl @f
mov ebp,SIZE_X*SIZE_Y-1
@@:
or ebp,ebp
jg @f
xor ebp,ebp
or ebp,ebp
jg @f
xor ebp,ebp
@@:
lea edx,[ebp*3+screen]
mov bl,byte[edx+ecx]
add eax,ebx
lea edx,[ebp*3+screen]
mov bl,byte[edx+ecx]
add eax,ebx
 
mov ebp,esi
sub ebp,SIZE_X
cmp ebp,SIZE_X*SIZE_Y-1 ; clipping
jl @f
mov ebp,SIZE_X*SIZE_Y-1
mov ebp,esi
sub ebp,SIZE_X
cmp ebp,SIZE_X*SIZE_Y-1 ; clipping
jl @f
mov ebp,SIZE_X*SIZE_Y-1
@@:
or ebp,ebp
jg @f
xor ebp,ebp
or ebp,ebp
jg @f
xor ebp,ebp
@@:
lea edx,[ebp*3+screen]
mov bl,byte[edx+ecx]
add eax,ebx
lea edx,[ebp*3+screen]
mov bl,byte[edx+ecx]
add eax,ebx
 
mov ebp,esi
add ebp,SIZE_X
cmp ebp,SIZE_X*SIZE_Y-1 ; clipping
jl @f
mov ebp,SIZE_X*SIZE_Y-1
mov ebp,esi
add ebp,SIZE_X
cmp ebp,SIZE_X*SIZE_Y-1 ; clipping
jl @f
mov ebp,SIZE_X*SIZE_Y-1
@@:
or ebp,ebp
jg @f
xor ebp,ebp
or ebp,ebp
jg @f
xor ebp,ebp
@@:
lea edx,[ebp*3+screen]
mov bl,byte[edx+ecx]
add eax,ebx
lea edx,[ebp*3+screen]
mov bl,byte[edx+ecx]
add eax,ebx
 
shr eax,2
lea edx,[esi*3+screen]
or al,al
jz @f
dec al ; not importand if fire
mov byte[edx+ecx],al
shr eax,2
lea edx,[esi*3+screen]
or al,al
jz @f
dec al ; not importand if fire
mov byte[edx+ecx],al
@@:
 
inc esi
dec edi
jnz .next
inc esi
dec edi
jnz .next
 
inc ecx
cmp ecx,3
jne .next_col_coof
pop ecx
dec ecx
jnz .blur
inc ecx
cmp ecx,3
jne .next_col_coof
pop ecx
dec ecx
jnz .blur
end if
ret
 
mirror: ; mirror effect - loseless operation
mirror: ; mirror effect - loseless operation
; in ah - button id = 11, 12, 13
mov edi,[points_ptr] ; one real point - triple float
mov esi,[points_normals_ptr] ; one 3dvector - triple float dword x,y,z
fninit
movzx ecx,[points_count_var]
mov edi,[points_ptr] ; one real point - triple float
mov esi,[points_normals_ptr] ; one 3dvector - triple float dword x,y,z
fninit
mov ecx,[points_count_var]
 
cmp ah,11
je @f
cmp ah,12
je .yn
cmp ah,13
je .zn
cmp ah,11
je @f
cmp ah,12
je .yn
cmp ah,13
je .zn
 
@@: ; neg x
fld dword[edi] ;x
fchs
fstp dword[edi] ;x
fld dword[esi]
fchs
fstp dword[esi]
add edi,12
add esi,12
loop @b
ret
@@: ; neg x
fld dword[edi] ;x
fchs
fstp dword[edi] ;x
fld dword[esi]
fchs
fstp dword[esi]
add edi,12
add esi,12
loop @b
ret
.yn:
fld dword[edi+4] ;y
fchs
fstp dword[edi+4] ;y
fld dword[esi+4]
fchs
fstp dword[esi+4]
fld dword[edi+4] ;y
fchs
fstp dword[edi+4] ;y
fld dword[esi+4]
fchs
fstp dword[esi+4]
 
add edi,12
add esi,12
loop .yn
ret
add edi,12
add esi,12
loop .yn
ret
.zn:
fld dword[edi+8] ;z
fchs
fstp dword[edi+8] ;z
fld dword[esi+8]
fchs
fstp dword[esi+8]
fld dword[edi+8] ;z
fchs
fstp dword[edi+8] ;z
fld dword[esi+8]
fchs
fstp dword[esi+8]
 
add edi,12
add esi,12
loop .zn
add edi,12
add esi,12
loop .zn
ret
 
exchange: ; exchange some coords - loseless operation
mov edi,[points_ptr] ; one real point - triple float
mov esi,[points_normals_ptr] ; one 3dvector - triple float dword x,y,z
fninit ; exchange both points and normal vactors coords/coofics
movzx ecx,[points_count_var]
exchange: ; exchange some coords - loseless operation
mov edi,[points_ptr] ; one real point - triple float
mov esi,[points_normals_ptr] ; one 3dvector - triple float dword x,y,z
fninit ; exchange both points and normal vactors coords/coofics
mov ecx,[points_count_var]
 
cmp [xchg_flag],1
je @f
cmp [xchg_flag],2
je .zx
cmp [xchg_flag],3
je .yz
cmp [xchg_flag],1
je @f
cmp [xchg_flag],2
je .zx
cmp [xchg_flag],3
je .yz
@@:
fld dword[edi] ;x
fld dword[edi+4] ;y
fstp dword[edi] ;x
fstp dword[edi+4] ;y
fld dword[esi] ;x
fld dword[esi+4] ;y
fstp dword[esi] ;x
fstp dword[esi+4] ;y
fld dword[edi] ;x
fld dword[edi+4] ;y
fstp dword[edi] ;x
fstp dword[edi+4] ;y
fld dword[esi] ;x
fld dword[esi+4] ;y
fstp dword[esi] ;x
fstp dword[esi+4] ;y
 
add esi,12
add edi,12
loop @b
ret
add esi,12
add edi,12
loop @b
ret
.zx:
fld dword[edi] ;x
fld dword[edi+8] ;z
fstp dword[edi] ;x
fstp dword[edi+8] ;z
fld dword[esi] ;x
fld dword[esi+8] ;y
fstp dword[esi] ;x
fstp dword[esi+8] ;y
fld dword[edi] ;x
fld dword[edi+8] ;z
fstp dword[edi] ;x
fstp dword[edi+8] ;z
fld dword[esi] ;x
fld dword[esi+8] ;y
fstp dword[esi] ;x
fstp dword[esi+8] ;y
 
add esi,12
add edi,12
loop .zx
ret
add esi,12
add edi,12
loop .zx
ret
.yz:
fld dword[edi+8] ;z
fld dword[edi+4] ;y
fstp dword[edi+8] ;z
fstp dword[edi+4] ;y
fld dword[esi+8] ;x
fld dword[esi+4] ;y
fstp dword[esi+8] ;x
fstp dword[esi+4] ;y
fld dword[edi+8] ;z
fld dword[edi+4] ;y
fstp dword[edi+8] ;z
fstp dword[edi+4] ;y
fld dword[esi+8] ;x
fld dword[esi+4] ;y
fstp dword[esi+8] ;x
fstp dword[esi+4] ;y
 
add edi,12
add esi,12
loop .yz
add edi,12
add esi,12
loop .yz
ret
 
;#\\\\\\\\\\\\\\\\\\\\\\\\\comented///////////////////////////////
if 0
calc_attenuation_light: ;; calculate point to spot_light distance
calc_attenuation_light: ;; calculate point to spot_light distance
; spot light with attenuation ;; and vector, normalize vector,
;; calc dot_pr and unlinear color according
;; to dot_product, write to color buff
.distance equ dword[ebp-4] ;; color buff in bumpmap for save the mem
;; calc dot_pr and unlinear color according
;; to dot_product, write to color buff
.distance equ dword[ebp-4] ;; color buff in bumpmap for save the mem
.temp_col equ word[ebp-6]
.vector equ [ebp-20]
.spot_light_ptr equ dword [ebp-24]
mov ebp,esp
sub esp,24
mov edi,rotated_points_r ;points_rotated
mov edx,point_normals_rotated
mov ecx,bumpmap ; mem area with temp points color list
xor ax,ax ; counter
mov esi,spot_light_params
mov .spot_light_ptr,esi
mov ebp,esp
sub esp,24
mov edi,rotated_points_r ;points_rotated
mov edx,point_normals_rotated
mov ecx,bumpmap ; mem area with temp points color list
xor ax,ax ; counter
mov esi,spot_light_params
mov .spot_light_ptr,esi
.again_color:
push eax
lea ebx,.vector
mov esi,.spot_light_ptr ; calc vector fom light to every point
call make_vector_r
; ebx - ptr to result vector
fld dword [ebx]
fmul st, st
fld dword [ebx+4]
fmul st, st
fld dword [ebx+8]
fmul st, st
faddp st1, st
faddp st1, st
fsqrt
fstp .distance
push edi
mov edi,ebx
call normalize_vector
; edi - normalized distance vector
mov esi,edx
call dot_product ; esi first vector, edi second vector
; st0 - dot product
fabs ; why not ? - think about it
pop edi
fldz
fcomip st1
jbe @f ; st1>0
mov dword[ecx],0
mov word[ecx+4],0
add ecx,6
ffree st0
jmp .update_counters
push eax
lea ebx,.vector
mov esi,.spot_light_ptr ; calc vector fom light to every point
call make_vector_r
; ebx - ptr to result vector
fld dword [ebx]
fmul st, st
fld dword [ebx+4]
fmul st, st
fld dword [ebx+8]
fmul st, st
faddp st1, st
faddp st1, st
fsqrt
fstp .distance
push edi
mov edi,ebx
call normalize_vector
; edi - normalized distance vector
mov esi,edx
call dot_product ; esi first vector, edi second vector
; st0 - dot product
fabs ; why not ? - think about it
pop edi
fldz
fcomip st1
jbe @f ; st1>0
mov dword[ecx],0
mov word[ecx+4],0
add ecx,6
ffree st0
jmp .update_counters
@@:
; pop edi
 
; calc color(with atenuation), write to buff
; buff - color of points list
; color = ambient+cos(x)*diffuse+(cos(x)^n)*specular
; calc color(with atenuation), write to buff
; buff - color of points list
; color = ambient+cos(x)*diffuse+(cos(x)^n)*specular
 
push edx
push edi
push edx
push edi
 
push ecx
push ebp
push ecx
push ebp
 
; mov eax,spot_light_params
mov eax,.spot_light_ptr
movzx dx,byte[eax+15]
push dx ; shines
movzx dx,byte[eax+8] ; b
push dx ; orginal col
movzx dx,byte[eax+7] ; g
push dx
movzx dx,byte[eax+6] ; r
push dx
movzx dx,byte[eax+14] ; max col
push dx
movzx dx,byte[eax+13]
push dx
movzx dx,byte[eax+12]
push dx
movzx dx,byte[eax+11] ; min col
push dx
movzx dx,byte[eax+10]
push dx
movzx dx,byte[eax+9]
push dx
push eax ; dot pr. (in st0)
call calc_one_col
; eax - 0x00rrggbb
; brightness = 1 - (distance/light.fadezero)^fogness
; if brightness < 0, then brightness = 0
; attenuetion equation taken from 3dica tutorial - 1/d^2 isn't perfect
; color = color * brightness ; fogness = <0.5,2.0>
pop ebp
pop ecx
mov eax,.spot_light_ptr
movzx dx,byte[eax+15]
push dx ; shines
movzx dx,byte[eax+8] ; b
push dx ; orginal col
movzx dx,byte[eax+7] ; g
push dx
movzx dx,byte[eax+6] ; r
push dx
movzx dx,byte[eax+14] ; max col
push dx
movzx dx,byte[eax+13]
push dx
movzx dx,byte[eax+12]
push dx
movzx dx,byte[eax+11] ; min col
push dx
movzx dx,byte[eax+10]
push dx
movzx dx,byte[eax+9]
push dx
push eax ; dot pr. (in st0)
call calc_one_col
; eax - 0x00rrggbb
; brightness = 1 - (distance/light.fadezero)^fogness
; if brightness < 0, then brightness = 0
; attenuetion equation taken from 3dica tutorial - 1/d^2 isn't perfect
; color = color * brightness ; fogness = <0.5,2.0>
pop ebp
pop ecx
 
fld .distance
mov esi,.spot_light_ptr
fld .distance
mov esi,.spot_light_ptr
; fidiv word[spot_light_params+16] ; fadezero
fidiv word[esi+16] ; fadezero
fidiv word[esi+16] ; fadezero
; fmul st,st0 ; fogness = 2
fabs ; to be sure
fchs
fld1
faddp
fld1
fcomip st1
jnbe @f
ffree st0
fld1
fabs ; to be sure
fchs
fld1
faddp
fld1
fcomip st1
jnbe @f
ffree st0
fld1
@@:
fld st ; st - brightness
ror eax,16
movzx bx,al ; al - r
mov .temp_col,bx
fimul .temp_col
fistp word[ecx]
cmp word[ecx],0
jge @f
mov word[ecx],0
fld st ; st - brightness
ror eax,16
movzx bx,al ; al - r
mov .temp_col,bx
fimul .temp_col
fistp word[ecx]
cmp word[ecx],0
jge @f
mov word[ecx],0
@@:
; mov edx,dword[spot_light_params+12] ; max colors
mov edx,dword[esi+12] ; max colors
movzx bx,dl ; r max
cmp word[ecx],bx ; choose the brightest for r, g, b
jl @f
mov word[ecx],bx
mov edx,dword[esi+12] ; max colors
movzx bx,dl ; r max
cmp word[ecx],bx ; choose the brightest for r, g, b
jl @f
mov word[ecx],bx
@@:
 
add ecx,2
fld st
ror eax,16
movzx bx,ah ; g
mov .temp_col,bx
fimul .temp_col
fistp word[ecx]
cmp word[ecx],0
jg @f
mov word[ecx],0
add ecx,2
fld st
ror eax,16
movzx bx,ah ; g
mov .temp_col,bx
fimul .temp_col
fistp word[ecx]
cmp word[ecx],0
jg @f
mov word[ecx],0
@@:
movzx bx,dh ; g max
cmp word[ecx],bx
jle @f
mov word[ecx],bx
movzx bx,dh ; g max
cmp word[ecx],bx
jle @f
mov word[ecx],bx
@@:
 
add ecx,2
movzx bx,al ; b
mov .temp_col,bx
fimul .temp_col
fistp word[ecx]
cmp word[ecx],0
jg @f
mov word[ecx],0
add ecx,2
movzx bx,al ; b
mov .temp_col,bx
fimul .temp_col
fistp word[ecx]
cmp word[ecx],0
jg @f
mov word[ecx],0
@@:
shr edx,16
movzx bx,dl ; b max
cmp word[ecx],bx
jle @f
mov word[ecx],bx
shr edx,16
movzx bx,dl ; b max
cmp word[ecx],bx
jle @f
mov word[ecx],bx
@@:
add ecx,2
add ecx,2
;end if
; ror eax,16
; movzx bx,al
1268,23 → 1265,23
; mov word[ecx+4],ax
; add ecx,6
 
pop edi
pop edx
pop edi
pop edx
 
.update_counters:
add edx,12 ; normal_size
add edi,12 ;6 ; 3d point_coord_size
add edx,12 ; normal_size
add edi,12 ;6 ; 3d point_coord_size
 
pop eax
inc ax
cmp ax,[points_count_var]
jne .again_color
pop eax
inc ax
cmp ax,[points_count_var]
jne .again_color
 
add .spot_light_ptr,18
cmp .spot_light_ptr,spot_l_end
jl .again_color
add .spot_light_ptr,18
cmp .spot_light_ptr,spot_l_end
jl .again_color
 
mov esp,ebp
mov esp,ebp
ret
end if
;#\\\\\\\\\\\\\\\\\\\\\\\\\comented////////////////////////////////////
/programs/demos/3DS/DATA.INC
74,7 → 74,7
db 3
db 'shd. model'
db 12
dr_flag db 0
dr_flag db 0 ; 6 - dots
dd shd_f
 
db 4
457,8 → 457,8
scale dd ? ; help scale variable
edges_counter dd ?
;==
triangles_count_var dw ?
points_count_var dw ?
triangles_count_var dd ?
points_count_var dd ?
; triangles_ptr dd ?
; triangles_w_z_ptr dd ?
; triangles_normals_ptr dd ?
485,9 → 485,9
 
;===
 
point_index1 dw ? ;-\
point_index2 dw ? ; } don't change order
point_index3 dw ? ;-/
point_index1 dd ? ;-\
point_index2 dd ? ; } don't change order
point_index3 dd ? ;-/
temp_col dw ?
high dd ?
rand_seed dw ?
/programs/demos/3DS/History.txt
1,9 → 1,8
View3ds 0.068b - V 2018
1. Fixed SSE build.
-----------------------------------------------------------------------------------
 
View3ds 0.068 - XI 2016
1. Editing option - new 'editor' button.
2. For now I disable perspective correction, to make implemtation of editing option easier.
2. For now I disable perspective correction, to make implemtation
of editing option easier.
-----------------------------------------------------------------------------------
 
View3ds 0.067 - XI 2016
/programs/demos/3DS/README.TXT
1,6 → 1,15
View3ds 0.068b - tiny viewer to .3ds and .asc files with several graphics
effects implementation.
View3ds 0.069 - tiny viewer to .3ds and .asc files with several graphics
effects implementation.
 
 
What's new?
1. KPacked files support by Leency.
1. 32bit vertices indexes and ability to load whole RAM limited objects.
(Above 65535 vertices and triangles), (by me).
2. I switch off painters algotithm mode (depth sorting). In app impelementetion it has
limited vertices count and produce less quality image than Z buffer Catmull algo.
In addition this switch off reduces app size, (by me).
 
Buttons description:
1. rotary: choosing rotary axle: x, y, x+y.
2. shd. model: choosing shading model: flat, grd (smooth), env (spherical
11,8 → 20,7
mapping), grdl (Gouraud lines - edges only).
3. speed: idle, full.
4,5. zoom in, out: no comment.
6. catmull: on -> use z buffer ( z coordinate interpolation), off -> depth sorting, painters
alghoritm).Txgrd, 2tex and bumptex models only with catmull = on.
6. catmull: disabled
7. culling: backface culling on/ off.
8. rand. light: Randomize 3 unlinear lights( so called Phong's illumination).
9. Blur: blur N times; N=0,1,2,3,4,5
34,4 → 42,4
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 XI 2016
Maciej Guba V 2020
/programs/demos/3DS/VIEW3DS.ASM
1,11 → 1,11
 
; application : View3ds ver. 0.069 - tiny .3ds and .asc files viewer
; with a few graphics effects demonstration.
; with a few graphics effects demonstration.
; compiler : FASM
; system : KolibriOS
; author : Macgub aka Maciej Guba
; email : macgub3@wp.pl
; web : www.macgub.hekko.pl
; web : www.macgub.hekko.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.
20,436 → 20,436
 
 
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.
TEX_Y equ 512 ; height ; \/ /
TEX_SHIFT equ 9 ; texture width shifting ; __||__ /
TEXTURE_SIZE EQU (TEX_X * TEX_Y)-1 ; /| |
TEX equ SHIFTING ; TEX={SHIFTING | FLUENTLY} ; / \ /
FLUENTLY = 0 ; / | |
SHIFTING = 1 ; ------
CATMULL_SHIFT equ 8 ; | |
LIGHT_SIZE equ 22 ; | |
NON = 0 ; -/ \-
SIZE_Y equ 512 ; ///// I want definitely
TIMEOUT equ 10 ; ------ say:
ROUND equ 10 ; \ @ @/ keep smiling every
TEX_X equ 512 ; texture width ; \ ./ / day.
TEX_Y equ 512 ; height ; \/ /
TEX_SHIFT equ 9 ; texture width shifting ; __||__ /
TEXTURE_SIZE EQU (TEX_X * TEX_Y)-1 ; /| |
TEX equ SHIFTING ; TEX={SHIFTING | FLUENTLY} ; / \ /
FLUENTLY = 0 ; / | |
SHIFTING = 1 ; ------
CATMULL_SHIFT equ 8 ; | |
LIGHT_SIZE equ 22 ; | |
NON = 0 ; -/ \-
MMX = 1
SSE = 2
SSE2 = 3
Ext = SSE2 ;Ext={ NON | MMX | SSE | SSE2 }
Ext = SSE2 ;Ext={ NON | MMX | SSE | SSE2 }
 
; 0 for short names (Menuet-compatible), 1 for long names (Kolibri features)
USE_LFN = 1
 
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd MEM_END ; memory for app
dd MEM_END ; esp
dd I_Param ; I_Param
dd 0x0 ; I_Icon
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd MEM_END ; memory for app
dd MEM_END ; esp
dd I_Param ; I_Param
dd 0x0 ; I_Icon
 
START: ; start of execution
cld
; mov eax,14 ; window size according to cur res ...
; int 0x40
; sub eax,150 shl 16 + 150
mov eax, 500 shl 16 + 600 ; ... or set manually
mov [size_y_var],ax
shr ax,1
mov [vect_y],ax
START: ; start of execution
cld
; mov eax,14 ; window size according to cur res ...
; int 0x40
; sub eax,150 shl 16 + 150
mov eax, 500 shl 16 + 600 ; ... or set manually
mov [size_y_var],ax
shr ax,1
mov [vect_y],ax
 
 
shr ax,2
movzx ebx,ax
lea ebx,[ebx*3]
push ebx
fninit
fild dword[esp]
fstp [rsscale]
pop ebx
shr ax,2
movzx ebx,ax
lea ebx,[ebx*3]
push ebx
fninit
fild dword[esp]
fstp [rsscale]
pop ebx
 
shr eax,16
mov [size_x_var],ax
shr ax,1
mov [vect_x],ax
shr eax,16
mov [size_x_var],ax
shr ax,1
mov [vect_x],ax
 
mov eax, 20 shl 16 + 20
mov [x_start],eax
mov eax, 20 shl 16 + 20
mov [x_start],eax
 
 
call alloc_buffer_mem
call read_param
call read_from_disk ; read, if all is ok eax = 0
cmp eax,0
jne .gen
mov esi,[fptr]
cmp [esi],word 4D4Dh
jne .asc
call read_tp_variables ; init points and triangles count variables
cmp eax,0
je .gen
jmp .malloc
call alloc_buffer_mem
call read_param
call read_from_disk ; read, if all is ok eax = 0
cmp eax,0
jne .gen
mov esi,[fptr]
cmp [esi],word 4D4Dh
jne .asc
call read_tp_variables ; init points and triangles count variables
cmp eax,0
je .gen
jmp .malloc
.gen:
if USE_LFN
mov [triangles_count_var],1000
mov [points_count_var],1000
call alloc_mem_for_tp
mov [triangles_count_var],1000
mov [points_count_var],1000
call alloc_mem_for_tp
end if
call generate_object
jmp .opt
call generate_object
jmp .opt
.asc:
mov [triangles_count_var],10000
mov [points_count_var],10000
call alloc_mem_for_tp
call read_asc
jmp .opt
mov [triangles_count_var],10000
mov [points_count_var],10000
call alloc_mem_for_tp
call read_asc
jmp .opt
.malloc:
if USE_LFN
call alloc_mem_for_tp
call alloc_mem_for_tp
end if
call read_from_file
call read_from_file
.opt:
 
 
; call alloc_buffer_mem ; alloc memfor screnn and z buffer
; call alloc_buffer_mem ; alloc memfor screnn and z buffer
 
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>
call normalize_all_light_vectors
call init_triangles_normals2
call init_point_normals
call init_envmap2
call init_envmap_cub
call generate_texture2
call init_sincos_tab
call do_color_buffer ; intit color_map
mov edi,bumpmap
call calc_bumpmap
call calc_bumpmap_coords ; bump and texture mapping
call draw_window
; mov [draw_win_at_first],0
; mov eax,40 ; set events mask
; mov ebx,1100000000000000000000000100111b
; int 0x40
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>
call normalize_all_light_vectors
call init_triangles_normals2
call init_point_normals
call init_envmap2
call init_envmap_cub
call generate_texture2
call init_sincos_tab
call do_color_buffer ; intit color_map
mov edi,bumpmap
call calc_bumpmap
call calc_bumpmap_coords ; bump and texture mapping
call draw_window
; mov [draw_win_at_first],0
; mov eax,40 ; set events mask
; mov ebx,1100000000000000000000000100111b
; int 0x40
still:
cmp [edit_flag],1
jne @f
mov eax,40 ; set events mask
mov ebx,1100000000000000000000000100111b
jmp .int
cmp [edit_flag],1
jne @f
mov eax,40 ; set events mask
mov ebx,1100000000000000000000000100111b
jmp .int
@@:
mov eax,40 ; set events mask
mov ebx,111b
mov eax,40 ; set events mask
mov ebx,111b
.int:
int 0x40
int 0x40
 
mov eax,23
mov ebx,TIMEOUT
cmp [speed_flag],0
je .skip
mov eax,11
mov eax,23
mov ebx,TIMEOUT
cmp [speed_flag],0
je .skip
mov eax,11
.skip:
cmp [edit_flag],1
jne @f
mov eax,10
cmp [edit_flag],1
jne @f
mov eax,10
 
@@:
int 0x40
int 0x40
 
cmp eax,1 ; redraw request ?
je red
cmp eax,2 ; key in buffer ?
je key
cmp eax,3 ; button in buffer ?
je button
cmp eax,6
jne @f
cmp [edit_flag],1
jne @f
mov eax,37
mov ebx,3 ;read mouse state
int 0x40
mov [mouse_state],eax
call edit
cmp eax,1 ; redraw request ?
je red
cmp eax,2 ; key in buffer ?
je key
cmp eax,3 ; button in buffer ?
je button
cmp eax,6
jne @f
cmp [edit_flag],1
jne @f
mov eax,37
mov ebx,3 ;read mouse state
int 0x40
mov [mouse_state],eax
call edit
@@:
jmp noclose
jmp noclose
 
red: ; redraw
mov eax,9 ; get process info
mov ebx,procinfo
mov ecx,-1
int 0x40
mov eax,[procinfo+42] ; read params of window
sub eax,115
mov [size_x_var],ax
shr ax,1
mov [vect_x],ax
mov eax,9 ; get process info
mov ebx,procinfo
mov ecx,-1
int 0x40
mov eax,[procinfo+42] ; read params of window
sub eax,115
mov [size_x_var],ax
shr ax,1
mov [vect_x],ax
;
mov eax,[procinfo+46]
sub eax,30
mov [size_y_var],ax
shr ax,1
mov [vect_y],ax
mov eax,[procinfo+46]
sub eax,30
mov [size_y_var],ax
shr ax,1
mov [vect_y],ax
 
mov eax,[procinfo+34]
mov [x_start],ax
mov eax,[procinfo+38]
mov [y_start],ax
call alloc_buffer_mem ;realloc mem for scr & z buffs
call draw_window
mov eax,[procinfo+34]
mov [x_start],ax
mov eax,[procinfo+38]
mov [y_start],ax
call alloc_buffer_mem ;realloc mem for scr & z buffs
call draw_window
 
jmp noclose
jmp noclose
 
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
jmp noclose
key: ; key
mov eax,2 ; just read it and ignore
int 0x40
jmp noclose
 
button: ; button
mov eax,17 ; get id
int 0x40
button: ; button
mov eax,17 ; get id
int 0x40
 
cmp ah,1 ; button id=1 ?
jne @f
cmp ah,1 ; button id=1 ?
jne @f
 
mov eax,-1 ; close this program
int 0x40
mov eax,-1 ; close this program
int 0x40
@@:
cmp ah,30
jge add_vec_buttons
call update_flags ; update flags and write labels of flags
cmp ah,30
jge add_vec_buttons
call update_flags ; update flags and write labels of flags
 
; do other operations according to flag
cmp ah,3 ; ah = 3 -> shading model
jne .next_m6
cmp [dr_flag],2
jne @f
; call init_envmap2 ; <----! this don't works in env mode
; and more than ~18 kb objects
; call init_envmap_cub2
; do other operations according to flag
cmp ah,3 ; ah = 3 -> shading model
jne .next_m6
cmp [dr_flag],2
jne @f
; call init_envmap2 ; <----! this don't works in env mode
; and more than ~18 kb objects
; call init_envmap_cub2
@@:
cmp [dr_flag],4
jne @f
call generate_texture2
cmp [dr_flag],4
jne @f
call generate_texture2
 
@@:
.next_m6:
; ah = 5 -> scale-
cmp ah,5
jne @f
mov dword[scale],0.7
fninit
fld [rsscale]
fmul [scale]
fstp [rsscale]
; ah = 5 -> scale-
cmp ah,5
jne @f
mov dword[scale],0.7
fninit
fld [rsscale]
fmul [scale]
fstp [rsscale]
 
@@:
cmp ah,6 ; ah = 6 -> scale+
jne @f
mov dword[scale],1.3
fninit
fld [rsscale]
fmul [scale]
fstp [rsscale]
cmp ah,6 ; ah = 6 -> scale+
jne @f
mov dword[scale],1.3
fninit
fld [rsscale]
fmul [scale]
fstp [rsscale]
 
@@:
cmp ah,9 ; lights random ; 'flat' 0
jne .next_m5 ; 'grd ' 1
call make_random_lights ; 'env ' 2
call normalize_all_light_vectors ; 'bump' 3
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
cmp ah,9 ; lights random ; 'flat' 0
jne .next_m5 ; 'grd ' 1
call make_random_lights ; 'env ' 2
call normalize_all_light_vectors ; 'bump' 3
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
call init_envmap2 ; update env map if shading model = environment or bump
.next_m5:
cmp ah,11
je @f
cmp ah,12
je @f
cmp ah,13
jne .next_m4
cmp ah,11
je @f
cmp ah,12
je @f
cmp ah,13
jne .next_m4
@@:
call mirror
call mirror
.next_m4:
cmp ah,14
jne @f
call exchange
cmp ah,14
jne @f
call exchange
@@:
cmp ah,15
jne @f
cmp [emboss_flag],1
call init_envmap2
cmp ah,15
jne @f
cmp [emboss_flag],1
call init_envmap2
@@:
; cmp ah,17
; jne .next_m
; cmp [move_flag],2
; jne @f
; call draw_window ; redraw other labels to navigation buttons
; cmp ah,17
; jne .next_m
; cmp [move_flag],2
; jne @f
; call draw_window ; redraw other labels to navigation buttons
; @@:
; cmp [move_flag],0
; jne .next_m
; call draw_window ; redraw other labels to navigation buttons
; cmp [move_flag],0
; jne .next_m
; call draw_window ; redraw other labels to navigation buttons
.next_m:
cmp ah,18
jne .next_m2
cmp ah,18
jne .next_m2
if USE_LFN
mov [re_alloc_flag],1 ; reallocate memory
mov [triangles_count_var],1000
mov [points_count_var],1000
call alloc_mem_for_tp
mov [re_alloc_flag],0
mov [re_alloc_flag],1 ; reallocate memory
mov [triangles_count_var],1000
mov [points_count_var],1000
call alloc_mem_for_tp
mov [re_alloc_flag],0
end if
mov bl,[generator_flag]
or bl,bl
jz .next_m2
cmp bl,1
jne @f
call generate_object
jmp .calc_norm
mov bl,[generator_flag]
; or bl,bl
; jz .next_m2
cmp bl,1
jne @f
call generate_object
jmp .calc_norm
@@:
cmp bl,4
jg @f
movzx ax,bl ; ax < - object number
call generate_object2
jmp .calc_norm
cmp bl,4
jg @f
movzx ax,bl ; ax < - object number
call generate_object2
jmp .calc_norm
@@:
call generate_object3
call generate_object3
.calc_norm:
call optimize_object1
call init_triangles_normals2
call init_point_normals
call calc_bumpmap_coords ; bump and texture mapping
call optimize_object1
call init_triangles_normals2
call init_point_normals
call calc_bumpmap_coords ; bump and texture mapping
 
.next_m2:
cmp ah,19
je @f
cmp ah,20
jne .next_m3
cmp ah,19
je @f
cmp ah,20
jne .next_m3
@@:
mov edi,bumpmap
call calc_bumpmap
mov edi,bumpmap
call calc_bumpmap
.next_m3:
cmp ah,21 ; re map bumps, texture coordinates
jne @f
call calc_bumpmap_coords
cmp ah,21 ; re map bumps, texture coordinates
jne @f
call calc_bumpmap_coords
@@:
jmp noclose
jmp noclose
 
 
; there are 6 navigation buttons each
add_vec_buttons: ; can move: object, camera,.. list is open
;
cmp ah,30
jne .next
cmp [move_flag],0
jne @f
; cmp [move_flag],2
; je .set_light1
sub [vect_y],10
jmp .next
; there are 6 navigation buttons each
add_vec_buttons: ; can move: object, camera,.. list is open
;
cmp ah,30
jne .next
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
cmp [move_flag],1
jne @f
sub [yobs],10 ; observator = camera position
jmp .next
@@:
sub [sin_amplitude],10
sub [sin_amplitude],10
;--------------------------------------------------
; .set_light1: ; r -
; movzx ebx,[light_no_flag] ; * 22
; mov ecx,ebx
; shl ebx,4
; shl ecx,1
; add ebx,ecx
; shl ecx,1
; add ebx,ecx
; add ebx,lights+6 ; 6 -> light vector size
; .set_light1: ; r -
; movzx ebx,[light_no_flag] ; * 22
; mov ecx,ebx
; shl ebx,4
; shl ecx,1
; add ebx,ecx
; shl ecx,1
; add ebx,ecx
; add ebx,lights+6 ; 6 -> light vector size
;
; movzx ecx,[light_comp_flag]
; lea ecx,[ecx*3}
; add ebx,ecx ; ebx -> color to set
; movzx ecx,[light_comp_flag]
; lea ecx,[ecx*3}
; add ebx,ecx ; ebx -> color to set
 
;---------------------------------------------------
.next:
cmp ah,31
jne .next1
cmp [move_flag],1
je @f
add [vect_z],10
jmp .next1
cmp ah,31
jne .next1
cmp [move_flag],1
je @f
add [vect_z],10
jmp .next1
@@:
add [zobs],10 ; observator = camera position
add [zobs],10 ; observator = camera position
.next1:
cmp ah,33
jne .next2
cmp [move_flag],0
jne @f
sub [vect_x],10
jmp .next2
cmp ah,33
jne .next2
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
cmp [move_flag],1
jne @f
sub [xobs],10 ; observator = camera position
jmp .next2
@@:
fninit
fld [sin_frq]
fsub [sin_delta]
fstp [sin_frq]
fninit
fld [sin_frq]
fsub [sin_delta]
fstp [sin_frq]
.next2:
cmp ah,32
jne .next3
cmp [move_flag],0
jne @f
add [vect_x],10
jmp .next3
cmp ah,32
jne .next3
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
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]
fninit
fld [sin_frq] ; change wave effect frequency
fadd [sin_delta]
fstp [sin_frq]
.next3:
cmp ah,34
jne .next4
cmp [move_flag],1
je @f
cmp ah,34
jne .next4
cmp [move_flag],1
je @f
 
sub [vect_z],10
jmp .next4
sub [vect_z],10
jmp .next4
@@:
sub [zobs],10 ; observator = camera position
sub [zobs],10 ; observator = camera position
.next4:
cmp ah,35
jne .next5
cmp [move_flag],0
jne @f
; call add_vector
add [vect_y],10
jmp .next5
cmp ah,35
jne .next5
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
cmp [move_flag],1
jne @f
add [yobs],10 ; observator = camera position
jmp .next5
@@:
add [sin_amplitude],10
add [sin_amplitude],10
.next5:
 
 
456,53 → 456,53
 
noclose:
 
cmp [edit_flag],1
jz .end_rot
cmp [r_flag],2
jne .no_x
inc [angle_x]
and [angle_x],0xff
mov [angle_z],0
jmp .end_rot
cmp [edit_flag],1
jz .end_rot
cmp [r_flag],2
jne .no_x
inc [angle_x]
and [angle_x],0xff
mov [angle_z],0
jmp .end_rot
 
.no_x:
cmp [r_flag],0
jne .no_y
inc [angle_y]
and [angle_y],0xff
mov [angle_z],0
jmp .end_rot
cmp [r_flag],0
jne .no_y
inc [angle_y]
and [angle_y],0xff
mov [angle_z],0
jmp .end_rot
 
.no_y:
cmp [r_flag],1
jne .end_rot
mov cx,[angle_x]
inc cx
and cx,0xff
mov [angle_z],0
mov [angle_y],cx
mov [angle_x],cx
cmp [r_flag],1
jne .end_rot
mov cx,[angle_x]
inc cx
and cx,0xff
mov [angle_z],0
mov [angle_y],cx
mov [angle_x],cx
.end_rot:
 
mov esi,angle_x
mov edi,matrix
call make_rotation_matrix
mov esi,angle_x
mov edi,matrix
call make_rotation_matrix
RDTSC
push eax
mov esi,[points_normals_ptr]
mov edi,[points_normals_rot_ptr]
mov ebx,matrix
movzx ecx,[points_count_var]
call rotary
mov esi,[points_normals_ptr]
mov edi,[points_normals_rot_ptr]
mov ebx,matrix
mov ecx,[points_count_var]
call rotary
 
mov esi,matrix
call add_scale_to_matrix
mov esi,matrix
call add_scale_to_matrix
 
mov esi,[points_ptr]
mov edi,[points_rotated_ptr]
mov ebx,matrix
movzx ecx,[points_count_var]
call rotary
mov esi,[points_ptr]
mov edi,[points_rotated_ptr]
mov ebx,matrix
mov ecx,[points_count_var]
call rotary
 
; RDTSC
; pop ebx
510,45 → 510,45
; sub eax,41
; push eax
 
mov esi,[points_rotated_ptr]
mov edi,[points_translated_ptr]
movzx ecx,[points_count_var]
call translate_points
mov esi,[points_rotated_ptr]
mov edi,[points_translated_ptr]
mov ecx,[points_count_var]
call translate_points
 
; cmp [dr_flag],5
; jne @f
; call calc_attenuation_light
; cmp [dr_flag],5
; jne @f
; call calc_attenuation_light
; @@:
cmp [fire_flag],0
jne @f
call clrscr ; clear the screen
cmp [fire_flag],0
jne @f
call clrscr ; clear the screen
@@:
cmp [catmull_flag],1 ;non sort if Catmull = on
je .no_sort
call sort_triangles
; 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
je .non_f
cmp [dr_flag],6 ; non fill if dots
je .non_f
cmp [dr_flag],7 ; fill if 2tex and texgrd
jge @f
cmp [catmull_flag],0 ;non fill if Catmull = off
je .non_f
cmp [dr_flag],6 ; non fill if dots
je .non_f
@@:
call fill_Z_buffer ; make background
call fill_Z_buffer ; make background
.non_f:
; RDTSC
; push eax
cmp [dr_flag],6
jne @f
call draw_dots
jmp .blurrr
cmp [dr_flag],6
jne @f
call draw_dots
jmp .blurrr
@@:
call draw_triangles ; draw all triangles from the list
cmp [edit_flag],0
jz .no_edit
call clear_vertices_index
call draw_handlers
; call edit
call draw_triangles ; draw all triangles from the list
cmp [edit_flag],0
jz .no_edit
call clear_vertices_index
call draw_handlers
; call edit
 
 
 
558,33 → 558,33
.no_edit:
 
.blurrr:
cmp [sinus_flag],0
je @f
call do_sinus
cmp [sinus_flag],0
je @f
call do_sinus
@@:
cmp [fire_flag],0
jne @f
cmp [blur_flag],0
je .no_blur ; no blur, no fire
movzx ecx,[blur_flag]
call blur_screen ; blur and fire
jmp .no_blur
cmp [fire_flag],0
jne @f
cmp [blur_flag],0
je .no_blur ; no blur, no fire
movzx ecx,[blur_flag]
call blur_screen ; blur and fire
jmp .no_blur
@@:
cmp [emboss_flag],0
jne .emb ; if emboss=true -> no fire
movzx ecx,[fire_flag]
call blur_screen ; blur and fire
.no_blur: ; no blur, no fire
cmp [emboss_flag],0
je @f
cmp [emboss_flag],0
jne .emb ; if emboss=true -> no fire
movzx ecx,[fire_flag]
call blur_screen ; blur and fire
.no_blur: ; no blur, no fire
cmp [emboss_flag],0
je @f
.emb:
call do_emboss
call do_emboss
 
@@:
 
 
cmp [inc_bright_flag],0 ; increase brightness
je .no_inc_bright
cmp [inc_bright_flag],0 ; increase brightness
je .no_inc_bright
movzx ebx,[inc_bright_flag]
shl ebx,4
mov esi,[screen_ptr]
642,7 → 642,7
 
 
cmp [dec_bright_flag],0
je .no_dec_bright
je .no_dec_bright
movzx ebx,[dec_bright_flag]
shl ebx,4
mov esi,[screen_ptr]
671,7 → 671,7
if Ext=NON
lodsb
sub al,bl
jb @f
jb @f
mov [esi-1],al
loop .oop1
@@:
710,7 → 710,7
loop .dc
pop eax
 
mov eax,7 ; put image
mov eax,7 ; put image
mov ebx,[screen_ptr]
mov ecx,[size_y_var]
; mov ecx,SIZE_X shl 16 + SIZE_Y
729,15 → 729,15
xor edx,edx
int 40h
 
mov eax,4 ; function 4 : write text to window
mov eax,4 ; function 4 : write text to window
mov bx,[size_x_var]
add ebx,18
shl ebx,16
mov bx,[size_y_var]
sub bx,2 ; [x start] *65536 + [y start]
sub bx,2 ; [x start] *65536 + [y start]
mov ecx,0x00888888
mov edx,STRdata ; pointer to text beginning
mov esi,10 ; text length
mov edx,STRdata ; pointer to text beginning
mov esi,10 ; text length
int 40h
 
 
744,20 → 744,20
; addsubps xmm0,xmm0
 
 
jmp still
jmp still
 
;--------------------------------------------------------------------------------
;-------------------------PROCEDURES---------------------------------------------
;--------------------------------------------------------------------------------
include "TEX3.INC"
;include "TEX3.INC"
include "FLAT_CAT.INC"
include "TEX_CAT.INC"
include "BUMP_CAT.INC"
include "3DMATH.INC"
include "GRD_LINE.INC"
include "GRD3.INC"
include "FLAT3.INC"
include "BUMP3.INC"
;include "GRD3.INC"
;include "FLAT3.INC"
;include "BUMP3.INC"
include "B_PROCS.INC"
include "A_PROCS.INC"
include "GRD_CAT.INC"
774,162 → 774,162
shr ecx,1
rep stosd
ret
edit: ; mmx required, edit mesh by vertex
push ebp
mov ebp,esp
sub esp,128
edit: ; mmx required, edit mesh by vertex
push ebp
mov ebp,esp
sub esp,128
 
.y_coord equ ebp-2
.x_coord equ ebp-4
.points_translated equ ebp-10
.points equ ebp-22
.points_rotated equ ebp-34
.mx equ ebp-70
.y_coord equ ebp-2
.x_coord equ ebp-4
.points_translated equ ebp-10
.points equ ebp-22
.points_rotated equ ebp-34
.mx equ ebp-70
 
macro check_bar
{
movzx ebx,word[.x_coord]
movzx ecx,word[.y_coord]
movzx edx,word[size_x_var]
imul edx,ecx
add ebx,edx
movzx ebx,word[.x_coord]
movzx ecx,word[.y_coord]
movzx edx,word[size_x_var]
imul edx,ecx
add ebx,edx
 
lea ecx,[ebx*2]
lea ebx,[ebx*3]
add ebx,[screen_ptr]
mov ebx,[ebx]
and ebx,0x00ffffff
cmp ebx,0x00ff0000 ; is handle bar ?
lea ecx,[ebx*2]
lea ebx,[ebx*3]
add ebx,[screen_ptr]
mov ebx,[ebx]
and ebx,0x00ffffff
cmp ebx,0x00ff0000 ; is handle bar ?
}
 
emms
mov eax,37 ; get mouse state
mov ebx,1 ; x = 5, y = 25 - offsets
int 0x40
emms
mov eax,37 ; get mouse state
mov ebx,1 ; x = 5, y = 25 - offsets
int 0x40
 
mov ebx,[offset_y] ;5 shl 16 + 25
movd mm0,ebx
movd mm1,eax
movd mm3,[size_y_var]
pcmpgtw mm0,mm1
pcmpgtw mm3,mm1
pxor mm3,mm0
movd eax,mm3
mov cx,ax
shr eax,16
and ax,cx
or ax,ax
jz .no_edit
mov ebx,[offset_y] ;5 shl 16 + 25
movd mm0,ebx
movd mm1,eax
movd mm3,[size_y_var]
pcmpgtw mm0,mm1
pcmpgtw mm3,mm1
pxor mm3,mm0
movd eax,mm3
mov cx,ax
shr eax,16
and ax,cx
or ax,ax
jz .no_edit
 
 
movd mm0,ebx
psubw mm1,mm0
movd eax,mm1
movd mm0,ebx
psubw mm1,mm0
movd eax,mm1
 
; store both x and y coordinates
ror eax,16
; push eax
; sub esp,256
mov [.x_coord],eax
test word[mouse_state],100000000b
jz .not_press ; check if left mouse button press
ror eax,16
; push eax
; sub esp,256
mov [.x_coord],eax
test word[mouse_state],100000000b
jz .not_press ; check if left mouse button press
 
; left button pressed
; left button pressed
 
; macro check_bar
; {
; movzx ebx,word[.x_coord]
; movzx ecx,word[.y_coord]
; imul ebx,ecx
; lea ecx,[ebx*2]
; lea ebx,[ebx*3]
; add ebx,[screen_ptr]
; mov ebx,[ebx]
; and ebx,0x00ffffff
; cmp ebx,0x00ff0000 ; is handle bar ?
; movzx ebx,word[.x_coord]
; movzx ecx,word[.y_coord]
; imul ebx,ecx
; lea ecx,[ebx*2]
; lea ebx,[ebx*3]
; add ebx,[screen_ptr]
; mov ebx,[ebx]
; and ebx,0x00ffffff
; cmp ebx,0x00ff0000 ; is handle bar ?
; }
 
check_bar
jne .no_edit
add ecx,[vertices_index_ptr]
mov cx,word[ecx]
inc cx
check_bar
jne .no_edit
add ecx,[vertices_index_ptr]
mov cx,word[ecx]
inc cx
 
 
mov [vertex_edit_no],cx ;if vert_edit_no = 0, no vertex selected
mov [vertex_edit_no],cx ;if vert_edit_no = 0, no vertex selected
 
mov eax,dword[.x_coord]
mov dword[edit_end_x],eax
mov dword[edit_start_x],eax
jmp .end
mov eax,dword[.x_coord]
mov dword[edit_end_x],eax
mov dword[edit_start_x],eax
jmp .end
.not_press:
test byte[mouse_state],1b ; check if left button is held
jz .not_held
test byte[mouse_state],1b ; check if left button is held
jz .not_held
; check_bar
; jne .no_edit
; add ecx,[vertices_index_ptr]
; mov cx,[ecx]
; inc cx
cmp [vertex_edit_no],0 ; cx ; vertex number
je .end
push dword[.x_coord]
pop dword[edit_end_x]
jmp .end
; jne .no_edit
; add ecx,[vertices_index_ptr]
; mov cx,[ecx]
; inc cx
cmp [vertex_edit_no],0 ; cx ; vertex number
je .end
push dword[.x_coord]
pop dword[edit_end_x]
jmp .end
.not_held:
shr [mouse_state],16
test byte[mouse_state],1b ; test if left button released
jz .end
check_bar
jne .end
shr [mouse_state],16
test byte[mouse_state],1b ; test if left button released
jz .end
check_bar
jne .end
 
movzx esi,[vertex_edit_no]
dec esi
lea esi,[esi*3]
add esi,esi
add esi,[points_translated_ptr]
emms
movzx esi,[vertex_edit_no]
dec esi
lea esi,[esi*3]
add esi,esi
add esi,[points_translated_ptr]
emms
 
movd mm1,dword[esi]
paddw mm1,mm0
psubw mm1,qword[vect_x]
movd dword[esi],mm1
movd mm1,dword[esi]
paddw mm1,mm0
psubw mm1,qword[vect_x]
movd dword[esi],mm1
 
lea edi,[.points]
lea edi,[.points]
; detranslate
fninit
fild word[esi+4]
fstp dword[edi+8]
fild word[esi+2]
fisub word[offset_x]
fstp dword[edi+4]
fild word[esi]
fisub word[offset_y] ; proteza
fstp dword[edi]
fninit
fild word[esi+4]
fstp dword[edi+8]
fild word[esi+2]
fisub word[offset_x]
fstp dword[edi+4]
fild word[esi]
fisub word[offset_y] ; proteza
fstp dword[edi]
 
mov esi,matrix
lea edi,[.mx]
call reverse_mx_3x3
mov esi,matrix
lea edi,[.mx]
call reverse_mx_3x3
 
lea esi,[.points]
lea edi,[.points_rotated]
lea ebx,[.mx]
mov ecx,1
call rotary
lea esi,[.points]
lea edi,[.points_rotated]
lea ebx,[.mx]
mov ecx,1
call rotary
 
; inject into vertex list
movzx edi,[vertex_edit_no]
dec edi
lea edi,[edi*3]
shl edi,2
add edi,[points_ptr]
lea esi,[.points_rotated]
mov ecx,3
cld
rep movsd
; inject into vertex list
movzx edi,[vertex_edit_no]
dec edi
lea edi,[edi*3]
shl edi,2
add edi,[points_ptr]
lea esi,[.points_rotated]
mov ecx,3
cld
rep movsd
 
 
mov dword[edit_end_x],0
mov [vertex_edit_no],0
mov dword[edit_end_x],0
mov [vertex_edit_no],0
 
.no_edit:
.end:
1002,7 → 1002,7
add ecx,eax
add ecx,MEM_END
mov ebx,1
mov eax,64 ; allocate mem - resize app mem
mov eax,64 ; allocate mem - resize app mem
int 0x40
mov [screen_ptr],MEM_END
mov [Zbuffer_ptr],MEM_END
1013,84 → 1013,84
 
update_flags:
; updates flags and writing flag description
; in ah - button number
push ax
mov edi,menu
; in ah - button number
push ax
mov edi,menu
.ch_another:
cmp ah,byte[edi] ; ah = button id
jne @f
mov bl,byte[edi+11] ; max_flag + 1
cmp bl,255
je .no_write
inc byte[edi+12] ; flag
cmp byte[edi+12],bl
jne .write
mov byte[edi+12],0
jmp .write
cmp ah,byte[edi] ; ah = button id
jne @f
mov bl,byte[edi+11] ; max_flag + 1
cmp bl,255
je .no_write
inc byte[edi+12] ; flag
cmp byte[edi+12],bl
jne .write
mov byte[edi+12],0
jmp .write
@@:
add edi,17
cmp byte[edi],-1
jne .ch_another
add edi,17
cmp byte[edi],-1
jne .ch_another
.write:
; clreol {pascal never dies}
; * eax = 13 - function number
; * eax = 13 - function number
; * ebx = [coordinate on axis x]*65536 + [size on axis x]
; * ecx = [coordinate on axis y]*65536 + [size on axis y]
; * edx = color 0xRRGGBB or 0x80RRGGBB for gradient fill
 
mov eax,13 ; function 13 write rectangle
movzx ecx,byte[edi]
sub cl,2
lea ecx,[ecx*3]
lea ecx,[ecx*5]
add ecx,28
shl ecx,16
add ecx,14 ; ecx = [coord y]*65536 + [size y]
mov bx,[size_x_var]
shl ebx,16
add ebx,(12+70)*65536+25 ; [x start] *65536 + [size x]
mov edx,0x00000000 ; color 0x00RRGGBB
int 0x40
mov eax,13 ; function 13 write rectangle
movzx ecx,byte[edi]
sub cl,2
lea ecx,[ecx*3]
lea ecx,[ecx*5]
add ecx,28
shl ecx,16
add ecx,14 ; ecx = [coord y]*65536 + [size y]
mov bx,[size_x_var]
shl ebx,16
add ebx,(12+70)*65536+25 ; [x start] *65536 + [size x]
mov edx,0x00000000 ; color 0x00RRGGBB
int 0x40
 
mov eax,4 ; function 4 : write text to window
movzx ebx,byte[edi]
sub bl,2
lea ebx,[ebx*3]
lea ebx,[ebx*5]
mov cx,[size_x_var]
shl ecx,16
add ebx,ecx
add ebx,(12+70)*65536+28 ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
movzx edx,byte[edi+12] ; current flag
shl edx,2 ; * 4 = text length
add edx,dword[edi+13] ; pointer to text beginning
mov esi,4 ; text length -
; flag description 4 characters
int 0x40
mov eax,4 ; function 4 : write text to window
movzx ebx,byte[edi]
sub bl,2
lea ebx,[ebx*3]
lea ebx,[ebx*5]
mov cx,[size_x_var]
shl ecx,16
add ebx,ecx
add ebx,(12+70)*65536+28 ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
movzx edx,byte[edi+12] ; current flag
shl edx,2 ; * 4 = text length
add edx,dword[edi+13] ; pointer to text beginning
mov esi,4 ; text length -
; flag description 4 characters
int 0x40
 
.no_write:
pop ax
pop ax
ret
normalize_all_light_vectors:
mov edi,lights
mov edi,lights
@@:
call normalize_vector ; 3dmath.inc
add edi,LIGHT_SIZE
cmp edi,lightsend ;ecx
jl @b
call normalize_vector ; 3dmath.inc
add edi,LIGHT_SIZE
cmp edi,lightsend ;ecx
jl @b
ret
 
calc_bumpmap_coords: ; map texture, bump
calc_bumpmap_coords: ; map texture, bump
;macro .comment222
; ; planar mapping
; mov esi,points
; mov edi,tex_points
; ; planar mapping
; mov esi,points
; mov edi,tex_points
; @@:
; add esi,2
; movsd
; cmp dword[esi],dword -1
; jne @b
; add esi,2
; movsd
; cmp dword[esi],dword -1
; jne @b
 
; .Pi2 equ dword[ebp-4]
 
1099,32 → 1099,32
 
fninit
fldpi
fadd st,st
mov esi,[points_ptr]
mov edi,tex_points
movzx ecx,[points_count_var]
inc ecx
; cmp [map_tex_flag],1
; jne .cylindric
fadd st,st
mov esi,[points_ptr]
mov edi,tex_points
mov ecx,[points_count_var]
inc ecx
; cmp [map_tex_flag],1
; jne .cylindric
; spherical mapping around y axle
 
@@:
fld dword[esi] ; x coord
fld dword[esi+8] ; z coord
fpatan ; arctg(st1/st)
; fdiv .Pi2
fdiv st0,st1
fimul [tex_x_div2]
fiadd [tex_x_div2]
fistp word[edi] ; x
fld dword[esi] ; x coord
fld dword[esi+8] ; z coord
fpatan ; arctg(st1/st)
; fdiv .Pi2
fdiv st0,st1
fimul [tex_x_div2]
fiadd [tex_x_div2]
fistp word[edi] ; x
 
fld dword[esi+4] ; y coord
fld dword[esi] ; x
fmul st,st0
fld dword[esi+4] ; y
fmul st,st0
fld dword[esi+8] ; z
fmul st,st0
fld dword[esi+4] ; y coord
fld dword[esi] ; x
fmul st,st0
fld dword[esi+4] ; y
fmul st,st0
fld dword[esi+8] ; z
fmul st,st0
faddp
faddp
fsqrt
1139,31 → 1139,31
add edi,4
loop @b
ffree st0
; jmp .end_map
; jmp .end_map
; .cylindric:
; fld dword[esi] ; around y axle
; fld dword[esi+8]
; fpatan
; fdiv st0,st1
; fimul [tex_x_div2]
; fiadd [tex_x_div2]
; fistp word[edi]
; fld dword[esi] ; around y axle
; fld dword[esi+8]
; fpatan
; fdiv st0,st1
; fimul [tex_x_div2]
; fiadd [tex_x_div2]
; fistp word[edi]
 
; fld dword[esi+4]
; fimul [tex_y_div2]
; fiadd [tex_y_div2]
; fistp word[edi+2]
; fld dword[esi+4]
; fimul [tex_y_div2]
; fiadd [tex_y_div2]
; fistp word[edi+2]
 
; add esi,12
; add edi,4
; loop .cylindric
; ffree st0
;; mov esp,ebp
; add esi,12
; add edi,4
; loop .cylindric
; ffree st0
;; mov esp,ebp
; .end_map:
ret
 
 
init_envmap2: ; do env_map using many light sources
init_envmap2: ; do env_map using many light sources
;env_map 512 x 512 x 3 bytes
.temp equ word [ebp-2]
.nEy equ word [ebp-4]
1172,129 → 1172,129
.col_g equ [ebp-9]
.col_b equ [ebp-10]
 
push ebp
mov ebp,esp
sub esp,20
mov edi,envmap
fninit
push ebp
mov ebp,esp
sub esp,20
mov edi,envmap
fninit
 
mov dx,- TEX_Y / 2 ;256 ; dx - vertical coordinate = y
mov dx,- TEX_Y / 2 ;256 ; dx - vertical coordinate = y
.ie_ver:
mov cx,- TEX_X / 2 ;256 ; cx - horizontal coord = x
mov cx,- TEX_X / 2 ;256 ; cx - horizontal coord = x
.ie_hor:
xor ebx,ebx
mov dword .col_b, 0
xor ebx,ebx
mov dword .col_b, 0
.light:
lea esi,[lights+ebx]
fld dword[esi] ; light vector x cooficient
fimul [tex_x_div2] ;[i256]
mov .temp,cx
fisubr .temp
fistp .nEx
fld dword[esi+4] ; light vector y cooficient
fimul [tex_y_div2] ;[i256]
mov .temp,dx
fisubr .temp
fistp .nEy
lea esi,[lights+ebx]
fld dword[esi] ; light vector x cooficient
fimul [tex_x_div2] ;[i256]
mov .temp,cx
fisubr .temp
fistp .nEx
fld dword[esi+4] ; light vector y cooficient
fimul [tex_y_div2] ;[i256]
mov .temp,dx
fisubr .temp
fistp .nEy
 
cmp .nEx,- TEX_X / 2 ;256
jl .update_counters
cmp .nEy,- TEX_Y / 2 ;256
jl .update_counters
cmp .nEx,TEX_X / 2 ;256
jg .update_counters
cmp .nEy,TEX_Y / 2 ;256
jg .update_counters
cmp .nEx,- TEX_X / 2 ;256
jl .update_counters
cmp .nEy,- TEX_Y / 2 ;256
jl .update_counters
cmp .nEx,TEX_X / 2 ;256
jg .update_counters
cmp .nEy,TEX_Y / 2 ;256
jg .update_counters
 
fild .nEx
fmul st,st0
fild .nEy
fmul st,st0
faddp
fsqrt
fisubr [i256]
fmul [env_const]
fidiv [i256] ; st - 'virtual' dot product
fild .nEx
fmul st,st0
fild .nEy
fmul st,st0
faddp
fsqrt
fisubr [i256]
fmul [env_const]
fidiv [i256] ; st - 'virtual' dot product
 
fcom [dot_max]
fstsw ax
sahf
jb @f
ffree st
fld1 ;[dot_max]
fcom [dot_max]
fstsw ax
sahf
jb @f
ffree st
fld1 ;[dot_max]
@@:
fcom [dot_min]
fstsw ax
sahf
ja @f
ffree st
fldz ;[dot_min]
fcom [dot_min]
fstsw ax
sahf
ja @f
ffree st
fldz ;[dot_min]
@@:
push ebp
movzx ax,byte[esi+21]
push ax ;- shines
mov al,byte[esi+14] ; b orginal color
push ax
mov al,byte[esi+13] ; g
push ax
mov al,byte[esi+12] ; r
push ax
mov al,byte[esi+20] ; b max color
push ax
mov al,byte[esi+19] ; g
push ax
mov al,byte[esi+18] ; r
push ax
mov al,byte[esi+17] ; b min col
push ax
mov al,byte[esi+16] ; g
push ax
mov al,byte[esi+15] ; r
push ax
push eax ; earlier - dot pr
; fstp .dot_product
; push .dot_product
call calc_one_col
pop ebp
; eax-0x00rrggbb
cmp al,.col_b
jbe @f
mov .col_b,al
@@: ; eax - ggbb00rr
shr ax,8
cmp al,.col_g
jbe @f
mov .col_g,al
@@: ; eax - bb0000gg
shr eax,16
cmp al,.col_r
jbe @f
mov .col_r,al
push ebp
movzx ax,byte[esi+21]
push ax ;- shines
mov al,byte[esi+14] ; b orginal color
push ax
mov al,byte[esi+13] ; g
push ax
mov al,byte[esi+12] ; r
push ax
mov al,byte[esi+20] ; b max color
push ax
mov al,byte[esi+19] ; g
push ax
mov al,byte[esi+18] ; r
push ax
mov al,byte[esi+17] ; b min col
push ax
mov al,byte[esi+16] ; g
push ax
mov al,byte[esi+15] ; r
push ax
push eax ; earlier - dot pr
; fstp .dot_product
; push .dot_product
call calc_one_col
pop ebp
; eax-0x00rrggbb
cmp al,.col_b
jbe @f
mov .col_b,al
@@: ; eax - ggbb00rr
shr ax,8
cmp al,.col_g
jbe @f
mov .col_g,al
@@: ; eax - bb0000gg
shr eax,16
cmp al,.col_r
jbe @f
mov .col_r,al
@@:
.update_counters: ; update and jump when neccesery
add ebx,LIGHT_SIZE
cmp bx,[all_lights_size]
jl .light ; next_light
mov eax,dword .col_b
stosd
dec edi
.update_counters: ; update and jump when neccesery
add ebx,LIGHT_SIZE
cmp bx,[all_lights_size]
jl .light ; next_light
mov eax,dword .col_b
stosd
dec edi
 
inc cx
cmp cx,TEX_X / 2 ;256
jne .ie_hor
inc cx
cmp cx,TEX_X / 2 ;256
jne .ie_hor
 
inc dx
cmp dx,TEX_Y / 2 ;256
jne .ie_ver
inc dx
cmp dx,TEX_Y / 2 ;256
jne .ie_ver
 
mov esp,ebp
pop ebp
mov esp,ebp
pop ebp
ret
 
 
 
do_color_buffer: ; do color buffer for Gouraud, flat shading
;env_map 512 x 512 x 3 bytes ; many lights using
do_color_buffer: ; do color buffer for Gouraud, flat shading
;env_map 512 x 512 x 3 bytes ; many lights using
.temp equ word [ebp-2]
.nz equ dword [ebp-6] ; dword
.ny equ dword [ebp-10]
1303,613 → 1303,619
.col_g equ [ebp-17]
.col_b equ [ebp-18]
 
push ebp
mov ebp,esp
sub esp,20
mov edi,color_map
fninit
push ebp
mov ebp,esp
sub esp,20
mov edi,color_map
fninit
 
mov dx,- TEX_Y / 2 ;-256 ; dx - vertical coordinate = y
mov dx,- TEX_Y / 2 ;-256 ; dx - vertical coordinate = y
.ie_ver:
mov cx,- TEX_X / 2 ;256 ; cx - horizontal coord = x
mov cx,- TEX_X / 2 ;256 ; cx - horizontal coord = x
.ie_hor:
mov .temp,cx
fild .temp
fidiv [i256] ;st = Nx - vector normal x cooficient
fst .nx
fmul st,st0
mov .temp,dx
fild .temp
fidiv [i256] ; st = Ny - vector normal y coeficient
fst .ny
fmul st,st0
faddp
fld1
fchs
faddp
fabs
fsqrt
fchs
fstp .nz ; st - Nz - vect normal z coeficient
xor ebx,ebx
mov dword .col_b, 0
mov .temp,cx
fild .temp
fidiv [i256] ;st = Nx - vector normal x cooficient
fst .nx
fmul st,st0
mov .temp,dx
fild .temp
fidiv [i256] ; st = Ny - vector normal y coeficient
fst .ny
fmul st,st0
faddp
fld1
fchs
faddp
fabs
fsqrt
fchs
fstp .nz ; st - Nz - vect normal z coeficient
xor ebx,ebx
mov dword .col_b, 0
.light:
push edi ;env_map
lea esi,[lights+ebx]
lea edi,.nx
call dot_product
pop edi
fcom [dot_min]
fstsw ax
sahf
ja .env_ok1 ;compare with dot_max
ffree st
push edi ;env_map
lea esi,[lights+ebx]
lea edi,.nx
call dot_product
pop edi
fcom [dot_min]
fstsw ax
sahf
ja .env_ok1 ;compare with dot_max
ffree st
 
jmp .update_counters
jmp .update_counters
.env_ok1:
fcom [dot_max]
fstsw ax
sahf
jb .env_ok2 ; calc col
ffree st
jmp .update_counters
.env_ok2: ;calc col
push ebp
movzx ax,byte[esi+21]
push ax ;- shines
mov al,byte[esi+14] ; b orginal color
push ax
mov al,byte[esi+13] ; g
push ax
mov al,byte[esi+12] ; r
push ax
mov al,byte[esi+20] ; b max color
push ax
mov al,byte[esi+19] ; g
push ax
mov al,byte[esi+18] ; r
push ax
mov al,byte[esi+17] ; b min col
push ax
mov al,byte[esi+16] ; g
push ax
mov al,byte[esi+15] ; r
push ax
push eax ; earlier - dot pr
; fstp .dot_product
; push .dot_product
call calc_one_col
pop ebp
; eax-0x00rrggbb
cmp al,.col_b
jbe @f
mov .col_b,al
fcom [dot_max]
fstsw ax
sahf
jb .env_ok2 ; calc col
ffree st
jmp .update_counters
.env_ok2: ;calc col
push ebp
movzx ax,byte[esi+21]
push ax ;- shines
mov al,byte[esi+14] ; b orginal color
push ax
mov al,byte[esi+13] ; g
push ax
mov al,byte[esi+12] ; r
push ax
mov al,byte[esi+20] ; b max color
push ax
mov al,byte[esi+19] ; g
push ax
mov al,byte[esi+18] ; r
push ax
mov al,byte[esi+17] ; b min col
push ax
mov al,byte[esi+16] ; g
push ax
mov al,byte[esi+15] ; r
push ax
push eax ; earlier - dot pr
; fstp .dot_product
; push .dot_product
call calc_one_col
pop ebp
; eax-0x00rrggbb
cmp al,.col_b
jbe @f
mov .col_b,al
@@:
shr ax,8
cmp al,.col_g
jbe @f
mov .col_g,al
shr ax,8
cmp al,.col_g
jbe @f
mov .col_g,al
@@:
shr eax,16
cmp al,.col_r
jbe @f
mov .col_r,al
shr eax,16
cmp al,.col_r
jbe @f
mov .col_r,al
@@:
.update_counters: ; update and jump when neccesery
add ebx,LIGHT_SIZE
cmp bx,[all_lights_size]
jl .light ; next_light
mov eax,dword .col_b
stosd
dec edi
.update_counters: ; update and jump when neccesery
add ebx,LIGHT_SIZE
cmp bx,[all_lights_size]
jl .light ; next_light
mov eax,dword .col_b
stosd
dec edi
 
inc cx
cmp cx,TEX_X / 2 ;256
jne .ie_hor
inc cx
cmp cx,TEX_X / 2 ;256
jne .ie_hor
 
inc dx
cmp dx,TEX_X / 2 ;256
jne .ie_ver
inc dx
cmp dx,TEX_X / 2 ;256
jne .ie_ver
 
.env_done:
mov esp,ebp
pop ebp
mov esp,ebp
pop ebp
ret
if 0
init_triangles_normals:
mov ebx,triangles_normals
mov ebp,triangles
mov ebx,triangles_normals
mov ebp,triangles
@@:
push ebx
mov ebx,vectors
movzx esi,word[ebp] ; first point index
lea esi,[esi*3]
lea esi,[points+esi*2] ; esi - pointer to 1st 3d point
movzx edi,word[ebp+2] ; second point index
lea edi,[edi*3]
lea edi,[points+edi*2] ; edi - pointer to 2nd 3d point
call make_vector
add ebx,12
mov esi,edi
movzx edi,word[ebp+4] ; third point index
lea edi,[edi*3]
lea edi,[points+edi*2]
call make_vector
mov edi,ebx ; edi - pointer to 2nd vector
mov esi,ebx
sub esi,12 ; esi - pointer to 1st vector
pop ebx
call cross_product
mov edi,ebx
call normalize_vector
add ebp,6
add ebx,12
cmp dword[ebp],-1
jne @b
push ebx
mov ebx,vectors
mov esi,dword[ebp] ; first point index
lea esi,[esi*3]
lea esi,[points+esi*2] ; esi - pointer to 1st 3d point
movzx edi,dword[ebp+4] ; second point index
lea edi,[edi*3]
lea edi,[points+edi*2] ; edi - pointer to 2nd 3d point
call make_vector
add ebx,12
mov esi,edi
movzx edi,dword[ebp+8] ; third point index
lea edi,[edi*3]
lea edi,[points+edi*2]
call make_vector
mov edi,ebx ; edi - pointer to 2nd vector
mov esi,ebx
sub esi,12 ; esi - pointer to 1st vector
pop ebx
call cross_product
mov edi,ebx
call normalize_vector
add ebp,12
add ebx,12
cmp dword[ebp],-1
jne @b
ret
end if
 
init_point_normals:
.x equ dword [ebp-4]
.y equ dword [ebp-8]
.z equ dword [ebp-12]
.point_number equ word [ebp-26]
.hit_faces equ word [ebp-28]
.point_number equ dword [ebp-28]
.hit_faces equ dword [ebp-32]
 
fninit
mov ebp,esp
sub esp,28
mov edi,[points_normals_ptr]
mov .point_number,0
fninit
mov ebp,esp
sub esp,32
mov edi,[points_normals_ptr]
mov .point_number,0
.ipn_loop:
mov .hit_faces,0
mov .x,0
mov .y,0
mov .z,0
mov esi,[triangles_ptr]
xor ecx,ecx ; ecx - triangle number
mov .hit_faces,0
mov .x,0
mov .y,0
mov .z,0
mov esi,[triangles_ptr]
xor ecx,ecx ; ecx - triangle number
.ipn_check_face:
xor ebx,ebx ; ebx - 'position' in one triangle
xor ebx,ebx ; ebx - 'position' in one triangle
.ipn_check_vertex:
movzx eax,word[esi+ebx] ; eax - point_number
cmp ax,.point_number
jne .ipn_next_vertex
push esi
mov esi,ecx
lea esi,[esi*3]
; lea esi,[triangles_normals+esi*4]
shl esi,2
add esi,[triangles_normals_ptr]
mov eax,dword[esi+ebx] ; eax - point_number
cmp eax,.point_number
jne .ipn_next_vertex
push esi
mov esi,ecx
lea esi,[esi*3]
; lea esi,[triangles_normals+esi*4]
shl esi,2
add esi,[triangles_normals_ptr]
 
fld .x
fadd dword[esi+vec_x] ; vec_x this defined in 3dmath.asm - x cooficient
fstp .x ; of normal vactor
fld .y
fadd dword[esi+vec_y]
fstp .y
fld .z
fadd dword[esi+vec_z]
fstp .z
pop esi
inc .hit_faces
jmp .ipn_next_face
fld .x
fadd dword[esi+vec_x] ; vec_x this defined in 3dmath.asm - x cooficient
fstp .x ; of normal vactor
fld .y
fadd dword[esi+vec_y]
fstp .y
fld .z
fadd dword[esi+vec_z]
fstp .z
pop esi
inc .hit_faces
jmp .ipn_next_face
.ipn_next_vertex:
add ebx,2
cmp ebx,6
jne .ipn_check_vertex
add ebx,4
cmp ebx,12
jne .ipn_check_vertex
.ipn_next_face:
add esi,6
inc ecx
cmp cx,[triangles_count_var]
jne .ipn_check_face
add esi,12
inc ecx
cmp ecx,[triangles_count_var]
jne .ipn_check_face
 
fld .x
fidiv .hit_faces
fstp dword[edi+vec_x]
fld .y
fidiv .hit_faces
fstp dword[edi+vec_y]
fld .z
fidiv .hit_faces
fstp dword[edi+vec_z]
call normalize_vector
add edi,12 ;type vector 3d
inc .point_number
mov dx,.point_number
cmp dx,[points_count_var]
jne .ipn_loop
fld .x
fidiv .hit_faces
fstp dword[edi+vec_x]
fld .y
fidiv .hit_faces
fstp dword[edi+vec_y]
fld .z
fidiv .hit_faces
fstp dword[edi+vec_z]
call normalize_vector
add edi,12 ;type vector 3d
inc .point_number
mov edx,.point_number
cmp edx,[points_count_var]
jne .ipn_loop
 
mov esp,ebp
mov esp,ebp
ret
;===============================================================
 
init_triangles_normals2:
mov ebx,[triangles_normals_ptr]
mov ebp,[triangles_ptr]
mov ebx,[triangles_normals_ptr]
mov ebp,[triangles_ptr]
mov ecx,[triangles_count_var]
@@:
push ebx
mov ebx,vectors
movzx esi,word[ebp] ; first point index
lea esi,[esi*3]
; lea esi,[points+esi*2] ; esi - pointer to 1st 3d point
shl esi,2
add esi,[points_ptr]
movzx edi,word[ebp+2] ; first point index
lea edi,[edi*3]
shl edi,2
add edi,[points_ptr]
; movzx edi,word[ebp+2] ; second point index
; lea edi,[edi*3]
; lea edi,[points+edi*2] ; edi - pointer to 2nd 3d point
call make_vector_r
add ebx,12
mov esi,edi
movzx edi,word[ebp+4] ; third point index
lea edi,[edi*3]
shl edi,2
add edi,[points_ptr]
; lea edi,[points+edi*2]
call make_vector_r
mov edi,ebx ; edi - pointer to 2nd vector
mov esi,ebx
sub esi,12 ; esi - pointer to 1st vector
pop ebx
call cross_product
mov edi,ebx
call normalize_vector
add ebp,6
add ebx,12
cmp dword[ebp],-1
jne @b
push ecx
push ebx
mov ebx,vectors
mov esi,dword[ebp] ; first point index
lea esi,[esi*3]
; lea esi,[points+esi*2] ; esi - pointer to 1st 3d point
shl esi,2
add esi,[points_ptr]
mov edi,dword[ebp+4] ; first point index
lea edi,[edi*3]
shl edi,2
add edi,[points_ptr]
; movzx edi,word[ebp+2] ; second point index
; lea edi,[edi*3]
; lea edi,[points+edi*2] ; edi - pointer to 2nd 3d point
call make_vector_r
add ebx,12
mov esi,edi
mov edi,dword[ebp+8] ; third point index
lea edi,[edi*3]
shl edi,2
add edi,[points_ptr]
; lea edi,[points+edi*2]
call make_vector_r
mov edi,ebx ; edi - pointer to 2nd vector
mov esi,ebx
sub esi,12 ; esi - pointer to 1st vector
pop ebx
call cross_product
mov edi,ebx
call normalize_vector
add ebp,12
add ebx,12
pop ecx
sub ecx,1
jnz @b
; cmp dword[ebp],-1
; jne @b
ret
if 0 ; ind 64 but
 
 
;=================================================================
sort_triangles:
mov esi,[triangles_ptr]
mov edi,triangles_with_z
mov ebp,[points_translated_ptr]
mov esi,[triangles_ptr]
mov edi,triangles_with_z
mov ebp,[points_translated_ptr]
 
make_triangle_with_z: ;makes list with triangles and z position
movzx eax,word[esi]
lea eax,[eax*3]
movzx ecx,word[ebp+eax*2+4]
make_triangle_with_z: ;makes list with triangles and z position
movzx eax,word[esi]
lea eax,[eax*3]
movzx ecx,word[ebp+eax*2+4]
 
movzx eax,word[esi+2]
lea eax,[eax*3]
add cx,word[ebp+eax*2+4]
movzx eax,word[esi+2]
lea eax,[eax*3]
add cx,word[ebp+eax*2+4]
 
movzx eax,word[esi+4]
lea eax,[eax*3]
add cx,word[ebp+eax*2+4]
movzx eax,word[esi+4]
lea eax,[eax*3]
add cx,word[ebp+eax*2+4]
 
mov ax,cx
mov ax,cx
; cwd
; idiv word[i3]
movsd ; store vertex coordinates
movsw
stosw ; middle vertex coordinate 'z' in triangles_with_z list
cmp dword[esi],-1
jne make_triangle_with_z
movsd ; copy end mark
mov eax,4
lea edx,[edi-8-trizdd]
; lea edx, [edi-8]
; sub edx,[triangles_w_z_ptr]
mov [high],edx
call quicksort
mov eax,4
mov edx,[high]
call insertsort
jmp end_sort
; idiv word[i3]
movsd ; store vertex coordinates
movsw
stosw ; middle vertex coordinate 'z' in triangles_with_z list
cmp dword[esi],-1
jne make_triangle_with_z
movsd ; copy end mark
mov eax,4
lea edx,[edi-8-trizdd]
; lea edx, [edi-8]
; sub edx,[triangles_w_z_ptr]
mov [high],edx
call quicksort
mov eax,4
mov edx,[high]
call insertsort
jmp end_sort
 
quicksort:
mov ecx,edx
sub ecx,eax
cmp ecx,32
jc .exit
lea ecx,[eax+edx]
shr ecx,4
lea ecx,[ecx*8-4];
; mov edi,[triangles_w_z_ptr]
; mov ebx,[edi+eax]
; mov esi,[edi+ecx]
; mov edi,[edi+edx]
mov ebx,[trizdd+eax]; trizdd[l]
mov esi,[trizdd+ecx]; trizdd[i]
mov edi,[trizdd+edx]; trizdd[h]
cmp ebx,esi
jg @f ; direction NB! you need to negate these to invert the order
mov ecx,edx
sub ecx,eax
cmp ecx,32
jc .exit
lea ecx,[eax+edx]
shr ecx,4
lea ecx,[ecx*8-4];
; mov edi,[triangles_w_z_ptr]
; mov ebx,[edi+eax]
; mov esi,[edi+ecx]
; mov edi,[edi+edx]
mov ebx,[trizdd+eax]; trizdd[l]
mov esi,[trizdd+ecx]; trizdd[i]
mov edi,[trizdd+edx]; trizdd[h]
cmp ebx,esi
jg @f ; direction NB! you need to negate these to invert the order
if Ext=NON
mov [trizdd+eax],esi
mov [trizdd+ecx],ebx
mov ebx,[trizdd+eax-4]
mov esi,[trizdd+ecx-4]
mov [trizdd+eax-4],esi
mov [trizdd+ecx-4],ebx
mov ebx,[trizdd+eax]
mov esi,[trizdd+ecx]
mov [trizdd+eax],esi
mov [trizdd+ecx],ebx
mov ebx,[trizdd+eax-4]
mov esi,[trizdd+ecx-4]
mov [trizdd+eax-4],esi
mov [trizdd+ecx-4],ebx
mov ebx,[trizdd+eax]
mov esi,[trizdd+ecx]
else
; push ebx
; mov ebx,[triangles_w_z_ptr]
; movq mm0,[ebx+eax-4]
; movq mm1,[ebx+ecx-4]
; movq [ebx+ecx-4],mm0
; movq [ebx+eax-4],mm1
; pop ebx
movq mm0,[trizdq+eax-4]
movq mm1,[trizdq+ecx-4]
movq [trizdq+ecx-4],mm0
movq [trizdq+eax-4],mm1
xchg ebx,esi
; push ebx
; mov ebx,[triangles_w_z_ptr]
; movq mm0,[ebx+eax-4]
; movq mm1,[ebx+ecx-4]
; movq [ebx+ecx-4],mm0
; movq [ebx+eax-4],mm1
; pop ebx
movq mm0,[trizdq+eax-4]
movq mm1,[trizdq+ecx-4]
movq [trizdq+ecx-4],mm0
movq [trizdq+eax-4],mm1
xchg ebx,esi
end if
@@:
cmp ebx,edi
jg @f ; direction
cmp ebx,edi
jg @f ; direction
if Ext=NON
mov [trizdd+eax],edi
mov [trizdd+edx],ebx
mov ebx,[trizdd+eax-4]
mov edi,[trizdd+edx-4]
mov [trizdd+eax-4],edi
mov [trizdd+edx-4],ebx
mov ebx,[trizdd+eax]
mov edi,[trizdd+edx]
mov [trizdd+eax],edi
mov [trizdd+edx],ebx
mov ebx,[trizdd+eax-4]
mov edi,[trizdd+edx-4]
mov [trizdd+eax-4],edi
mov [trizdd+edx-4],ebx
mov ebx,[trizdd+eax]
mov edi,[trizdd+edx]
else
; push ebx
; mov ebx,[triangles_w_z_ptr]
; movq mm0,[ebx+eax-4]
; movq mm1,[ebx+edx-4]
; movq [ebx+edx-4],mm0
; movq [ebx+eax-4],mm1
movq mm0,[trizdq+eax-4]
movq mm1,[trizdq+edx-4]
movq [trizdq+edx-4],mm0
movq [trizdq+eax-4],mm1
; pop ebx
xchg ebx,edi
; push ebx
; mov ebx,[triangles_w_z_ptr]
; movq mm0,[ebx+eax-4]
; movq mm1,[ebx+edx-4]
; movq [ebx+edx-4],mm0
; movq [ebx+eax-4],mm1
movq mm0,[trizdq+eax-4]
movq mm1,[trizdq+edx-4]
movq [trizdq+edx-4],mm0
movq [trizdq+eax-4],mm1
; pop ebx
xchg ebx,edi
end if
@@:
cmp esi,edi
jg @f ; direction
cmp esi,edi
jg @f ; direction
if Ext=NON
mov [trizdd+ecx],edi
mov [trizdd+edx],esi
mov esi,[trizdd+ecx-4]
mov edi,[trizdd+edx-4]
mov [trizdd+ecx-4],edi
mov [trizdd+edx-4],esi
mov [trizdd+ecx],edi
mov [trizdd+edx],esi
mov esi,[trizdd+ecx-4]
mov edi,[trizdd+edx-4]
mov [trizdd+ecx-4],edi
mov [trizdd+edx-4],esi
else
; push ebx
; mov ebx,[triangles_w_z_ptr]
; movq mm0,[ebx+ecx-4]
; movq mm1,[ebx+edx-4]
; movq [ebx+edx-4],mm0
; movq [ebx+ecx-4],mm1
; pop ebx
; push ebx
; mov ebx,[triangles_w_z_ptr]
; movq mm0,[ebx+ecx-4]
; movq mm1,[ebx+edx-4]
; movq [ebx+edx-4],mm0
; movq [ebx+ecx-4],mm1
; pop ebx
 
movq mm0,[trizdq+ecx-4]
movq mm1,[trizdq+edx-4]
movq [trizdq+edx-4],mm0
movq [trizdq+ecx-4],mm1
xchg ebx,esi
movq mm0,[trizdq+ecx-4]
movq mm1,[trizdq+edx-4]
movq [trizdq+edx-4],mm0
movq [trizdq+ecx-4],mm1
xchg ebx,esi
end if
@@:
mov ebp,eax ; direction
add ebp,8 ; j
mov ebp,eax ; direction
add ebp,8 ; j
if Ext=NON
mov esi,[trizdd+ebp]
mov edi,[trizdd+ecx]
mov [trizdd+ebp],edi
mov [trizdd+ecx],esi
mov esi,[trizdd+ebp-4]
mov edi,[trizdd+ecx-4]
mov [trizdd+ecx-4],esi
mov [trizdd+ebp-4],edi
mov esi,[trizdd+ebp]
mov edi,[trizdd+ecx]
mov [trizdd+ebp],edi
mov [trizdd+ecx],esi
mov esi,[trizdd+ebp-4]
mov edi,[trizdd+ecx-4]
mov [trizdd+ecx-4],esi
mov [trizdd+ebp-4],edi
else
; push ebx
; mov ebx,[triangles_w_z_ptr]
; movq mm0,[ebx+ebp-4]
; movq mm1,[ebx+ecx-4]
; movq [ebx+ecx-4],mm0
; movq [ebx+ebp-4],mm1
; pop ebx
; push ebx
; mov ebx,[triangles_w_z_ptr]
; movq mm0,[ebx+ebp-4]
; movq mm1,[ebx+ecx-4]
; movq [ebx+ecx-4],mm0
; movq [ebx+ebp-4],mm1
; pop ebx
 
movq mm0,[trizdq+ebp-4]
movq mm1,[trizdq+ecx-4]
movq [trizdq+ecx-4],mm0
movq [trizdq+ebp-4],mm1
movq mm0,[trizdq+ebp-4]
movq mm1,[trizdq+ecx-4]
movq [trizdq+ecx-4],mm0
movq [trizdq+ebp-4],mm1
end if
mov ecx,edx ; i; direction
mov ebx,[trizdd+ebp]; trizdd[j]
; mov ebx, [triangles_w_z_ptr]
; add ebx, ebp
mov ecx,edx ; i; direction
mov ebx,[trizdd+ebp]; trizdd[j]
; mov ebx, [triangles_w_z_ptr]
; add ebx, ebp
 
; push eax
; mov eax, [triangles_w_z_ptr]
; push eax
; mov eax, [triangles_w_z_ptr]
.loop:
sub ecx,8 ; direction
cmp [trizdd+ecx],ebx
; cmp [eax+ecx],ebx
jl .loop ; direction
sub ecx,8 ; direction
cmp [trizdd+ecx],ebx
; cmp [eax+ecx],ebx
jl .loop ; direction
@@:
add ebp,8 ; direction
cmp [trizdd+ebp],ebx
; cmp [eax+ebp],ebx
jg @b ; direction
cmp ebp,ecx
jge @f ; direction
add ebp,8 ; direction
cmp [trizdd+ebp],ebx
; cmp [eax+ebp],ebx
jg @b ; direction
cmp ebp,ecx
jge @f ; direction
if Ext=NON
mov esi,[trizdd+ecx]
mov edi,[trizdd+ebp]
mov [trizdd+ebp],esi
mov [trizdd+ecx],edi
mov edi,[trizdd+ecx-4]
mov esi,[trizdd+ebp-4]
mov [trizdd+ebp-4],edi
mov [trizdd+ecx-4],esi
mov esi,[trizdd+ecx]
mov edi,[trizdd+ebp]
mov [trizdd+ebp],esi
mov [trizdd+ecx],edi
mov edi,[trizdd+ecx-4]
mov esi,[trizdd+ebp-4]
mov [trizdd+ebp-4],edi
mov [trizdd+ecx-4],esi
else
; movq mm0,[eax+ecx-4]
; movq mm1,[eax+ebp-4]
; movq [eax+ebp-4],mm0
; movq [eax+ecx-4],mm1
movq mm0,[trizdq+ecx-4]
movq mm1,[trizdq+ebp-4]
movq [trizdq+ebp-4],mm0
movq [trizdq+ecx-4],mm1
; movq mm0,[eax+ecx-4]
; movq mm1,[eax+ebp-4]
; movq [eax+ebp-4],mm0
; movq [eax+ecx-4],mm1
movq mm0,[trizdq+ecx-4]
movq mm1,[trizdq+ebp-4]
movq [trizdq+ebp-4],mm0
movq [trizdq+ecx-4],mm1
end if
jmp .loop
; pop eax
jmp .loop
; pop eax
@@:
if Ext=NON
mov esi,[trizdd+ecx]
mov edi,[trizdd+eax+8]
mov [trizdd+eax+8],esi
mov [trizdd+ecx],edi
mov edi,[trizdd+ecx-4]
mov esi,[trizdd+eax+4]
mov [trizdd+eax+4],edi
mov [trizdd+ecx-4],esi
mov esi,[trizdd+ecx]
mov edi,[trizdd+eax+8]
mov [trizdd+eax+8],esi
mov [trizdd+ecx],edi
mov edi,[trizdd+ecx-4]
mov esi,[trizdd+eax+4]
mov [trizdd+eax+4],edi
mov [trizdd+ecx-4],esi
else
; push edx
; mov edx,[triangles_w_z_ptr]
; movq mm0,[edx+ecx-4]
; movq mm1,[edx+eax+4]; dir
; movq [edx+eax+4],mm0; dir
; movq [edx+ecx-4],mm1
; pop edx
; push edx
; mov edx,[triangles_w_z_ptr]
; movq mm0,[edx+ecx-4]
; movq mm1,[edx+eax+4]; dir
; movq [edx+eax+4],mm0; dir
; movq [edx+ecx-4],mm1
; pop edx
 
movq mm0,[trizdq+ecx-4]
movq mm1,[trizdq+eax+4]; dir
movq [trizdq+eax+4],mm0; dir
movq [trizdq+ecx-4],mm1
movq mm0,[trizdq+ecx-4]
movq mm1,[trizdq+eax+4]; dir
movq [trizdq+eax+4],mm0; dir
movq [trizdq+ecx-4],mm1
end if
add ecx,8
push ecx edx
mov edx,ebp
call quicksort
pop edx eax
call quicksort
add ecx,8
push ecx edx
mov edx,ebp
call quicksort
pop edx eax
call quicksort
.exit:
ret
insertsort:
mov esi,eax
mov esi,eax
.start:
add esi,8
cmp esi,edx
ja .exit
mov ebx,[trizdd+esi]
; mov ebx,[triangles_w_z_ptr]
; add ebx,esi
add esi,8
cmp esi,edx
ja .exit
mov ebx,[trizdd+esi]
; mov ebx,[triangles_w_z_ptr]
; add ebx,esi
if Ext=NON
mov ecx,[trizdd+esi-4]
mov ecx,[trizdd+esi-4]
else
; push ebx
; mov ebx,[triangles_w_z_ptr]
; movq mm1,[ebx+esi-4]
movq mm1,[trizdq+esi-4]
; pop ebx
; push ebx
; mov ebx,[triangles_w_z_ptr]
; movq mm1,[ebx+esi-4]
movq mm1,[trizdq+esi-4]
; pop ebx
end if
mov edi,esi
mov edi,esi
@@:
cmp edi,eax
jna @f
; push eax
; mov eax,[triangles_w_z_ptr]
; cmp [eax+edi-8],ebx
; pop eax
cmp edi,eax
jna @f
; push eax
; mov eax,[triangles_w_z_ptr]
; cmp [eax+edi-8],ebx
; pop eax
cmp [trizdd+edi-8],ebx
jg @f ; direction
jg @f ; direction
if Ext=NON
mov ebp,[trizdd+edi-8]
mov [trizdd+edi],ebp
mov ebp,[trizdd+edi-12]
mov [trizdd+edi-4],ebp
mov ebp,[trizdd+edi-8]
mov [trizdd+edi],ebp
mov ebp,[trizdd+edi-12]
mov [trizdd+edi-4],ebp
else
; push eax
; mov eax,[triangles_w_z_ptr]
; movq mm0,[eax+edi-12]
; movq [eax+edi-4],mm0
movq mm0,[trizdq+edi-12]
movq [trizdq+edi-4],mm0
; pop eax
; push eax
; mov eax,[triangles_w_z_ptr]
; movq mm0,[eax+edi-12]
; movq [eax+edi-4],mm0
movq mm0,[trizdq+edi-12]
movq [trizdq+edi-4],mm0
; pop eax
end if
sub edi,8
jmp @b
sub edi,8
jmp @b
@@:
if Ext=NON
mov [trizdd+edi],ebx
mov [trizdd+edi-4],ecx
mov [trizdd+edi],ebx
mov [trizdd+edi-4],ecx
else
; push eax
; mov eax,[triangles_w_z_ptr]
; movq [eax+edi-4],mm1
movq [trizdq+edi-4],mm1
; pop eax
; push eax
; mov eax,[triangles_w_z_ptr]
; movq [eax+edi-4],mm1
movq [trizdq+edi-4],mm1
; pop eax
end if
jmp .start
jmp .start
.exit:
ret
end_sort:
; translate triangles_with_z to sorted_triangles
mov esi,triangles_with_z
; mov esi,[triangles_w_z_ptr]
; mov edi,sorted_triangles
mov edi,[triangles_ptr]
mov esi,triangles_with_z
; mov esi,[triangles_w_z_ptr]
; mov edi,sorted_triangles
mov edi,[triangles_ptr]
again_copy:
if Ext=NON
movsd
movsw
add esi,2
movsd
movsw
add esi,2
else
movq mm0,[esi]
movq [edi],mm0
add esi,8
add edi,6
movq mm0,[esi]
movq [edi],mm0
add esi,8
add edi,6
end if
cmp dword[esi],-1
jne again_copy
cmp dword[esi],-1
jne again_copy
; if Ext=MMX
; emms
; emms
; end if
movsd ; copy end mark too
movsd ; copy end mark too
ret
 
end if ; 64 ind
clrscr:
mov edi,[screen_ptr]
movzx ecx,word[size_x_var]
movzx eax,word[size_y_var]
imul ecx,eax
lea ecx,[ecx*3]
shr ecx,2
xor eax,eax
mov edi,[screen_ptr]
movzx ecx,word[size_x_var]
movzx eax,word[size_y_var]
imul ecx,eax
lea ecx,[ecx*3]
shr ecx,2
xor eax,eax
if Ext=NON
rep stosd
rep stosd
else if Ext = MMX
pxor mm0,mm0
pxor mm0,mm0
@@:
movq [edi+00],mm0
movq [edi+08],mm0
movq [edi+16],mm0
movq [edi+24],mm0
add edi,32
sub ecx,8
jnc @b
movq [edi+00],mm0
movq [edi+08],mm0
movq [edi+16],mm0
movq [edi+24],mm0
add edi,32
sub ecx,8
jnc @b
else
push ecx
mov ecx,edi
and ecx,0x0000000f
rep stosb
pop ecx
and ecx,0xfffffff0
xorps xmm0,xmm0
push ecx
mov ecx,edi
and ecx,0x0000000f
rep stosb
pop ecx
and ecx,0xfffffff0
xorps xmm0,xmm0
@@:
movaps [edi],xmm0
movaps [edi+16],xmm0
movaps [edi+32],xmm0
movaps [edi+48],xmm0
add edi,64
sub ecx,16
jnz @b
movaps [edi],xmm0
movaps [edi+16],xmm0
movaps [edi+32],xmm0
movaps [edi+48],xmm0
add edi,64
sub ecx,16
jnz @b
end if
 
ret
1917,1011 → 1923,1014
 
draw_triangles:
 
emms
emms
; update translated list MMX required
cmp [vertex_edit_no],0
je @f
movzx eax,[vertex_edit_no]
dec eax
movd mm0,[edit_end_x]
psubw mm0,[edit_start_x]
lea eax,[eax*3]
add eax,eax
add eax,[points_translated_ptr]
movd mm1,dword[eax]
paddw mm1,mm0
movd dword[eax],mm1
cmp [vertex_edit_no],0
je @f
movzx eax,[vertex_edit_no]
dec eax
movd mm0,[edit_end_x]
psubw mm0,[edit_start_x]
lea eax,[eax*3]
add eax,eax
add eax,[points_translated_ptr]
movd mm1,dword[eax]
paddw mm1,mm0
movd dword[eax],mm1
@@:
 
 
 
mov esi,[triangles_ptr]
mov [edges_counter],0
mov esi,[triangles_ptr]
mov [edges_counter],0
mov ecx,[triangles_count_var]
.again_dts:
mov ebp,[points_translated_ptr]
if Ext=NON
movzx eax,word[esi]
mov [point_index1],ax
lea eax,[eax*3]
add eax,eax
push ebp
add ebp,eax
mov eax,[ebp]
cmp [vertex_edit_no],0
jne @f
push ecx
mov ebp,[points_translated_ptr]
if Ext >= SSE2
mov eax,dword[esi]
mov [point_index1],eax
lea eax,[eax*3]
add eax,eax
push ebp
add ebp,eax
mov eax,[ebp]
; cmp [vertex_edit_no],0
; jne @f
;
; @@:
mov dword[xx1],eax
mov eax,[ebp+4]
mov [zz1],ax
 
@@:
mov dword[xx1],eax
mov eax,[ebp+4]
mov [zz1],ax
pop ebp
pop ebp
 
 
movzx eax,word[esi+2]
mov [point_index2],ax
lea eax,[eax*3]
add eax,eax
push ebp
add ebp,eax
mov eax,[ebp]
mov dword[xx2],eax
mov eax,[ebp+4]
mov [zz2],ax
pop ebp
mov eax,dword[esi+4]
mov [point_index2],eax
lea eax,[eax*3]
add eax,eax
push ebp
add ebp,eax
mov eax,[ebp]
mov dword[xx2],eax
mov eax,[ebp+4]
mov [zz2],ax
pop ebp
 
 
movzx eax,word[esi+4] ; xyz3 = [ebp+[esi+4]*6]
mov [point_index3],ax
lea eax,[eax*3]
add eax,eax
; push ebp
add ebp,eax
mov eax,[ebp]
mov dword[xx3],eax
mov eax,[ebp+4]
mov [zz3],ax
mov eax,dword[esi+8] ; xyz3 = [ebp+[esi+4]*6]
mov [point_index3],eax
lea eax,[eax*3]
add eax,eax
; push ebp
add ebp,eax
mov eax,[ebp]
mov dword[xx3],eax
mov eax,[ebp+4]
mov [zz3],ax
else
mov eax,dword[esi] ; don't know MMX
mov dword[point_index1],eax
; shr eax,16
; mov [point_index2],ax
mov ax,word[esi+4]
mov [point_index3],ax
movq mm0,[esi]
pmullw mm0,qword[const6]
movd eax,mm0
psrlq mm0,16
movd ebx,mm0
psrlq mm0,16
movd ecx,mm0
and eax,0FFFFh
and ebx,0FFFFh
and ecx,0FFFFh
movq mm0,[ebp+eax]
movq mm1,[ebp+ebx]
movq mm2,[ebp+ecx]
movq qword[xx1],mm0
movq qword[xx2],mm1
movq qword[xx3],mm2
; emms
movq mm0,[esi] ; don't know MMX
mov qword[point_index1],mm0
; shr eax,16
; mov [point_index2],ax
mov eax,dword[esi+8]
mov [point_index3],eax
movdqu xmm0,[esi]
paddd xmm0,xmm0
movdqa xmm1,xmm0
paddd xmm0,xmm0
paddd xmm0,xmm1
movd eax,xmm0
psrldq xmm0,4
movd ebx,xmm0
psrldq xmm0,4
movd ecx,xmm0
and eax,0FFFFh
and ebx,0FFFFh
and ecx,0FFFFh
movq mm0,[ebp+eax]
movq mm1,[ebp+ebx]
movq mm2,[ebp+ecx]
movq qword[xx1],mm0
movq qword[xx2],mm1
movq qword[xx3],mm2
; emms
end if ; *********************************
if 0
cmp [vertex_edit_no],0
jne .no_edit
mov ax,[vertex_edit_no]
dec ax
cmp ax,[point_index1]
jne @f
movd mm0,[edit_start_x]
psubw mm0,[edit_end_x]
movd mm1,dword[xx1]
paddw mm1,mm0
movd dword[xx1],mm1
jmp .no_edit
cmp [vertex_edit_no],0
jne .no_edit
mov ax,[vertex_edit_no]
dec ax
cmp ax,[point_index1]
jne @f
movd mm0,[edit_start_x]
psubw mm0,[edit_end_x]
movd mm1,dword[xx1]
paddw mm1,mm0
movd dword[xx1],mm1
jmp .no_edit
@@:
 
cmp ax,[point_index2]
jne @f
movd mm0,[edit_start_x]
psubw mm0,[edit_end_x]
movd mm1,dword[xx2]
paddw mm1,mm0
movd dword[xx2],mm1
jmp .no_edit
cmp ax,[point_index2]
jne @f
movd mm0,[edit_start_x]
psubw mm0,[edit_end_x]
movd mm1,dword[xx2]
paddw mm1,mm0
movd dword[xx2],mm1
jmp .no_edit
@@:
 
cmp ax,[point_index3]
jne @f
movd mm0,[edit_start_x]
psubw mm0,[edit_end_x]
movd mm1,dword[xx3]
paddw mm1,mm0
movd dword[xx3],mm1
jmp .no_edit
cmp ax,[point_index3]
jne @f
movd mm0,[edit_start_x]
psubw mm0,[edit_end_x]
movd mm1,dword[xx3]
paddw mm1,mm0
movd dword[xx3],mm1
jmp .no_edit
@@:
 
 
.no_edit:
end if
push esi ;
fninit ; DO culling AT FIRST
cmp [culling_flag],1 ; (if culling_flag = 1)
jne .no_culling
mov esi,point_index1 ; *********************************
mov ecx,3 ;
push esi ;
fninit ; DO culling AT FIRST
cmp [culling_flag],1 ; (if culling_flag = 1)
jne .no_culling
mov esi,point_index1 ; *********************************
mov ecx,3 ;
@@:
movzx eax,word[esi]
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr]
; 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
loop @b
jmp .end_draw ; non visable
mov eax,dword[esi]
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr]
; 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
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
cmp [dr_flag],2
je .env_mapping
cmp [dr_flag],3
je .bump_mapping
cmp [dr_flag],4
je .tex_mapping
cmp [dr_flag],5
je .rainbow
cmp [dr_flag],7
je .grd_tex
cmp [dr_flag],8
je .two_tex
cmp [dr_flag],9
je .bump_tex
cmp [dr_flag],10
je .cubic_env_mapping
cmp [dr_flag],11
je .draw_smooth_line
; ****************
mov esi,point_index3 ; do Gouraud shading
mov ecx,3
cmp [dr_flag],0 ; draw type flag
je .flat_draw
cmp [dr_flag],2
je .env_mapping
cmp [dr_flag],3
je .bump_mapping
cmp [dr_flag],4
je .tex_mapping
cmp [dr_flag],5
je .rainbow
cmp [dr_flag],7
je .grd_tex
cmp [dr_flag],8
je .two_tex
cmp [dr_flag],9
je .bump_tex
cmp [dr_flag],10
je .cubic_env_mapping
cmp [dr_flag],11
je .draw_smooth_line
; ****************
mov esi,point_index3 ; do Gouraud shading
mov ecx,3
.again_grd_draw:
movzx eax,word[esi]
shl eax,2
lea eax,[eax*3]
add eax,[points_normals_rot_ptr]
; texture x=(rotated point normal -> x * 255)+255
fld dword[eax] ; x cooficient of normal vector
fimul [correct_tex]
fiadd [correct_tex]
fistp word[esp-2]
; texture y=(rotated point normal -> y * 255)+255
fld dword[eax+4] ; y cooficient
fimul [correct_tex]
fiadd [correct_tex]
fistp word[esp-4]
mov eax,dword[esi]
shl eax,2
lea eax,[eax*3]
add eax,[points_normals_rot_ptr]
; texture x=(rotated point normal -> x * 255)+255
fld dword[eax] ; x cooficient of normal vector
fimul [correct_tex]
fiadd [correct_tex]
fistp word[esp-2]
; texture y=(rotated point normal -> y * 255)+255
fld dword[eax+4] ; y cooficient
fimul [correct_tex]
fiadd [correct_tex]
fistp word[esp-4]
 
movzx eax,word[esp-4]
movzx ebx,word[esp-2]
shl eax,TEX_SHIFT
add eax,ebx
lea eax,[eax*3+color_map]
mov eax,dword[eax]
cmp [catmull_flag],1 ; put on stack z coordinate if necessary
jne @f
lea edx,[ecx*3]
push word[edx*2+xx1-2] ; zz1 ,2 ,3
@@:
ror eax,16 ; eax -0xxxrrggbb -> 0xggbbxxrr
xor ah,ah
push ax ;r
rol eax,8 ; eax-0xggbb00rr -> 0xbb00rrgg
xor ah,ah
push ax ;g
shr eax,24
push ax ;b
movzx eax,word[esp-4]
movzx ebx,word[esp-2]
shl eax,TEX_SHIFT
add eax,ebx
lea eax,[eax*3+color_map]
mov eax,dword[eax]
; cmp [catmull_flag],1 ; put on stack z coordinate if necessary
; jne @f
lea edx,[ecx*3]
push word[edx*2+xx1-2] ; zz1 ,2 ,3
; @@:
ror eax,16 ; eax -0xxxrrggbb -> 0xggbbxxrr
xor ah,ah
push ax ;r
rol eax,8 ; eax-0xggbb00rr -> 0xbb00rrgg
xor ah,ah
push ax ;g
shr eax,24
push ax ;b
 
sub esi,2
dec cx
jnz .again_grd_draw
jmp .both_draw
sub esi,4
dec cx
jnz .again_grd_draw
jmp .both_draw
 
; movzx edi,[point_index3] ;gouraud shading according to light vector
; lea edi,[edi*3]
; lea edi,[4*edi+point_normals_rotated] ; edi - normal
; mov esi,light_vector
; call dot_product
; fabs
; fimul [orginal_color_r]
; fistp [temp_col]
; and [temp_col],0x00ff
; push [temp_col]
; push [temp_col]
; push [temp_col]
; movzx edi,[point_index3] ;gouraud shading according to light vector
; lea edi,[edi*3]
; lea edi,[4*edi+point_normals_rotated] ; edi - normal
; mov esi,light_vector
; call dot_product
; fabs
; fimul [orginal_color_r]
; fistp [temp_col]
; and [temp_col],0x00ff
; push [temp_col]
; push [temp_col]
; push [temp_col]
 
; movzx edi,[point_index2]
; lea edi,[edi*3]
; lea edi,[4*edi+point_normals_rotated] ; edi - normal
; mov esi,light_vector
; call dot_product
; fabs
; fimul [orginal_color_r]
; fistp [temp_col]
; and [temp_col],0x00ff
; push [temp_col]
; push [temp_col]
; push [temp_col]
; movzx edi,[point_index2]
; lea edi,[edi*3]
; lea edi,[4*edi+point_normals_rotated] ; edi - normal
; mov esi,light_vector
; call dot_product
; fabs
; fimul [orginal_color_r]
; fistp [temp_col]
; and [temp_col],0x00ff
; push [temp_col]
; push [temp_col]
; push [temp_col]
 
; movzx edi,[point_index1]
; lea edi,[edi*3]
; lea edi,[4*edi+point_normals_rotated] ; edi - normal
; mov esi,light_vector
; call dot_product
; fabs
; fimul [orginal_color_r]
; fistp [temp_col]
; and [temp_col],0x00ff
; push [temp_col]
; push [temp_col]
; push [temp_col]
; movzx edi,[point_index1]
; lea edi,[edi*3]
; lea edi,[4*edi+point_normals_rotated] ; edi - normal
; mov esi,light_vector
; call dot_product
; fabs
; fimul [orginal_color_r]
; fistp [temp_col]
; and [temp_col],0x00ff
; push [temp_col]
; push [temp_col]
; push [temp_col]
.rainbow:
cmp [catmull_flag],1 ; put on stack z coordinate if necessary
jne @f
push [zz3]
cmp [catmull_flag],1 ; put on stack z coordinate if necessary
jne @f
push [zz3]
@@:
mov eax,dword[yy3]
mov ebx,0x00ff00ff
and eax,ebx
push eax
neg al
push ax
cmp [catmull_flag],1
jne @f
push [zz2]
@@:
mov eax,dword[yy2]
and eax,ebx
push eax
neg al
push ax
cmp [catmull_flag],1
jne @f
push [zz1]
@@:
mov eax,dword[yy1]
and eax,ebx
push eax
neg al
push ax
mov eax,dword[yy3]
mov ebx,0x00ff00ff
and eax,ebx
push eax
neg al
push ax
; cmp [catmull_flag],1
; jne @f
push [zz2]
; @@:
mov eax,dword[yy2]
and eax,ebx
push eax
neg al
push ax
; cmp [catmull_flag],1
; jne @f
push [zz1]
; @@:
mov eax,dword[yy1]
and eax,ebx
push eax
neg al
push ax
.both_draw:
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
cmp [catmull_flag],0
je @f
; lea esi,[Z_buffer]
mov esi,[Zbuffer_ptr]
call gouraud_triangle_z
jmp .end_draw
@@:
call gouraud_triangle
jmp .end_draw
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
; cmp [catmull_flag],0
; je @f
mov esi,[Zbuffer_ptr]
call gouraud_triangle_z
; jmp .end_draw
; @@:
; call gouraud_triangle
jmp .end_draw
 
.flat_draw: ;**************************
; FLAT DRAWING
movzx eax,[point_index1]
movzx ebx,[point_index2]
movzx ecx,[point_index3]
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]
add ebx,[points_normals_rot_ptr]
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]
fimul [correct_tex]
fiadd [correct_tex]
fistp 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]
fimul [correct_tex]
fiadd [correct_tex]
fistp dword[esp-8] ; y
mov edx,dword[esp-8]
shl edx,TEX_SHIFT
add edx,dword[esp-4]
lea eax,[3*edx+color_map]
mov edx,dword[eax]
.flat_draw: ;**************************
; FLAT DRAWING
mov eax,[point_index1]
mov ebx,[point_index2]
mov ecx,[point_index3]
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]
add ebx,[points_normals_rot_ptr]
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]
fimul [correct_tex]
fiadd [correct_tex]
fistp 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]
fimul [correct_tex]
fiadd [correct_tex]
fistp dword[esp-8] ; y
mov edx,dword[esp-8]
shl edx,TEX_SHIFT
add edx,dword[esp-4]
lea eax,[3*edx]
add eax,color_map
mov edx,dword[eax]
 
and edx,0x00ffffff ; edx = 0x00rrggbb
and edx,0x00ffffff ; edx = 0x00rrggbb
 
 
 
; mov ax,[zz1] ; z position depend draw
; add ax,[zz2]
; add ax,[zz3]
; cwd
; idiv [i3] ; = -((a+b+c)/3+130)
; add ax,130
; neg al
; xor edx,edx
; mov ah,al ;set color according to z position
; shl eax,8
; mov edx,eax
; mov ax,[zz1] ; z position depend draw
; add ax,[zz2]
; add ax,[zz3]
; cwd
; idiv [i3] ; = -((a+b+c)/3+130)
; add ax,130
; neg al
; xor edx,edx
; mov ah,al ;set color according to z position
; shl eax,8
; mov edx,eax
 
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
; mov edi,screen
mov edi,[screen_ptr]
cmp [catmull_flag],0
je @f
; lea esi,[Z_buffer]
mov esi,[Zbuffer_ptr]
push word[zz3]
push word[zz2]
push word[zz1]
call flat_triangle_z
jmp .end_draw
@@:
call draw_triangle
jmp .end_draw
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
; cmp [catmull_flag],0
; je @f
mov esi,[Zbuffer_ptr]
push word[zz3]
push word[zz2]
push word[zz1]
call flat_triangle_z
jmp .end_draw
; @@:
; call draw_triangle
; jmp .end_draw
.env_mapping:
; fninit
cmp [catmull_flag],0
je @f
push [zz3]
push [zz2]
push [zz1]
; cmp [catmull_flag],0
; je @f
push [zz3]
push [zz2]
push [zz1]
; @@:
mov esi,point_index1
sub esp,12
mov edi,esp
mov ecx,3
@@:
mov esi,point_index1
sub esp,12
mov edi,esp
mov ecx,3
@@:
movzx eax,word[esi]
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr] ;point_normals_rotated
mov eax,dword[esi]
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr] ;point_normals_rotated
; #
; fld dword[eax]
; fmul dword[eax+4]
; fld1
; fld1
; faddp
; fmulp
; fimul [correct_tex]
; fiadd [correct_tex]
; fistp word[edi]
; mov word[edi+2],0
;; fistp word[edi+2]
; fld dword[eax]
; fmul dword[eax+4]
; fld1
; fld1
; faddp
; fmulp
; fimul [correct_tex]
; fiadd [correct_tex]
; fistp word[edi]
; mov word[edi+2],0
;; fistp word[edi+2]
; # last change
; 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]
; 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]
; # end of last ch.
add edi,4
add esi,2
loop @b
add edi,4
add esi,4
loop @b
 
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
mov esi,envmap
cmp [catmull_flag],0
je @f
; mov edx,Z_buffer
mov edx,[Zbuffer_ptr]
call tex_triangle_z
jmp .end_draw
@@:
call tex_triangle
jmp .end_draw
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
mov esi,envmap
; cmp [catmull_flag],0
; je @f
 
mov edx,[Zbuffer_ptr]
call tex_triangle_z
; jmp .end_draw
; @@:
; call tex_triangle
jmp .end_draw
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.cubic_env_mapping:
; fninit
cmp [catmull_flag],0
je @f
push [zz3]
push [zz2]
push [zz1]
; cmp [catmull_flag],0
; je @f
push [zz3]
push [zz2]
push [zz1]
; @@:
mov esi,point_index1
sub esp,12
mov edi,esp
mov ecx,3
@@:
mov esi,point_index1
sub esp,12
mov edi,esp
mov ecx,3
@@:
movzx eax,word[esi]
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr] ;point_normals_rotated
mov eax,dword[esi]
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr] ;point_normals_rotated
; #
fld dword[eax]
fmul dword[eax+4]
fld1
fld1
faddp
fmulp
fimul [correct_tex]
fiadd [correct_tex]
fistp word[edi]
mov word[edi+2],0
; fistp word[edi+2]
fld dword[eax]
fmul dword[eax+4]
fld1
fld1
faddp
fmulp
fimul [correct_tex]
fiadd [correct_tex]
fistp word[edi]
mov word[edi+2],0
; fistp word[edi+2]
; # last change
; ; 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]
; ; 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]
; # end of last ch.
add edi,4
add esi,2
loop @b
add edi,4
add esi,4
loop @b
 
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
mov esi,envmap_cub
cmp [catmull_flag],0
je @f
; mov edx,Z_buffer
mov edx,[Zbuffer_ptr]
call tex_triangle_z
jmp .end_draw
@@:
call tex_triangle
jmp .end_draw
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
mov esi,envmap_cub
; cmp [catmull_flag],0
; je @f
mov edx,[Zbuffer_ptr]
call tex_triangle_z
; jmp .end_draw
; @@:
; call tex_triangle
jmp .end_draw
 
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
.bump_mapping:
; fninit
cmp [catmull_flag],0
je @f
; push Z_buffer
push [Zbuffer_ptr]
push [zz3]
push [zz2]
push [zz1]
; fninit
; cmp [catmull_flag],0
; je @f
 
push [Zbuffer_ptr]
push [zz3]
push [zz2]
push [zz1]
; @@:
mov esi,point_index1
sub esp,12
mov edi,esp
mov ecx,3
@@:
mov esi,point_index1
sub esp,12
mov edi,esp
mov ecx,3
@@:
movzx eax,word[esi]
lea eax,[eax*3]
shl eax,2
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]
mov eax,dword[esi]
lea eax,[eax*3]
shl eax,2
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]
 
add edi,4
add esi,2
loop @b
add edi,4
add esi,4
loop @b
 
movzx esi,[point_index3] ; bump map coords
shl esi,2
add esi,tex_points
push dword[esi]
movzx 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]
movzx 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 esi,[point_index3] ; bump map coords
shl esi,2
add esi,tex_points
push dword[esi]
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
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
mov esi,envmap
mov edx,bumpmap ;BUMP_MAPPING
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
mov esi,envmap
mov edx,bumpmap ;BUMP_MAPPING
 
cmp [catmull_flag],0
je @f
call bump_triangle_z
jmp .end_draw
@@:
call bump_triangle
jmp .end_draw
; cmp [catmull_flag],0
; je @f
call bump_triangle_z
; jmp .end_draw
; @@:
; call bump_triangle
jmp .end_draw
 
.tex_mapping:
 
; fninit
cmp [catmull_flag],0
je @f
push [zz3]
push [zz2]
push [zz1]
@@:
movzx esi,[point_index3] ; tex map coords
shl esi,2
add esi,tex_points
push dword[esi]
movzx esi,[point_index2]
shl esi,2
add esi,tex_points
push dword[esi]
movzx esi,[point_index1]
shl esi,2
add esi,tex_points
push dword[esi]
; fninit
; cmp [catmull_flag],0
; je @f
push [zz3]
push [zz2]
push [zz1]
; @@:
mov esi,[point_index3] ; tex map coords
shl esi,2
add esi,tex_points
push dword[esi]
mov esi,[point_index2]
shl esi,2
add esi,tex_points
push dword[esi]
mov esi,[point_index1]
shl esi,2
add esi,tex_points
push dword[esi]
 
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
mov esi,texmap
cmp [catmull_flag],0
je @f
; mov edx,Z_buffer
mov edx,[Zbuffer_ptr]
call tex_triangle_z
; call tex_plus_grd_trianlgle
jmp .end_draw
@@:
call tex_triangle
jmp .end_draw
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
mov esi,texmap
; cmp [catmull_flag],0
; je @f
mov edx,[Zbuffer_ptr]
call tex_triangle_z
; jmp .end_draw
; @@:
; call tex_triangle
jmp .end_draw
; .ray:
; grd_triangle according to points index
; cmp [catmull_flag],0
; je @f
; push [zz3] ; spot light with attenuation
; grd_triangle according to points index
; cmp [catmull_flag],0
; je @f
; push [zz3] ; spot light with attenuation
; @@:
; movzx eax,[point_index3] ; env_map - points color list
; shl eax,1 ; each color as word, 0x00rr00gg00bb..
; lea eax,[3*eax+bumpmap]
; push word[eax]
; push word[eax+2]
; push word[eax+4]
; cmp [catmull_flag],0
; je @f
; push [zz2]
; movzx eax,[point_index3] ; env_map - points color list
; shl eax,1 ; each color as word, 0x00rr00gg00bb..
; lea eax,[3*eax+bumpmap]
; push word[eax]
; push word[eax+2]
; push word[eax+4]
; cmp [catmull_flag],0
; je @f
; push [zz2]
; @@:
; movzx eax,[point_index2] ; env_map - points color list
; shl eax,1 ; each color as word, 0x00rr00gg00bb..
; lea eax,[eax*3+bumpmap]
; push word[eax]
; push word[eax+2]
; push word[eax+4]
; cmp [catmull_flag],0
; je @f
; push [zz1]
; movzx eax,[point_index2] ; env_map - points color list
; shl eax,1 ; each color as word, 0x00rr00gg00bb..
; lea eax,[eax*3+bumpmap]
; push word[eax]
; push word[eax+2]
; push word[eax+4]
; cmp [catmull_flag],0
; je @f
; push [zz1]
; @@:
; movzx eax,[point_index1] ; env_map - points color list
; shl eax,1 ; each color as word, 0xrr00gg00bb00..
; lea eax,[eax*3+bumpmap]
; push word[eax]
; push word[eax+2]
; push word[eax+4]
; jmp .both_draw
; movzx eax,[point_index1] ; env_map - points color list
; shl eax,1 ; each color as word, 0xrr00gg00bb00..
; lea eax,[eax*3+bumpmap]
; push word[eax]
; push word[eax+2]
; push word[eax+4]
; jmp .both_draw
 
.grd_tex: ; smooth shading + texture
push ebp
mov ebp,esp
sub esp,4
push ebp
.grd_tex: ; smooth shading + texture
push ebp
mov ebp,esp
sub esp,4
push ebp
 
movzx esi,[point_index3] ; tex map coords
shl esi,2
add esi,tex_points
push dword[esi] ; texture coords as first
movzx esi,[point_index2] ; group of parameters
shl esi,2
add esi,tex_points
push dword[esi]
movzx esi,[point_index1]
shl esi,2
add esi,tex_points
push dword[esi]
mov esi,[point_index3] ; tex map coords
shl esi,2
add esi,tex_points
push dword[esi] ; texture coords as first
mov esi,[point_index2] ; group of parameters
shl esi,2
add esi,tex_points
push dword[esi]
mov esi,[point_index1]
shl esi,2
add esi,tex_points
push dword[esi]
 
mov esi,point_index3
mov ecx,3
mov esi,point_index3
mov ecx,3
 
.aagain_grd_draw:
 
lea edx,[ecx*3]
push word[edx*2+xx1-2] ; zz1 ,2 ,3
lea edx,[ecx*3]
push word[edx*2+xx1-2] ; zz1 ,2 ,3
 
movzx eax,word[esi]
shl eax,2
lea eax,[eax*3] ;+point_normals_rotated]
add eax,[points_normals_rot_ptr]
; texture x=(rotated point normal -> x * 255)+255
fld dword[eax] ; x cooficient of normal vector
fimul [correct_tex]
fiadd [correct_tex]
fistp word[ebp-2]
; texture y=(rotated point normal -> y * 255)+255
fld dword[eax+4] ; y cooficient
fimul [correct_tex]
fiadd [correct_tex]
fistp word[ebp-4]
mov eax,dword[esi]
shl eax,2
lea eax,[eax*3] ;+point_normals_rotated]
add eax,[points_normals_rot_ptr]
; texture x=(rotated point normal -> x * 255)+255
fld dword[eax] ; x cooficient of normal vector
fimul [correct_tex]
fiadd [correct_tex]
fistp word[ebp-2]
; texture y=(rotated point normal -> y * 255)+255
fld dword[eax+4] ; y cooficient
fimul [correct_tex]
fiadd [correct_tex]
fistp word[ebp-4]
 
movzx eax,word[ebp-4]
movzx ebx,word[ebp-2]
shl eax,TEX_SHIFT
add eax,ebx
lea eax,[eax*3+color_map]
mov eax,dword[eax]
movzx eax,word[ebp-4]
movzx ebx,word[ebp-2]
shl eax,TEX_SHIFT
add eax,ebx
lea eax,[eax*3+color_map]
mov eax,dword[eax]
 
ror eax,16 ; eax -0xxxrrggbb -> 0xggbbxxrr
xor ah,ah
push ax ;r
rol eax,8 ; eax-0xggbb00rr -> 0xbb00rrgg
xor ah,ah
push ax ;g
shr eax,24
push ax ;b
ror eax,16 ; eax -0xxxrrggbb -> 0xggbbxxrr
xor ah,ah
push ax ;r
rol eax,8 ; eax-0xggbb00rr -> 0xbb00rrgg
xor ah,ah
push ax ;g
shr eax,24
push ax ;b
 
sub esi,2
dec cx
jnz .aagain_grd_draw
sub esi,4
dec cx
jnz .aagain_grd_draw
 
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
mov edx,texmap
mov esi,[Zbuffer_ptr]
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
mov edx,texmap
mov esi,[Zbuffer_ptr]
 
call tex_plus_grd_triangle
call tex_plus_grd_triangle
 
pop ebp
mov esp,ebp
pop ebp
jmp .end_draw
pop ebp
mov esp,ebp
pop ebp
jmp .end_draw
 
.two_tex:
push [Zbuffer_ptr]
push [Zbuffer_ptr]
 
push word[zz3]
push word[zz2]
push word[zz1]
push word[zz3]
push word[zz2]
push word[zz1]
 
movzx esi,[point_index3] ; tex map coords
shl esi,2
add esi,tex_points
push dword[esi]
movzx esi,[point_index2]
shl esi,2
add esi,tex_points
push dword[esi]
movzx esi,[point_index1]
shl esi,2
add esi,tex_points
push dword[esi]
mov esi,[point_index3] ; tex map coords
shl esi,2
add esi,tex_points
push dword[esi]
mov esi,[point_index2]
shl esi,2
add esi,tex_points
push dword[esi]
mov esi,[point_index1]
shl esi,2
add esi,tex_points
push dword[esi]
 
mov esi,point_index1 ; env coords
sub esp,12
mov edi,esp
mov ecx,3
mov esi,point_index1 ; env coords
sub esp,12
mov edi,esp
mov ecx,3
@@:
movzx eax,word[esi]
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr]
; 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]
mov eax,dword[esi]
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr]
; 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,2
loop @b
add edi,4
add esi,4
loop @b
 
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
mov esi,texmap
mov edx,envmap
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
mov esi,texmap
mov edx,envmap
 
call two_tex_triangle_z
jmp .end_draw
call two_tex_triangle_z
jmp .end_draw
 
.bump_tex:
movzx esi,[point_index3] ; tex map coords
shl esi,2
add esi,tex_points
push dword[esi]
movzx esi,[point_index2]
shl esi,2
add esi,tex_points
push dword[esi]
movzx esi,[point_index1]
shl esi,2
add esi,tex_points
push dword[esi]
mov esi,[point_index3] ; tex map coords
shl esi,2
add esi,tex_points
push dword[esi]
mov esi,[point_index2]
shl esi,2
add esi,tex_points
push dword[esi]
mov esi,[point_index1]
shl esi,2
add esi,tex_points
push dword[esi]
 
push dword texmap
push dword texmap
 
push [Zbuffer_ptr]
xor edi,edi
push [Zbuffer_ptr]
xor edi,edi
 
push word[zz3]
push word[zz2]
push word[zz1]
push word[zz3]
push word[zz2]
push word[zz1]
 
mov esi,point_index1 ; env coords
sub esp,12
mov edi,esp
mov ecx,3
mov esi,point_index1 ; env coords
sub esp,12
mov edi,esp
mov ecx,3
@@:
movzx eax,word[esi]
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr]
; 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]
mov eax,dword[esi]
lea eax,[eax*3]
shl eax,2
add eax,[points_normals_rot_ptr]
; 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,2
loop @b
add edi,4
add esi,4
loop @b
 
; push dword 1 shl 16 + 1 ; emap coords
; push dword 127 shl 16 + 1
; push dword 127 shl 16 + 127
; push dword 1 shl 16 + 1 ; emap coords
; push dword 127 shl 16 + 1
; push dword 127 shl 16 + 127
 
movzx esi,[point_index3] ; bump map coords
shl esi,2
add esi,tex_points
push dword[esi]
movzx esi,[point_index2]
shl esi,2
add esi,tex_points
push dword[esi]
mov esi,[point_index3] ; bump map coords
shl esi,2
add esi,tex_points
push dword[esi]
mov esi,[point_index2]
shl esi,2
add esi,tex_points
push dword[esi]
 
movzx esi,[point_index1]
shl esi,2
add esi,tex_points
push dword[esi]
mov esi,[point_index1]
shl esi,2
add esi,tex_points
push dword[esi]
 
; push dword 1 shl 16 + 127
; push dword 127 shl 16 + 127
; push dword 1 shl 16 + 1 ; bump coords
; push dword 1 shl 16 + 127
; push dword 127 shl 16 + 127
; push dword 1 shl 16 + 1 ; bump coords
 
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
mov esi,envmap
mov edx,bumpmap
mov eax,dword[xx1]
ror eax,16
mov ebx,dword[xx2]
ror ebx,16
mov ecx,dword[xx3]
ror ecx,16
mov edi,[screen_ptr]
mov esi,envmap
mov edx,bumpmap
 
call bump_tex_triangle_z
call bump_tex_triangle_z
 
jmp .end_draw
jmp .end_draw
 
.draw_smooth_line:
mov esi,point_index3
mov ecx,3
mov esi,point_index3
mov ecx,3
.again_line_param:
movzx eax,word[esi]
shl eax,2
lea eax,[eax*3]
add eax,[points_normals_rot_ptr]
; texture ;x=(rotated point normal -> x * 255)+255
fld dword[eax] ; x cooficient of normal vector
fimul [correct_tex]
fiadd [correct_tex]
fistp word[esp-2]
; texture y=(rotated point normal -> y * 255)+255
fld dword[eax+4] ; y cooficient
fimul [correct_tex]
fiadd [correct_tex]
fistp word[esp-4]
mov eax,dword[esi]
shl eax,2
lea eax,[eax*3]
add eax,[points_normals_rot_ptr]
; texture ;x=(rotated point normal -> x * 255)+255
fld dword[eax] ; x cooficient of normal vector
fimul [correct_tex]
fiadd [correct_tex]
fistp word[esp-2]
; texture y=(rotated point normal -> y * 255)+255
fld dword[eax+4] ; y cooficient
fimul [correct_tex]
fiadd [correct_tex]
fistp word[esp-4]
 
movzx eax,word[esp-4]
movzx ebx,word[esp-2]
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
movzx eax,word[esp-4]
movzx ebx,word[esp-2]
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,2
dec ecx
jnz .again_line_param
sub esi,4
dec ecx
jnz .again_line_param
 
; mov eax,[edges_ptr] ; this not works correctly
; add eax,[edges_counter] ; I mean chosing overlapped edges.
; mov bl,[eax] ;
; test bl,00000001b ;
; jz @f ;
mov edi,[screen_ptr]
mov esi,[Zbuffer_ptr]
; mov eax,[edges_ptr] ; this not works correctly
; add eax,[edges_counter] ; I mean chosing overlapped edges.
; mov bl,[eax] ;
; test bl,00000001b ;
; jz @f ;
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,[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]
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
call smooth_line
@@:
; mov eax,[edges_ptr] ; this not works correctly
; add eax,[edges_counter]
; mov bl,[eax]
; test bl,00000010b
; jz @f
; mov eax,[edges_ptr] ; this not works correctly
; add eax,[edges_counter]
; mov bl,[eax]
; test bl,00000010b
; jz @f
 
mov edi,[screen_ptr]
mov esi,[Zbuffer_ptr]
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,[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]
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
call smooth_line
@@:
 
; mov eax,[edges_ptr] ; this not works correctly
; add eax,[edges_counter] ;
; mov bl,[eax] ;
; test bl,00000100b ;
; jz @f ;
; mov eax,[edges_ptr] ; this not works correctly
; add eax,[edges_counter] ;
; mov bl,[eax] ;
; test bl,00000100b ;
; jz @f ;
 
mov edi,[screen_ptr]
mov esi,[Zbuffer_ptr]
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,[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]
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
call smooth_line
@@:
 
.end_draw:
pop esi
add esi,6
inc [edges_counter]
cmp dword[esi],-1
jne .again_dts
pop esi
add esi,12
inc [edges_counter]
pop ecx
sub ecx,1
; cmp dword[esi],-1
jnz .again_dts
ret
 
 
2930,6 → 2939,10
 
 
 
 
 
 
 
draw_handlers:
 
push ebp
2955,22 → 2968,22
mov esi,[points_translated_ptr]
.loop:
push esi
; DO culling AT FIRST
cmp [culling_flag],1 ; (if culling_flag = 1)
jne .no_culling
mov edi,[.counter] ; *********************************
lea edi,[edi*3]
shl edi,2
add edi,[points_normals_rot_ptr]
mov eax,[edi+8] ; check sign of z coof
shr eax,31
cmp eax,1
jnz .skip
; DO culling AT FIRST
cmp [culling_flag],1 ; (if culling_flag = 1)
jne .no_culling
mov edi,[.counter] ; *********************************
lea edi,[edi*3]
shl edi,2
add edi,[points_normals_rot_ptr]
mov eax,[edi+8] ; check sign of z coof
shr eax,31
cmp eax,1
jnz .skip
.no_culling:
mov eax,[esi]
movzx ebx,ax ; ebx - x
shr eax,16 ; eax - y
cmp eax,4 ; check if markers not exceedes screen
movzx ebx,ax ; ebx - x
shr eax,16 ; eax - y
cmp eax,4 ; check if markers not exceedes screen
jle .skip
cmp ebx,4
jle .skip
2984,8 → 2997,8
jge .skip
 
movzx edx,word[size_x_var]
; sub ebx,3
; sub eax,3
; sub ebx,3
; sub eax,3
imul eax,edx
add eax,ebx
lea edi,[eax*3]
3006,7 → 3019,7
 
@@:
mov word[edi],0x0000 ;ax
mov byte[edi+2],0xff ;al
mov byte[edi+2],0xff ;al
mov word[eax],dx
add eax,2
add edi,3
3021,7 → 3034,7
add esi,6
inc dword[.counter]
mov ecx,[.counter]
cmp cx,[points_count_var]
cmp ecx,[points_count_var]
jng .loop
 
mov esp,ebp
3031,315 → 3044,313
 
 
fill_Z_buffer:
mov eax,0x70000000
mov edi,[Zbuffer_ptr]
movzx ecx,word[size_x_var]
movzx ebx,word[size_y_var]
imul ecx,ebx
mov eax,0x70000000
mov edi,[Zbuffer_ptr]
movzx ecx,word[size_x_var]
movzx ebx,word[size_y_var]
imul ecx,ebx
if Ext>=SSE2
movd xmm0,eax
shufps xmm0,xmm0,0
push ecx
mov ecx,edi
and edi,0xffffff00
and ecx,0x000000ff
mov edx,ecx
rep stosd
pop ecx
sub ecx,edx
movd xmm0,eax
shufps xmm0,xmm0,0
push ecx
mov ecx,edi
and edi,0xffffff00
and ecx,0x000000ff
mov edx,ecx
rep stosd
pop ecx
sub ecx,edx
@@:
movaps [edi],xmm0
movaps [edi+16],xmm0
movaps [edi+32],xmm0
movaps [edi+48],xmm0
add edi,64
sub ecx,16
jnc @b
movaps [edi],xmm0
movaps [edi+16],xmm0
movaps [edi+32],xmm0
movaps [edi+48],xmm0
add edi,64
sub ecx,16
jnc @b
else
rep stosd
rep stosd
end if
ret
 
read_tp_variables: ; read [triangles_count_var] and [points_count_var]
; and allocate memory
xor ebx,ebx
xor ebp,ebp
mov [points_count_var],bx
mov [triangles_count_var],bx
read_tp_variables: ; read [triangles_count_var] and [points_count_var]
; and allocate memory
xor ebx,ebx
xor ebp,ebp
mov [points_count_var],ebx
mov [triangles_count_var],ebx
if USE_LFN = 0
mov esi,SourceFile
mov esi,SourceFile
else
mov esi,[fptr]
mov esi,[fptr]
end if
 
cmp [esi],word 4D4Dh
je @f ;Must be legal .3DS file
xor eax,eax
ret
cmp [esi],word 4D4Dh
je @f ;Must be legal .3DS file
xor eax,eax
ret
@@:
mov eax,dword[esi+2]
cmp eax,[fsize] ;This must tell the length
je @f
xor eax,eax
ret
mov eax,dword[esi+2]
cmp eax,[fsize] ;This must tell the length
je @f
xor eax,eax
ret
@@:
add eax,esi
mov [EndFile],eax ;
add eax,esi
mov [EndFile],eax ;
 
add esi,6
add esi,6
@@:
cmp [esi],word 3D3Dh
je @f
add esi,[esi+2]
jmp @b
cmp [esi],word 3D3Dh
je @f
add esi,[esi+2]
jmp @b
@@:
add esi,6
add esi,6
.find4k:
cmp [esi],word 4000h
je @f
add esi,[esi+2]
cmp esi,[EndFile]
jc .find4k
jmp .exit
cmp [esi],word 4000h
je @f
add esi,[esi+2]
cmp esi,[EndFile]
jc .find4k
jmp .exit
@@:
add esi,6
add esi,6
@@:
cmp [esi],byte 0
je @f
inc esi
jmp @b
cmp [esi],byte 0
je @f
inc esi
jmp @b
@@:
inc esi
inc esi
@@:
cmp [esi],word 4100h
je @f
add esi,[esi+2]
jmp @b
cmp [esi],word 4100h
je @f
add esi,[esi+2]
jmp @b
@@:
add esi,6
add esi,6
@@:
cmp [esi],word 4110h
je @f
add esi,[esi+2]
jmp @b
cmp [esi],word 4110h
je @f
add esi,[esi+2]
jmp @b
@@:
movzx ecx,word[esi+6]
add [points_count_var],cx
movzx ecx,word[esi+6]
add [points_count_var],ecx
 
mov edx,ecx
add esi,8
mov edx,ecx
add esi,8
@@:
 
add ebx,6
add esi,12
; dec ecx
loop @b
add ebx,6
add esi,12
; dec ecx
loop @b
@@:
 
@@:
cmp [esi],word 4120h
je @f
add esi,[esi+2]
jmp @b
cmp [esi],word 4120h
je @f
add esi,[esi+2]
jmp @b
@@:
movzx ecx,word[esi+6]
add [triangles_count_var],cx
add esi,8
movzx ecx,word[esi+6]
add [triangles_count_var],ecx
add esi,8
 
@@:
add esi,8
dec ecx
jnz @b
; xor ecx,ecx
add ebp,edx
jmp .find4k
mov eax,-1 ;<---mark if OK
add esi,8
dec ecx
jnz @b
; xor ecx,ecx
add ebp,edx
jmp .find4k
mov eax,-1 ;<---mark if OK
.exit:
ret
 
read_from_file:
fninit
mov edi,[triangles_ptr]
xor ebx,ebx
xor ebp,ebp
mov [points_count_var],0
mov [triangles_count_var],0
fninit
mov edi,[triangles_ptr]
xor ebx,ebx
xor ebp,ebp
mov [points_count_var],0
mov [triangles_count_var],0
if USE_LFN = 0
mov esi,SourceFile
mov esi,SourceFile
else
mov esi,[fptr]
mov esi,[fptr]
end if
cmp [esi],word 4D4Dh
jne .exit ;Must be legal .3DS file
; cmp dword[esi+2],EndFile-SourceFile
; jne .exit ;This must tell the length
mov eax,dword[esi+2]
; cmp eax,[fsize]
; jne .exit
cmp [esi],word 4D4Dh
jne .exit ;Must be legal .3DS file
; cmp dword[esi+2],EndFile-SourceFile
; jne .exit ;This must tell the length
mov eax,dword[esi+2]
; cmp eax,[fsize]
; jne .exit
 
add eax,esi
mov [EndFile],eax ;
add eax,esi
mov [EndFile],eax ;
 
add esi,6
add esi,6
@@:
cmp [esi],word 3D3Dh
je @f
add esi,[esi+2]
jmp @b
cmp [esi],word 3D3Dh
je @f
add esi,[esi+2]
jmp @b
@@:
add esi,6
add esi,6
.find4k:
cmp [esi],word 4000h
je @f
add esi,[esi+2]
cmp esi,[EndFile]
jc .find4k
jmp .exit
cmp [esi],word 4000h
je @f
add esi,[esi+2]
cmp esi,[EndFile]
jc .find4k
jmp .exit
@@:
add esi,6
add esi,6
@@:
cmp [esi],byte 0
je @f
inc esi
jmp @b
cmp [esi],byte 0
je @f
inc esi
jmp @b
@@:
inc esi
inc esi
@@:
cmp [esi],word 4100h
je @f
add esi,[esi+2]
jmp @b
cmp [esi],word 4100h
je @f
add esi,[esi+2]
jmp @b
@@:
add esi,6
add esi,6
@@:
cmp [esi],word 4110h
je @f
add esi,[esi+2]
jmp @b
cmp [esi],word 4110h
je @f
add esi,[esi+2]
jmp @b
@@:
movzx ecx,word[esi+6]
add [points_count_var],cx
movzx ecx,word[esi+6]
add [points_count_var],ecx
 
mov edx,ecx
add esi,8
mov edx,ecx
add esi,8
@@:
push edi
mov edi,[points_ptr]
push dword[esi+0]
pop dword[edi+ebx*2+0]
push dword[esi+4]
pop dword[edi+ebx*2+4]
push dword[esi+8]
pop dword[edi+ebx*2+8]
pop edi
; fld dword[esi+4]
; fstp dword[real_points+ebx*2+0] ; x
; fld dword[esi+8]
; fstp dword[real_points+ebx*2+4] ; y
; fld dword[esi+0]
; fstp dword[real_points+ebx*2+8] ; z
push edi
mov edi,[points_ptr]
push dword[esi+0]
pop dword[edi+ebx*2+0]
push dword[esi+4]
pop dword[edi+ebx*2+4]
push dword[esi+8]
pop dword[edi+ebx*2+8]
pop edi
 
add ebx,6
add esi,12
dec ecx
jnz @b
add ebx,6
add esi,12
dec ecx
jnz @b
@@:
; mov dword[points+ebx],-1
push edi
mov edi,[points_ptr]
mov dword[edi+ebx*2],-1 ; end mark (not always in use)
pop edi
; mov dword[points+ebx],-1
push edi
mov edi,[points_ptr]
mov dword[edi+ebx*2],-1 ; end mark (not always in use)
pop edi
@@:
cmp [esi],word 4120h
je @f
add esi,[esi+2]
jmp @b
cmp [esi],word 4120h
je @f
add esi,[esi+2]
jmp @b
@@:
movzx ecx,word[esi+6]
add [triangles_count_var],cx
add esi,8
;mov edi,triangles
movzx ecx,word[esi+6]
add [triangles_count_var],ecx
add esi,8
;mov edi,triangles
@@:
movsd
movsw
add word[edi-6],bp
add word[edi-4],bp
add word[edi-2],bp
add esi,2
dec ecx
jnz @b
add ebp,edx
jmp .find4k
mov eax,-1 ;<---mark if OK
movzx eax,word[esi]
stosd
movzx eax,word[esi+2]
stosd
movzx eax,word[esi+4]
stosd
add dword[edi-12],ebp
add dword[edi-8],ebp
add dword[edi-4],ebp
add esi,8
dec ecx
jnz @b
add ebp,edx
jmp .find4k
mov eax,-1 ;<---mark if OK
.exit:
mov dword[edi],-1
mov dword[edi],-1
ret
 
if USE_LFN
alloc_mem_for_tp:
mov eax, 68
cmp [re_alloc_flag],1
jz @f
mov ebx, 12
jmp .alloc
mov eax, 68
cmp [re_alloc_flag],1
jz @f
mov ebx, 12
jmp .alloc
@@:
mov ebx,20
mov ebx,20
.alloc:
 
movzx ecx, [triangles_count_var]
inc ecx
lea ecx, [ecx*3]
add ecx, ecx
mov edx,[triangles_ptr]
int 0x40 ; -> allocate memory to triangles
mov [triangles_ptr], eax ; -> eax = pointer to allocated mem
mov ecx,[triangles_count_var]
add ecx,20
lea ecx, [ecx*3]
shl ecx,2
mov edx,[triangles_ptr]
int 0x40 ; -> allocate memory to triangles
mov [triangles_ptr], eax ; -> eax = pointer to allocated mem
 
; mov eax, 68
; movzx ecx, [triangles_count_var]
; inc ecx
; mov edx,[edges_ptr]
; int 0x40 ; -> allocate memory to edges
; mov [edges_ptr], eax ; -> eax = pointer to allocated mem
; mov eax, 68
; movzx ecx, [triangles_count_var]
; inc ecx
; mov edx,[edges_ptr]
; 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,-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
; movzx ecx, [triangles_count_var]
; shl ecx, 4
; int 0x40
; mov [triangles_w_z_ptr], eax ; for trainagles_with_z list
; ststic memory
; mov eax, 68
; mov ebx, 12
; movzx ecx, [triangles_count_var]
; shl ecx, 4
; int 0x40
; mov [triangles_w_z_ptr], eax ; for trainagles_with_z list
; ststic memory
 
mov eax, 68
movzx ecx, [triangles_count_var]
lea ecx, [3+ecx*3]
shl ecx, 2
mov edx,[triangles_normals_ptr]
int 0x40 ; -> allocate memory for triangles normals
mov [triangles_normals_ptr], eax ; -> eax = pointer to allocated mem
mov eax, 68
mov ecx, [triangles_count_var]
lea ecx, [3+ecx*3]
shl ecx, 2
mov edx,[triangles_normals_ptr]
int 0x40 ; -> allocate memory for triangles normals
mov [triangles_normals_ptr], eax ; -> eax = pointer to allocated mem
 
; mov eax, 68
; movzx ecx,[points_count_var]
; lea ecx,[2+ecx*2]
; mov edx,dword [vertices_index_ptr]
; int 0x40
; mov dword[vertices_index_ptr], eax
; mov eax, 68
; movzx ecx,[points_count_var]
; lea ecx,[2+ecx*2]
; mov edx,dword [vertices_index_ptr]
; int 0x40
; mov dword[vertices_index_ptr], eax
 
mov eax, 68
movzx ecx, [points_count_var]
lea ecx,[3+ecx*3]
shl ecx, 2
mov edx,[points_normals_ptr]
int 0x40
mov [points_normals_ptr], eax
mov eax, 68
mov ecx, [points_count_var]
lea ecx,[3+ecx*3]
shl ecx, 2
mov edx,[points_normals_ptr]
int 0x40
mov [points_normals_ptr], eax
; int3
 
 
3346,32 → 3357,32
; int3
 
 
mov eax, 68
; mov ebx, 12
movzx ecx, [points_count_var]
lea ecx,[3+ecx*3]
shl ecx, 2
mov edx,[points_normals_rot_ptr]
int 0x40
mov [points_normals_rot_ptr], eax
mov eax, 68
; mov ebx, 12
mov ecx, [points_count_var]
lea ecx,[3+ecx*3]
shl ecx, 2
mov edx,[points_normals_rot_ptr]
int 0x40
mov [points_normals_rot_ptr], eax
 
mov eax, 68
mov edx,[points_ptr]
int 0x40
mov [points_ptr], eax
mov eax, 68
mov edx,[points_ptr]
int 0x40
mov [points_ptr], eax
 
mov eax, 68
mov edx,[points_rotated_ptr]
int 0x40
mov [points_rotated_ptr], eax
mov eax, 68
mov edx,[points_rotated_ptr]
int 0x40
mov [points_rotated_ptr], eax
 
mov eax, 68
movzx ecx, [points_count_var]
inc ecx
shl ecx, 3
mov edx,[points_translated_ptr]
int 0x40
mov [points_translated_ptr], eax
mov eax, 68
mov ecx, [points_count_var]
inc ecx
shl ecx, 3
mov edx,[points_translated_ptr]
int 0x40
mov [points_translated_ptr], eax
ret
end if
 
3381,54 → 3392,45
;-
mov eax, 68
mov ebx, 11
int 0x40 ; -> init heap
int 0x40 ; -> create heap
 
;mov eax, 70
;mov ebx, file_info
;mov dword[ebx], 5 ; -> subfunction number
;int 0x40 ; -> read file size
;mov ebx, [fptr]
;mov ebx, dword[ebx+32]
;inc ebx
;mov [fsize], ebx
; mov eax, 70
; mov ebx, file_info
; mov dword[ebx], 5 ; -> subfunction number
; int 0x40 ; -> read file size
; mov ebx, [fptr]
; mov ebx, dword[ebx+32]
; inc ebx
; mov [fsize], ebx
 
;mov eax, 68
;mov ebx, 12
;mov ecx, [fsize]
;int 0x40 ; -> allocate memory for file
;mov [fptr], eax ; -> eax = pointer to allocated mem
 
;mov eax, 70
;mov ebx, file_info
;mov dword[ebx],0
;int 0x40 ; -> read file
;mov [fsize],ebx
;cmp eax,6
;jnz @f
;xor eax,eax ;;;;---
;cmp eax,6
;jnz @f
;xor eax,eax ;;;;---
 
;load kpacked files by Leency
; mov eax, 68
; mov ebx, 12
; mov ecx, [fsize]
; int 0x40 ; -> allocate memory for file
; mov [fptr], eax ; -> eax = pointer to allocated mem
 
mov eax,68
mov ebx,27
mov ecx,I_Param
int 0x40
; mov eax, 70
; mov ebx, file_info
; mov dword[ebx],0
; int 0x40 ; -> read file
;load kpacked files by Leency
mov eax,68
mov ebx,27
mov ecx,file_name
int 0x40
 
mov [fsize],edx
mov [file_info+16],eax
test eax,eax
jnz .open_opened_well
mov eax,6 ;otherwise => failed
jmp @f
.open_opened_well:
xor eax,eax
@@:
mov [fsize],edx
mov [file_info+16],eax
 
test eax,eax
jnz .open_opened_well
mov eax,6 ;otherwise => failed
jmp @f
.open_opened_well:
xor eax,eax
@@:
else
mov eax,58
mov ebx,file_info
3444,8 → 3446,8
; mov ecx,ebx
; add ecx,MEM_END
; mov ebx,1
; mov eax,64 ; allocate mem - resize app mem
; for points and triangles
; mov eax,64 ; allocate mem - resize app mem
; for points and triangles
int 0x40
 
mov eax,58
3454,260 → 3456,262
end if
; eax = 0 -> ok file loaded
ret
; eax = 0 -> ok file loaded
ret
read_param:
mov esi,I_Param
cmp dword[esi],0
je .end
je .end
cmp byte[esi],'/'
je .copy
je .copy
mov edi,esi
mov ecx,25 ; 25 - would be enought
mov ecx,25 ; 25 - would be enought
repe scasb
jne .end
dec edi
mov esi,edi
.copy:
mov edi,file_name
mov ecx,50
rep movsd
mov edi,file_name
mov ecx,50
rep movsd
.end:
ret
buttons: ; draw some buttons (all but navigation and close )
mov edi,menu
buttons: ; draw some buttons (all but navigation and close )
mov edi,menu
.again:
mov eax,8 ; function 8 : define and draw button
mov bx,[size_x_var]
shl ebx,16
add ebx,(10)*65536+62 ; [x start] *65536 + [x size]
movzx ecx,byte[edi] ; button id = position+2
sub cl,2
lea ecx,[ecx*5]
lea ecx,[ecx*3]
add ecx,25
shl ecx,16
add ecx,12
movzx edx,byte[edi] ; button id
mov esi,0x6688dd ; button color RRGGBB
int 0x40
; BUTTON LABEL
mov eax,4 ; function 4 : write text to window
movzx ebx,byte[edi]
sub bl,2 ; button id, according to position
lea ebx,[ebx*3]
lea ebx,[ebx*5]
mov cx,[size_x_var]
shl ecx,16
add ebx,ecx
add ebx,(12)*65536+28 ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
lea edx,[edi+1] ; pointer to text beginning
mov esi,10 ; text length
int 0x40
cmp byte[edi+11],255 ; if max_flag=255
je @f ; skip
; flag description
; mov eax,4 ; function 4 : write text to window
; movzx ebx,byte[edi]
; sub bl,2
; lea ebx,[ebx*3]
; lea ebx,[ebx*5]
; add ebx,(SIZE_X+12+70)*65536+28 ; [x start] *65536 + [y start]
add ebx,70*65536
; mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
movzx edx,byte[edi+12] ; current flag
shl edx,2 ; * 4 = text length
add edx,dword[edi+13] ; pointer to text beginning
mov esi,4 ; text length
int 0x40
mov eax,8 ; function 8 : define and draw button
mov bx,[size_x_var]
shl ebx,16
add ebx,(10)*65536+62 ; [x start] *65536 + [x size]
movzx ecx,byte[edi] ; button id = position+2
sub cl,2
lea ecx,[ecx*5]
lea ecx,[ecx*3]
add ecx,25
shl ecx,16
add ecx,12
movzx edx,byte[edi] ; button id
mov esi,0x6688dd ; button color RRGGBB
int 0x40
; BUTTON LABEL
mov eax,4 ; function 4 : write text to window
movzx ebx,byte[edi]
sub bl,2 ; button id, according to position
lea ebx,[ebx*3]
lea ebx,[ebx*5]
mov cx,[size_x_var]
shl ecx,16
add ebx,ecx
add ebx,(12)*65536+28 ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
lea edx,[edi+1] ; pointer to text beginning
mov esi,10 ; text length
int 0x40
cmp byte[edi+11],255 ; if max_flag=255
je @f ; skip
; flag description
; mov eax,4 ; function 4 : write text to window
; movzx ebx,byte[edi]
; sub bl,2
; lea ebx,[ebx*3]
; lea ebx,[ebx*5]
; add ebx,(SIZE_X+12+70)*65536+28 ; [x start] *65536 + [y start]
add ebx,70*65536
; mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
movzx edx,byte[edi+12] ; current flag
shl edx,2 ; * 4 = text length
add edx,dword[edi+13] ; pointer to text beginning
mov esi,4 ; text length
int 0x40
 
@@:
add edi,17
cmp byte[edi],-1
jnz .again
add edi,17
cmp byte[edi],-1
jnz .again
ret
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
draw_window:
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
 
; DRAW WINDOW
mov eax,0 ; function 0 : define and draw window
mov bx,[x_start]
shl ebx,16
mov cx,[y_start]
shl ecx,16
;ebx - [x start] *65536 + [x size]
;ecx - [y start] *65536 + [y size]
mov bx,[size_x_var]
add bx,115
mov cx,[size_y_var]
add cx,30
; DRAW WINDOW
mov eax,0 ; function 0 : define and draw window
mov bx,[x_start]
shl ebx,16
mov cx,[y_start]
shl ecx,16
;ebx - [x start] *65536 + [x size]
;ecx - [y start] *65536 + [y size]
mov bx,[size_x_var]
add bx,115
mov cx,[size_y_var]
add cx,30
; @@:
mov edx,0x13000000 ; color of work area RRGGBB,8->color gl
mov edi,labelt ; WINDOW LABEL
int 0x40
mov edx,0x13000000 ; color of work area RRGGBB,8->color gl
mov edi,labelt ; WINDOW LABEL
int 0x40
 
call buttons ; more buttons
call buttons ; more buttons
 
.Y_ADD equ 2 ;-> offset of 'add vector' buttons
.Y_ADD equ 2 ;-> offset of 'add vector' buttons
 
; ADD VECTOR LABEL ; add vector buttons - 30 ++
mov eax,4 ; function 4 : write text to window
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(12)*65536+(168+15*(13+.Y_ADD)) ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelvector ; pointer to text beginning
mov esi,labelvectorend-labelvector ; text length
; cmp [move_flag],2
; jne @f
; add edx,navigation_size
; ADD VECTOR LABEL ; add vector buttons - 30 ++
mov eax,4 ; function 4 : write text to window
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(12)*65536+(168+15*(13+.Y_ADD)) ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelvector ; pointer to text beginning
mov esi,labelvectorend-labelvector ; text length
; cmp [move_flag],2
; jne @f
; add edx,navigation_size
; @@:
int 0x40
; VECTOR Y- BUTTON
mov eax,8 ; function 8 : define and draw button
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,30*65536+20 ; [x start] *65536 + [x size]
mov ecx,(165+15*(14+.Y_ADD))*65536+12 ; [y start] *65536 + [y size]
mov edx,30 ; button id
mov esi,0x6688dd ; button color RRGGBB
int 0x40
;VECTOR Y- LABEL
mov eax,4 ; function 4 : write text to window
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(32)*65536+(168+15*(14+.Y_ADD)) ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelyminus ; pointer to text beginning
mov esi,labelyminusend-labelyminus ; text length
cmp [move_flag],2
; jne @f
; add edx,navigation_size
int 0x40
; VECTOR Y- BUTTON
mov eax,8 ; function 8 : define and draw button
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,30*65536+20 ; [x start] *65536 + [x size]
mov ecx,(165+15*(14+.Y_ADD))*65536+12 ; [y start] *65536 + [y size]
mov edx,30 ; button id
mov esi,0x6688dd ; button color RRGGBB
int 0x40
;VECTOR Y- LABEL
mov eax,4 ; function 4 : write text to window
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(32)*65536+(168+15*(14+.Y_ADD)) ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelyminus ; pointer to text beginning
mov esi,labelyminusend-labelyminus ; text length
cmp [move_flag],2
; jne @f
; add edx,navigation_size
; @@:
int 0x40
; VECTOR Z+ BUTTON
mov eax,8 ; function 8 : define and draw button
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(51)*65536+21 ; [x start] *65536 + [x size]
mov ecx,(165+15*(14+.Y_ADD))*65536+12 ; [y start] *65536 + [y size]
mov edx,31 ; button id
mov esi,0x6688dd ; button color RRGGBB
int 0x40
;VECTOR Z+ LABEL
mov eax,4 ; function 4 : write text to window
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(53)*65536+(168+15*(14+.Y_ADD)) ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelzplus ; pointer to text beginning
mov esi,labelzplusend-labelzplus ; text length
; cmp [move_flag],2
; jne @f
; add edx,navigation_size
int 0x40
; VECTOR Z+ BUTTON
mov eax,8 ; function 8 : define and draw button
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(51)*65536+21 ; [x start] *65536 + [x size]
mov ecx,(165+15*(14+.Y_ADD))*65536+12 ; [y start] *65536 + [y size]
mov edx,31 ; button id
mov esi,0x6688dd ; button color RRGGBB
int 0x40
;VECTOR Z+ LABEL
mov eax,4 ; function 4 : write text to window
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(53)*65536+(168+15*(14+.Y_ADD)) ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelzplus ; pointer to text beginning
mov esi,labelzplusend-labelzplus ; text length
; cmp [move_flag],2
; jne @f
; add edx,navigation_size
; @@:
 
int 0x40
; VECTOR x- BUTTON
mov eax,8 ; function 8 : define and draw button
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(10)*65536+21 ; [x start] *65536 + [x size]
mov ecx,(165+15*(15+.Y_ADD))*65536+12 ; [y start] *65536 + [y size]
mov edx,32 ; button id
mov esi,0x6688dd ; button color RRGGBB
int 0x40
;VECTOR x- LABEL
mov eax,4 ; function 4 : write text to window
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(12)*65536+(168+15*(15+.Y_ADD)) ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelxminus ; pointer to text beginning
mov esi,labelxminusend-labelxminus ; text length
; cmp [move_flag],2
; jne @f
; add edx,navigation_size
int 0x40
; VECTOR x- BUTTON
mov eax,8 ; function 8 : define and draw button
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(10)*65536+21 ; [x start] *65536 + [x size]
mov ecx,(165+15*(15+.Y_ADD))*65536+12 ; [y start] *65536 + [y size]
mov edx,32 ; button id
mov esi,0x6688dd ; button color RRGGBB
int 0x40
;VECTOR x- LABEL
mov eax,4 ; function 4 : write text to window
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(12)*65536+(168+15*(15+.Y_ADD)) ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelxminus ; pointer to text beginning
mov esi,labelxminusend-labelxminus ; text length
; cmp [move_flag],2
; jne @f
; add edx,navigation_size
; @@:
int 0x40
; VECTOR x+ BUTTON
mov eax,8 ; function 8 : define and draw button
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(51)*65536+21 ; [x start] *65536 + [x size]
mov ecx,(165+15*(15+.Y_ADD))*65536+12 ; [y start] *65536 + [y size]
mov edx,33 ; button id
mov esi,0x6688dd ; button color RRGGBB
int 0x40
;VECTOR x+ LABEL
mov eax,4 ; function 4 : write text to window
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(53)*65536+(168+15*(15+.Y_ADD)) ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelxplus ; pointer to text beginning
mov esi,labelxplusend-labelxplus ; text length
; cmp [move_flag],2
; jne @f
; add edx,navigation_size
int 0x40
; VECTOR x+ BUTTON
mov eax,8 ; function 8 : define and draw button
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(51)*65536+21 ; [x start] *65536 + [x size]
mov ecx,(165+15*(15+.Y_ADD))*65536+12 ; [y start] *65536 + [y size]
mov edx,33 ; button id
mov esi,0x6688dd ; button color RRGGBB
int 0x40
;VECTOR x+ LABEL
mov eax,4 ; function 4 : write text to window
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(53)*65536+(168+15*(15+.Y_ADD)) ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelxplus ; pointer to text beginning
mov esi,labelxplusend-labelxplus ; text length
; cmp [move_flag],2
; jne @f
; add edx,navigation_size
; @@:
int 0x40
; VECTOR z- BUTTON
mov eax,8 ; function 8 : define and draw button
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(10)*65536+62-41 ; [x start] *65536 + [x size]
mov ecx,(25+140+15*(16+.Y_ADD))*65536+12 ; [y start] *65536 + [y size]
mov edx,34 ; button id
mov esi,0x6688dd ; button color RRGGBB
int 0x40
;VECTOR z- LABEL
mov eax,4 ; function 4 : write text to window
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(12)*65536+(168+15*(16+.Y_ADD)) ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelzminus ; pointer to text beginning
mov esi,labelzminusend-labelzminus ; text length
; cmp [move_flag],2
; jne @f
; add edx,navigation_size
int 0x40
; VECTOR z- BUTTON
mov eax,8 ; function 8 : define and draw button
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(10)*65536+62-41 ; [x start] *65536 + [x size]
mov ecx,(25+140+15*(16+.Y_ADD))*65536+12 ; [y start] *65536 + [y size]
mov edx,34 ; button id
mov esi,0x6688dd ; button color RRGGBB
int 0x40
;VECTOR z- LABEL
mov eax,4 ; function 4 : write text to window
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(12)*65536+(168+15*(16+.Y_ADD)) ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelzminus ; pointer to text beginning
mov esi,labelzminusend-labelzminus ; text length
; cmp [move_flag],2
; jne @f
; add edx,navigation_size
; @@:
int 0x40
int 0x40
;VECTOR Y+ BUTTON
mov eax,8 ; function 8 : define and draw button
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(10+20)*65536+20 ; [x start] *65536 + [x size]
mov ecx,(165+15*(16+.Y_ADD))*65536+12 ; [y start] *65536 + [y size]
mov edx,35 ; button id
mov esi,0x6688dd ; button color RRGGBB
int 0x40
;VECTOR Y+ LABEL
mov eax,4 ; function 4 : write text to window
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(32)*65536+(168+15*(16+.Y_ADD)) ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelyplus ; pointer to text beginning
mov esi,labelyplusend-labelyplus ; text length
; cmp [move_flag],2
; jne @f
; add edx,navigation_size
mov eax,8 ; function 8 : define and draw button
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(10+20)*65536+20 ; [x start] *65536 + [x size]
mov ecx,(165+15*(16+.Y_ADD))*65536+12 ; [y start] *65536 + [y size]
mov edx,35 ; button id
mov esi,0x6688dd ; button color RRGGBB
int 0x40
;VECTOR Y+ LABEL
mov eax,4 ; function 4 : write text to window
movzx ebx,word[size_x_var]
shl ebx,16
add ebx,(32)*65536+(168+15*(16+.Y_ADD)) ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB )
mov edx,labelyplus ; pointer to text beginning
mov esi,labelyplusend-labelyplus ; text length
; cmp [move_flag],2
; jne @f
; add edx,navigation_size
; @@:
int 0x40
int 0x40
 
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
ret
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
ret
 
 
; DATA AREA ************************************
; DATA AREA ************************************
 
include 'DATA.INC'
align 16