Rev 5153 | Rev 5256 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5153 | Rev 5218 | ||
---|---|---|---|
Line 40... | Line 40... | ||
40 | fcomp st1 ;ñðàâíåíèå ñ 1.0 |
40 | fcomp st1 ;ñðàâíåíèå ñ 1.0 |
41 | fstsw ax |
41 | fstsw ax |
42 | test ah,0x40 |
42 | test ah,0x40 |
43 | je .not_1 ;åñëè íå ðàâíî 1.0 ìàòðèöà íå åäèíè÷íàÿ |
43 | je .not_1 ;åñëè íå ðàâíî 1.0 ìàòðèöà íå åäèíè÷íàÿ |
44 | @@: |
44 | @@: |
- | 45 | ffree st0 |
|
- | 46 | fincstp |
|
45 | add eax,4 |
47 | add eax,4 |
46 | inc ebx |
48 | inc ebx |
47 | btr ebx,2 |
49 | btr ebx,2 |
48 | jnc .cycle_01 |
50 | jnc .cycle_01 |
49 | inc ecx |
51 | inc ecx |
Line 51... | Line 53... | ||
51 | jnc .cycle_01 |
53 | jnc .cycle_01 |
Line 52... | Line 54... | ||
52 | 54 | ||
53 | mov eax,1 |
55 | mov eax,1 |
54 | jmp @f |
56 | jmp @f |
- | 57 | .not_1: |
|
- | 58 | ffree st0 |
|
55 | .not_1: |
59 | fincstp |
56 | xor eax,eax |
60 | xor eax,eax |
57 | @@: |
61 | @@: |
58 | ret |
62 | ret |
Line 233... | Line 237... | ||
233 | mov edx,[ecx+0x3c] |
237 | mov edx,[ecx+0x3c] |
234 | mov [eax+0x3c],edx |
238 | mov [eax+0x3c],edx |
235 | ret |
239 | ret |
236 | endp |
240 | endp |
Line 237... | Line 241... | ||
237 | 241 | ||
238 | ;/* inversion of an orthogonal matrix of type Y=M.X+P */ |
242 | ; inversion of an orthogonal matrix of type Y=M.X+P |
239 | ;void gl_M4_InvOrtho(M4 *a,M4 b) |
243 | ;void gl_M4_InvOrtho(M4 *a,M4 b) |
240 | ;{ |
244 | ;{ |
241 | ; int i,j; |
245 | ; int i,j; |
242 | ; float s; |
246 | ; float s; |
Line 248... | Line 252... | ||
248 | ; for(j=0;j<3;j++) s-=b.m[j][i]*b.m[j][3]; |
252 | ; for(j=0;j<3;j++) s-=b.m[j][i]*b.m[j][3]; |
249 | ; a->m[i][3]=s; |
253 | ; a->m[i][3]=s; |
250 | ; } |
254 | ; } |
251 | ;} |
255 | ;} |
Line 252... | Line 256... | ||
252 | 256 | ||
253 | ;/* Inversion of a general nxn matrix. |
257 | ; Inversion of a general nxn matrix. |
Line 254... | Line 258... | ||
254 | ; Note : m is destroyed */ |
258 | ; Note : m is destroyed |
255 | 259 | ||
256 | align 4 |
260 | align 4 |
257 | proc Matrix_Inv uses ecx, r:dword, m:dword, n:dword ;(float *r,float *m,int n) |
261 | proc Matrix_Inv uses ecx, r:dword, m:dword, n:dword ;(float *r,float *m,int n) |
Line 399... | Line 403... | ||
399 | ; a->m[2][2] = (m->m[0][0]*m->m[1][1]-m->m[0][1]*m->m[1][0])/det; |
403 | ; a->m[2][2] = (m->m[0][0]*m->m[1][1]-m->m[0][1]*m->m[1][0])/det; |
400 | ;} |
404 | ;} |
Line 401... | Line 405... | ||
401 | 405 | ||
Line -... | Line 406... | ||
- | 406 | ; vector arithmetic |
|
402 | ; vector arithmetic |
407 | |
- | 408 | align 4 |
|
- | 409 | proc gl_V3_Norm uses ebx, a:dword |
|
- | 410 | mov ebx,[a] |
|
- | 411 | fld dword[ebx] |
|
- | 412 | fmul dword[ebx] |
|
403 | 413 | fld dword[ebx+4] |
|
404 | ;int gl_V3_Norm(V3 *a) |
414 | fmul dword[ebx+4] |
- | 415 | faddp |
|
- | 416 | fld dword[ebx+8] |
|
405 | ;{ |
417 | fmul dword[ebx+8] |
- | 418 | faddp |
|
- | 419 | fsqrt ;st0 = sqrt(a.X^2 +a.Y^2 +a.Z^2) |
|
- | 420 | fldz |
|
- | 421 | fcomp |
|
406 | ; float n; |
422 | fstsw ax |
- | 423 | sahf |
|
407 | ; n=sqrt(a->X*a->X+a->Y*a->Y+a->Z*a->Z); |
424 | je .r1 ;if (sqrt(...)==0) return 1 |
- | 425 | fld dword[ebx] ;offs_X = 0 |
|
408 | ; if (n==0) return 1; |
426 | fdiv st0,st1 |
409 | ; a->X/=n; |
427 | fstp dword[ebx] ;a.X/=sqrt(...) |
- | 428 | fld dword[ebx+4] |
|
410 | ; a->Y/=n; |
429 | fdiv st0,st1 |
- | 430 | fstp dword[ebx+4] ;a.Y/=sqrt(...) |
|
- | 431 | fld dword[ebx+8] |
|
- | 432 | fdiv st0,st1 |
|
- | 433 | fstp dword[ebx+8] ;a.Z/=sqrt(...) |
|
- | 434 | xor eax,eax |
|
- | 435 | jmp @f |
|
- | 436 | .r1: |
|
- | 437 | xor eax,eax |
|
- | 438 | inc eax |
|
- | 439 | @@: |
|
- | 440 | ffree st0 |
|
411 | ; a->Z/=n; |
441 | fincstp |
Line 412... | Line 442... | ||
412 | ; return 0; |
442 | ret |
413 | ;} |
443 | endp |
414 | 444 | ||
415 | macro gl_V3_New p_mem, x, y, z |
445 | macro gl_V3_New p_mem, x, y, z |