News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

CPU Matrix

Started by Farabi, August 20, 2009, 09:27:18 AM

Previous topic - Next topic

Farabi

Hi All,
Im sorry, Im noob at math, so I tried to translate this matrix multiplication but dont know how to determine if what Im doing was right.


; Tempmotion and tempmotionx is a 16 dword array
tempMotion = tempMotion * (tempMotionZ *tempMotionX * tempMotionY );


Here is my code of the matrix multiplication

fFillMatrix4f proc uses esi lpfMat4:dword,nIndex:dword,value:dword

mov esi,lpfMat4
mov ecx,nIndex
mov eax,value
mov [esi+ecx*4],eax

ret
fFillMatrix4f endp

fLoadMatrix4fToFPU proc uses esi lpfMat4f:dword,nIndex:dword

mov esi,lpfMat4f
mov ecx,nIndex

fld dword ptr[esi+ecx*4]

ret
fLoadMatrix4fToFPU endp

fMat4fMulProcess proc uses esi edi M1:dword,M2:dword,m10:dword,m11:dword,m20:dword,m21:dword,m30:dword,m31:dword,m40:dword,m41:dword
LOCAL ftmp:dword

mov esi,M1
mov edi,M2

invoke fLoadMatrix4fToFPU,esi,m10
invoke fLoadMatrix4fToFPU,edi,m11
fmul st,st(1)
push 0
fstp dword ptr[esp]
pop ftmp
finit
invoke fLoadMatrix4fToFPU,esi,m20
invoke fLoadMatrix4fToFPU,edi,m21
fmul st,st(1)
push 0
fadd ftmp
fstp dword ptr[esp]
pop ftmp
finit
invoke fLoadMatrix4fToFPU,esi,m30
invoke fLoadMatrix4fToFPU,edi,m31
fmul st,st(1)
push 0
fadd ftmp
fstp dword ptr[esp]
pop ftmp
finit
invoke fLoadMatrix4fToFPU,esi,m40
invoke fLoadMatrix4fToFPU,edi,m41
fmul st,st(1)
push 0
fadd ftmp
fstp dword ptr[esp]
pop ftmp
finit

mov eax,ftmp

ret
fMat4fMulProcess endp

fMat4fMulMatrix proc uses esi edi lpMat4fDestination:dword,lpMat4fM1:dword,lpMat4fM2:dword
LOCAL mtmp[16]:dword
LOCAL ftmp:real4

mov esi,lpMat4fM1
mov edi,lpMat4fM2

;invoke fMat4fLoadZero,addr mtmp

;result.matrix[0] = (m1.matrix[0]*m2.matrix[0]) + (m1.matrix[4]*m2.matrix[1]) +(m1.matrix[8]*m2.matrix[2]) +(m1.matrix[12]*m2.matrix[3]);
invoke fMat4fMulProcess,esi,edi,0,0,4,1,8,2,12,3
invoke fFillMatrix4f,addr mtmp,0,eax
;result.matrix[4] = (m1.matrix[0]*m2.matrix[4]) + (m1.matrix[4]*m2.matrix[5]) +(m1.matrix[8]*m2.matrix[6]) +(m1.matrix[12]*m2.matrix[7]);
invoke fMat4fMulProcess,esi,edi,0,4,4,5,8,6,12,7
invoke fFillMatrix4f,addr mtmp,4,eax
;result.matrix[8] = (m1.matrix[0]*m2.matrix[8]) + (m1.matrix[4]*m2.matrix[9]) +(m1.matrix[8]*m2.matrix[10])+(m1.matrix[12]*m2.matrix[11]);
invoke fMat4fMulProcess,esi,edi,0,8,4,9,8,10,12,11
invoke fFillMatrix4f,addr mtmp,8,eax
;result.matrix[12]= (m1.matrix[0]*m2.matrix[12])+ (m1.matrix[4]*m2.matrix[13])+(m1.matrix[8]*m2.matrix[14])+(m1.matrix[12]*m2.matrix[15]);
invoke fMat4fMulProcess,esi,edi,0,12,4,13,8,14,12,15
invoke fFillMatrix4f,addr mtmp,12,eax

