Subversion Repositories Kolibri OS

Rev

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

Rev 5353 Rev 5415
Line 185... Line 185...
185
	ret
185
	ret
186
endp
186
endp
187
 
187
 
Line 188... Line 188...
188
align 4
188
align 4
189
proc glopRotate uses eax ebx ecx, context:dword, p:dword
189
proc glopRotate uses eax ebx ecx edx, context:dword, p:dword
190
locals
190
locals
191
	u0 dd ?
191
	u0 dd ?
192
	u1 dd ?
192
	u1 dd ?
193
	u2 dd ?
193
	u2 dd ?
194
	angle dd ?
194
	angle dd ?
Line 207... Line 207...
207
	fdiv dword[an180f]
207
	fdiv dword[an180f]
208
	fst dword[angle] ;angle = p[1].f * M_PI / 180.0
208
	fst dword[angle] ;angle = p[1].f * M_PI / 180.0
209
	;st0 = angle
209
	;st0 = angle
210
 
210
 
Line 211... Line -...
211
	fldz
-
 
212
	fild dword[ebx+8]
-
 
213
	fstp dword[u0]
-
 
214
	fild dword[ebx+12]
-
 
215
	fstp dword[u1]
-
 
216
	fild dword[ebx+16]
-
 
217
	fst dword[u2]
-
 
218
 
-
 
219
	; simple case detection
211
	; simple case detection
220
	xor ebx,ebx
212
	xor edx,edx
221
	fcomp st1 ;u2 ... 0
213
	fld dword[ebx+16]
-
 
214
	ftst
222
	fstsw ax
215
	fstsw ax
223
	sahf
216
	sahf
224
	je @f
217
	je @f
225
		inc ebx
218
		inc edx
226
	@@:
219
	@@:
227
	fcom dword[u1] ;0 ... u1
220
	fstp dword[u2]
-
 
221
	fld dword[ebx+12]
-
 
222
	ftst
228
	fstsw ax
223
	fstsw ax
229
	sahf
224
	sahf
230
	je @f
225
	je @f
231
		or ebx,2
226
		or edx,2
232
	@@:
227
	@@:
233
	fcom dword[u0] ;0 ... u0
228
	fstp dword[u1]
-
 
229
	fld dword[ebx+8]
-
 
230
	ftst
234
	fstsw ax
231
	fstsw ax
235
	sahf
232
	sahf
236
	je @f
233
	je @f
237
		or ebx,4
234
		or edx,4
238
	@@:
235
	@@:
239
	;st0 = 0, st1 = angle
236
	fstp dword[u0]
Line -... Line 237...
-
 
237
 
240
 
238
	;st0 = angle
241
	;ebx = ((u0 != 0)<<2) | ((u1 != 0)<<1) | (u2 != 0)
239
	;ebx = ((u0 != 0)<<2) | ((u1 != 0)<<1) | (u2 != 0)
242
	cmp ebx,0
240
	or edx,edx
243
	je .end_f ;если нет поворотов выход из функции
241
	jz .end_f ;если нет поворотов выход из функции
244
	cmp ebx,4
242
	cmp edx,4
245
	jne @f
243
	jne @f
-
 
244
		fld dword[u0]
246
		fcomp dword[u0] ;0 ... u0
245
		ftst
-
 
246
		fstsw ax
-
 
247
		ffree st0
247
		fstsw ax
248
		fincstp
248
		sahf
249
		sahf
249
		jae .u0ch
-
 
250
			fchs
250
		jae .u0ch
251
			fstp dword[angle] ;if (u0 < 0) angle *= -1
251
			fchs ;if (u0 < 0) angle *= -1
-
 
252
		.u0ch:
-
 
253
		push dword 0
-
 
254
		fstp dword[esp-4]
252
		.u0ch:
255
		sub esp,4
253
		stdcall gl_M4_Rotate, ecx,[angle],0
256
		stdcall gl_M4_Rotate, ecx
254
		jmp .end_sw
257
		jmp .end_sw
255
	@@:
