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.

251 lines
7.0 KiB

  1. ;-----------------------------------------------------------------------------
  2. ;
  3. ; This file contains the output buffer color reading routines for Blending.
  4. ;
  5. ; Have pBits passed in as eax for now. Color value returned in mm1.
  6. ; returns 16 bits for each color channel, but only lower eight are used. This is
  7. ; so that the I can use pmullw multiplies in the blending code.
  8. ;
  9. ; These routines could all loose the punpck instruction by shifting to the correct
  10. ; location. This wouldnt save alot but it could be done. Texread rouines
  11. ; could not do that because of colorkey case.
  12. ;
  13. ;
  14. ;-----------------------------------------------------------------------------
  15. include(`texread.mh')dnl
  16. .586
  17. .model flat
  18. .code
  19. INCLUDE iammx.inc
  20. INCLUDE offs_acp.inc
  21. texreadVars()
  22. ; Names are read LSB to MSB, so B5G6R5 means five bits of blue starting
  23. ; at the LSB, then six bits of green, then five bits of red.
  24. ;-----------------------------------------------------------------------------
  25. ;
  26. ; Read_B8G8R8
  27. ;
  28. ; Reads output buffer in BGR-888 format.
  29. ;
  30. ;-----------------------------------------------------------------------------
  31. ;D3DCOLOR Read_B8G8R8(PUINT8 pBits)
  32. ;{
  33. PUBLIC _MMX_BufRead_B8G8R8
  34. _MMX_BufRead_B8G8R8:
  35. ;PUINT32 pSurface = (PUINT32)pBits;
  36. movzx edx, byte ptr [eax+1]
  37. or dh, byte ptr [eax+2]
  38. movzx eax, byte ptr [eax]
  39. shl edx, 8
  40. or edx, eax
  41. ;return *pSurface | 0xff000000;
  42. or edx, 0ff000000h
  43. movd mm1, edx
  44. pxor mm2, mm2 ; Zero out mm1 for unpacking
  45. punpcklbw mm1, mm2
  46. ret
  47. ;}
  48. ;-----------------------------------------------------------------------------
  49. ;
  50. ; Read_B8G8R8X8
  51. ;
  52. ; Reads output buffer in BGR-888x format.
  53. ;
  54. ;-----------------------------------------------------------------------------
  55. ;D3DCOLOR Read_B8G8R8X8(PUINT8 pBits)
  56. ;{
  57. PUBLIC _MMX_BufRead_B8G8R8X8
  58. _MMX_BufRead_B8G8R8X8:
  59. ;PUINT32 pSurface = (PUINT32)pBits;
  60. movd mm1, dword ptr [eax]
  61. ;return *pSurface | 0xff000000;
  62. por mm1, MMWORD PTR SetAlphaTo0xFF
  63. pxor mm2, mm2 ; Zero out mm1 for unpacking
  64. punpcklbw mm1, mm2
  65. ret
  66. ;}
  67. ;-----------------------------------------------------------------------------
  68. ;
  69. ; Read_B8G8R8A8
  70. ;
  71. ; Reads output in BGRA-8888 format.
  72. ;
  73. ;-----------------------------------------------------------------------------
  74. ;D3DCOLOR Read_B8G8R8A8(PUINT8 pBits)
  75. ;{
  76. PUBLIC _MMX_BufRead_B8G8R8A8
  77. _MMX_BufRead_B8G8R8A8:
  78. ;PUINT32 pSurface = (PUINT32)pBits;
  79. movd mm1, dword ptr [eax]
  80. ;return *pSurface;
  81. pxor mm2, mm2 ; Zero out mm1 for unpacking
  82. punpcklbw mm1, mm2
  83. ret
  84. ;}
  85. ;-----------------------------------------------------------------------------
  86. ;
  87. ; Read_B5G6R5
  88. ;
  89. ; Reads output in BGR-565 format.
  90. ;
  91. ;-----------------------------------------------------------------------------
  92. ;D3DCOLOR Read_B5G6R5(PUINT8 pBits)
  93. ;{
  94. PUBLIC _MMX_BufRead_B5G6R5
  95. _MMX_BufRead_B5G6R5:
  96. ;UINT16 uPixel = *(PUINT16)pBits;
  97. movzx eax, word ptr [eax]
  98. ;D3DCOLOR Color = RGBA_MAKE(( uPixel >> 8 ) & 0xf8,
  99. ; (( uPixel >> 3) & 0xfc ),
  100. ; (( uPixel << 3) & 0xf8 ),
  101. ; 0xff);
  102. movd mm1, eax ; Make two more copies of input color
  103. movq mm2, mm1 ; Could possibly use eax to shift blue.
  104. pand mm1, MaskGreen565to888 ; MaskGreen565to888 is in memory
  105. psllq mm2, RedShift565to888 ; RedShift should be an immediate
  106. pand mm2, MaskRed565to888 ; MaskRed565to888 in memory.
  107. psllq mm1, GreenShift565to888
  108. shl eax, BlueShift565to888
  109. por mm1, mm2
  110. and eax, MaskBlue565to888
  111. movd mm2, eax
  112. por mm1, SetAlphato0xFF
  113. por mm1, mm2
  114. pxor mm2, mm2 ; Zero out mm1 for unpacking.
  115. punpcklbw mm1, mm2
  116. ;return Color;
  117. ret
  118. ;}
  119. ;-----------------------------------------------------------------------------
  120. ;
  121. ; Read_B5G5R5
  122. ;
  123. ; Reads output in BGR-555 format.
  124. ;
  125. ;-----------------------------------------------------------------------------
  126. ;D3DCOLOR Read_B5G5R5(PUINT8 pBits)
  127. ;{
  128. PUBLIC _MMX_BufRead_B5G5R5
  129. _MMX_BufRead_B5G5R5:
  130. ;UINT16 uPixel = *(PUINT16)pBits;
  131. movzx eax, word ptr [eax]
  132. ;D3DCOLOR Color = RGBA_MAKE(( uPixel >> 7 ) & 0xf8,
  133. ; (( uPixel >> 2) & 0xf8 ),
  134. ; (( uPixel << 3) & 0xf8 ),
  135. ; 0xff);
  136. movd mm1, eax ; Make two more copies of input color
  137. movq mm2, mm1
  138. pand mm1, MaskGreen555to888 ; MaskGreen555to888 is in memory
  139. psllq mm2, RedShift555to888 ; RedShift should be an immediate
  140. pand mm2, MaskRed555to888 ; MaskRed555to888 in memory.
  141. psllq mm1, GreenShift555to888
  142. shl eax, BlueShift555to888
  143. por mm1, mm2
  144. and eax, MaskBlue555to888
  145. movd mm2, eax
  146. por mm1, SetAlphato0xFF
  147. por mm1, mm2
  148. pxor mm2, mm2 ; Zero out mm1 for unpacking
  149. punpcklbw mm1, mm2
  150. ;return Color;
  151. ret
  152. ;}
  153. ;-----------------------------------------------------------------------------
  154. ;
  155. ; Read_B5G5R5A1
  156. ;
  157. ; Reads output in BGRA-1555 format.
  158. ;
  159. ;-----------------------------------------------------------------------------
  160. ;D3DCOLOR Read_B5G5R5A1(PUINT8 pBits)
  161. ;{
  162. PUBLIC _MMX_BufRead_B5G5R5A1
  163. _MMX_BufRead_B5G5R5A1:
  164. ;UINT16 iPixel = *(PINT16)pBits;
  165. movzx eax, word ptr [eax]
  166. ;D3DCOLOR Color = RGBA_MAKE(( iPixel >> 7 ) & 0xf8,
  167. ; (( iPixel >> 2) & 0xf8 ),
  168. ; (( iPixel << 3) & 0xf8 ),
  169. ; (iPixel >> 15) & 0xff);
  170. movd mm1, eax ; Make two more copies of input color
  171. movq mm2, mm1
  172. mov edx, eax
  173. pand mm1, MaskAlpha1555to8888 ; MaskAlpha1555to8888 is in memory
  174. psllq mm2, RedShift1555to8888 ; RedShift should be an immediate
  175. pand mm2, MaskRed1555to8888 ; MaskRed1555to8888 in memory.
  176. psllq mm1, AlphaShift1555to8888 ; shift bit to top of dword
  177. psrad mm1, 7 ; copy bit to upper 8 bits.
  178. shl eax, BlueShift1555to8888
  179. por mm1, mm2
  180. shl edx, GreenShift1555to8888
  181. and eax, MaskBlue1555to8888
  182. movd mm2, eax
  183. por mm1, mm2
  184. and edx, MaskGreen1555to8888
  185. movd mm2, edx
  186. por mm1, mm2
  187. pxor mm2, mm2 ; Zero out mm1 for unpacking
  188. punpcklbw mm1, mm2
  189. ;return Color;
  190. ret
  191. ;}
  192. ;-----------------------------------------------------------------------------
  193. ;
  194. ; Read_Palette8
  195. ;
  196. ; Reads output buffer in Palette8 format.
  197. ;
  198. ;-----------------------------------------------------------------------------
  199. ;D3DCOLOR Read_Palette8(PUINT8 pBits)
  200. ;{
  201. PUBLIC _MMX_BufRead_Palette8
  202. _MMX_BufRead_Palette8:
  203. ; Always return 0.
  204. ; ATTENTION - This is not correct. But We assume Palette8 format will
  205. ; normally not be used for alpha blending.
  206. pxor mm1, mm1
  207. ret
  208. ;}
  209. END