;result.matrix[1] = (m1.matrix[1]*m2.matrix[0]) +(m1.matrix[5]*m2.matrix[1]) +(m1.matrix[9]*m2.matrix[2]) +(m1.matrix[13]*m2.matrix[3]);
invoke fMat4fMulProcess,esi,edi,1,0,5,1,9,2,13,3
invoke fFillMatrix4f,addr mtmp,1,eax
;result.matrix[5] = (m1.matrix[1]*m2.matrix[4]) +(m1.matrix[5]*m2.matrix[5]) +(m1.matrix[9]*m2.matrix[6]) +(m1.matrix[13]*m2.matrix[7]);
invoke fMat4fMulProcess,esi,edi,1,4,5,5,9,6,13,7
invoke fFillMatrix4f,addr mtmp,5,eax
;result.matrix[9] = (m1.matrix[1]*m2.matrix[8]) +(m1.matrix[5]*m2.matrix[9]) +(m1.matrix[9]*m2.matrix[10])+(m1.matrix[13]*m2.matrix[11]);
invoke fMat4fMulProcess,esi,edi,1,8,5,9,9,10,13,11
invoke fFillMatrix4f,addr mtmp,9,eax
;result.matrix[13]= (m1.matrix[1]*m2.matrix[12])+(m1.matrix[5]*m2.matrix[13])+(m1.matrix[9]*m2.matrix[14])+(m1.matrix[13]*m2.matrix[15]);
invoke fMat4fMulProcess,esi,edi,1,12,5,13,9,14,13,15
invoke fFillMatrix4f,addr mtmp,13,eax

;result.matrix[2] = (m1.matrix[2]*m2.matrix[0]) +(m1.matrix[6]*m2.matrix[1]) +(m1.matrix[10]*m2.matrix[2]) +(m1.matrix[14]*m2.matrix[3]);
invoke fMat4fMulProcess,esi,edi,2,0,6,1,10,2,14,3
invoke fFillMatrix4f,addr mtmp,2,eax
;result.matrix[6] = (m1.matrix[2]*m2.matrix[4]) +(m1.matrix[6]*m2.matrix[5]) +(m1.matrix[10]*m2.matrix[6]) +(m1.matrix[14]*m2.matrix[7]);
invoke fMat4fMulProcess,esi,edi,2,4,6,5,10,6,14,7
invoke fFillMatrix4f,addr mtmp,6,eax
;result.matrix[10]= (m1.matrix[2]*m2.matrix[8]) +(m1.matrix[6]*m2.matrix[9]) +(m1.matrix[10]*m2.matrix[10])+(m1.matrix[14]*m2.matrix[11]);
invoke fMat4fMulProcess,esi,edi,2,8,6,9,10,10,14,11
invoke fFillMatrix4f,addr mtmp,10,eax
;result.matrix[14]= (m1.matrix[2]*m2.matrix[12])+(m1.matrix[6]*m2.matrix[13])+(m1.matrix[10]*m2.matrix[14])+(m1.matrix[14]*m2.matrix[15]);
invoke fMat4fMulProcess,esi,edi,2,12,6,13,10,14,14,15
invoke fFillMatrix4f,addr mtmp,14,eax

;result.matrix[3] = (m1.matrix[3]*m2.matrix[0]) +(m1.matrix[7]*m2.matrix[1]) +(m1.matrix[11]*m2.matrix[2]) +(m1.matrix[15]*m2.matrix[3]);
invoke fMat4fMulProcess,esi,edi,3,0,7,1,11,2,15,3
invoke fFillMatrix4f,addr mtmp,3,eax
;result.matrix[7] = (m1.matrix[3]*m2.matrix[4]) +(m1.matrix[7]*m2.matrix[5]) +(m1.matrix[11]*m2.matrix[6]) +(m1.matrix[15]*m2.matrix[7]);
invoke fMat4fMulProcess,esi,edi,3,4,7,5,11,6,15,7
invoke fFillMatrix4f,addr mtmp,7,eax
;result.matrix[11]= (m1.matrix[3]*m2.matrix[8]) +(m1.matrix[7]*m2.matrix[9]) +(m1.matrix[11]*m2.matrix[10])+(m1.matrix[15]*m2.matrix[11]);
invoke fMat4fMulProcess,esi,edi,3,8,7,9,11,10,15,11
invoke fFillMatrix4f,addr mtmp,11,eax
;result.matrix[15]= (m1.matrix[3]*m2.matrix[12])+(m1.matrix[7]*m2.matrix[13])+(m1.matrix[11]*m2.matrix[14])+(m1.matrix[15]*m2.matrix[15]);
invoke fMat4fMulProcess,esi,edi,3,12,7,13,11,14,15,15
invoke fFillMatrix4f,addr mtmp,15,eax

invoke MemCopy,addr mtmp,lpMat4fDestination,16*4

ret
fMat4fMulMatrix endp


And here is how I did multiplyed it

LOCAL rx[16]:dword
LOCAL ry[16]:dword
LOCAL rz[16]:dword
LOCAL tm[16]:dword

