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.

346 lines
8.5 KiB

  1. ;-----------------------------------------------------------------------------
  2. ;
  3. ; Monolith 26. Non-Perspective Correct Nearest Gouraud Modulated
  4. ; NO Z buffer X888.
  5. ;
  6. ; Exactly the same as monolith 5 except color input is 32 bits and
  7. ; output is 32 bits and no Z buffer code
  8. ;
  9. ;-----------------------------------------------------------------------------
  10. INCLUDE iammx.inc
  11. INCLUDE offs_acp.inc
  12. ;TBD check to see if this value is correct.
  13. COLOR_SHIFT equ 8
  14. .586
  15. .model flat
  16. ; Big seperating lines seperate code into span code
  17. ; and loop code. If span and loop are not going to
  18. ; end up being combined then it will be easy to
  19. ; seperate the code.
  20. .data
  21. ; Need externs for all of the variables that are needed for various beads
  22. EXTERN IncHighandLow16:MMWORD
  23. EXTERN UFracVFracMask:MMWORD
  24. EXTERN UV32to15Mask:MMWORD
  25. EXTERN Makelow16one:MMWORD
  26. EXTERN MaskKeepUValues:MMWORD
  27. EXTERN MaskKeepVValues:MMWORD
  28. EXTERN UFrac:MMWORD
  29. EXTERN VFrac:MMWORD
  30. EXTERN Zero:MMWORD
  31. EXTERN memD3DTFG_POINT:MMWORD
  32. EXTERN GiveUp:MMWORD
  33. EXTERN LastW:MMWORD
  34. EXTERN Val0x000a000a:MMWORD
  35. EXTERN Val0xffff:MMWORD
  36. EXTERN Val0x0000002000000020:MMWORD
  37. EXTERN Val0x0000ffff0000ffff:MMWORD
  38. opt_MaskRed565to888 MMWORD 000000000000F800H
  39. EXTERN MaskRed565to888:MMWORD
  40. EXTERN MaskGreen565to888:MMWORD
  41. EXTERN MaskBlue565to888:MMWORD
  42. EXTERN MaskRed555to888:MMWORD
  43. EXTERN MaskGreen555to888:MMWORD
  44. EXTERN MaskBlue555to888:MMWORD
  45. EXTERN MaskAlpha1555to8888:MMWORD
  46. EXTERN MaskRed1555to8888:MMWORD
  47. EXTERN MaskGreen1555to8888:MMWORD
  48. EXTERN MaskBlue1555to8888:MMWORD
  49. ; TBD. I think that I want to do 0xffff instead of 0xff. This will
  50. ; have to be checked. There is a value very similiar to this in
  51. ; buf write.
  52. EXTERN SetAlphato0xffff:MMWORD
  53. EXTERN SetAlphato0xff:MMWORD
  54. ; TODO This equate are identical to the ones in texread.mas. Maybe they should be in a common .inc file.
  55. RedShift565to888 equ 8
  56. GreenShift565to888 equ 5
  57. BlueShift565to888 equ 3
  58. RedShift555to888 equ 9
  59. GreenShift555to888 equ 6
  60. BlueShift555to888 equ 3
  61. AlphaShift1555to8888 equ 16
  62. RedShift1555to8888 equ 9
  63. GreenShift1555to8888 equ 6
  64. BlueShift1555to8888 equ 3
  65. EXTERN Zero:MMWORD
  66. EXTERN DW_One_One:MMWORD
  67. EXTERN MaskOffAlpha:MMWORD
  68. EXTERN ShiftTA:MMWORD
  69. EXTERN Val0x00ff00ff00ff00ff:MMWORD
  70. EXTERN Val0x000000ff00ff00ff:MMWORD
  71. EXTERN Val0X0000000001000000:MMWORD
  72. EXTERN AlphaVal128:MMWORD
  73. EXTERN RGBVal128:MMWORD
  74. EXTERN g_uDitherValue:MMWORD
  75. EXTERN SetAlphato0xff:MMWORD
  76. EXTERN u888to565RedBlueMask:MMWORD
  77. EXTERN u888to565GreenMask:MMWORD
  78. EXTERN u888to565Multiplier:MMWORD
  79. EXTERN uVal0x000007ff03ff07ff:MMWORD
  80. EXTERN uVal0x0000078003c00780:MMWORD
  81. EXTERN u888to555RedBlueMask:MMWORD
  82. EXTERN u888to555GreenMask:MMWORD
  83. EXTERN u888to555Multiplier:MMWORD
  84. EXTERN uVal0x000007ff07ff07ff:MMWORD
  85. EXTERN uVal0x0000078007800780:MMWORD
  86. ;-----------------------------------------------------------------------------
  87. ; Span Variables
  88. StackPos dd ?
  89. uSpans dd ?
  90. ;-----------------------------------------------------------------------------
  91. ;-----------------------------------------------------------------------------
  92. ; Loop Variables
  93. iSurfaceStep dd ?
  94. uPix dd ?
  95. ;-----------------------------------------------------------------------------
  96. .code
  97. PUBLIC _MMXMLRast_26
  98. _MMXMLRast_26:
  99. push ebp
  100. mov StackPos, esp
  101. mov eax, esp
  102. sub esp, 0Ch ; This will need to change if stack frame size changes.
  103. push ebx
  104. push esi
  105. push edi
  106. ; Put pCtx into ebx
  107. mov ebx, [eax+8]
  108. ;PD3DI_RASTPRIM pP = pCtx->pPrim;
  109. mov ecx, [ebx+RASTCTX_pPrim]
  110. ;while (pP)
  111. ;{
  112. PrimLoop:
  113. cmp ecx, 0
  114. je ExitPrimLoop
  115. ;UINT16 uSpans = pP->uSpans;
  116. movzx eax, word ptr [ecx+RASTPRIM_uSpans]
  117. mov uSpans, eax
  118. ;PD3DI_RASTSPAN pS = (PD3DI_RASTSPAN)(pP + 1);
  119. mov ebp, ecx
  120. add ebp, SIZEOF_RASTPRIM
  121. ;while (uSpans-- > 0)
  122. ;{
  123. SpanLoop:
  124. mov edx, uSpans
  125. mov eax, edx
  126. dec eax
  127. mov uSpans, eax
  128. test edx, edx
  129. jle ExitSpanLoop
  130. ;pCtx->pfnBegin(pCtx, pP, pS);
  131. ;-----------------------------------------------------------------------------
  132. ; LoopAny code inserted here. This is to get rid of an extra
  133. ; jump.
  134. ;-----------------------------------------------------------------------------
  135. ; Setup Code begins
  136. movzx eax, word ptr [ebp+RASTSPAN_uPix]
  137. mov uPix, eax
  138. movq mm5, [ebp+RASTSPAN_iUoW1]
  139. psrad mm5, TEX_TO_FINAL_SHIFT
  140. movq [ebx+RASTCTX_SI+SPANITER_iU1], mm5
  141. ;pCtx->SI.iU2 = pS->iUoW2>>TEX_TO_FINAL_SHIFT;
  142. ;pCtx->SI.iV2 = pS->iVoW2>>TEX_TO_FINAL_SHIFT;
  143. ;movq mm5, [ebp+RASTSPAN_iUoW2]
  144. ;pCtx->SI.iDW = 0x0;
  145. mov dword ptr [ebx+RASTCTX_SI+SPANITER_iDW], 0
  146. ;pCtx->SI.iSpecialW = 0;
  147. mov word ptr [ebx+RASTCTX_SI+SPANITER_iSpecialW], 0
  148. ; -----
  149. ;if (pP->uFlags & D3DI_RASTPRIM_X_DEC)
  150. ;{
  151. mov eax, [ecx+RASTPRIM_uFlags]
  152. and eax, D3DI_RASTPRIM_X_DEC
  153. test eax, eax
  154. jz LeftToRightSpan
  155. ;iSurfaceStep = -pCtx->iSurfaceStep;
  156. mov eax, [ebx+RASTCTX_iSurfaceStep]
  157. neg eax
  158. mov iSurfaceStep, eax
  159. ;}
  160. jmp DoneSpanDirif
  161. ;else
  162. ;{
  163. LeftToRightSpan:
  164. ;iSurfaceStep = pCtx->iSurfaceStep;
  165. mov eax, [ebx+RASTCTX_iSurfaceStep]
  166. mov iSurfaceStep, eax
  167. ;}
  168. DoneSpanDirif:
  169. movq mm6, [ebp+RASTSPAN_uB]
  170. ; Setup Code Ends
  171. ; ----------------------------------------------------------------------------------------------------------------
  172. ; Loop Code Begins
  173. PixelLoop:
  174. ; texturecode
  175. mov esi, [ebx+RASTCTX_pTexture]
  176. movq mm5, MMWORD PTR Val0x000a000a ; This is TEX_FINAL_SHIFT - 6 = 10.
  177. movd mm4, [esi+SPANTEX_iShiftU]
  178. psubw mm5, mm4
  179. movq mm4, mm5
  180. pand mm5, MMWORD PTR Val0xffff
  181. psrld mm4, 16
  182. movd mm1, [ebx+RASTCTX_SI+SPANITER_iU1]
  183. psrad mm1, mm5
  184. movd mm2, [ebx+RASTCTX_SI+SPANITER_iV1]
  185. psrad mm2, mm4
  186. punpckldq mm1, mm2
  187. movzx edx, word ptr [esi+SPANTEX_iShiftPitch]
  188. add edx, 16
  189. movd mm2, edx
  190. movq mm5, MMWORD ptr Makelow16one
  191. pslld mm5, mm2
  192. por mm5, MMWORD ptr Makelow16one
  193. psrad mm1, 6
  194. packssdw mm1, mm1 ; Value needs to be packed since all wrap/mirror
  195. movd mm0, [esi+SPANTEX_uMaskU] ; Load U and V mask
  196. movq mm7, mm1
  197. movd mm4, [esi+SPANTEX_iFlipMaskU]
  198. pand mm7, mm4
  199. pcmpeqw mm7, MMWORD PTR Zero
  200. pandn mm7, mm0
  201. pand mm1, mm0
  202. pxor mm1, mm7
  203. movq mm4, mm1
  204. pmaddwd mm4, mm5 ; Throw in first address calculation.
  205. mov edi, [esi+SPANTEX_pBits]
  206. movd eax, mm4
  207. pxor mm1, mm1
  208. movd mm2, dword ptr [edi+4*eax]
  209. punpcklbw mm2, mm1
  210. ;modulate
  211. movq mm1, mm6
  212. psrlw mm1, COLOR_SHIFT ; COLOR_SHIFT is set to 8.
  213. pmullw mm1, mm2
  214. ;write
  215. mov edi, [ebp+RASTSPAN_pSurface]
  216. psrlw mm1, 8 ; Convert color1 from 8.8 two 0.8
  217. packuswb mm1, mm7 ; pack one color
  218. movd edx, mm1
  219. and edx, 000ffffffh
  220. mov [edi], edx
  221. dec uPix
  222. jle ExitPixelLoop
  223. ; Keeping uB in MM6 so that dont need to store back and forth from memory.
  224. paddw mm6, [ecx+RASTPRIM_iDBDX]
  225. movq mm5, [ebp+RASTSPAN_iUoW1]
  226. paddd mm5, [ecx+RASTPRIM_iDUoW1DX]
  227. movq [ebp+RASTSPAN_iUoW1], mm5
  228. psrad mm5, TEX_TO_FINAL_SHIFT
  229. movq [ebx+RASTCTX_SI+SPANITER_iU1], mm5
  230. mov edx, dword ptr [ebp+RASTSPAN_pSurface]
  231. add edx, iSurfaceStep
  232. mov dword ptr [ebp+RASTSPAN_pSurface], edx
  233. jmp PixelLoop
  234. ExitPixelLoop:
  235. ; Loop code ends
  236. ;-----------------------------------------------------------------------------
  237. ; LoopAny code ends here
  238. ;-----------------------------------------------------------------------------
  239. add ebp, SIZEOF_RASTSPAN
  240. jmp SpanLoop
  241. ExitSpanLoop:
  242. mov ecx, [ecx+RASTPRIM_pNext]
  243. jmp PrimLoop
  244. ExitPrimLoop:
  245. emms
  246. xor eax, eax
  247. pop edi
  248. pop esi
  249. pop ebx
  250. mov esp, StackPos
  251. pop ebp
  252. ret
  253. END