258
	@@:
256
	cmp ebx,2
259
	cmp edx,2
257
	jne @f
260
	jne @f
-
 
261
		fld dword[u1]
258
		fcomp dword[u1] ;0 ... u1
262
		ftst
-
 
263
		fstsw ax
-
 
264
		ffree st0
259
		fstsw ax
265
		fincstp
260
		sahf
266
		sahf
261
		jae .u1ch
-
 
262
			fchs
267
		jae .u1ch
263
			fstp dword[angle] ;if (u1 < 0) angle *= -1
268
			fchs ;if (u1 < 0) angle *= -1
-
 
269
		.u1ch:
-
 
270
		push dword 1
-
 
271
		fstp dword[esp-4]
264
		.u1ch:
272
		sub esp,4
265
		stdcall gl_M4_Rotate, ecx,[angle],1
273
		stdcall gl_M4_Rotate, ecx
266
		jmp .end_sw
274
		jmp .end_sw
267
	@@:
275
	@@:
268
	cmp ebx,1
276
	cmp edx,1
269
	jne @f
277
	jne @f
-
 
278
		fld dword[u2]
270
		fcomp dword[u2] ;0 ... u2
279
		ftst
-
 
280
		fstsw ax
-
 
281
		ffree st0
271
		fstsw ax
282
		fincstp
272
		sahf
283
		sahf
273
		jae .u2ch
-
 
274
			fchs
284
		jae .u2ch
275
			fstp dword[angle] ;if (u2 < 0) angle *= -1
285
			fchs ;if (u2 < 0) angle *= -1
-
 
286
		.u2ch:
-
 
287
		push dword 2
-
 
288
		fstp dword[esp-4]
276
		.u2ch:
289
		sub esp,4
277
		stdcall gl_M4_Rotate, ecx,[angle],2
290
		stdcall gl_M4_Rotate, ecx
278
		jmp .end_sw
291
		jmp .end_sw
279
	@@: ;default:
292
	@@: ;default:
280
if DEBUG ;glopRotete
293
if DEBUG ;glopRotete
281
		stdcall dbg_print,txt_sp,m_1
294
		stdcall dbg_print,txt_sp,m_1
Line 285... Line 298...
285
		fld dword[u0]
298
		fld dword[u0]
286
		fmul st0,st0
299
		fmul st0,st0
287
		fld dword[u1]
300
		fld dword[u1]
288
		fmul st0,st0
301
		fmul st0,st0
289
		fld dword[u2]
302
		faddp
-
 
303
		fld dword[u2]
290
		fmul st0,st0
304
		fmul st0,st0
291
		fadd st0,st1
305
		faddp
292
		fadd st0,st2
-
 
293
;		fst dword[len] ;len = u0*u0+u1*u1+u2*u2
306
;		fst dword[len] ;len = u0*u0+u1*u1+u2*u2
294
		fcom st1
307
		ftst
295
		fstsw ax
308
		fstsw ax
296
		sahf
309
		sahf
297
		je .end_f ;if (len == 0.0f) return
310
		je .f2 ;if (len == 0.0f) return
298
		fsqrt
311
		fsqrt
299
		fld1
312
		fld1
300
		fdiv st0,st1
313
		fxch
301
;		fst dword[len] ;len = 1.0f / sqrt(len)
314
		fdivp ;len = 1.0f / sqrt(len)
302
		fld dword[u0]
315
;		fst dword[len]
-
 
316
		fld dword[u0]
303
		fmul st0,st1
317
		fmul st0,st1
304
		fstp dword[u0] ;u0 *= len
318
		fstp dword[u0] ;u0 *= len
305
		fld dword[u1]
319
		fld dword[u1]
306
		fmul st0,st1
320
		fmul st0,st1
307
		fstp dword[u1] ;u1 *= len
321
		fstp dword[u1] ;u1 *= len
308
		fld dword[u2]
322
		fld dword[u2]
309
		fmul st0,st1
323
		fmul st0,st1
310
		fstp dword[u2] ;u2 *= len
