Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6134 → Rev 6130

/programs/develop/libraries/TinyGL/asm_fork/examples/build.bat
File deleted
\ No newline at end of file
/programs/develop/libraries/TinyGL/asm_fork/ztriangle.asm
39,7 → 39,7
add [z],eax
}
 
align 16
align 4
proc ZB_fillTriangleFlat, zb:dword, p0:dword, p1:dword, p2:dword
locals
if TGL_FEATURE_RENDER_BITS eq 24
94,12 → 94,12
add [ob1],eax
}
 
align 16
align 4
proc ZB_fillTriangleSmooth, zb:dword, p0:dword, p1:dword, p2:dword
locals
include 'ztriangle.inc'
 
align 16
align 4
proc ZB_setTexture uses eax ebx, zb:dword, texture:dword
mov eax,[zb]
mov ebx,[texture]
120,7 → 120,6
macro PUT_PIXEL _a
{
local .end_0
local .in_mem
mov eax,[z]
shr eax,ZB_POINT_Z_FRAC_BITS
cmp ax,word[esi+2*_a] ;if (zz >= pz[_a])
132,10 → 131,6
and ebx,0x3fc00000
or ebx,[s]
shr ebx,14
cmp ebx,256*256-1 ;проверка на выход за пределы текстуры
jl .in_mem ;координата 1.0,1.0 может выползать
mov ebx,256*256-1 ;переход на последний пиксель текстуры
.in_mem:
imul ebx,3
add ebx,[texture] ;ptr = texture + (((t & 0x3fc00000) | s) >> 14) * 3
mov ax,word[ebx]
154,7 → 149,7
add [t],eax
}
 
align 16
align 4
proc ZB_fillTriangleMapping, zb:dword, p0:dword, p1:dword, p2:dword
locals
texture dd ? ;PIXEL*
193,7 → 188,6
macro PUT_PIXEL _a
{
local .end_0
local .in_mem
mov eax,[z]
shr eax,ZB_POINT_Z_FRAC_BITS
cmp ax,word[esi+2*_a] ;if (zz >= pz[_a])
207,15 → 201,6
and eax,0x003fc000
or ebx,eax
shr ebx,14
if 1
; не знаю нужна ли сдесь эта проверка
; функция ZB_fillTriangleMapping без нее не работает
; на всякий случай делаю и тут такое же
cmp ebx,256*256-1 ;проверка на выход за пределы текстуры
jl .in_mem ;координата 1.0,1.0 может выползать
mov ebx,256*256-1 ;переход на последний пиксель текстуры
.in_mem:
end if
imul ebx,3
add ebx,[texture] ;ptr = texture + (((t & 0x3fc00000) | (s & 0x003FC000)) >> 14) * 3
mov ax,word[ebx]
248,6 → 233,7
fld1
fild dword[z1]
fst dword[f_z] ;fz = (float)z1
;fld1
fdivp
fstp dword[zinv] ;zinv = 1.0 / fz
imul edi,PSZB
285,6 → 271,7
fld dword[f_z]
fadd dword[fndzdx]
fst dword[f_z] ;fz += fndzdx
;fld1
fdivp
fstp dword[zinv] ;zinv = 1.0 / fz
PUT_PIXEL 0
305,7 → 292,6
fadd dword[t_z]
fstp dword[t_z] ;tz += ndtzdx
jmp .cycle_2
align 4
.cycle_2_end:
fld dword[zinv]
fld st0
332,12 → 318,11
add edi,PSZB ;pp += PSZB
dec dword[n]
jmp .cycle_3
align 4
.cycle_3_end:
end if
}
 
align 16
align 4
proc ZB_fillTriangleMappingPerspective, zb:dword, p0:dword, p1:dword, p2:dword
locals
texture dd ? ;PIXEL *
401,7 → 386,7
fstp dword[t_z]
}
 
