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