324
		fstp dword[u2] ;u2 *= len
311
		;st0 = len, st1=..., st2=..., st3 = 0, st4 = angle
325
		;st0 = len, st1 = angle
312
 
326
		ffree st0
-
 
327
		fincstp
-
 
328
 
Line 313... Line 329...
313
		; store cos and sin values
329
		; store cos and sin values
314
		finit
-
 
315
		fld dword[angle]
-
 
316
		fcos
330
		fcos
317
		fst dword[cost] ;cost=cos(angle)
331
		fst dword[cost] ;cost=cos(angle)
318
		fld dword[angle]
332
		fld dword[angle]
319
		fsin
333
		fsin
320
		fst dword[sint] ;sint=sin(angle)
334
		fst dword[sint] ;sint=sin(angle)
Line 330... Line 344...
330
		mov ebx,1.0
344
		mov ebx,1.0
331
		mov [ecx+3*16+12],ebx ;m[3][3]
345
		mov [ecx+3*16+12],ebx ;m[3][3]
332
 
346
 
Line 333... Line 347...
333
		; do the math
347
		; do the math
-
 
348
		fld dword[u0]
-
 
349
		fmul st0,st0
-
 
350
		fld1
-
 
351
		fsub st0,st1
-
 
352
		fmul st0,st3 ;st0 = cost*(1-u0^2)
-
 
353
		faddp
334
;      m.m[0][0]=u[0]*u[0]+cost*(1-u[0]*u[0]);
354
		fstp dword[ecx] ;m[0][0] = u0*u0+cost*(1-u0*u0)
-
 
355
 
-
 
356
		fld1
-
 
357
		fsub st0,st2 ;st0 = 1-cost
-
 
358
 
-
 
359
		fld st0
-
 
360
		fmul dword[u0]
-
 
361
		fmul dword[u1]
-
 
362
		fld dword[u2]
-
 
363
		fmul st0,st3 ;st0 = u2*sint
-
 
364
		fchs
-
 
365
		faddp
335
;      m.m[1][0]=u[0]*u[1]*(1-cost)-u[2]*sint;
366
		fstp dword[ecx+16] ;m[1][0] = u0*u1*(1-cost)-u2*sint
-
 
367
 
-
 
368
		fld st0
-
 
369
		fmul dword[u0]
-
 
370
		fmul dword[u2]
-
 
371
		fld dword[u1]
-
 
372
		fmul st0,st3 ;st0 = u1*sint
-
 
373
		faddp
336
;      m.m[2][0]=u[2]*u[0]*(1-cost)+u[1]*sint;
374
		fstp dword[ecx+32] ;m.m[2][0]=u[2]*u[0]*(1-cost)+u[1]*sint
-
 
375
 
-
 
376
		fld st0
-
 
377
		fmul dword[u0]
-
 
378
		fmul dword[u1]
-
 
379
		fld dword[u2]
-
 
380
		fmul st0,st3 ;st0 = u2*sint
-
 
381
		faddp
337
;      m.m[0][1]=u[0]*u[1]*(1-cost)+u[2]*sint;
382
		fstp dword[ecx+4] ;m.m[0][1]=u[0]*u[1]*(1-cost)+u[2]*sint
-
 
383
 
-
 
384
		fld dword[u1]
-
 
385
		fmul st0,st0
-
 
386
		fld1
-
 
387
		fsub st0,st1
-
 
388
		fmul st0,st4 ;st0 = cost*(1-u1^2)
-
 
389
		faddp
338
;      m.m[1][1]=u[1]*u[1]+cost*(1-u[1]*u[1]);
390
		fstp dword[ecx+20] ;m.m[1][1]=u[1]*u[1]+cost*(1-u[1]*u[1])
-
 
391
 
-
 
392
		fld st0
-
 
393
		fmul dword[u1]
-
 
394
		fmul dword[u2]
-
 
395
		fld dword[u0]
-
 
396
		fmul st0,st3 ;st0 = u0*sint
-
 
397
		fchs
-
 
398
		faddp
