RGB.H 4.8 KB

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