diff --git a/programs/demos/3DS/3DMATH.INC b/programs/demos/3DS/3DMATH.INC index ea6628e06c..5b26dc288f 100644 --- a/programs/demos/3DS/3DMATH.INC +++ b/programs/demos/3DS/3DMATH.INC @@ -13,18 +13,18 @@ vec_z equ 8 ;---------------------- 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 @@ reverse_mx_3x3: ; 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 @@ reverse_mx_3x3: 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 @@ ret ;--------------------------- 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 @@ ret ;------------------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 @@ ret ; 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 @@ ret 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 diff --git a/programs/demos/3DS/ASC.INC b/programs/demos/3DS/ASC.INC index 15ba59609c..8a81af1432 100644 --- a/programs/demos/3DS/ASC.INC +++ b/programs/demos/3DS/ASC.INC @@ -31,7 +31,7 @@ read_asc: 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 @@ read_asc: 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 @@ read_asc: 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 @@ read_asc: 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 @@ read_asc: 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 diff --git a/programs/demos/3DS/A_PROCS.INC b/programs/demos/3DS/A_PROCS.INC index c072e328b5..0d0e8152e5 100644 --- a/programs/demos/3DS/A_PROCS.INC +++ b/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 @@ else 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 @@ else ; add eax,ebx - and eax, 0x000000ff + and eax, 0x000000ff ; cdq ; mul [sin_frq] @@ -61,79 +61,79 @@ else ; 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,55 +176,55 @@ if Ext >= SSE2 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 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 @@ if 0 ; old emb proc ; 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 @@ if Ext=NON ;; 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 @@ generate_object2: ; torus ; 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 @@ generate_object3: ; heart ; 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 + diff --git a/programs/demos/3DS/BUMP3.INC b/programs/demos/3DS/BUMP3.INC deleted file mode 100644 index 23e3b9abd6..0000000000 --- a/programs/demos/3DS/BUMP3.INC +++ /dev/null @@ -1,630 +0,0 @@ -;------- Big thanks to majuma (www.majuma.xt.pl) for absolutelly great-- -;------- 13h mode demos ------------------------------------------------ - -bump_triangle: -;------------------in - eax - x1 shl 16 + y1 ----------- -;---------------------- ebx - x2 shl 16 + y2 ----------- -;---------------------- ecx - x3 shl 16 + y3 ----------- -;---------------------- edx - pointer to bump map ------ -;---------------------- esi - pointer to environment map -;---------------------- edi - pointer to screen buffer-- -;---------------------- stack : bump coordinates-------- -;---------------------- environment coordinates- -.b_x1 equ ebp+4 ; procedure don't save registers !!! -.b_y1 equ ebp+6 ; each coordinate as word -.b_x2 equ ebp+8 -.b_y2 equ ebp+10 -.b_x3 equ ebp+12 -.b_y3 equ ebp+14 -.e_x1 equ ebp+16 -.e_y1 equ ebp+18 -.e_x2 equ ebp+20 -.e_y2 equ ebp+22 -.e_x3 equ ebp+24 -.e_y3 equ ebp+26 - -.t_bmap equ dword[ebp-4] -.t_emap equ dword[ebp-8] -.x1 equ word[ebp-10] -.y1 equ word[ebp-12] -.x2 equ word[ebp-14] -.y2 equ word[ebp-16] -.x3 equ word[ebp-18] -.y3 equ word[ebp-20] - -.dx12 equ dword[ebp-24] -.dbx12 equ dword[ebp-28] -.dby12 equ dword[ebp-32] -.dex12 equ dword[ebp-36] -.dey12 equ dword[ebp-40] - -.dx13 equ dword[ebp-44] -.dbx13 equ dword[ebp-48] -.dby13 equ dword[ebp-52] -.dex13 equ dword[ebp-56] -.dey13 equ dword[ebp-60] - -.dx23 equ dword[ebp-64] -.dbx23 equ dword[ebp-68] -.dby23 equ dword[ebp-72] -.dex23 equ dword[ebp-76] -.dey23 equ dword[ebp-80] - -.cx1 equ dword[ebp-84] ; current variables -.cx2 equ dword[ebp-88] -.cbx1 equ dword[ebp-92] -.cbx2 equ dword[ebp-96] -.cby1 equ dword[ebp-100] -.cby2 equ dword[ebp-104] -.cex1 equ dword[ebp-108] -.cex2 equ dword[ebp-112] -.cey1 equ dword[ebp-116] -.cey2 equ dword[ebp-120] - - mov ebp,esp - push edx ; store bump map - push esi ; store e. map - ; sub esp,120 - .sort3: ; sort triangle coordinates... - cmp ax,bx - jle .sort1 - xchg eax,ebx - mov edx,dword[.b_x1] - xchg edx,dword[.b_x2] - mov dword[.b_x1],edx - mov edx,dword[.e_x1] - xchg edx,dword[.e_x2] - mov dword[.e_x1],edx - .sort1: - cmp bx,cx - jle .sort2 - xchg ebx,ecx - mov edx,dword[.b_x2] - xchg edx,dword[.b_x3] - mov dword[.b_x2],edx - mov edx,dword[.e_x2] - xchg edx,dword[.e_x3] - mov dword[.e_x2],edx - jmp .sort3 - .sort2: - push eax ; store triangle coords in variables - push ebx - push ecx - - mov edx,eax ; eax,ebx,ecx are ORd together into edx which means that - or edx,ebx ; if any *one* of them is negative a sign flag is raised - or edx,ecx - test edx,80000000h ; Check only X - jne .loop23_done - - mov dx,[size_x_var] - cmp .x1,dx ;SIZE_X ; { - jg .loop23_done - cmp .x2,dx ;SIZE_X ; This can be optimized with effort - jg .loop23_done - cmp .x3,dx ;SIZE_X - jg .loop23_done ; { - - - mov bx,.y2 ; calc delta 12 - sub bx,.y1 - jnz .bt_dx12_make - mov ecx,5 - xor edx,edx - @@: - push edx ;dword 0 - loop @b - jmp .bt_dx12_done - .bt_dx12_make: - mov ax,.x2 - sub ax,.x1 - cwde - movsx ebx,bx - shl eax,ROUND - cdq - idiv ebx - ; mov .dx12,eax - push eax - - mov ax,word[.b_x2] - sub ax,word[.b_x1] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dbx12,eax - push eax - - mov ax,word[.b_y2] - sub ax,word[.b_y1] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dby12,eax - push eax - - mov ax,word[.e_x2] - sub ax,word[.e_x1] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dex12,eax - push eax - - mov ax,word[.e_y2] - sub ax,word[.e_y1] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dey12,eax - push eax - .bt_dx12_done: - - mov bx,.y3 ; calc delta13 - sub bx,.y1 - jnz .bt_dx13_make - mov ecx,5 - xor edx,edx - @@: - push edx ;dword 0 - loop @b - jmp .bt_dx13_done - .bt_dx13_make: - mov ax,.x3 - sub ax,.x1 - cwde - movsx ebx,bx - shl eax,ROUND - cdq - idiv ebx - ; mov .dx13,eax - push eax - - mov ax,word[.b_x3] - sub ax,word[.b_x1] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dbx13,eax - push eax - - mov ax,word[.b_y3] - sub ax,word[.b_y1] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dby13,eax - push eax - - mov ax,word[.e_x3] - sub ax,word[.e_x1] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dex13,eax - push eax - - mov ax,word[.e_y3] - sub ax,word[.e_y1] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dey13,eax - push eax - .bt_dx13_done: - - mov bx,.y3 ; calc delta23 - sub bx,.y2 - jnz .bt_dx23_make - mov ecx,5 - xor edx,edx - @@: - push edx ;dword 0 - loop @b - jmp .bt_dx23_done - .bt_dx23_make: - mov ax,.x3 - sub ax,.x2 - cwde - movsx ebx,bx - shl eax,ROUND - cdq - idiv ebx - ; mov .dx23,eax - push eax - - mov ax,word[.b_x3] - sub ax,word[.b_x2] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dbx23,eax - push eax - - mov ax,word[.b_y3] - sub ax,word[.b_y2] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dby23,eax - push eax - - mov ax,word[.e_x3] - sub ax,word[.e_x2] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dex23,eax - push eax - - mov ax,word[.e_y3] - sub ax,word[.e_y2] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dey23,eax - push eax - - ; sub esp,40 - .bt_dx23_done: - - movsx eax,.x1 - shl eax,ROUND - ; mov .cx1,eax - ; mov .cx2,eax - push eax - push eax - - movsx eax,word[.b_x1] - shl eax,ROUND - ; mov .cbx1,eax - ; mov .cbx2,eax - push eax - push eax - - movsx eax,word[.b_y1] - shl eax,ROUND - ; mov .cby1,eax - ; mov .cby2,eax - push eax - push eax - - movsx eax,word[.e_x1] - shl eax,ROUND - ;mov .cex1,eax - ;mov .cex2,eax - push eax - push eax - - movsx eax,word[.e_y1] - shl eax,ROUND - ;mov .cey1,eax - ;mov .cey2,eax - push eax - push eax - - movzx ecx,.y1 - cmp cx,.y2 - jge .loop12_done - .loop12: - call .call_bump_line - - mov eax,.dx13 - add .cx1,eax - mov eax,.dx12 - add .cx2,eax - - mov eax,.dbx13 - add .cbx1,eax - mov eax,.dbx12 - add .cbx2,eax - mov eax,.dby13 - add .cby1,eax - mov eax,.dby12 - add .cby2,eax - - mov eax,.dex13 - add .cex1,eax - mov eax,.dex12 - add .cex2,eax - mov eax,.dey13 - add .cey1,eax - mov eax,.dey12 - add .cey2,eax - - inc ecx - cmp cx,.y2 - jl .loop12 - .loop12_done: - movzx ecx,.y2 - cmp cx,.y3 - jge .loop23_done - - movzx eax,.x2 - shl eax,ROUND - mov .cx2,eax - - movzx eax,word[.b_x2] - shl eax,ROUND - mov .cbx2,eax - - movzx eax,word[.b_y2] - shl eax,ROUND - mov .cby2,eax - - movzx eax,word[.e_x2] - shl eax,ROUND - mov .cex2,eax - - movzx eax,word[.e_y2] - shl eax,ROUND - mov .cey2,eax - - .loop23: - call .call_bump_line - - mov eax,.dx13 - add .cx1,eax - mov eax,.dx23 - add .cx2,eax - - mov eax,.dbx13 - add .cbx1,eax - mov eax,.dbx23 - add .cbx2,eax - mov eax,.dby13 - add .cby1,eax - mov eax,.dby23 - add .cby2,eax - - mov eax,.dex13 - add .cex1,eax - mov eax,.dex23 - add .cex2,eax - mov eax,.dey13 - add .cey1,eax - mov eax,.dey23 - add .cey2,eax - - inc ecx - cmp cx,.y3 - jl .loop23 - .loop23_done: - mov esp,ebp -ret 24 - -.call_bump_line: - - ; push ebp - ; push ecx - pushad - - push .t_emap - push .t_bmap - push .cey2 - push .cex2 - push .cey1 - push .cex1 - push .cby2 - push .cbx2 - push .cby1 - push .cbx1 - push ecx - - mov eax,.cx1 - sar eax,ROUND - mov ebx,.cx2 - sar ebx,ROUND - - call bump_line - - popad -ret -bump_line: -;--------------in: eax - x1 -;-------------- ebx - x2 -;-------------- edi - pointer to screen buffer -;stack - another parameters : -.y equ dword [ebp+4] -.bx1 equ [ebp+8] ; --- -.by1 equ dword [ebp+12] ; | -.bx2 equ [ebp+16] ; | -.by2 equ dword [ebp+20] ; |> bump and env coords -.ex1 equ [ebp+24] ; |> shifted shl ROUND -.ey1 equ dword [ebp+28] ; | -.ex2 equ [ebp+32] ; | -.ey2 equ dword [ebp+36] ; --- -.bmap equ dword [ebp+40] -.emap equ dword [ebp+44] - -.x1 equ dword [ebp-4] -.x2 equ dword [ebp-8] -.dbx equ dword [ebp-12] -.dby equ [ebp-16] -.dex equ dword [ebp-20] -.dey equ [ebp-24] -.cbx equ dword [ebp-28] -.cby equ [ebp-32] -.cex equ dword [ebp-36] -.cey equ [ebp-40] - mov ebp,esp - - mov ecx,.y - or ecx,ecx - jl .bl_end - movzx edx,word[size_y_var] - cmp ecx,edx ;SIZE_Y - jge .bl_end - - cmp eax,ebx - jl .bl_ok - je .bl_end - - xchg eax,ebx -if Ext = NON - mov edx,.bx1 - xchg edx,.bx2 - mov .bx1,edx - mov edx,.by1 - xchg edx,.by2 - mov .by1,edx - - mov edx,.ex1 - xchg edx,.ex2 - mov .ex1,edx - mov edx,.ey1 - xchg edx,.ey2 - mov .ey1,edx -else - movq mm0,.bx1 - movq mm1,.bx2 - movq mm2,.ex1 - movq mm3,.ex2 - movq .bx2,mm0 - movq .bx1,mm1 - movq .ex1,mm3 - movq .ex2,mm2 -end if - .bl_ok: - push eax - push ebx ;store x1, x2 - movzx eax,word[size_x_var] - lea eax,[eax*3] - - ; mov eax,SIZE_X*3 - mov ebx,.y - mul ebx - mov ecx,.x1 - lea ecx,[ecx*3] - add eax,ecx - add edi,eax - - mov ecx,.x2 - sub ecx,.x1 - - mov eax,.bx2 ; calc .dbx - sub eax,.bx1 - cdq - idiv ecx - push eax - - mov eax,.by2 ; calc .dby - sub eax,.by1 - cdq - idiv ecx - push eax - - mov eax,.ex2 ; calc .dex - sub eax,.ex1 - cdq - idiv ecx - push eax - - mov eax,.ey2 ; calc .dey - sub eax,.ey1 - cdq - idiv ecx - push eax - - push dword .bx1 - push .by1 - push dword .ex1 - push .ey1 - .draw: - ; if TEX = SHIFTING ;bump drawing only in shifting mode - - mov eax,.cby - sar eax,ROUND - shl eax,TEX_SHIFT - mov esi,.cbx - sar esi,ROUND - add esi,eax - - mov ebx,esi - dec ebx - and ebx,TEXTURE_SIZE - add ebx,.bmap - movzx eax,byte [ebx] - - mov ebx,esi - inc ebx - and ebx,TEXTURE_SIZE - add ebx,.bmap - movzx ebx,byte [ebx] - sub eax,ebx - - mov ebx,esi - sub ebx,TEX_X - and ebx,TEXTURE_SIZE - add ebx,.bmap - movzx edx,byte [ebx] - - mov ebx,esi - add ebx,TEX_X - and ebx,TEXTURE_SIZE - add ebx,.bmap - movzx ebx,byte [ebx] - sub edx,ebx - - mov ebx,.cex ;.cex - current env map X - sar ebx,ROUND - add eax,ebx ; eax - modified x coord - - mov ebx,.cey ;.cey - current env map y - sar ebx,ROUND - add edx,ebx ; edx - modified y coord - - or eax,eax - jl .black - cmp eax,TEX_X - jg .black - or edx,edx - jl .black - cmp edx,TEX_Y - jg .black - - shl edx,TEX_SHIFT - add edx,eax - lea edx,[edx*3] - add edx,.emap - mov eax,dword[edx] - jmp .put_pixel - .black: - xor eax,eax - .put_pixel: - stosd - dec edi -;if Ext >= MMX -; movq mm0,.cby -; movq mm1,.cey -; paddd mm0,.dby -; paddd mm1,.dey -; movq .cby,mm0 -; movq .cey,mm1 -;else - mov eax,.dbx - add .cbx,eax - mov eax,.dby - add .cby,eax - mov eax,.dex - add .cex,eax - mov eax,.dey - add .cey,eax -;end if - dec ecx - jnz .draw - ; end if - .bl_end: - mov esp,ebp -ret 44 \ No newline at end of file diff --git a/programs/demos/3DS/B_PROCS.INC b/programs/demos/3DS/B_PROCS.INC index 006419ef88..5c5c53a574 100644 --- a/programs/demos/3DS/B_PROCS.INC +++ b/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 @@ calc_one_col: ; 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 @@ calc_one_col: ; 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 @@ calc_bumpmap: ; calculate random bumpmap ; 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 @@ optimize_object1: ; setting point (0,0,0) in center of object .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 @@ generate_object: ; generate node @@: ; 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,687 +576,684 @@ generate_object: ; generate node 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 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 @@ calc_attenuation_light: ;; calculate point to spot_light distance ; 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//////////////////////////////////// \ No newline at end of file diff --git a/programs/demos/3DS/DATA.INC b/programs/demos/3DS/DATA.INC index 06a25874ae..e1ad25daca 100644 --- a/programs/demos/3DS/DATA.INC +++ b/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 @@ align 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 @@ align 8 ;=== - 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 ? diff --git a/programs/demos/3DS/FLAT3.INC b/programs/demos/3DS/FLAT3.INC deleted file mode 100644 index aa33310410..0000000000 --- a/programs/demos/3DS/FLAT3.INC +++ /dev/null @@ -1,209 +0,0 @@ -draw_triangle: - ;----------in - eax - x1 shl 16 + y1 - ;------------- -ebx - x2 shl 16 + y2 - ;---------------ecx - x3 shl 16 + y3 - ;---------------edx - color 0x00rrggbb - ;---------------edi - pointer to screen buffer - - .col equ ebp-4 ;dd ? - .x1 equ ebp-6 ;dw ? - .y1 equ ebp-8 ;dw ?;+8 - .x2 equ ebp-10 ;dw ? - .y2 equ ebp-12 ;dw ? - .x3 equ ebp-14 ;dw ? - .y3 equ ebp-16 ;dw ?;+16 - .dx12 equ ebp-20 ; dd ? - .dx13 equ ebp-24 ; dd ?;+24 - .dx23 equ ebp-28 ; dd ? - - mov ebp,esp - ; sub esp,28 - push edx - .ch3: - cmp ax,bx - jg .ch1 - .ch4: ; sort parameters - cmp bx,cx - jg .ch2 - jle .chEnd - .ch1: - xchg eax,ebx - jmp .ch4 - .ch2: - xchg ebx,ecx - jmp .ch3 - .chEnd: - ; mov dword[.y1],eax ; ..and store to user friendly variables - ; mov dword[.y2],ebx - ; mov dword[.y3],ecx - ; mov [.col],edx - push eax - push ebx - push ecx - sub esp,12 - mov edx,eax ; eax,ebx,ecx are ORd together into edx which means that - or edx,ebx ; if any *one* of them is negative a sign flag is raised - or edx,ecx - test edx,80008000h ; Check both X&Y at once - jne .end_triangle - - mov dx,[size_x_var] - cmp word[.x1],dx ;SIZE_X ; { - jg .end_triangle - cmp word[.x2],dx ;SIZE_X ; This can be optimized with effort - jg .end_triangle - cmp word[.x3],dx ;SIZE_X - jg .end_triangle ; } - - shr eax,16 - shr ebx,16 - shr ecx,16 - - neg ax ; calculate delta 12 - add ax,bx - cwde - shl eax,ROUND - cdq - mov bx,[.y2] - mov cx,[.y1] - sub bx,cx - ;cmp ebx,0 - jne .noZero1 - mov dword[.dx12],0 - jmp .yesZero1 - .noZero1: - idiv ebx - mov [.dx12],eax - .yesZero1: - - mov ax,[.x3] ; calculate delta 13 - sub ax,[.x1] - cwde - shl eax,ROUND - cdq - mov bx,[.y3] - mov cx,[.y1] - sub bx,cx - ;cmp ebx,0 - jne .noZero2 - mov dword[.dx13],0 - jmp .yesZero2 - .noZero2: - idiv ebx - mov [.dx13],eax - .yesZero2: - - mov ax,[.x3] ; calculate delta 23 [dx23] - sub ax,[.x2] - cwde - shl eax,ROUND - cdq - mov bx,[.y3] - mov cx,[.y2] - sub bx,cx - ;cmp ebx,0 - jne .noZero3 - mov dword[.dx23],0 - jmp .yesZero3 - .noZero3: - idiv ebx - mov [.dx23],eax - .yesZero3: - - movsx eax,word[.x1] ; eax - xk1 ;;; - shl eax,ROUND - mov ebx,eax ; ebx - xk2 ;;; - movsx esi,word[.y1] ; esi - y - .next_line1: - mov ecx,eax ; ecx - x11 - sar ecx,ROUND - mov edx,ebx ; edx - x12 - sar edx,ROUND - cmp ecx,edx - jle .nochg - xchg ecx,edx - .nochg: - pusha - mov ebx,ecx - sub edx,ecx - mov ecx,edx - mov edx,esi - mov eax,[.col] - call .horizontal_line - popa - add eax,[.dx13] - add ebx,[.dx12] - inc esi - cmp si,[.y2] - jl .next_line1 - - movzx esi,word[.y2] - movzx ebx,word[.x2] - shl ebx,ROUND - .next_line2: - mov ecx,eax - sar ecx,ROUND - mov edx,ebx - sar edx,ROUND - cmp ecx,edx - jle .nochg1 - xchg ecx,edx - .nochg1: - pusha - mov ebx,ecx - sub edx,ecx - mov ecx,edx - mov edx,esi - mov eax,[.col] - call .horizontal_line - popa - add eax,[.dx13] - add ebx,[.dx23] - inc esi - cmp si,[.y3] - jl .next_line2 - .end_triangle: - - mov esp,ebp -ret - -.horizontal_line: - ;---------in - ;---------eax - color of line, 0x00RRGGBB - ;---------ebx - x1 - x position of line begin - ;---------ecx - lenght of line - ;---------edx - y position of line - ;---------edi - pointer to buffer - jcxz .end_hor_l -; or edx,edx -; jl .end_hor_l - movzx esi,word[size_y_var] - cmp edx,esi ;SIZE_Y - jg .end_hor_l - push eax - movzx eax,word[size_x_var] - lea eax,[eax*3] - ; mov eax,SIZE_X*3 - mul edx - add edi,eax ; calculate line begin adress - ;add edi,ebx - ;shl ebx,1 - lea edi,[edi+ebx*2] - add edi,ebx - pop eax - cld - ;mov dword[edi-3],0000FF00h - dec ecx - jecxz .last_pix - .ddraw: ; Drawing horizontally: - ;push eax - stosd ; 4 bytes at a time - dec edi ; point to the 4th - loop .ddraw - .last_pix: - stosw - shr eax,16 - stosb -; mov byte[edi],0 ; The last 4th will be reset - .end_hor_l: -ret diff --git a/programs/demos/3DS/GRD3.INC b/programs/demos/3DS/GRD3.INC deleted file mode 100644 index 74ec620db3..0000000000 --- a/programs/demos/3DS/GRD3.INC +++ /dev/null @@ -1,697 +0,0 @@ -gouraud_triangle: -;------------------in - eax - x1 shl 16 + y1 --------- -;---------------------- ebx - x2 shl 16 + y2 --------- -;---------------------- ecx - x3 shl 16 + y3 --------- -;---------------------- edi - pointer to screen buffer -;---------------------- stack : colors---------------- -;----------------- procedure don't save registers !!-- -.col1r equ ebp+4 ; each color as word -.col1g equ ebp+6 -.col1b equ ebp+8 -.col2r equ ebp+10 -.col2g equ ebp+12 -.col2b equ ebp+14 -.col3r equ ebp+16 -.col3g equ ebp+18 -.col3b equ ebp+20 - -.x1 equ word[ebp-2] -.y1 equ word[ebp-4] -.x2 equ word[ebp-6] -.y2 equ word[ebp-8] -.x3 equ word[ebp-10] -.y3 equ word[ebp-12] - -.dx12 equ dword[ebp-16] -.dc12r equ dword[ebp-20] -.dc12g equ [ebp-24] -.dc12b equ dword[ebp-28] -.dx13 equ dword[ebp-32] -.dc13r equ dword[ebp-36] -.dc13g equ [ebp-40] -.dc13b equ dword[ebp-44] -.dx23 equ dword[ebp-48] -.dc23r equ dword[ebp-52] -.dc23g equ [ebp-56] -.dc23b equ dword[ebp-60] - -.c1r equ dword[ebp-64] -.c1g equ [ebp-68] -.c1b equ dword[ebp-72] -.c2r equ dword[ebp-76] -.c2g equ [ebp-80] -.c2b equ dword[ebp-84] - - - mov ebp,esp -; sub esp,72 - - .sort3: ; sort triangle coordinates... - cmp ax,bx - jle .sort1 - xchg eax,ebx - mov edx,dword[.col1r] - xchg edx,dword[.col2r] - mov dword[.col1r],edx - mov dx,word[.col1b] - xchg dx,word[.col2b] - mov word[.col1b],dx - .sort1: - cmp bx,cx - jle .sort2 - xchg ebx,ecx - mov edx,dword[.col2r] - xchg edx,dword[.col3r] - mov dword[.col2r],edx - mov dx,word[.col2b] - xchg dx,word[.col3b] - mov word[.col2b],dx - jmp .sort3 - .sort2: - push eax ;store triangle coordinates in user friendly variables - push ebx - push ecx - ; sub esp,72 ; set correctly value of esp - - mov edx,eax ; check only X triangle coordinate - or edx,ebx - or edx,ecx - test edx,80000000h - jne .gt_loop2_end - - mov dx,[size_x_var] - dec dx - shr eax,16 - cmp ax,dx ;SIZE_X-1 - jg .gt_loop2_end - shr ebx,16 - cmp bx,dx ;SIZE_X-1 - jg .gt_loop2_end - shr ecx,16 - cmp cx,dx ;SIZE_X-1 - jg .gt_loop2_end - - - mov bx,.y2 ; calc deltas - sub bx,.y1 - jnz .gt_dx12_make - xor edx,edx - mov ecx,4 - @@: - push edx - loop @b - ; mov .dx12,0 - ; mov .dc12r,0 - ; mov .dc12g,0 - ; mov .dc12b,0 - jmp .gt_dx12_done - .gt_dx12_make: - - mov ax,.x2 - sub ax,.x1 - cwde - movsx ebx,bx - shl eax,ROUND - cdq - idiv ebx - ; mov .dx12,eax - push eax - - mov ax,word[.col2r] - sub ax,word[.col1r] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dc12r,eax - push eax - - mov ax,word[.col2g] - sub ax,word[.col1g] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dc12g,eax - push eax - - mov ax,word[.col2b] - sub ax,word[.col1b] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dc12b,eax - push eax -.gt_dx12_done: - mov bx,.y3 - sub bx,.y1 - jnz .gt_dx13_make - xor edx,edx - mov ecx,4 - @@: - push edx - loop @b - ; mov .dx13,0 - ; mov .dc13r,0 - ; mov .dc13g,0 - ; mov .dc13b,0 - jmp .gt_dx13_done -.gt_dx13_make: - mov ax,.x3 - sub ax,.x1 - cwde - movsx ebx,bx - shl eax,ROUND - cdq - idiv ebx - ; mov .dx13,eax - push eax - - mov ax,word[.col3r] - sub ax,word[.col1r] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dc13r,eax - push eax - - mov ax,word[.col3g] - sub ax,word[.col1g] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dc13g,eax - push eax - mov ax,word[.col3b] - sub ax,word[.col1b] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dc13b,eax - push eax -.gt_dx13_done: - mov bx,.y3 - sub bx,.y2 - jnz .gt_dx23_make - xor edx,edx - mov ecx,4 - @@: - push edx - loop @b - ; mov .dx23,0 - ; mov .dc23r,0 - ; mov .dc23g,0 - ; mov .dc23b,0 - jmp .gt_dx23_done -.gt_dx23_make: - mov ax,.x3 - sub ax,.x2 - cwde - movsx ebx,bx - shl eax,ROUND - cdq - idiv ebx - ; mov .dx23,eax - push eax - - mov ax,word[.col3r] - sub ax,word[.col2r] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dc23r,eax - push eax - - - mov ax,word[.col3g] - sub ax,word[.col2g] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dc23g,eax - push eax - - mov ax,word[.col3b] - sub ax,word[.col2b] - cwde - shl eax,ROUND - cdq - idiv ebx - ; mov .dc23b,eax - push eax - -.gt_dx23_done: - sub esp,24 - movsx eax,.x1 - shl eax,ROUND - mov ebx,eax - movsx edx,word[.col1r] - shl edx,ROUND - mov .c1r,edx - mov .c2r,edx - movsx edx,word[.col1g] - shl edx,ROUND - mov .c1g,edx - mov .c2g,edx - movsx edx,word[.col1b] - shl edx,ROUND - mov .c1b,edx - mov .c2b,edx - mov cx,.y1 - cmp cx,.y2 - jge .gt_loop1_end -.gt_loop1: - push eax ; eax - cur x1 - push ebx ; ebx - cur x2 - push cx ; cx - cur y - push edi - push ebp - - sar ebx,ROUND - push bx - mov edx,.c2r ; c2r,c2g,c2b,c1r,c1g,c1b - current colors - sar edx,ROUND - push dx - mov edx,.c2g - sar edx,ROUND - push dx - mov edx,.c2b - sar edx,ROUND - push dx - - sar eax,ROUND - push ax - mov edx,.c1r - sar edx,ROUND - push dx - mov edx,.c1g - sar edx,ROUND - push dx - mov edx,.c1b - sar edx,ROUND - push dx - push cx - call gouraud_line - - pop ebp - pop edi - pop cx - pop ebx - pop eax - -if Ext >= MMX - movq mm0,.c1g - paddd mm0,.dc13g - movq .c1g,mm0 -else - mov edx,.dc13r - add .c1r,edx - mov edx,.dc13g - add .c1g,edx -end if - mov edx,.dc13b - add .c1b,edx -if Ext >= MMX - movq mm0,.c2g - paddd mm0,.dc12g - movq .c2g,mm0 -else - mov edx,.dc12r - add .c2r,edx - mov edx,.dc12g - add .c2g,edx -end if - mov edx,.dc12b - add .c2b,edx - - add eax,.dx13 - add ebx,.dx12 - inc cx - cmp cx,.y2 - jl .gt_loop1 -.gt_loop1_end: - - mov cx,.y2 - cmp cx,.y3 - jge .gt_loop2_end - movsx ebx,.x2 - shl ebx,ROUND - - movsx edx,word[.col2r] - shl edx,ROUND - mov .c2r,edx - movsx edx,word[.col2g] - shl edx,ROUND - mov .c2g,edx - movsx edx,word[.col2b] - shl edx,ROUND - mov .c2b,edx -.gt_loop2: - push eax ; eax - cur x1 - push ebx ; ebx - cur x2 - push cx - push edi - push ebp - - sar ebx,ROUND - push bx - mov edx,.c2r - sar edx,ROUND - push dx - mov edx,.c2g - sar edx,ROUND - push dx - mov edx,.c2b - sar edx,ROUND - push dx - - sar eax,ROUND - push ax - mov edx,.c1r - sar edx,ROUND - push dx - mov edx,.c1g - sar edx,ROUND - push dx - mov edx,.c1b - sar edx,ROUND - push dx - push cx - call gouraud_line - - pop ebp - pop edi - pop cx - pop ebx - pop eax - -if Ext >= MMX - movq mm0,.c1g - paddd mm0,.dc13g - movq .c1g,mm0 -else - mov edx,.dc13r - add .c1r,edx - mov edx,.dc13g - add .c1g,edx -end if - mov edx,.dc13b - add .c1b,edx -if Ext >= MMX - movq mm0,.c2g - paddd mm0,.dc23g - movq .c2g,mm0 -else - mov edx,.dc23r - add .c2r,edx - mov edx,.dc23g - add .c2g,edx -end if - mov edx,.dc23b - add .c2b,edx - - add eax,.dx13 - add ebx,.dx23 - inc cx - cmp cx,.y3 - jl .gt_loop2 -.gt_loop2_end: - - ; add esp,84 - mov esp,ebp -ret 18 -gouraud_line: -;-------------in - edi - pointer to screen buffer -;----------------- stack - another parameters -.y equ word [ebp+4] -.col1b equ ebp+6 -.col1g equ ebp+8 -.col1r equ ebp+10 -.x1 equ [ebp+12] -.col2b equ ebp+14 -.col2g equ ebp+16 -.col2r equ ebp+18 -.x2 equ [ebp+20] -.dc_r equ dword[ebp-4] -.dc_g equ dword[ebp-8] -.dc_b equ dword[ebp-12] - mov ebp,esp - - mov ax,.y - or ax,ax - jl .gl_quit - mov dx,[size_y_var] - dec dx - cmp ax,dx ;SIZE_Y-1 - jg .gl_quit - - mov ax,.x1 - cmp ax,.x2 - je .gl_quit - jl .gl_ok - -if Ext >= MMX - movq mm0,[.col1b] - movq mm1,[.col2b] - movq [.col1b],mm1 - movq [.col2b],mm0 -else - mov eax,[.col1b] - xchg eax,[.col2b] - mov [.col1b],eax - mov eax,[.col1r] - xchg eax,[.col2r] - mov [.col1r],eax -end if -.gl_ok: - ; cmp .x1,SIZE_X-1 ;check - ; jg .gl_quit - ; cmp .x2,SIZE_X-1 - ; jl @f - ; mov .x2,SIZE_X-1 - ; @@: - ; cmp .x1,0 - ; jg @f - ; mov .x1,0 - ; @@: - ; cmp .x2,0 - ; jl .gl_quit - - movsx ecx,.y - movzx eax,word[size_x_var] - lea eax,[eax*3] - ; mov eax,SIZE_X*3 - mul ecx - movsx ebx,word .x1 - lea ecx,[ebx*2+eax] - add edi,ecx - add edi,ebx - - mov ax,word[.col2r] - sub ax,word[.col1r] - cwde - shl eax,ROUND - cdq - mov cx,.x2 - sub cx,.x1 - movsx ecx,cx - idiv ecx - ;mov .dc_r,eax ;first delta - push eax - - mov ax,word[.col2g] - sub ax,word[.col1g] - cwde - shl eax,ROUND - cdq - idiv ecx - ;mov .dc_g,eax - push eax - - mov ax,word[.col2b] - sub ax,word[.col1b] - cwde - shl eax,ROUND - cdq - idiv ecx - ; mov .dc_b,eax - push eax - - movsx ebx,word[.col1r] - shl ebx,ROUND - movsx edx,word[.col1g] - shl edx,ROUND - movsx esi,word[.col1b] - shl esi,ROUND -.gl_draw: - mov eax,ebx - sar eax,ROUND - stosb - mov eax,edx - sar eax,ROUND - stosb - mov eax,esi - sar eax,ROUND - stosb - add ebx,.dc_r - add edx,.dc_g - add esi,.dc_b - loop .gl_draw -.gl_quit: - ; add esp,12 - mov esp,ebp -ret 18 -if 0 -gouraud_line_SSE: ; new -;-------------in - edi - pointer to screen buffer -;----------------- stack - another parameters -.y equ word [ebp+4] -.col1b equ ebp+6 -.col1g equ ebp+8 -.col1r equ ebp+10 -.x1 equ [ebp+12] -.col2b equ ebp+14 -.col2g equ ebp+16 -.col2r equ ebp+18 -.x2 equ [ebp+20] -.dc_r equ dword[ebp-4] -.dc_g equ dword[ebp-8] -.dc_b equ dword[ebp-12] -.lenght equ [ebp-16] -.factor equ [ebp-24] ;new - mov ebp,esp - - mov ax,.y - or ax,ax - jl .gl_quit - cmp ax,SIZE_Y-1 - jg .gl_quit - - mov ax,.x1 - cmp ax,.x2 - je .gl_quit - jl .gl_ok - -if Ext >= MMX - movq mm0,[.col1b] - movq mm1,[.col2b] - movq [.col1b],mm1 - movq [.col2b],mm0 -else - mov eax,[.col1b] - xchg eax,[.col2b] - mov [.col1b],eax - mov eax,[.col1r] - xchg eax,[.col2r] - mov [.col1r],eax -end if -.gl_ok: - ; cmp .x1,SIZE_X-1 ;check - ; jg .gl_quit - ; cmp .x2,SIZE_X-1 - ; jl @f - ; mov .x2,SIZE_X-1 - ; @@: - ; cmp .x1,0 - ; jg @f - ; mov .x1,0 - ; @@: - ; cmp .x2,0 - ; jl .gl_quit - - movsx ecx,.y - mov eax,SIZE_X*3 - mul ecx - movsx ebx,word .x1 - lea ecx,[ebx*2+eax] - add edi,ecx - add edi,ebx - - mov ax,word[.col2r] - sub ax,word[.col1r] - cwde - shl eax,ROUND - cdq - mov cx,.x2 - sub cx,.x1 - movsx ecx,cx - idiv ecx - ;mov .dc_r,eax ;first delta - push eax - - mov ax,word[.col2g] - sub ax,word[.col1g] - cwde - shl eax,ROUND - cdq - idiv ecx - ;mov .dc_g,eax - push eax - - mov ax,word[.col2b] - sub ax,word[.col1b] - cwde - shl eax,ROUND - cdq - idiv ecx - ; mov .dc_b,eax - push eax - - movsx ebx,word[.col1r] - shl ebx,ROUND - movsx edx,word[.col1g] - shl edx,ROUND - movsx esi,word[.col1b] - shl esi,ROUND - - push ecx ; store line lenght - movd mm3,.dc_r - psrlq mm3,16 ; load dr to lowest word of mm3 - pxor mm2,mm2 ; clear mm2 - movd mm4,.dc_g - punpcklwd mm3,mm3 ; unpack dr to lower 2 words in in mm3 - psrlq mm4,16 ; load dg to lowest word of mm4 - movd mm5,.dc_b - psrlq mm5,16 ; load db to lowest word of mm5 - punpcklwd mm4,mm4 ; unpack dg to lower 2 words in in mm3 - lea ecx,[factor] - punpckldq mm3,mm3 - punpcklwd mm5,mm5 ; unpack db to lower 2 words in in mm5 - movq mm6,[.col1b] - xor eax,eax - pinsrw mm6,eax,3 ; clear the highest word in mm6 - mov eax,010000h - punpckldq mm4,mm4 ; unpack dg to 4 words in mm4 - mov [ecx],eax - mov eax,030002h - punpckldq mm5,mm5 ; unpack db to 4 words in mm5 - movq mm7,mm6 ; load r1r1,g1g1,b1b1 to the first three - ; words of mm7 - pxor mm1,mm1 ; clear mm1 - - -.gl_draw: - mov eax,ebx - sar eax,ROUND - stosb - mov eax,edx - sar eax,ROUND - stosb - mov eax,esi - sar eax,ROUND - stosb - add ebx,.dc_r - add edx,.dc_g - add esi,.dc_b - loop .gl_draw -.gl_quit: - ; add esp,12 - mov esp,ebp -ret 18 -end if diff --git a/programs/demos/3DS/History.txt b/programs/demos/3DS/History.txt index f603898e62..01a42f49f3 100644 --- a/programs/demos/3DS/History.txt +++ b/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 diff --git a/programs/demos/3DS/README.TXT b/programs/demos/3DS/README.TXT index f472b839c0..10134cb0fd 100644 --- a/programs/demos/3DS/README.TXT +++ b/programs/demos/3DS/README.TXT @@ -1,5 +1,14 @@ -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. @@ -11,8 +20,7 @@ Buttons description: 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 @@ Buttons description: 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 diff --git a/programs/demos/3DS/TEX3.INC b/programs/demos/3DS/TEX3.INC deleted file mode 100644 index 5d1b0c2a4f..0000000000 --- a/programs/demos/3DS/TEX3.INC +++ /dev/null @@ -1,546 +0,0 @@ -;--------------------------------------------------------------------- -;--------------------textured triangle procedure---------------------- -;--------------------------------------------------------------------- - -tex_triangle: -;----------in - eax - x1 shl 16 + y1 -;-------------- ebx - x2 shl 16 + y2 -;---------------ecx - x3 shl 16 + y3 -;---------------edx - nothing -;---------------esi - pointer to texture buffer -;---------------edi - pointer to screen buffer -;-------------stack - texture coordinates -.tex_x1 equ ebp+4 -.tex_y1 equ ebp+6 -.tex_x2 equ ebp+8 -.tex_y2 equ ebp+10 -.tex_x3 equ ebp+12 -.tex_y3 equ ebp+14 - -.x1 equ ebp-2 ;dw ? -.y1 equ ebp-4 ;dw ? -.x2 equ ebp-6 ;dw ? -.y2 equ ebp-8 ;dw ? -.x3 equ ebp-10 ;dw ? -.y3 equ ebp-12 ;dw ? -.dx12 equ ebp-16 ;dd ? -.dx13 equ ebp-20 ;dd ? -.dx23 equ ebp-24 ;dd ? -.tex_dx12 equ ebp-28 ;dd ? -.tex_dy12 equ ebp-32 ;dd ? -.tex_dx13 equ ebp-36 ;dd ? -.tex_dy13 equ ebp-40 ;dd ? -.tex_dx23 equ ebp-44 ;dd ? -.tex_dy23 equ ebp-48 ;dd ? -.tex_ptr equ ebp-52 ;dd ? - -.scan_x2 equ ebp-56 ;dd ? -.scan_y2 equ ebp-60 ;dd ? -.scan_x1 equ ebp-64 ;dd ? -.scan_y1 equ ebp-68 ;dd ? - - mov ebp,esp - sub esp,68 -;if Ext = MMX -; emms -;end if - mov edx,dword[.tex_x1] ; check all parameters - or dx,dx - jl .tt_end - cmp dx,TEX_X-1 - jg .tt_end - shr edx,16 - or dx,dx - jl .tt_end - cmp dx,TEX_Y-1 - jg .tt_end - - mov edx,dword[.tex_x2] - or dx,dx - jl .tt_end - cmp dx,TEX_X-1 - jg .tt_end - shr edx,16 - or dx,dx - jl .tt_end - cmp dx,TEX_Y-1 - jg .tt_end - - mov edx,dword[.tex_x3] - or dx,dx - jl .tt_end - cmp dx,TEX_X-1 - jg .tt_end - shr edx,16 - cmp dx,TEX_Y-1 - jg .tt_end - or dx,dx - jl .tt_end - - mov edx,eax ; check X&Y triangle coordinate - or edx,ebx - or edx,ecx - test edx,80008000h - jne .tt_end - mov dx,[size_x_var] - ; or ax,ax - ; jl .tt_end -; cmp ax,SIZE_Y -; jg .tt_end - ror eax,16 - ; or ax,ax - ; jl .tt_end - cmp ax,dx ;SIZE_X - jg .tt_end - rol eax,16 - - ; or bx,bx - ; jl .tt_end -; cmp bx,SIZE_Y -; jg .tt_end - ror ebx,16 - ; or bx,bx - ; jl .tt_end - cmp bx,dx ;SIZE_X - jg .tt_end - rol ebx,16 - - ; or cx,cx - ; jl .tt_end -; cmp cx,SIZE_Y -; jg .tt_end - ror ecx,16 - ; or cx,cx - ; jl .tt_end - cmp cx,dx ;SIZE_X - jg .tt_end - rol ecx,16 ; uff.. parameters was checked - - cmp ax,bx ;sort all parameters - jle .tt_sort1 - xchg eax,ebx - mov edx,dword [.tex_x1] - xchg edx,dword [.tex_x2] - mov dword[.tex_x1],edx -.tt_sort1: - cmp ax,cx - jle .tt_sort2 - xchg eax,ecx - mov edx,dword [.tex_x1] - xchg edx,dword [.tex_x3] - mov dword [.tex_x1],edx -.tt_sort2: - cmp bx,cx - jle .tt_sort3 - xchg ebx,ecx - mov edx,dword [.tex_x2] - xchg edx,dword [.tex_x3] - mov dword [.tex_x2],edx -.tt_sort3: - mov [.y1],ax ; and store to user friendly variables - shr eax,16 - mov [.x1],ax - mov [.y2],bx - shr ebx,16 - mov [.x2],bx - mov [.y3],cx - shr ecx,16 - mov [.x3],cx - mov [.tex_ptr],esi - - movsx ebx,word[.y2] - sub bx,[.y1] - jnz .tt_dx12_make - - mov dword[.dx12],0 - mov dword[.tex_dx12],0 - mov dword[.tex_dy12],0 - jmp .tt_dx12_done -.tt_dx12_make: - mov ax,[.x2] - sub ax,[.x1] - cwde - shl eax,ROUND - cdq - idiv ebx - mov [.dx12],eax ; dx12 = (x2-x1)/(y2-y1) - - mov ax,word[.tex_x2] - sub ax,word[.tex_x1] - cwde - shl eax,ROUND - cdq - idiv ebx - mov [.tex_dx12],eax ; tex_dx12 = (tex_x2-tex_x1)/(y2-y1) - - mov ax,word[.tex_y2] - sub ax,word[.tex_y1] - cwde - shl eax,ROUND - cdq - idiv ebx - mov [.tex_dy12],eax ; tex_dy12 = (tex_y2-tex_y1)/(y2-y1) -.tt_dx12_done: - - movsx ebx,word[.y3] - sub bx,word[.y1] - jnz .tt_dx13_make - - mov dword [.dx13],0 - mov dword [.tex_dx13],0 - mov dword [.tex_dy13],0 - jmp .tt_dx13_done -.tt_dx13_make: - mov ax,[.x3] - sub ax,[.x1] - cwde - shl eax,ROUND - cdq - idiv ebx - mov [.dx13],eax ; dx13 = (x3-x1)/(y3-y1) - - mov ax,word[.tex_x3] - sub ax,word[.tex_x1] - cwde - shl eax,ROUND - cdq - idiv ebx - mov [.tex_dx13],eax ; tex_dx13 = (tex_x3-tex_x1)/(y3-y1) - - mov ax,word[.tex_y3] - sub ax,word[.tex_y1] - cwde - shl eax,ROUND - cdq - idiv ebx - mov [.tex_dy13],eax ; tex_dy13 = (tex_y3-tex_y1)/(y3-y1) -.tt_dx13_done: - - movsx ebx,word[.y3] - sub bx,word[.y2] - jnz .tt_dx23_make - - mov dword [.dx23],0 - mov dword [.tex_dx23],0 - mov dword [.tex_dy23],0 - jmp .tt_dx23_done -.tt_dx23_make: - mov ax,[.x3] - sub ax,[.x2] - cwde - shl eax,ROUND - cdq - idiv ebx - mov [.dx23],eax ; dx23 = (x3-x2)/(y3-y2) - - mov ax,word[.tex_x3] - sub ax,word[.tex_x2] - cwde - shl eax,ROUND - cdq - idiv ebx - mov [.tex_dx23],eax ; tex_dx23 = (tex_x3-tex_x2)/(y3-y2) - - mov ax,word[.tex_y3] - sub ax,word[.tex_y2] - cwde - shl eax,ROUND - cdq - idiv ebx - mov [.tex_dy23],eax ; tex_dy23 = (tex_y3-tex_y2)/(y3-y2) -.tt_dx23_done: - - movsx eax,word[.x1] - shl eax,ROUND - mov ebx,eax - - movsx edx, word[.tex_x1] - shl edx,ROUND - mov [.scan_x1],edx - mov [.scan_x2],edx - movsx edx, word[.tex_y1] - shl edx,ROUND - mov [.scan_y1],edx - mov [.scan_y2],edx - - mov cx,[.y1] - cmp cx, [.y2] - jge .tt_loop1_end -.tt_loop1: - push edi - push eax - push ebx - push cx - push ebp -;; Madis -;if Ext=MMX ; With MMX enabled it reverse light vectors ???? -; mov dword[esp-8],ROUND -; mov dword[esp-4],0 ; Is this a bug? Explanation down 3 lines -; movq mm0,qword[.scan_y1] -; movq mm1,qword[.scan_y2] -; psrad mm0,[esp-8] ;This instr. won't allow modifiers BYTE, WORD, etc. -; psrad mm1,[esp-8] ;It always defaults to QWORD -; packssdw mm0,mm1 -; movq [esp-8],mm0 -; sub esp,8 -;else - - push dword[.scan_y2] ; now I push variables on stack without shifting - push dword[.scan_x2] - push dword[.scan_y1] - push dword[.scan_x1] - -;end if - - - - push dword[.tex_ptr] - - push cx - mov edx,ebx - sar edx,ROUND - push dx - mov edx,eax - sar edx,ROUND - push dx - call textured_line - - pop ebp - pop cx - pop ebx - pop eax - pop edi - - mov edx, [.tex_dx13] - add [.scan_x1], edx - mov edx, [.tex_dx12] - add [.scan_x2], edx - mov edx, [.tex_dy13] - add [.scan_y1], edx - mov edx, [.tex_dy12] - add [.scan_y2], edx - - add eax, [.dx13] - add ebx, [.dx12] - inc cx - cmp cx,[.y2] - jl .tt_loop1 - -.tt_loop1_end: - - - mov cx, [.y2] - cmp cx, [.y3] - jge .tt_loop2_end - - movsx ebx,word[.x2] - shl ebx,ROUND - - movsx edx, word[.tex_x2] - shl edx,ROUND - mov [.scan_x2],edx - movsx edx, word[.tex_y2] - shl edx,ROUND - mov [.scan_y2],edx - -.tt_loop2: - push edi - push eax - push ebx - push cx - push ebp -;; Madis -;if Ext=MMX -; mov dword[esp-8],ROUND -; mov dword[esp-4],0 ; Is this a bug? Explanation down 3 lines -; movq mm0,qword[.scan_y1] -; movq mm1,qword[.scan_y2] -; psrad mm0,[esp-8] ;This instr. won't allow modifiers BYTE, WORD, etc. -; psrad mm1,[esp-8] ;It always defaults to QWORD -; packssdw mm0,mm1 -; movq [esp-8],mm0 -; sub esp,8 -;else - -;end if - push dword[.scan_y2] - push dword[.scan_x2] - push dword[.scan_y1] - push dword[.scan_x1] - - - - push dword[.tex_ptr] - - push cx - mov edx,ebx - sar edx,ROUND - push dx - mov edx,eax - sar edx,ROUND - push dx - call textured_line - - pop ebp - pop cx - pop ebx - pop eax - pop edi - - mov edx, [.tex_dx13] - add [.scan_x1], edx - mov edx, [.tex_dx23] - add [.scan_x2], edx - mov edx, [.tex_dy13] - add [.scan_y1], edx - mov edx, [.tex_dy23] - add [.scan_y2], edx - - add eax, [.dx13] - add ebx, [.dx23] - inc cx - cmp cx,[.y3] - jl .tt_loop2 - -.tt_loop2_end: - -.tt_end: - mov esp,ebp - -ret 12 - - -textured_line: -;-----in -edi screen buffer pointer -;------------ stack: - .x1 equ word [ebp+4] - .x2 equ word [ebp+6] - .y equ word [ebp+8] - - .tex_ptr equ dword [ebp+10] - .tex_x1 equ [ebp+14] - .tex_y1 equ [ebp+18] - .tex_x2 equ [ebp+22] - .tex_y2 equ [ebp+26] - - .tex_dx equ ebp-4 ;dd ? - .tex_dy equ ebp-8 ;dd ? - - mov ebp,esp - sub esp,8 - - mov ax,.y - or ax,ax - jl .tl_quit - mov dx,[size_y_var] - cmp ax,dx ;SIZE_Y - jg .tl_quit - - mov ax,.x1 - cmp ax,.x2 - je .tl_quit - jl .tl_ok - - xchg ax,.x2 - mov .x1,ax - -if Ext >= MMX - movq mm0,.tex_x1 - movq mm1,.tex_x2 - movq .tex_x2,mm0 - movq .tex_x1,mm1 - -else - - mov eax,.tex_x1 - xchg eax,.tex_x2 - mov .tex_x1,eax - - mov eax,.tex_y1 - xchg eax,.tex_y2 - mov .tex_y1,eax - -end if - - .tl_ok: - - mov ebx,edi - movsx edi,.y - movzx eax,word[size_x_var] - lea eax,[eax*3] -; mov eax,SIZE_X*3 - mul edi - mov edi,eax - movsx eax,.x1 - add edi,eax - shl eax,1 - add edi,eax - add edi,ebx - - mov cx,.x2 - sub cx,.x1 - movsx ecx,cx - - mov eax,.tex_x2 - sub eax,.tex_x1 - cdq - idiv ecx - mov [.tex_dx],eax ; tex_dx=(tex_x2-tex_x1)/(x2-x1) - - mov eax,.tex_y2 - sub eax,.tex_y1 - cdq - idiv ecx - mov [.tex_dy],eax ; tex_dy = (tex_y2-tex_y1)/(x2-x1) - - mov eax,.tex_x1 - mov ebx,.tex_y1 - cld - .tl_loop: - mov edx,eax ; eax - cur x - mov esi,ebx ; ebx - cur y - shr edx,ROUND - shr esi,ROUND - macro .fluent - { - push eax - push edx - mov eax,TEX_X*3 - mul esi - mov esi,eax - pop edx - pop eax - } - macro .shift - { - shl esi,TEX_SHIFT - lea esi,[esi*3] - ;push edx - ;mov edx,esi - ;shl esi,1 - ;add esi,edx - ;pop edx - } - if TEX = FLUENTLY - .fluent - end if - if TEX = SHIFTING - .shift - end if - lea edx,[edx*3] - add esi,edx - ; shl edx,1 - ; add esi,edx - add esi,.tex_ptr - movsd - dec edi - add eax,[.tex_dx] - add ebx,[.tex_dy] - loop .tl_loop - - .tl_quit: - mov esp,ebp - -ret 18+8 -; .tex_dx dd ? -; .tex_dy dd ? diff --git a/programs/demos/3DS/VIEW3DS.ASM b/programs/demos/3DS/VIEW3DS.ASM index 13cbeb3a34..ba216448af 100644 --- a/programs/demos/3DS/VIEW3DS.ASM +++ b/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,489 +20,489 @@ 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: 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 @@ still: ; 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 @@ still: .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 @@ end if 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 @@ end if if Ext=NON lodsb sub al,bl - jb @f + jb @f mov [esi-1],al loop .oop1 @@: @@ -710,7 +710,7 @@ end if 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,35 +729,35 @@ end if 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 ; 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 @@ clear_vertices_index: 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 @@ if 0 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 @@ ret 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 @@ calc_bumpmap_coords: ; map texture, bump 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 @@ calc_bumpmap_coords: ; map texture, bump 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 @@ init_envmap2: ; do env_map using many light sources .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 @@ do_color_buffer: ; do color buffer for Gouraud, flat shading .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 @@ ret 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 @@ ret + + + + draw_handlers: push ebp @@ -2955,22 +2968,22 @@ draw_handlers: 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 @@ draw_handlers: 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 @@ draw_handlers: @@: 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 @@ draw_handlers: 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,347 +3044,345 @@ ret 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 ; 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 @@ if USE_LFN ;- 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 @@ else ; 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 @@ -3453,261 +3455,263 @@ else int 0x40 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