optimize, clean code

git-svn-id: svn://kolibrios.org@8063 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2020-09-16 06:59:01 +00:00
parent 185996ac6b
commit 51fcac25ee
6 changed files with 514 additions and 826 deletions

View File

@ -1,25 +1,14 @@
; glVertex ; glVertex
align 4 align 4
proc glVertex4f uses eax, x:dword, y:dword, z:dword, w:dword glVertex4f: ;x, y, z, w
locals push dword[esp] ;копируем адрес возврата
p rd 5 push eax
endl lea eax,[esp+8]
mov dword[p],OP_Vertex mov dword[eax],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
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 20 ;=sizeof(dd)*5
align 4 align 4
proc glVertex2f, x:dword, y:dword proc glVertex2f, x:dword, y:dword
@ -57,23 +46,14 @@ endp
; glNormal ; glNormal
align 4 align 4
proc glNormal3f uses eax, x:dword, y:dword, z:dword glNormal3f: ;x, y, z
locals push dword[esp] ;копируем адрес возврата
p rd 4 push eax
endl lea eax,[esp+8]
mov dword[p],OP_Normal mov dword[eax],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
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 16 ;=sizeof(dd)*4
align 4 align 4
proc glNormal3fv uses eax, v:dword proc glNormal3fv uses eax, v:dword
@ -99,8 +79,7 @@ endl
mov eax,[a] mov eax,[a]
mov dword[p+16],eax mov dword[p+16],eax
; direct convertion to integer to go faster if no shading ; direct convertion to integer to go faster if no shading
mov eax,ebp lea eax,[ebp-12] ;ebp-12 = &p[5]
sub eax,12 ;ebp-12 = &p[5]
push eax push eax
add eax,4 ;ebp-8 = &p[6] add eax,4 ;ebp-8 = &p[6]
push eax push eax
@ -108,8 +87,7 @@ endl
push eax push eax
stdcall RGBFtoRGBI,[r],[g],[b] ;call: r,g,b,&p[7],&p[6],&p[5] stdcall RGBFtoRGBI,[r],[g],[b] ;call: r,g,b,&p[7],&p[6],&p[5]
mov eax,ebp lea eax,[ebp-32] ;=sizeof(dd)*8
sub eax,32 ;=sizeof(dd)*8
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret ret
endp endp
@ -168,25 +146,14 @@ endp
; TexCoord ; TexCoord
align 4 align 4
proc glTexCoord4f uses eax, s:dword, t:dword, r:dword, q:dword glTexCoord4f: ;s, t, r, q
locals push dword[esp] ;копируем адрес возврата
p rd 5 push eax
endl lea eax,[esp+8]
mov dword[p],OP_TexCoord mov dword[eax],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
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 20 ;=sizeof(dd)*5
align 4 align 4
proc glTexCoord2f, s:dword, t:dword proc glTexCoord2f, s:dword, t:dword
@ -202,59 +169,40 @@ proc glTexCoord2fv uses eax, v:dword
endp endp
align 4 align 4
proc glEdgeFlag uses eax, flag:dword glEdgeFlag: ;flag
locals push dword[esp] ;копируем адрес возврата
p rd 2 push eax
endl lea eax,[esp+8]
mov dword[p],OP_EdgeFlag mov dword[eax],OP_EdgeFlag
mov eax,[flag]
mov dword[p+4],eax
mov eax,ebp
sub eax,8 ;=sizeof(dd)*2
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 8 ;=sizeof(dd)*2
; misc ; misc
align 4 align 4
proc glShadeModel uses eax, mode:dword glShadeModel: ;mode
locals
p rd 2
endl
; assert(mode == GL_FLAT || mode == GL_SMOOTH); ; assert(mode == GL_FLAT || mode == GL_SMOOTH);
push dword[esp] ;копируем адрес возврата
mov dword[p],OP_ShadeModel push eax
mov eax,[mode] lea eax,[esp+8]
mov dword[p+4],eax mov dword[eax],OP_ShadeModel
mov eax,ebp
sub eax,8 ;=sizeof(dd)*2
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 8 ;=sizeof(dd)*2
align 4 align 4
proc glCullFace uses eax, mode:dword glCullFace: ;mode
locals
p rd 2
endl
; assert(mode == GL_BACK || ; assert(mode == GL_BACK ||
; mode == GL_FRONT || ; mode == GL_FRONT ||
; mode == GL_FRONT_AND_BACK); ; mode == GL_FRONT_AND_BACK);
push dword[esp] ;копируем адрес возврата
mov dword[p],OP_CullFace push eax
mov eax,[mode] lea eax,[esp+8]
mov dword[p+4],eax mov dword[eax],OP_CullFace
mov eax,ebp
sub eax,8 ;=sizeof(dd)*2
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 8 ;=sizeof(dd)*2
align 4 align 4
proc glFrontFace uses eax, mode:dword proc glFrontFace uses eax, mode:dword
@ -272,34 +220,24 @@ endl
@@: @@:
mov dword[p+4],eax mov dword[p+4],eax
mov eax,ebp lea eax,[ebp-8] ;=sizeof(dd)*2
sub eax,8 ;=sizeof(dd)*2
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret ret
endp endp
align 4 align 4
proc glPolygonMode uses eax, face:dword, mode:dword glPolygonMode: ;face, mode
locals
p rd 3
endl
; assert(face == GL_BACK || ; assert(face == GL_BACK ||
; face == GL_FRONT || ; face == GL_FRONT ||
; face == GL_FRONT_AND_BACK); ; face == GL_FRONT_AND_BACK);
; assert(mode == GL_POINT || mode == GL_LINE || mode==GL_FILL); ; assert(mode == GL_POINT || mode == GL_LINE || mode==GL_FILL);
push dword[esp] ;копируем адрес возврата
mov dword[p],OP_PolygonMode push eax
mov eax,[face] lea eax,[esp+8]
mov dword[p+4],eax mov dword[eax],OP_PolygonMode
mov eax,[mode]
mov dword[p+8],eax
mov eax,ebp
sub eax,12 ;=sizeof(dd)*3
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 12 ;=sizeof(dd)*3
; glEnable / glDisable ; glEnable / glDisable
@ -313,8 +251,7 @@ endl
mov dword[p+4],eax mov dword[p+4],eax
mov dword[p+8],1 mov dword[p+8],1
mov eax,ebp lea eax,[ebp-12] ;=sizeof(dd)*3
sub eax,12 ;=sizeof(dd)*3
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret ret
endp endp
@ -329,8 +266,7 @@ endl
mov dword[p+4],eax mov dword[p+4],eax
mov dword[p+8],0 mov dword[p+8],0
mov eax,ebp lea eax,[ebp-12] ;=sizeof(dd)*3
sub eax,12 ;=sizeof(dd)*3
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret ret
endp endp
@ -338,49 +274,31 @@ endp
; glBegin / glEnd ; glBegin / glEnd
align 4 align 4
proc glBegin uses eax, mode:dword glBegin: ;mode
locals push dword[esp] ;копируем адрес возврата
p rd 2 push eax
endl lea eax,[esp+8]
mov dword[p],OP_Begin mov dword[eax],OP_Begin
mov eax,[mode]
mov dword[p+4],eax
mov eax,ebp
sub eax,8 ;=sizeof(dd)*2
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 8 ;=sizeof(dd)*2
align 4 align 4
proc glEnd uses eax glEnd:
locals stdcall gl_add_op,op_End
p dd ?
endl
mov dword[p],OP_End
mov eax,ebp
sub eax,4 ;=sizeof(dd)*1
stdcall gl_add_op,eax
ret ret
endp
; matrix ; matrix
align 4 align 4
proc glMatrixMode uses eax, mode:dword glMatrixMode: ;mode
locals push dword[esp] ;копируем адрес возврата
p rd 2 push eax
endl lea eax,[esp+8]
mov dword[p],OP_MatrixMode mov dword[eax],OP_MatrixMode
mov eax,[mode]
mov dword[p+4],eax
mov eax,ebp
sub eax,8 ;=sizeof(dd)*2
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 8 ;=sizeof(dd)*2
align 4 align 4
proc glLoadMatrixf uses ecx edi esi, m:dword proc glLoadMatrixf uses ecx edi esi, m:dword
@ -394,24 +312,15 @@ endl
sub edi,64 ;=sizeof(M4) sub edi,64 ;=sizeof(M4)
rep movsd rep movsd
mov ecx,ebp lea ecx,[ebp-68] ;=sizeof(dd)*17
sub ecx,68 ;=sizeof(dd)*17
stdcall gl_add_op,ecx stdcall gl_add_op,ecx
ret ret
endp endp
align 4 align 4
proc glLoadIdentity uses eax glLoadIdentity:
locals stdcall gl_add_op,op_LoadIdentity
p dd ?
endl
mov dword[p],OP_LoadIdentity
mov eax,ebp
sub eax,4 ;=sizeof(dd)*1
stdcall gl_add_op,eax
ret ret
endp
align 4 align 4
proc glMultMatrixf uses ecx edi esi, m:dword proc glMultMatrixf uses ecx edi esi, m:dword
@ -425,117 +334,60 @@ endl
sub edi,64 ;=sizeof(M4) sub edi,64 ;=sizeof(M4)
rep movsd rep movsd
mov ecx,ebp lea ecx,[ebp-68] ;=sizeof(dd)*17
sub ecx,68 ;=sizeof(dd)*17
stdcall gl_add_op,ecx stdcall gl_add_op,ecx
ret ret
endp endp
align 4 align 4
proc glPushMatrix uses eax glPushMatrix:
locals stdcall gl_add_op,op_PushMatrix
p dd ?
endl
mov dword[p],OP_PushMatrix
mov eax,ebp
sub eax,4 ;=sizeof(dd)*1
stdcall gl_add_op,eax
ret ret
endp
align 4 align 4
proc glPopMatrix uses eax glPopMatrix:
locals stdcall gl_add_op,op_PopMatrix
p dd ?
endl
mov dword[p],OP_PopMatrix
mov eax,ebp
sub eax,4 ;=sizeof(dd)*1
stdcall gl_add_op,eax
ret ret
endp
align 4 align 4
proc glRotatef uses eax, angle:dword, x:dword, y:dword, z:dword glRotatef: ;angle, x, y, z
locals push dword[esp] ;копируем адрес возврата
p rd 5 push eax
endl lea eax,[esp+8]
mov dword[p],OP_Rotate mov dword[eax],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
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 20 ;=sizeof(dd)*5
align 4 align 4
proc glTranslatef uses eax, x:dword, y:dword, z:dword glTranslatef: ;x, y, z
locals push dword[esp] ;копируем адрес возврата
p rd 4 push eax
endl lea eax,[esp+8]
mov dword[p],OP_Translate mov dword[eax],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
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 16 ;=sizeof(dd)*4
align 4 align 4
proc glScalef uses eax, x:dword, y:dword, z:dword glScalef: ;x, y, z
locals push dword[esp] ;копируем адрес возврата
p rd 4 push eax
endl lea eax,[esp+8]
mov dword[p],OP_Scale mov dword[eax],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
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 16 ;=sizeof(dd)*4
align 4 align 4
proc glViewport uses eax, x:dword, y:dword, width:dword, heigh:dword glViewport: ;x, y, width, heigh
locals push dword[esp] ;копируем адрес возврата
p rd 5 push eax
endl lea eax,[esp+8]
mov dword[p],OP_Viewport mov dword[eax],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
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 20 ;=sizeof(dd)*5
align 4 align 4
proc glFrustum uses eax, left:qword, right:qword, bottom:qword, top:qword,\ proc glFrustum uses eax, left:qword, right:qword, bottom:qword, top:qword,\
@ -557,8 +409,7 @@ endl
fld qword[farv] fld qword[farv]
fstp dword[p+24] fstp dword[p+24]
mov eax,ebp lea eax,[ebp-28] ;=sizeof(dd)*7
sub eax,28 ;=sizeof(dd)*7
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret ret
endp endp
@ -621,8 +472,7 @@ endl
mov dword[p+24],0.0 mov dword[p+24],0.0
@@: @@:
mov eax,ebp lea eax,[ebp-28] ;=sizeof(dd)*7
sub eax,28 ;=sizeof(dd)*7
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret ret
endp endp
@ -643,28 +493,20 @@ endl
mov dword[p+20],0.0 mov dword[p+20],0.0
mov dword[p+24],0.0 mov dword[p+24],0.0
mov eax,ebp lea eax,[ebp-28] ;=sizeof(dd)*7
sub eax,28 ;=sizeof(dd)*7
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret ret
endp endp
align 4 align 4
proc glColorMaterial uses eax, mode:dword, type:dword glColorMaterial: ;mode, type
locals push dword[esp] ;копируем адрес возврата
p rd 3 push eax
endl lea eax,[esp+8]
mov dword[p],OP_ColorMaterial mov dword[eax],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
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 12 ;=sizeof(dd)*3
align 4 align 4
proc glLightfv uses eax ecx, light:dword, type:dword, v:dword proc glLightfv uses eax ecx, light:dword, type:dword, v:dword
@ -688,8 +530,7 @@ endl
mov ecx,[eax+12] mov ecx,[eax+12]
mov dword[p+24],ecx mov dword[p+24],ecx
mov eax,ebp lea eax,[ebp-28] ;=sizeof(dd)*7
sub eax,28 ;=sizeof(dd)*7
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret ret
endp endp
@ -710,8 +551,7 @@ endl
mov dword[p+20],0.0 mov dword[p+20],0.0
mov dword[p+24],0.0 mov dword[p+24],0.0
mov eax,ebp lea eax,[ebp-28] ;=sizeof(dd)*7
sub eax,28 ;=sizeof(dd)*7
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret ret
endp endp
@ -731,8 +571,7 @@ endl
mov dword[p+16],0.0 mov dword[p+16],0.0
mov dword[p+20],0.0 mov dword[p+20],0.0
mov eax,ebp lea eax,[ebp-24] ;=sizeof(dd)*6
sub eax,24 ;=sizeof(dd)*6
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret ret
endp endp
@ -755,8 +594,7 @@ endl
mov ecx,[eax+12] mov ecx,[eax+12]
mov dword[p+20],ecx mov dword[p+20],ecx
mov eax,ebp lea eax,[ebp-24] ;=sizeof(dd)*6
sub eax,24 ;=sizeof(dd)*6
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret ret
endp endp
@ -764,19 +602,14 @@ endp
; clear ; clear
align 4 align 4
proc glClear uses eax, mask:dword glClear: ;mask
locals push dword[esp] ;копируем адрес возврата
p rd 2 push eax
endl lea eax,[esp+8]
mov dword[p],OP_Clear mov dword[eax],OP_Clear
mov eax,[mask]
mov dword[p+4],eax
mov eax,ebp
sub eax,8 ;=sizeof(dd)*2
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 8 ;=sizeof(dd)*2
align 4 align 4
proc glClearColor uses eax, r:dword, g:dword, b:dword, a:dword proc glClearColor uses eax, r:dword, g:dword, b:dword, a:dword
@ -793,8 +626,7 @@ endl
mov eax,[a] mov eax,[a]
mov dword[p+16],eax mov dword[p+16],eax
mov eax,ebp lea eax,[ebp-20] ;=sizeof(dd)*5
sub eax,20 ;=sizeof(dd)*5
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret ret
endp endp
@ -809,8 +641,7 @@ endl
fld qword[eax] fld qword[eax]
fstp dword[p+4] fstp dword[p+4]
mov eax,ebp lea eax,[ebp-8] ;=sizeof(dd)*2
sub eax,8 ;=sizeof(dd)*2
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret ret
endp endp
@ -818,43 +649,24 @@ endp
; textures ; textures
align 4 align 4
proc glTexImage2D uses ecx edi esi,\ glTexImage2D: ;target, level, components, width, height, border, format, type, pixels
target:dword, level:dword, components:dword,\ push dword[esp] ;копируем адрес возврата
width:dword, height:dword, border:dword,\ push eax
format:dword, type:dword, pixels:dword lea eax,[esp+8]
locals mov dword[eax],OP_TexImage2D
p rd 10 stdcall gl_add_op,eax
endl pop eax
mov dword[p],OP_TexImage2D ret 40 ;=sizeof(dd)*10
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
align 4 align 4
proc glBindTexture uses eax, target:dword, texture:dword glBindTexture: ;target, texture
locals push dword[esp] ;копируем адрес возврата
p rd 3 push eax
endl lea eax,[esp+8]
mov dword[p],OP_BindTexture mov dword[eax],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
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 12 ;=sizeof(dd)*3
align 4 align 4
proc glTexEnvi uses eax, target:dword, pname:dword, param:dword proc glTexEnvi uses eax, target:dword, pname:dword, param:dword
@ -873,8 +685,7 @@ endl
mov dword[p+24],0.0 mov dword[p+24],0.0
mov dword[p+28],0.0 mov dword[p+28],0.0
mov eax,ebp lea eax,[ebp-32] ;=sizeof(dd)*8
sub eax,32 ;=sizeof(dd)*8
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret ret
endp endp
@ -896,120 +707,74 @@ endl
mov dword[p+24],0.0 mov dword[p+24],0.0
mov dword[p+28],0.0 mov dword[p+28],0.0
mov eax,ebp lea eax,[ebp-32] ;=sizeof(dd)*8
sub eax,32 ;=sizeof(dd)*8
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret ret
endp endp
align 4 align 4
proc glPixelStorei uses eax, pname:dword, param:dword glPixelStorei: ;pname, param
locals push dword[esp] ;копируем адрес возврата
p rd 3 push eax
endl lea eax,[esp+8]
mov dword[p],OP_PixelStore mov dword[eax],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
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 12 ;=sizeof(dd)*3
; selection ; selection
align 4 align 4
proc glInitNames uses eax glInitNames:
locals stdcall gl_add_op,op_InitNames
p dd ?
endl
mov dword[p],OP_InitNames
mov eax,ebp
sub eax,4 ;=sizeof(dd)*1
stdcall gl_add_op,eax
ret ret
endp
align 4 align 4
proc glPushName uses eax, name:dword glPushName: ;name
locals push dword[esp] ;копируем адрес возврата
p rd 2 push eax
endl lea eax,[esp+8]
mov dword[p],OP_PushName mov dword[eax],OP_PushName
mov eax,[name]
mov dword[p+4],eax
mov eax,ebp
sub eax,8 ;=sizeof(dd)*2
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 8 ;=sizeof(dd)*2
align 4 align 4
proc glPopName uses eax glPopName:
locals stdcall gl_add_op,op_PopName
p dd ?
endl
mov dword[p],OP_PopName
mov eax,ebp
sub eax,4 ;=sizeof(dd)*1
stdcall gl_add_op,eax
ret ret
endp
align 4 align 4
proc glLoadName uses eax, name:dword glLoadName: ;name
locals push dword[esp] ;копируем адрес возврата
p rd 2 push eax
endl lea eax,[esp+8]
mov dword[p],OP_LoadName mov dword[eax],OP_LoadName
mov eax,[name]
mov dword[p+4],eax
mov eax,ebp
sub eax,8 ;=sizeof(dd)*2
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 8 ;=sizeof(dd)*2
align 4 align 4
proc glPolygonOffset uses eax, factor:dword, units:dword glPolygonOffset: ;factor, units
locals push dword[esp] ;копируем адрес возврата
p rd 3 push eax
endl lea eax,[esp+8]
mov dword[p],OP_PolygonOffset mov dword[eax],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
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 12 ;=sizeof(dd)*3
; Special Functions ; Special Functions
align 4 align 4
proc glCallList uses eax, list:dword glCallList: ;list
locals push dword[esp] ;копируем адрес возврата
p rd 2 push eax
endl lea eax,[esp+8]
mov dword[p],OP_CallList mov dword[eax],OP_CallList
mov eax,[list]
mov dword[p+4],eax
mov eax,ebp
sub eax,8 ;=sizeof(dd)*2
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 8 ;=sizeof(dd)*2
align 4 align 4
proc glFlush ;(void) proc glFlush ;(void)
@ -1018,21 +783,14 @@ proc glFlush ;(void)
endp endp
align 4 align 4
proc glHint uses eax, target:dword, mode:dword glHint: ;target, mode
locals push dword[esp] ;копируем адрес возврата
p rd 3 push eax
endl lea eax,[esp+8]
mov dword[p],OP_Hint mov dword[eax],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
stdcall gl_add_op,eax stdcall gl_add_op,eax
ret pop eax
endp ret 12 ;=sizeof(dd)*3
; Non standard functions ; Non standard functions

