Source code of Windows XP (NT5)
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.

82 lines
2.8 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: spangen.h
  3. *
  4. * This code figures out the color for pixel and stores it
  5. *
  6. * 14-Oct-1994 mikeke Created
  7. *
  8. * Copyright (c) 1994 Microsoft Corporation
  9. \**************************************************************************/
  10. {
  11. DWORD r, g, b;
  12. DWORD color;
  13. ULONG ditherVal;
  14. if (flags & GEN_DITHER) {
  15. ditherVal = pdither[iDither];
  16. } else {
  17. if ((flags & (GEN_SHADE | GEN_TEXTURE | GEN_RGBMODE)) ==
  18. (GEN_SHADE | GEN_TEXTURE | GEN_RGBMODE)) {
  19. ditherVal = 0x08;
  20. } else {
  21. ditherVal = 0x0000;
  22. }
  23. }
  24. if (!(flags & GEN_RGBMODE)) {
  25. if (BPP == 8) {
  26. color = ((rAccum + ditherVal) >> 16) & 0xff;
  27. } else {
  28. color = ((PULONG)pXlat)[(((rAccum + ditherVal) >> 16) & 0xfff)];
  29. }
  30. } else {
  31. if (flags & GEN_TEXTURE) {
  32. texBits = (texAddr + ((sAccum & sMask) >> 14) +
  33. ((tAccum & tMask) >> tShift));
  34. if (flags & GEN_SHADE) {
  35. r = ((ULONG)(gbMulTable[(((rAccum >> rBits) & 0xff00) | texBits[2])] << rBits) + ditherVal) >> 8;
  36. g = ((ULONG)(gbMulTable[(((gAccum >> gBits) & 0xff00) | texBits[1])] << gBits) + ditherVal) >> 8;
  37. b = ((ULONG)(gbMulTable[(((bAccum >> bBits) & 0xff00) | texBits[0])] << bBits) + ditherVal) >> 8;
  38. } else {
  39. if (flags & GEN_DITHER) {
  40. r = ((ULONG)(gbMulTable[(rAccum | texBits[2])] << rBits) + ditherVal) >> 8;
  41. g = ((ULONG)(gbMulTable[(gAccum | texBits[1])] << gBits) + ditherVal) >> 8;
  42. b = ((ULONG)(gbMulTable[(bAccum | texBits[0])] << bBits) + ditherVal) >> 8;
  43. } else {
  44. r = (texBits[2] << rBits) >> 8;
  45. g = (texBits[1] << gBits) >> 8;
  46. b = (texBits[0] << bBits) >> 8;
  47. }
  48. }
  49. } else {
  50. r = (rAccum + ditherVal) >> 16;
  51. g = (gAccum + ditherVal) >> 16;
  52. b = (bAccum + ditherVal) >> 16;
  53. }
  54. color = (r << rShift) |
  55. (g << gShift) |
  56. (b << bShift);
  57. }
  58. if (BPP == 8) {
  59. *pPix = gengc->xlatPalette[color & 0xff];
  60. #ifdef OLDWAY
  61. if ((flags & (GEN_TEXTURE | GEN_SHADE | GEN_DITHER)) ==
  62. GEN_TEXTURE) {
  63. *pPix = (BYTE)color;
  64. } else {
  65. *pPix = (BYTE)pXlat[color & 0xff];
  66. }
  67. #endif
  68. } else if (BPP == 16) {
  69. *((WORD *)pPix) = (USHORT)color;
  70. } else if (BPP == 24) {
  71. *pPix = (BYTE)color;
  72. *(pPix + 1) = (BYTE)(color >> 8);
  73. *(pPix + 2) = (BYTE)(color >> 16);
  74. } else {
  75. *((DWORD *)pPix) = color;
  76. }
  77. }