RGB.H 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: /CounterStrike/RGB.H 1 3/03/97 10:25a Joe_bostic $ */
  19. /***********************************************************************************************
  20. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : RGB.H *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : 12/02/95 *
  30. * *
  31. * Last Update : December 2, 1995 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef RGB_H
  37. #define RGB_H
  38. class PaletteClass;
  39. class HSVClass;
  40. #ifndef OUTPORTB
  41. #define OUTPORTB
  42. extern void outportb(int port, unsigned char data);
  43. #pragma aux outportb parm [edx] [al] = \
  44. "out dx,al"
  45. extern void outport(int port, unsigned short data);
  46. #pragma aux outport parm [edx] [ax] = \
  47. "out dx,al" \
  48. "inc dx" \
  49. "mov al,ah" \
  50. "out dx,al"
  51. #endif
  52. extern void outrgb(unsigned char red, unsigned char green, unsigned char blue);
  53. #pragma aux outrgb parm [al] [bl] [cl] \
  54. modify [dx al] = \
  55. "mov dx,03C9h" \
  56. "out dx,al" \
  57. "jmp e1" \
  58. "e1:" \
  59. "mov al,bl" \
  60. "out dx,al" \
  61. "jmp e2" \
  62. "e2:" \
  63. "mov al,cl" \
  64. "out dx,al" \
  65. "jmp e3" \
  66. "e3:"
  67. /*
  68. ** Each color entry is represented by this class. It holds the values for the color
  69. ** guns. The gun values are recorded in device dependant format, but the interface
  70. ** uses gun values from 0 to 255.
  71. */
  72. class RGBClass
  73. {
  74. // static RGBClass const BlackColor;
  75. public:
  76. RGBClass(void) : Red(0), Green(0), Blue(0) {};
  77. RGBClass(unsigned char red, unsigned char green, unsigned char blue) :
  78. Red((unsigned char)(red>>2)),
  79. Green((unsigned char)(green>>2)),
  80. Blue((unsigned char)(blue>>2))
  81. {};
  82. operator HSVClass (void) const;
  83. RGBClass & operator = (RGBClass const & rgb) {
  84. if (this == &rgb) return(*this);
  85. Red = rgb.Red;
  86. Green = rgb.Green;
  87. Blue = rgb.Blue;
  88. return(*this);
  89. };
  90. enum {
  91. MAX_VALUE=255
  92. };
  93. void Adjust(int ratio, RGBClass const & rgb);
  94. // void Adjust(int ratio, RGBClass const & rgb = BlackColor);
  95. int Difference(RGBClass const & rgb) const;
  96. int Red_Component(void) const {return ((Red << 2) | (Red >> 6));};
  97. int Green_Component(void) const {return((Green << 2) | (Green >> 6));};
  98. int Blue_Component(void) const {return((Blue << 2) | (Blue >> 6));};
  99. void Set(int color) const;
  100. private:
  101. friend class PaletteClass;
  102. void Raw_Set(void) const {
  103. outrgb(Red, Green, Blue);
  104. // outportb(0x03C9, Red);
  105. // outportb(0x03C9, Green);
  106. // outportb(0x03C9, Blue);
  107. };
  108. static void Raw_Color_Prep(unsigned char color) {
  109. outportb(0x03C8, color);
  110. };
  111. /*
  112. ** These hold the actual color gun values in machine dependant scale. This
  113. ** means the values range from 0 to 63.
  114. */
  115. unsigned char Red;
  116. unsigned char Green;
  117. unsigned char Blue;
  118. };
  119. extern RGBClass const BlackColor;
  120. #endif