View File

@ -15,47 +15,46 @@ proc gl_transform_to_viewport uses eax ebx ecx, context:dword,v:dword
; coordinates ; coordinates
fld1 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 st0,st1
fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_X] fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_X]
fadd dword[eax+GLContext.viewport+offs_vpor_trans+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 st0,st1
fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_Y] fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_Y]
fadd dword[eax+GLContext.viewport+offs_vpor_trans+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 fmulp
fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_Z] fmul dword[eax+GLContext.viewport+offs_vpor_scale+offs_Z]
fadd dword[eax+GLContext.viewport+offs_vpor_trans+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 ; color
cmp dword[eax+GLContext.lighting_enabled],0 ;if (context.lighting_enabled) cmp dword[eax+GLContext.lighting_enabled],0 ;if (context.lighting_enabled)
je @f je @f
mov ecx,ebx lea ecx,[ebx+GLVertex.zp+offs_zbup_b]
add ecx,offs_vert_zp+offs_zbup_b
push ecx push ecx
add ecx,offs_zbup_g-offs_zbup_b add ecx,offs_zbup_g-offs_zbup_b
push ecx push ecx
add ecx,offs_zbup_r-offs_zbup_g add ecx,offs_zbup_r-offs_zbup_g
push ecx 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 jmp .end_if
align 4 align 4
@@: @@:
; no need to convert to integer if no lighting : take current color ; no need to convert to integer if no lighting : take current color
mov ecx,[eax+GLContext.longcurrent_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 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 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: .end_if:
; texture ; texture
@ -66,13 +65,13 @@ align 4
;[eax+offs_text_images] = im = &context.current_texture.images[0] ;[eax+offs_text_images] = im = &context.current_texture.images[0]
fild dword[eax+offs_text_images+offs_imag_s_bound] fild dword[eax+offs_text_images+offs_imag_s_bound]
fmul dword[ebx+offs_vert_tex_coord+offs_X] fmul dword[ebx+GLVertex.tex_coord+offs_X]
fistp dword[ebx+offs_vert_zp+offs_zbup_s] fistp dword[ebx+GLVertex.zp+offs_zbup_s]
;v.zp.s=(int)(v.tex_coord.X * im.s_bound) ;v.zp.s=(int)(v.tex_coord.X * im.s_bound)
fild dword[eax+offs_text_images+offs_imag_t_bound] fild dword[eax+offs_text_images+offs_imag_t_bound]
fmul dword[ebx+offs_vert_tex_coord+offs_Y] fmul dword[ebx+GLVertex.tex_coord+offs_Y]
fistp dword[ebx+offs_vert_zp+offs_zbup_t] fistp dword[ebx+GLVertex.zp+offs_zbup_t]
;v.zp.t=(int)(v.tex_coord.Y * im.t_bound) ;v.zp.t=(int)(v.tex_coord.Y * im.t_bound)
@@: @@:
ret ret
@ -113,16 +112,16 @@ endp
align 16 align 16
proc gl_draw_point uses eax ebx, context:dword, p0:dword proc gl_draw_point uses eax ebx, context:dword, p0:dword
mov ebx,[p0] 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 jne @f
mov eax,[context] mov eax,[context]
cmp dword[eax+GLContext.render_mode],GL_SELECT cmp dword[eax+GLContext.render_mode],GL_SELECT
jne .els 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 jmp @f
align 4 align 4
.els: .els:
add ebx,offs_vert_zp add ebx,GLVertex.zp
stdcall ZB_plot, dword[eax+GLContext.zb],ebx stdcall ZB_plot, dword[eax+GLContext.zb],ebx
@@: @@:
ret ret
@ -140,48 +139,48 @@ macro interpolate q, p0, p1, t
fld dword[t] fld dword[t]
; интерполяция по координатам ; интерполяция по координатам
fld dword[p1+offs_vert_pc] fld dword[p1+GLVertex.pc]
fsub dword[p0+offs_vert_pc] fsub dword[p0+GLVertex.pc]
fmul st0,st1 fmul st0,st1
fadd dword[p0+offs_vert_pc] fadd dword[p0+GLVertex.pc]
fstp dword[q+offs_vert_pc] ;q.pc.X = p0.pc.X + (p1.pc.X - p0.pc.X) * t 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] fld dword[p1+GLVertex.pc+offs_Y]
fsub dword[p0+offs_vert_pc+offs_Y] fsub dword[p0+GLVertex.pc+offs_Y]
fmul st0,st1 fmul st0,st1
fadd dword[p0+offs_vert_pc+offs_Y] fadd dword[p0+GLVertex.pc+offs_Y]
fstp dword[q+offs_vert_pc+offs_Y] fstp dword[q+GLVertex.pc+offs_Y]
fld dword[p1+offs_vert_pc+offs_Z] fld dword[p1+GLVertex.pc+offs_Z]
fsub dword[p0+offs_vert_pc+offs_Z] fsub dword[p0+GLVertex.pc+offs_Z]
fmul st0,st1 fmul st0,st1
fadd dword[p0+offs_vert_pc+offs_Z] fadd dword[p0+GLVertex.pc+offs_Z]
fstp dword[q+offs_vert_pc+offs_Z] fstp dword[q+GLVertex.pc+offs_Z]
fld dword[p1+offs_vert_pc+offs_W] fld dword[p1+GLVertex.pc+offs_W]
fsub dword[p0+offs_vert_pc+offs_W] fsub dword[p0+GLVertex.pc+offs_W]
fmul st0,st1 fmul st0,st1
fadd dword[p0+offs_vert_pc+offs_W] fadd dword[p0+GLVertex.pc+offs_W]
fstp dword[q+offs_vert_pc+offs_W] fstp dword[q+GLVertex.pc+offs_W]
; интерполяция по цвету ; интерполяция по цвету
fld dword[p1+offs_vert_color] fld dword[p1+GLVertex.color]
fsub dword[p0+offs_vert_color] fsub dword[p0+GLVertex.color]
fmul st0,st1 fmul st0,st1
fadd dword[p0+offs_vert_color] fadd dword[p0+GLVertex.color]
fstp dword[q+offs_vert_color] fstp dword[q+GLVertex.color]
fld dword[p1+offs_vert_color+4] fld dword[p1+GLVertex.color+4]
fsub dword[p0+offs_vert_color+4] fsub dword[p0+GLVertex.color+4]
fmul st0,st1 fmul st0,st1
fadd dword[p0+offs_vert_color+4] fadd dword[p0+GLVertex.color+4]
fstp dword[q+offs_vert_color+4] fstp dword[q+GLVertex.color+4]
fld dword[p1+offs_vert_color+8] fld dword[p1+GLVertex.color+8]
fsub dword[p0+offs_vert_color+8] fsub dword[p0+GLVertex.color+8]
fmulp fmulp
fadd dword[p0+offs_vert_color+8] fadd dword[p0+GLVertex.color+8]
fstp dword[q+offs_vert_color+8] fstp dword[q+GLVertex.color+8]
} }
; ;
@ -280,20 +279,20 @@ pushad
mov edi,[p1] mov edi,[p1]
mov esi,[p2] mov esi,[p2]
cmp dword[edi+offs_vert_clip_code],0 cmp dword[edi+GLVertex.clip_code],0
jne .els_i jne .els_i
cmp dword[esi+offs_vert_clip_code],0 cmp dword[esi+GLVertex.clip_code],0
jne .els_i jne .els_i
;if ( (p1.clip_code | p2.clip_code) == 0) ;if ( (p1.clip_code | p2.clip_code) == 0)
cmp dword[edx+GLContext.render_mode],GL_SELECT ;if (context.render_mode == GL_SELECT) cmp dword[edx+GLContext.render_mode],GL_SELECT ;if (context.render_mode == GL_SELECT)
jne .els_1 jne .els_1
stdcall gl_add_select1, edx,dword[edi+offs_vert_zp+offs_zbup_z],\ stdcall gl_add_select1, edx,dword[edi+GLVertex.zp+offs_zbup_z],\
dword[esi+offs_vert_zp+offs_zbup_z],dword[esi+offs_vert_zp+offs_zbup_z] dword[esi+GLVertex.zp+offs_zbup_z],dword[esi+GLVertex.zp+offs_zbup_z]
jmp .end_f jmp .end_f
align 4 align 4
.els_1: .els_1:
add edi,offs_vert_zp add edi,GLVertex.zp
add esi,offs_vert_zp add esi,GLVertex.zp
push esi push esi
push edi push edi
push dword[edx+GLContext.zb] push dword[edx+GLContext.zb]
@ -309,39 +308,38 @@ align 4
align 4 align 4
.els_i: .els_i:
;else if ( (p1.clip_code & p2.clip_code) != 0 ) ;else if ( (p1.clip_code & p2.clip_code) != 0 )
mov eax,[edi+offs_vert_clip_code] mov eax,[edi+GLVertex.clip_code]
and eax,[esi+offs_vert_clip_code] and eax,[esi+GLVertex.clip_code]
or eax,eax or eax,eax
jnz .end_f jnz .end_f
.els_0: .els_0:
fld dword[esi+offs_vert_pc+offs_X] fld dword[esi+GLVertex.pc+offs_X]
fsub dword[edi+offs_vert_pc+offs_X] fsub dword[edi+GLVertex.pc+offs_X]
fstp dword[d_x] ;d_x = p2.pc.X - p1.pc.X fstp dword[d_x] ;d_x = p2.pc.X - p1.pc.X
fld dword[esi+offs_vert_pc+offs_Y] fld dword[esi+GLVertex.pc+offs_Y]
fsub dword[edi+offs_vert_pc+offs_Y] fsub dword[edi+GLVertex.pc+offs_Y]
fstp dword[d_y] ;d_y = p2.pc.Y - p1.pc.Y fstp dword[d_y] ;d_y = p2.pc.Y - p1.pc.Y
fld dword[esi+offs_vert_pc+offs_Z] fld dword[esi+GLVertex.pc+offs_Z]
fsub dword[edi+offs_vert_pc+offs_Z] fsub dword[edi+GLVertex.pc+offs_Z]
fstp dword[d_z] ;d_z = p2.pc.Z - p1.pc.Z fstp dword[d_z] ;d_z = p2.pc.Z - p1.pc.Z
fld dword[esi+offs_vert_pc+offs_W] fld dword[esi+GLVertex.pc+offs_W]
fsub dword[edi+offs_vert_pc+offs_W] fsub dword[edi+GLVertex.pc+offs_W]
fstp dword[d_w] ;d_w = p2.pc.W - p1.pc.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 [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 [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 [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 [w1],eax ;w1 = p1.pc.W
mov dword[tmin],0.0 mov dword[tmin],0.0
mov dword[tmax],1.0 mov dword[tmax],1.0
mov eax,ebp lea eax,[ebp-4]
sub eax,4
push eax ;толкаем в стек адрес &tmax push eax ;толкаем в стек адрес &tmax
sub eax,4 sub eax,4
push eax ;толкаем в стек адрес &tmin push eax ;толкаем в стек адрес &tmin
@ -419,8 +417,7 @@ align 4
bt eax,0 bt eax,0
jnc .end_f jnc .end_f
mov eax,ebp lea eax,[ebp-8-2*sizeof.GLVertex] ;eax = &q1
sub eax,8+2*sizeof.GLVertex ;eax = &q1
interpolate eax,edi,esi,tmin interpolate eax,edi,esi,tmin
stdcall gl_transform_to_viewport, edx,eax stdcall gl_transform_to_viewport, edx,eax
add eax,sizeof.GLVertex ;eax = &q2 add eax,sizeof.GLVertex ;eax = &q2
@ -428,26 +425,24 @@ align 4
stdcall gl_transform_to_viewport, edx,eax stdcall gl_transform_to_viewport, edx,eax
sub eax,sizeof.GLVertex ;eax = &q1 sub eax,sizeof.GLVertex ;eax = &q1
mov ebx,eax lea ebx,[eax+GLVertex.zp+offs_zbup_b]
add ebx,offs_vert_zp+offs_zbup_b
push ebx push ebx
add ebx,offs_zbup_g-offs_zbup_b add ebx,offs_zbup_g-offs_zbup_b
push ebx push ebx
add ebx,offs_zbup_r-offs_zbup_g add ebx,offs_zbup_r-offs_zbup_g
push ebx 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 add eax,sizeof.GLVertex ;eax = &q2
mov ebx,eax lea ebx,[eax+GLVertex.zp+offs_zbup_b]
add ebx,offs_vert_zp+offs_zbup_b
push ebx push ebx
add ebx,offs_zbup_g-offs_zbup_b add ebx,offs_zbup_g-offs_zbup_b
push ebx push ebx
add ebx,offs_zbup_r-offs_zbup_g add ebx,offs_zbup_r-offs_zbup_g
push ebx 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 push eax
sub eax,sizeof.GLVertex ;eax = &q1.zp sub eax,sizeof.GLVertex ;eax = &q1.zp
push eax 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) cmp dword[edx+GLContext.current_shade_model],GL_SMOOTH ;if (context.current_shade_model == GL_SMOOTH)
jne .els_0 jne .els_0
mov ecx,[p1] mov ecx,[p1]
fld dword[ecx+offs_vert_color] fld dword[ecx+GLVertex.color]
fsub dword[eax+offs_vert_color] fsub dword[eax+GLVertex.color]
fmul dword[t] fmul dword[t]
fadd dword[eax+offs_vert_color] fadd dword[eax+GLVertex.color]
fstp dword[edi+offs_vert_color] ;q.color.v[0]=p0.color.v[0] + (p1.color.v[0]-p0.color.v[0])*t 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+offs_vert_color+4] fld dword[ecx+GLVertex.color+4]
fsub dword[eax+offs_vert_color+4] fsub dword[eax+GLVertex.color+4]
fmul dword[t] fmul dword[t]
fadd dword[eax+offs_vert_color+4] fadd dword[eax+GLVertex.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 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+offs_vert_color+8] fld dword[ecx+GLVertex.color+8]
fsub dword[eax+offs_vert_color+8] fsub dword[eax+GLVertex.color+8]
fmul dword[t] fmul dword[t]
fadd dword[eax+offs_vert_color+8] fadd dword[eax+GLVertex.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 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 jmp @f
align 4 align 4
.els_0: .els_0:
mov ecx,[eax+offs_vert_color] mov ecx,[eax+GLVertex.color]
mov [edi+offs_vert_color],ecx ;q.color.v[0]=p0.color.v[0] mov [edi+GLVertex.color],ecx ;q.color.v[0]=p0.color.v[0]
mov ecx,[eax+offs_vert_color+4] mov ecx,[eax+GLVertex.color+4]
mov [edi+offs_vert_color+4],ecx ;q.color.v[1]=p0.color.v[1] mov [edi+GLVertex.color+4],ecx ;q.color.v[1]=p0.color.v[1]
mov ecx,[eax+offs_vert_color+8] mov ecx,[eax+GLVertex.color+8]
mov [edi+offs_vert_color+8],ecx ;q.color.v[2]=p0.color.v[2] 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) cmp dword[edx+GLContext.texture_2d_enabled],0 ;if (context.texture_2d_enabled)
je @f je @f
mov ecx,[p1] mov ecx,[p1]
fld dword[ecx+offs_vert_tex_coord+offs_X] fld dword[ecx+GLVertex.tex_coord+offs_X]
fsub dword[eax+offs_vert_tex_coord+offs_X] fsub dword[eax+GLVertex.tex_coord+offs_X]
fmul dword[t] fmul dword[t]
fadd dword[eax+offs_vert_tex_coord+offs_X] fadd dword[eax+GLVertex.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 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+offs_vert_tex_coord+offs_Y] fld dword[ecx+GLVertex.tex_coord+offs_Y]
fsub dword[eax+offs_vert_tex_coord+offs_Y] fsub dword[eax+GLVertex.tex_coord+offs_Y]
fmul dword[t] fmul dword[t]
fadd dword[eax+offs_vert_tex_coord+offs_Y] fadd dword[eax+GLVertex.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 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],\ stdcall gl_clipcode, [edi+GLVertex.pc+offs_X],[edi+GLVertex.pc+offs_Y],\
[edi+offs_vert_pc+offs_Z],[edi+offs_vert_pc+offs_W] [edi+GLVertex.pc+offs_Z],[edi+GLVertex.pc+offs_W]
mov dword[edi+offs_vert_clip_code],eax mov dword[edi+GLVertex.clip_code],eax
or eax,eax ;if (q.clip_code==0) or eax,eax ;if (q.clip_code==0)
jnz @f jnz @f
stdcall gl_transform_to_viewport,[context],edi stdcall gl_transform_to_viewport,[context],edi
mov eax,edi lea eax,[edi+GLVertex.zp+offs_zbup_b]
add eax,offs_vert_zp+offs_zbup_b
push eax push eax
add eax,offs_zbup_g-offs_zbup_b add eax,offs_zbup_g-offs_zbup_b
push eax push eax
add eax,offs_zbup_r-offs_zbup_g add eax,offs_zbup_r-offs_zbup_g
push eax 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 ret
endp endp
@ -665,12 +659,12 @@ pushad
mov ebx,[p0] mov ebx,[p0]
mov ecx,[p1] mov ecx,[p1]
mov edx,[p2] mov edx,[p2]
mov edi,[ebx+offs_vert_clip_code] mov edi,[ebx+GLVertex.clip_code]
mov dword[cc],edi mov dword[cc],edi
mov eax,[ecx+offs_vert_clip_code] mov eax,[ecx+GLVertex.clip_code]
mov dword[cc+4],eax mov dword[cc+4],eax
or edi,eax or edi,eax
mov eax,[edx+offs_vert_clip_code] mov eax,[edx+GLVertex.clip_code]
mov dword[cc+8],eax mov dword[cc+8],eax
or edi,eax ;co = cc[0] | cc[1] | cc[2] or edi,eax ;co = cc[0] | cc[1] | cc[2]
@ -678,21 +672,21 @@ pushad
;or edi,___ - было выше ;or edi,___ - было выше
jnz .els_0 jnz .els_0
;if (co==0) ;if (co==0)
mov edi,dword[edx+offs_vert_zp+offs_zbup_x] mov edi,dword[edx+GLVertex.zp+offs_zbup_x]
sub edi,dword[ebx+offs_vert_zp+offs_zbup_x] sub edi,dword[ebx+GLVertex.zp+offs_zbup_x]
mov dword[norm],edi ;p2.x-p0.x mov dword[norm],edi ;p2.x-p0.x
fild dword[norm] fild dword[norm]
mov edi,dword[ecx+offs_vert_zp+offs_zbup_y] mov edi,dword[ecx+GLVertex.zp+offs_zbup_y]
sub edi,dword[ebx+offs_vert_zp+offs_zbup_y] sub edi,dword[ebx+GLVertex.zp+offs_zbup_y]
mov dword[norm],edi ;p1.y-p0.y mov dword[norm],edi ;p1.y-p0.y
fimul dword[norm] fimul dword[norm]
fchs fchs
mov edi,dword[ecx+offs_vert_zp+offs_zbup_x] mov edi,dword[ecx+GLVertex.zp+offs_zbup_x]
sub edi,dword[ebx+offs_vert_zp+offs_zbup_x] sub edi,dword[ebx+GLVertex.zp+offs_zbup_x]
mov dword[norm],edi ;p1.x-p0.x mov dword[norm],edi ;p1.x-p0.x
fild dword[norm] fild dword[norm]
mov edi,dword[edx+offs_vert_zp+offs_zbup_y] mov edi,dword[edx+GLVertex.zp+offs_zbup_y]
sub edi,dword[ebx+offs_vert_zp+offs_zbup_y] sub edi,dword[ebx+GLVertex.zp+offs_zbup_y]
mov dword[norm],edi ;p2.y-p0.y mov dword[norm],edi ;p2.y-p0.y
fimul dword[norm] fimul dword[norm]
faddp faddp
@ -770,12 +764,12 @@ pushad
mov ecx,[p1] mov ecx,[p1]
mov edx,[p2] mov edx,[p2]
mov edi,[ebx+offs_vert_clip_code] mov edi,[ebx+GLVertex.clip_code]
mov [cc],edi mov [cc],edi
mov eax,[ecx+offs_vert_clip_code] mov eax,[ecx+GLVertex.clip_code]
mov [cc+4],eax mov [cc+4],eax
or edi,eax or edi,eax
mov eax,[edx+offs_vert_clip_code] mov eax,[edx+GLVertex.clip_code]
mov [cc+8],eax mov [cc+8],eax
or edi,eax or edi,eax
mov [co],edi ;co = cc[0] | cc[1] | cc[2] mov [co],edi ;co = cc[0] | cc[1] | cc[2]
@ -869,54 +863,49 @@ align 4
.els_2_end: .els_2_end:
mov ebx,[q] mov ebx,[q]
add ebx,offs_vert_pc add ebx,GLVertex.pc
mov ecx,[q+4] mov ecx,[q+4]
add ecx,offs_vert_pc add ecx,GLVertex.pc
mov edx,[q+8] mov edx,[q+8]
add edx,offs_vert_pc add edx,GLVertex.pc
lea eax,[clip_proc] lea eax,[clip_proc]
mov edi,[clip_bit] mov edi,[clip_bit]
shl edi,2 lea eax,[eax+4*edi]
add eax,edi lea edi,[ebp-(2*sizeof.GLVertex)+GLVertex.pc]
mov edi,ebp
sub edi,(2*sizeof.GLVertex)-offs_vert_pc
stdcall dword[eax],edi,ebx,ecx ;clip_proc[clip_bit](&tmp1.pc,&q[0].pc,&q[1].pc) 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 ebx,GLVertex.pc
sub ecx,offs_vert_pc sub ecx,GLVertex.pc
stdcall updateTmp,[context],ebx,ecx,eax ;(c,&tmp1,q[0],q[1],tt) 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] lea eax,[clip_proc]
mov edi,[clip_bit] mov edi,[clip_bit]
shl edi,2 lea eax,[eax+4*edi]
add eax,edi lea edi,[ebp-sizeof.GLVertex+GLVertex.pc]
mov edi,ebp
sub edi,sizeof.GLVertex-offs_vert_pc
stdcall dword[eax],edi,ebx,edx ;clip_proc[clip_bit](&tmp2.pc,&q[0].pc,&q[2].pc) 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
sub ebx,offs_vert_pc sub ebx,GLVertex.pc
sub edx,offs_vert_pc sub edx,GLVertex.pc
stdcall updateTmp,[context],ebx,edx,eax ;(c,&tmp2,q[0],q[2],tt) 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 [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 [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] mov eax,[clip_bit]
inc eax inc eax
push eax ;для вызова нижней функции push eax ;для вызова нижней функции
mov edi,ebp lea edi,[ebp-2*sizeof.GLVertex]
sub edi,2*sizeof.GLVertex
stdcall gl_draw_triangle_clip,[context],edi,ecx,edx,eax ;gl_draw_triangle_clip(c,&tmp1,q[1],q[2],clip_bit+1) 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[tmp2.edge_flag],0
mov dword[tmp1.edge_flag],0 mov dword[tmp1.edge_flag],0
mov eax,[edge_flag_tmp] 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 edx
push edi push edi
add edi,sizeof.GLVertex ;edi = &tmp2 add edi,sizeof.GLVertex ;edi = &tmp2
@ -954,34 +943,30 @@ align 4
.els_4_end: .els_4_end:
mov ebx,[q] mov ebx,[q]
add ebx,offs_vert_pc add ebx,GLVertex.pc
mov ecx,[q+4] mov ecx,[q+4]
add ecx,offs_vert_pc add ecx,GLVertex.pc
mov edx,[q+8] mov edx,[q+8]
add edx,offs_vert_pc add edx,GLVertex.pc
lea eax,[clip_proc] lea eax,[clip_proc]
mov edi,[clip_bit] mov edi,[clip_bit]
shl edi,2 lea eax,[eax+4*edi]
add eax,edi lea edi,[ebp-(2*sizeof.GLVertex)+GLVertex.pc]
mov edi,ebp
sub edi,(2*sizeof.GLVertex)-offs_vert_pc
stdcall dword[eax],edi,ebx,ecx ;clip_proc[clip_bit](&tmp1.pc,&q[0].pc,&q[1].pc) 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 stdcall updateTmp,[context],[q],[q+4],eax
lea eax,[clip_proc] lea eax,[clip_proc]
mov edi,[clip_bit] mov edi,[clip_bit]
shl edi,2 lea eax,[eax+4*edi]
add eax,edi lea edi,[ebp-sizeof.GLVertex+GLVertex.pc]
mov edi,ebp
sub edi,sizeof.GLVertex-offs_vert_pc
stdcall dword[eax],edi,ebx,edx ;clip_proc[clip_bit](&tmp2.pc,&q[0].pc,&q[2].pc) 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 stdcall updateTmp,[context],[q],[q+8],eax
mov dword[tmp1.edge_flag],1 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 dword[tmp2.edge_flag],eax ;tmp2.edge_flag = q[2].edge_flag
mov eax,[clip_bit] mov eax,[clip_bit]
inc eax inc eax
@ -997,11 +982,11 @@ endp
align 16 align 16
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
mov eax,[p2] mov eax,[p2]
push dword[eax+offs_vert_zp+offs_Z] push dword[eax+GLVertex.zp+offs_Z]
mov eax,[p1] mov eax,[p1]
push dword[eax+offs_vert_zp+offs_Z] push dword[eax+GLVertex.zp+offs_Z]
mov eax,[p0] 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 stdcall gl_add_select1, [context] ;,p0.zp.z, p1.zp.z, p2.zp.z
ret ret
endp endp
@ -1031,9 +1016,9 @@ if PROFILE eq 1
end if end if
mov ebx,[p1] mov ebx,[p1]
add ebx,offs_vert_zp add ebx,GLVertex.zp
mov ecx,[p2] mov ecx,[p2]
add ecx,offs_vert_zp add ecx,GLVertex.zp
mov edx,[context] mov edx,[context]
cmp dword[edx+GLContext.texture_2d_enabled],0 cmp dword[edx+GLContext.texture_2d_enabled],0
je .els_i je .els_i
@ -1047,7 +1032,7 @@ end if
stdcall ZB_setTexture, [edx+GLContext.zb], [eax],\ stdcall ZB_setTexture, [edx+GLContext.zb], [eax],\
[eax+offs_imag_s_bound],[eax+offs_imag_t_bound],[eax+offs_imag_xsize_log2] [eax+offs_imag_s_bound],[eax+offs_imag_t_bound],[eax+offs_imag_xsize_log2]
mov eax,[p0] mov eax,[p0]
add eax,offs_vert_zp add eax,GLVertex.zp
push ecx push ecx
push ebx push ebx
push eax push eax
@ -1063,7 +1048,7 @@ align 4
align 4 align 4
.els_i: .els_i:
mov eax,[p0] mov eax,[p0]
add eax,offs_vert_zp add eax,GLVertex.zp
cmp dword[edx+GLContext.current_shade_model],GL_SMOOTH cmp dword[edx+GLContext.current_shade_model],GL_SMOOTH
jne .els jne .els
;else if (context.current_shade_model == GL_SMOOTH) ;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) ;if (p0.edge_flag) ZB_line_z(context.zb,&p0.zp,&p1.zp)
mov eax,[p0] mov eax,[p0]
cmp dword[eax+offs_vert_edge_flag],0 cmp dword[eax+GLVertex.edge_flag],0
je @f je @f
mov ebx,eax lea ebx,[eax+GLVertex.zp]
add ebx,offs_vert_zp
mov eax,[p1] mov eax,[p1]
add eax,offs_vert_zp add eax,GLVertex.zp
stdcall ecx,dword[edx+GLContext.zb],ebx,eax stdcall ecx,dword[edx+GLContext.zb],ebx,eax
@@: @@:
;if (p1.edge_flag) ZB_line_z(context.zb,&p1.zp,&p2.zp) ;if (p1.edge_flag) ZB_line_z(context.zb,&p1.zp,&p2.zp)
mov eax,[p1] mov eax,[p1]
cmp dword[eax+offs_vert_edge_flag],0 cmp dword[eax+GLVertex.edge_flag],0
je @f je @f
mov ebx,eax lea ebx,[eax+GLVertex.zp]
add ebx,offs_vert_zp
mov eax,[p2] mov eax,[p2]
add eax,offs_vert_zp add eax,GLVertex.zp
stdcall ecx,dword[edx+GLContext.zb],ebx,eax stdcall ecx,dword[edx+GLContext.zb],ebx,eax
@@: @@:
;if (p2.edge_flag) ZB_line_z(context.zb,&p2.zp,&p0.zp); ;if (p2.edge_flag) ZB_line_z(context.zb,&p2.zp,&p0.zp);
mov eax,[p2] mov eax,[p2]
cmp dword[eax+offs_vert_edge_flag],0 cmp dword[eax+GLVertex.edge_flag],0
je @f je @f
mov ebx,eax lea ebx,[eax+GLVertex.zp]
add ebx,offs_vert_zp
mov eax,[p0] mov eax,[p0]
add eax,offs_vert_zp add eax,GLVertex.zp
stdcall ecx,dword[edx+GLContext.zb],ebx,eax stdcall ecx,dword[edx+GLContext.zb],ebx,eax
@@: @@:
@ -1127,28 +1109,25 @@ endp
; Render a clipped triangle in point mode ; Render a clipped triangle in point mode
align 16 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 edx,[context]
mov eax,[p0] mov eax,[p0]
cmp dword[eax+offs_vert_edge_flag],0 cmp dword[eax+GLVertex.edge_flag],0
je @f je @f
mov ebx,eax lea eax,[eax+GLVertex.zp]
add ebx,offs_vert_zp stdcall ZB_plot,dword[edx+GLContext.zb],eax
stdcall ZB_plot,dword[edx+GLContext.zb],ebx
@@: @@:
mov eax,[p1] mov eax,[p1]
cmp dword[eax+offs_vert_edge_flag],0 cmp dword[eax+GLVertex.edge_flag],0
je @f je @f
mov ebx,eax lea eax,[eax+GLVertex.zp]
add ebx,offs_vert_zp stdcall ZB_plot,dword[edx+GLContext.zb],eax
stdcall ZB_plot,dword[edx+GLContext.zb],ebx
@@: @@:
mov eax,[p2] mov eax,[p2]
cmp dword[eax+offs_vert_edge_flag],0 cmp dword[eax+GLVertex.edge_flag],0
je @f je @f
mov ebx,eax lea eax,[eax+GLVertex.zp]
add ebx,offs_vert_zp stdcall ZB_plot,dword[edx+GLContext.zb],eax
stdcall ZB_plot,dword[edx+GLContext.zb],ebx
@@: @@:
ret ret
endp endp

