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.

123 lines
3.4 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // This file contains the general 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. void Ramp_Mono_Modulate(PD3DI_RASTCTX pCtx, PD3DI_RASTPRIM pP,
  12. PD3DI_RASTSPAN pS)
  13. {
  14. INT32 iMapIdx = 0;
  15. INT32 iIIdx = pS->iIdx >> INDEX_COLOR_SHIFT;
  16. BOOL bColorKey = FALSE;
  17. INT32 iIdx = pS->iIdx;
  18. UINT32 uZ = pS->uZ;
  19. PUINT8 pZ = pS->pZ;
  20. INT32 iDZDX = pP->iDZDX;
  21. d_RpZInit16
  22. if (pCtx->pdwRenderState[D3DRENDERSTATE_ZENABLE])
  23. {
  24. d_RpZTest16Any(`NoPixel')
  25. }
  26. // ATTENTION, carefully consolidate this at some point, making sure
  27. // to update the global color key flag when the render state or the texture
  28. // changes.
  29. if (pCtx->cActTex != 0)
  30. {
  31. PD3DI_SPANTEX pTex = pCtx->pTexture[0];
  32. // bColorKey iff there is a texture and it has transparent color AND
  33. // colorkey is enabled.
  34. bColorKey = (pCtx->pdwRenderState[D3DRENDERSTATE_COLORKEYENABLE] ||
  35. pCtx->pdwRenderState[D3DRENDERSTATE_ALPHABLENDENABLE]) &&
  36. (pTex->uFlags & D3DI_SPANTEX_HAS_TRANSPARENT);
  37. d_RpTexelAddrLOD
  38. iMapIdx = pCtx->pfnTexRead[0](iU00, iV00, pTex->iShiftPitch[iLOD0],
  39. pTex->pBits[iLOD0], pTex);
  40. }
  41. if(pCtx->pdwRenderState[D3DRENDERSTATE_DITHERENABLE])
  42. {
  43. d_RpDither
  44. }
  45. if(pCtx->pdwRenderState[D3DRENDERSTATE_ALPHABLENDENABLE] || bColorKey)
  46. {
  47. d_RpAlphaTest(`Gen', `NoPixel')
  48. }
  49. if (pCtx->pdwRenderState[D3DRENDERSTATE_ZENABLE])
  50. {
  51. d_RpZWrite16(`Gen')
  52. }
  53. iMapIdx &= 0xffffff; // mask off texture alpha
  54. iMapIdx += iIIdx;
  55. #if DBG
  56. if (iMapIdx < 0 || iMapIdx > 0x7fff)
  57. {
  58. D3D_WARN(0, "Ramp index out of range: 0x%X", iMapIdx);
  59. }
  60. #endif
  61. // always put iMapIdx into range
  62. iMapIdx &= 0x7fff;
  63. switch (pCtx->iSurfaceType)
  64. {
  65. case RR_STYPE_B8G8R8X8:
  66. case RR_STYPE_B8G8R8A8:
  67. *(PUINT32)pS->pSurface = (UINT32)(pCtx->pRampMap[iMapIdx]);
  68. break;
  69. case RR_STYPE_B8G8R8:
  70. {
  71. PUINT8 pSurf = (PUINT8)pS->pSurface;
  72. UINT32 Color = (UINT32)(pCtx->pRampMap[iMapIdx]);
  73. pSurf[0] = (UINT8)(Color);
  74. pSurf[1] = (UINT8)(Color >> 8);
  75. pSurf[2] = (UINT8)(Color >> 16);
  76. }
  77. break;
  78. case RR_STYPE_B5G6R5:
  79. case RR_STYPE_B5G5R5:
  80. case RR_STYPE_B5G5R5A1:
  81. *(PUINT16)pS->pSurface = (UINT16)(pCtx->pRampMap[iMapIdx]);
  82. break;
  83. case RR_STYPE_PALETTE8:
  84. *(PUINT8)pS->pSurface = (UINT8)(pCtx->pRampMap[iMapIdx]);
  85. break;
  86. }
  87. NoPixel:
  88. if (pCtx->pdwRenderState[D3DRENDERSTATE_ZENABLE])
  89. {
  90. pS->uZ = uZ;
  91. }
  92. if (pCtx->pdwRenderState[D3DRENDERSTATE_SHADEMODE] != D3DSHADE_FLAT)
  93. {
  94. pS->iIdx += pP->iDIdxDX;
  95. pS->iIdxA += pP->iDIdxADX;
  96. }
  97. if (pCtx->cActTex != 0)
  98. {
  99. if (pCtx->pdwRenderState[D3DRENDERSTATE_TEXTUREPERSPECTIVE])
  100. {
  101. d_RpSpecialWPerspStepTexLOD
  102. }
  103. else
  104. {
  105. d_RpAffineStepTexLOD
  106. }
  107. }
  108. }