align 16
align 4
proc ZB_fillTriangleMappingPerspective, zb:dword, p0:dword, p1:dword, p2:dword
locals
texture dd ? ;PIXEL*
/programs/develop/libraries/TinyGL/asm_fork/clip.asm
8,7 → 8,7
CLIP_ZMIN equ (1<<4)
CLIP_ZMAX equ (1<<5)
 
align 16
align 4
proc gl_transform_to_viewport uses eax ebx ecx, context:dword,v:dword
locals
point dd ?
53,7 → 53,6
push ecx
stdcall RGBFtoRGBI, dword[ebx+offs_vert_color],dword[ebx+offs_vert_color+4],dword[ebx+offs_vert_color+8]
jmp .end_if
align 4
@@:
; no need to convert to integer if no lighting : take current color
mov ecx,[eax+offs_cont_longcurrent_color]
75,7 → 74,7
 
mov dword[point],dword(ZB_POINT_T_MAX - ZB_POINT_T_MIN)
fild dword[point]
fmul dword[ebx+offs_vert_tex_coord+offs_Y] ;st0 *= v.tex_coord.Y
fmul dword[ebx+offs_vert_tex_coord+4] ;st0 *= v.tex_coord.Y
fistp dword[ebx+offs_vert_zp+offs_zbup_t]
add dword[ebx+offs_vert_zp+offs_zbup_s],ZB_POINT_T_MIN
@@:
82,7 → 81,7
ret
endp
 
align 16
align 4
proc gl_add_select1 uses eax ebx ecx, context:dword, z1:dword,z2:dword,z3:dword
mov eax,[z1]
mov ebx,eax
114,7 → 113,7
 
; point
 
align 16
align 4
proc gl_draw_point uses eax ebx, context:dword, p0:dword
mov ebx,[p0]
cmp dword[ebx+offs_vert_clip_code],0 ;if (p0.clip_code == 0)
124,7 → 123,6
jne .els
stdcall gl_add_select, eax,dword[ebx+offs_vert_zp+offs_zbup_z],dword[ebx+offs_vert_zp+offs_zbup_z] ;p0.zp.z,p0.zp.z
jmp @f
align 4
.els:
add ebx,offs_vert_zp
stdcall ZB_plot, dword[eax+offs_cont_zb],ebx
134,7 → 132,7
 
; line
 
align 16
align 4
proc interpolate uses eax ebx ecx, q:dword,p0:dword,p1:dword,t:dword
mov eax,[q]
mov ebx,[p0]
197,7 → 195,7
; Line Clipping algorithm from 'Computer Graphics', Principles and
; Practice
; tmin,tmax -> &float
align 16
align 4
proc ClipLine1 uses ebx, denom:dword,num:dword,tmin:dword,tmax:dword
fld dword[denom]
ftst
219,7 → 217,6
jbe .r1_f1 ;if (t>*tmin) *tmin=t
fstp dword[ebx]
jmp .r1
align 4
.els_0: ;else if (denom<0)
jae .els_1
fld dword[num]
237,7 → 234,6
jae .r1_f1
fstp dword[ebx] ;if (t<*tmin) *tmax=t
jmp .r1
align 4
.els_1: ;else if (num>0)
ffree st0 ;denom
fincstp
247,7 → 243,7
sahf
ja .r0_f1 ;if (num>0) return 0
jmp .r1_f1
align 4
 
.r0_f1: ;return 0 & free st0
ffree st0
fincstp
254,7 → 250,6
.r0: ;return 0
xor eax,eax
jmp .end_f
align 4
.r1_f1: ;return 1 & free st0
ffree st0
fincstp
265,7 → 260,7
ret
endp
 
