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.

701 lines
20 KiB

  1. ; Names are read LSB to MSB, so B5G6R5 means five bits of blue starting
  2. ; at the LSB, then six bits of green, then five bits of red.
  3. dnl
  4. dnl Texture read routine have texture address passed as edi. The offset into that
  5. dnl is passed as eax. Output is mm1 in 8.8 for each color channel. For border
  6. dnl mm0 is used to pass sign information of iU and iV. Each word contains a
  7. dnl UV pair so that all 4 values for bilinear can be stored in mm0.
  8. dnl
  9. dnl The only free registers are MM1 and MM2. EAX is free after texture is read and
  10. dnl edx is free after DoBorder macro. Any other register useage will cause problems
  11. dnl and even exceptions.
  12. dnl
  13. dnl
  14. define(`texreadVars', `
  15. EXTERN MaskRed565to888:MMWORD
  16. EXTERN MaskGreen565to888:MMWORD
  17. EXTERN MaskBlue565to888:MMWORD
  18. EXTERN MaskRed555to888:MMWORD
  19. EXTERN MaskGreen555to888:MMWORD
  20. EXTERN MaskBlue555to888:MMWORD
  21. EXTERN MaskAlpha1555to8888:MMWORD
  22. EXTERN MaskRed1555to8888:MMWORD
  23. EXTERN MaskGreen1555to8888:MMWORD
  24. EXTERN MaskBlue1555to8888:MMWORD
  25. ; TBD. I think that I want to do 0xffff instead of 0xff. This will
  26. ; have to be checked. There is a value very similiar to this in
  27. ; buf write.
  28. EXTERN SetAlphato0xffff:MMWORD
  29. EXTERN SetAlphato0xff:MMWORD
  30. ; TODO This equate are identical to the ones in texread.mas. Maybe they should be in a common .inc file.
  31. RedShift565to888 equ 8
  32. GreenShift565to888 equ 5
  33. BlueShift565to888 equ 3
  34. RedShift555to888 equ 9
  35. GreenShift555to888 equ 6
  36. BlueShift555to888 equ 3
  37. AlphaShift1555to8888 equ 16
  38. RedShift1555to8888 equ 9
  39. GreenShift1555to8888 equ 6
  40. BlueShift1555to8888 equ 3
  41. EXTERN Zero:MMWORD
  42. ')
  43. dnl
  44. dnl d_DoTex
  45. dnl
  46. dnl Calls the macro in $1 with all options to generate differentiated texture
  47. dnl read functions. Specifies that all of these are Not Monolithic.
  48. dnl Monolithic cases will need to call routines by themselves and specify border and colorkey options.
  49. dnl
  50. define(`d_DoTex', `d_Null($1(NoBorder, NoColorKey, NotMonolithic))
  51. d_Null($1(NoBorder, ColorKey, NotMonolithic))
  52. d_Null($1(Border, NoColorKey, NotMonolithic))
  53. d_Null($1(Border, ColorKey, NotMonolithic))')dnl
  54. dnl
  55. dnl d_DoBorder
  56. dnl
  57. dnl Inserts conditional border code
  58. dnl
  59. define(`d_DoBorder', `ifelse(`$1', `NoBorder', `
  60. ; Generate Border Mask to always be true in non border case.
  61. ;pcmpeqd mm5, mm5
  62. ', `
  63. ; Generate Border Mask based on if statement.
  64. ;if ((iU < 0) || (iV < 0))
  65. ;{
  66. ; Are branches bad enough to do all of this code?
  67. ; Address ends up negative when were supposed to set the border color.
  68. ; Generate mask based on sign bit.
  69. movq mm5, mm0
  70. psrlq mm0, 16 ; Shift iu iv values for next border case. This is only useful in bilinear
  71. pand mm5, MMWORD PTR CheckLowTwo8BitSignbits
  72. pcmpeqd mm5, MMWORD PTR Zero
  73. movd edx, mm5
  74. and eax, edx
  75. ;return pTex->BorderColor;
  76. ;}
  77. ')
  78. ')dnl
  79. dnl
  80. dnl d_DoBorderMix
  81. dnl
  82. dnl Inserts conditional border code
  83. dnl
  84. define(`d_DoBorderMix', `ifelse(`$1', `NoBorder', `
  85. ; Generate Border Mask to always be true.
  86. ;pcmpeqd mm5, mm5
  87. ', `
  88. movd mm2, XpTex(BorderColor)
  89. pand mm1, mm5
  90. pandn mm5, mm2
  91. por mm1, mm5
  92. ')
  93. ')dnl
  94. dnl
  95. dnl d_DoColorKey
  96. dnl
  97. dnl Inserts conditional color key code
  98. dnl $1 the function type, $2 is the thing to test against the Transparent color,
  99. dnl and $3 is its type.
  100. dnl
  101. define(`d_DoColorKey', `ifelse(`$1', `ColorKey', `
  102. ; Generate another mask based on TransparentColor
  103. ; Should be able to do pcmpeq to generate mask.
  104. ; Need Palettized and non Palettized code both use eax for the original Texel.
  105. ; if (ColorOriTexel == (int32)pTex->TransparentColor)
  106. ; {
  107. ; Color &= 0xffffff;
  108. ; }
  109. movq mm2, mm1
  110. movd mm1, eax
  111. pcmpeqd mm1, XpTex(TransparentColor)
  112. ; if they are equal then mm1 = 0xffffffff else mm1 = 0
  113. pslld mm1, 24 ; mm1 = 0xffffffff << 24 = 0xff000000 or mm2 = 0 << 24 = 0.
  114. pandn mm1, mm2 ; mask off alpha if color is transparent color.
  115. ')')dnl
  116. dnl
  117. dnl
  118. dnl d_DoReturn
  119. dnl
  120. dnl Inserts conditional return. Return in general case and dont in monolith case.
  121. dnl
  122. define(`d_DoReturn', `ifelse(`$1', `NotMonolithic', `
  123. ;return Color;
  124. ret
  125. ', `
  126. ; No call or return in monolith case.
  127. ')
  128. ')dnl
  129. define(`d_Palette8', ``
  130. ; This code needs to be cleaned up quite a bit.
  131. ;D3DCOLOR TexRead_Palette8_$1_$2(INT32 iU, INT32 iV, INT32 iShiftU, PUINT8 pBits, PD3DI_SPANTEX pTex)
  132. ;{
  133. ifelse(`$3', `Monolithic', `', `
  134. PUBLIC _MMX_TexRead_Palette8_$1_$2
  135. _MMX_TexRead_Palette8_$1_$2:
  136. ')
  137. ; Start this line now to give pmadd moretime to finish
  138. ; INT32 iTexel = pBits[iU | (iV << iShiftU)];
  139. ; Save mm3 for now
  140. ; TBD look to see if need to save it or if it will change.
  141. d_DoBorder(`$1')
  142. movzx eax, byte ptr [edi + eax] ; get index
  143. mov edx, eax
  144. shl edx, 2 ; convert to DWORD offset
  145. ;D3DCOLOR Color = pTex->pPalette[iTexel];
  146. add edx, XpTex(pPalette) ; add index to get palette address
  147. movd mm1, dword ptr[edx]
  148. movq mm2, mm1 ; 0000?BGR = mm2
  149. punpcklwd mm1, mm1 ; ?B?BGRGR = mm1
  150. psrlq mm2, 16 ; 000000?B
  151. pand mm2, MMWORD PTR Val0x00ff00ff ; 0000000B
  152. pand mm1, MMWORD PTR Val0xffff00 ; 00000RG0
  153. por mm1, mm2 ; 00000RGB
  154. ; RL palette is BGR - flip the channels into RGB
  155. ;Color = RGBA_MAKE((Color & 0xff),
  156. ; (Color >> 8) & 0xff,
  157. ; (Color >> 16) & 0xff,
  158. ; 0xff);
  159. ; result should be in mm1 for color key and border masking.
  160. por mm1, dword ptr SetAlphaTo0xFF
  161. d_DoColorKey(`$2')
  162. d_DoBorderMix($1)
  163. ; Need to unpack color for bilinear 16 bit multiplications
  164. punpcklbw mm1, MMWORD PTR Zero
  165. d_DoReturn($3)
  166. ;}'')dnl
  167. define(`d_Palette4', ``
  168. ;D3DCOLOR TexRead_Palette4_$1_$2(INT32 iU, INT32 iV, INT32 iShiftU, PUINT8 pBits, PD3DI_SPANTEX pTex)
  169. ;{
  170. ifelse(`$3', `Monolithic', `', `
  171. PUBLIC _MMX_TexRead_Palette4_$1_$2
  172. _MMX_TexRead_Palette4_$1_$2:
  173. ')
  174. d_DoBorder(`$1')
  175. ;INT32 iIndex = iU | (iV << iShiftU);
  176. ; Need ecx to shift with. Save it off since it will be needed later.
  177. mov edx, ecx
  178. mov ecx, eax
  179. and ecx, 1
  180. ;INT32 iTexel = pBits[iIndex>>1];
  181. shr eax, 1
  182. movzx eax, byte ptr [edi + eax] ; get index
  183. ;if ((iIndex & 1) == 0)
  184. ;{
  185. ; iTexel &= 0xf;
  186. ;}
  187. ;else
  188. ;{
  189. ; iTexel >>= 4;
  190. ;}
  191. shl ecx, 2 ; This will make ecx 0 or 4. This gets lookup value in correct place without branching.
  192. shr eax, cl ; Shift by 0 or 4 now.
  193. and eax, 0fh
  194. mov ecx, eax
  195. shl ecx, 2 ; convert to DWORD offset
  196. ;D3DCOLOR Color = pTex->pPalette[iTexel];
  197. add ecx, XpTex(pPalette) ; add index to get palette address
  198. movd mm1, dword ptr[ecx]
  199. ; RL palette is BGR - flip the channels into RGB
  200. ;Color = RGBA_MAKE((Color & 0xff),
  201. ; (Color >> 8) & 0xff,
  202. ; (Color >> 16) & 0xff,
  203. ; 0xff);
  204. movq mm2, mm1 ; 0000?BGR = mm2
  205. punpcklwd mm1, mm1 ; ?B?BGRGR = mm1
  206. psrlq mm2, 16 ; 000000?B
  207. pand mm2, MMWORD PTR Val0x00ff00ff ; 0000000B
  208. pand mm1, MMWORD PTR Val0xffff00 ; 00000RG0
  209. por mm1, mm2 ; 00000RGB
  210. por mm1, dword ptr SetAlphaTo0xFF
  211. d_DoColorKey(`$2')
  212. d_DoBorderMix($1)
  213. punpcklbw mm1, MMWORD PTR Zero
  214. ; Revive ecx.
  215. mov ecx, edx
  216. d_DoReturn($3)
  217. ;}'')dnl
  218. define(`d_Palette8A', ``
  219. ; This code needs to be cleaned up quite a bit.
  220. ;D3DCOLOR TexRead_Palette8A_$1_$2(INT32 iU, INT32 iV, INT32 iShiftU, PUINT8 pBits, PD3DI_SPANTEX pTex)
  221. ;{
  222. ifelse(`$3', `Monolithic', `', `
  223. PUBLIC _MMX_TexRead_Palette8A_$1_$2
  224. _MMX_TexRead_Palette8A_$1_$2:
  225. ')
  226. ; Start this line now to give pmadd moretime to finish
  227. ; INT32 iTexel = pBits[iU | (iV << iShiftU)];
  228. ; Save mm3 for now
  229. ; TBD look to see if need to save it or if it will change.
  230. d_DoBorder(`$1')
  231. movzx eax, byte ptr [edi + eax] ; get index
  232. mov edx, eax
  233. shl edx, 2 ; convert to DWORD offset
  234. ;D3DCOLOR Color = pTex->pPalette[iTexel];
  235. add edx, XpTex(pPalette) ; add index to get palette address
  236. movd mm1, dword ptr[edx]
  237. movq mm2, mm1 ; 0000ABGR = mm2
  238. pand mm1, MMWORD PTR Val0xff00ff00 ; 0000A0G0 = mm1
  239. pand mm2, MMWORD PTR Val0x00ff00ff ; 00000B0R = mm2
  240. psllq mm2, 16 ; 000B0R00 = mm2
  241. por mm1, mm2 ; 000BARG0 = mm1
  242. psrlq mm2, 32 ; 0000000B = mm2
  243. por mm1, mm2 ; 000BARBG = mm1
  244. ; RL palette is BGR - flip the channels into RGB
  245. ;Color = RGBA_MAKE((Color & 0xff),
  246. ; (Color >> 8) & 0xff,
  247. ; (Color >> 16) & 0xff,
  248. ; (Color >> 24) & 0xff);
  249. d_DoColorKey(`$2')
  250. d_DoBorderMix($1)
  251. ; Need to unpack color for bilinear 16 bit multiplications
  252. punpcklbw mm1, MMWORD PTR Zero
  253. d_DoReturn($3)
  254. ;}'')dnl
  255. define(`d_Palette4A', ``
  256. ;D3DCOLOR TexRead_Palette4A_$1_$2(INT32 iU, INT32 iV, INT32 iShiftU, PUINT8 pBits, PD3DI_SPANTEX pTex)
  257. ;{
  258. ifelse(`$3', `Monolithic', `', `
  259. PUBLIC _MMX_TexRead_Palette4A_$1_$2
  260. _MMX_TexRead_Palette4A_$1_$2:
  261. ')
  262. d_DoBorder(`$1')
  263. ;INT32 iIndex = iU | (iV << iShiftU);
  264. ; Need ecx to shift with. Save it off since it will be needed later.
  265. mov edx, ecx
  266. mov ecx, eax
  267. and ecx, 1
  268. ;INT32 iTexel = pBits[iIndex>>1];
  269. shr eax, 1
  270. movzx eax, byte ptr [edi + eax] ; get index
  271. ;if ((iIndex & 1) == 0)
  272. ;{
  273. ; iTexel &= 0xf;
  274. ;}
  275. ;else
  276. ;{
  277. ; iTexel >>= 4;
  278. ;}
  279. shl ecx, 2 ; This will make ecx 0 or 4. This gets lookup value in correct place without branching.
  280. shr eax, cl ; Shift by 0 or 4 now.
  281. and eax, 0fh
  282. mov ecx, eax
  283. shl ecx, 2 ; convert to DWORD offset
  284. ;D3DCOLOR Color = pTex->pPalette[iTexel];
  285. add ecx, XpTex(pPalette) ; add index to get palette address
  286. movd mm1, dword ptr[ecx]
  287. ; RL palette is BGR - flip the channels into RGB
  288. ;Color = RGBA_MAKE((Color & 0xff),
  289. ; (Color >> 8) & 0xff,
  290. ; (Color >> 16) & 0xff,
  291. ; (Color >> 24) & 0xff);
  292. movq mm2, mm1 ; 0000ABGR = mm2
  293. pand mm1, MMWORD PTR Val0xff00ff00 ; 0000A0G0 = mm1
  294. pand mm2, MMWORD PTR Val0x00ff00ff ; 00000B0R = mm2
  295. psllq mm2, 16 ; 000B0R00 = mm2
  296. por mm1, mm2 ; 000BARG0 = mm1
  297. psrlq mm2, 32 ; 0000000B = mm2
  298. por mm1, mm2 ; 000BARBG = mm1
  299. d_DoColorKey(`$2')
  300. d_DoBorderMix($1)
  301. punpcklbw mm1, MMWORD PTR Zero
  302. ; Revive ecx.
  303. mov ecx, edx
  304. d_DoReturn($3)
  305. ;}'')dnl
  306. define(`d_B8G8R8', ``
  307. ;D3DCOLOR TexRead_B8G8R8_$1_$2(INT32 iU, INT32 iV, INT32 iShiftU, PUINT8 pBits, PD3DI_SPANTEX pTex)
  308. ;{
  309. ifelse(`$3', `Monolithic', `', `
  310. PUBLIC _MMX_TexRead_B8G8R8_$1_$2
  311. _MMX_TexRead_B8G8R8_$1_$2:
  312. ')
  313. d_DoBorder(`$1')
  314. ;D3DCOLOR Color = (((D3DCOLOR*)pBits)[iU | (iV << iShiftU)]) | 0xff000000;
  315. ; Save mm3 for now
  316. ; TBD look to see if need to save it or if it will change.
  317. mov eax, dword ptr [edi+4*eax]
  318. movd mm1, eax ; save copy of original texel
  319. por mm1, dword ptr SetAlphaTo0xFF
  320. d_DoColorKey(`$2')
  321. d_DoBorderMix($1)
  322. ; Need to unpack color for bilinear 16 bit multiplications
  323. punpcklbw mm1, MMWORD PTR Zero
  324. d_DoReturn($3)
  325. ;}'')dnl
  326. define(`d_B8G8R8A8', ``
  327. ;D3DCOLOR TexRead_B8G8R8A8_$1_$2(INT32 iU, INT32 iV, INT32 iShiftU, PUINT8 pBits, PD3DI_SPANTEX pTex)
  328. ;{
  329. ifelse(`$3', `Monolithic', `', `
  330. PUBLIC _MMX_TexRead_B8G8R8A8_$1_$2
  331. _MMX_TexRead_B8G8R8A8_$1_$2:
  332. ')
  333. d_DoBorder(`$1')
  334. ;D3DCOLOR Color = ((D3DCOLOR*)pBits)[iU | (iV << iShiftU)];
  335. mov eax, dword ptr [edi+4*eax] ; This should be aligned
  336. movd mm1, eax ; save copy of original texel
  337. d_DoColorKey(`$2')
  338. d_DoBorderMix($1)
  339. punpcklbw mm1, MMWORD PTR Zero
  340. d_DoReturn($3)
  341. ;}'')dnl
  342. define(`d_B5G6R5', ``
  343. ;D3DCOLOR TexRead_B5G6R5_$1_$2(INT32 iU, INT32 iV, INT32 iShiftU, PUINT8 pBits, PD3DI_SPANTEX pTex)
  344. ;{
  345. ifelse(`$3', `Monolithic', `', `
  346. PUBLIC _MMX_TexRead_B5G6R5_$1_$2
  347. _MMX_TexRead_B5G6R5_$1_$2:
  348. ')
  349. d_DoBorder(`$1')
  350. movzx eax, word ptr [edi+2*eax]
  351. ;UINT16 uTexel = ((UINT16*)pBits)[iU | (iV << iShiftU)];
  352. ;D3DCOLOR Color = RGBA_MAKE(( uTexel >> 8 ) & 0xf8,
  353. ; (( uTexel >> 3) & 0xfc ),
  354. ; (( uTexel << 3) & 0xf8 ),
  355. ; 0xff);
  356. movd mm1, eax ; Make three more copies of input color
  357. mov edx, eax
  358. movq mm2, mm1
  359. pand mm1, dword ptr MaskGreen565to888 ; MaskGreen565to888 is in memory
  360. psllq mm2, RedShift565to888 ; RedShift should be an immediate
  361. pand mm2, dword ptr MaskRed565to888 ; MaskRed565to888 in memory.
  362. psllq mm1, GreenShift565to888
  363. shl edx, BlueShift565to888
  364. por mm1, mm2
  365. and edx, dword ptr MaskBlue565to888
  366. movd mm2, edx
  367. por mm1, dword ptr SetAlphaTo0xFF
  368. por mm1, mm2
  369. d_DoColorKey(`$2')
  370. d_DoBorderMix($1)
  371. ; Dont need to unpack here since I shift to correct location.
  372. ; BUG BUG this will cause a problem with the border color.
  373. ; Could do different shifts if border is on or not.
  374. ; For now, just unpack and dont shift as much.
  375. punpcklbw mm1, MMWORD PTR Zero
  376. d_DoReturn($3)
  377. ;}'')dnl
  378. define(`d_B5G5R5', ``
  379. ;D3DCOLOR TexRead_B5G5R5_$1_$2(INT32 iU, INT32 iV, INT32 iShiftU, PUINT8 pBits, PD3DI_SPANTEX pTex)
  380. ;{
  381. ifelse(`$3', `Monolithic', `', `
  382. PUBLIC _MMX_TexRead_B5G5R5_$1_$2
  383. _MMX_TexRead_B5G5R5_$1_$2:
  384. ')
  385. d_DoBorder(`$1')
  386. ;UINT16 uTexel = ((UINT16*)pBits)[iU | (iV << iShiftU)];
  387. movzx eax, word ptr [edi+2*eax]
  388. ;D3DCOLOR Color = RGBA_MAKE(( uTexel >> 7 ) & 0xf8,
  389. ; (( uTexel >> 2) & 0xf8 ),
  390. ; (( uTexel << 3) & 0xf8 ),
  391. ; 0xff);
  392. movd mm1, eax ; Make three more copies of input color
  393. mov edx, eax
  394. movq mm2, mm1
  395. pand mm1, dword ptr MaskGreen555to888 ; MaskGreen555to888 is in memory
  396. psllq mm2, RedShift555to888 ; RedShift should be an immediate
  397. pand mm2, dword ptr MaskRed555to888 ; MaskRed555to888 in memory.
  398. psllq mm1, GreenShift555to888
  399. shl edx, BlueShift555to888
  400. por mm1, mm2
  401. and edx, dword ptr MaskBlue555to888
  402. movd mm2, edx
  403. por mm1, dword ptr SetAlphaTo0xFF
  404. por mm1, mm2
  405. por mm1, dword ptr SetAlphaTo0xFF
  406. d_DoColorKey(`$2')
  407. d_DoBorderMix($1)
  408. punpcklbw mm1, MMWORD PTR Zero
  409. d_DoReturn($3)
  410. ;}'')dnl
  411. define(`d_B5G5R5A1', ``
  412. ;D3DCOLOR TexRead_B5G5R5A1_$1_$2(INT32 iU, INT32 iV, INT32 iShiftU, PUINT8 pBits, PD3DI_SPANTEX pTex)
  413. ;{
  414. ifelse(`$3', `Monolithic', `', `
  415. PUBLIC _MMX_TexRead_B5G5R5A1_$1_$2
  416. _MMX_TexRead_B5G5R5A1_$1_$2:
  417. ')
  418. d_DoBorder(`$1')
  419. ;INT16 iTexel = ((INT16*)pBits)[iU | (iV << iShiftU)];
  420. movzx eax, word ptr [edi+2*eax]
  421. ;D3DCOLOR Color = RGBA_MAKE(( iTexel >> 7 ) & 0xf8,
  422. ; (( iTexel >> 2) & 0xf8 ),
  423. ; (( iTexel << 3) & 0xf8 ),
  424. ; (iTexel >> 15) & 0xff);
  425. movd mm1, eax ; Make two more copies of input color
  426. movq mm2, mm1
  427. mov edx, eax
  428. pand mm1, dword ptr MaskAlpha1555to8888 ; MaskAlpha1555to8888 is in memory
  429. psllq mm2, RedShift1555to8888 ; RedShift should be an immediate
  430. pand mm2, dword ptr MaskRed1555to8888 ; MaskRed1555to8888 in memory.
  431. psllq mm1, AlphaShift1555to8888 ; shift bit to top of dword
  432. psrad mm1, 7 ; copy bit to upper 8 bits.
  433. por mm1, mm2
  434. movd mm2, eax
  435. pslld mm2, BlueShift1555to8888
  436. shl edx, GreenShift1555to8888
  437. pand mm2, MMWORD PTR MaskBlue1555to8888
  438. por mm1, mm2
  439. and edx, dword ptr MaskGreen1555to8888
  440. movd mm2, edx
  441. por mm1, mm2
  442. d_DoColorKey(`$2')
  443. d_DoBorderMix($1)
  444. punpcklbw mm1, MMWORD PTR Zero
  445. d_DoReturn($3)
  446. ;}'')dnl
  447. define(`d_B4G4R4', ``
  448. ;D3DCOLOR TexRead_B4G4R4_$1_$2(INT32 iU, INT32 iV, INT32 iShiftU, PUINT8 pBits, PD3DI_SPANTEX pTex)
  449. ;{
  450. ifelse(`$3', `Monolithic', `', `
  451. PUBLIC _MMX_TexRead_B4G4R4_$1_$2
  452. _MMX_TexRead_B4G4R4_$1_$2:
  453. ')
  454. d_DoBorder(`$1')
  455. movzx eax, word ptr [edi+2*eax]
  456. ;D3DCOLOR Color = RGBA_MAKE((( iTexel >> 4 ) & 0xf0),
  457. ; (( iTexel >> 0) & 0xf0 ),
  458. ; (( iTexel << 4) & 0xf0 ),
  459. ; 0xff);
  460. movd mm1, eax
  461. pand mm1, MMWORD ptr MaskGreen444to888
  462. psrld mm1, 4
  463. movd mm2, eax
  464. pand mm2, MMWORD PTR MaskRedBlue444to888
  465. punpcklbw mm1, mm2 ; interleave red green and blue.
  466. ; Duplicate 4 bits to make 8 bits. Also allows colors to reach full intensity and linear.
  467. movq mm2, mm1
  468. psrld mm2, 4
  469. por mm1, mm2
  470. por mm1, dword ptr SetAlphaTo0xFF ; make alpha value one.
  471. d_DoColorKey(`$2')
  472. d_DoBorderMix($1)
  473. ; Need to unpack color for bilinear 16 bit multiplications
  474. punpcklbw mm1, MMWORD PTR Zero
  475. d_DoReturn($3)
  476. ;}'')dnl
  477. define(`d_B4G4R4A4', ``
  478. ;D3DCOLOR TexRead_B4G4R4A4_$1_$2(INT32 iU, INT32 iV, INT32 iShiftU, PUINT8 pBits, PD3DI_SPANTEX pTex)
  479. ;{
  480. ifelse(`$3', `Monolithic', `', `
  481. PUBLIC _MMX_TexRead_B4G4R4A4_$1_$2
  482. _MMX_TexRead_B4G4R4A4_$1_$2:
  483. ')
  484. d_DoBorder(`$1')
  485. movzx eax, word ptr [edi+2*eax]
  486. ;INT16 iAlpha = ( iTexel >> 12 ) & 0xf;
  487. ; Kents Idea:
  488. ; An alpha of 0xf becomes 0xff, 0x0 becomes 0x0, and it is monotonic.
  489. ; May want to apply this operation to all color channels
  490. ; Great Idea.
  491. ;D3DCOLOR Color = RGBA_MAKE((( iTexel >> 4 ) & 0xf0),
  492. ; (( iTexel >> 0) & 0xf0 ),
  493. ; (( iTexel << 4) & 0xf0 ),
  494. ; (iAlpha << 4) | iAlpha );
  495. movd mm1, eax
  496. pand mm1, MMWORD PTR MaskAlphaGreen4444to8888
  497. psrld mm1, 4
  498. movd mm2, eax
  499. pand mm2, MMWORD PTR MaskRedBlue4444to8888
  500. punpcklbw mm2, mm1 ; interleave red green and blue.
  501. ; Duplicate 4 bits to make 8 bits. Also allows colors to reach full intensity and linear.
  502. movq mm1, mm2
  503. pslld mm2, 4
  504. por mm1, mm2
  505. d_DoColorKey(`$2')
  506. d_DoBorderMix($1)
  507. ; BUG BUG border needs to be unpacked.
  508. punpcklbw mm1, MMWORD PTR Zero
  509. d_DoReturn($3)
  510. ;}'')dnl
  511. define(`d_L8', ``
  512. ;D3DCOLOR TexRead_L8_$1_$2(INT32 iU, INT32 iV, INT32 iShiftU, PUINT8 pBits, PD3DI_SPANTEX pTex)
  513. ;{
  514. ifelse(`$2', `Monolithic', `', `
  515. PUBLIC _MMX_TexRead_L8_$1_$2
  516. _MMX_TexRead_L8_$1_$2:
  517. ')
  518. d_DoBorder(`$1')
  519. ;UINT8 iTexel = pBits[iU | (iV << iShiftU)];
  520. ;D3DCOLOR Color = RGBA_MAKE(iTexel,
  521. ; iTexel,
  522. ; iTexel,
  523. ; 0xff );
  524. movzx eax, byte ptr [edi+eax]
  525. movd mm1, eax
  526. punpcklbw mm1,mm1
  527. punpcklwd mm1,mm1
  528. por mm1, dword ptr SetAlphaTo0xFF
  529. d_DoColorKey(`$2')
  530. d_DoBorderMix($1)
  531. ; BUG BUG border needs to be unpacked.
  532. punpcklbw mm1, MMWORD PTR Zero
  533. d_DoReturn($3)
  534. ;}'')dnl
  535. define(`d_L8A8', ``
  536. ;D3DCOLOR TexRead_L8A8_$1_$2(INT32 iU, INT32 iV, INT32 iShiftU, PUINT8 pBits, PD3DI_SPANTEX pTex)
  537. ;{
  538. ifelse(`$2', `Monolithic', `', `
  539. PUBLIC _MMX_TexRead_L8A8_$1_$2
  540. _MMX_TexRead_L8A8_$1_$2:
  541. ')
  542. d_DoBorder(`$1')
  543. ;INT16 iTexel = ((INT16*)pBits)[iU | (iV << iShiftU)];
  544. ;INT16 iAlpha = ( iTexel >> 8 ) & 0xff;
  545. ;D3DCOLOR Color = RGBA_MAKE(iTexel,
  546. ; iTexel,
  547. ; iTexel,
  548. ; iAlpha );
  549. movzx eax, word ptr [edi+2*eax]
  550. movd mm1, eax
  551. pslld mm1, 16
  552. and eax, dword ptr MaskL8A8ALPHA
  553. movd mm2, eax
  554. por mm1, mm2
  555. pslld mm2, 8
  556. por mm1, mm2
  557. d_DoColorKey(`$2')
  558. d_DoBorderMix($1)
  559. ; BUG BUG border needs to be unpacked.
  560. punpcklbw mm1, MMWORD PTR Zero
  561. d_DoReturn($3)
  562. ;}'')dnl