invoke fMat4fMulMatrix,addr rz,addr rx,addr rz
invoke fMat4fMulMatrix,addr rz,addr ry,addr rz
invoke fMat4fMulMatrix,addr tm,addr tm,addr rz


Is what Im doing was right?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

NightWare

1. define a matrix structure
Matrix4x4   Struct
   Line00 dword 0
   Line01 dword 0
   Line02 dword 0
   Line03 dword 0
   Line10 dword 0
   Line11 dword 0
   Line12 dword 0
   Line13 dword 0
   Line20 dword 0
   Line21 dword 0
   Line22 dword 0
   Line23 dword 0
   Line30 dword 0
   Line31 dword 0
   Line32 dword 0
   Line33 dword 0
Matrix4x4   Struct ends

2. always init a matrix (also named identity matrix) like that :
1.0f,0,0,0
0,1.0f,0,0
0,0,1.0f,0
0,0,0,1.0f

3. fill with your values (depends of what you want to do here...)

4. multiply lines by columns
(Matrix4x4 ptr [edi]).Line00 * (Matrix4x4 ptr [esi]).Line00
(Matrix4x4 ptr [edi]).Line01 * (Matrix4x4 ptr [esi]).Line10
(Matrix4x4 ptr [edi]).Line02 * (Matrix4x4 ptr [esi]).Line20
(Matrix4x4 ptr [edi]).Line03 * (Matrix4x4 ptr [esi]).Line30

(Matrix4x4 ptr [edi]).Line10 * (Matrix4x4 ptr [esi]).Line01
(Matrix4x4 ptr [edi]).Line11 * (Matrix4x4 ptr [esi]).Line11
(Matrix4x4 ptr [edi]).Line12 * (Matrix4x4 ptr [esi]).Line21
(Matrix4x4 ptr [edi]).Line13 * (Matrix4x4 ptr [esi]).Line31

(Matrix4x4 ptr [edi]).Line20 * (Matrix4x4 ptr [esi]).Line02
(Matrix4x4 ptr [edi]).Line21 * (Matrix4x4 ptr [esi]).Line12
(Matrix4x4 ptr [edi]).Line22 * (Matrix4x4 ptr [esi]).Line22
(Matrix4x4 ptr [edi]).Line23 * (Matrix4x4 ptr [esi]).Line32

(Matrix4x4 ptr [edi]).Line30 * (Matrix4x4 ptr [esi]).Line03
(Matrix4x4 ptr [edi]).Line31 * (Matrix4x4 ptr [esi]).Line13
(Matrix4x4 ptr [edi]).Line32 * (Matrix4x4 ptr [esi]).Line23
(Matrix4x4 ptr [edi]).Line33 * (Matrix4x4 ptr [esi]).Line33

note : do not use finit each time you want to make an operation, use fmulp instead


Farabi

Quote from: NightWare on August 20, 2009, 11:30:39 PM
1. define a matrix structure
Matrix4x4   Struct
   Line00 dword 0
   Line01 dword 0
   Line02 dword 0
   Line03 dword 0
   Line10 dword 0
   Line11 dword 0
   Line12 dword 0
   Line13 dword 0
   Line20 dword 0
   Line21 dword 0
   Line22 dword 0
   Line23 dword 0
   Line30 dword 0
   Line31 dword 0
   Line32 dword 0
   Line33 dword 0
Matrix4x4   Struct ends

2. always init a matrix (also named identity matrix) like that :
1.0f,0,0,0
0,1.0f,0,0
0,0,1.0f,0
0,0,0,1.0f

3. fill with your values (depends of what you want to do here...)

4. multiply lines by columns
(Matrix4x4 ptr [edi]).Line00 * (Matrix4x4 ptr [esi]).Line00
(Matrix4x4 ptr [edi]).Line01 * (Matrix4x4 ptr [esi]).Line10
(Matrix4x4 ptr [edi]).Line02 * (Matrix4x4 ptr [esi]).Line20
(Matrix4x4 ptr [edi]).Line03 * (Matrix4x4 ptr [esi]).Line30

(Matrix4x4 ptr [edi]).Line10 * (Matrix4x4 ptr [esi]).Line01
(Matrix4x4 ptr [edi]).Line11 * (Matrix4x4 ptr [esi]).Line11
(Matrix4x4 ptr [edi]).Line12 * (Matrix4x4 ptr [esi]).Line21
(Matrix4x4 ptr [edi]).Line13 * (Matrix4x4 ptr [esi]).Line31

