Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 8063 → Rev 8062

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