Subversion Repositories Kolibri OS

Rev

Rev 6101 | Rev 6523 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6101 Rev 6243
Line 30... Line 30...
30
	cmp ebx,GL_EMISSION
30
	cmp ebx,GL_EMISSION
31
	jne @f
31
	jne @f
32
		;add edi,offs_mate_emission ;offs_mate_emission=0
32
		;add edi,offs_mate_emission ;offs_mate_emission=0
33
		rep movsd
33
		rep movsd
34
		jmp .end_f
34
		jmp .end_f
-
 
35
align 4
35
	@@:
36
	@@:
36
	cmp ebx,GL_AMBIENT
37
	cmp ebx,GL_AMBIENT
37
	jne @f
38
	jne @f
38
		add edi,offs_mate_ambient
39
		add edi,offs_mate_ambient
39
		rep movsd
40
		rep movsd
40
		jmp .end_f
41
		jmp .end_f
-
 
42
align 4
41
	@@:
43
	@@:
42
	cmp ebx,GL_DIFFUSE
44
	cmp ebx,GL_DIFFUSE
43
	jne @f
45
	jne @f
44
		add edi,offs_mate_diffuse
46
		add edi,offs_mate_diffuse
45
		rep movsd
47
		rep movsd
46
		jmp .end_f
48
		jmp .end_f
-
 
49
align 4
47
	@@:
50
	@@:
48
	cmp ebx,GL_SPECULAR
51
	cmp ebx,GL_SPECULAR
49
	jne @f
52
	jne @f
50
		add edi,offs_mate_specular
53
		add edi,offs_mate_specular
51
		rep movsd
54
		rep movsd
52
		jmp .end_f
55
		jmp .end_f
-
 
56
align 4
53
	@@:
57
	@@:
54
	cmp ebx,GL_SHININESS
58
	cmp ebx,GL_SHININESS
55
	jne @f
59
	jne @f
56
		fld dword[esi]
60
		fld dword[esi]
57
		add edi,offs_mate_shininess
61
		add edi,offs_mate_shininess
Line 59... Line 63...
59
		mov dword[edi],SPECULAR_BUFFER_RESOLUTION
63
		mov dword[edi],SPECULAR_BUFFER_RESOLUTION
60
		fdiv dword[sp128f]
64
		fdiv dword[sp128f]
61
		fimul dword[edi]
65
		fimul dword[edi]
62
		fistp dword[edi] ;m.shininess_i = (v[0]/128.0f)*SPECULAR_BUFFER_RESOLUTION
66
		fistp dword[edi] ;m.shininess_i = (v[0]/128.0f)*SPECULAR_BUFFER_RESOLUTION
63
		jmp .end_f
67
		jmp .end_f
-
 
68
align 4
64
	@@:
69
	@@:
65
	cmp ebx,GL_AMBIENT_AND_DIFFUSE
70
	cmp ebx,GL_AMBIENT_AND_DIFFUSE
66
	jne @f
71
	jne @f
67
		add edi,offs_mate_ambient
72
		add edi,offs_mate_ambient
68
		rep movsd
73
		rep movsd
69
		sub esi,16
74
		sub esi,16
70
		;edi = &offs_mate_diffuse
75
		;edi = &offs_mate_diffuse
71
		mov ecx,4
76
		mov ecx,4
72
		rep movsd
77
		rep movsd
73
		jmp .end_f
78
		jmp .end_f
-
 
79
align 4
74
	@@: ;default
80
	@@: ;default
75
;    assert(0);
81
;    assert(0);
76
	.end_f:
82
	.end_f:
77
	ret
83
	ret
78
endp
84
endp
Line 113... Line 119...
113
		mov edi,edx
119
		mov edi,edx
114
		;add edi,offs_ligh_ambient ;offs_ligh_ambient = 0
120
		;add edi,offs_ligh_ambient ;offs_ligh_ambient = 0
115
		mov ecx,4
121
		mov ecx,4
116
		rep movsd ;l.ambient=v
122
		rep movsd ;l.ambient=v
117
		jmp .end_f
123
		jmp .end_f
-
 
124
align 4
118
	@@:
125
	@@:
119
	cmp ecx,GL_DIFFUSE