(Matrix4x4 ptr [edi]).Line20 * (Matrix4x4 ptr [esi]).Line02
(Matrix4x4 ptr [edi]).Line21 * (Matrix4x4 ptr [esi]).Line12
(Matrix4x4 ptr [edi]).Line22 * (Matrix4x4 ptr [esi]).Line22
(Matrix4x4 ptr [edi]).Line23 * (Matrix4x4 ptr [esi]).Line32

(Matrix4x4 ptr [edi]).Line30 * (Matrix4x4 ptr [esi]).Line03
(Matrix4x4 ptr [edi]).Line31 * (Matrix4x4 ptr [esi]).Line13
(Matrix4x4 ptr [edi]).Line32 * (Matrix4x4 ptr [esi]).Line23
(Matrix4x4 ptr [edi]).Line33 * (Matrix4x4 ptr [esi]).Line33

note : do not use finit each time you want to make an operation, use fmulp instead



So I guess my matrix multiplication is right is not it?
So What is the sequence if I want to do a matrix multiplication like this? tempMotion = tempMotion * (tempMotionZ *tempMotionX * tempMotionY );

is this right?
Quote
   invoke fMat4fLoadIdentity,addr tm
         invoke fMat4fTranslate,addr tm,v.x,v.y,v.z
         
         invoke fMat4fLoadIdentity,addr rx
         mov eax,prnt_data
         push eax
            fld dword ptr[eax].fObject.RotationX
            fchs
            fstp dword ptr[esp]
         pop ecx
         invoke fMat4fRotate,addr rx,ROTATE_X,ecx

         invoke fMat4fLoadIdentity,addr ry
         mov eax,prnt_data
         push eax
            fld dword ptr[eax].fObject.RotationY
            fchs
            fstp dword ptr[esp]
         pop ecx
         invoke fMat4fRotate,addr ry,ROTATE_Y,ecx

         invoke fMat4fLoadIdentity,addr rz
         mov eax,prnt_data
         push eax
            fld dword ptr[eax].fObject.RotationZ
            fchs
            fstp dword ptr[esp]
         pop ecx
         invoke fMat4fRotate,addr rz,ROTATE_Z,ecx
         
         
         invoke fMat4fMulMatrix,addr rz,addr rx,addr rz     ; Mul rz with rx
         invoke fMat4fMulMatrix,addr rz,addr ry,addr rz     ; Mul rz with ry
         invoke fMat4fMulMatrix,addr tm,addr tm,addr rz  ; Mul rz with tm which is contain the X,Y,Z position

      
         
                       ; Get the result which is stored at cell 12,13,14
         invoke fLoadMatrix4fToFPU,addr tm,12
         fstp v.x
         invoke fLoadMatrix4fToFPU,addr tm,13
         fstp v.y
         invoke fLoadMatrix4fToFPU,addr tm,14
         fstp v.z
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

Can someone tell me what I did is right or wrong?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

NightWare

you can't test your own work ?

http://www.masm32.com/board/index.php?topic=11817.0
1. IF you had REALLY studied it a bit, you would have seen that the order IS NOT the one you imagine but : Gr=t(Yr*(Xr*Zr))

2. i told you that the order has an influence. but IF you want to multiply a matrix by another matrix (whatever it is), AND IF the result matrix is supposed to do the job of both, IN THIS CASE it must be made in REVERSE order to obtain something usefull.

3. IF you had just followed what i've SAID  about the reverse order, you would have naturally obtained Gr=(Xr*(Yr*Zr)) or Gr=((Xr*Yr)*Zr) or ANY other VALID rotation combinations, coz the order IS NOT essential HERE, it will just influence your coords system.

4. what the hell your tmpMotion matrix is ? IF you can apply scale/reflection/etc... on the global rotation matrix it's because there is a link/relation between them (the 3d world), what is the relation with your "tmpMotion" matrix ? and since when do we need a matrix for time managment ?

imo, you have absolutely no idea of what you're doing... farabi, if you don't learn/understand/make the work you're supposed to do, i (or anyone else) will not do it for you.

you must understand the relation betwwen sine and cosine, you must understand that your matrices will be constitued of values from -1 to 1, you must understand the relations between axis, the effects on the others when you affect one of them, you must understand what you are doing !!! if you think that simply applying math formulas will be enough, you're simply wrong !


Farabi

