forked from KolibriOS/kolibrios
fixes in 'clip.asm'
git-svn-id: svn://kolibrios.org@5208 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
c432de825e
commit
0feb6fbe0b
@ -47,8 +47,8 @@ endl
|
|||||||
fincstp
|
fincstp
|
||||||
|
|
||||||
; color
|
; color
|
||||||
bt dword[eax+offs_cont_lighting_enabled],0
|
cmp dword[eax+offs_cont_lighting_enabled],0 ;if (context.lighting_enabled)
|
||||||
jnc @f
|
je @f
|
||||||
mov ecx,ebx
|
mov ecx,ebx
|
||||||
add ecx,offs_vert_zp+offs_zbup_b
|
add ecx,offs_vert_zp+offs_zbup_b
|
||||||
push ecx
|
push ecx
|
||||||
@ -60,14 +60,12 @@ endl
|
|||||||
jmp .end_if
|
jmp .end_if
|
||||||
@@:
|
@@:
|
||||||
; no need to convert to integer if no lighting : take current color
|
; no need to convert to integer if no lighting : take current color
|
||||||
push ecx
|
|
||||||
mov ecx,[eax+offs_cont_longcurrent_color]
|
mov ecx,[eax+offs_cont_longcurrent_color]
|
||||||
mov dword[ebx+offs_vert_zp+offs_zbup_r],ecx
|
mov dword[ebx+offs_vert_zp+offs_zbup_r],ecx
|
||||||
mov ecx,[eax+offs_cont_longcurrent_color+4]
|
mov ecx,[eax+offs_cont_longcurrent_color+4]
|
||||||
mov dword[ebx+offs_vert_zp+offs_zbup_g],ecx
|
mov dword[ebx+offs_vert_zp+offs_zbup_g],ecx
|
||||||
mov ecx,[eax+offs_cont_longcurrent_color+8]
|
mov ecx,[eax+offs_cont_longcurrent_color+8]
|
||||||
mov dword[ebx+offs_vert_zp+offs_zbup_b],ecx
|
mov dword[ebx+offs_vert_zp+offs_zbup_b],ecx
|
||||||
pop ecx
|
|
||||||
.end_if:
|
.end_if:
|
||||||
|
|
||||||
; texture
|
; texture
|
||||||
@ -214,6 +212,9 @@ proc interpolate uses eax ebx ecx, q:dword,p0:dword,p1:dword,t:dword
|
|||||||
fmul st0,st1
|
fmul st0,st1
|
||||||
fadd dword[ebx+offs_vert_color+8]
|
fadd dword[ebx+offs_vert_color+8]
|
||||||
fstp dword[eax+offs_vert_color+8]
|
fstp dword[eax+offs_vert_color+8]
|
||||||
|
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
@ -322,12 +323,6 @@ endl
|
|||||||
mov edi,[p1]
|
mov edi,[p1]
|
||||||
mov esi,[p2]
|
mov esi,[p2]
|
||||||
|
|
||||||
if DEBUG
|
|
||||||
jmp @f
|
|
||||||
f_1 db ' gl_draw_line',0
|
|
||||||
@@:
|
|
||||||
stdcall dbg_print,f_1,m_1
|
|
||||||
end if
|
|
||||||
cmp dword[edi+offs_vert_clip_code],0
|
cmp dword[edi+offs_vert_clip_code],0
|
||||||
jne .els_i
|
jne .els_i
|
||||||
cmp dword[esi+offs_vert_clip_code],0
|
cmp dword[esi+offs_vert_clip_code],0
|
||||||
@ -359,9 +354,6 @@ end if
|
|||||||
cmp eax,0
|
cmp eax,0
|
||||||
jne .end_f
|
jne .end_f
|
||||||
.els_0:
|
.els_0:
|
||||||
if DEBUG
|
|
||||||
stdcall dbg_print,f_1,m_2
|
|
||||||
end if
|
|
||||||
|
|
||||||
finit
|
finit
|
||||||
fld dword[esi+offs_vert_pc+offs_X]
|
fld dword[esi+offs_vert_pc+offs_X]
|
||||||
@ -553,10 +545,11 @@ else
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
fldz
|
fldz
|
||||||
fcompp
|
fcomp
|
||||||
fstsw ax
|
fstsw ax
|
||||||
sahf
|
sahf
|
||||||
ja @f
|
jne @f
|
||||||
|
fldz
|
||||||
fst dword[t] ;t=0
|
fst dword[t] ;t=0
|
||||||
jmp .e_zero
|
jmp .e_zero
|
||||||
@@: ;else
|
@@: ;else
|
||||||
@ -573,6 +566,9 @@ end if
|
|||||||
fadd dword[edx+offs#dir1]
|
fadd dword[edx+offs#dir1]
|
||||||
fstp dword[ecx+offs#dir1] ;c.dir1 = a.dir1 + t * d.dir1
|
fstp dword[ecx+offs#dir1] ;c.dir1 = a.dir1 + t * d.dir1
|
||||||
|
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
|
|
||||||
fld dword[t]
|
fld dword[t]
|
||||||
fmul dword[d#dir2] ;st0 = t * d.dir2
|
fmul dword[d#dir2] ;st0 = t * d.dir2
|
||||||
fadd dword[edx+offs#dir2]
|
fadd dword[edx+offs#dir2]
|
||||||
@ -630,31 +626,68 @@ align 4
|
|||||||
clip_proc dd clip_xmin,clip_xmax, clip_ymin,clip_ymax, clip_zmin,clip_zmax
|
clip_proc dd clip_xmin,clip_xmax, clip_ymin,clip_ymax, clip_zmin,clip_zmax
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
proc updateTmp uses edx, context:dword, q:dword, p0:dword, p1:dword, t:dword
|
proc updateTmp uses eax ebx ecx edx, context:dword, q:dword, p0:dword, p1:dword, t:dword
|
||||||
mov eax,[context]
|
mov ebx,[q]
|
||||||
|
mov edx,[context]
|
||||||
|
mov eax,[p0]
|
||||||
cmp dword[edx+offs_cont_current_shade_model],GL_SMOOTH ;if (context.current_shade_model == GL_SMOOTH)
|
cmp dword[edx+offs_cont_current_shade_model],GL_SMOOTH ;if (context.current_shade_model == GL_SMOOTH)
|
||||||
jne .els_0
|
jne .els_0
|
||||||
; q->color.v[0]=p0->color.v[0] + (p1->color.v[0]-p0->color.v[0])*t;
|
mov ecx,[p1]
|
||||||
; q->color.v[1]=p0->color.v[1] + (p1->color.v[1]-p0->color.v[1])*t;
|
fld dword[ecx+offs_vert_color]
|
||||||
; q->color.v[2]=p0->color.v[2] + (p1->color.v[2]-p0->color.v[2])*t;
|
fsub dword[eax+offs_vert_color]
|
||||||
|
fmul dword[t]
|
||||||
|
fadd dword[eax+offs_vert_color]
|
||||||
|
fstp dword[ebx+offs_vert_color] ;q.color.v[0]=p0.color.v[0] + (p1.color.v[0]-p0.color.v[0])*t
|
||||||
|
fld dword[ecx+offs_vert_color+4]
|
||||||
|
fsub dword[eax+offs_vert_color+4]
|
||||||
|
fmul dword[t]
|
||||||
|
fadd dword[eax+offs_vert_color+4]
|
||||||
|
fstp dword[ebx+offs_vert_color+4] ;q.color.v[1]=p0.color.v[1] + (p1.color.v[1]-p0.color.v[1])*t
|
||||||
|
fld dword[ecx+offs_vert_color+8]
|
||||||
|
fsub dword[eax+offs_vert_color+8]
|
||||||
|
fmul dword[t]
|
||||||
|
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
|
jmp @f
|
||||||
.els_0:
|
.els_0:
|
||||||
; q->color.v[0]=p0->color.v[0];
|
mov ecx,[eax+offs_vert_color]
|
||||||
; q->color.v[1]=p0->color.v[1];
|
mov [ebx+offs_vert_color],ecx ;q.color.v[0]=p0.color.v[0]
|
||||||
; q->color.v[2]=p0->color.v[2];
|
mov ecx,[eax+offs_vert_color+4]
|
||||||
|
mov [ebx+offs_vert_color+4],ecx ;q.color.v[1]=p0.color.v[1]
|
||||||
|
mov ecx,[eax+offs_vert_color+8]
|
||||||
|
mov [ebx+offs_vert_color+8],ecx ;q.color.v[2]=p0.color.v[2]
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
cmp dword[edx+offs_cont_texture_2d_enabled],0 ;if (context.texture_2d_enabled)
|
cmp dword[edx+offs_cont_texture_2d_enabled],0 ;if (context.texture_2d_enabled)
|
||||||
je @f
|
je @f
|
||||||
; q->tex_coord.X=p0->tex_coord.X + (p1->tex_coord.X-p0->tex_coord.X)*t;
|
mov ecx,[p1]
|
||||||
; q->tex_coord.Y=p0->tex_coord.Y + (p1->tex_coord.Y-p0->tex_coord.Y)*t;
|
fld dword[ecx+offs_vert_tex_coord+offs_X]
|
||||||
|
fsub dword[eax+offs_vert_tex_coord+offs_X]
|
||||||
|
fmul dword[t]
|
||||||
|
fadd dword[eax+offs_vert_tex_coord+offs_X]
|
||||||
|
fstp dword[ebx+offs_vert_tex_coord+offs_X] ;q.tex_coord.X=p0.tex_coord.X + (p1.tex_coord.X-p0.tex_coord.X)*t
|
||||||
|
fld dword[ecx+offs_vert_tex_coord+offs_Y]
|
||||||
|
fsub dword[eax+offs_vert_tex_coord+offs_Y]
|
||||||
|
fmul dword[t]
|
||||||
|
fadd dword[eax+offs_vert_tex_coord+offs_Y]
|
||||||
|
fstp dword[ebx+offs_vert_tex_coord+offs_Y] ;q.tex_coord.Y=p0.tex_coord.Y + (p1.tex_coord.Y-p0.tex_coord.Y)*t
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
; q->clip_code=gl_clipcode(q->pc.X,q->pc.Y,q->pc.Z,q->pc.W);
|
stdcall gl_clipcode, [ebx+offs_vert_pc+offs_X],[ebx+offs_vert_pc+offs_Y],\
|
||||||
; if (q->clip_code==0){
|
[ebx+offs_vert_pc+offs_Z],[ebx+offs_vert_pc+offs_W]
|
||||||
; gl_transform_to_viewport(c,q);
|
mov dword[ebx+offs_vert_clip_code],eax
|
||||||
; RGBFtoRGBI(q->color.v[0],q->color.v[1],q->color.v[2],q->zp.r,q->zp.g,q->zp.b);
|
cmp eax,0 ;if (q.clip_code==0)
|
||||||
; }
|
jne @f
|
||||||
|
stdcall gl_transform_to_viewport,[context],ebx
|
||||||
|
mov eax,ebx
|
||||||
|
add eax,offs_vert_zp+offs_zbup_b
|
||||||
|
push eax
|
||||||
|
add eax,offs_zbup_g-offs_zbup_b
|
||||||
|
push eax
|
||||||
|
add eax,offs_zbup_r-offs_zbup_g
|
||||||
|
push eax
|
||||||
|
stdcall RGBFtoRGBI, dword[ebx+offs_vert_color],dword[ebx+offs_vert_color+4],dword[ebx+offs_vert_color+8]
|
||||||
|
@@:
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
@ -677,17 +710,17 @@ pushad
|
|||||||
or edi,eax
|
or edi,eax
|
||||||
mov eax,[edx+offs_vert_clip_code]
|
mov eax,[edx+offs_vert_clip_code]
|
||||||
mov dword[cc+8],eax
|
mov dword[cc+8],eax
|
||||||
or edi,eax
|
or edi,eax ;co = cc[0] | cc[1] | cc[2]
|
||||||
|
|
||||||
; we handle the non clipped case here to go faster
|
; we handle the non clipped case here to go faster
|
||||||
cmp edi,0
|
cmp edi,0 ;if (co==0)
|
||||||
jne .els_0
|
jne .els_0
|
||||||
mov edi,dword[edx+offs_vert_zp+offs_zbup_x]
|
mov edi,dword[edx+offs_vert_zp+offs_zbup_x]
|
||||||
mov edi,dword[ebx+offs_vert_zp+offs_zbup_x]
|
sub edi,dword[ebx+offs_vert_zp+offs_zbup_x]
|
||||||
mov dword[norm],edi
|
mov dword[norm],edi
|
||||||
fild dword[norm]
|
fild dword[norm]
|
||||||
mov esi,dword[ecx+offs_vert_zp+offs_zbup_y]
|
mov esi,dword[ecx+offs_vert_zp+offs_zbup_y]
|
||||||
mov esi,dword[ebx+offs_vert_zp+offs_zbup_y]
|
sub esi,dword[ebx+offs_vert_zp+offs_zbup_y]
|
||||||
mov dword[norm],edi
|
mov dword[norm],edi
|
||||||
fimul dword[norm]
|
fimul dword[norm]
|
||||||
mov edi,dword[ecx+offs_vert_zp+offs_zbup_x]
|
mov edi,dword[ecx+offs_vert_zp+offs_zbup_x]
|
||||||
@ -695,7 +728,7 @@ pushad
|
|||||||
mov dword[norm],edi
|
mov dword[norm],edi
|
||||||
fild dword[norm]
|
fild dword[norm]
|
||||||
mov edi,dword[edx+offs_vert_zp+offs_zbup_y]
|
mov edi,dword[edx+offs_vert_zp+offs_zbup_y]
|
||||||
mov edi,dword[ebx+offs_vert_zp+offs_zbup_y]
|
sub edi,dword[ebx+offs_vert_zp+offs_zbup_y]
|
||||||
mov dword[norm],edi
|
mov dword[norm],edi
|
||||||
fimul dword[norm]
|
fimul dword[norm]
|
||||||
fsubp
|
fsubp
|
||||||
@ -741,9 +774,10 @@ pushad
|
|||||||
stdcall dword[edi+offs_cont_draw_triangle_back], edi,ebx,ecx,edx
|
stdcall dword[edi+offs_cont_draw_triangle_back], edi,ebx,ecx,edx
|
||||||
jmp .end_f
|
jmp .end_f
|
||||||
.els_0:
|
.els_0:
|
||||||
|
;eax = cc[2]
|
||||||
and eax,[cc]
|
and eax,[cc]
|
||||||
and eax,[cc+4]
|
and eax,[cc+4] ;eax = c_and = cc[0] & cc[1] & cc[2]
|
||||||
cmp eax,0
|
cmp eax,0 ;if (c_and==0)
|
||||||
jne .end_f
|
jne .end_f
|
||||||
stdcall gl_draw_triangle_clip, [context],ebx,ecx,edx,0
|
stdcall gl_draw_triangle_clip, [context],ebx,ecx,edx,0
|
||||||
.end_f:
|
.end_f:
|
||||||
@ -755,47 +789,69 @@ align 4
|
|||||||
proc gl_draw_triangle_clip, context:dword, p0:dword, p1:dword, p2:dword, clip_bit:dword
|
proc gl_draw_triangle_clip, context:dword, p0:dword, p1:dword, p2:dword, clip_bit:dword
|
||||||
locals
|
locals
|
||||||
co dd ?
|
co dd ?
|
||||||
co1 dd ?
|
|
||||||
cc rd 3
|
cc rd 3
|
||||||
edge_flag_tmp dd ?
|
edge_flag_tmp dd ?
|
||||||
clip_mask dd ?
|
clip_mask dd ?
|
||||||
|
q rd 3 ;GLVertex*
|
||||||
tmp1 GLVertex ?
|
tmp1 GLVertex ?
|
||||||
tmp2 GLVertex ?
|
tmp2 GLVertex ?
|
||||||
q rd 3 ;GLVertex*
|
|
||||||
tt dd ? ;float
|
|
||||||
endl
|
endl
|
||||||
pushad
|
pushad
|
||||||
|
|
||||||
mov ebx,[p0]
|
mov ebx,[p0]
|
||||||
mov ecx,[p1]
|
mov ecx,[p1]
|
||||||
mov edx,[p2]
|
mov edx,[p2]
|
||||||
|
|
||||||
|
if DEBUG ;(1) gl_draw_triangle_clip
|
||||||
|
pushad
|
||||||
|
stdcall dbg_print,txt_sp,m_1
|
||||||
|
add ebx,offs_vert_color
|
||||||
|
add ecx,offs_vert_color
|
||||||
|
add edx,offs_vert_color
|
||||||
|
stdcall gl_print_matrix,ebx,1
|
||||||
|
stdcall gl_print_matrix,ecx,1
|
||||||
|
stdcall gl_print_matrix,edx,1
|
||||||
|
popad
|
||||||
|
end if
|
||||||
|
|
||||||
|
; finit ;???
|
||||||
|
|
||||||
mov edi,[ebx+offs_vert_clip_code]
|
mov edi,[ebx+offs_vert_clip_code]
|
||||||
mov dword[cc],edi
|
mov [cc],edi
|
||||||
mov eax,[ecx+offs_vert_clip_code]
|
mov eax,[ecx+offs_vert_clip_code]
|
||||||
mov dword[cc+4],eax
|
mov [cc+4],eax
|
||||||
or edi,eax
|
or edi,eax
|
||||||
mov eax,[edx+offs_vert_clip_code]
|
mov eax,[edx+offs_vert_clip_code]
|
||||||
mov dword[cc+8],eax
|
mov [cc+8],eax
|
||||||
or edi,eax
|
or edi,eax
|
||||||
mov dword[co],edi
|
mov [co],edi ;co = cc[0] | cc[1] | cc[2]
|
||||||
|
|
||||||
cmp edi,0
|
cmp edi,0 ;if (co == 0)
|
||||||
jne .els_0
|
jne .els_0
|
||||||
stdcall gl_draw_triangle, [context],ebx,ecx,edx
|
stdcall gl_draw_triangle, [context],ebx,ecx,edx
|
||||||
jmp .end_f
|
jmp .end_f
|
||||||
.els_0:
|
.els_0:
|
||||||
|
;eax = cc[2]
|
||||||
and eax,[cc]
|
and eax,[cc]
|
||||||
and eax,[cc+4]
|
and eax,[cc+4] ;c_and = cc[0] & cc[1] & cc[2]
|
||||||
|
|
||||||
; the triangle is completely outside
|
; the triangle is completely outside
|
||||||
cmp eax,0
|
cmp eax,0 ;if (c_and!=0) return
|
||||||
jne .end_f
|
jne .end_f
|
||||||
|
|
||||||
; find the next direction to clip
|
; find the next direction to clip
|
||||||
; while (clip_bit < 6 && (co & (1 << clip_bit)) == 0) {
|
.cycle_0: ;while (clip_bit < 6 && (co & (1 << clip_bit)) == 0)
|
||||||
; clip_bit++;
|
cmp dword[clip_bit],6
|
||||||
; }
|
jge .cycle_0_end
|
||||||
|
xor eax,eax
|
||||||
|
inc eax
|
||||||
|
mov ecx,[clip_bit]
|
||||||
|
shl eax,cl
|
||||||
|
and eax,[co]
|
||||||
|
cmp eax,0
|
||||||
|
jne .cycle_0_end
|
||||||
|
inc dword[clip_bit]
|
||||||
|
jmp .cycle_0
|
||||||
|
.cycle_0_end:
|
||||||
|
|
||||||
; this test can be true only in case of rounding errors
|
; this test can be true only in case of rounding errors
|
||||||
cmp dword[clip_bit],6
|
cmp dword[clip_bit],6
|
||||||
@ -807,53 +863,172 @@ if 0
|
|||||||
; printf("%f %f %f %f\n",p2->pc.X,p2->pc.Y,p2->pc.Z,p2->pc.W);
|
; printf("%f %f %f %f\n",p2->pc.X,p2->pc.Y,p2->pc.Z,p2->pc.W);
|
||||||
jmp .end_f
|
jmp .end_f
|
||||||
@@:
|
@@:
|
||||||
else
|
end if
|
||||||
|
if 1
|
||||||
je .end_f
|
je .end_f
|
||||||
end if
|
end if
|
||||||
|
|
||||||
; clip_mask = 1 << clip_bit;
|
xor eax,eax
|
||||||
; co1=(cc[0] ^ cc[1] ^ cc[2]) & clip_mask;
|
inc eax
|
||||||
|
mov ecx,[clip_bit]
|
||||||
|
shl eax,cl
|
||||||
|
mov [clip_mask],eax ;1 << clip_bit
|
||||||
|
mov edi,[cc]
|
||||||
|
xor edi,[cc+4]
|
||||||
|
xor edi,[cc+8]
|
||||||
|
and eax,edi ;eax = co1 = (cc[0] ^ cc[1] ^ cc[2]) & clip_mask
|
||||||
|
|
||||||
; if (co1) {
|
mov ecx,[p1] ;востанавливаем после shl ___,cl
|
||||||
; /* one point outside */
|
|
||||||
|
|
||||||
; if (cc[0] & clip_mask) { q[0]=p0; q[1]=p1; q[2]=p2; }
|
cmp eax,0 ;if (co1)
|
||||||
; else if (cc[1] & clip_mask) { q[0]=p1; q[1]=p2; q[2]=p0; }
|
je .els_1
|
||||||
; else { q[0]=p2; q[1]=p0; q[2]=p1; }
|
; one point outside
|
||||||
;
|
mov eax,[cc]
|
||||||
; tt=clip_proc[clip_bit](&tmp1.pc,&q[0]->pc,&q[1]->pc);
|
and eax,[clip_mask]
|
||||||
; updateTmp(c,&tmp1,q[0],q[1],tt);
|
cmp eax,0 ;if (cc[0] & clip_mask)
|
||||||
;
|
je .els_2
|
||||||
; tt=clip_proc[clip_bit](&tmp2.pc,&q[0]->pc,&q[2]->pc);
|
;q[0]=p0 q[1]=p1 q[2]=p2
|
||||||
; updateTmp(c,&tmp2,q[0],q[2],tt);
|
mov [q],ebx
|
||||||
;
|
mov [q+4],ecx
|
||||||
; tmp1.edge_flag=q[0]->edge_flag;
|
mov [q+8],edx
|
||||||
; edge_flag_tmp=q[2]->edge_flag;
|
jmp .els_2_end
|
||||||
; q[2]->edge_flag=0;
|
.els_2:
|
||||||
; gl_draw_triangle_clip(c,&tmp1,q[1],q[2],clip_bit+1);
|
mov eax,[cc+4]
|
||||||
;
|
and eax,[clip_mask]
|
||||||
; tmp2.edge_flag=0;
|
cmp eax,0 ;else if (cc[1] & clip_mask)
|
||||||
; tmp1.edge_flag=0;
|
je .els_3
|
||||||
; q[2]->edge_flag=edge_flag_tmp;
|
;q[0]=p1 q[1]=p2 q[2]=p0
|
||||||
; gl_draw_triangle_clip(c,&tmp2,&tmp1,q[2],clip_bit+1);
|
mov [q],ecx
|
||||||
; } else {
|
mov [q+4],edx
|
||||||
; /* two points outside */
|
mov [q+8],ebx
|
||||||
|
jmp .els_2_end
|
||||||
|
.els_3:
|
||||||
|
;q[0]=p2 q[1]=p0 q[2]=p1
|
||||||
|
mov [q],edx
|
||||||
|
mov [q+4],ebx
|
||||||
|
mov [q+8],ecx
|
||||||
|
.els_2_end:
|
||||||
|
|
||||||
; if ((cc[0] & clip_mask)==0) { q[0]=p0; q[1]=p1; q[2]=p2; }
|
mov ebx,[q]
|
||||||
; else if ((cc[1] & clip_mask)==0) { q[0]=p1; q[1]=p2; q[2]=p0; }
|
add ebx,offs_vert_pc
|
||||||
; else { q[0]=p2; q[1]=p0; q[2]=p1; }
|
mov ecx,[q+4]
|
||||||
|
add ecx,offs_vert_pc
|
||||||
|
mov edx,[q+8]
|
||||||
|
add edx,offs_vert_pc
|
||||||
|
|
||||||
; tt=clip_proc[clip_bit](&tmp1.pc,&q[0]->pc,&q[1]->pc);
|
lea eax,[clip_proc]
|
||||||
; updateTmp(c,&tmp1,q[0],q[1],tt);
|
mov edi,[clip_bit]
|
||||||
|
shl edi,2
|
||||||
|
add eax,edi
|
||||||
|
mov edi,ebp
|
||||||
|
sub edi,(2*sizeof.GLVertex)-offs_vert_pc
|
||||||
|
stdcall dword[eax],edi,ebx,ecx ;clip_proc[clip_bit](&tmp1.pc,&q[0].pc,&q[1].pc)
|
||||||
|
sub edi,offs_vert_pc
|
||||||
|
|
||||||
; tt=clip_proc[clip_bit](&tmp2.pc,&q[0]->pc,&q[2]->pc);
|
sub ebx,offs_vert_pc
|
||||||
; updateTmp(c,&tmp2,q[0],q[2],tt);
|
sub ecx,offs_vert_pc
|
||||||
|
stdcall updateTmp,[context],edi,ebx,ecx,eax ;updateTmp(c,&tmp1,q[0],q[1],tt)
|
||||||
|
add ebx,offs_vert_pc
|
||||||
|
|
||||||
; tmp1.edge_flag=1;
|
lea eax,[clip_proc]
|
||||||
; tmp2.edge_flag=q[2]->edge_flag;
|
mov edi,[clip_bit]
|
||||||
; gl_draw_triangle_clip(c,q[0],&tmp1,&tmp2,clip_bit+1);
|
shl edi,2
|
||||||
; }
|
add eax,edi
|
||||||
; }
|
mov edi,ebp
|
||||||
|
sub edi,sizeof.GLVertex-offs_vert_pc
|
||||||
|
stdcall dword[eax],edi,ebx,edx ;clip_proc[clip_bit](&tmp2.pc,&q[0].pc,&q[2].pc)
|
||||||
|
sub edi,offs_vert_pc
|
||||||
|
sub ebx,offs_vert_pc
|
||||||
|
sub edx,offs_vert_pc
|
||||||
|
stdcall updateTmp,[context],edi,ebx,edx,eax ;updateTmp(c,&tmp2,q[0],q[2],tt)
|
||||||
|
|
||||||
|
mov eax,[ebx+offs_vert_edge_flag]
|
||||||
|
mov [tmp1+offs_vert_edge_flag],eax ;q[0].edge_flag
|
||||||
|
mov eax,[edx+offs_vert_edge_flag]
|
||||||
|
mov [edge_flag_tmp],eax ;q[2].edge_flag
|
||||||
|
mov dword[edx+offs_vert_edge_flag],0 ;q[2].edge_flag=0
|
||||||
|
mov eax,[clip_bit]
|
||||||
|
inc eax
|
||||||
|
push eax ;для вызова нижней функции
|
||||||
|
mov edi,ebp
|
||||||
|
sub edi,2*sizeof.GLVertex
|
||||||
|
stdcall gl_draw_triangle_clip,[context],edi,ecx,edx,eax ;gl_draw_triangle_clip(c,&tmp1,q[1],q[2],clip_bit+1)
|
||||||
|
|
||||||
|
mov dword[tmp2.edge_flag],0
|
||||||
|
mov dword[tmp1.edge_flag],0
|
||||||
|
mov eax,[edge_flag_tmp]
|
||||||
|
mov [edx+offs_vert_edge_flag],eax ;q[2].edge_flag=edge_flag_tmp
|
||||||
|
push edx
|
||||||
|
push edi
|
||||||
|
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
|
||||||
|
.els_1:
|
||||||
|
; two points outside
|
||||||
|
mov eax,[cc]
|
||||||
|
and eax,[clip_mask]
|
||||||
|
cmp eax,0 ;if (cc[0] & clip_mask)==0
|
||||||
|
jne .els_4
|
||||||
|
;q[0]=p0 q[1]=p1 q[2]=p2
|
||||||
|
mov [q],ebx
|
||||||
|
mov [q+4],ecx
|
||||||
|
mov [q+8],edx
|
||||||
|
jmp .els_4_end
|
||||||
|
.els_4:
|
||||||
|
mov eax,[cc+4]
|
||||||
|
and eax,[clip_mask]
|
||||||
|
cmp eax,0 ;else if (cc[1] & clip_mask)==0
|
||||||
|
jne .els_5
|
||||||
|
;q[0]=p1 q[1]=p2 q[2]=p0
|
||||||
|
mov [q],ecx
|
||||||
|
mov [q+4],edx
|
||||||
|
mov [q+8],ebx
|
||||||
|
jmp .els_4_end
|
||||||
|
.els_5:
|
||||||
|
;q[0]=p2 q[1]=p0 q[2]=p1
|
||||||
|
mov [q],edx
|
||||||
|
mov [q+4],ebx
|
||||||
|
mov [q+8],ecx
|
||||||
|
.els_4_end:
|
||||||
|
|
||||||
|
mov ebx,[q]
|
||||||
|
add ebx,offs_vert_pc
|
||||||
|
mov ecx,[q+4]
|
||||||
|
add ecx,offs_vert_pc
|
||||||
|
mov edx,[q+8]
|
||||||
|
add edx,offs_vert_pc
|
||||||
|
|
||||||
|
lea eax,[clip_proc]
|
||||||
|
mov edi,[clip_bit]
|
||||||
|
shl edi,2
|
||||||
|
add eax,edi
|
||||||
|
mov edi,ebp
|
||||||
|
sub edi,(2*sizeof.GLVertex)-offs_vert_pc
|
||||||
|
stdcall dword[eax],edi,ebx,ecx ;clip_proc[clip_bit](&tmp1.pc,&q[0].pc,&q[1].pc)
|
||||||
|
sub edi,offs_vert_pc
|
||||||
|
stdcall updateTmp,[context],edi,[q],[q+4],eax
|
||||||
|
|
||||||
|
lea eax,[clip_proc]
|
||||||
|
mov edi,[clip_bit]
|
||||||
|
shl edi,2
|
||||||
|
add eax,edi
|
||||||
|
mov edi,ebp
|
||||||
|
sub edi,sizeof.GLVertex-offs_vert_pc
|
||||||
|
stdcall dword[eax],edi,ebx,edx ;clip_proc[clip_bit](&tmp2.pc,&q[0].pc,&q[2].pc)
|
||||||
|
sub edi,offs_vert_pc
|
||||||
|
stdcall updateTmp,[context],edi,[q],[q+8],eax
|
||||||
|
|
||||||
|
mov edx,[q+8]
|
||||||
|
|
||||||
|
mov dword[tmp1+offs_vert_edge_flag],1
|
||||||
|
mov eax,[edx+offs_vert_edge_flag]
|
||||||
|
mov dword[tmp1+offs_vert_edge_flag],eax ;tmp2.edge_flag = q[2].edge_flag
|
||||||
|
mov eax,[clip_bit]
|
||||||
|
inc eax
|
||||||
|
push eax
|
||||||
|
push edi
|
||||||
|
sub edi,sizeof.GLVertex
|
||||||
|
stdcall gl_draw_triangle_clip,[context],[q],edi ;gl_draw_triangle_clip(c,q[0],&tmp1,&tmp2,clip_bit+1)
|
||||||
.end_f:
|
.end_f:
|
||||||
popad
|
popad
|
||||||
ret
|
ret
|
||||||
|
@ -421,8 +421,6 @@ align 4
|
|||||||
proc gl_clipcode uses ebx, x:dword, y:dword, z:dword, w1:dword
|
proc gl_clipcode uses ebx, x:dword, y:dword, z:dword, w1:dword
|
||||||
xor ebx,ebx
|
xor ebx,ebx
|
||||||
|
|
||||||
;ffree st0
|
|
||||||
;fincstp
|
|
||||||
fld1
|
fld1
|
||||||
fadd dword[CLIP_EPSILON]
|
fadd dword[CLIP_EPSILON]
|
||||||
fmul dword[w1]
|
fmul dword[w1]
|
||||||
@ -466,6 +464,9 @@ proc gl_clipcode uses ebx, x:dword, y:dword, z:dword, w1:dword
|
|||||||
or ebx,16
|
or ebx,16
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
|
|
||||||
mov eax,ebx
|
mov eax,ebx
|
||||||
if DEBUG ;gl_clipcode
|
if DEBUG ;gl_clipcode
|
||||||
push edi
|
push edi
|
||||||
|
@ -6,14 +6,11 @@ macro DRAW_INIT
|
|||||||
if TGL_FEATURE_RENDER_BITS eq 24
|
if TGL_FEATURE_RENDER_BITS eq 24
|
||||||
mov ecx,[p2]
|
mov ecx,[p2]
|
||||||
mov eax,[ecx+offs_zbup_r]
|
mov eax,[ecx+offs_zbup_r]
|
||||||
shr eax,8
|
mov [colorR],ah ;colorR=p2.r>>8
|
||||||
mov [colorR],al ;colorR=p2.r>>8
|
|
||||||
mov eax,[ecx+offs_zbup_g]
|
mov eax,[ecx+offs_zbup_g]
|
||||||
shr eax,8
|
mov [colorG],ah ;colorG=p2.g>>8
|
||||||
mov [colorG],al ;colorG=p2.g>>8
|
|
||||||
mov eax,[ecx+offs_zbup_b]
|
mov eax,[ecx+offs_zbup_b]
|
||||||
shr eax,8
|
mov [colorB],ah ;colorB=p2.b>>8
|
||||||
mov [colorB],al ;colorB=p2.b>>8
|
|
||||||
;else
|
;else
|
||||||
; color=RGB_TO_PIXEL(p2->r,p2->g,p2->b);
|
; color=RGB_TO_PIXEL(p2->r,p2->g,p2->b);
|
||||||
end if
|
end if
|
||||||
@ -133,7 +130,7 @@ if code eq 0
|
|||||||
end if
|
end if
|
||||||
if code eq 1
|
if code eq 1
|
||||||
mov eax,[x2]
|
mov eax,[x2]
|
||||||
shr eax,16
|
sar eax,16
|
||||||
sub eax,[x1]
|
sub eax,[x1]
|
||||||
mov [n],eax ;n = (x2 >> 16) - x1
|
mov [n],eax ;n = (x2 >> 16) - x1
|
||||||
; pp=pp1+x1;
|
; pp=pp1+x1;
|
||||||
|
@ -536,11 +536,7 @@ end if
|
|||||||
mov dword[error],0 ;error = 0
|
mov dword[error],0 ;error = 0
|
||||||
mov dword[derror],eax
|
mov dword[derror],eax
|
||||||
and dword[derror],0xffff ;derror = eax & 0x0000ffff
|
and dword[derror],0xffff ;derror = eax & 0x0000ffff
|
||||||
shr eax,16
|
sar eax,16
|
||||||
bt eax,15
|
|
||||||
jnc @f
|
|
||||||
or eax,0xffff0000
|
|
||||||
@@:
|
|
||||||
mov [dxdy_min],eax ;dxdy_min = eax >> 16
|
mov [dxdy_min],eax ;dxdy_min = eax >> 16
|
||||||
inc eax
|
inc eax
|
||||||
mov [dxdy_max],eax
|
mov [dxdy_max],eax
|
||||||
@ -686,40 +682,13 @@ if DRAW_LINE_M eq 1
|
|||||||
else
|
else
|
||||||
; generic draw line
|
; generic draw line
|
||||||
mov eax,[x2]
|
mov eax,[x2]
|
||||||
shr eax,16
|
sar eax,16
|
||||||
mov edi,[x1]
|
mov edi,[x1]
|
||||||
sub eax,edi
|
sub eax,edi
|
||||||
mov [n],eax ;n = (x2 >> 16) - x1
|
mov [n],eax ;n = (x2 >> 16) - x1
|
||||||
imul edi,PSZB
|
imul edi,PSZB
|
||||||
add edi,[pp1] ;pp = pp1 + x1 * PSZB
|
add edi,[pp1] ;pp = pp1 + x1 * PSZB
|
||||||
|
|
||||||
if DEBUG ;[n], [x1], [x2]>>16
|
|
||||||
push ecx edi
|
|
||||||
mov eax,[n]
|
|
||||||
mov ecx,80
|
|
||||||
lea edi,[buf_param]
|
|
||||||
stdcall convert_int_to_str,ecx
|
|
||||||
stdcall str_n_cat,edi,txt_zp_sp,2
|
|
||||||
stdcall str_len,edi
|
|
||||||
add edi,eax
|
|
||||||
sub ecx,eax
|
|
||||||
|
|
||||||
mov eax,[x1]
|
|
||||||
stdcall convert_int_to_str,ecx
|
|
||||||
stdcall str_n_cat,edi,txt_zp_sp,2
|
|
||||||
stdcall str_len,edi
|
|
||||||
add edi,eax
|
|
||||||
sub ecx,eax
|
|
||||||
|
|
||||||
mov eax,[x2]
|
|
||||||
shr eax,16
|
|
||||||
stdcall convert_int_to_str,ecx
|
|
||||||
|
|
||||||
stdcall str_n_cat,edi,txt_nl,2
|
|
||||||
stdcall dbg_print,f_fill_tr_nll,buf_param
|
|
||||||
pop edi ecx
|
|
||||||
end if
|
|
||||||
|
|
||||||
if INTERP_Z eq 1
|
if INTERP_Z eq 1
|
||||||
mov eax,[x1]
|
mov eax,[x1]
|
||||||
shl eax,1
|
shl eax,1
|
||||||
|
Loading…
Reference in New Issue
Block a user