126
	cmp ecx,GL_DIFFUSE
120
	jne @f
127
	jne @f
121
		mov esi,ebx
128
		mov esi,ebx
122
		add esi,12
129
		add esi,12
123
		mov edi,edx
130
		mov edi,edx
124
		add edi,offs_ligh_diffuse
131
		add edi,offs_ligh_diffuse
125
		mov ecx,4
132
		mov ecx,4
126
		rep movsd ;l.diffuse=v
133
		rep movsd ;l.diffuse=v
127
		jmp .end_f
134
		jmp .end_f
-
 
135
align 4
128
	@@:
136
	@@:
129
	cmp ecx,GL_SPECULAR
137
	cmp ecx,GL_SPECULAR
130
	jne @f
138
	jne @f
131
		mov esi,ebx
139
		mov esi,ebx
132
		add esi,12
140
		add esi,12
133
		mov edi,edx
141
		mov edi,edx
134
		add edi,offs_ligh_specular
142
		add edi,offs_ligh_specular
135
		mov ecx,4
143
		mov ecx,4
136
		rep movsd ;l.specular=v
144
		rep movsd ;l.specular=v
137
		jmp .end_f
145
		jmp .end_f
-
 
146
align 4
138
	@@:
147
	@@:
139
	cmp ecx,GL_POSITION
148
	cmp ecx,GL_POSITION
140
	jne @f
149
	jne @f
141
		mov edi,ebx ;ebx = [ebp+12] = [p] = &p[0]
150
		mov edi,ebx ;ebx = [ebp+12] = [p] = &p[0]
142
		add edi,12 ;&p[3]
151
		add edi,12 ;&p[3]
Line 166... Line 175...
166
			stdcall gl_V3_Norm,edi ;&l.norm_position
175
			stdcall gl_V3_Norm,edi ;&l.norm_position
167
		.end_i:
176
		.end_i:
168
		ffree st0
177
		ffree st0
169
		fincstp
178
		fincstp
170
		jmp .end_f
179
		jmp .end_f
-
 
180
align 4
171
	@@:
181
	@@:
172
	cmp ecx,GL_SPOT_DIRECTION
182
	cmp ecx,GL_SPOT_DIRECTION
173
	jne @f
183
	jne @f
174
		mov esi,ebx ;&p[0]
184
		mov esi,ebx ;&p[0]
175
		add esi,12
185
		add esi,12
Line 186... Line 196...
186
		mov ecx,3
196
		mov ecx,3
187
		rep movsd ;l.norm_spot_direction=v[0,1,2]
197
		rep movsd ;l.norm_spot_direction=v[0,1,2]
188
		add edx,offs_ligh_norm_spot_direction
198
		add edx,offs_ligh_norm_spot_direction
189
		stdcall gl_V3_Norm,edx
199
		stdcall gl_V3_Norm,edx
190
		jmp .end_f
200
		jmp .end_f
-
 
201
align 4
191
	@@:
202
	@@:
192
	cmp ecx,GL_SPOT_EXPONENT
203
	cmp ecx,GL_SPOT_EXPONENT
193
	jne @f
204
	jne @f
194
		mov ecx,[ebx+12]
205
		mov ecx,[ebx+12]
195
		mov [edi+offs_ligh_spot_exponent],ecx ;l.spot_exponent=p[3]
206
		mov [edi+offs_ligh_spot_exponent],ecx ;l.spot_exponent=p[3]
196
		jmp .end_f
207
		jmp .end_f
-
 
208
align 4
197
	@@:
209
	@@:
198
	cmp ecx,GL_SPOT_CUTOFF
210
	cmp ecx,GL_SPOT_CUTOFF
199
	jne .end_spot_c
211
	jne .end_spot_c
200
		fld dword[ebp+12] ;float a=v.v[0]
212
		fld dword[ebp+12] ;float a=v.v[0]
201
;      assert(a == 180 || (a>=0 && a<=90));
213
;      assert(a == 180 || (a>=0 && a<=90));
Line 212... Line 224...
212
			jmp .end_f
224
			jmp .end_f
213
		@@:
225
		@@:
214
		ffree st0
226
		ffree st0
215
		fincstp