Quote
4. what the hell your tmpMotion matrix is ? IF you can apply scale/reflection/etc... on the global rotation matrix it's because there is a link/relation between them (the 3d world), what is the relation with your "tmpMotion" matrix ? and since when do we need a matrix for time managment ?
Hi,
Okay thanks for the answer. First I appologize for the lack of my knowledge of math, and of my lazyness to read all the information everyone provided. Im never think if 3D matter is this complicated, I just though that it was just as simple as give the length of the vector and provide the rotation value, calculate it and tadaaa you got the result.
for tmpMotion it contain the X,Y and Z value on cell 12, 13, 14 here is the code for what it did do,
Quote
fMat4fTranslate proc uses esi lpfMat:dword,x:real4,y:real4,z:real4
   LOCAL ftmp:real4
   
   ;this->matrix[12]=(this->matrix[0]*x)+(this->matrix[4]*y)+(this->matrix[8] *z)+(this->matrix[12]);
   invoke fLoadMatrix4fToFPU,lpfMat,0
   push x
      fmul dword ptr[esp]
      fstp dword ptr[esp]
   pop ftmp
   invoke fLoadMatrix4fToFPU,lpfMat,4
   push y
      fmul dword ptr[esp]
      fadd ftmp
      fstp dword ptr[esp]
   pop ftmp
   invoke fLoadMatrix4fToFPU,lpfMat,8
   push z
      fmul dword ptr[esp]
      fadd ftmp
      fstp dword ptr[esp]
   pop ftmp
   invoke fLoadMatrix4fToFPU,lpfMat,12
   push ftmp
      fadd dword ptr[esp]
      fstp dword ptr[esp]
   pop ftmp
   invoke fFillMatrix4f,lpfMat,12,ftmp
   ;this->matrix[13]=(this->matrix[1]*x)+(this->matrix[5]*y)+(this->matrix[9] *z)+(this->matrix[13]);
   invoke fLoadMatrix4fToFPU,lpfMat,1
   push x
      fmul dword ptr[esp]
      fstp dword ptr[esp]
   pop ftmp
   invoke fLoadMatrix4fToFPU,lpfMat,5
   push y
      fmul dword ptr[esp]
      fadd ftmp
      fstp dword ptr[esp]
   pop ftmp
   invoke fLoadMatrix4fToFPU,lpfMat,9
   push z
      fmul dword ptr[esp]
      fadd ftmp
      fstp dword ptr[esp]
   pop ftmp
   invoke fLoadMatrix4fToFPU,lpfMat,13
   push ftmp
      fadd dword ptr[esp]
      fstp dword ptr[esp]
   pop ftmp
   invoke fFillMatrix4f,lpfMat,13,ftmp
   ;this->matrix[14]=(this->matrix[2]*x)+(this->matrix[6]*y)+(this->matrix[10]*z)+(this->matrix[14]);
   invoke fLoadMatrix4fToFPU,lpfMat,2
   push x
      fmul dword ptr[esp]
      fstp dword ptr[esp]
   pop ftmp
   invoke fLoadMatrix4fToFPU,lpfMat,6
   push y
      fmul dword ptr[esp]
      fadd ftmp
      fstp dword ptr[esp]
   pop ftmp
   invoke fLoadMatrix4fToFPU,lpfMat,10
   push z
      fmul dword ptr[esp]
      fadd ftmp
      fstp dword ptr[esp]
   pop ftmp
   invoke fLoadMatrix4fToFPU,lpfMat,14
   push ftmp
      fadd dword ptr[esp]
      fstp dword ptr[esp]
   pop ftmp
   invoke fFillMatrix4f,lpfMat,14,ftmp
   
   ret
fMat4fTranslate endp
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

NightWare

