forked from KolibriOS/kolibrios
fix in some vertex functions
git-svn-id: svn://kolibrios.org@5175 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
1b1d267df0
commit
c3161395bd
@ -169,29 +169,29 @@ proc interpolate uses eax ebx ecx, q:dword,p0:dword,p1:dword,t:dword
|
|||||||
fld dword[t]
|
fld dword[t]
|
||||||
|
|
||||||
; интерполяция по координатам
|
; интерполяция по координатам
|
||||||
fld dword[ecx+offs_vert_pc]
|
fld dword[ecx+offs_vert_pc+offs_X]
|
||||||
fsub dword[ebx+offs_vert_pc]
|
fsub dword[ebx+offs_vert_pc+offs_X]
|
||||||
fmul st0,st1
|
fmul st0,st1
|
||||||
fadd dword[ebx+offs_vert_pc]
|
fadd dword[ebx+offs_vert_pc+offs_X]
|
||||||
fstp dword[eax+offs_vert_pc]
|
fstp dword[eax+offs_vert_pc+offs_X]
|
||||||
|
|
||||||
fld dword[ecx+offs_vert_pc+4]
|
fld dword[ecx+offs_vert_pc+offs_Y]
|
||||||
fsub dword[ebx+offs_vert_pc+4]
|
fsub dword[ebx+offs_vert_pc+offs_Y]
|
||||||
fmul st0,st1
|
fmul st0,st1
|
||||||
fadd dword[ebx+offs_vert_pc+4]
|
fadd dword[ebx+offs_vert_pc+offs_Y]
|
||||||
fstp dword[eax+offs_vert_pc+4]
|
fstp dword[eax+offs_vert_pc+offs_Y]
|
||||||
|
|
||||||
fld dword[ecx+offs_vert_pc+8]
|
fld dword[ecx+offs_vert_pc+offs_Z]
|
||||||
fsub dword[ebx+offs_vert_pc+8]
|
fsub dword[ebx+offs_vert_pc+offs_Z]
|
||||||
fmul st0,st1
|
fmul st0,st1
|
||||||
fadd dword[ebx+offs_vert_pc+8]
|
fadd dword[ebx+offs_vert_pc+offs_Z]
|
||||||
fstp dword[eax+offs_vert_pc+8]
|
fstp dword[eax+offs_vert_pc+offs_Z]
|
||||||
|
|
||||||
fld dword[ecx+offs_vert_pc+12]
|
fld dword[ecx+offs_vert_pc+offs_W]
|
||||||
fsub dword[ebx+offs_vert_pc+12]
|
fsub dword[ebx+offs_vert_pc+offs_W]
|
||||||
fmul st0,st1
|
fmul st0,st1
|
||||||
fadd dword[ebx+offs_vert_pc+12]
|
fadd dword[ebx+offs_vert_pc+offs_W]
|
||||||
fstp dword[eax+offs_vert_pc+12]
|
fstp dword[eax+offs_vert_pc+offs_W]
|
||||||
|
|
||||||
; интерполяция по цвету
|
; интерполяция по цвету
|
||||||
fld dword[ecx+offs_vert_color]
|
fld dword[ecx+offs_vert_color]
|
||||||
@ -531,17 +531,17 @@ endl
|
|||||||
mov edx,[a]
|
mov edx,[a]
|
||||||
mov ebx,[b]
|
mov ebx,[b]
|
||||||
mov ecx,[c]
|
mov ecx,[c]
|
||||||
fld dword[ebx]
|
fld dword[ebx+offs_X]
|
||||||
fsub dword[edx]
|
fsub dword[edx+offs_X]
|
||||||
fstp dword[d_X] ;d_X = (b.X - a.X)
|
fstp dword[d_X] ;d_X = (b.X - a.X)
|
||||||
fld dword[ebx+4]
|
fld dword[ebx+offs_Y]
|
||||||
fsub dword[edx+4]
|
fsub dword[edx+offs_Y]
|
||||||
fstp dword[d_Y] ;d_Y = (b.Y - a.Y)
|
fstp dword[d_Y] ;d_Y = (b.Y - a.Y)
|
||||||
fld dword[ebx+8]
|
fld dword[ebx+offs_Z]
|
||||||
fsub dword[edx+8]
|
fsub dword[edx+offs_Z]
|
||||||
fstp dword[d_Z] ;d_Z = (b.Z - a.Z)
|
fstp dword[d_Z] ;d_Z = (b.Z - a.Z)
|
||||||
fld dword[ebx+12]
|
fld dword[ebx+offs_W]
|
||||||
fsub dword[edx+12]
|
fsub dword[edx+offs_W]
|
||||||
fst dword[d_W] ;d_W = (b.W - a.W)
|
fst dword[d_W] ;d_W = (b.W - a.W)
|
||||||
if sign eq 0
|
if sign eq 0
|
||||||
fadd dword[d#dir]
|
fadd dword[d#dir]
|
||||||
@ -550,15 +550,13 @@ else
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
fldz
|
fldz
|
||||||
fcomp st1
|
fcompp
|
||||||
fstsw ax
|
fstsw ax
|
||||||
sahf
|
sahf
|
||||||
ja @f
|
ja @f
|
||||||
fincstp
|
|
||||||
fst dword[t] ;t=0
|
fst dword[t] ;t=0
|
||||||
jmp .e_zero
|
jmp .e_zero
|
||||||
@@: ;else
|
@@: ;else
|
||||||
fincstp
|
|
||||||
fld dword[edx+offs#dir]
|
fld dword[edx+offs#dir]
|
||||||
if sign eq 0
|
if sign eq 0
|
||||||
fchs
|
fchs
|
||||||
@ -628,115 +626,189 @@ endp
|
|||||||
align 4
|
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
|
||||||
|
|
||||||
;static inline void updateTmp(GLContext *c, GLVertex *q,GLVertex *p0,GLVertex *p1,float t)
|
align 4
|
||||||
;{
|
proc updateTmp uses edx, context:dword, q:dword, p0:dword, p1:dword, t:dword
|
||||||
; if (c->current_shade_model == GL_SMOOTH) {
|
mov eax,[context]
|
||||||
|
cmp dword[edx+offs_cont_current_shade_model],GL_SMOOTH ;if (context.current_shade_model == GL_SMOOTH)
|
||||||
|
jne .els_0
|
||||||
; q->color.v[0]=p0->color.v[0] + (p1->color.v[0]-p0->color.v[0])*t;
|
; q->color.v[0]=p0->color.v[0] + (p1->color.v[0]-p0->color.v[0])*t;
|
||||||
; q->color.v[1]=p0->color.v[1] + (p1->color.v[1]-p0->color.v[1])*t;
|
; q->color.v[1]=p0->color.v[1] + (p1->color.v[1]-p0->color.v[1])*t;
|
||||||
; q->color.v[2]=p0->color.v[2] + (p1->color.v[2]-p0->color.v[2])*t;
|
; q->color.v[2]=p0->color.v[2] + (p1->color.v[2]-p0->color.v[2])*t;
|
||||||
; } else {
|
jmp @f
|
||||||
|
.els_0:
|
||||||
; q->color.v[0]=p0->color.v[0];
|
; q->color.v[0]=p0->color.v[0];
|
||||||
; q->color.v[1]=p0->color.v[1];
|
; q->color.v[1]=p0->color.v[1];
|
||||||
; q->color.v[2]=p0->color.v[2];
|
; q->color.v[2]=p0->color.v[2];
|
||||||
; }
|
@@:
|
||||||
|
|
||||||
; if (c->texture_2d_enabled) {
|
cmp dword[edx+offs_cont_texture_2d_enabled],0 ;if (context.texture_2d_enabled)
|
||||||
|
je @f
|
||||||
; q->tex_coord.X=p0->tex_coord.X + (p1->tex_coord.X-p0->tex_coord.X)*t;
|
; q->tex_coord.X=p0->tex_coord.X + (p1->tex_coord.X-p0->tex_coord.X)*t;
|
||||||
; q->tex_coord.Y=p0->tex_coord.Y + (p1->tex_coord.Y-p0->tex_coord.Y)*t;
|
; 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);
|
; q->clip_code=gl_clipcode(q->pc.X,q->pc.Y,q->pc.Z,q->pc.W);
|
||||||
; if (q->clip_code==0){
|
; if (q->clip_code==0){
|
||||||
; gl_transform_to_viewport(c,q);
|
; gl_transform_to_viewport(c,q);
|
||||||
; RGBFtoRGBI(q->color.v[0],q->color.v[1],q->color.v[2],q->zp.r,q->zp.g,q->zp.b);
|
; RGBFtoRGBI(q->color.v[0],q->color.v[1],q->color.v[2],q->zp.r,q->zp.g,q->zp.b);
|
||||||
; }
|
; }
|
||||||
;}
|
ret
|
||||||
|
endp
|
||||||
|
|
||||||
;static void gl_draw_triangle_clip(GLContext *c, GLVertex *p0,GLVertex *p1,GLVertex *p2,int clip_bit);
|
align 4
|
||||||
|
proc gl_draw_triangle, context:dword, p0:dword, p1:dword, p2:dword
|
||||||
|
locals
|
||||||
|
cc rd 3
|
||||||
|
front dd ?
|
||||||
|
norm dd ? ;float
|
||||||
|
endl
|
||||||
|
pushad
|
||||||
|
mov ebx,[p0]
|
||||||
|
mov ecx,[p1]
|
||||||
|
mov edx,[p2]
|
||||||
|
|
||||||
|
mov edi,[ebx+offs_vert_clip_code]
|
||||||
|
mov dword[cc],edi
|
||||||
|
mov eax,[ecx+offs_vert_clip_code]
|
||||||
|
mov dword[cc+4],eax
|
||||||
|
or edi,eax
|
||||||
|
mov eax,[edx+offs_vert_clip_code]
|
||||||
|
mov dword[cc+8],eax
|
||||||
|
or edi,eax
|
||||||
|
|
||||||
;void gl_draw_triangle(GLContext *c, GLVertex *p0,GLVertex *p1,GLVertex *p2)
|
; we handle the non clipped case here to go faster
|
||||||
;{
|
cmp edi,0
|
||||||
; int co,c_and,cc[3],front;
|
jne .els_0
|
||||||
; float norm;
|
mov edi,dword[edx+offs_vert_zp+offs_zbup_x]
|
||||||
;
|
mov edi,dword[ebx+offs_vert_zp+offs_zbup_x]
|
||||||
; cc[0]=p0->clip_code;
|
mov dword[norm],edi
|
||||||
; cc[1]=p1->clip_code;
|
fild dword[norm]
|
||||||
; cc[2]=p2->clip_code;
|
mov esi,dword[ecx+offs_vert_zp+offs_zbup_y]
|
||||||
;
|
mov esi,dword[ebx+offs_vert_zp+offs_zbup_y]
|
||||||
; co=cc[0] | cc[1] | cc[2];
|
mov dword[norm],edi
|
||||||
;
|
fimul dword[norm]
|
||||||
; /* we handle the non clipped case here to go faster */
|
mov edi,dword[ecx+offs_vert_zp+offs_zbup_x]
|
||||||
; if (co==0) {
|
sub edi,dword[ebx+offs_vert_zp+offs_zbup_x]
|
||||||
;
|
mov dword[norm],edi
|
||||||
; norm=(float)(p1->zp.x-p0->zp.x)*(float)(p2->zp.y-p0->zp.y)-
|
fild dword[norm]
|
||||||
; (float)(p2->zp.x-p0->zp.x)*(float)(p1->zp.y-p0->zp.y);
|
mov edi,dword[edx+offs_vert_zp+offs_zbup_y]
|
||||||
;
|
mov edi,dword[ebx+offs_vert_zp+offs_zbup_y]
|
||||||
; if (norm == 0) return;
|
mov dword[norm],edi
|
||||||
;
|
fimul dword[norm]
|
||||||
; front = norm < 0.0;
|
fsub st0,st1
|
||||||
; front = front ^ c->current_front_face;
|
|
||||||
;
|
|
||||||
; /* back face culling */
|
|
||||||
; if (c->cull_face_enabled) {
|
|
||||||
; /* most used case first */
|
|
||||||
; if (c->current_cull_face == GL_BACK) {
|
|
||||||
; if (front == 0) return;
|
|
||||||
; c->draw_triangle_front(c,p0,p1,p2);
|
|
||||||
; } else if (c->current_cull_face == GL_FRONT) {
|
|
||||||
; if (front != 0) return;
|
|
||||||
; c->draw_triangle_back(c,p0,p1,p2);
|
|
||||||
; } else {
|
|
||||||
; return;
|
|
||||||
; }
|
|
||||||
; } else {
|
|
||||||
; /* no culling */
|
|
||||||
; if (front) {
|
|
||||||
; c->draw_triangle_front(c,p0,p1,p2);
|
|
||||||
; } else {
|
|
||||||
; c->draw_triangle_back(c,p0,p1,p2);
|
|
||||||
; }
|
|
||||||
; }
|
|
||||||
; } else {
|
|
||||||
; c_and=cc[0] & cc[1] & cc[2];
|
|
||||||
; if (c_and==0) {
|
|
||||||
; gl_draw_triangle_clip(c,p0,p1,p2,0);
|
|
||||||
; }
|
|
||||||
; }
|
|
||||||
;}
|
|
||||||
|
|
||||||
;static void gl_draw_triangle_clip(GLContext *c, GLVertex *p0,GLVertex *p1,GLVertex *p2,int clip_bit)
|
;st0 = (p1.zp.x-p0.zp.x)*(p2.zp.y-p0.zp.y) - (p2.zp.x-p0.zp.x)*(p1.zp.y-p0.zp.y)
|
||||||
;{
|
|
||||||
; int co,c_and,co1,cc[3],edge_flag_tmp,clip_mask;
|
|
||||||
; GLVertex tmp1,tmp2,*q[3];
|
|
||||||
; float tt;
|
|
||||||
|
|
||||||
; cc[0]=p0->clip_code;
|
mov dword[front],0
|
||||||
; cc[1]=p1->clip_code;
|
fldz
|
||||||
; cc[2]=p2->clip_code;
|
fcom st1
|
||||||
|
fstsw ax
|
||||||
|
sahf
|
||||||
|
je .end_f
|
||||||
|
jb @f
|
||||||
|
inc dword[front] ;front = 0.0 > norm
|
||||||
|
@@:
|
||||||
|
mov edi,[context]
|
||||||
|
mov eax,dword[edi+offs_cont_current_front_face]
|
||||||
|
xor dword[front],eax ;front ^= context.current_front_face
|
||||||
|
|
||||||
; co=cc[0] | cc[1] | cc[2];
|
; back face culling
|
||||||
; if (co == 0) {
|
cmp dword[edi+offs_cont_cull_face_enabled],0
|
||||||
; gl_draw_triangle(c,p0,p1,p2);
|
je .els_1
|
||||||
; } else {
|
; most used case first
|
||||||
; c_and=cc[0] & cc[1] & cc[2];
|
cmp dword[edi+offs_cont_current_cull_face],GL_BACK
|
||||||
; /* the triangle is completely outside */
|
jne @f
|
||||||
; if (c_and!=0) return;
|
cmp dword[front],0
|
||||||
|
je .end_f
|
||||||
|
stdcall dword[edi+offs_cont_draw_triangle_front], edi,ebx,ecx,edx
|
||||||
|
jmp .end_f
|
||||||
|
@@:
|
||||||
|
cmp dword[edi+offs_cont_current_cull_face],GL_FRONT
|
||||||
|
jne .end_f
|
||||||
|
cmp dword[front],0
|
||||||
|
jne .end_f
|
||||||
|
stdcall dword[edi+offs_cont_draw_triangle_back], edi,ebx,ecx,edx
|
||||||
|
jmp .end_f
|
||||||
|
.els_1:
|
||||||
|
; no culling
|
||||||
|
cmp dword[front],0
|
||||||
|
je @f
|
||||||
|
stdcall dword[edi+offs_cont_draw_triangle_front], edi,ebx,ecx,edx
|
||||||
|
@@:
|
||||||
|
stdcall dword[edi+offs_cont_draw_triangle_back], edi,ebx,ecx,edx
|
||||||
|
jmp .end_f
|
||||||
|
.els_0:
|
||||||
|
and eax,[cc]
|
||||||
|
and eax,[cc+4]
|
||||||
|
cmp eax,0
|
||||||
|
jne @f
|
||||||
|
stdcall gl_draw_triangle_clip, [context],ebx,ecx,edx,0
|
||||||
|
.end_f:
|
||||||
|
finit
|
||||||
|
@@:
|
||||||
|
popad
|
||||||
|
ret
|
||||||
|
endp
|
||||||
|
|
||||||
; /* find the next direction to clip */
|
align 4
|
||||||
|
proc gl_draw_triangle_clip, context:dword, p0:dword, p1:dword, p2:dword, clip_bit:dword
|
||||||
|
locals
|
||||||
|
co dd ?
|
||||||
|
co1 dd ?
|
||||||
|
cc rd 3
|
||||||
|
edge_flag_tmp dd ?
|
||||||
|
clip_mask dd ?
|
||||||
|
tmp1 GLVertex ?
|
||||||
|
tmp2 GLVertex ?
|
||||||
|
q rd 3 ;GLVertex*
|
||||||
|
tt dd ? ;float
|
||||||
|
endl
|
||||||
|
pushad
|
||||||
|
|
||||||
|
mov ebx,[p0]
|
||||||
|
mov ecx,[p1]
|
||||||
|
mov edx,[p2]
|
||||||
|
|
||||||
|
mov edi,[ebx+offs_vert_clip_code]
|
||||||
|
mov dword[cc],edi
|
||||||
|
mov eax,[ecx+offs_vert_clip_code]
|
||||||
|
mov dword[cc+4],eax
|
||||||
|
or edi,eax
|
||||||
|
mov eax,[edx+offs_vert_clip_code]
|
||||||
|
mov dword[cc+8],eax
|
||||||
|
or edi,eax
|
||||||
|
mov dword[co],edi
|
||||||
|
|
||||||
|
cmp edi,0
|
||||||
|
jne .els_0
|
||||||
|
stdcall gl_draw_triangle, [context],ebx,ecx,edx
|
||||||
|
jmp .end_f
|
||||||
|
.els_0:
|
||||||
|
and eax,[cc]
|
||||||
|
and eax,[cc+4]
|
||||||
|
|
||||||
|
; the triangle is completely outside
|
||||||
|
cmp eax,0
|
||||||
|
jne .end_f
|
||||||
|
|
||||||
|
; find the next direction to clip
|
||||||
; while (clip_bit < 6 && (co & (1 << clip_bit)) == 0) {
|
; while (clip_bit < 6 && (co & (1 << clip_bit)) == 0) {
|
||||||
; clip_bit++;
|
; clip_bit++;
|
||||||
; }
|
; }
|
||||||
|
|
||||||
; /* this test can be true only in case of rounding errors */
|
; this test can be true only in case of rounding errors
|
||||||
; if (clip_bit == 6) {
|
cmp dword[clip_bit],6
|
||||||
;#if 0
|
if 0
|
||||||
|
jne @f
|
||||||
; printf("Error:\n");
|
; printf("Error:\n");
|
||||||
; printf("%f %f %f %f\n",p0->pc.X,p0->pc.Y,p0->pc.Z,p0->pc.W);
|
; printf("%f %f %f %f\n",p0->pc.X,p0->pc.Y,p0->pc.Z,p0->pc.W);
|
||||||
; printf("%f %f %f %f\n",p1->pc.X,p1->pc.Y,p1->pc.Z,p1->pc.W);
|
; printf("%f %f %f %f\n",p1->pc.X,p1->pc.Y,p1->pc.Z,p1->pc.W);
|
||||||
; 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);
|
||||||
;#endif
|
jmp .end_f
|
||||||
; return;
|
@@:
|
||||||
; }
|
else
|
||||||
|
je .end_f
|
||||||
|
end if
|
||||||
|
|
||||||
; clip_mask = 1 << clip_bit;
|
; clip_mask = 1 << clip_bit;
|
||||||
; co1=(cc[0] ^ cc[1] ^ cc[2]) & clip_mask;
|
; co1=(cc[0] ^ cc[1] ^ cc[2]) & clip_mask;
|
||||||
@ -781,7 +853,10 @@ clip_proc dd clip_xmin,clip_xmax, clip_ymin,clip_ymax, clip_zmin,clip_zmax
|
|||||||
; gl_draw_triangle_clip(c,q[0],&tmp1,&tmp2,clip_bit+1);
|
; gl_draw_triangle_clip(c,q[0],&tmp1,&tmp2,clip_bit+1);
|
||||||
; }
|
; }
|
||||||
; }
|
; }
|
||||||
;}
|
.end_f:
|
||||||
|
popad
|
||||||
|
ret
|
||||||
|
endp
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
proc gl_draw_triangle_select uses eax, context:dword, p0:dword,p1:dword,p2:dword
|
proc gl_draw_triangle_select uses eax, context:dword, p0:dword,p1:dword,p2:dword
|
||||||
@ -795,14 +870,16 @@ proc gl_draw_triangle_select uses eax, context:dword, p0:dword,p1:dword,p2:dword
|
|||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
;#ifdef PROFILE
|
if PROFILE eq 1
|
||||||
;int count_triangles,count_triangles_textured,count_pixels;
|
count_triangles dd ?
|
||||||
;#endif
|
count_triangles_textured dd ?
|
||||||
|
count_pixels dd ?
|
||||||
|
end if
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
proc gl_draw_triangle_fill uses eax edx, context:dword, p0:dword,p1:dword,p2:dword
|
proc gl_draw_triangle_fill, context:dword, p0:dword,p1:dword,p2:dword
|
||||||
;#ifdef PROFILE
|
pushad
|
||||||
; {
|
if PROFILE eq 1
|
||||||
; int norm;
|
; int norm;
|
||||||
; assert(p0->zp.x >= 0 && p0->zp.x < c->zb->xsize);
|
; assert(p0->zp.x >= 0 && p0->zp.x < c->zb->xsize);
|
||||||
; assert(p0->zp.y >= 0 && p0->zp.y < c->zb->ysize);
|
; assert(p0->zp.y >= 0 && p0->zp.y < c->zb->ysize);
|
||||||
@ -814,32 +891,40 @@ proc gl_draw_triangle_fill uses eax edx, context:dword, p0:dword,p1:dword,p2:dwo
|
|||||||
; norm=(p1->zp.x-p0->zp.x)*(p2->zp.y-p0->zp.y)-
|
; norm=(p1->zp.x-p0->zp.x)*(p2->zp.y-p0->zp.y)-
|
||||||
; (p2->zp.x-p0->zp.x)*(p1->zp.y-p0->zp.y);
|
; (p2->zp.x-p0->zp.x)*(p1->zp.y-p0->zp.y);
|
||||||
; count_pixels+=abs(norm)/2;
|
; count_pixels+=abs(norm)/2;
|
||||||
; count_triangles++;
|
inc dword[count_triangles]
|
||||||
; }
|
end if
|
||||||
;#endif
|
|
||||||
|
|
||||||
|
mov ebx,[p1]
|
||||||
|
add ebx,offs_vert_zp
|
||||||
|
mov ecx,[p2]
|
||||||
|
add ecx,offs_vert_zp
|
||||||
mov edx,[context]
|
mov edx,[context]
|
||||||
cmp dword[edx+offs_cont_texture_2d_enabled],0
|
cmp dword[edx+offs_cont_texture_2d_enabled],0
|
||||||
je .els_i
|
je .els_i
|
||||||
;if (context.texture_2d_enabled)
|
;if (context.texture_2d_enabled)
|
||||||
;#ifdef PROFILE
|
if PROFILE eq 1
|
||||||
; count_triangles_textured++;
|
inc dword[count_triangles_textured]
|
||||||
;#endif
|
end if
|
||||||
mov eax,dword[edx+offs_cont_current_texture]
|
mov eax,dword[edx+offs_cont_current_texture]
|
||||||
mov eax,[eax] ;переход по указателю
|
mov eax,[eax] ;переход по указателю
|
||||||
;так как offs_text_images+offs_imag_pixmap = 0 то context.current_texture.images[0].pixmap = [eax]
|
;так как offs_text_images+offs_imag_pixmap = 0 то context.current_texture.images[0].pixmap = [eax]
|
||||||
stdcall ZB_setTexture, dword[edx+offs_cont_zb],dword[eax]
|
stdcall ZB_setTexture, dword[edx+offs_cont_zb],dword[eax]
|
||||||
; ZB_fillTriangleMappingPerspective, dword[edx+offs_cont_zb],&p0->zp,&p1->zp,&p2->zp);
|
mov eax,[p0]
|
||||||
|
add eax,offs_vert_zp
|
||||||
|
stdcall ZB_fillTriangleMappingPerspective, dword[edx+offs_cont_zb],eax,ebx,ecx
|
||||||
jmp .end_f
|
jmp .end_f
|
||||||
.els_i:
|
.els_i:
|
||||||
cmp dword[edx+offs_cont_current_shade_model],GL_SMOOTH
|
mov eax,[p0]
|
||||||
jne .els
|
add eax,offs_vert_zp
|
||||||
;else if (context.current_shade_model == GL_SMOOTH)
|
cmp dword[edx+offs_cont_current_shade_model],GL_SMOOTH
|
||||||
; ZB_fillTriangleSmooth, dword[edx+offs_cont_zb],&p0->zp,&p1->zp,&p2->zp);
|
jne .els
|
||||||
jmp .end_f
|
;else if (context.current_shade_model == GL_SMOOTH)
|
||||||
.els:
|
stdcall ZB_fillTriangleSmooth, dword[edx+offs_cont_zb],eax,ebx,ecx
|
||||||
; ZB_fillTriangleFlat, dword[edx+offs_cont_zb],&p0->zp,&p1->zp,&p2->zp);
|
jmp .end_f
|
||||||
|
.els:
|
||||||
|
stdcall ZB_fillTriangleFlat, dword[edx+offs_cont_zb],eax,ebx,ecx
|
||||||
.end_f:
|
.end_f:
|
||||||
|
popad
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
|
@ -410,16 +410,18 @@ proc glopTranslate uses eax ebx ecx, context:dword, p:dword
|
|||||||
fmul st0,st3 ;m[1] * y
|
fmul st0,st3 ;m[1] * y
|
||||||
fld dword[ebx+8] ;m[2]
|
fld dword[ebx+8] ;m[2]
|
||||||
fmul st0,st3 ;m[2] * z
|
fmul st0,st3 ;m[2] * z
|
||||||
fadd st0,st1
|
faddp
|
||||||
fadd st0,st2
|
faddp
|
||||||
fadd dword[ebx+12] ;m[3]
|
fadd dword[ebx+12] ;m[3]
|
||||||
fstp dword[ebx+12] ;m[3] = m[0] * x + m[1] * y + m[2] * z + m[3]
|
fstp dword[ebx+12] ;m[3] = m[0] * x + m[1] * y + m[2] * z + m[3]
|
||||||
ffree st0
|
|
||||||
fincstp
|
|
||||||
ffree st0
|
|
||||||
fincstp
|
|
||||||
add ebx,16
|
add ebx,16
|
||||||
loop @b
|
loop @b
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
|
|
||||||
if DEBUG ;glopTranslate
|
if DEBUG ;glopTranslate
|
||||||
mov ebx,[eax+offs_cont_matrix_mode]
|
mov ebx,[eax+offs_cont_matrix_mode]
|
||||||
|
@ -87,9 +87,9 @@ m_5 db '(5)',13,10,0
|
|||||||
buf_param rb 80
|
buf_param rb 80
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
proc str_n_cat uses eax ecx edi esi, str1:dword, str2:dword, n:dword
|
proc str_n_cat uses eax ecx edi esi, str1:dword, str2:dword, n_len:dword
|
||||||
mov esi,dword[str2]
|
mov esi,dword[str2]
|
||||||
mov ecx,dword[n]
|
mov ecx,dword[n_len]
|
||||||
mov edi,dword[str1]
|
mov edi,dword[str1]
|
||||||
stdcall str_len,edi
|
stdcall str_len,edi
|
||||||
add edi,eax
|
add edi,eax
|
||||||
|
@ -236,7 +236,6 @@ pushad
|
|||||||
je .els_0
|
je .els_0
|
||||||
; eye coordinates needed for lighting
|
; eye coordinates needed for lighting
|
||||||
mov ebx,dword[eax+offs_cont_matrix_stack_ptr]
|
mov ebx,dword[eax+offs_cont_matrix_stack_ptr]
|
||||||
;;;mov edx,[v]
|
|
||||||
finit
|
finit
|
||||||
fld dword[edx+offs_vert_coord+offs_X]
|
fld dword[edx+offs_vert_coord+offs_X]
|
||||||
fld dword[edx+offs_vert_coord+offs_Y]
|
fld dword[edx+offs_vert_coord+offs_Y]
|
||||||
@ -251,13 +250,9 @@ pushad
|
|||||||
fld dword[ebx+8] ;st0 = m[2]
|
fld dword[ebx+8] ;st0 = m[2]
|
||||||
fmul st0,st3 ;st0 *= v.coord.Z
|
fmul st0,st3 ;st0 *= v.coord.Z
|
||||||
fadd dword[ebx+12] ;st0 += m[3]
|
fadd dword[ebx+12] ;st0 += m[3]
|
||||||
fadd st0,st1 ;st0 += v.coord.Z * m[2]
|
faddp ;st0 += v.coord.Z * m[2]
|
||||||
fadd st0,st2 ;st0 += v.coord.Y * m[1]
|
faddp ;st0 += v.coord.Y * m[1]
|
||||||
fstp dword[edx+offs_vert_ec] ;v.ec.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3]
|
fstp dword[edx+offs_vert_ec] ;v.ec.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3]
|
||||||
ffree st0
|
|
||||||
fincstp
|
|
||||||
ffree st0
|
|
||||||
fincstp
|
|
||||||
add ebx,16 ;следущая строка матрицы
|
add ebx,16 ;следущая строка матрицы
|
||||||
add edx,4 ;следущая координата вектора
|
add edx,4 ;следущая координата вектора
|
||||||
loop .cycle_0
|
loop .cycle_0
|
||||||
@ -279,13 +274,9 @@ pushad
|
|||||||
fld dword[ebx+8] ;st0 = m[2]
|
fld dword[ebx+8] ;st0 = m[2]
|
||||||
fmul st0,st3 ;st0 *= v.ec.Z
|
fmul st0,st3 ;st0 *= v.ec.Z
|
||||||
fadd dword[ebx+12] ;st0 += m[3]
|
fadd dword[ebx+12] ;st0 += m[3]
|
||||||
fadd st0,st1 ;st0 += v.ec.Z * m[2]
|
faddp ;st0 += v.ec.Z * m[2]
|
||||||
fadd st0,st2 ;st0 += v.ec.Y * m[1]
|
faddp ;st0 += v.ec.Y * m[1]
|
||||||
fstp dword[edx+offs_vert_pc] ;v.pc.X = v.ec.X * m[0] + v.ec.Y * m[1] + v.ec.Z * m[2] + m[3]
|
fstp dword[edx+offs_vert_pc] ;v.pc.X = v.ec.X * m[0] + v.ec.Y * m[1] + v.ec.Z * m[2] + m[3]
|
||||||
ffree st0
|
|
||||||
fincstp
|
|
||||||
ffree st0
|
|
||||||
fincstp
|
|
||||||
add ebx,16 ;следущая строка матрицы
|
add ebx,16 ;следущая строка матрицы
|
||||||
add edx,4 ;следущая координата вектора
|
add edx,4 ;следущая координата вектора
|
||||||
loop .cycle_1
|
loop .cycle_1
|
||||||
@ -308,13 +299,9 @@ pushad
|
|||||||
fmul st0,st3 ;st0 *= n.Y
|
fmul st0,st3 ;st0 *= n.Y
|
||||||
fld dword[ebx+8] ;st0 = m[2]
|
fld dword[ebx+8] ;st0 = m[2]
|
||||||
fmul st0,st3 ;st0 *= n.Z
|
fmul st0,st3 ;st0 *= n.Z
|
||||||
fadd st0,st1 ;st0 += n.Z * m[2]
|
faddp ;st0 += n.Z * m[2]
|
||||||
fadd st0,st2 ;st0 += n.Y * m[1]
|
faddp ;st0 += n.Y * m[1]
|
||||||
fstp dword[edx+offs_vert_normal] ;v.normal.X = n.X * m[0] + n.Y * m[1] + n.Z * m[2]
|
fstp dword[edx+offs_vert_normal] ;v.normal.X = n.X * m[0] + n.Y * m[1] + n.Z * m[2]
|
||||||
ffree st0
|
|
||||||
fincstp
|
|
||||||
ffree st0
|
|
||||||
fincstp
|
|
||||||
add ebx,16 ;следущая строка матрицы
|
add ebx,16 ;следущая строка матрицы
|
||||||
add edx,4 ;следущая координата вектора
|
add edx,4 ;следущая координата вектора
|
||||||
loop .cycle_2
|
loop .cycle_2
|
||||||
@ -329,7 +316,6 @@ pushad
|
|||||||
mov ebx,eax
|
mov ebx,eax
|
||||||
add ebx,offs_cont_matrix_model_projection
|
add ebx,offs_cont_matrix_model_projection
|
||||||
|
|
||||||
;;;mov edx,[v]
|
|
||||||
finit
|
finit
|
||||||
fld dword[edx+offs_vert_coord+offs_X]
|
fld dword[edx+offs_vert_coord+offs_X]
|
||||||
fld dword[edx+offs_vert_coord+offs_Y]
|
fld dword[edx+offs_vert_coord+offs_Y]
|
||||||
@ -345,13 +331,10 @@ pushad
|
|||||||
fld dword[ebx+8] ;st0 = m[2]
|
fld dword[ebx+8] ;st0 = m[2]
|
||||||
fmul st0,st3 ;st0 *= v.coord.Z
|
fmul st0,st3 ;st0 *= v.coord.Z
|
||||||
fadd dword[ebx+12] ;st0 += m[3]
|
fadd dword[ebx+12] ;st0 += m[3]
|
||||||
fadd st0,st1 ;st0 += v.coord.Z * m[2]
|
faddp ;st0 += v.coord.Z * m[2]
|
||||||
fadd st0,st2 ;st0 += v.coord.Y * m[1]
|
faddp ;st0 += v.coord.Y * m[1]
|
||||||
fstp dword[esi] ;v.pc.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3]
|
fstp dword[esi] ;v.pc.X = v.coord.X * m[0] + v.coord.Y * m[1] + v.coord.Z * m[2] + m[3]
|
||||||
ffree st0
|
|
||||||
fincstp
|
|
||||||
ffree st0
|
|
||||||
fincstp
|
|
||||||
fld dword[ebx+16] ;st0 = m[4]
|
fld dword[ebx+16] ;st0 = m[4]
|
||||||
fmul st0,st3 ;st0 *= v.coord.X
|
fmul st0,st3 ;st0 *= v.coord.X
|
||||||
fld dword[ebx+20] ;st0 = m[5]
|
fld dword[ebx+20] ;st0 = m[5]
|
||||||
@ -359,13 +342,10 @@ pushad
|
|||||||
fld dword[ebx+24] ;st0 = m[6]
|
fld dword[ebx+24] ;st0 = m[6]
|
||||||
fmul st0,st3 ;st0 *= v.coord.Z
|
fmul st0,st3 ;st0 *= v.coord.Z
|
||||||
fadd dword[ebx+28] ;st0 += m[7]
|
fadd dword[ebx+28] ;st0 += m[7]
|
||||||
fadd st0,st1 ;st0 += v.coord.Z * m[6]
|
faddp ;st0 += v.coord.Z * m[6]
|
||||||
fadd st0,st2 ;st0 += v.coord.Y * m[5]
|
faddp ;st0 += v.coord.Y * m[5]
|
||||||
fstp dword[esi+4] ;v.pc.X = v.coord.X * m[4] + v.coord.Y * m[5] + v.coord.Z * m[6] + m[7]
|
fstp dword[esi+4] ;v.pc.X = v.coord.X * m[4] + v.coord.Y * m[5] + v.coord.Z * m[6] + m[7]
|
||||||
ffree st0
|
|
||||||
fincstp
|
|
||||||
ffree st0
|
|
||||||
fincstp
|
|
||||||
fld dword[ebx+32] ;st0 = m[8]
|
fld dword[ebx+32] ;st0 = m[8]
|
||||||
fmul st0,st3 ;st0 *= v.coord.X
|
fmul st0,st3 ;st0 *= v.coord.X
|
||||||
fld dword[ebx+36] ;st0 = m[9]
|
fld dword[ebx+36] ;st0 = m[9]
|
||||||
@ -373,8 +353,8 @@ pushad
|
|||||||
fld dword[ebx+40] ;st0 = m[10]
|
fld dword[ebx+40] ;st0 = m[10]
|
||||||
fmul st0,st3 ;st0 *= v.coord.Z
|
fmul st0,st3 ;st0 *= v.coord.Z
|
||||||
fadd dword[ebx+44] ;st0 += m[11]
|
fadd dword[ebx+44] ;st0 += m[11]
|
||||||
fadd st0,st1 ;st0 += v.coord.Z * m[10]
|
faddp ;st0 += v.coord.Z * m[10]
|
||||||
fadd st0,st2 ;st0 += v.coord.Y * m[9]
|
faddp ;st0 += v.coord.Y * m[9]
|
||||||
fstp dword[esi+8] ;v.pc.X = v.coord.X * m[8] + v.coord.Y * m[9] + v.coord.Z * m[10] + m[11]
|
fstp dword[esi+8] ;v.pc.X = v.coord.X * m[8] + v.coord.Y * m[9] + v.coord.Z * m[10] + m[11]
|
||||||
|
|
||||||
cmp dword[eax+offs_cont_matrix_model_projection_no_w_transform],0
|
cmp dword[eax+offs_cont_matrix_model_projection_no_w_transform],0
|
||||||
@ -384,10 +364,6 @@ pushad
|
|||||||
mov dword[esi+12],ebx ;v.pc.W = m[15]
|
mov dword[esi+12],ebx ;v.pc.W = m[15]
|
||||||
jmp .end_els
|
jmp .end_els
|
||||||
.els_1:
|
.els_1:
|
||||||
ffree st0
|
|
||||||
fincstp
|
|
||||||
ffree st0
|
|
||||||
fincstp
|
|
||||||
fld dword[ebx+48] ;st0 = m[12]
|
fld dword[ebx+48] ;st0 = m[12]
|
||||||
fmul st0,st3 ;st0 *= v.coord.X
|
fmul st0,st3 ;st0 *= v.coord.X
|
||||||
fld dword[ebx+52] ;st0 = m[13]
|
fld dword[ebx+52] ;st0 = m[13]
|
||||||
@ -395,10 +371,17 @@ pushad
|
|||||||
fld dword[ebx+56] ;st0 = m[14]
|
fld dword[ebx+56] ;st0 = m[14]
|
||||||
fmul st0,st3 ;st0 *= v.coord.Z
|
fmul st0,st3 ;st0 *= v.coord.Z
|
||||||
fadd dword[ebx+60] ;st0 += m[15]
|
fadd dword[ebx+60] ;st0 += m[15]
|
||||||
fadd st0,st1 ;st0 += v.coord.Z * m[14]
|
faddp ;st0 += v.coord.Z * m[14]
|
||||||
fadd st0,st2 ;st0 += v.coord.Y * m[13]
|
faddp ;st0 += v.coord.Y * m[13]
|
||||||
fstp dword[esi+12] ;v.pc.W = v.coord.X * m[12] + v.coord.Y * m[13] + v.coord.Z * m[14] + m[15]
|
fstp dword[esi+12] ;v.pc.W = v.coord.X * m[12] + v.coord.Y * m[13] + v.coord.Z * m[14] + m[15]
|
||||||
.end_els:
|
.end_els:
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
|
ffree st0
|
||||||
|
fincstp
|
||||||
|
|
||||||
if DEBUG ;gl_vertex_transform
|
if DEBUG ;gl_vertex_transform
|
||||||
stdcall dbg_print,f_vt,txt_nl
|
stdcall dbg_print,f_vt,txt_nl
|
||||||
mov edx,[v]
|
mov edx,[v]
|
||||||
@ -509,8 +492,7 @@ pushad
|
|||||||
mov eax,[edx+offs_cont_vertex]
|
mov eax,[edx+offs_cont_vertex]
|
||||||
push eax
|
push eax
|
||||||
add eax,sizeof.GLVertex
|
add eax,sizeof.GLVertex
|
||||||
push eax
|
stdcall gl_draw_line, edx, eax
|
||||||
stdcall gl_draw_line, edx
|
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
mov dword[n],eax
|
mov dword[n],eax
|
||||||
jmp .end_f
|
jmp .end_f
|
||||||
@ -534,8 +516,7 @@ pushad
|
|||||||
mov eax,[edx+offs_cont_vertex]
|
mov eax,[edx+offs_cont_vertex]
|
||||||
push eax
|
push eax
|
||||||
add eax,sizeof.GLVertex
|
add eax,sizeof.GLVertex
|
||||||
push eax
|
stdcall gl_draw_line, edx, eax
|
||||||
stdcall gl_draw_line, edx
|
|
||||||
mov edi,[edx+offs_cont_vertex]
|
mov edi,[edx+offs_cont_vertex]
|
||||||
mov esi,edi
|
mov esi,edi
|
||||||
add esi,sizeof.GLVertex
|
add esi,sizeof.GLVertex
|
||||||
@ -548,7 +529,12 @@ pushad
|
|||||||
jne @f
|
jne @f
|
||||||
cmp dword[n],3
|
cmp dword[n],3
|
||||||
jne .end_f
|
jne .end_f
|
||||||
; gl_draw_triangle(c, &c->vertex[0], &c->vertex[1], &c->vertex[2]);
|
mov eax,[edx+offs_cont_vertex]
|
||||||
|
push eax
|
||||||
|
add eax,sizeof.GLVertex
|
||||||
|
push eax
|
||||||
|
add eax,sizeof.GLVertex
|
||||||
|
stdcall gl_draw_triangle, edx, eax
|
||||||
xor eax,eax
|
xor eax,eax
|
||||||
mov dword[n],eax
|
mov dword[n],eax
|
||||||
jmp .end_f
|
jmp .end_f
|
||||||
|
@ -2,19 +2,13 @@ include 'opengl_const.inc'
|
|||||||
include 'zbuffer.inc'
|
include 'zbuffer.inc'
|
||||||
include 'zmath.inc'
|
include 'zmath.inc'
|
||||||
|
|
||||||
;#define fputc(...) /*nothing*/
|
|
||||||
;#define fprintf(...) /*nothing*/
|
|
||||||
;#define vfprintf(...) /*nothing*/
|
|
||||||
;#undef stderr
|
|
||||||
;#define stderr ((FILE*)-1)
|
|
||||||
|
|
||||||
|
|
||||||
;enum { OP_ ## a , ... }
|
;enum { OP_ ## a , ... }
|
||||||
s1 equ 0
|
sum1 equ 0
|
||||||
macro ADD_OP a,b,c
|
macro ADD_OP a,b,c
|
||||||
{
|
{
|
||||||
OP_#a equ s1
|
OP_#a equ sum1
|
||||||
s1 equ (s1+1)
|
sum1 equ (sum1+1)
|
||||||
}
|
}
|
||||||
include 'opinfo.inc'
|
include 'opinfo.inc'
|
||||||
|
|
||||||
|
@ -7,13 +7,13 @@ 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
|
shr eax,8
|
||||||
mov [colorR],eax ;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
|
shr eax,8
|
||||||
mov [colorG],eax ;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
|
shr eax,8
|
||||||
mov [colorB],eax ;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
|
||||||
@ -21,19 +21,27 @@ end if
|
|||||||
|
|
||||||
macro PUT_PIXEL _a
|
macro PUT_PIXEL _a
|
||||||
{
|
{
|
||||||
; zz=z >> ZB_POINT_Z_FRAC_BITS;
|
local .end_0
|
||||||
; if (zz >= pz[_a]) {
|
mov eax,[z]
|
||||||
|
shr eax, ZB_POINT_Z_FRAC_BITS
|
||||||
|
mov [zz],eax
|
||||||
|
mov ebx,[pz]
|
||||||
|
cmp ax,word[ebx+2*_a] ;if (zz >= pz[_a])
|
||||||
|
jl .end_0
|
||||||
|
;edi = pp
|
||||||
if TGL_FEATURE_RENDER_BITS eq 24
|
if TGL_FEATURE_RENDER_BITS eq 24
|
||||||
; pp[3 * _a]=colorR;
|
mov cl,[colorR]
|
||||||
; pp[3 * _a + 1]=colorG;
|
mov ch,[colorG]
|
||||||
; pp[3 * _a + 2]=colorB;
|
mov word[edi+3*_a],cx
|
||||||
; pz[_a]=zz;
|
mov cl,[colorB]
|
||||||
|
mov byte[edi+3*_a +2],cl
|
||||||
else
|
else
|
||||||
; pp[_a]=color;
|
; pp[_a]=color;
|
||||||
; pz[_a]=zz;
|
|
||||||
end if
|
end if
|
||||||
; }
|
mov word[ebx+2*_a],ax ;пишем в буфер глубины новое значение
|
||||||
; z+=dzdx;
|
.end_0:
|
||||||
|
mov eax,[dzdx]
|
||||||
|
add [z],eax
|
||||||
}
|
}
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
@ -47,8 +55,6 @@ else
|
|||||||
color dd ? ;int
|
color dd ? ;int
|
||||||
end if
|
end if
|
||||||
include 'ztriangle.inc'
|
include 'ztriangle.inc'
|
||||||
ret
|
|
||||||
endp
|
|
||||||
|
|
||||||
;
|
;
|
||||||
; Smooth filled triangle.
|
; Smooth filled triangle.
|
||||||
@ -69,7 +75,9 @@ end if
|
|||||||
|
|
||||||
macro PUT_PIXEL _a
|
macro PUT_PIXEL _a
|
||||||
{
|
{
|
||||||
; zz=z >> ZB_POINT_Z_FRAC_BITS;
|
mov eax,[z]
|
||||||
|
shr eax,ZB_POINT_Z_FRAC_BITS
|
||||||
|
mov [zz],eax
|
||||||
if TGL_FEATURE_RENDER_BITS eq 24
|
if TGL_FEATURE_RENDER_BITS eq 24
|
||||||
; if (zz >= pz[_a]) {
|
; if (zz >= pz[_a]) {
|
||||||
; pp[3 * _a]=or1 >> 8;
|
; pp[3 * _a]=or1 >> 8;
|
||||||
@ -77,7 +85,8 @@ if TGL_FEATURE_RENDER_BITS eq 24
|
|||||||
; pp[3 * _a + 2]=ob1 >> 8;
|
; pp[3 * _a + 2]=ob1 >> 8;
|
||||||
; pz[_a]=zz;
|
; pz[_a]=zz;
|
||||||
; }
|
; }
|
||||||
; z+=dzdx;
|
mov eax,[dzdx]
|
||||||
|
add [z],eax
|
||||||
; og1+=dgdx;
|
; og1+=dgdx;
|
||||||
; or1+=drdx;
|
; or1+=drdx;
|
||||||
; ob1+=dbdx;
|
; ob1+=dbdx;
|
||||||
@ -94,20 +103,26 @@ else
|
|||||||
; pp[_a] = RGB_TO_PIXEL(or1, og1, ob1);
|
; pp[_a] = RGB_TO_PIXEL(or1, og1, ob1);
|
||||||
; pz[_a]=zz;
|
; pz[_a]=zz;
|
||||||
; }
|
; }
|
||||||
; z+=dzdx;
|
mov eax,[dzdx]
|
||||||
|
add [z],eax
|
||||||
; og1+=dgdx;
|
; og1+=dgdx;
|
||||||
; or1+=drdx;
|
; or1+=drdx;
|
||||||
; ob1+=dbdx;
|
; ob1+=dbdx;
|
||||||
end if
|
end if
|
||||||
}
|
}
|
||||||
|
|
||||||
macro DRAW_LINE
|
DRAW_LINE_M equ 1
|
||||||
|
|
||||||
|
macro DRAW_LINE code
|
||||||
{
|
{
|
||||||
if TGL_FEATURE_RENDER_BITS eq 16
|
if TGL_FEATURE_RENDER_BITS eq 16
|
||||||
|
if code eq 0
|
||||||
; register unsigned short *pz;
|
; register unsigned short *pz;
|
||||||
; register PIXEL *pp;
|
; register PIXEL *pp;
|
||||||
; register unsigned int tmp,z,zz,rgb,drgbdx;
|
; register unsigned int tmp,z,zz,rgb,drgbdx;
|
||||||
; register int n;
|
; register int n;
|
||||||
|
end if
|
||||||
|
if code eq 1
|
||||||
; n=(x2 >> 16) - x1;
|
; n=(x2 >> 16) - x1;
|
||||||
; pp=pp1+x1;
|
; pp=pp1+x1;
|
||||||
; pz=pz1+x1;
|
; pz=pz1+x1;
|
||||||
@ -132,12 +147,134 @@ if TGL_FEATURE_RENDER_BITS eq 16
|
|||||||
; n-=1;
|
; n-=1;
|
||||||
; }
|
; }
|
||||||
end if
|
end if
|
||||||
|
end if
|
||||||
|
}
|
||||||
|
|
||||||
|
align 4
|
||||||
|
proc ZB_fillTriangleSmooth, zb:dword, p0:dword, p1:dword, p2:dword
|
||||||
|
locals
|
||||||
|
if TGL_FEATURE_RENDER_BITS eq 16
|
||||||
|
_drgbdx dd ? ;int
|
||||||
|
end if
|
||||||
|
include 'ztriangle.inc'
|
||||||
|
|
||||||
|
align 4
|
||||||
|
proc ZB_setTexture uses eax ebx, zb:dword, texture:dword
|
||||||
|
mov eax,[zb]
|
||||||
|
mov ebx,[texture]
|
||||||
|
mov dword[eax+offs_zbuf_current_texture],ebx
|
||||||
|
ret
|
||||||
|
endp
|
||||||
|
|
||||||
|
INTERP_Z equ 1
|
||||||
|
INTERP_ST equ 1
|
||||||
|
|
||||||
|
macro DRAW_INIT
|
||||||
|
{
|
||||||
|
; texture=zb->current_texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
macro PUT_PIXEL _a
|
||||||
|
{
|
||||||
|
; zz=z >> ZB_POINT_Z_FRAC_BITS;
|
||||||
if TGL_FEATURE_RENDER_BITS eq 24
|
if TGL_FEATURE_RENDER_BITS eq 24
|
||||||
; register unsigned short *pz;
|
; unsigned char *ptr;
|
||||||
; register PIXEL *pp;
|
; if (zz >= pz[_a]) {
|
||||||
; register unsigned int s,t,z,zz;
|
; ptr = texture + (((t & 0x3FC00000) | s) >> 14) * 3;
|
||||||
; register int n,dsdx,dtdx;
|
; pp[3 * _a]= ptr[0];
|
||||||
; float sz,tz,fz,zinv;
|
; pp[3 * _a + 1]= ptr[1];
|
||||||
|
; pp[3 * _a + 2]= ptr[2];
|
||||||
|
; pz[_a]=zz;
|
||||||
|
; }
|
||||||
|
else
|
||||||
|
; if (zz >= pz[_a]) {
|
||||||
|
; pp[_a]=texture[((t & 0x3FC00000) | s) >> 14];
|
||||||
|
; pz[_a]=zz;
|
||||||
|
; }
|
||||||
|
end if
|
||||||
|
mov eax,[dzdx]
|
||||||
|
add [z],eax
|
||||||
|
mov eax,[dsdx]
|
||||||
|
add [s],eax
|
||||||
|
mov eax,[dtdx]
|
||||||
|
add [t],eax
|
||||||
|
}
|
||||||
|
|
||||||
|
align 4
|
||||||
|
proc ZB_fillTriangleMapping, zb:dword, p0:dword, p1:dword, p2:dword
|
||||||
|
locals
|
||||||
|
texture dd ? ;PIXEL*
|
||||||
|
include 'ztriangle.inc'
|
||||||
|
|
||||||
|
;
|
||||||
|
; Texture mapping with perspective correction.
|
||||||
|
; We use the gradient method to make less divisions.
|
||||||
|
; TODO: pipeline the division
|
||||||
|
;
|
||||||
|
if 1
|
||||||
|
|
||||||
|
INTERP_Z equ 1
|
||||||
|
INTERP_STZ equ 1
|
||||||
|
|
||||||
|
NB_INTERP equ 8
|
||||||
|
|
||||||
|
macro DRAW_INIT
|
||||||
|
{
|
||||||
|
; texture=zb->current_texture;
|
||||||
|
; fdzdx=(float)dzdx;
|
||||||
|
; fndzdx=NB_INTERP * fdzdx;
|
||||||
|
; ndszdx=NB_INTERP * dszdx;
|
||||||
|
; ndtzdx=NB_INTERP * dtzdx;
|
||||||
|
}
|
||||||
|
|
||||||
|
macro PUT_PIXEL _a
|
||||||
|
{
|
||||||
|
; zz=z >> ZB_POINT_Z_FRAC_BITS;
|
||||||
|
if TGL_FEATURE_RENDER_BITS eq 24
|
||||||
|
; unsigned char *ptr;
|
||||||
|
; if (zz >= pz[_a]) {
|
||||||
|
; ptr = texture + (((t & 0x3FC00000) | (s & 0x003FC000)) >> 14) * 3;
|
||||||
|
; pp[3 * _a]= ptr[0];
|
||||||
|
; pp[3 * _a + 1]= ptr[1];
|
||||||
|
; pp[3 * _a + 2]= ptr[2];
|
||||||
|
; pz[_a]=zz;
|
||||||
|
; }
|
||||||
|
else
|
||||||
|
; if (zz >= pz[_a]) {
|
||||||
|
; pp[_a]=*(PIXEL *)((char *)texture+
|
||||||
|
; (((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH)));
|
||||||
|
; pz[_a]=zz;
|
||||||
|
; }
|
||||||
|
end if
|
||||||
|
mov eax,[dzdx]
|
||||||
|
add [z],eax
|
||||||
|
mov eax,[dsdx]
|
||||||
|
add [s],eax
|
||||||
|
mov eax,[dtdx]
|
||||||
|
add [t],eax
|
||||||
|
}
|
||||||
|
|
||||||
|
DRAW_LINE_M equ 1
|
||||||
|
|
||||||
|
macro DRAW_LINE code
|
||||||
|
{
|
||||||
|
if TGL_FEATURE_RENDER_BITS eq 24
|
||||||
|
if code eq 0
|
||||||
|
pz dd ? ;uint *
|
||||||
|
;edi = pp dd ?
|
||||||
|
s dd ? ;uint
|
||||||
|
t dd ? ;uint
|
||||||
|
z dd ? ;uint
|
||||||
|
zz dd ? ;uint
|
||||||
|
n dd ? ;int
|
||||||
|
dsdx dd ? ;int
|
||||||
|
dtdx dd ? ;int
|
||||||
|
s_z dd ? ;float
|
||||||
|
t_z dd ? ;float
|
||||||
|
fz dd ? ;float
|
||||||
|
zinv dd ? ;float
|
||||||
|
end if
|
||||||
|
if code eq 1
|
||||||
; n=(x2>>16)-x1;
|
; n=(x2>>16)-x1;
|
||||||
; fz=(float)z1;
|
; fz=(float)z1;
|
||||||
; zinv=1.0 / fz;
|
; zinv=1.0 / fz;
|
||||||
@ -188,118 +325,18 @@ if TGL_FEATURE_RENDER_BITS eq 24
|
|||||||
; n-=1;
|
; n-=1;
|
||||||
; }
|
; }
|
||||||
end if
|
end if
|
||||||
}
|
|
||||||
|
|
||||||
align 4
|
|
||||||
proc ZB_fillTriangleSmooth, zb:dword, p0:dword, p1:dword, p2:dword
|
|
||||||
locals
|
|
||||||
if TGL_FEATURE_RENDER_BITS eq 16
|
|
||||||
_drgbdx dd ? ;int
|
|
||||||
end if
|
end if
|
||||||
include 'ztriangle.inc'
|
|
||||||
ret
|
|
||||||
endp
|
|
||||||
|
|
||||||
align 4
|
|
||||||
proc ZB_setTexture uses eax ebx, zb:dword, texture:dword
|
|
||||||
mov eax,[zb]
|
|
||||||
mov ebx,[texture]
|
|
||||||
mov dword[eax+offs_zbuf_current_texture],ebx
|
|
||||||
ret
|
|
||||||
endp
|
|
||||||
|
|
||||||
INTERP_Z equ 1
|
|
||||||
INTERP_ST equ 1
|
|
||||||
|
|
||||||
macro DRAW_INIT
|
|
||||||
{
|
|
||||||
; texture=zb->current_texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
macro PUT_PIXEL _a
|
|
||||||
{
|
|
||||||
; zz=z >> ZB_POINT_Z_FRAC_BITS;
|
|
||||||
if TGL_FEATURE_RENDER_BITS eq 24
|
|
||||||
; unsigned char *ptr;
|
|
||||||
; if (zz >= pz[_a]) {
|
|
||||||
; ptr = texture + (((t & 0x3FC00000) | s) >> 14) * 3;
|
|
||||||
; pp[3 * _a]= ptr[0];
|
|
||||||
; pp[3 * _a + 1]= ptr[1];
|
|
||||||
; pp[3 * _a + 2]= ptr[2];
|
|
||||||
; pz[_a]=zz;
|
|
||||||
; }
|
|
||||||
else
|
|
||||||
; if (zz >= pz[_a]) {
|
|
||||||
; pp[_a]=texture[((t & 0x3FC00000) | s) >> 14];
|
|
||||||
; pz[_a]=zz;
|
|
||||||
; }
|
|
||||||
end if
|
|
||||||
; z+=dzdx;
|
|
||||||
; s+=dsdx;
|
|
||||||
; t+=dtdx;
|
|
||||||
}
|
|
||||||
|
|
||||||
align 4
|
|
||||||
proc ZB_fillTriangleMapping, zb:dword, p0:dword, p1:dword, p2:dword
|
|
||||||
locals
|
|
||||||
texture dd ? ;PIXEL*
|
|
||||||
include 'ztriangle.inc'
|
|
||||||
ret
|
|
||||||
endp
|
|
||||||
|
|
||||||
;
|
|
||||||
; Texture mapping with perspective correction.
|
|
||||||
; We use the gradient method to make less divisions.
|
|
||||||
; TODO: pipeline the division
|
|
||||||
;
|
|
||||||
if 1
|
|
||||||
|
|
||||||
INTERP_Z equ 1
|
|
||||||
INTERP_STZ equ 1
|
|
||||||
|
|
||||||
NB_INTERP equ 8
|
|
||||||
|
|
||||||
macro DRAW_INIT
|
|
||||||
{
|
|
||||||
; texture=zb->current_texture;
|
|
||||||
; fdzdx=(float)dzdx;
|
|
||||||
; fndzdx=NB_INTERP * fdzdx;
|
|
||||||
; ndszdx=NB_INTERP * dszdx;
|
|
||||||
; ndtzdx=NB_INTERP * dtzdx;
|
|
||||||
}
|
|
||||||
|
|
||||||
macro PUT_PIXEL _a
|
|
||||||
{
|
|
||||||
; zz=z >> ZB_POINT_Z_FRAC_BITS;
|
|
||||||
if TGL_FEATURE_RENDER_BITS eq 24
|
|
||||||
; unsigned char *ptr;
|
|
||||||
; if (zz >= pz[_a]) {
|
|
||||||
; ptr = texture + (((t & 0x3FC00000) | (s & 0x003FC000)) >> 14) * 3;
|
|
||||||
; pp[3 * _a]= ptr[0];
|
|
||||||
; pp[3 * _a + 1]= ptr[1];
|
|
||||||
; pp[3 * _a + 2]= ptr[2];
|
|
||||||
; pz[_a]=zz;
|
|
||||||
; }
|
|
||||||
else
|
|
||||||
; if (zz >= pz[_a]) {
|
|
||||||
; pp[_a]=*(PIXEL *)((char *)texture+
|
|
||||||
; (((t & 0x3FC00000) | (s & 0x003FC000)) >> (17 - PSZSH)));
|
|
||||||
; pz[_a]=zz;
|
|
||||||
; }
|
|
||||||
end if
|
|
||||||
; z+=dzdx;
|
|
||||||
; s+=dsdx;
|
|
||||||
; t+=dtdx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
proc ZB_fillTriangleMappingPerspective, zb:dword, p0:dword, p1:dword, p2:dword
|
proc ZB_fillTriangleMappingPerspective, zb:dword, p0:dword, p1:dword, p2:dword
|
||||||
locals
|
locals
|
||||||
; PIXEL *texture;
|
texture dd ? ;PIXEL *
|
||||||
; float fdzdx,fndzdx,ndszdx,ndtzdx;
|
fdzdx dd ? ;float
|
||||||
|
fndzdx dd ?
|
||||||
|
ndszdx dd ?
|
||||||
|
ndtzdx dd ?
|
||||||
include 'ztriangle.inc'
|
include 'ztriangle.inc'
|
||||||
ret
|
|
||||||
endp
|
|
||||||
|
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@ -328,9 +365,12 @@ macro PUT_PIXEL _a
|
|||||||
; pp[_a]=texture[((t & 0x3FC00000) | s) >> 14];
|
; pp[_a]=texture[((t & 0x3FC00000) | s) >> 14];
|
||||||
; pz[_a]=zz;
|
; pz[_a]=zz;
|
||||||
; }
|
; }
|
||||||
; z+=dzdx;
|
mov eax,[dzdx]
|
||||||
; sz+=dszdx;
|
add [z],eax
|
||||||
; tz+=dtzdx;
|
mov eax,[dszdx]
|
||||||
|
add [sz],eax
|
||||||
|
mov eax,[dtzdx]
|
||||||
|
add [tz],eax
|
||||||
}
|
}
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
@ -338,7 +378,5 @@ proc ZB_fillTriangleMappingPerspective, zb:dword, p0:dword, p1:dword, p2:dword
|
|||||||
locals
|
locals
|
||||||
texture dd ? ;PIXEL*
|
texture dd ? ;PIXEL*
|
||||||
include 'ztriangle.inc'
|
include 'ztriangle.inc'
|
||||||
ret
|
|
||||||
endp
|
|
||||||
|
|
||||||
end if
|
end if
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user