227
		fincstp
216
		jmp .end_f
228
		jmp .end_f
-
 
229
align 4
217
	.end_spot_c:
230
	.end_spot_c:
218
	cmp ecx,GL_CONSTANT_ATTENUATION
231
	cmp ecx,GL_CONSTANT_ATTENUATION
219
	jne @f
232
	jne @f
220
		mov ecx,[ebx+12]
233
		mov ecx,[ebx+12]
221
		mov [edi+offs_ligh_attenuation],ecx ;l->attenuation[0]=p[3]
234
		mov [edi+offs_ligh_attenuation],ecx ;l->attenuation[0]=p[3]
222
		jmp .end_f
235
		jmp .end_f
-
 
236
align 4
223
	@@:
237
	@@:
224
	cmp ecx,GL_LINEAR_ATTENUATION
238
	cmp ecx,GL_LINEAR_ATTENUATION
225
	jne @f
239
	jne @f
226
		mov ecx,[ebx+12]
240
		mov ecx,[ebx+12]
227
		mov [edi+offs_ligh_attenuation+4],ecx ;l->attenuation[1]=p[3]
241
		mov [edi+offs_ligh_attenuation+4],ecx ;l->attenuation[1]=p[3]
228
		jmp .end_f
242
		jmp .end_f
-
 
243
align 4
229
	@@:
244
	@@:
230
	cmp ecx,GL_QUADRATIC_ATTENUATION
245
	cmp ecx,GL_QUADRATIC_ATTENUATION
231
	jne @f
246
	jne @f
232
		mov ecx,[ebx+12]
247
		mov ecx,[ebx+12]
233
		mov [edi+offs_ligh_attenuation+8],ecx ;l->attenuation[2]=p[3]
248
		mov [edi+offs_ligh_attenuation+8],ecx ;l->attenuation[2]=p[3]
234
		jmp .end_f
249
		jmp .end_f
-
 
250
align 4
235
	@@: ;default:
251
	@@: ;default:
236
;    assert(0);
252
;    assert(0);
237
	.end_f:
253
	.end_f:
238
popad
254
popad
239
	ret
255
	ret
Line 252... Line 268...
252
	jne @f
268
	jne @f
253
		mov ecx,4
269
		mov ecx,4
254
		add edi,offs_cont_ambient_light_model
270
		add edi,offs_cont_ambient_light_model
255
		rep movsd ;for(i=0;i<4;i++) context.ambient_light_model.v[i]=v[i]
271
		rep movsd ;for(i=0;i<4;i++) context.ambient_light_model.v[i]=v[i]
256
		jmp .end_f
272
		jmp .end_f
-
 
273
align 4
257
	@@:
274
	@@:
258
	cmp ebx,GL_LIGHT_MODEL_LOCAL_VIEWER
275
	cmp ebx,GL_LIGHT_MODEL_LOCAL_VIEWER
259
	jne @f
276
	jne @f
260
		fld dword[esi] ;st0 = p[2]
277
		fld dword[esi] ;st0 = p[2]
261
		fistp dword[edi+offs_cont_local_light_model]
278
		fistp dword[edi+offs_cont_local_light_model]
262
		jmp .end_f
279
		jmp .end_f
-
 
280
align 4
263
	@@:
281
	@@:
264
	cmp ebx,GL_LIGHT_MODEL_TWO_SIDE
282
	cmp ebx,GL_LIGHT_MODEL_TWO_SIDE
265
	jne @f
283
	jne @f
266
		fld dword[esi] ;st0 = p[2]
284
		fld dword[esi] ;st0 = p[2]
267
		fistp dword[edi+offs_cont_light_model_two_side]
285
		fistp dword[edi+offs_cont_light_model_two_side]
268
		jmp .end_f
286
		jmp .end_f
-
 
287
align 4
269
	@@: ;default:
288
	@@: ;default:
270
;    tgl_warning("glopLightModel: illegal pname: 0x%x\n", ebx);
289
;    tgl_warning("glopLightModel: illegal pname: 0x%x\n", ebx);
271
;    //assert(0);
290
;    //assert(0);
272
	.end_f:
291
	.end_f:
273
	ret
292
	ret