View File

@ -64,17 +64,17 @@ pushad
mov eax,edx mov eax,edx
add eax,GLContext.lights add eax,GLContext.lights
.cycle_0: .cycle_0:
gl_V4_New eax+offs_ligh_ambient, 0.0,0.0,0.0,1.0 gl_V4_New eax+GLLight.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+GLLight.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+GLLight.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_V4_New eax+GLLight.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+GLLight.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+GLLight.spot_direction, 0.0,0.0,-1.0
gl_V3_New eax+offs_ligh_norm_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+offs_ligh_spot_exponent],0.0 mov dword[eax+GLLight.spot_exponent],0.0
mov dword[eax+offs_ligh_spot_cutoff],180.0 mov dword[eax+GLLight.spot_cutoff],180.0
gl_V3_New eax+offs_ligh_attenuation, 1.0,0.0,0.0 gl_V3_New eax+GLLight.attenuation, 1.0,0.0,0.0
mov dword[eax+offs_ligh_enabled],0 mov dword[eax+GLLight.enabled],0
add eax,sizeof.GLLight add eax,sizeof.GLLight
dec ecx dec ecx
cmp ecx,0 cmp ecx,0
@ -88,14 +88,13 @@ pushad
; default materials ; default materials
mov ecx,2 ;for(i=0;i<2;i++) mov ecx,2 ;for(i=0;i<2;i++)
mov eax,edx lea eax,[edx+GLContext.materials]
add eax,GLContext.materials
@@: @@:
gl_V4_New eax+offs_mate_emission, 0.0,0.0,0.0,1.0 gl_V4_New eax+GLMaterial.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+GLMaterial.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+GLMaterial.diffuse, 0.8,0.8,0.8,1.0
gl_V4_New eax+offs_mate_specular, 0.0,0.0,0.0,1.0 gl_V4_New eax+GLMaterial.specular, 0.0,0.0,0.0,1.0
mov dword[eax+offs_mate_shininess], 0.0 mov dword[eax+GLMaterial.shininess], 0.0
add eax,sizeof.GLMaterial add eax,sizeof.GLMaterial
loop @b loop @b