ok, here a trick to "always" have the good order, design your algo to multiply columns by lines (instead of the normal contrary, but it's something you will have to always keep in mind...). by doing this, you will be able to decompose the work like with the parenthesis ex :
Xr*Yr
and then result (Xr*Yr)*Zr
result will be Gr=(Xr*Yr)*Zr

"always" because in most case (in 3d) we calculate a matrix to obtain a unique matrix that will do the job. for you it will appear the normal sens/direction, the algo will implicitly do the reverse (but remember, it's NOT the normal sens).

for translation,
you must not calc all the points ! it does not work like that.
your global rotation matrix correspond to the view (directions (vector X for direction X, vector Y for direction Y, etc... )) of your current position. pX,pY,pZ (0,0,0 at the beginning if you haven't defined them). you simply need to multiply your displacement value (dX,dY,dZ) by the matrices you already have (for example, by Zr if you only want a translation on the Z axis, or by the global rotation matrix if you want to go forward/backward). and add/subtract the result obtained to your position (pX,pY,pZ), to obtain the new point of view in your 3d world, and reproduce the operation for each movments. now, if there is a changement of the view (anle/vector X, angle/vector Y, etc...) you will have to recalc your global rotation matrix (coz your world (or how you SEE it, to be more precise) will be different).

Farabi

#7
Quote from: NightWare on August 23, 2009, 10:41:26 PM
ok, here a trick to "always" have the good order, design your algo to multiply columns by lines (instead of the normal contrary, but it's something you will have to always keep in mind...). by doing this, you will be able to decompose the work like with the parenthesis ex :
Xr*Yr
and then result (Xr*Yr)*Zr
result will be Gr=(Xr*Yr)*Zr

"always" because in most case (in 3d) we calculate a matrix to obtain a unique matrix that will do the job. for you it will appear the normal sens/direction, the algo will implicitly do the reverse (but remember, it's NOT the normal sens).

for translation,
you must not calc all the points ! it does not work like that.
your global rotation matrix correspond to the view (directions (vector X for direction X, vector Y for direction Y, etc... )) of your current position. pX,pY,pZ (0,0,0 at the beginning if you haven't defined them). you simply need to multiply your displacement value (dX,dY,dZ) by the matrices you already have (for example, by Zr if you only want a translation on the Z axis, or by the global rotation matrix if you want to go forward/backward). and add/subtract the result obtained to your position (pX,pY,pZ), to obtain the new point of view in your 3d world, and reproduce the operation for each movments. now, if there is a changement of the view (anle/vector X, angle/vector Y, etc...) you will have to recalc your global rotation matrix (coz your world (or how you SEE it, to be more precise) will be different).

Sorry to annoy you but, is my fMat4fMulMatrix function code above is wrong at multiplicating it? I guess I created it right, please check it.
You dont need to feed me a code, but please give me a direction on what should I do, I only can learn by trial error not reading a lot of stuffs.

[edit]
Uploaded a matrix multiplication test
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

NightWare

the entire process
; 1. init matrices (example, here for the 4x4 rotation matrix x)
mov edx,OFFSET Matrix_X

mov eax,03F800000h ; put 1.0 in eax
mov DWORD PTR [edx],eax ; or DWORD*0
mov DWORD PTR [edx+20],eax ; or DWORD*5
mov DWORD PTR [edx+40],eax ; or DWORD*10
mov DWORD PTR [edx+60],eax ; or DWORD*15

; 2. obtain sine and cosine of your angles of view (example, here for angle x)
emms ; IF mmx registers used before
fld DWORD PTR Angle_X ; read the angle X
fmul DWORD PTR Value_3C8EFA35h ; (1/180)*Pi <= degres to radians
fsincos ; obtain sine in st(1) and cosine in st(0)
fstp DWORD PTR Cosine_X ; ) save sine and cosine
fstp DWORD PTR Sine_X ; )

; 3. fill your matrices with the sine/cosine obtained (example, here for the 4x4 rotation matrix x)
mov edx,OFFSET Matrix_X

mov eax,DWORD PTR Cosine_X ; read the cosine
mov DWORD PTR [edx+20],eax ; or DWORD*5
mov DWORD PTR [edx+40],eax ; or DWORD*10

mov eax,DWORD PTR Sine_X ; read the sine
mov DWORD PTR [edx+24],eax ; or DWORD*6
btc eax,31 ; change sine sign
mov DWORD PTR [edx+36],eax ; or DWORD*9

; 4. calc your global rotation matrix
mov eax,OFFSET XxY_TmpMatrix
mov ecx,OFFSET Y_RotationMatrix
mov edx,OFFSET X_RotationMatrix
; line 1
fld DWORD PTR [ecx] ; )
fmul DWORD PTR [edx] ; )
fstp DWORD PTR [eax] ; )
fld DWORD PTR [ecx+4] ; )
fmul DWORD PTR [edx+16] ; )
fadd DWORD PTR [eax] ; )
fstp DWORD PTR [eax] ; )
fld DWORD PTR [ecx+8] ; )
fmul DWORD PTR [edx+32] ; )
fadd DWORD PTR [eax] ; )
fstp DWORD PTR [eax] ; )
;
fld DWORD PTR [ecx] ; )
fmul DWORD PTR [edx+4] ; )
fstp DWORD PTR [eax+4] ; )
fld DWORD PTR [ecx+4] ; )
fmul DWORD PTR [edx+20] ; )
fadd DWORD PTR [eax+4] ; )
fstp DWORD PTR [eax+4] ; )
fld DWORD PTR [ecx+8] ; )
fmul DWORD PTR [edx+36] ; )
fadd DWORD PTR [eax+4] ; )
fstp DWORD PTR [eax+4] ; )
;
fld DWORD PTR [ecx] ; )
fmul DWORD PTR [edx+8] ; )
fstp DWORD PTR [eax+8] ; )
fld DWORD PTR [ecx+4] ; )
fmul DWORD PTR [edx+24] ; )
fadd DWORD PTR [eax+8] ; )
fstp DWORD PTR [eax+8] ; )
fld DWORD PTR [ecx+8] ; )
fmul DWORD PTR [edx+40] ; )
fadd DWORD PTR [eax+8] ; )
fstp DWORD PTR [eax+8] ; )
; line 2
fld DWORD PTR [ecx+16] ; )
fmul DWORD PTR [edx] ; )
fstp DWORD PTR [eax+16] ; )
fld DWORD PTR [ecx+20] ; )
fmul DWORD PTR [edx+16] ; )
fadd DWORD PTR [eax+16] ; )
fstp DWORD PTR [eax+16] ; )
fld DWORD PTR [ecx+24] ; )
fmul DWORD PTR [edx+32] ; )
fadd DWORD PTR [eax+16] ; )
fstp DWORD PTR [eax+16] ; )
;
fld DWORD PTR [ecx+16] ; )
fmul DWORD PTR [edx+4] ; )
fstp DWORD PTR [eax+20] ; )
fld DWORD PTR [ecx+20] ; )
fmul DWORD PTR [edx+20] ; )
fadd DWORD PTR [eax+20] ; )
fstp DWORD PTR [eax+20] ; )
fld DWORD PTR [ecx+24] ; )
fmul DWORD PTR [edx+36] ; )
fadd DWORD PTR [eax+20] ; )
fstp DWORD PTR [eax+20] ; )
;
fld DWORD PTR [ecx+16] ; )
fmul DWORD PTR [edx+8] ; )
fstp DWORD PTR [eax+24] ; )
fld DWORD PTR [ecx+20] ; )
fmul DWORD PTR [edx+24] ; )
fadd DWORD PTR [eax+24] ; )
fstp DWORD PTR [eax+24] ; )
fld DWORD PTR [ecx+24] ; )
fmul DWORD PTR [edx+40] ; )
fadd DWORD PTR [eax+24] ; )
fstp DWORD PTR [eax+24] ; )
; line 3
fld DWORD PTR [ecx+32] ; )
fmul DWORD PTR [edx] ; )
fstp DWORD PTR [eax+32] ; )
fld DWORD PTR [ecx+36] ; )
fmul DWORD PTR [edx+16] ; )
fadd DWORD PTR [eax+32] ; )
fstp DWORD PTR [eax+32] ; )
fld DWORD PTR [ecx+40] ; )
fmul DWORD PTR [edx+32] ; )
fadd DWORD PTR [eax+32] ; )
fstp DWORD PTR [eax+32] ; )
;
fld DWORD PTR [ecx+32] ; )
fmul DWORD PTR [edx+4] ; )
fstp DWORD PTR [eax+36] ; )
fld DWORD PTR [ecx+36] ; )
fmul DWORD PTR [edx+20] ; )
fadd DWORD PTR [eax+36] ; )
fstp DWORD PTR [eax+36] ; )
fld DWORD PTR [ecx+40] ; )
fmul DWORD PTR [edx+36] ; )
fadd DWORD PTR [eax+36] ; )
fstp DWORD PTR [eax+36] ; )
;
fld DWORD PTR [ecx+32] ; )
fmul DWORD PTR [edx+8] ; )
fstp DWORD PTR [eax+40] ; )
fld DWORD PTR [ecx+36] ; )
fmul DWORD PTR [edx+24] ; )
fadd DWORD PTR [eax+40] ; )
fstp DWORD PTR [eax+40] ; )
fld DWORD PTR [ecx+40] ; )
fmul DWORD PTR [edx+40] ; )
fadd DWORD PTR [eax+40] ; )
fstp DWORD PTR [eax+40] ; )

