Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

286 lines
9.6 KiB

  1. .486p
  2. .model flat
  3. include offsets.asm
  4. include pentium2.inc
  5. .data
  6. gD3DCS_LEFT dd 01h
  7. gD3DCS_RIGHT dd 02h
  8. gD3DCS_TOP dd 04h
  9. gD3DCS_BOTTOM dd 08h
  10. gD3DCS_FRONT dd 10h
  11. gD3DCS_BACK dd 20h
  12. .code
  13. if 0
  14. D3DVERTEX_x equ 0
  15. D3DVERTEX_y equ 4
  16. D3DVERTEX_z equ 8
  17. D3DTLVERTEX_sx equ 0
  18. D3DTLVERTEX_sy equ 4
  19. D3DTLVERTEX_sz equ 8
  20. D3DTLVERTEX_rhw equ 12
  21. D3DTLVERTEX_color equ 16
  22. D3DTLVERTEX_specular equ 20
  23. D3DTLVERTEX_tu equ 24
  24. D3DTLVERTEX_tv equ 28
  25. D3DFE_PROCESSVERTICES_rExtents equ 16*4
  26. D3DFE_PROCESSVERTICES_vcache equ 20*4
  27. D3DFE_PROCESSVERTICES_dwFlags equ 24*4
  28. D3DFE_VIEWPORTCACHE_scaleX equ 0
  29. D3DFE_VIEWPORTCACHE_scaleY equ 4
  30. D3DFE_VIEWPORTCACHE_offsetX equ 8
  31. D3DFE_VIEWPORTCACHE_offsetY equ 12
  32. D3DDP_DONOTUPDATEEXTENTS equ 1
  33. D3DMATRIXI__11 equ 0
  34. D3DMATRIXI__12 equ 4
  35. D3DMATRIXI__13 equ 8
  36. D3DMATRIXI__14 equ 12
  37. D3DMATRIXI__21 equ 16
  38. D3DMATRIXI__22 equ 20
  39. D3DMATRIXI__23 equ 24
  40. D3DMATRIXI__24 equ 28
  41. D3DMATRIXI__31 equ 32
  42. D3DMATRIXI__32 equ 36
  43. D3DMATRIXI__33 equ 40
  44. D3DMATRIXI__34 equ 44
  45. D3DMATRIXI__41 equ 48
  46. D3DMATRIXI__42 equ 52
  47. D3DMATRIXI__43 equ 56
  48. D3DMATRIXI__44 equ 60
  49. endif
  50. PUBLIC _matmul6
  51. _matmul6 PROC
  52. pout equ dword ptr [esp+44]
  53. pin equ dword ptr [esp+48]
  54. pmat equ dword ptr [esp+52]
  55. hout equ dword ptr [esp+56]
  56. tempxx equ dword ptr [esp+16]
  57. tempyy equ dword ptr [esp+20]
  58. tempzz equ dword ptr [esp+24]
  59. tempx equ dword ptr [esp+28]
  60. tempy equ dword ptr [esp+32]
  61. tempz equ dword ptr [esp+36]
  62. sub esp,24 ; Make room for locals
  63. push ebx ; Save regs
  64. push esi ;
  65. push edi ;
  66. push ebp ;
  67. mov eax,pin ; Get in ptr
  68. mov ecx,pmat ; Get mat ptr
  69. mov ebp,pout ; Get out ptr
  70. mov esi,80000000h ; Ready to compute clip codes
  71. ; float x, y, z, w, we;
  72. ; x = in->x*pv->mCTM._11 + in->y*pv-mCTM._21 + in->z*pv->mCTM._31 + pv->mCTM._41;
  73. ; y = in->x*pv->mCTM._12 + in->y*pv->mCTM._22 + in->z*pv->mCTM._32 + pv->mCTM._42;
  74. ; z = in->x*pv->mCTM._13 + in->y*pv->mCTM._23 + in->z*pv->mCTM._33 + pv->mCTM._43;
  75. ; we= in->x*pv->mCTM._14 + in->y*pv->mCTM._24 + in->z*pv->mCTM._34 + pv->mCTM._44;
  76. fld dword ptr [eax+D3DVERTEX_x] ; x1
  77. fmul dword ptr [ecx+D3DMATRIXI__11] ;
  78. fld dword ptr [eax+D3DVERTEX_x] ; w1 x1
  79. fmul dword ptr [ecx+D3DMATRIXI__14] ;
  80. fld dword ptr [eax+D3DVERTEX_x] ; y1 w1 x1
  81. fmul dword ptr [ecx+D3DMATRIXI__12] ;
  82. fld dword ptr [eax+D3DVERTEX_x] ; z1 y1 w1 x1
  83. fmul dword ptr [ecx+D3DMATRIXI__13] ;
  84. fxch st(3) ; x1 y1 w1 z1
  85. fadd dword ptr [ecx+D3DMATRIXI__41] ; x2 y1 w1 z1
  86. fxch st(2) ; w1 y1 x2 z1
  87. fadd dword ptr [ecx+D3DMATRIXI__44] ; w2 y1 x2 z1
  88. fxch st(1) ; y1 w2 x2 z1
  89. fadd dword ptr [ecx+D3DMATRIXI__42] ; y2 w2 x2 z1
  90. fxch st(3) ; z1 w2 x2 y2
  91. fadd dword ptr [ecx+D3DMATRIXI__43] ; z2 w2 x2 y2
  92. fld dword ptr [eax+D3DVERTEX_y] ; y*_21
  93. fmul dword ptr [ecx+D3DMATRIXI__21] ;
  94. fld dword ptr [eax+D3DVERTEX_y] ; y*_24
  95. fmul dword ptr [ecx+D3DMATRIXI__24] ;
  96. fld dword ptr [eax+D3DVERTEX_y] ; y*_22
  97. fmul dword ptr [ecx+D3DMATRIXI__22] ;
  98. fld dword ptr [eax+D3DVERTEX_y] ; y*_23
  99. fmul dword ptr [ecx+D3DMATRIXI__23] ;
  100. fxch st(3) ; y*_21 y*_22 y*_24 y*_23 z2 w2 x2 y2
  101. faddp st(6),st ; y*_22 y*_24 y*_23 z2 w2 x3 y2
  102. fxch st(1) ; y*_24 y*_22 y*_23 z2 w2 x3 y2
  103. faddp st(4),st ; y*_22 y*_23 z2 w3 x3 y2
  104. faddp st(5),st ; y*_23 z2 w3 x3 y3
  105. faddp st(1),st ; z3 w3 x3 y3
  106. fld dword ptr [eax+D3DVERTEX_z] ; z*_31
  107. fmul dword ptr [ecx+D3DMATRIXI__31] ;
  108. fld dword ptr [eax+D3DVERTEX_z] ; z*_34
  109. fmul dword ptr [ecx+D3DMATRIXI__34] ;
  110. fld dword ptr [eax+D3DVERTEX_z] ; z*_32
  111. fmul dword ptr [ecx+D3DMATRIXI__32] ;
  112. fld dword ptr [eax+D3DVERTEX_z] ; z*_33
  113. fmul dword ptr [ecx+D3DMATRIXI__33] ;
  114. fxch st(3) ; z*_31 z*_32 z*_34 z*_33 z3 w3 x3 y3
  115. faddp st(6),st ; z*_32 z*_34 z*_33 z3 w3 x4 y3
  116. fxch st(1) ; z*_34 z*_32 z*_33 z3 w3 x4 y3
  117. faddp st(4),st ; z*_32 z*_33 z3 w4 x4 y3
  118. faddp st(5),st ; z*_33 z3 w4 x4 y4
  119. faddp st(1),st ; z4 w4 x4 y4
  120. fldz ; 0 z4 w4 x4 y4
  121. fxch st(4) ; y4 z4 w4 x4 0
  122. fxch st(3) ; x4 z4 w4 y4 0
  123. xor eax,eax ;
  124. xor ebx,ebx ;
  125. xor ecx,ecx ;
  126. xor edx,edx ;
  127. fcomi st,st(4) ;
  128. cmovb eax,gD3DCS_LEFT
  129. fcomi st,st(2) ;
  130. cmovnb ebx,gD3DCS_RIGHT
  131. fxch st(3) ; y4 z4 w4 x4 0
  132. or eax,ebx
  133. xor ebx,ebx
  134. fcomi st,st(4) ;
  135. cmovb ecx,gD3DCS_BOTTOM
  136. fcomi st,st(2) ;
  137. cmovnb edx,gD3DCS_TOP
  138. or eax,ecx
  139. xor ecx,ecx
  140. fxch st(1) ; z4 y4 w4 x4 0
  141. fcomi st,st(4) ;
  142. or edx,edx
  143. cmovb ebx,gD3DCS_FRONT
  144. fcomi st,st(2) ;
  145. cmovnb ecx,gD3DCS_BACK
  146. or eax,ebx
  147. mov esi,hout ; Propagate diffuse, specular, tu, tv
  148. or eax,ecx
  149. mov ebx,pmat ;
  150. mov word ptr [esi],ax ; Output clip flags
  151. mov esi,pin ;
  152. fxch st(4) ; 0 y4 w4 x4 z4
  153. fstp st ; y4 w4 x4 z4
  154. ;; Now compute the clipcodes.
  155. ; D3DVALUE xx = we - x;
  156. ; D3DVALUE yy = we - y;
  157. ; D3DVALUE zz = we - z;
  158. ; clip = ((ASINT32(x) & 0x80000000) >> (32-1)) | // D3DCS_LEFT
  159. ; ((ASINT32(y) & 0x80000000) >> (32-4)) | // D3DCS_BOTTOM
  160. ; ((ASINT32(z) & 0x80000000) >> (32-5)) | // D3DCS_FRONT
  161. ; ((ASINT32(xx) & 0x80000000) >> (32-2)) | // D3DCS_RIGHT
  162. ; ((ASINT32(yy) & 0x80000000) >> (32-3)) | // D3DCS_TOP
  163. ; ((ASINT32(zz) & 0x80000000) >> (32-6)); // D3DCS_BACK
  164. ;; actually the flags have not been touched since the final OR so we don't
  165. ;; need to test this explicitly
  166. ;; test eax,eax
  167. jnz ClipNonzero ; jump if clip flags nonzero
  168. fld1 ; 1 y w x z
  169. fdivrp st(2),st ; y w x z
  170. mov ecx,[esi+D3DTLVERTEX_color]
  171. mov edx,[esi+D3DTLVERTEX_specular]
  172. mov [ebp+D3DTLVERTEX_color],ecx
  173. mov [ebp+D3DTLVERTEX_specular],edx
  174. mov ecx,[esi+D3DTLVERTEX_tu]
  175. mov edx,[esi+D3DTLVERTEX_tv]
  176. mov [ebp+D3DTLVERTEX_tu],ecx
  177. mov [ebp+D3DTLVERTEX_tv],edx
  178. ; y w x z
  179. fabs
  180. fxch st(2)
  181. fabs
  182. fxch st(2)
  183. fmul dword ptr [ebx+D3DFE_PROCESSVERTICES_vcache+D3DFE_VIEWPORTCACHE_scaleY]
  184. fxch st(2) ;
  185. fmul dword ptr [ebx+D3DFE_PROCESSVERTICES_vcache+D3DFE_VIEWPORTCACHE_scaleX]
  186. fxch st(2) ; y w x z
  187. fmul st,st(1)
  188. fxch st(2) ; x w y z
  189. fmul st,st(1) ;
  190. fxch st(2) ; y w x z
  191. fadd dword ptr [ebx+D3DFE_PROCESSVERTICES_vcache+D3DFE_VIEWPORTCACHE_offsetY]
  192. fxch st(2) ; x w y z
  193. fadd dword ptr [ebx+D3DFE_PROCESSVERTICES_vcache+D3DFE_VIEWPORTCACHE_offsetX]
  194. fxch st(3) ; z w y x
  195. fmul st,st(1)
  196. fxch st(3) ; x w y z
  197. test dword ptr [ebx+D3DFE_PROCESSVERTICES_dwFlags], D3DDP_DONOTUPDATEEXTENTS
  198. jnz NoExtents
  199. ;; update extents rect in PV structure
  200. ; minx x w y z
  201. fld dword ptr [ebx+D3DFE_PROCESSVERTICES_rExtents+0]
  202. fcomi st,st(1)
  203. fcmovnb st,st(1)
  204. fstp dword ptr [ebx+D3DFE_PROCESSVERTICES_rExtents+0]
  205. ; maxx x w y z
  206. fld dword ptr [ebx+D3DFE_PROCESSVERTICES_rExtents+8]
  207. fcomi st,st(1)
  208. fcmovb st,st(1)
  209. fstp dword ptr [ebx+D3DFE_PROCESSVERTICES_rExtents+8]
  210. ; miny x w y z
  211. fld dword ptr [ebx+D3DFE_PROCESSVERTICES_rExtents+4]
  212. fcomi st,st(3)
  213. fcmovnb st,st(3)
  214. fstp dword ptr [ebx+D3DFE_PROCESSVERTICES_rExtents+4]
  215. ; maxy x w y z
  216. fld dword ptr [ebx+D3DFE_PROCESSVERTICES_rExtents+12]
  217. fcomi st,st(3)
  218. fcmovb st,st(3)
  219. fstp dword ptr [ebx+D3DFE_PROCESSVERTICES_rExtents+12]
  220. NoExtents:
  221. fstp dword ptr [ebp+D3DTLVERTEX_sx]
  222. fstp dword ptr [ebp+D3DTLVERTEX_rhw]
  223. fstp dword ptr [ebp+D3DTLVERTEX_sy]
  224. fstp dword ptr [ebp+D3DTLVERTEX_sz]
  225. Return:
  226. pop ebp ; Restore registers
  227. pop edi ;
  228. pop esi ;
  229. pop ebx ;
  230. add esp,24 ; Locals
  231. ret ; Return
  232. ClipNonZero:
  233. fstp dword ptr [ebp+D3DTLVERTEX_sy]
  234. fstp dword ptr [ebp+D3DTLVERTEX_rhw]
  235. fstp dword ptr [ebp+D3DTLVERTEX_sx]
  236. fstp dword ptr [ebp+D3DTLVERTEX_sz]
  237. jmp short Return
  238. _matmul6 ENDP
  239. end