View File

@ -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) cmp ecx,GL_FRONT_AND_BACK ;if (mode == GL_FRONT_AND_BACK)
jne @f jne @f
mov dword[ebx+4],GL_FRONT ;p[1].i=GL_FRONT mov dword[ebx+4],GL_FRONT ;p[1].i=GL_FRONT
mov edi,ebp lea edi,[ebp+12]
add edi,12
stdcall glopMaterial,eax,edi stdcall glopMaterial,eax,edi
mov ecx,GL_BACK mov ecx,GL_BACK
@@: @@:
mov edi,eax lea edi,[eax+GLContext.materials]
add edi,GLContext.materials
cmp ecx,GL_FRONT ;if (mode == GL_FRONT) m=&context.materials[0] cmp ecx,GL_FRONT ;if (mode == GL_FRONT) m=&context.materials[0]
je @f je @f
add edi,sizeof.GLMaterial ;else m=&context.materials[1] add edi,sizeof.GLMaterial ;else m=&context.materials[1]
@@: @@:
mov ecx,4 mov ecx,4
mov esi,ebx ;esi = &p lea esi,[ebx+12] ;esi = &p[3]
add esi,12 ;esi = &p[3]
mov ebx,[ebx+8] ;ebx = p[2] mov ebx,[ebx+8] ;ebx = p[2]
cmp ebx,GL_EMISSION cmp ebx,GL_EMISSION
jne @f jne @f
;add edi,offs_mate_emission ;offs_mate_emission=0 ;add edi,GLMaterial.emission ;GLMaterial.emission=0
rep movsd rep movsd
jmp .end_f jmp .end_f
align 4 align 4
@@: @@:
cmp ebx,GL_AMBIENT cmp ebx,GL_AMBIENT
jne @f jne @f
add edi,offs_mate_ambient add edi,GLMaterial.ambient
rep movsd rep movsd
jmp .end_f jmp .end_f
align 4 align 4
@@: @@:
cmp ebx,GL_DIFFUSE cmp ebx,GL_DIFFUSE
jne @f jne @f
add edi,offs_mate_diffuse add edi,GLMaterial.diffuse
rep movsd rep movsd
jmp .end_f jmp .end_f
align 4 align 4
@@: @@:
cmp ebx,GL_SPECULAR cmp ebx,GL_SPECULAR
jne @f jne @f
add edi,offs_mate_specular add edi,GLMaterial.specular
rep movsd rep movsd
jmp .end_f jmp .end_f
align 4 align 4
@ -58,7 +55,7 @@ align 4
cmp ebx,GL_SHININESS cmp ebx,GL_SHININESS
jne @f jne @f
fld dword[esi] fld dword[esi]
add edi,offs_mate_shininess add edi,GLMaterial.shininess
movsd movsd
mov dword[edi],SPECULAR_BUFFER_RESOLUTION mov dword[edi],SPECULAR_BUFFER_RESOLUTION
fdiv dword[sp128f] fdiv dword[sp128f]
@ -69,10 +66,10 @@ align 4
@@: @@:
cmp ebx,GL_AMBIENT_AND_DIFFUSE cmp ebx,GL_AMBIENT_AND_DIFFUSE
jne @f jne @f
add edi,offs_mate_ambient add edi,GLMaterial.ambient
rep movsd rep movsd
sub esi,16 sub esi,16
;edi = &offs_mate_diffuse ;edi = &GLMaterial.diffuse
mov ecx,4 mov ecx,4
rep movsd rep movsd
jmp .end_f jmp .end_f
@ -108,16 +105,14 @@ pushad
sub edx,GL_LIGHT0 sub edx,GL_LIGHT0
imul edx,sizeof.GLLight imul edx,sizeof.GLLight
add edx,eax lea edx,[eax+edx+GLContext.lights]
add edx,GLContext.lights
mov ecx,[ebx+8] ;ecx = p[2] mov ecx,[ebx+8] ;ecx = p[2]
cmp ecx,GL_AMBIENT cmp ecx,GL_AMBIENT
jne @f jne @f
mov esi,ebx lea esi,[ebx+12]
add esi,12
mov edi,edx mov edi,edx
;add edi,offs_ligh_ambient ;offs_ligh_ambient = 0 ;add edi,GLLight.ambient ;GLLight.ambient = 0
mov ecx,4 mov ecx,4
rep movsd ;l.ambient=v rep movsd ;l.ambient=v
jmp .end_f jmp .end_f
@ -125,10 +120,8 @@ align 4
@@: @@:
cmp ecx,GL_DIFFUSE cmp ecx,GL_DIFFUSE
jne @f jne @f
mov esi,ebx lea esi,[ebx+12]
add esi,12 lea edi,[edx+GLLight.diffuse]
mov edi,edx
add edi,offs_ligh_diffuse
mov ecx,4 mov ecx,4
rep movsd ;l.diffuse=v rep movsd ;l.diffuse=v
jmp .end_f jmp .end_f
@ -136,10 +129,8 @@ align 4
@@: @@:
cmp ecx,GL_SPECULAR cmp ecx,GL_SPECULAR
jne @f jne @f
mov esi,ebx lea esi,[ebx+12]
add esi,12 lea edi,[edx+GLLight.specular]
mov edi,edx
add edi,offs_ligh_specular
mov ecx,4 mov ecx,4
rep movsd ;l.specular=v rep movsd ;l.specular=v
jmp .end_f jmp .end_f
@ -147,13 +138,10 @@ align 4
@@: @@:
cmp ecx,GL_POSITION cmp ecx,GL_POSITION
jne @f jne @f
mov edi,ebx ;ebx = [ebp+12] = [p] = &p[0] lea edi,[ebx+12] ;&p[3]
add edi,12 ;&p[3] lea esi,[ebp-16] ;&pos
mov esi,ebp
sub esi,16 ;&pos
stdcall gl_M4_MulV4, esi,dword[eax+GLContext.matrix_stack_ptr],edi stdcall gl_M4_MulV4, esi,dword[eax+GLContext.matrix_stack_ptr],edi
mov edi,edx lea edi,[edx+GLLight.position]
add edi,offs_ligh_position
mov ecx,4 mov ecx,4
rep movsd ;l.position=pos rep movsd ;l.position=pos
@ -164,13 +152,11 @@ align 4
jne .end_i jne .end_i
;mov esi,ebp ;mov esi,ebp
sub esi,16 ;&pos sub esi,16 ;&pos
mov edi,edx lea edi,[edx+GLLight.norm_position]
add edi,offs_ligh_norm_position
mov ecx,3 mov ecx,3
rep movsd ;l.norm_position=pos[1,2,3] rep movsd ;l.norm_position=pos[1,2,3]
;mov edi,edx ;lea edi,[edx+GLLight.norm_position]
;add edi,offs_ligh_norm_position
sub edi,12 sub edi,12
stdcall gl_V3_Norm,edi ;&l.norm_position stdcall gl_V3_Norm,edi ;&l.norm_position
.end_i: .end_i:
@ -181,21 +167,17 @@ align 4
@@: @@:
cmp ecx,GL_SPOT_DIRECTION cmp ecx,GL_SPOT_DIRECTION
jne @f jne @f
mov esi,ebx ;&p[0] lea esi,[ebx+12] ;&p[3]
add esi,12 lea edi,[edx+GLLight.spot_direction]
mov edi,edx
add edi,offs_ligh_spot_direction
mov ecx,3 mov ecx,3
rep movsd ;l.spot_direction=v[0,1,2] rep movsd ;l.spot_direction=v[0,1,2]
;mov esi,ebx ;lea esi,[ebx+12]
;add esi,12
sub esi,12 sub esi,12
;mov edi,edx ;lea edi,[edx+GLLight.norm_spot_direction]
;add edi,offs_ligh_norm_spot_direction add edi,GLLight.norm_spot_direction-(GLLight.spot_direction+12)
add edi,offs_ligh_norm_spot_direction-(offs_ligh_spot_direction+12)
mov ecx,3 mov ecx,3
rep movsd ;l.norm_spot_direction=v[0,1,2] 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 stdcall gl_V3_Norm,edx
jmp .end_f jmp .end_f
align 4 align 4
@ -203,7 +185,7 @@ align 4
cmp ecx,GL_SPOT_EXPONENT cmp ecx,GL_SPOT_EXPONENT
jne @f jne @f
mov ecx,[ebx+12] 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 jmp .end_f
align 4 align 4
@@: @@:
@ -211,7 +193,7 @@ align 4
jne .end_spot_c jne .end_spot_c
fld dword[ebp+12] ;float a=v.v[0] fld dword[ebp+12] ;float a=v.v[0]
; assert(a == 180 || (a>=0 && a<=90)); ; 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) fcom dword[an180f] ;if (a != 180)
fstsw ax fstsw ax
sahf sahf
@ -220,7 +202,7 @@ align 4
fmulp fmulp
fdiv dword[an180f] fdiv dword[an180f]
fcos 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 jmp .end_f
@@: @@:
ffree st0 ffree st0
@ -231,21 +213,21 @@ align 4
cmp ecx,GL_CONSTANT_ATTENUATION cmp ecx,GL_CONSTANT_ATTENUATION
jne @f jne @f
mov ecx,[ebx+12] 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 jmp .end_f
align 4 align 4
@@: @@:
cmp ecx,GL_LINEAR_ATTENUATION cmp ecx,GL_LINEAR_ATTENUATION
jne @f jne @f
mov ecx,[ebx+12] 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 jmp .end_f
align 4 align 4
@@: @@:
cmp ecx,GL_QUADRATIC_ATTENUATION cmp ecx,GL_QUADRATIC_ATTENUATION
jne @f jne @f
mov ecx,[ebx+12] 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 jmp .end_f
align 4 align 4
@@: ;default: @@: ;default:
@ -326,11 +308,10 @@ proc gl_enable_disable_light uses eax ebx ecx, context:dword, light:dword, v:dwo
mov eax,[context] mov eax,[context]
mov ebx,[light] mov ebx,[light]
imul ebx,sizeof.GLLight imul ebx,sizeof.GLLight
add ebx,eax lea ebx,[eax+ebx+GLContext.lights]
add ebx,GLContext.lights
xor ecx,ecx xor ecx,ecx
cmp dword[ebx+offs_ligh_enabled],0 cmp dword[ebx+GLLight.enabled],0
jne @f jne @f
not ecx not ecx
@@: @@:
@ -338,11 +319,11 @@ proc gl_enable_disable_light uses eax ebx ecx, context:dword, light:dword, v:dwo
or ecx,ecx or ecx,ecx
jz @f jz @f
;if (v && !l.enabled) ;if (v && !l.enabled)
mov dword[ebx+offs_ligh_enabled],1 mov dword[ebx+GLLight.enabled],1
mov ecx,[eax+GLContext.first_light] 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 [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 jmp .end_f
align 4 align 4
@@: @@:
@ -351,26 +332,26 @@ align 4
jne @f jne @f
not ecx not ecx
@@: @@:
and ecx,[ebx+offs_ligh_enabled] and ecx,[ebx+GLLight.enabled]
or ecx,ecx or ecx,ecx
jz .end_f jz .end_f
;else if (!v && l.enabled) ;else if (!v && l.enabled)
mov dword[ebx+offs_ligh_enabled],0 ;l.enabled = 0 mov dword[ebx+GLLight.enabled],0 ;l.enabled = 0
mov ecx,[ebx+offs_ligh_next] mov ecx,[ebx+GLLight.next]
cmp dword[ebx+offs_ligh_prev],0 ;if (l.prev == NULL) cmp dword[ebx+GLLight.prev],0 ;if (l.prev == NULL)
jne .els_0 jne .els_0
mov [eax+GLContext.first_light],ecx ;context.first_light = l.next mov [eax+GLContext.first_light],ecx ;context.first_light = l.next
jmp @f jmp @f
align 4 align 4
.els_0: .els_0:
mov eax,[ebx+offs_ligh_prev] mov eax,[ebx+GLLight.prev]
mov [eax+offs_ligh_next],ecx ;l.prev.next = l.next 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 je .end_f
mov ecx,[ebx+offs_ligh_prev] mov ecx,[ebx+GLLight.prev]
mov eax,[ebx+offs_ligh_next] mov eax,[ebx+GLLight.next]
mov [eax+offs_ligh_prev],ecx ;l.next.prev = l.prev mov [eax+GLLight.prev],ecx ;l.next.prev = l.prev
.end_f: .end_f:
ret ret
endp endp
@ -420,27 +401,26 @@ pushad
mov eax,[edx+GLContext.light_model_two_side] mov eax,[edx+GLContext.light_model_two_side]
mov [twoside],eax mov [twoside],eax
add esi,offs_vert_normal add esi,GLVertex.normal
mov edi,ebp lea edi,[ebp-24] ;edi = &n
sub edi,24 ;edi = &n
movsd ;n.X=v.normal.X movsd ;n.X=v.normal.X
movsd ;n.Y=v.normal.Y movsd ;n.Y=v.normal.Y
movsd ;n.Z=v.normal.Z movsd ;n.Z=v.normal.Z
mov esi,[v] mov esi,[v]
fld dword[edx+GLContext.ambient_light_model] fld dword[edx+GLContext.ambient_light_model]
fmul dword[ecx+offs_mate_ambient] fmul dword[ecx+GLMaterial.ambient]
fadd dword[ecx] ;offs_mate_emission=0 fadd dword[ecx] ;GLMaterial.emission=0
fstp dword[R] ;R=m.emission.v[0]+m.ambient.v[0]*context.ambient_light_model.v[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] fld dword[edx+GLContext.ambient_light_model+4]
fmul dword[ecx+offs_mate_ambient+4] fmul dword[ecx+GLMaterial.ambient+4]
fadd dword[ecx+offs_mate_emission+4] fadd dword[ecx+GLMaterial.emission+4]
fstp dword[G] fstp dword[G]
fld dword[edx+GLContext.ambient_light_model+8] fld dword[edx+GLContext.ambient_light_model+8]
fmul dword[ecx+offs_mate_ambient+8] fmul dword[ecx+GLMaterial.ambient+8]
fadd dword[ecx+offs_mate_emission+8] fadd dword[ecx+GLMaterial.emission+8]
fstp dword[B] 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 [A],eax ;A=clampf(m.diffuse.v[3],0,1)
mov ebx,[edx+GLContext.first_light] mov ebx,[edx+GLContext.first_light]
@ -449,17 +429,17 @@ pushad
jz .cycle_0_end jz .cycle_0_end
; ambient ; ambient
fld dword[ecx+offs_mate_ambient] fld dword[ecx+GLMaterial.ambient]
fmul dword[ebx] ;offs_ligh_ambient=0 fmul dword[ebx] ;GLLight.ambient=0
fstp dword[lR] ;lR=l.ambient.v[0] * m.ambient.v[0] fstp dword[lR] ;lR=l.ambient.v[0] * m.ambient.v[0]
fld dword[ecx+offs_mate_ambient+4] fld dword[ecx+GLMaterial.ambient+4]
fmul dword[ebx+offs_ligh_ambient+4] fmul dword[ebx+GLLight.ambient+4]
fstp dword[lG] ;lG=l.ambient.v[1] * m.ambient.v[1] fstp dword[lG] ;lG=l.ambient.v[1] * m.ambient.v[1]
fld dword[ecx+offs_mate_ambient+8] fld dword[ecx+GLMaterial.ambient+8]
fmul dword[ebx+offs_ligh_ambient+8] fmul dword[ebx+GLLight.ambient+8]
fstp dword[lB] ;lB=l.ambient.v[2] * m.ambient.v[2] 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) ftst ;if (l.position.v[3] == 0)
fstsw ax fstsw ax
sahf sahf
@ -467,11 +447,11 @@ pushad
; light at infinity ; light at infinity
ffree st0 ;l.position.v[3] ffree st0 ;l.position.v[3]
fincstp 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 [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 [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 [d+offs_Z],eax ;d.Z=l.norm_position.v[2]
mov dword[att],1.0 mov dword[att],1.0
jmp .els_0_end jmp .els_0_end
@ -480,14 +460,14 @@ align 4
; distance attenuation ; distance attenuation
ffree st0 ;l.position.v[3] ffree st0 ;l.position.v[3]
fincstp fincstp
fld dword[ebx+offs_ligh_position] fld dword[ebx+GLLight.position]
fsub dword[esi+offs_vert_ec] fsub dword[esi+GLVertex.ec]
fstp dword[d] ;d.X=l.position.v[0]-v.ec.v[0] fstp dword[d] ;d.X=l.position.v[0]-v.ec.v[0]
fld dword[ebx+offs_ligh_position+offs_Y] fld dword[ebx+GLLight.position+offs_Y]
fsub dword[esi+offs_vert_ec+offs_Y] fsub dword[esi+GLVertex.ec+offs_Y]
fstp dword[d+offs_Y] ;d.Y=l.position.v[1]-v.ec.v[1] fstp dword[d+offs_Y] ;d.Y=l.position.v[1]-v.ec.v[1]
fld dword[ebx+offs_ligh_position+offs_Z] fld dword[ebx+GLLight.position+offs_Z]
fsub dword[esi+offs_vert_ec+offs_Z] fsub dword[esi+GLVertex.ec+offs_Z]
fstp dword[d+offs_Z] ;d.Z=l.position.v[2]-v.ec.v[2] fstp dword[d+offs_Z] ;d.Z=l.position.v[2]-v.ec.v[2]
fld dword[d] fld dword[d]
fmul st0,st0 fmul st0,st0
@ -516,11 +496,11 @@ align 4
ffree st0 ;1.0/dist ffree st0 ;1.0/dist
fincstp fincstp
@@: @@:
fld dword[ebx+offs_ligh_attenuation+8] fld dword[ebx+GLLight.attenuation+8]
fmul st0,st1 ;st0 = dist * l.attenuation[2] fmul st0,st1 ;st0 = dist * l.attenuation[2]
fadd dword[ebx+offs_ligh_attenuation+4] fadd dword[ebx+GLLight.attenuation+4]
fmul st0,st1 fmul st0,st1
fadd dword[ebx+offs_ligh_attenuation] fadd dword[ebx+GLLight.attenuation]
fld1 fld1
fdiv st0,st1 fdiv st0,st1
fstp dword[att] ;att = 1.0f/(l.attenuation[0]+dist*(l.attenuation[1]+dist*l.attenuation[2])) fstp dword[att] ;att = 1.0f/(l.attenuation[0]+dist*(l.attenuation[1]+dist*l.attenuation[2]))
@ -550,18 +530,18 @@ align 4
sahf sahf
jbe .if0_end jbe .if0_end
; diffuse light ; diffuse light
fld dword[ecx+offs_mate_diffuse] fld dword[ecx+GLMaterial.diffuse]
fmul dword[ebx+offs_ligh_diffuse] fmul dword[ebx+GLLight.diffuse]
fmul st0,st1 fmul st0,st1
fadd dword[lR] fadd dword[lR]
fstp dword[lR] ;lR+=dot * l.diffuse.v[0] * m.diffuse.v[0] fstp dword[lR] ;lR+=dot * l.diffuse.v[0] * m.diffuse.v[0]
fld dword[ecx+offs_mate_diffuse+4] fld dword[ecx+GLMaterial.diffuse+4]
fmul dword[ebx+offs_ligh_diffuse+4] fmul dword[ebx+GLLight.diffuse+4]
fmul st0,st1 fmul st0,st1
fadd dword[lG] fadd dword[lG]
fstp dword[lG] ;lG+=dot * l.diffuse.v[1] * m.diffuse.v[1] fstp dword[lG] ;lG+=dot * l.diffuse.v[1] * m.diffuse.v[1]
fld dword[ecx+offs_mate_diffuse+8] fld dword[ecx+GLMaterial.diffuse+8]
fmul dword[ebx+offs_ligh_diffuse+8] fmul dword[ebx+GLLight.diffuse+8]
fmul st0,st1 fmul st0,st1
fadd dword[lB] fadd dword[lB]
fstp dword[lB] ;lB+=dot * l.diffuse.v[2] * m.diffuse.v[2] fstp dword[lB] ;lB+=dot * l.diffuse.v[2] * m.diffuse.v[2]
@ -569,17 +549,17 @@ align 4
fincstp fincstp
; spot light ; spot light
fld dword[ebx+offs_ligh_spot_cutoff] fld dword[ebx+GLLight.spot_cutoff]
fcomp dword[an180f] ;if (l.spot_cutoff != 180) fcomp dword[an180f] ;if (l.spot_cutoff != 180)
fstsw ax fstsw ax
sahf sahf
je .if1_end je .if1_end
fld dword[ebx+offs_ligh_norm_spot_direction] fld dword[ebx+GLLight.norm_spot_direction]
fmul dword[d] 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] fmul dword[d+offs_Y]
faddp 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] fmul dword[d+offs_Z]
faddp faddp
fchs fchs
@ -592,19 +572,19 @@ align 4
jae @f jae @f
fchs ;dot_spot = -dot_spot 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 fstsw ax
sahf sahf
jae .els_1 jae .els_1
; no contribution ; no contribution
ffree st0 ;dot_spot ffree st0 ;dot_spot
fincstp fincstp
mov ebx,[ebx+offs_ligh_next] mov ebx,[ebx+GLLight.next]
jmp .cycle_0 ;continue jmp .cycle_0 ;continue
align 4 align 4
.els_1: .els_1:
; TODO: optimize ; TODO: optimize
fld dword[ebx+offs_ligh_spot_exponent] fld dword[ebx+GLLight.spot_exponent]
ftst ;if (l.spot_exponent > 0) ftst ;if (l.spot_exponent > 0)
fstsw ax fstsw ax
sahf sahf
@ -639,14 +619,13 @@ align 4
; specular light ; specular light
cmp dword[edx+GLContext.local_light_model],0 ;if (c.local_light_model) cmp dword[edx+GLContext.local_light_model],0 ;if (c.local_light_model)
je .els_2 je .els_2
mov eax,[esi+offs_vert_ec] mov eax,[esi+GLVertex.ec]
mov [vcoord],eax ;vcoord.X=v.ec.X 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 [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 [vcoord+offs_Z],eax ;vcoord.Z=v.ec.Z
mov eax,ebp lea eax,[ebp-12] ;eax = &vcoord
sub eax,12 ;eax = &vcoord
stdcall gl_V3_Norm, eax stdcall gl_V3_Norm, eax
fld dword[d] fld dword[d]
fsub dword[vcoord] fsub dword[vcoord]
@ -709,7 +688,7 @@ align 4
; TODO: optimize ; TODO: optimize
; testing specular buffer code ; testing specular buffer code
; dot_spec= pow(dot_spec,m.shininess) ; 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 edi,eax ;edi = specbuf
mov dword[idx],SPECULAR_BUFFER_SIZE ;idx = SPECULAR_BUFFER_SIZE mov dword[idx],SPECULAR_BUFFER_SIZE ;idx = SPECULAR_BUFFER_SIZE
@ -724,19 +703,19 @@ align 4
shl dword[idx],2 shl dword[idx],2
add edi,dword[idx] add edi,dword[idx]
fld dword[edi+offs_spec_buf] ;dot_spec = specbuf.buf[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 st0,st1
fmul dword[ecx+offs_mate_specular] fmul dword[ecx+GLMaterial.specular]
fadd dword[lR] fadd dword[lR]
fstp dword[lR] ;lR+=dot_spec * l.specular.v[0] * m.specular.v[0] 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 st0,st1
fmul dword[ecx+offs_mate_specular+4] fmul dword[ecx+GLMaterial.specular+4]
fadd dword[lG] fadd dword[lG]
fstp dword[lG] ;lG+=dot_spec * l.specular.v[1] * m.specular.v[1] 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 st0,st1
fmul dword[ecx+offs_mate_specular+8] fmul dword[ecx+GLMaterial.specular+8]
fadd dword[lB] fadd dword[lB]
fstp dword[lB] ;lB+=dot_spec * l.specular.v[2] * m.specular.v[2] fstp dword[lB] ;lB+=dot_spec * l.specular.v[2] * m.specular.v[2]
.if0_end: .if0_end:
@ -759,19 +738,19 @@ align 4
fstp dword[B] ;B += att * lB fstp dword[B] ;B += att * lB
ffree st0 ;att ffree st0 ;att
fincstp fincstp
mov ebx,[ebx+offs_ligh_next] mov ebx,[ebx+GLLight.next]
jmp .cycle_0 jmp .cycle_0
align 4 align 4
.cycle_0_end: .cycle_0_end:
clampf [R],0,1 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 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 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 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 popad
ret ret
endp endp

View File

@ -5,22 +5,38 @@ macro ADD_OP a,b,c
db 'gl',`a,' ',c,0 db 'gl',`a,' ',c,0
} }
include 'opinfo.inc' include 'opinfo.inc'
purge ADD_OP
;указатели на функции ;static void (*op_table_func[])(GLContext *,GLParam *)= ;указатели на функции ;static void (*op_table_func[])(GLContext *,GLParam *)=
align 4
op_table_func: op_table_func:
macro ADD_OP a,b,c macro ADD_OP a,b,c
{ {
dd glop#a dd glop#a
} }
include 'opinfo.inc' include 'opinfo.inc'
purge ADD_OP
;число параметров в функциях ;число параметров в функциях
align 4
op_table_size: op_table_size:
macro ADD_OP a,b,c macro ADD_OP a,b,c
{ {
dd b+1 dd b+1
} }
include 'opinfo.inc' 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: ;output:
@ -30,8 +46,7 @@ proc find_list uses ebx, context:dword, list:dword
mov eax,[context] mov eax,[context]
mov eax,[eax+GLContext.shared_state] mov eax,[eax+GLContext.shared_state]
mov ebx,[list] mov ebx,[list]
shl ebx,2 lea eax,[eax+4*ebx]
add eax,ebx
mov eax,[eax] mov eax,[eax]
ret ret
endp endp
@ -55,10 +70,9 @@ proc delete_list uses eax ebx ecx edx, context:dword, list:dword
.end_w: .end_w:
stdcall gl_free,edx stdcall gl_free,edx
mov ecx,[list]
shl ecx,2
mov ebx,[ebx+GLContext.shared_state] ;ebx = &context.shared_state.lists 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 mov dword[ebx],0 ;=NULL
ret ret
endp endp
@ -77,8 +91,7 @@ proc alloc_list uses ebx ecx, context:dword, list:dword
mov ebx,[context] mov ebx,[context]
mov ebx,[ebx+GLContext.shared_state] mov ebx,[ebx+GLContext.shared_state]
mov ecx,[list] mov ecx,[list]
shl ecx,2 lea ebx,[ebx+4*ecx]
add ebx,ecx
mov [ebx],eax ;context.shared_state.lists[list]=l mov [ebx],eax ;context.shared_state.lists[list]=l
ret ret
endp endp
@ -116,18 +129,15 @@ proc gl_compile_op, context:dword, p:dword
pushad pushad
mov edx,[context] mov edx,[context]
lea ebx,[op_table_size]
mov ecx,[p] mov ecx,[p]
mov ecx,[ecx] mov ecx,[ecx] ;код операции
shl ecx,2 lea ecx,[op_table_size+4*ecx]
add ecx,ebx
mov ecx,[ecx] ;ecx = кол-во параметров в компилируемой функции mov ecx,[ecx] ;ecx = кол-во параметров в компилируемой функции
mov ebx,[edx+GLContext.current_op_buffer_index] mov ebx,[edx+GLContext.current_op_buffer_index]
mov eax,[edx+GLContext.current_op_buffer] mov eax,[edx+GLContext.current_op_buffer]
; we should be able to add a NextBuffer opcode ; we should be able to add a NextBuffer opcode
mov esi,ebx lea esi,[ebx+ecx]
add esi,ecx
cmp esi,(OP_BUFFER_MAX_SIZE-2) cmp esi,(OP_BUFFER_MAX_SIZE-2)
jle @f jle @f
mov edi,eax mov edi,eax
@ -135,9 +145,7 @@ pushad
mov dword[eax+offs_gpbu_next],0 ;=NULL mov dword[eax+offs_gpbu_next],0 ;=NULL
mov dword[edi+offs_gpbu_next],eax mov dword[edi+offs_gpbu_next],eax
mov esi,ebx lea esi,[edi+4*ebx]
shl esi,2
add esi,edi
mov dword[esi+offs_gpbu_ops],OP_NextBuffer mov dword[esi+offs_gpbu_ops],OP_NextBuffer
mov dword[esi+offs_gpbu_ops+4],eax mov dword[esi+offs_gpbu_ops+4],eax
@ -147,9 +155,7 @@ pushad
mov esi,[p] mov esi,[p]
@@: @@:
mov edi,ebx lea edi,[eax+4*ebx]
shl edi,2
add edi,eax
movsd movsd
inc ebx inc ebx
loop @b loop @b

View File

@ -75,21 +75,6 @@ struct GLLight
prev dd ? ;struct GLLight* prev dd ? ;struct GLLight*
ends 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 struct GLMaterial
emission V4 emission V4
ambient V4 ambient V4
@ -102,14 +87,6 @@ struct GLMaterial
do_specular dd ? ;int do_specular dd ? ;int
ends 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 struct GLViewport
xmin dd ? ;int xmin dd ? ;int
ymin dd ? ;int ymin dd ? ;int
@ -155,16 +132,6 @@ struct GLVertex
zp ZBufferPoint ; integer coordinates for the rasterization zp ZBufferPoint ; integer coordinates for the rasterization
ends 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 struct GLImage
pixmap dd ? ;void* pixmap dd ? ;void*
xsize dd ? ;int xsize dd ? ;int