339
;      m.m[2][1]=u[1]*u[2]*(1-cost)-u[0]*sint;
399
		fstp dword[ecx+36] ;m.m[2][1]=u[1]*u[2]*(1-cost)-u[0]*sint
-
 
400
 
-
 
401
		fld st0
-
 
402
		fmul dword[u0]
-
 
403
		fmul dword[u2]
-
 
404
		fld dword[u1]
-
 
405
		fmul st0,st3 ;st0 = u1*sint
-
 
406
		fchs
-
 
407
		faddp
340
;      m.m[0][2]=u[2]*u[0]*(1-cost)-u[1]*sint;
408
		fstp dword[ecx+8] ;m.m[0][2]=u[2]*u[0]*(1-cost)-u[1]*sint
-
 
409
 
-
 
410
		fld st0
-
 
411
		fmul dword[u1]
-
 
412
		fmul dword[u2]
-
 
413
		fld dword[u0]
-
 
414
		fmul st0,st3 ;st0 = u0*sint
-
 
415
		faddp
341
;      m.m[1][2]=u[1]*u[2]*(1-cost)+u[0]*sint;
416
		fstp dword[ecx+24] ;m.m[1][2]=u[1]*u[2]*(1-cost)+u[0]*sint
-
 
417
 
-
 
418
		ffree st0 ;1-cost
-
 
419
		fincstp
-
 
420
 
-
 
421
		fld dword[u2]
-
 
422
		fmul st0,st0
-
 
423
		fld1
-
 
424
		fsub st0,st1
-
 
425
		fmul st0,st3 ;st0 = cost*(1-u2^2)
-
 
426
		faddp
342
;      m.m[2][2]=u[2]*u[2]+cost*(1-u[2]*u[2]);
427
		fstp dword[ecx+40] ;m[2][2] = u2*u2+cost*(1-u2*u2)
-
 
428
 
-
 
429
		ffree st0 ;sint
-
 
430
  fincstp
-
 
431
		ffree st0 ;cost
-
 
432
  fincstp
343
	.end_sw:
433
	.end_sw:
Line 344... Line 434...
344
 
434
 
345
	mov eax,[context]
435
	mov eax,[context]
346
	mov ebx,[eax+offs_cont_matrix_mode]
436
	mov ebx,[eax+offs_cont_matrix_mode]
Line 350... Line 440...
350
if DEBUG ;glopRotete
440
if DEBUG ;glopRotete
351
		stdcall gl_print_matrix,ecx,4
441
		stdcall gl_print_matrix,ecx,4
352
end if
442
end if
353
	gl_matrix_update eax,ebx
443
	gl_matrix_update eax,ebx
354
	.end_f:
444
	jmp .end_f
-
 
445
	.f2:
-
 
446
		ffree st0 ;len
-
 
447
		fincstp
-
 
448
		ffree st0 ;angle
-
 
449
		fincstp
-
 
450
	.end_f:
355
	ret
451
	ret
356
endp
452
endp
357
 
453
 
Line 358... Line 454...
358
align 4
454
align 4
Line 380... Line 476...
380
	fmul st0,st1     ;m[2] * z
476
	fmul st0,st1     ;m[2] * z
381
	fstp dword[ebx+8];m[2] *= z
477
	fstp dword[ebx+8];m[2] *= z
382
	add ebx,16
478
	add ebx,16
383
	loop @b
479
	loop @b
384
 
480
	ffree st0
-
 
481
	fincstp
-
 
482
	ffree st0
-
 
483
	fincstp
-
 
484
	ffree st0
-
 
485
	fincstp
-
 
486
 
Line 385... Line 487...
385
if DEBUG ;glopScale
487
if DEBUG ;glopScale
386
pushad
488
pushad
387
	stdcall dbg_print,txt_gl_scal,txt_nl
489
	stdcall dbg_print,txt_gl_scal,txt_nl
388
	mov ebx,[eax+offs_cont_matrix_mode]
490
	mov ebx,[eax+offs_cont_matrix_mode]