Line 285... Line 304...
285
	ja .o_1
304
	ja .o_1
286
		ffree st0
305
		ffree st0
287
		fincstp
306
		fincstp
288
		mov eax,0.0
307
		mov eax,0.0
289
		jmp .end_m ;return 0.0
308
		jmp .end_m ;return 0.0
-
 
309
align 4
290
	.o_1:
310
	.o_1:
291
	fld1 ;else if (a>=1.0)
311
	fld1 ;else if (a>=1.0)
292
	fcompp
312
	fcompp
293
	fstsw ax
313
	fstsw ax
294
	sahf
314
	sahf
295
	ja .o_2
315
	ja .o_2
296
		mov eax,1.0
316
		mov eax,1.0
297
		jmp .end_m ;return 1.0
317
		jmp .end_m ;return 1.0
-
 
318
align 4
298
	.o_2:
319
	.o_2:
299
	mov eax,dword a ;else return a
320
	mov eax,dword a ;else return a
300
	.end_m:
321
	.end_m:
301
}
322
}
Line 321... Line 342...
321
		mov ecx,[eax+offs_cont_first_light]
342
		mov ecx,[eax+offs_cont_first_light]
322
		mov [ebx+offs_ligh_next],ecx
343
		mov [ebx+offs_ligh_next],ecx
323
		mov [eax+offs_cont_first_light],ebx ;context.first_light = l
344
		mov [eax+offs_cont_first_light],ebx ;context.first_light = l
324
		mov dword[ebx+offs_ligh_prev],0 ;l.prev = NULL
345
		mov dword[ebx+offs_ligh_prev],0 ;l.prev = NULL
325
		jmp .end_f
346
		jmp .end_f
-
 
347
align 4
326
	@@:
348
	@@:
327
	xor ecx,ecx
349
	xor ecx,ecx
328
	cmp dword[v],0
350
	cmp dword[v],0
329
	jne @f
351
	jne @f
330
		not ecx
352
		not ecx
Line 337... Line 359...
337
		mov ecx,[ebx+offs_ligh_next]
359
		mov ecx,[ebx+offs_ligh_next]
338
		cmp dword[ebx+offs_ligh_prev],0 ;if (l.prev == NULL)
360
		cmp dword[ebx+offs_ligh_prev],0 ;if (l.prev == NULL)
339
		jne .els_0
361
		jne .els_0
340
			mov [eax+offs_cont_first_light],ecx	;context.first_light = l.next
362
			mov [eax+offs_cont_first_light],ecx	;context.first_light = l.next
341
			jmp @f
363
			jmp @f
-
 
364
align 4
342
		.els_0:
365
		.els_0:
343
			mov eax,[ebx+offs_ligh_prev]
366
			mov eax,[ebx+offs_ligh_prev]
344
			mov [eax+offs_ligh_next],ecx ;l.prev.next = l.next
367
			mov [eax+offs_ligh_next],ecx ;l.prev.next = l.next
345
		@@:
368
		@@:
346
		cmp dword[ebx+offs_ligh_next],0
369
		cmp dword[ebx+offs_ligh_next],0
Line 354... Line 377...
354
 
377
 
355
align 4
378
align 4
Line 356... Line 379...
356
fl_1e_3 dd 1.0e-3
379
fl_1e_3 dd 1.0e-3
357
 
380
 
358
; non optimized lightening model
381
; non optimized lightening model
359
align 4
382
align 16
360
proc gl_shade_vertex, context:dword, v:dword
383
proc gl_shade_vertex, context:dword, v:dword
361
locals
384
locals
362
	R dd ? ;float ebp-96
385
	R dd ? ;float ebp-96
Line 450... Line 473...
450
			mov [d+offs_Y],eax ;d.Y=l.norm_position.v[1]
473
			mov [d+offs_Y],eax ;d.Y=l.norm_position.v[1]
451
			mov eax,[ebx+offs_ligh_norm_position+offs_Z]
474
			mov eax,[ebx+offs_ligh_norm_position+offs_Z]
452
			mov [d+offs_Z],eax ;d.Z=l.norm_position.v[2]
475
			mov [d+offs_Z],eax ;d.Z=l.norm_position.v[2]