align 16
align 4
proc gl_draw_line, context:dword, p1:dword, p2:dword
locals
d_x dd ?
296,7 → 291,6
stdcall gl_add_select1, edx,dword[edi+offs_vert_zp+offs_zbup_z],\
dword[esi+offs_vert_zp+offs_zbup_z],dword[esi+offs_vert_zp+offs_zbup_z]
jmp .end_f
align 4
.els_1:
add edi,offs_vert_zp
add esi,offs_vert_zp
308,17 → 302,15
;if (context.depth_test)
call ZB_line_z ;, dword[edx+offs_cont_zb],edi,esi
jmp .end_f
align 4
.els_2:
call ZB_line ;, dword[edx+offs_cont_zb],edi,esi
jmp .end_f
align 4
.els_i:
;else if ( (p1.clip_code & p2.clip_code) != 0 )
mov eax,[edi+offs_vert_clip_code]
and eax,[esi+offs_vert_clip_code]
or eax,eax
jnz .end_f
cmp eax,0
jne .end_f
.els_0:
 
fld dword[esi+offs_vert_pc+offs_X]
462,7 → 454,6
je .els_3
call ZB_line_z ;(context.zb,&q1.zp,&q2.zp)
jmp .end_f
align 4
.els_3:
call ZB_line ;(context.zb,&q1.zp,&q2.zp)
.end_f:
518,7 → 509,6
fldz
fst dword[t] ;t=0
jmp .e_zero
align 4
@@: ;else
fld dword[edx+offs#dir]
if sign eq 0
553,37 → 543,37
mov eax,[t]
}
 
align 16
align 4
proc clip_xmin uses ebx ecx edx, c:dword, a:dword, b:dword
clip_func 0,_X,_Y,_Z
ret
endp
 
align 16
align 4
proc clip_xmax uses ebx ecx edx, c:dword, a:dword, b:dword
clip_func 1,_X,_Y,_Z
ret
endp
 
align 16
align 4
proc clip_ymin uses ebx ecx edx, c:dword, a:dword, b:dword
clip_func 0,_Y,_X,_Z
ret
endp
 
align 16
align 4
proc clip_ymax uses ebx ecx edx, c:dword, a:dword, b:dword
clip_func 1,_Y,_X,_Z
ret
endp
 
align 16
align 4
proc clip_zmin uses ebx ecx edx, c:dword, a:dword, b:dword
clip_func 0,_Z,_X,_Y
ret
endp
 
align 16
align 4
proc clip_zmax uses ebx ecx edx, c:dword, a:dword, b:dword
clip_func 1,_Z,_X,_Y
ret
592,7 → 582,7
align 4
clip_proc dd clip_xmin,clip_xmax, clip_ymin,clip_ymax, clip_zmin,clip_zmax
 
align 16
align 4
proc updateTmp uses eax ebx ecx edx, context:dword, q:dword, p0:dword, p1:dword, t:dword
mov ebx,[q]
mov edx,[context]
616,7 → 606,6
fadd dword[eax+offs_vert_color+8]
fstp dword[ebx+offs_vert_color+8] ;q.color.v[2]=p0.color.v[2] + (p1.color.v[2]-p0.color.v[2])*t
jmp @f
align 4
.els_0:
mov ecx,[eax+offs_vert_color]
mov [ebx+offs_vert_color],ecx ;q.color.v[0]=p0.color.v[0]
659,7 → 648,7
ret
endp
 
align 16
align 4
proc gl_draw_triangle, context:dword, p0:dword, p1:dword, p2:dword
locals
cc rd 3
727,7 → 716,6
je .end_f
stdcall dword[edi+offs_cont_draw_triangle_front], edi,ebx,ecx,edx
jmp .end_f
align 4
@@:
cmp dword[edi+offs_cont_current_cull_face],GL_FRONT
jne .end_f
735,7 → 723,6
jne .end_f
stdcall dword[edi+offs_cont_draw_triangle_back], edi,ebx,ecx,edx
jmp .end_f
align 4
.els_1:
; no culling
cmp dword[front],0
742,11 → 729,9
je @f
stdcall dword[edi+offs_cont_draw_triangle_front], edi,ebx,ecx,edx
jmp .end_f
align 4
@@:
stdcall dword[edi+offs_cont_draw_triangle_back], edi,ebx,ecx,edx
jmp .end_f
align 4
.els_0:
;eax = cc[2]
and eax,[cc]
759,7 → 744,7
ret
endp
 
