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
12 KiB

  1. dnl
  2. dnl Buffer write routines are used in General and monolithic cases.
  3. dnl
  4. dnl
  5. define(`bufwriteVars',`
  6. EXTERN g_uDitherValue:MMWORD
  7. EXTERN SetAlphato0x00:MMWORD
  8. EXTERN u888to565RedBlueMask:MMWORD
  9. EXTERN u888to565GreenMask:MMWORD
  10. EXTERN u888to565Multiplier:MMWORD
  11. EXTERN uVal0x000007ff03ff07ff:MMWORD
  12. EXTERN uVal0x0000078003c00780:MMWORD
  13. EXTERN u888to555RedBlueMask:MMWORD
  14. EXTERN u888to555GreenMask:MMWORD
  15. EXTERN u888to555Multiplier:MMWORD
  16. EXTERN uVal0x000007ff07ff07ff:MMWORD
  17. EXTERN uVal0x0000078007800780:MMWORD
  18. ')
  19. dnl
  20. dnl d_BufWrite_B8G8R8X8_NoDither
  21. dnl
  22. dnl Takes $1 as Monolithic or NotMonolithic
  23. dnl
  24. define(`d_BufWrite_B8G8R8X8_NoDither',`
  25. ifelse(`$1', `Monolithic', `; ATTENTION None shouldnt have to do any copying to memory for monolithic. Surface pointer could probably stay in register')dnl
  26. ;// Must write 0 for the unspecified alpha channel to be compatible with DX5
  27. ;// for destination color keying
  28. ;UINT32 uARGB = RGBA_MAKE(pCtx->SI.uBR>>8, pCtx->SI.uBG>>8,
  29. ; pCtx->SI.uBB>>8, 0x00);
  30. mov edi, XpS(pSurface)
  31. movq mm6, XpCtxSI(uBB)
  32. psrlw mm6, 8 ; Convert color1 from 8.8 two 0.8
  33. packuswb mm6, mm7 ; pack one color
  34. pand mm6, MMWORD PTR SetAlphato0x00 ; = 0x00ffffff
  35. ;PUINT32 pSurface = (PUINT32)pS->pSurface;
  36. ;*pSurface = uARGB;
  37. movd [edi], mm6
  38. ')
  39. define(`d_BufWrite_B8G8R8A8_NoDither', `
  40. ifelse(`$1', `Monolithic', `; ATTENTION None shouldnt have to do any copying to memory for monolithic. Surface pointer could probably stay in register')dnl
  41. ;UINT32 uARGB = RGBA_MAKE(pCtx->SI.uBR>>8, pCtx->SI.uBG>>8,
  42. ; pCtx->SI.uBB>>8, pCtx->SI.uBA>>8);
  43. mov edi, XpS(pSurface)
  44. movq mm6, XpCtxSI(uBB)
  45. psrlw mm6, 8 ; Convert color1 from 8.8 two 0.8
  46. packuswb mm6, mm7 ; pack one color
  47. ;PUINT32 pSurface = (PUINT32)pS->pSurface;
  48. ;*pSurface = uARGB;
  49. movd [edi], mm6
  50. ')
  51. define(`d_BufWrite_B5G6R5_NoDither', `
  52. ifelse(`$1', `Monolithic', `; ATTENTION None shouldnt have to do any copying to memory for monolithic. Surface pointer could probably stay in register')dnl
  53. ;*(PUINT16)pS->pSurface =
  54. ; ((pCtx->SI.uBR >> 0) & 0xf800) |
  55. ; ((pCtx->SI.uBG >> 5) & 0x07e0) |
  56. ; ((pCtx->SI.uBB >> 11) & 0x001f);
  57. mov edi, XpS(pSurface)
  58. movq mm6, XpCtxSI(uBB)
  59. psrlw mm6, 8 ; Convert color1 from 8.8 two 0.8
  60. packuswb mm6, mm7 ; pack one color
  61. movq mm3, mm6
  62. pand mm6, MMWORD PTR u888to565RedBlueMask
  63. pmaddwd mm6, MMWORD PTR u888to565Multiplier
  64. pand mm3, MMWORD PTR u888to565GreenMask
  65. por mm6, mm3
  66. psrld mm6, 5
  67. movd edx, mm6
  68. mov [edi], dx
  69. ')
  70. define(`d_BufWrite_B5G6R5_Dither', `
  71. ifelse(`$1', `Monolithic', `; ATTENTION None shouldnt have to do any copying to memory for monolithic. Surface pointer could probably stay in register')dnl
  72. ;UINT16 uDither = uDitherTable[pCtx->SI.uDitherOffset];
  73. ; do xor twice
  74. ;UINT16 uB = pCtx->SI.uBB >> 3; ; 8.8 >> 3 = 8.5 really 5.8
  75. ;UINT16 uG = pCtx->SI.uBG >> 2; ; 8.8 >> 2 = 8.6 really 6.8
  76. ;UINT16 uR = pCtx->SI.uBR >> 3; ; 8.8 >> 3 = 8.5 really 5.8
  77. movq mm3, MMWORD PTR g_uDitherValue
  78. movq mm2, XpCtxSI(uBB)
  79. movq mm1, mm2
  80. pand mm2, MMWORD PTR uVal0x0000078003c00780 ; Mask off bits to test dither value against.
  81. ; Turn on all lower bits of colors with ones. This will make incrementing
  82. ; easier. If I add one to the low bit, they will all flip and one
  83. ; will be added to the correct location.
  84. por mm1, MMWORD PTR uVal0x000007ff03ff07ff
  85. ;uB = min((uB >> 8) + ((uB & 0xff) > uDither), 0x1f);
  86. ;uG = min((uG >> 8) + ((uG & 0xff) > uDither), 0x3f);
  87. ;uR = min((uR >> 8) + ((uR & 0xff) > uDither), 0x1f);
  88. pcmpgtw mm2, mm3
  89. psrlw mm2, 15
  90. paddusw mm1, mm2
  91. ;*(PUINT16)pS->pSurface = uB | (uG << 5) | (uR << 11);
  92. ; Do color conversion the same as other 565 case.
  93. mov edi, XpS(pSurface)
  94. psrlw mm1, 8 ; Convert color1 from 8.8 two 0.8
  95. packuswb mm1, mm7 ; pack one color
  96. movq mm3, mm1
  97. pand mm1, MMWORD PTR u888to565RedBlueMask
  98. pmaddwd mm1, MMWORD PTR u888to565Multiplier
  99. pand mm3, MMWORD PTR u888to565GreenMask
  100. por mm1, mm3
  101. psrld mm1, 5
  102. movd edx, mm1
  103. mov [edi], dx
  104. ')
  105. define(`d_BufWrite_B5G5R5_NoDither', `
  106. ifelse(`$1', `Monolithic', `; ATTENTION None shouldnt have to do any copying to memory for monolithic. Surface pointer could probably stay in register')dnl
  107. ;// Must write 0 for the unspecified alpha channel to be compatible with DX5
  108. ;// for destination color keying
  109. ;*(PUINT16)pS->pSurface =
  110. ; ((pCtx->SI.uBR >> 1) & 0x7c00) |
  111. ; ((pCtx->SI.uBG >> 6) & 0x03e0) |
  112. ; ((pCtx->SI.uBB >> 11) & 0x001f);
  113. mov edi, XpS(pSurface)
  114. movq mm6, XpCtxSI(uBB)
  115. psrlw mm6, 8 ; Convert color1 from 8.8 two 0.8
  116. packuswb mm6, mm7 ; pack one color
  117. movq mm3, mm6
  118. pand mm6, MMWORD PTR u888to555RedBlueMask
  119. pmaddwd mm6, MMWORD PTR u888to555Multiplier
  120. pand mm3, MMWORD PTR u888to555GreenMask
  121. por mm6, mm3
  122. psrld mm6, 6
  123. movd edx, mm6
  124. mov [edi], dx
  125. ')
  126. define(`d_BufWrite_B5G5R5_Dither', `
  127. ifelse(`$1', `Monolithic', `; ATTENTION None shouldnt have to do any copying to memory for monolithic. Surface pointer could probably stay in register')dnl
  128. ;UINT16 uDither = uDitherTable[pCtx->SI.uDitherOffset];
  129. ;UINT16 uB = pCtx->SI.uBB >> 3; ; 8.8 >> 3 = 8.5
  130. ;UINT16 uG = pCtx->SI.uBG >> 3;
  131. ;UINT16 uR = pCtx->SI.uBR >> 3;
  132. movq mm3, MMWORD PTR g_uDitherValue
  133. movq mm2, XpCtxSI(uBB)
  134. movq mm1, mm2
  135. pand mm2, MMWORD PTR uVal0x0000078007800780 ; Mask off bits to test dither value against.
  136. ; Turn on all lower bits of colors with ones. This will make incrementing
  137. ; easier. If I add one to the low bit, they will all flip and one
  138. ; will be added to the correct location.
  139. por mm1, MMWORD PTR uVal0x000007ff07ff07ff
  140. ;uB = min((uB >> 8) + ((uB & 0xff) > uDither), 0x1f);
  141. ;uG = min((uG >> 8) + ((uG & 0xff) > uDither), 0x1f);
  142. ;uR = min((uR >> 8) + ((uR & 0xff) > uDither), 0x1f);
  143. pcmpgtw mm2, mm3
  144. psrlw mm2, 15
  145. paddusw mm1, mm2
  146. ;// Must write 0 for the unspecified alpha channel to be compatible with DX5
  147. ;// for destination color keying
  148. ;*(PUINT16)pS->pSurface = uB | (uG << 5) | (uR << 10);
  149. ; Do normal color conversion code here
  150. mov edi, XpS(pSurface)
  151. psrlw mm1, 8 ; Convert color1 from 8.8 two 0.8
  152. packuswb mm1, mm7 ; pack one color
  153. movq mm3, mm1
  154. pand mm1, MMWORD PTR u888to555RedBlueMask
  155. pmaddwd mm1, MMWORD PTR u888to555Multiplier
  156. pand mm3, MMWORD PTR u888to555GreenMask
  157. por mm1, mm3
  158. psrld mm1, 6
  159. movd edx, mm1
  160. mov [edi], dx
  161. ')
  162. define(`d_BufWrite_B5G5R5A1_NoDither', `
  163. ifelse(`$1', `Monolithic', `; ATTENTION None shouldnt have to do any copying to memory for monolithic. Surface pointer could probably stay in register')dnl
  164. ;*(PUINT16)pS->pSurface =
  165. ; ((pCtx->SI.uBR >> 1) & 0x7c00) |
  166. ; ((pCtx->SI.uBG >> 6) & 0x03e0) |
  167. ; ((pCtx->SI.uBB >> 11) & 0x001f) |
  168. ; 0x8000;
  169. mov edi, XpS(pSurface)
  170. movq mm6, XpCtxSI(uBB)
  171. psrlw mm6, 8 ; Convert color1 from 8.8 two 0.8
  172. packuswb mm6, mm7 ; pack one color
  173. movq mm3, mm6
  174. pand mm6, MMWORD PTR u888to555RedBlueMask
  175. pmaddwd mm6, MMWORD PTR u888to555Multiplier
  176. pand mm3, MMWORD PTR u888to555GreenMask
  177. por mm6, mm3
  178. psrld mm6, 6
  179. movzx eax, word ptr XpCtxSI(uBA)
  180. movd edx, mm6
  181. and eax, 08000h
  182. or edx, eax
  183. mov [edi], dx
  184. ')
  185. define(`d_BufWrite_B5G5R5A1_Dither', `
  186. ifelse(`$1', `Monolithic', `; ATTENTION None shouldnt have to do any copying to memory for monolithic. Surface pointer could probably stay in register')dnl
  187. ;UINT16 uDither = uDitherTable[pCtx->SI.uDitherOffset];
  188. ;UINT16 uB = pCtx->SI.uBB >> 3; ; 8.8 >> 3 = 8.5
  189. ;UINT16 uG = pCtx->SI.uBG >> 3;
  190. ;UINT16 uR = pCtx->SI.uBR >> 3;
  191. movq mm3, MMWORD PTR g_uDitherValue
  192. movq mm2, XpCtxSI(uBB)
  193. movq mm1, mm2
  194. pand mm2, MMWORD PTR uVal0x0000078007800780 ; Mask off bits to test dither value against.
  195. ; Turn on all lower bits of colors with ones. This will make incrementing
  196. ; easier. If I add one to the low bit, they will all flip and one
  197. ; will be added to the correct location.
  198. por mm1, MMWORD PTR uVal0x000007ff07ff07ff
  199. ;uB = min((uB >> 8) + ((uB & 0xff) > uDither), 0x1f);
  200. ;uG = min((uG >> 8) + ((uG & 0xff) > uDither), 0x1f);
  201. ;uR = min((uR >> 8) + ((uR & 0xff) > uDither), 0x1f);
  202. pcmpgtw mm2, mm3
  203. psrlw mm2, 15
  204. paddusw mm1, mm2
  205. ;*(PUINT16)pS->pSurface = uB | (uG << 5) | (uR << 10) | 0x8000;
  206. ; Do normal color conversion code here
  207. mov edi, XpS(pSurface)
  208. psrlw mm1, 8 ; Convert color1 from 8.8 two 0.8
  209. packuswb mm1, mm7 ; pack one color
  210. movq mm3, mm1
  211. pand mm1, MMWORD PTR u888to555RedBlueMask
  212. pmaddwd mm1, MMWORD PTR u888to555Multiplier
  213. pand mm3, MMWORD PTR u888to555GreenMask
  214. por mm1, mm3
  215. psrld mm1, 6
  216. movzx eax, word ptr XpCtxSI(uBA)
  217. movd edx, mm1
  218. and eax, 08000h
  219. or edx, eax
  220. mov [edi], dx
  221. ')
  222. define(`d_BufWrite_B8G8R8_NoDither', `
  223. ifelse(`$1', `Monolithic', `; ATTENTION None shouldnt have to do any copying to memory for monolithic. Surface pointer could probably stay in register')dnl
  224. ;PUINT8 pSurface = (PUINT8)pS->pSurface;
  225. ;*pSurface++ = pCtx->SI.uBB>>8;
  226. ;*pSurface++ = pCtx->SI.uBG>>8;
  227. ;*pSurface++ = pCtx->SI.uBR>>8;
  228. mov edi, XpS(pSurface)
  229. movq mm6, XpCtxSI(uBB)
  230. psrlw mm6, 8 ; Convert color1 from 8.8 two 0.8
  231. packuswb mm6, mm6
  232. movd eax, mm6
  233. mov [edi], al
  234. inc edi
  235. mov [edi], ah
  236. inc edi
  237. shr eax, 16
  238. mov [edi], al
  239. ')
  240. define(`d_BufWrite_Palette8_Dither', `
  241. ifelse(`$1', `Monolithic', `; ATTENTION None shouldnt have to do any copying to memory for monolithic. Surface pointer could probably stay in register')dnl
  242. mov edi, XpS(pSurface)
  243. ;UINT16 uMapIdx = MAKE_RGB8(pCtx->SI.uBR>>8, pCtx->SI.uBG>>8, pCtx->SI.uBB>>8);
  244. movq mm6, XpCtxSI(uBB)
  245. psrlw mm6, 8 ; Convert color1 from 8.8 two 0.8
  246. ; These 3 lines do RGB8_Channel conversion. [0, 0xff] to [0, 5]
  247. pmullw mm6, MMWORD PTR Val0x000500050005
  248. paddw mm6, MMWORD PTR Val0x008000800080
  249. psrlw mm6, 8
  250. ; These 5 lines do Make_RGB8 which creates a pointer to a lookup table.
  251. pmaddwd mm6, MMWORD PTR Val0x002400060001 ; this is basically 0, 36, 6 and 1
  252. movq mm7, mm6
  253. psrlq mm6, 32
  254. paddd mm7, mm6
  255. movd eax, mm7
  256. shl eax, 2 ; pRampMap table is table of DWORDs
  257. ;*(PUINT8)pS->pSurface = (UINT8)(pCtx->pRampMap[uMapIdx]);
  258. add eax, XpCtx(pRampMap)
  259. mov al, [eax]
  260. mov [edi], al
  261. ')