453
			mov dword[att],1.0
476
			mov dword[att],1.0
454
			jmp .els_0_end
477
			jmp .els_0_end
-
 
478
align 4
455
		.els_0:
479
		.els_0:
456
			; distance attenuation
480
			; distance attenuation
457
			ffree st0 ;l.position.v[3]
481
			ffree st0 ;l.position.v[3]
458
			fincstp
482
			fincstp
459
			fld dword[ebx+offs_ligh_position]
483
			fld dword[ebx+offs_ligh_position]
Line 575... Line 599...
575
					; no contribution
599
					; no contribution
576
					ffree st0 ;dot_spot
600
					ffree st0 ;dot_spot
577
					fincstp
601
					fincstp
578
					mov ebx,[ebx+offs_ligh_next]
602
					mov ebx,[ebx+offs_ligh_next]
579
					jmp .cycle_0 ;continue
603
					jmp .cycle_0 ;continue
-
 
604
align 4
580
				.els_1:
605
				.els_1:
581
					; TODO: optimize
606
					; TODO: optimize
582
					fld dword[ebx+offs_ligh_spot_exponent]
607
					fld dword[ebx+offs_ligh_spot_exponent]
583
					ftst ;if (l.spot_exponent > 0)
608
					ftst ;if (l.spot_exponent > 0)
584
					fstsw ax
609
					fstsw ax
Line 600... Line 625...
600
						fxch st1
625
						fxch st1
601
						fstp st ;Результат остается на вершине стека st0
626
						fstp st ;Результат остается на вершине стека st0
602
						fmul dword[att]
627
						fmul dword[att]
603
						fstp dword[att] ;att=att*pow(dot_spot,l.spot_exponent)
628
						fstp dword[att] ;att=att*pow(dot_spot,l.spot_exponent)
604
						jmp .if1_end_f1
629
						jmp .if1_end_f1
-
 
630
align 4
605
					@@:
631
					@@:
606
					ffree st0 ;l.spot_exponent
632
					ffree st0 ;l.spot_exponent
607
					fincstp
633
					fincstp
608
					.if1_end_f1:
634
					.if1_end_f1:
609
					ffree st0 ;dot_spot
635
					ffree st0 ;dot_spot
Line 630... Line 656...
630
				fstp dword[s+offs_Y] ;s.Y=d.Y-vcoord.Y
656
				fstp dword[s+offs_Y] ;s.Y=d.Y-vcoord.Y
631
				fld dword[d+offs_Z]
657
				fld dword[d+offs_Z]
632
				fsub dword[vcoord+offs_Z]
658
				fsub dword[vcoord+offs_Z]
633
				fstp dword[s+offs_Z] ;s.Z=d.Z-vcoord.Z
659
				fstp dword[s+offs_Z] ;s.Z=d.Z-vcoord.Z
634
				jmp .els_2_end
660
				jmp .els_2_end
-
 
661
align 4
635
			.els_2:
662
			.els_2:
636
				mov eax,[d]
663
				mov eax,[d]
637
				mov [s],eax ;s.X=d.X
664
				mov [s],eax ;s.X=d.X
638
				mov eax,[d+offs_Y]
665
				mov eax,[d+offs_Y]
639
				mov [s+offs_Y],eax ;s.Y=d.Y
666
				mov [s+offs_Y],eax ;s.Y=d.Y
Line 732... Line 759...
732
		fstp dword[B] ;B += att * lB
759
		fstp dword[B] ;B += att * lB
733
		ffree st0 ;att
760
		ffree st0 ;att
734
		fincstp
761
		fincstp
735
		mov ebx,[ebx+offs_ligh_next]
762
		mov ebx,[ebx+offs_ligh_next]
736
		jmp .cycle_0
763
		jmp .cycle_0
-
 
764
align 4
737
	.cycle_0_end:
765
	.cycle_0_end:
Line 738... Line 766...
738
 
766
 
739
	clampf [R],0,1
767
	clampf [R],0,1
740
	mov [esi+offs_vert_color],eax ;v.color.v[0]=clampf(R,0,1)
768
	mov [esi+offs_vert_color],eax ;v.color.v[0]=clampf(R,0,1)