diff --git a/programs/develop/libraries/TinyGL/asm_fork/api.asm b/programs/develop/libraries/TinyGL/asm_fork/api.asm index b7144a2f21..036d25a02c 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/api.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/api.asm @@ -1,25 +1,14 @@ ; glVertex align 4 -proc glVertex4f uses eax, x:dword, y:dword, z:dword, w:dword -locals - p rd 5 -endl - mov dword[p],OP_Vertex - mov eax,[x] - mov dword[p+4],eax - mov eax,[y] - mov dword[p+8],eax - mov eax,[z] - mov dword[p+12],eax - mov eax,[w] - mov dword[p+16],eax - - mov eax,ebp - sub eax,20 ;=sizeof(dd)*5 +glVertex4f: ;x, y, z, w + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_Vertex stdcall gl_add_op,eax - ret -endp + pop eax + ret 20 ;=sizeof(dd)*5 align 4 proc glVertex2f, x:dword, y:dword @@ -57,23 +46,14 @@ endp ; glNormal align 4 -proc glNormal3f uses eax, x:dword, y:dword, z:dword -locals - p rd 4 -endl - mov dword[p],OP_Normal - mov eax,[x] - mov dword[p+4],eax - mov eax,[y] - mov dword[p+8],eax - mov eax,[z] - mov dword[p+12],eax - - mov eax,ebp - sub eax,16 ;=sizeof(dd)*4 +glNormal3f: ;x, y, z + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_Normal stdcall gl_add_op,eax - ret -endp + pop eax + ret 16 ;=sizeof(dd)*4 align 4 proc glNormal3fv uses eax, v:dword @@ -99,8 +79,7 @@ endl mov eax,[a] mov dword[p+16],eax ; direct convertion to integer to go faster if no shading - mov eax,ebp - sub eax,12 ;ebp-12 = &p[5] + lea eax,[ebp-12] ;ebp-12 = &p[5] push eax add eax,4 ;ebp-8 = &p[6] push eax @@ -108,8 +87,7 @@ endl push eax stdcall RGBFtoRGBI,[r],[g],[b] ;call: r,g,b,&p[7],&p[6],&p[5] - mov eax,ebp - sub eax,32 ;=sizeof(dd)*8 + lea eax,[ebp-32] ;=sizeof(dd)*8 stdcall gl_add_op,eax ret endp @@ -168,25 +146,14 @@ endp ; TexCoord align 4 -proc glTexCoord4f uses eax, s:dword, t:dword, r:dword, q:dword -locals - p rd 5 -endl - mov dword[p],OP_TexCoord - mov eax,[s] - mov dword[p+4],eax - mov eax,[t] - mov dword[p+8],eax - mov eax,[r] - mov dword[p+12],eax - mov eax,[q] - mov dword[p+16],eax - - mov eax,ebp - sub eax,20 ;=sizeof(dd)*5 +glTexCoord4f: ;s, t, r, q + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_TexCoord stdcall gl_add_op,eax - ret -endp + pop eax + ret 20 ;=sizeof(dd)*5 align 4 proc glTexCoord2f, s:dword, t:dword @@ -202,59 +169,40 @@ proc glTexCoord2fv uses eax, v:dword endp align 4 -proc glEdgeFlag uses eax, flag:dword -locals - p rd 2 -endl - mov dword[p],OP_EdgeFlag - mov eax,[flag] - mov dword[p+4],eax - - mov eax,ebp - sub eax,8 ;=sizeof(dd)*2 +glEdgeFlag: ;flag + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_EdgeFlag stdcall gl_add_op,eax - ret -endp + pop eax + ret 8 ;=sizeof(dd)*2 ; misc align 4 -proc glShadeModel uses eax, mode:dword -locals - p rd 2 -endl - +glShadeModel: ;mode ; assert(mode == GL_FLAT || mode == GL_SMOOTH); - - mov dword[p],OP_ShadeModel - mov eax,[mode] - mov dword[p+4],eax - - mov eax,ebp - sub eax,8 ;=sizeof(dd)*2 + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_ShadeModel stdcall gl_add_op,eax - ret -endp + pop eax + ret 8 ;=sizeof(dd)*2 align 4 -proc glCullFace uses eax, mode:dword -locals - p rd 2 -endl - +glCullFace: ;mode ; assert(mode == GL_BACK || ; mode == GL_FRONT || ; mode == GL_FRONT_AND_BACK); - - mov dword[p],OP_CullFace - mov eax,[mode] - mov dword[p+4],eax - - mov eax,ebp - sub eax,8 ;=sizeof(dd)*2 + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_CullFace stdcall gl_add_op,eax - ret -endp + pop eax + ret 8 ;=sizeof(dd)*2 align 4 proc glFrontFace uses eax, mode:dword @@ -272,34 +220,24 @@ endl @@: mov dword[p+4],eax - mov eax,ebp - sub eax,8 ;=sizeof(dd)*2 + lea eax,[ebp-8] ;=sizeof(dd)*2 stdcall gl_add_op,eax ret endp align 4 -proc glPolygonMode uses eax, face:dword, mode:dword -locals - p rd 3 -endl - +glPolygonMode: ;face, mode ; assert(face == GL_BACK || ; face == GL_FRONT || ; face == GL_FRONT_AND_BACK); ; assert(mode == GL_POINT || mode == GL_LINE || mode==GL_FILL); - - mov dword[p],OP_PolygonMode - mov eax,[face] - mov dword[p+4],eax - mov eax,[mode] - mov dword[p+8],eax - - mov eax,ebp - sub eax,12 ;=sizeof(dd)*3 + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_PolygonMode stdcall gl_add_op,eax - ret -endp + pop eax + ret 12 ;=sizeof(dd)*3 ; glEnable / glDisable @@ -313,8 +251,7 @@ endl mov dword[p+4],eax mov dword[p+8],1 - mov eax,ebp - sub eax,12 ;=sizeof(dd)*3 + lea eax,[ebp-12] ;=sizeof(dd)*3 stdcall gl_add_op,eax ret endp @@ -329,8 +266,7 @@ endl mov dword[p+4],eax mov dword[p+8],0 - mov eax,ebp - sub eax,12 ;=sizeof(dd)*3 + lea eax,[ebp-12] ;=sizeof(dd)*3 stdcall gl_add_op,eax ret endp @@ -338,49 +274,31 @@ endp ; glBegin / glEnd align 4 -proc glBegin uses eax, mode:dword -locals - p rd 2 -endl - mov dword[p],OP_Begin - mov eax,[mode] - mov dword[p+4],eax - - mov eax,ebp - sub eax,8 ;=sizeof(dd)*2 +glBegin: ;mode + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_Begin stdcall gl_add_op,eax - ret -endp + pop eax + ret 8 ;=sizeof(dd)*2 align 4 -proc glEnd uses eax -locals - p dd ? -endl - mov dword[p],OP_End - - mov eax,ebp - sub eax,4 ;=sizeof(dd)*1 - stdcall gl_add_op,eax +glEnd: + stdcall gl_add_op,op_End ret -endp ; matrix align 4 -proc glMatrixMode uses eax, mode:dword -locals - p rd 2 -endl - mov dword[p],OP_MatrixMode - mov eax,[mode] - mov dword[p+4],eax - - mov eax,ebp - sub eax,8 ;=sizeof(dd)*2 +glMatrixMode: ;mode + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_MatrixMode stdcall gl_add_op,eax - ret -endp + pop eax + ret 8 ;=sizeof(dd)*2 align 4 proc glLoadMatrixf uses ecx edi esi, m:dword @@ -394,24 +312,15 @@ endl sub edi,64 ;=sizeof(M4) rep movsd - mov ecx,ebp - sub ecx,68 ;=sizeof(dd)*17 + lea ecx,[ebp-68] ;=sizeof(dd)*17 stdcall gl_add_op,ecx ret endp align 4 -proc glLoadIdentity uses eax -locals - p dd ? -endl - mov dword[p],OP_LoadIdentity - - mov eax,ebp - sub eax,4 ;=sizeof(dd)*1 - stdcall gl_add_op,eax +glLoadIdentity: + stdcall gl_add_op,op_LoadIdentity ret -endp align 4 proc glMultMatrixf uses ecx edi esi, m:dword @@ -425,117 +334,60 @@ endl sub edi,64 ;=sizeof(M4) rep movsd - mov ecx,ebp - sub ecx,68 ;=sizeof(dd)*17 + lea ecx,[ebp-68] ;=sizeof(dd)*17 stdcall gl_add_op,ecx ret endp align 4 -proc glPushMatrix uses eax -locals - p dd ? -endl - mov dword[p],OP_PushMatrix - - mov eax,ebp - sub eax,4 ;=sizeof(dd)*1 - stdcall gl_add_op,eax +glPushMatrix: + stdcall gl_add_op,op_PushMatrix ret -endp align 4 -proc glPopMatrix uses eax -locals - p dd ? -endl - mov dword[p],OP_PopMatrix - - mov eax,ebp - sub eax,4 ;=sizeof(dd)*1 - stdcall gl_add_op,eax +glPopMatrix: + stdcall gl_add_op,op_PopMatrix ret -endp align 4 -proc glRotatef uses eax, angle:dword, x:dword, y:dword, z:dword -locals - p rd 5 -endl - mov dword[p],OP_Rotate - mov eax,[angle] - mov dword[p+4],eax - mov eax,[x] - mov dword[p+8],eax - mov eax,[y] - mov dword[p+12],eax - mov eax,[z] - mov dword[p+16],eax - - mov eax,ebp - sub eax,20 ;=sizeof(dd)*5 +glRotatef: ;angle, x, y, z + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_Rotate stdcall gl_add_op,eax - ret -endp + pop eax + ret 20 ;=sizeof(dd)*5 align 4 -proc glTranslatef uses eax, x:dword, y:dword, z:dword -locals - p rd 4 -endl - mov dword[p],OP_Translate - mov eax,[x] - mov dword[p+4],eax - mov eax,[y] - mov dword[p+8],eax - mov eax,[z] - mov dword[p+12],eax - - mov eax,ebp - sub eax,16 ;=sizeof(dd)*4 +glTranslatef: ;x, y, z + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_Translate stdcall gl_add_op,eax - ret -endp + pop eax + ret 16 ;=sizeof(dd)*4 align 4 -proc glScalef uses eax, x:dword, y:dword, z:dword -locals - p rd 4 -endl - mov dword[p],OP_Scale - mov eax,[x] - mov dword[p+4],eax - mov eax,[y] - mov dword[p+8],eax - mov eax,[z] - mov dword[p+12],eax - - mov eax,ebp - sub eax,16 ;=sizeof(dd)*4 +glScalef: ;x, y, z + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_Scale stdcall gl_add_op,eax - ret -endp + pop eax + ret 16 ;=sizeof(dd)*4 align 4 -proc glViewport uses eax, x:dword, y:dword, width:dword, heigh:dword -locals - p rd 5 -endl - mov dword[p],OP_Viewport - mov eax,[x] - mov dword[p+4],eax - mov eax,[y] - mov dword[p+8],eax - mov eax,[width] - mov dword[p+12],eax - mov eax,[heigh] - mov dword[p+16],eax - - mov eax,ebp - sub eax,20 ;=sizeof(dd)*5 +glViewport: ;x, y, width, heigh + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_Viewport stdcall gl_add_op,eax - ret -endp + pop eax + ret 20 ;=sizeof(dd)*5 align 4 proc glFrustum uses eax, left:qword, right:qword, bottom:qword, top:qword,\ @@ -557,8 +409,7 @@ endl fld qword[farv] fstp dword[p+24] - mov eax,ebp - sub eax,28 ;=sizeof(dd)*7 + lea eax,[ebp-28] ;=sizeof(dd)*7 stdcall gl_add_op,eax ret endp @@ -621,8 +472,7 @@ endl mov dword[p+24],0.0 @@: - mov eax,ebp - sub eax,28 ;=sizeof(dd)*7 + lea eax,[ebp-28] ;=sizeof(dd)*7 stdcall gl_add_op,eax ret endp @@ -643,28 +493,20 @@ endl mov dword[p+20],0.0 mov dword[p+24],0.0 - mov eax,ebp - sub eax,28 ;=sizeof(dd)*7 + lea eax,[ebp-28] ;=sizeof(dd)*7 stdcall gl_add_op,eax ret endp align 4 -proc glColorMaterial uses eax, mode:dword, type:dword -locals - p rd 3 -endl - mov dword[p],OP_ColorMaterial - mov eax,[mode] - mov dword[p+4],eax - mov eax,[type] - mov dword[p+8],eax - - mov eax,ebp - sub eax,12 ;=sizeof(dd)*3 +glColorMaterial: ;mode, type + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_ColorMaterial stdcall gl_add_op,eax - ret -endp + pop eax + ret 12 ;=sizeof(dd)*3 align 4 proc glLightfv uses eax ecx, light:dword, type:dword, v:dword @@ -688,8 +530,7 @@ endl mov ecx,[eax+12] mov dword[p+24],ecx - mov eax,ebp - sub eax,28 ;=sizeof(dd)*7 + lea eax,[ebp-28] ;=sizeof(dd)*7 stdcall gl_add_op,eax ret endp @@ -710,8 +551,7 @@ endl mov dword[p+20],0.0 mov dword[p+24],0.0 - mov eax,ebp - sub eax,28 ;=sizeof(dd)*7 + lea eax,[ebp-28] ;=sizeof(dd)*7 stdcall gl_add_op,eax ret endp @@ -731,8 +571,7 @@ endl mov dword[p+16],0.0 mov dword[p+20],0.0 - mov eax,ebp - sub eax,24 ;=sizeof(dd)*6 + lea eax,[ebp-24] ;=sizeof(dd)*6 stdcall gl_add_op,eax ret endp @@ -755,8 +594,7 @@ endl mov ecx,[eax+12] mov dword[p+20],ecx - mov eax,ebp - sub eax,24 ;=sizeof(dd)*6 + lea eax,[ebp-24] ;=sizeof(dd)*6 stdcall gl_add_op,eax ret endp @@ -764,19 +602,14 @@ endp ; clear align 4 -proc glClear uses eax, mask:dword -locals - p rd 2 -endl - mov dword[p],OP_Clear - mov eax,[mask] - mov dword[p+4],eax - - mov eax,ebp - sub eax,8 ;=sizeof(dd)*2 +glClear: ;mask + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_Clear stdcall gl_add_op,eax - ret -endp + pop eax + ret 8 ;=sizeof(dd)*2 align 4 proc glClearColor uses eax, r:dword, g:dword, b:dword, a:dword @@ -793,8 +626,7 @@ endl mov eax,[a] mov dword[p+16],eax - mov eax,ebp - sub eax,20 ;=sizeof(dd)*5 + lea eax,[ebp-20] ;=sizeof(dd)*5 stdcall gl_add_op,eax ret endp @@ -809,8 +641,7 @@ endl fld qword[eax] fstp dword[p+4] - mov eax,ebp - sub eax,8 ;=sizeof(dd)*2 + lea eax,[ebp-8] ;=sizeof(dd)*2 stdcall gl_add_op,eax ret endp @@ -818,43 +649,24 @@ endp ; textures align 4 -proc glTexImage2D uses ecx edi esi,\ - target:dword, level:dword, components:dword,\ - width:dword, height:dword, border:dword,\ - format:dword, type:dword, pixels:dword -locals - p rd 10 -endl - mov dword[p],OP_TexImage2D - mov ecx,9 - mov esi,ebp - add esi,8 ;указатель на стек с входными параметрами - mov edi,ebp - sub edi,36 ;указатель на стек с локальным массивом - rep movsd ;копирование в цикле 9-ти входных параметров - - mov ecx,ebp - sub ecx,40 ;=sizeof(dd)*10 - stdcall gl_add_op,ecx - ret -endp +glTexImage2D: ;target, level, components, width, height, border, format, type, pixels + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_TexImage2D + stdcall gl_add_op,eax + pop eax + ret 40 ;=sizeof(dd)*10 align 4 -proc glBindTexture uses eax, target:dword, texture:dword -locals - p rd 3 -endl - mov dword[p],OP_BindTexture - mov eax,[target] - mov dword[p+4],eax - mov eax,[texture] - mov dword[p+8],eax - - mov eax,ebp - sub eax,12 ;=sizeof(dd)*3 +glBindTexture: ;target, texture + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_BindTexture stdcall gl_add_op,eax - ret -endp + pop eax + ret 12 ;=sizeof(dd)*3 align 4 proc glTexEnvi uses eax, target:dword, pname:dword, param:dword @@ -873,8 +685,7 @@ endl mov dword[p+24],0.0 mov dword[p+28],0.0 - mov eax,ebp - sub eax,32 ;=sizeof(dd)*8 + lea eax,[ebp-32] ;=sizeof(dd)*8 stdcall gl_add_op,eax ret endp @@ -896,120 +707,74 @@ endl mov dword[p+24],0.0 mov dword[p+28],0.0 - mov eax,ebp - sub eax,32 ;=sizeof(dd)*8 + lea eax,[ebp-32] ;=sizeof(dd)*8 stdcall gl_add_op,eax ret endp align 4 -proc glPixelStorei uses eax, pname:dword, param:dword -locals - p rd 3 -endl - mov dword[p],OP_PixelStore - mov eax,[pname] - mov dword[p+4],eax - mov eax,[param] - mov dword[p+8],eax - - mov eax,ebp - sub eax,12 ;=sizeof(dd)*3 +glPixelStorei: ;pname, param + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_PixelStore stdcall gl_add_op,eax - ret -endp + pop eax + ret 12 ;=sizeof(dd)*3 ; selection align 4 -proc glInitNames uses eax -locals - p dd ? -endl - mov dword[p],OP_InitNames - - mov eax,ebp - sub eax,4 ;=sizeof(dd)*1 - stdcall gl_add_op,eax +glInitNames: + stdcall gl_add_op,op_InitNames ret -endp align 4 -proc glPushName uses eax, name:dword -locals - p rd 2 -endl - mov dword[p],OP_PushName - mov eax,[name] - mov dword[p+4],eax - - mov eax,ebp - sub eax,8 ;=sizeof(dd)*2 +glPushName: ;name + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_PushName stdcall gl_add_op,eax - ret -endp + pop eax + ret 8 ;=sizeof(dd)*2 align 4 -proc glPopName uses eax -locals - p dd ? -endl - mov dword[p],OP_PopName - - mov eax,ebp - sub eax,4 ;=sizeof(dd)*1 - stdcall gl_add_op,eax +glPopName: + stdcall gl_add_op,op_PopName ret -endp align 4 -proc glLoadName uses eax, name:dword -locals - p rd 2 -endl - mov dword[p],OP_LoadName - mov eax,[name] - mov dword[p+4],eax - - mov eax,ebp - sub eax,8 ;=sizeof(dd)*2 +glLoadName: ;name + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_LoadName stdcall gl_add_op,eax - ret -endp + pop eax + ret 8 ;=sizeof(dd)*2 align 4 -proc glPolygonOffset uses eax, factor:dword, units:dword -locals - p rd 3 -endl - mov dword[p],OP_PolygonOffset - mov eax,[factor] - mov dword[p+4],eax - mov eax,[units] - mov dword[p+8],eax - - mov eax,ebp - sub eax,12 ;=sizeof(dd)*3 +glPolygonOffset: ;factor, units + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_PolygonOffset stdcall gl_add_op,eax - ret -endp + pop eax + ret 12 ;=sizeof(dd)*3 ; Special Functions align 4 -proc glCallList uses eax, list:dword -locals - p rd 2 -endl - mov dword[p],OP_CallList - mov eax,[list] - mov dword[p+4],eax - - mov eax,ebp - sub eax,8 ;=sizeof(dd)*2 +glCallList: ;list + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_CallList stdcall gl_add_op,eax - ret -endp + pop eax + ret 8 ;=sizeof(dd)*2 align 4 proc glFlush ;(void) @@ -1018,21 +783,14 @@ proc glFlush ;(void) endp align 4 -proc glHint uses eax, target:dword, mode:dword -locals - p rd 3 -endl - mov dword[p],OP_Hint - mov eax,[target] - mov dword[p+4],eax - mov eax,[mode] - mov dword[p+8],eax - - mov eax,ebp - sub eax,12 ;=sizeof(dd)*3 +glHint: ;target, mode + push dword[esp] ;копируем адрес возврата + push eax + lea eax,[esp+8] + mov dword[eax],OP_Hint stdcall gl_add_op,eax - ret -endp + pop eax + ret 12 ;=sizeof(dd)*3 ; Non standard functions diff --git a/programs/develop/libraries/TinyGL/asm_fork/clip.asm b/programs/develop/libraries/TinyGL/asm_fork/clip.asm index 09947f3280..e6f4236260 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/clip.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/clip.asm @@ -15,47 +15,46 @@ proc gl_transform_to_viewport uses eax ebx ecx, context:dword,v:dword ; coordinates fld1 - fdiv dword[ebx+offs_vert_pc+offs_W] ;st0 = 1/v.pc.W + fdiv dword[ebx+GLVertex.pc+offs_W] ;st0 = 1/v.pc.W - fld dword[ebx+offs_vert_pc+offs_X] ;st0 = v.pc.X + fld dword[ebx+GLVertex.pc+offs_X] ;st0 = v.pc.X fmul st0,st1 fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_X] fadd dword[eax+GLContext.viewport+offs_vpor_trans+offs_X] - fistp dword[ebx+offs_vert_zp] ;v.zp.x = st0, st0 = st1 + fistp dword[ebx+GLVertex.zp] ;v.zp.x = st0, st0 = st1 - fld dword[ebx+offs_vert_pc+offs_Y] ;st0 = v.pc.Y + fld dword[ebx+GLVertex.pc+offs_Y] ;st0 = v.pc.Y fmul st0,st1 fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_Y] fadd dword[eax+GLContext.viewport+offs_vpor_trans+offs_Y] - fistp dword[ebx+offs_vert_zp+offs_zbup_y] ;v.zp.y = st0, st0 = st1 + fistp dword[ebx+GLVertex.zp+offs_zbup_y] ;v.zp.y = st0, st0 = st1 - fld dword[ebx+offs_vert_pc+offs_Z] ;st0 = v.pc.Z + fld dword[ebx+GLVertex.pc+offs_Z] ;st0 = v.pc.Z fmulp fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_Z] fadd dword[eax+GLContext.viewport+offs_vpor_trans+offs_Z] - fistp dword[ebx+offs_vert_zp+offs_zbup_z] ;v.zp.z = st0, st0 = st1 + fistp dword[ebx+GLVertex.zp+offs_zbup_z] ;v.zp.z = st0, st0 = st1 ; color cmp dword[eax+GLContext.lighting_enabled],0 ;if (context.lighting_enabled) je @f - mov ecx,ebx - add ecx,offs_vert_zp+offs_zbup_b + lea ecx,[ebx+GLVertex.zp+offs_zbup_b] push ecx add ecx,offs_zbup_g-offs_zbup_b push ecx add ecx,offs_zbup_r-offs_zbup_g push ecx - stdcall RGBFtoRGBI, dword[ebx+offs_vert_color],dword[ebx+offs_vert_color+4],dword[ebx+offs_vert_color+8] + stdcall RGBFtoRGBI, dword[ebx+GLVertex.color],dword[ebx+GLVertex.color+4],dword[ebx+GLVertex.color+8] jmp .end_if align 4 @@: ; no need to convert to integer if no lighting : take current color mov ecx,[eax+GLContext.longcurrent_color] - mov dword[ebx+offs_vert_zp+offs_zbup_r],ecx + mov dword[ebx+GLVertex.zp+offs_zbup_r],ecx mov ecx,[eax+GLContext.longcurrent_color+4] - mov dword[ebx+offs_vert_zp+offs_zbup_g],ecx + mov dword[ebx+GLVertex.zp+offs_zbup_g],ecx mov ecx,[eax+GLContext.longcurrent_color+8] - mov dword[ebx+offs_vert_zp+offs_zbup_b],ecx + mov dword[ebx+GLVertex.zp+offs_zbup_b],ecx .end_if: ; texture @@ -66,13 +65,13 @@ align 4 ;[eax+offs_text_images] = im = &context.current_texture.images[0] fild dword[eax+offs_text_images+offs_imag_s_bound] - fmul dword[ebx+offs_vert_tex_coord+offs_X] - fistp dword[ebx+offs_vert_zp+offs_zbup_s] + fmul dword[ebx+GLVertex.tex_coord+offs_X] + fistp dword[ebx+GLVertex.zp+offs_zbup_s] ;v.zp.s=(int)(v.tex_coord.X * im.s_bound) fild dword[eax+offs_text_images+offs_imag_t_bound] - fmul dword[ebx+offs_vert_tex_coord+offs_Y] - fistp dword[ebx+offs_vert_zp+offs_zbup_t] + fmul dword[ebx+GLVertex.tex_coord+offs_Y] + fistp dword[ebx+GLVertex.zp+offs_zbup_t] ;v.zp.t=(int)(v.tex_coord.Y * im.t_bound) @@: ret @@ -113,16 +112,16 @@ endp align 16 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) + cmp dword[ebx+GLVertex.clip_code],0 ;if (p0.clip_code == 0) jne @f mov eax,[context] cmp dword[eax+GLContext.render_mode],GL_SELECT 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 + stdcall gl_add_select, eax,dword[ebx+GLVertex.zp+offs_zbup_z],dword[ebx+GLVertex.zp+offs_zbup_z] ;p0.zp.z,p0.zp.z jmp @f align 4 .els: - add ebx,offs_vert_zp + add ebx,GLVertex.zp stdcall ZB_plot, dword[eax+GLContext.zb],ebx @@: ret @@ -140,48 +139,48 @@ macro interpolate q, p0, p1, t fld dword[t] ; интерполяция по координатам - fld dword[p1+offs_vert_pc] - fsub dword[p0+offs_vert_pc] + fld dword[p1+GLVertex.pc] + fsub dword[p0+GLVertex.pc] fmul st0,st1 - fadd dword[p0+offs_vert_pc] - fstp dword[q+offs_vert_pc] ;q.pc.X = p0.pc.X + (p1.pc.X - p0.pc.X) * t + fadd dword[p0+GLVertex.pc] + fstp dword[q+GLVertex.pc] ;q.pc.X = p0.pc.X + (p1.pc.X - p0.pc.X) * t - fld dword[p1+offs_vert_pc+offs_Y] - fsub dword[p0+offs_vert_pc+offs_Y] + fld dword[p1+GLVertex.pc+offs_Y] + fsub dword[p0+GLVertex.pc+offs_Y] fmul st0,st1 - fadd dword[p0+offs_vert_pc+offs_Y] - fstp dword[q+offs_vert_pc+offs_Y] + fadd dword[p0+GLVertex.pc+offs_Y] + fstp dword[q+GLVertex.pc+offs_Y] - fld dword[p1+offs_vert_pc+offs_Z] - fsub dword[p0+offs_vert_pc+offs_Z] + fld dword[p1+GLVertex.pc+offs_Z] + fsub dword[p0+GLVertex.pc+offs_Z] fmul st0,st1 - fadd dword[p0+offs_vert_pc+offs_Z] - fstp dword[q+offs_vert_pc+offs_Z] + fadd dword[p0+GLVertex.pc+offs_Z] + fstp dword[q+GLVertex.pc+offs_Z] - fld dword[p1+offs_vert_pc+offs_W] - fsub dword[p0+offs_vert_pc+offs_W] + fld dword[p1+GLVertex.pc+offs_W] + fsub dword[p0+GLVertex.pc+offs_W] fmul st0,st1 - fadd dword[p0+offs_vert_pc+offs_W] - fstp dword[q+offs_vert_pc+offs_W] + fadd dword[p0+GLVertex.pc+offs_W] + fstp dword[q+GLVertex.pc+offs_W] ; интерполяция по цвету - fld dword[p1+offs_vert_color] - fsub dword[p0+offs_vert_color] + fld dword[p1+GLVertex.color] + fsub dword[p0+GLVertex.color] fmul st0,st1 - fadd dword[p0+offs_vert_color] - fstp dword[q+offs_vert_color] + fadd dword[p0+GLVertex.color] + fstp dword[q+GLVertex.color] - fld dword[p1+offs_vert_color+4] - fsub dword[p0+offs_vert_color+4] + fld dword[p1+GLVertex.color+4] + fsub dword[p0+GLVertex.color+4] fmul st0,st1 - fadd dword[p0+offs_vert_color+4] - fstp dword[q+offs_vert_color+4] + fadd dword[p0+GLVertex.color+4] + fstp dword[q+GLVertex.color+4] - fld dword[p1+offs_vert_color+8] - fsub dword[p0+offs_vert_color+8] + fld dword[p1+GLVertex.color+8] + fsub dword[p0+GLVertex.color+8] fmulp - fadd dword[p0+offs_vert_color+8] - fstp dword[q+offs_vert_color+8] + fadd dword[p0+GLVertex.color+8] + fstp dword[q+GLVertex.color+8] } ; @@ -280,20 +279,20 @@ pushad mov edi,[p1] mov esi,[p2] - cmp dword[edi+offs_vert_clip_code],0 + cmp dword[edi+GLVertex.clip_code],0 jne .els_i - cmp dword[esi+offs_vert_clip_code],0 + cmp dword[esi+GLVertex.clip_code],0 jne .els_i ;if ( (p1.clip_code | p2.clip_code) == 0) cmp dword[edx+GLContext.render_mode],GL_SELECT ;if (context.render_mode == GL_SELECT) jne .els_1 - 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] + stdcall gl_add_select1, edx,dword[edi+GLVertex.zp+offs_zbup_z],\ + dword[esi+GLVertex.zp+offs_zbup_z],dword[esi+GLVertex.zp+offs_zbup_z] jmp .end_f align 4 .els_1: - add edi,offs_vert_zp - add esi,offs_vert_zp + add edi,GLVertex.zp + add esi,GLVertex.zp push esi push edi push dword[edx+GLContext.zb] @@ -309,39 +308,38 @@ align 4 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] + mov eax,[edi+GLVertex.clip_code] + and eax,[esi+GLVertex.clip_code] or eax,eax jnz .end_f .els_0: - fld dword[esi+offs_vert_pc+offs_X] - fsub dword[edi+offs_vert_pc+offs_X] + fld dword[esi+GLVertex.pc+offs_X] + fsub dword[edi+GLVertex.pc+offs_X] fstp dword[d_x] ;d_x = p2.pc.X - p1.pc.X - fld dword[esi+offs_vert_pc+offs_Y] - fsub dword[edi+offs_vert_pc+offs_Y] + fld dword[esi+GLVertex.pc+offs_Y] + fsub dword[edi+GLVertex.pc+offs_Y] fstp dword[d_y] ;d_y = p2.pc.Y - p1.pc.Y - fld dword[esi+offs_vert_pc+offs_Z] - fsub dword[edi+offs_vert_pc+offs_Z] + fld dword[esi+GLVertex.pc+offs_Z] + fsub dword[edi+GLVertex.pc+offs_Z] fstp dword[d_z] ;d_z = p2.pc.Z - p1.pc.Z - fld dword[esi+offs_vert_pc+offs_W] - fsub dword[edi+offs_vert_pc+offs_W] + fld dword[esi+GLVertex.pc+offs_W] + fsub dword[edi+GLVertex.pc+offs_W] fstp dword[d_w] ;d_w = p2.pc.W - p1.pc.W - mov eax,[edi+offs_vert_pc+offs_X] + mov eax,[edi+GLVertex.pc+offs_X] mov [x1],eax ;x1 = p1.pc.X - mov eax,[edi+offs_vert_pc+offs_Y] + mov eax,[edi+GLVertex.pc+offs_Y] mov [y1],eax ;y1 = p1.pc.Y - mov eax,[edi+offs_vert_pc+offs_Z] + mov eax,[edi+GLVertex.pc+offs_Z] mov [z1],eax ;z1 = p1.pc.Z - mov eax,[edi+offs_vert_pc+offs_W] + mov eax,[edi+GLVertex.pc+offs_W] mov [w1],eax ;w1 = p1.pc.W mov dword[tmin],0.0 mov dword[tmax],1.0 - mov eax,ebp - sub eax,4 + lea eax,[ebp-4] push eax ;толкаем в стек адрес &tmax sub eax,4 push eax ;толкаем в стек адрес &tmin @@ -419,8 +417,7 @@ align 4 bt eax,0 jnc .end_f - mov eax,ebp - sub eax,8+2*sizeof.GLVertex ;eax = &q1 + lea eax,[ebp-8-2*sizeof.GLVertex] ;eax = &q1 interpolate eax,edi,esi,tmin stdcall gl_transform_to_viewport, edx,eax add eax,sizeof.GLVertex ;eax = &q2 @@ -428,26 +425,24 @@ align 4 stdcall gl_transform_to_viewport, edx,eax sub eax,sizeof.GLVertex ;eax = &q1 - mov ebx,eax - add ebx,offs_vert_zp+offs_zbup_b + lea ebx,[eax+GLVertex.zp+offs_zbup_b] push ebx add ebx,offs_zbup_g-offs_zbup_b push ebx add ebx,offs_zbup_r-offs_zbup_g push ebx - stdcall RGBFtoRGBI, dword[eax+offs_vert_color],dword[eax+offs_vert_color+4],dword[eax+offs_vert_color+8] + stdcall RGBFtoRGBI, dword[eax+GLVertex.color],dword[eax+GLVertex.color+4],dword[eax+GLVertex.color+8] add eax,sizeof.GLVertex ;eax = &q2 - mov ebx,eax - add ebx,offs_vert_zp+offs_zbup_b + lea ebx,[eax+GLVertex.zp+offs_zbup_b] push ebx add ebx,offs_zbup_g-offs_zbup_b push ebx add ebx,offs_zbup_r-offs_zbup_g push ebx - stdcall RGBFtoRGBI, dword[eax+offs_vert_color],dword[eax+offs_vert_color+4],dword[eax+offs_vert_color+8] + stdcall RGBFtoRGBI, dword[eax+GLVertex.color],dword[eax+GLVertex.color+4],dword[eax+GLVertex.color+8] - add eax,offs_vert_zp ;eax = &q2.zp + add eax,GLVertex.zp ;eax = &q2.zp push eax sub eax,sizeof.GLVertex ;eax = &q1.zp push eax @@ -595,61 +590,60 @@ proc updateTmp uses eax ecx edx, context:dword, p0:dword, p1:dword, t:dword cmp dword[edx+GLContext.current_shade_model],GL_SMOOTH ;if (context.current_shade_model == GL_SMOOTH) jne .els_0 mov ecx,[p1] - fld dword[ecx+offs_vert_color] - fsub dword[eax+offs_vert_color] + fld dword[ecx+GLVertex.color] + fsub dword[eax+GLVertex.color] fmul dword[t] - fadd dword[eax+offs_vert_color] - fstp dword[edi+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] + fadd dword[eax+GLVertex.color] + fstp dword[edi+GLVertex.color] ;q.color.v[0]=p0.color.v[0] + (p1.color.v[0]-p0.color.v[0])*t + fld dword[ecx+GLVertex.color+4] + fsub dword[eax+GLVertex.color+4] fmul dword[t] - fadd dword[eax+offs_vert_color+4] - fstp dword[edi+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] + fadd dword[eax+GLVertex.color+4] + fstp dword[edi+GLVertex.color+4] ;q.color.v[1]=p0.color.v[1] + (p1.color.v[1]-p0.color.v[1])*t + fld dword[ecx+GLVertex.color+8] + fsub dword[eax+GLVertex.color+8] fmul dword[t] - fadd dword[eax+offs_vert_color+8] - fstp dword[edi+offs_vert_color+8] ;q.color.v[2]=p0.color.v[2] + (p1.color.v[2]-p0.color.v[2])*t + fadd dword[eax+GLVertex.color+8] + fstp dword[edi+GLVertex.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 [edi+offs_vert_color],ecx ;q.color.v[0]=p0.color.v[0] - mov ecx,[eax+offs_vert_color+4] - mov [edi+offs_vert_color+4],ecx ;q.color.v[1]=p0.color.v[1] - mov ecx,[eax+offs_vert_color+8] - mov [edi+offs_vert_color+8],ecx ;q.color.v[2]=p0.color.v[2] + mov ecx,[eax+GLVertex.color] + mov [edi+GLVertex.color],ecx ;q.color.v[0]=p0.color.v[0] + mov ecx,[eax+GLVertex.color+4] + mov [edi+GLVertex.color+4],ecx ;q.color.v[1]=p0.color.v[1] + mov ecx,[eax+GLVertex.color+8] + mov [edi+GLVertex.color+8],ecx ;q.color.v[2]=p0.color.v[2] @@: cmp dword[edx+GLContext.texture_2d_enabled],0 ;if (context.texture_2d_enabled) je @f mov ecx,[p1] - fld dword[ecx+offs_vert_tex_coord+offs_X] - fsub dword[eax+offs_vert_tex_coord+offs_X] + fld dword[ecx+GLVertex.tex_coord+offs_X] + fsub dword[eax+GLVertex.tex_coord+offs_X] fmul dword[t] - fadd dword[eax+offs_vert_tex_coord+offs_X] - fstp dword[edi+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] + fadd dword[eax+GLVertex.tex_coord+offs_X] + fstp dword[edi+GLVertex.tex_coord+offs_X] ;q.tex_coord.X=p0.tex_coord.X + (p1.tex_coord.X-p0.tex_coord.X)*t + fld dword[ecx+GLVertex.tex_coord+offs_Y] + fsub dword[eax+GLVertex.tex_coord+offs_Y] fmul dword[t] - fadd dword[eax+offs_vert_tex_coord+offs_Y] - fstp dword[edi+offs_vert_tex_coord+offs_Y] ;q.tex_coord.Y=p0.tex_coord.Y + (p1.tex_coord.Y-p0.tex_coord.Y)*t + fadd dword[eax+GLVertex.tex_coord+offs_Y] + fstp dword[edi+GLVertex.tex_coord+offs_Y] ;q.tex_coord.Y=p0.tex_coord.Y + (p1.tex_coord.Y-p0.tex_coord.Y)*t @@: - stdcall gl_clipcode, [edi+offs_vert_pc+offs_X],[edi+offs_vert_pc+offs_Y],\ - [edi+offs_vert_pc+offs_Z],[edi+offs_vert_pc+offs_W] - mov dword[edi+offs_vert_clip_code],eax + stdcall gl_clipcode, [edi+GLVertex.pc+offs_X],[edi+GLVertex.pc+offs_Y],\ + [edi+GLVertex.pc+offs_Z],[edi+GLVertex.pc+offs_W] + mov dword[edi+GLVertex.clip_code],eax or eax,eax ;if (q.clip_code==0) jnz @f stdcall gl_transform_to_viewport,[context],edi - mov eax,edi - add eax,offs_vert_zp+offs_zbup_b + lea eax,[edi+GLVertex.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[edi+offs_vert_color],dword[edi+offs_vert_color+4],dword[edi+offs_vert_color+8] + stdcall RGBFtoRGBI, dword[edi+GLVertex.color],dword[edi+GLVertex.color+4],dword[edi+GLVertex.color+8] @@: ret endp @@ -665,12 +659,12 @@ pushad mov ebx,[p0] mov ecx,[p1] mov edx,[p2] - mov edi,[ebx+offs_vert_clip_code] + mov edi,[ebx+GLVertex.clip_code] mov dword[cc],edi - mov eax,[ecx+offs_vert_clip_code] + mov eax,[ecx+GLVertex.clip_code] mov dword[cc+4],eax or edi,eax - mov eax,[edx+offs_vert_clip_code] + mov eax,[edx+GLVertex.clip_code] mov dword[cc+8],eax or edi,eax ;co = cc[0] | cc[1] | cc[2] @@ -678,21 +672,21 @@ pushad ;or edi,___ - было выше jnz .els_0 ;if (co==0) - mov edi,dword[edx+offs_vert_zp+offs_zbup_x] - sub edi,dword[ebx+offs_vert_zp+offs_zbup_x] + mov edi,dword[edx+GLVertex.zp+offs_zbup_x] + sub edi,dword[ebx+GLVertex.zp+offs_zbup_x] mov dword[norm],edi ;p2.x-p0.x fild dword[norm] - mov edi,dword[ecx+offs_vert_zp+offs_zbup_y] - sub edi,dword[ebx+offs_vert_zp+offs_zbup_y] + mov edi,dword[ecx+GLVertex.zp+offs_zbup_y] + sub edi,dword[ebx+GLVertex.zp+offs_zbup_y] mov dword[norm],edi ;p1.y-p0.y fimul dword[norm] fchs - mov edi,dword[ecx+offs_vert_zp+offs_zbup_x] - sub edi,dword[ebx+offs_vert_zp+offs_zbup_x] + mov edi,dword[ecx+GLVertex.zp+offs_zbup_x] + sub edi,dword[ebx+GLVertex.zp+offs_zbup_x] mov dword[norm],edi ;p1.x-p0.x fild dword[norm] - mov edi,dword[edx+offs_vert_zp+offs_zbup_y] - sub edi,dword[ebx+offs_vert_zp+offs_zbup_y] + mov edi,dword[edx+GLVertex.zp+offs_zbup_y] + sub edi,dword[ebx+GLVertex.zp+offs_zbup_y] mov dword[norm],edi ;p2.y-p0.y fimul dword[norm] faddp @@ -770,12 +764,12 @@ pushad mov ecx,[p1] mov edx,[p2] - mov edi,[ebx+offs_vert_clip_code] + mov edi,[ebx+GLVertex.clip_code] mov [cc],edi - mov eax,[ecx+offs_vert_clip_code] + mov eax,[ecx+GLVertex.clip_code] mov [cc+4],eax or edi,eax - mov eax,[edx+offs_vert_clip_code] + mov eax,[edx+GLVertex.clip_code] mov [cc+8],eax or edi,eax mov [co],edi ;co = cc[0] | cc[1] | cc[2] @@ -869,54 +863,49 @@ align 4 .els_2_end: mov ebx,[q] - add ebx,offs_vert_pc + add ebx,GLVertex.pc mov ecx,[q+4] - add ecx,offs_vert_pc + add ecx,GLVertex.pc mov edx,[q+8] - add edx,offs_vert_pc + add edx,GLVertex.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 + lea eax,[eax+4*edi] + lea edi,[ebp-(2*sizeof.GLVertex)+GLVertex.pc] stdcall dword[eax],edi,ebx,ecx ;clip_proc[clip_bit](&tmp1.pc,&q[0].pc,&q[1].pc) - sub edi,offs_vert_pc + sub edi,GLVertex.pc - sub ebx,offs_vert_pc - sub ecx,offs_vert_pc + sub ebx,GLVertex.pc + sub ecx,GLVertex.pc stdcall updateTmp,[context],ebx,ecx,eax ;(c,&tmp1,q[0],q[1],tt) - add ebx,offs_vert_pc + add ebx,GLVertex.pc lea eax,[clip_proc] mov edi,[clip_bit] - shl edi,2 - add eax,edi - mov edi,ebp - sub edi,sizeof.GLVertex-offs_vert_pc + lea eax,[eax+4*edi] + lea edi,[ebp-sizeof.GLVertex+GLVertex.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 + sub edi,GLVertex.pc + sub ebx,GLVertex.pc + sub edx,GLVertex.pc stdcall updateTmp,[context],ebx,edx,eax ;(c,&tmp2,q[0],q[2],tt) - mov eax,[ebx+offs_vert_edge_flag] + mov eax,[ebx+GLVertex.edge_flag] mov [tmp1.edge_flag],eax ;q[0].edge_flag - mov eax,[edx+offs_vert_edge_flag] + mov eax,[edx+GLVertex.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 dword[edx+GLVertex.edge_flag],0 ;q[2].edge_flag=0 mov eax,[clip_bit] inc eax push eax ;для вызова нижней функции - mov edi,ebp - sub edi,2*sizeof.GLVertex + lea edi,[ebp-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 + mov [edx+GLVertex.edge_flag],eax ;q[2].edge_flag=edge_flag_tmp push edx push edi add edi,sizeof.GLVertex ;edi = &tmp2 @@ -954,34 +943,30 @@ align 4 .els_4_end: mov ebx,[q] - add ebx,offs_vert_pc + add ebx,GLVertex.pc mov ecx,[q+4] - add ecx,offs_vert_pc + add ecx,GLVertex.pc mov edx,[q+8] - add edx,offs_vert_pc + add edx,GLVertex.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 + lea eax,[eax+4*edi] + lea edi,[ebp-(2*sizeof.GLVertex)+GLVertex.pc] stdcall dword[eax],edi,ebx,ecx ;clip_proc[clip_bit](&tmp1.pc,&q[0].pc,&q[1].pc) - sub edi,offs_vert_pc + sub edi,GLVertex.pc stdcall updateTmp,[context],[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 + lea eax,[eax+4*edi] + lea edi,[ebp-sizeof.GLVertex+GLVertex.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 edi,GLVertex.pc stdcall updateTmp,[context],[q],[q+8],eax mov dword[tmp1.edge_flag],1 - mov eax,[edx+offs_vert_edge_flag-offs_vert_pc] + mov eax,[edx+GLVertex.edge_flag-GLVertex.pc] mov dword[tmp2.edge_flag],eax ;tmp2.edge_flag = q[2].edge_flag mov eax,[clip_bit] inc eax @@ -997,11 +982,11 @@ endp align 16 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] + push dword[eax+GLVertex.zp+offs_Z] mov eax,[p1] - push dword[eax+offs_vert_zp+offs_Z] + push dword[eax+GLVertex.zp+offs_Z] mov eax,[p0] - push dword[eax+offs_vert_zp+offs_Z] + push dword[eax+GLVertex.zp+offs_Z] stdcall gl_add_select1, [context] ;,p0.zp.z, p1.zp.z, p2.zp.z ret endp @@ -1031,9 +1016,9 @@ if PROFILE eq 1 end if mov ebx,[p1] - add ebx,offs_vert_zp + add ebx,GLVertex.zp mov ecx,[p2] - add ecx,offs_vert_zp + add ecx,GLVertex.zp mov edx,[context] cmp dword[edx+GLContext.texture_2d_enabled],0 je .els_i @@ -1047,7 +1032,7 @@ end if stdcall ZB_setTexture, [edx+GLContext.zb], [eax],\ [eax+offs_imag_s_bound],[eax+offs_imag_t_bound],[eax+offs_imag_xsize_log2] mov eax,[p0] - add eax,offs_vert_zp + add eax,GLVertex.zp push ecx push ebx push eax @@ -1063,7 +1048,7 @@ align 4 align 4 .els_i: mov eax,[p0] - add eax,offs_vert_zp + add eax,GLVertex.zp cmp dword[edx+GLContext.current_shade_model],GL_SMOOTH jne .els ;else if (context.current_shade_model == GL_SMOOTH) @@ -1093,32 +1078,29 @@ align 4 ;if (p0.edge_flag) ZB_line_z(context.zb,&p0.zp,&p1.zp) mov eax,[p0] - cmp dword[eax+offs_vert_edge_flag],0 + cmp dword[eax+GLVertex.edge_flag],0 je @f - mov ebx,eax - add ebx,offs_vert_zp + lea ebx,[eax+GLVertex.zp] mov eax,[p1] - add eax,offs_vert_zp + add eax,GLVertex.zp stdcall ecx,dword[edx+GLContext.zb],ebx,eax @@: ;if (p1.edge_flag) ZB_line_z(context.zb,&p1.zp,&p2.zp) mov eax,[p1] - cmp dword[eax+offs_vert_edge_flag],0 + cmp dword[eax+GLVertex.edge_flag],0 je @f - mov ebx,eax - add ebx,offs_vert_zp + lea ebx,[eax+GLVertex.zp] mov eax,[p2] - add eax,offs_vert_zp + add eax,GLVertex.zp stdcall ecx,dword[edx+GLContext.zb],ebx,eax @@: ;if (p2.edge_flag) ZB_line_z(context.zb,&p2.zp,&p0.zp); mov eax,[p2] - cmp dword[eax+offs_vert_edge_flag],0 + cmp dword[eax+GLVertex.edge_flag],0 je @f - mov ebx,eax - add ebx,offs_vert_zp + lea ebx,[eax+GLVertex.zp] mov eax,[p0] - add eax,offs_vert_zp + add eax,GLVertex.zp stdcall ecx,dword[edx+GLContext.zb],ebx,eax @@: @@ -1127,28 +1109,25 @@ endp ; Render a clipped triangle in point mode align 16 -proc gl_draw_triangle_point uses eax ebx edx, context:dword, p0:dword,p1:dword,p2:dword +proc gl_draw_triangle_point uses eax edx, context:dword, p0:dword,p1:dword,p2:dword mov edx,[context] mov eax,[p0] - cmp dword[eax+offs_vert_edge_flag],0 + cmp dword[eax+GLVertex.edge_flag],0 je @f - mov ebx,eax - add ebx,offs_vert_zp - stdcall ZB_plot,dword[edx+GLContext.zb],ebx + lea eax,[eax+GLVertex.zp] + stdcall ZB_plot,dword[edx+GLContext.zb],eax @@: mov eax,[p1] - cmp dword[eax+offs_vert_edge_flag],0 + cmp dword[eax+GLVertex.edge_flag],0 je @f - mov ebx,eax - add ebx,offs_vert_zp - stdcall ZB_plot,dword[edx+GLContext.zb],ebx + lea eax,[eax+GLVertex.zp] + stdcall ZB_plot,dword[edx+GLContext.zb],eax @@: mov eax,[p2] - cmp dword[eax+offs_vert_edge_flag],0 + cmp dword[eax+GLVertex.edge_flag],0 je @f - mov ebx,eax - add ebx,offs_vert_zp - stdcall ZB_plot,dword[edx+GLContext.zb],ebx + lea eax,[eax+GLVertex.zp] + stdcall ZB_plot,dword[edx+GLContext.zb],eax @@: ret endp diff --git a/programs/develop/libraries/TinyGL/asm_fork/init.asm b/programs/develop/libraries/TinyGL/asm_fork/init.asm index b680d44128..6b586cacfd 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/init.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/init.asm @@ -64,17 +64,17 @@ pushad mov eax,edx add eax,GLContext.lights .cycle_0: - gl_V4_New eax+offs_ligh_ambient, 0.0,0.0,0.0,1.0 - gl_V4_New eax+offs_ligh_diffuse, 1.0,1.0,1.0,1.0 - gl_V4_New eax+offs_ligh_specular, 1.0,1.0,1.0,1.0 - gl_V4_New eax+offs_ligh_position, 0.0,0.0,1.0,0.0 - gl_V3_New eax+offs_ligh_norm_position, 0.0,0.0,1.0 - gl_V3_New eax+offs_ligh_spot_direction, 0.0,0.0,-1.0 - gl_V3_New eax+offs_ligh_norm_spot_direction, 0.0,0.0,-1.0 - mov dword[eax+offs_ligh_spot_exponent],0.0 - mov dword[eax+offs_ligh_spot_cutoff],180.0 - gl_V3_New eax+offs_ligh_attenuation, 1.0,0.0,0.0 - mov dword[eax+offs_ligh_enabled],0 + gl_V4_New eax+GLLight.ambient, 0.0,0.0,0.0,1.0 + gl_V4_New eax+GLLight.diffuse, 1.0,1.0,1.0,1.0 + gl_V4_New eax+GLLight.specular, 1.0,1.0,1.0,1.0 + gl_V4_New eax+GLLight.position, 0.0,0.0,1.0,0.0 + gl_V3_New eax+GLLight.norm_position, 0.0,0.0,1.0 + gl_V3_New eax+GLLight.spot_direction, 0.0,0.0,-1.0 + gl_V3_New eax+GLLight.norm_spot_direction, 0.0,0.0,-1.0 + mov dword[eax+GLLight.spot_exponent],0.0 + mov dword[eax+GLLight.spot_cutoff],180.0 + gl_V3_New eax+GLLight.attenuation, 1.0,0.0,0.0 + mov dword[eax+GLLight.enabled],0 add eax,sizeof.GLLight dec ecx cmp ecx,0 @@ -88,14 +88,13 @@ pushad ; default materials mov ecx,2 ;for(i=0;i<2;i++) - mov eax,edx - add eax,GLContext.materials + lea eax,[edx+GLContext.materials] @@: - gl_V4_New eax+offs_mate_emission, 0.0,0.0,0.0,1.0 - gl_V4_New eax+offs_mate_ambient, 0.2,0.2,0.2,1.0 - gl_V4_New eax+offs_mate_diffuse, 0.8,0.8,0.8,1.0 - gl_V4_New eax+offs_mate_specular, 0.0,0.0,0.0,1.0 - mov dword[eax+offs_mate_shininess], 0.0 + gl_V4_New eax+GLMaterial.emission, 0.0,0.0,0.0,1.0 + gl_V4_New eax+GLMaterial.ambient, 0.2,0.2,0.2,1.0 + gl_V4_New eax+GLMaterial.diffuse, 0.8,0.8,0.8,1.0 + gl_V4_New eax+GLMaterial.specular, 0.0,0.0,0.0,1.0 + mov dword[eax+GLMaterial.shininess], 0.0 add eax,sizeof.GLMaterial loop @b diff --git a/programs/develop/libraries/TinyGL/asm_fork/light.asm b/programs/develop/libraries/TinyGL/asm_fork/light.asm index c655b7bc1a..469b1ae94e 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/light.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/light.asm @@ -11,46 +11,43 @@ proc glopMaterial uses eax ebx ecx edi esi, context:dword, p:dword cmp ecx,GL_FRONT_AND_BACK ;if (mode == GL_FRONT_AND_BACK) jne @f mov dword[ebx+4],GL_FRONT ;p[1].i=GL_FRONT - mov edi,ebp - add edi,12 + lea edi,[ebp+12] stdcall glopMaterial,eax,edi mov ecx,GL_BACK @@: - mov edi,eax - add edi,GLContext.materials + lea edi,[eax+GLContext.materials] cmp ecx,GL_FRONT ;if (mode == GL_FRONT) m=&context.materials[0] je @f add edi,sizeof.GLMaterial ;else m=&context.materials[1] @@: mov ecx,4 - mov esi,ebx ;esi = &p - add esi,12 ;esi = &p[3] + lea esi,[ebx+12] ;esi = &p[3] mov ebx,[ebx+8] ;ebx = p[2] cmp ebx,GL_EMISSION jne @f - ;add edi,offs_mate_emission ;offs_mate_emission=0 + ;add edi,GLMaterial.emission ;GLMaterial.emission=0 rep movsd jmp .end_f align 4 @@: cmp ebx,GL_AMBIENT jne @f - add edi,offs_mate_ambient + add edi,GLMaterial.ambient rep movsd jmp .end_f align 4 @@: cmp ebx,GL_DIFFUSE jne @f - add edi,offs_mate_diffuse + add edi,GLMaterial.diffuse rep movsd jmp .end_f align 4 @@: cmp ebx,GL_SPECULAR jne @f - add edi,offs_mate_specular + add edi,GLMaterial.specular rep movsd jmp .end_f align 4 @@ -58,7 +55,7 @@ align 4 cmp ebx,GL_SHININESS jne @f fld dword[esi] - add edi,offs_mate_shininess + add edi,GLMaterial.shininess movsd mov dword[edi],SPECULAR_BUFFER_RESOLUTION fdiv dword[sp128f] @@ -69,10 +66,10 @@ align 4 @@: cmp ebx,GL_AMBIENT_AND_DIFFUSE jne @f - add edi,offs_mate_ambient + add edi,GLMaterial.ambient rep movsd sub esi,16 - ;edi = &offs_mate_diffuse + ;edi = &GLMaterial.diffuse mov ecx,4 rep movsd jmp .end_f @@ -108,16 +105,14 @@ pushad sub edx,GL_LIGHT0 imul edx,sizeof.GLLight - add edx,eax - add edx,GLContext.lights + lea edx,[eax+edx+GLContext.lights] mov ecx,[ebx+8] ;ecx = p[2] cmp ecx,GL_AMBIENT jne @f - mov esi,ebx - add esi,12 + lea esi,[ebx+12] mov edi,edx - ;add edi,offs_ligh_ambient ;offs_ligh_ambient = 0 + ;add edi,GLLight.ambient ;GLLight.ambient = 0 mov ecx,4 rep movsd ;l.ambient=v jmp .end_f @@ -125,10 +120,8 @@ align 4 @@: cmp ecx,GL_DIFFUSE jne @f - mov esi,ebx - add esi,12 - mov edi,edx - add edi,offs_ligh_diffuse + lea esi,[ebx+12] + lea edi,[edx+GLLight.diffuse] mov ecx,4 rep movsd ;l.diffuse=v jmp .end_f @@ -136,10 +129,8 @@ align 4 @@: cmp ecx,GL_SPECULAR jne @f - mov esi,ebx - add esi,12 - mov edi,edx - add edi,offs_ligh_specular + lea esi,[ebx+12] + lea edi,[edx+GLLight.specular] mov ecx,4 rep movsd ;l.specular=v jmp .end_f @@ -147,13 +138,10 @@ align 4 @@: cmp ecx,GL_POSITION jne @f - mov edi,ebx ;ebx = [ebp+12] = [p] = &p[0] - add edi,12 ;&p[3] - mov esi,ebp - sub esi,16 ;&pos + lea edi,[ebx+12] ;&p[3] + lea esi,[ebp-16] ;&pos stdcall gl_M4_MulV4, esi,dword[eax+GLContext.matrix_stack_ptr],edi - mov edi,edx - add edi,offs_ligh_position + lea edi,[edx+GLLight.position] mov ecx,4 rep movsd ;l.position=pos @@ -164,13 +152,11 @@ align 4 jne .end_i ;mov esi,ebp sub esi,16 ;&pos - mov edi,edx - add edi,offs_ligh_norm_position + lea edi,[edx+GLLight.norm_position] mov ecx,3 rep movsd ;l.norm_position=pos[1,2,3] - ;mov edi,edx - ;add edi,offs_ligh_norm_position + ;lea edi,[edx+GLLight.norm_position] sub edi,12 stdcall gl_V3_Norm,edi ;&l.norm_position .end_i: @@ -181,21 +167,17 @@ align 4 @@: cmp ecx,GL_SPOT_DIRECTION jne @f - mov esi,ebx ;&p[0] - add esi,12 - mov edi,edx - add edi,offs_ligh_spot_direction + lea esi,[ebx+12] ;&p[3] + lea edi,[edx+GLLight.spot_direction] mov ecx,3 rep movsd ;l.spot_direction=v[0,1,2] - ;mov esi,ebx - ;add esi,12 + ;lea esi,[ebx+12] sub esi,12 - ;mov edi,edx - ;add edi,offs_ligh_norm_spot_direction - add edi,offs_ligh_norm_spot_direction-(offs_ligh_spot_direction+12) + ;lea edi,[edx+GLLight.norm_spot_direction] + add edi,GLLight.norm_spot_direction-(GLLight.spot_direction+12) mov ecx,3 rep movsd ;l.norm_spot_direction=v[0,1,2] - add edx,offs_ligh_norm_spot_direction + add edx,GLLight.norm_spot_direction stdcall gl_V3_Norm,edx jmp .end_f align 4 @@ -203,7 +185,7 @@ align 4 cmp ecx,GL_SPOT_EXPONENT jne @f mov ecx,[ebx+12] - mov [edi+offs_ligh_spot_exponent],ecx ;l.spot_exponent=p[3] + mov [edi+GLLight.spot_exponent],ecx ;l.spot_exponent=p[3] jmp .end_f align 4 @@: @@ -211,7 +193,7 @@ align 4 jne .end_spot_c fld dword[ebp+12] ;float a=v.v[0] ; assert(a == 180 || (a>=0 && a<=90)); - fst dword[edi+offs_ligh_spot_cutoff] ;l.spot_cutoff=a + fst dword[edi+GLLight.spot_cutoff] ;l.spot_cutoff=a fcom dword[an180f] ;if (a != 180) fstsw ax sahf @@ -220,7 +202,7 @@ align 4 fmulp fdiv dword[an180f] fcos - fstp dword[edi+offs_ligh_cos_spot_cutoff] ;l.cos_spot_cutoff=cos(a * M_PI / 180.0) + fstp dword[edi+GLLight.cos_spot_cutoff] ;l.cos_spot_cutoff=cos(a * M_PI / 180.0) jmp .end_f @@: ffree st0 @@ -231,21 +213,21 @@ align 4 cmp ecx,GL_CONSTANT_ATTENUATION jne @f mov ecx,[ebx+12] - mov [edi+offs_ligh_attenuation],ecx ;l->attenuation[0]=p[3] + mov [edi+GLLight.attenuation],ecx ;l->attenuation[0]=p[3] jmp .end_f align 4 @@: cmp ecx,GL_LINEAR_ATTENUATION jne @f mov ecx,[ebx+12] - mov [edi+offs_ligh_attenuation+4],ecx ;l->attenuation[1]=p[3] + mov [edi+GLLight.attenuation+4],ecx ;l->attenuation[1]=p[3] jmp .end_f align 4 @@: cmp ecx,GL_QUADRATIC_ATTENUATION jne @f mov ecx,[ebx+12] - mov [edi+offs_ligh_attenuation+8],ecx ;l->attenuation[2]=p[3] + mov [edi+GLLight.attenuation+8],ecx ;l->attenuation[2]=p[3] jmp .end_f align 4 @@: ;default: @@ -326,11 +308,10 @@ proc gl_enable_disable_light uses eax ebx ecx, context:dword, light:dword, v:dwo mov eax,[context] mov ebx,[light] imul ebx,sizeof.GLLight - add ebx,eax - add ebx,GLContext.lights + lea ebx,[eax+ebx+GLContext.lights] xor ecx,ecx - cmp dword[ebx+offs_ligh_enabled],0 + cmp dword[ebx+GLLight.enabled],0 jne @f not ecx @@: @@ -338,11 +319,11 @@ proc gl_enable_disable_light uses eax ebx ecx, context:dword, light:dword, v:dwo or ecx,ecx jz @f ;if (v && !l.enabled) - mov dword[ebx+offs_ligh_enabled],1 + mov dword[ebx+GLLight.enabled],1 mov ecx,[eax+GLContext.first_light] - mov [ebx+offs_ligh_next],ecx + mov [ebx+GLLight.next],ecx mov [eax+GLContext.first_light],ebx ;context.first_light = l - mov dword[ebx+offs_ligh_prev],0 ;l.prev = NULL + mov dword[ebx+GLLight.prev],0 ;l.prev = NULL jmp .end_f align 4 @@: @@ -351,26 +332,26 @@ align 4 jne @f not ecx @@: - and ecx,[ebx+offs_ligh_enabled] + and ecx,[ebx+GLLight.enabled] or ecx,ecx jz .end_f ;else if (!v && l.enabled) - mov dword[ebx+offs_ligh_enabled],0 ;l.enabled = 0 - mov ecx,[ebx+offs_ligh_next] - cmp dword[ebx+offs_ligh_prev],0 ;if (l.prev == NULL) + mov dword[ebx+GLLight.enabled],0 ;l.enabled = 0 + mov ecx,[ebx+GLLight.next] + cmp dword[ebx+GLLight.prev],0 ;if (l.prev == NULL) jne .els_0 mov [eax+GLContext.first_light],ecx ;context.first_light = l.next jmp @f align 4 .els_0: - mov eax,[ebx+offs_ligh_prev] - mov [eax+offs_ligh_next],ecx ;l.prev.next = l.next + mov eax,[ebx+GLLight.prev] + mov [eax+GLLight.next],ecx ;l.prev.next = l.next @@: - cmp dword[ebx+offs_ligh_next],0 + cmp dword[ebx+GLLight.next],0 je .end_f - mov ecx,[ebx+offs_ligh_prev] - mov eax,[ebx+offs_ligh_next] - mov [eax+offs_ligh_prev],ecx ;l.next.prev = l.prev + mov ecx,[ebx+GLLight.prev] + mov eax,[ebx+GLLight.next] + mov [eax+GLLight.prev],ecx ;l.next.prev = l.prev .end_f: ret endp @@ -420,27 +401,26 @@ pushad mov eax,[edx+GLContext.light_model_two_side] mov [twoside],eax - add esi,offs_vert_normal - mov edi,ebp - sub edi,24 ;edi = &n + add esi,GLVertex.normal + lea edi,[ebp-24] ;edi = &n movsd ;n.X=v.normal.X movsd ;n.Y=v.normal.Y movsd ;n.Z=v.normal.Z mov esi,[v] fld dword[edx+GLContext.ambient_light_model] - fmul dword[ecx+offs_mate_ambient] - fadd dword[ecx] ;offs_mate_emission=0 + fmul dword[ecx+GLMaterial.ambient] + fadd dword[ecx] ;GLMaterial.emission=0 fstp dword[R] ;R=m.emission.v[0]+m.ambient.v[0]*context.ambient_light_model.v[0] fld dword[edx+GLContext.ambient_light_model+4] - fmul dword[ecx+offs_mate_ambient+4] - fadd dword[ecx+offs_mate_emission+4] + fmul dword[ecx+GLMaterial.ambient+4] + fadd dword[ecx+GLMaterial.emission+4] fstp dword[G] fld dword[edx+GLContext.ambient_light_model+8] - fmul dword[ecx+offs_mate_ambient+8] - fadd dword[ecx+offs_mate_emission+8] + fmul dword[ecx+GLMaterial.ambient+8] + fadd dword[ecx+GLMaterial.emission+8] fstp dword[B] - clampf [ecx+offs_mate_diffuse+12],0,1 + clampf [ecx+GLMaterial.diffuse+12],0,1 mov [A],eax ;A=clampf(m.diffuse.v[3],0,1) mov ebx,[edx+GLContext.first_light] @@ -449,17 +429,17 @@ pushad jz .cycle_0_end ; ambient - fld dword[ecx+offs_mate_ambient] - fmul dword[ebx] ;offs_ligh_ambient=0 + fld dword[ecx+GLMaterial.ambient] + fmul dword[ebx] ;GLLight.ambient=0 fstp dword[lR] ;lR=l.ambient.v[0] * m.ambient.v[0] - fld dword[ecx+offs_mate_ambient+4] - fmul dword[ebx+offs_ligh_ambient+4] + fld dword[ecx+GLMaterial.ambient+4] + fmul dword[ebx+GLLight.ambient+4] fstp dword[lG] ;lG=l.ambient.v[1] * m.ambient.v[1] - fld dword[ecx+offs_mate_ambient+8] - fmul dword[ebx+offs_ligh_ambient+8] + fld dword[ecx+GLMaterial.ambient+8] + fmul dword[ebx+GLLight.ambient+8] fstp dword[lB] ;lB=l.ambient.v[2] * m.ambient.v[2] - fld dword[ebx+offs_ligh_position+offs_W] + fld dword[ebx+GLLight.position+offs_W] ftst ;if (l.position.v[3] == 0) fstsw ax sahf @@ -467,11 +447,11 @@ pushad ; light at infinity ffree st0 ;l.position.v[3] fincstp - mov eax,[ebx+offs_ligh_norm_position] + mov eax,[ebx+GLLight.norm_position] mov [d],eax ;d.X=l.norm_position.v[0] - mov eax,[ebx+offs_ligh_norm_position+offs_Y] + mov eax,[ebx+GLLight.norm_position+offs_Y] mov [d+offs_Y],eax ;d.Y=l.norm_position.v[1] - mov eax,[ebx+offs_ligh_norm_position+offs_Z] + mov eax,[ebx+GLLight.norm_position+offs_Z] mov [d+offs_Z],eax ;d.Z=l.norm_position.v[2] mov dword[att],1.0 jmp .els_0_end @@ -480,14 +460,14 @@ align 4 ; distance attenuation ffree st0 ;l.position.v[3] fincstp - fld dword[ebx+offs_ligh_position] - fsub dword[esi+offs_vert_ec] + fld dword[ebx+GLLight.position] + fsub dword[esi+GLVertex.ec] fstp dword[d] ;d.X=l.position.v[0]-v.ec.v[0] - fld dword[ebx+offs_ligh_position+offs_Y] - fsub dword[esi+offs_vert_ec+offs_Y] + fld dword[ebx+GLLight.position+offs_Y] + fsub dword[esi+GLVertex.ec+offs_Y] fstp dword[d+offs_Y] ;d.Y=l.position.v[1]-v.ec.v[1] - fld dword[ebx+offs_ligh_position+offs_Z] - fsub dword[esi+offs_vert_ec+offs_Z] + fld dword[ebx+GLLight.position+offs_Z] + fsub dword[esi+GLVertex.ec+offs_Z] fstp dword[d+offs_Z] ;d.Z=l.position.v[2]-v.ec.v[2] fld dword[d] fmul st0,st0 @@ -516,11 +496,11 @@ align 4 ffree st0 ;1.0/dist fincstp @@: - fld dword[ebx+offs_ligh_attenuation+8] + fld dword[ebx+GLLight.attenuation+8] fmul st0,st1 ;st0 = dist * l.attenuation[2] - fadd dword[ebx+offs_ligh_attenuation+4] + fadd dword[ebx+GLLight.attenuation+4] fmul st0,st1 - fadd dword[ebx+offs_ligh_attenuation] + fadd dword[ebx+GLLight.attenuation] fld1 fdiv st0,st1 fstp dword[att] ;att = 1.0f/(l.attenuation[0]+dist*(l.attenuation[1]+dist*l.attenuation[2])) @@ -550,18 +530,18 @@ align 4 sahf jbe .if0_end ; diffuse light - fld dword[ecx+offs_mate_diffuse] - fmul dword[ebx+offs_ligh_diffuse] + fld dword[ecx+GLMaterial.diffuse] + fmul dword[ebx+GLLight.diffuse] fmul st0,st1 fadd dword[lR] fstp dword[lR] ;lR+=dot * l.diffuse.v[0] * m.diffuse.v[0] - fld dword[ecx+offs_mate_diffuse+4] - fmul dword[ebx+offs_ligh_diffuse+4] + fld dword[ecx+GLMaterial.diffuse+4] + fmul dword[ebx+GLLight.diffuse+4] fmul st0,st1 fadd dword[lG] fstp dword[lG] ;lG+=dot * l.diffuse.v[1] * m.diffuse.v[1] - fld dword[ecx+offs_mate_diffuse+8] - fmul dword[ebx+offs_ligh_diffuse+8] + fld dword[ecx+GLMaterial.diffuse+8] + fmul dword[ebx+GLLight.diffuse+8] fmul st0,st1 fadd dword[lB] fstp dword[lB] ;lB+=dot * l.diffuse.v[2] * m.diffuse.v[2] @@ -569,17 +549,17 @@ align 4 fincstp ; spot light - fld dword[ebx+offs_ligh_spot_cutoff] + fld dword[ebx+GLLight.spot_cutoff] fcomp dword[an180f] ;if (l.spot_cutoff != 180) fstsw ax sahf je .if1_end - fld dword[ebx+offs_ligh_norm_spot_direction] + fld dword[ebx+GLLight.norm_spot_direction] fmul dword[d] - fld dword[ebx+offs_ligh_norm_spot_direction+offs_Y] + fld dword[ebx+GLLight.norm_spot_direction+offs_Y] fmul dword[d+offs_Y] faddp - fld dword[ebx+offs_ligh_norm_spot_direction+offs_Z] + fld dword[ebx+GLLight.norm_spot_direction+offs_Z] fmul dword[d+offs_Z] faddp fchs @@ -592,19 +572,19 @@ align 4 jae @f fchs ;dot_spot = -dot_spot @@: - fcom dword[ebx+offs_ligh_cos_spot_cutoff] ;if (dot_spot < l.cos_spot_cutoff) + fcom dword[ebx+GLLight.cos_spot_cutoff] ;if (dot_spot < l.cos_spot_cutoff) fstsw ax sahf jae .els_1 ; no contribution ffree st0 ;dot_spot fincstp - mov ebx,[ebx+offs_ligh_next] + mov ebx,[ebx+GLLight.next] jmp .cycle_0 ;continue align 4 .els_1: ; TODO: optimize - fld dword[ebx+offs_ligh_spot_exponent] + fld dword[ebx+GLLight.spot_exponent] ftst ;if (l.spot_exponent > 0) fstsw ax sahf @@ -639,14 +619,13 @@ align 4 ; specular light cmp dword[edx+GLContext.local_light_model],0 ;if (c.local_light_model) je .els_2 - mov eax,[esi+offs_vert_ec] + mov eax,[esi+GLVertex.ec] mov [vcoord],eax ;vcoord.X=v.ec.X - mov eax,[esi+offs_vert_ec+offs_Y] + mov eax,[esi+GLVertex.ec+offs_Y] mov [vcoord+offs_Y],eax ;vcoord.Y=v.ec.Y - mov eax,[esi+offs_vert_ec+offs_Z] + mov eax,[esi+GLVertex.ec+offs_Z] mov [vcoord+offs_Z],eax ;vcoord.Z=v.ec.Z - mov eax,ebp - sub eax,12 ;eax = &vcoord + lea eax,[ebp-12] ;eax = &vcoord stdcall gl_V3_Norm, eax fld dword[d] fsub dword[vcoord] @@ -709,7 +688,7 @@ align 4 ; TODO: optimize ; testing specular buffer code ; dot_spec= pow(dot_spec,m.shininess) - stdcall specbuf_get_buffer, edx, dword[ecx+offs_mate_shininess_i], dword[ecx+offs_mate_shininess] + stdcall specbuf_get_buffer, edx, dword[ecx+GLMaterial.shininess_i], dword[ecx+GLMaterial.shininess] mov edi,eax ;edi = specbuf mov dword[idx],SPECULAR_BUFFER_SIZE ;idx = SPECULAR_BUFFER_SIZE @@ -724,19 +703,19 @@ align 4 shl dword[idx],2 add edi,dword[idx] fld dword[edi+offs_spec_buf] ;dot_spec = specbuf.buf[idx] - fld dword[ebx+offs_ligh_specular] + fld dword[ebx+GLLight.specular] fmul st0,st1 - fmul dword[ecx+offs_mate_specular] + fmul dword[ecx+GLMaterial.specular] fadd dword[lR] fstp dword[lR] ;lR+=dot_spec * l.specular.v[0] * m.specular.v[0] - fld dword[ebx+offs_ligh_specular+4] + fld dword[ebx+GLLight.specular+4] fmul st0,st1 - fmul dword[ecx+offs_mate_specular+4] + fmul dword[ecx+GLMaterial.specular+4] fadd dword[lG] fstp dword[lG] ;lG+=dot_spec * l.specular.v[1] * m.specular.v[1] - fld dword[ebx+offs_ligh_specular+8] + fld dword[ebx+GLLight.specular+8] fmul st0,st1 - fmul dword[ecx+offs_mate_specular+8] + fmul dword[ecx+GLMaterial.specular+8] fadd dword[lB] fstp dword[lB] ;lB+=dot_spec * l.specular.v[2] * m.specular.v[2] .if0_end: @@ -759,19 +738,19 @@ align 4 fstp dword[B] ;B += att * lB ffree st0 ;att fincstp - mov ebx,[ebx+offs_ligh_next] + mov ebx,[ebx+GLLight.next] jmp .cycle_0 align 4 .cycle_0_end: clampf [R],0,1 - mov [esi+offs_vert_color],eax ;v.color.v[0]=clampf(R,0,1) + mov [esi+GLVertex.color],eax ;v.color.v[0]=clampf(R,0,1) clampf [G],0,1 - mov [esi+offs_vert_color+4],eax ;v.color.v[1]=clampf(G,0,1) + mov [esi+GLVertex.color+4],eax ;v.color.v[1]=clampf(G,0,1) clampf [B],0,1 - mov [esi+offs_vert_color+8],eax ;v.color.v[2]=clampf(B,0,1) + mov [esi+GLVertex.color+8],eax ;v.color.v[2]=clampf(B,0,1) mov eax,[A] - mov [esi+offs_vert_color+12],eax ;v.color.v[3]=A + mov [esi+GLVertex.color+12],eax ;v.color.v[3]=A popad ret endp diff --git a/programs/develop/libraries/TinyGL/asm_fork/list.asm b/programs/develop/libraries/TinyGL/asm_fork/list.asm index dd69424d15..7f3816b5cb 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/list.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/list.asm @@ -5,22 +5,38 @@ macro ADD_OP a,b,c db 'gl',`a,' ',c,0 } include 'opinfo.inc' +purge ADD_OP ;указатели на функции ;static void (*op_table_func[])(GLContext *,GLParam *)= +align 4 op_table_func: macro ADD_OP a,b,c { dd glop#a } include 'opinfo.inc' +purge ADD_OP ;число параметров в функциях +align 4 op_table_size: macro ADD_OP a,b,c { dd b+1 } include 'opinfo.inc' +purge ADD_OP + +;коды функций у которых нет входных параметров +align 4 +macro ADD_OP a,b,c +{ +if b eq 0 + op_#a dd OP_#a +end if +} +include 'opinfo.inc' +purge ADD_OP ;output: @@ -30,8 +46,7 @@ proc find_list uses ebx, context:dword, list:dword mov eax,[context] mov eax,[eax+GLContext.shared_state] mov ebx,[list] - shl ebx,2 - add eax,ebx + lea eax,[eax+4*ebx] mov eax,[eax] ret endp @@ -55,10 +70,9 @@ proc delete_list uses eax ebx ecx edx, context:dword, list:dword .end_w: stdcall gl_free,edx - mov ecx,[list] - shl ecx,2 mov ebx,[ebx+GLContext.shared_state] ;ebx = &context.shared_state.lists - add ebx,ecx + mov ecx,[list] + lea ebx,[ebx+4*ecx] mov dword[ebx],0 ;=NULL ret endp @@ -77,8 +91,7 @@ proc alloc_list uses ebx ecx, context:dword, list:dword mov ebx,[context] mov ebx,[ebx+GLContext.shared_state] mov ecx,[list] - shl ecx,2 - add ebx,ecx + lea ebx,[ebx+4*ecx] mov [ebx],eax ;context.shared_state.lists[list]=l ret endp @@ -116,18 +129,15 @@ proc gl_compile_op, context:dword, p:dword pushad mov edx,[context] - lea ebx,[op_table_size] mov ecx,[p] - mov ecx,[ecx] - shl ecx,2 - add ecx,ebx + mov ecx,[ecx] ;код операции + lea ecx,[op_table_size+4*ecx] mov ecx,[ecx] ;ecx = кол-во параметров в компилируемой функции mov ebx,[edx+GLContext.current_op_buffer_index] mov eax,[edx+GLContext.current_op_buffer] ; we should be able to add a NextBuffer opcode - mov esi,ebx - add esi,ecx + lea esi,[ebx+ecx] cmp esi,(OP_BUFFER_MAX_SIZE-2) jle @f mov edi,eax @@ -135,9 +145,7 @@ pushad mov dword[eax+offs_gpbu_next],0 ;=NULL mov dword[edi+offs_gpbu_next],eax - mov esi,ebx - shl esi,2 - add esi,edi + lea esi,[edi+4*ebx] mov dword[esi+offs_gpbu_ops],OP_NextBuffer mov dword[esi+offs_gpbu_ops+4],eax @@ -147,9 +155,7 @@ pushad mov esi,[p] @@: - mov edi,ebx - shl edi,2 - add edi,eax + lea edi,[eax+4*ebx] movsd inc ebx loop @b diff --git a/programs/develop/libraries/TinyGL/asm_fork/zgl.inc b/programs/develop/libraries/TinyGL/asm_fork/zgl.inc index e2a77df6de..e26b83f546 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/zgl.inc +++ b/programs/develop/libraries/TinyGL/asm_fork/zgl.inc @@ -75,21 +75,6 @@ struct GLLight prev dd ? ;struct GLLight* ends -offs_ligh_ambient equ 0 ;V4 -offs_ligh_diffuse equ 16 ;V4 -offs_ligh_specular equ 32 ;V4 -offs_ligh_position equ 48 ;V4 -offs_ligh_spot_direction equ 64 ;V3 -offs_ligh_spot_exponent equ 76 ;dd ? -offs_ligh_spot_cutoff equ 80 ;dd ? -offs_ligh_attenuation equ 84 ;rd 3 -offs_ligh_cos_spot_cutoff equ 96 ;dd ? -offs_ligh_norm_spot_direction equ 100 ;V3 -offs_ligh_norm_position equ 112 ;V3 -offs_ligh_enabled equ 124 ;dd ? -offs_ligh_next equ 128 ;dd ? -offs_ligh_prev equ 132 ;dd ? - struct GLMaterial emission V4 ambient V4 @@ -102,14 +87,6 @@ struct GLMaterial do_specular dd ? ;int ends -offs_mate_emission equ 0 ;V4 -offs_mate_ambient equ 16 ;V4 -offs_mate_diffuse equ 32 ;V4 -offs_mate_specular equ 48 ;V4 -offs_mate_shininess equ 64 ;dd -offs_mate_shininess_i equ 68 ;dd -offs_mate_do_specular equ 72 ;dd - struct GLViewport xmin dd ? ;int ymin dd ? ;int @@ -155,16 +132,6 @@ struct GLVertex zp ZBufferPoint ; integer coordinates for the rasterization ends -offs_vert_edge_flag equ 0 -offs_vert_normal equ 4 -offs_vert_coord equ 16 -offs_vert_tex_coord equ 32 -offs_vert_color equ 48 -offs_vert_ec equ 64 -offs_vert_pc equ 80 -offs_vert_clip_code equ 96 -offs_vert_zp equ 100 - struct GLImage pixmap dd ? ;void* xsize dd ? ;int