align 16
align 4
proc gl_draw_triangle_clip, context:dword, p0:dword, p1:dword, p2:dword, clip_bit:dword
locals
co dd ?
789,7 → 774,6
jnz .els_0
stdcall gl_draw_triangle, [context],ebx,ecx,edx
jmp .end_f
align 4
.els_0:
;eax = cc[2]
and eax,[cc]
812,7 → 796,6
jnz .cycle_0_end
inc dword[clip_bit]
jmp .cycle_0
align 4
.cycle_0_end:
 
; this test can be true only in case of rounding errors
854,7 → 837,6
mov [q+4],ecx
mov [q+8],edx
jmp .els_2_end
align 4
.els_2:
mov eax,[cc+4]
and eax,[clip_mask]
865,7 → 847,6
mov [q+4],edx
mov [q+8],ebx
jmp .els_2_end
align 4
.els_3:
;q[0]=p2 q[1]=p0 q[2]=p1
mov [q],edx
927,7 → 908,6
add edi,sizeof.GLVertex ;edi = &tmp2
stdcall gl_draw_triangle_clip,[context],edi ;gl_draw_triangle_clip(c,&tmp2,&tmp1,q[2],clip_bit+1)
jmp .end_f
align 4
.els_1:
; two points outside
mov eax,[cc]
939,7 → 919,6
mov [q+4],ecx
mov [q+8],edx
jmp .els_4_end
align 4
.els_4:
mov eax,[cc+4]
and eax,[clip_mask]
950,7 → 929,6
mov [q+4],edx
mov [q+8],ebx
jmp .els_4_end
align 4
.els_5:
;q[0]=p2 q[1]=p0 q[2]=p1
mov [q],edx
999,7 → 977,7
ret
endp
 
align 16
align 4
proc gl_draw_triangle_select uses eax, context:dword, p0:dword,p1:dword,p2:dword
mov eax,[p2]
push dword[eax+offs_vert_zp+offs_Z]
1017,7 → 995,7
count_pixels dd ?
end if
 
align 16
align 4
proc gl_draw_triangle_fill, context:dword, p0:dword,p1:dword,p2:dword
pushad
if PROFILE eq 1
1052,19 → 1030,8
stdcall ZB_setTexture, dword[edx+offs_cont_zb],dword[eax]
mov eax,[p0]
add eax,offs_vert_zp
push ecx
push ebx
push eax
push dword[edx+offs_cont_zb]
cmp dword[edx+offs_cont_matrix_model_projection_no_w_transform],0
je @f
call ZB_fillTriangleMappingPerspective
stdcall ZB_fillTriangleMappingPerspective, dword[edx+offs_cont_zb],eax,ebx,ecx
jmp .end_f
align 4
@@:
call ZB_fillTriangleMapping
jmp .end_f
align 4
.els_i:
mov eax,[p0]
add eax,offs_vert_zp
1073,7 → 1040,6
;else if (context.current_shade_model == GL_SMOOTH)
stdcall ZB_fillTriangleSmooth, dword[edx+offs_cont_zb],eax,ebx,ecx
jmp .end_f
align 4
.els:
stdcall ZB_fillTriangleFlat, dword[edx+offs_cont_zb],eax,ebx,ecx
.end_f:
1083,7 → 1049,7
 
; Render a clipped triangle in line mode
 
align 16
align 4
proc gl_draw_triangle_line uses eax ebx ecx edx, context:dword, p0:dword,p1:dword,p2:dword
mov edx,[context]
cmp dword[edx+offs_cont_depth_test],0
1090,7 → 1056,6
je .els
lea ecx,[ZB_line_z]
jmp @f
align 4
.els:
lea ecx,[ZB_line]
@@:
1130,7 → 1095,7
endp
 
; Render a clipped triangle in point mode
align 16
align 4
proc gl_draw_triangle_point uses eax ebx edx, context:dword, p0:dword,p1:dword,p2:dword
mov edx,[context]
mov eax,[p0]