mov eax,OFFSET XYZ_RotationMatrix
mov ecx,OFFSET Z_RotationMatrix
mov edx,OFFSET XxY_TmpMatrix
; line 1
fld DWORD PTR [ecx] ; )
fmul DWORD PTR [edx] ; )
fstp DWORD PTR [eax] ; )
fld DWORD PTR [ecx+4] ; )
fmul DWORD PTR [edx+16] ; )
fadd DWORD PTR [eax] ; )
fstp DWORD PTR [eax] ; )
fld DWORD PTR [ecx+8] ; )
fmul DWORD PTR [edx+32] ; )
fadd DWORD PTR [eax] ; )
fstp DWORD PTR [eax] ; )
;
fld DWORD PTR [ecx] ; )
fmul DWORD PTR [edx+4] ; )
fstp DWORD PTR [eax+4] ; )
fld DWORD PTR [ecx+4] ; )
fmul DWORD PTR [edx+20] ; )
fadd DWORD PTR [eax+4] ; )
fstp DWORD PTR [eax+4] ; )
fld DWORD PTR [ecx+8] ; )
fmul DWORD PTR [edx+36] ; )
fadd DWORD PTR [eax+4] ; )
fstp DWORD PTR [eax+4] ; )
;
fld DWORD PTR [ecx] ; )
fmul DWORD PTR [edx+8] ; )
fstp DWORD PTR [eax+8] ; )
fld DWORD PTR [ecx+4] ; )
fmul DWORD PTR [edx+24] ; )
fadd DWORD PTR [eax+8] ; )
fstp DWORD PTR [eax+8] ; )
fld DWORD PTR [ecx+8] ; )
fmul DWORD PTR [edx+40] ; )
fadd DWORD PTR [eax+8] ; )
fstp DWORD PTR [eax+8] ; )
; line 2
fld DWORD PTR [ecx+16] ; )
fmul DWORD PTR [edx] ; )
fstp DWORD PTR [eax+16] ; )
fld DWORD PTR [ecx+20] ; )
fmul DWORD PTR [edx+16] ; )
fadd DWORD PTR [eax+16] ; )
fstp DWORD PTR [eax+16] ; )
fld DWORD PTR [ecx+24] ; )
fmul DWORD PTR [edx+32] ; )
fadd DWORD PTR [eax+16] ; )
fstp DWORD PTR [eax+16] ; )
;
fld DWORD PTR [ecx+16] ; )
fmul DWORD PTR [edx+4] ; )
fstp DWORD PTR [eax+20] ; )
fld DWORD PTR [ecx+20] ; )
fmul DWORD PTR [edx+20] ; )
fadd DWORD PTR [eax+20] ; )
fstp DWORD PTR [eax+20] ; )
fld DWORD PTR [ecx+24] ; )
fmul DWORD PTR [edx+36] ; )
fadd DWORD PTR [eax+20] ; )
fstp DWORD PTR [eax+20] ; )
;
fld DWORD PTR [ecx+16] ; )
fmul DWORD PTR [edx+8] ; )
fstp DWORD PTR [eax+24] ; )
fld DWORD PTR [ecx+20] ; )
fmul DWORD PTR [edx+24] ; )
fadd DWORD PTR [eax+24] ; )
fstp DWORD PTR [eax+24] ; )
fld DWORD PTR [ecx+24] ; )
fmul DWORD PTR [edx+40] ; )
fadd DWORD PTR [eax+24] ; )
fstp DWORD PTR [eax+24] ; )
; line 3
fld DWORD PTR [ecx+32] ; )
fmul DWORD PTR [edx] ; )
fstp DWORD PTR [eax+32] ; )
fld DWORD PTR [ecx+36] ; )
fmul DWORD PTR [edx+16] ; )
fadd DWORD PTR [eax+32] ; )
fstp DWORD PTR [eax+32] ; )
fld DWORD PTR [ecx+40] ; )
fmul DWORD PTR [edx+32] ; )
fadd DWORD PTR [eax+32] ; )
fstp DWORD PTR [eax+32] ; )
;
fld DWORD PTR [ecx+32] ; )
fmul DWORD PTR [edx+4] ; )
fstp DWORD PTR [eax+36] ; )
fld DWORD PTR [ecx+36] ; )
fmul DWORD PTR [edx+20] ; )
fadd DWORD PTR [eax+36] ; )
fstp DWORD PTR [eax+36] ; )
fld DWORD PTR [ecx+40] ; )
fmul DWORD PTR [edx+36] ; )
fadd DWORD PTR [eax+36] ; )
fstp DWORD PTR [eax+36] ; )
;
fld DWORD PTR [ecx+32] ; )
fmul DWORD PTR [edx+8] ; )
fstp DWORD PTR [eax+40] ; )
fld DWORD PTR [ecx+36] ; )
fmul DWORD PTR [edx+24] ; )
fadd DWORD PTR [eax+40] ; )
fstp DWORD PTR [eax+40] ; )
fld DWORD PTR [ecx+40] ; )
fmul DWORD PTR [edx+40] ; )
fadd DWORD PTR [eax+40] ; )
fstp DWORD PTR [eax+40] ; )

; 5. multiply your global rotation matrix by your coords system (width/2, height/2 ,depth), and optionnally with zomm value

; 6. calc your displacements, and subtract to your point of view

; 7. substract your displacement to your points, and multiply your points by the global rotation matrix

; 8. calc the 2D coords and add half of the screen (width/2, height/2) (to obtain real screen position)



i hope you've understood, coz i will NOT help you more for 3D stuff...