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.

92 lines
2.5 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // This file contains the general texture copy ramp span routine.
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997.
  6. //
  7. //-----------------------------------------------------------------------------
  8. include(`ramppix.mh')dnl
  9. #include "pch.cpp"
  10. #pragma hdrstop
  11. dnl
  12. dnl d_Ramp_Mono_CopyFunc
  13. dnl
  14. define(`d_Ramp_Mono_CopyFunc', `
  15. void Ramp_Mono_Copy_$1(PD3DI_RASTCTX pCtx, PD3DI_RASTPRIM pP, PD3DI_RASTSPAN pS)
  16. {
  17. INT32 iMapIdx = 0;
  18. BOOL bColorKey = FALSE;
  19. INT32 iIdx = pS->iIdx;
  20. UINT32 uZ = pS->uZ;
  21. PUINT8 pZ = pS->pZ;
  22. INT32 iDZDX = pP->iDZDX;
  23. d_RpZInit16
  24. if (pCtx->pdwRenderState[D3DRENDERSTATE_ZENABLE])
  25. {
  26. d_RpZTest16Any(`NoPixel')
  27. }
  28. // ATTENTION, carefully consolidate this at some point, making sure
  29. // to update the global color key flag when the render state or the texture
  30. // changes.
  31. if (pCtx->cActTex != 0)
  32. {
  33. PD3DI_SPANTEX pTex = pCtx->pTexture[0];
  34. // bColorKey iff there is a texture and it has transparent color AND
  35. // colorkey is enabled.
  36. bColorKey = (pCtx->pdwRenderState[D3DRENDERSTATE_COLORKEYENABLE] ||
  37. pCtx->pdwRenderState[D3DRENDERSTATE_ALPHABLENDENABLE]) &&
  38. (pTex->uFlags & D3DI_SPANTEX_HAS_TRANSPARENT);
  39. d_RpTexelAddrLOD
  40. iMapIdx = pCtx->pfnTexRead[0](iU00, iV00, pTex->iShiftPitch[iLOD0],
  41. pTex->pBits[iLOD0], pTex);
  42. }
  43. if(pCtx->pdwRenderState[D3DRENDERSTATE_ALPHABLENDENABLE] || bColorKey)
  44. {
  45. d_RpAlphaTest(`Gen', `NoPixel')
  46. }
  47. if (pCtx->pdwRenderState[D3DRENDERSTATE_ZENABLE])
  48. {
  49. d_RpZWrite16(`Gen')
  50. }
  51. iMapIdx &= 0xffffff; // mask off texture alpha
  52. // The only way copy can work is 8 to 8 or 16 to 16
  53. ifelse(`$1', `8', `
  54. *(PUINT8)pS->pSurface = (UINT8)iMapIdx;', `
  55. *(PUINT16)pS->pSurface = (UINT16)iMapIdx;')
  56. NoPixel:
  57. if (pCtx->pdwRenderState[D3DRENDERSTATE_ZENABLE])
  58. {
  59. pS->uZ = uZ;
  60. }
  61. if (pCtx->pdwRenderState[D3DRENDERSTATE_SHADEMODE] != D3DSHADE_FLAT)
  62. {
  63. // iIdx apparently not needed
  64. pS->iIdxA += pP->iDIdxADX;
  65. }
  66. if (pCtx->cActTex != 0)
  67. {
  68. if (pCtx->pdwRenderState[D3DRENDERSTATE_TEXTUREPERSPECTIVE])
  69. {
  70. d_RpSpecialWPerspStepTexLOD
  71. }
  72. else
  73. {
  74. d_RpAffineStepTexLOD
  75. }
  76. }
  77. }
  78. ')dnl
  79. d_Ramp_Mono_CopyFunc(8)
  80. d_Ramp_Mono_CopyFunc(16)