MONOC.H 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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/MONOC.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 : MONO.H *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : July 2, 1994 *
  30. * *
  31. * Last Update : July 2, 1994 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef MONOC_Hx
  37. #define MONOC_Hx
  38. /*
  39. ** The "bool" integral type was defined by the C++ committee in
  40. ** November of '94. Until the compiler supports this, use the following
  41. ** definition.
  42. */
  43. #ifndef __BORLANDC__
  44. #ifndef TRUE_FALSE_DEFINED
  45. #define TRUE_FALSE_DEFINED
  46. enum {false=0,true=1};
  47. typedef int bool;
  48. #endif
  49. #endif
  50. class MonoClass {
  51. public:
  52. enum MonoClassPageEnums {
  53. COLUMNS=80, // Number of columns.
  54. LINES=25, // Number of lines.
  55. MAX_MONO_PAGES=16 // Maximum RAM pages on mono card.
  56. };
  57. typedef enum MonoAttribute {
  58. INVISIBLE=0x00, // Black on black.
  59. UNDERLINE=0x01, // Underline.
  60. BLINKING=0x90, // Blinking white on black.
  61. NORMAL=0x02, // White on black.
  62. INVERSE=0x70, // Black on white.
  63. } MonoAttribute;
  64. /*
  65. ** These are the various box styles that may be used.
  66. */
  67. typedef enum BoxStyleType {
  68. SINGLE, // Single thickness.
  69. DOUBLE_HORZ, // Double thick on the horizontal axis.
  70. DOUBLE_VERT, // Double thick on the vertical axis.
  71. DOUBLE, // Double thickness.
  72. COUNT
  73. } BoxStyleType;
  74. MonoClass(void);
  75. ~MonoClass(void);
  76. static void Enable(void) {Enabled = true;};
  77. static void Disable(void) {Enabled = false;};
  78. static bool Is_Enabled(void) {return Enabled;};
  79. static MonoClass * Get_Current(void) {return PageUsage[0];};
  80. void Sub_Window(int x=0, int y=0, int w=-1, int h=-1);
  81. void Fill_Attrib(int x, int y, int w, int h, MonoAttribute attrib);
  82. void Draw_Box(int x, int y, int w, int h, MonoAttribute attrib=NORMAL, BoxStyleType thick=SINGLE);
  83. void Set_Default_Attribute(MonoAttribute attrib) {Attrib = attrib;};
  84. void Clear(void);
  85. void Set_Cursor(int x, int y);
  86. void Print(char const *text);
  87. void Print(int text);
  88. void Printf(char const *text, ...);
  89. void Printf(int text, ...);
  90. void Text_Print(char const *text, int x, int y, MonoAttribute attrib=NORMAL);
  91. void Text_Print(int text, int x, int y, MonoAttribute attrib=NORMAL);
  92. void View(void);
  93. void Scroll(int lines=1);
  94. void Pan(int cols=1);
  95. int Get_X(void) const {return X;};
  96. int Get_Y(void) const {return Y;};
  97. int Get_Width(void) const {return(SubW);};
  98. int Get_Height(void) const {return(SubH);};
  99. /*
  100. ** Handles deep copies for the mono class objects. This performs what is essentially
  101. ** a screen copy.
  102. */
  103. MonoClass & operator = (MonoClass const & );
  104. /*
  105. ** This merely makes a duplicate of the mono object into a newly created mono
  106. ** object.
  107. */
  108. MonoClass (MonoClass const &);
  109. private:
  110. /*
  111. ** Cursor coordinate (relative to sub-window).
  112. */
  113. int X;
  114. int Y;
  115. /*
  116. ** Default attribute to use when printing text.
  117. */
  118. MonoAttribute Attrib;
  119. /*
  120. ** The current physical page that this mono class object refers to.
  121. */
  122. int Page;
  123. /*
  124. ** Sub window coordinates.
  125. */
  126. int SubX;
  127. int SubY;
  128. int SubW;
  129. int SubH;
  130. /*
  131. ** Pointer to the monochrome RAM.
  132. */
  133. // static MonoPageType * MonoRAM;
  134. /*
  135. ** This the the arrays of characters used for drawing boxes.
  136. */
  137. /*
  138. ** This is a private structure that is used to control which characters
  139. ** are used when a box is drawn. Line drawing on the monochrome screen is
  140. ** really made up of characters. This specifies which characters to use.
  141. */
  142. struct BoxDataType {
  143. char UpperLeft;
  144. char TopEdge;
  145. char UpperRight;
  146. char RightEdge;
  147. char BottomRight;
  148. char BottomEdge;
  149. char BottomLeft;
  150. char LeftEdge;
  151. };
  152. static BoxDataType const CharData[4];
  153. /*
  154. ** Each cell is constructed of the actual character that is displayed and the
  155. ** attribute to use. This character pair is located at every position on the
  156. ** display (80 x 25). Since this cell pair can be represented by a "short"
  157. ** integer, certain speed optimizations are taken in the monochrome drawing
  158. ** code.
  159. */
  160. struct CellType {
  161. unsigned char Character; // Character to display.
  162. unsigned char Attribute; // Attribute.
  163. };
  164. struct MonoPageType {
  165. CellType Data[LINES][COLUMNS];
  166. };
  167. /*
  168. ** These private constants are used in the various monochrome operations.
  169. */
  170. enum MonoClassPortEnums {
  171. CONTROL_PORT=0x03B4, // CRTC control register.
  172. DATA_PORT=0x03B5, // CRTC data register.
  173. SIZE_OF_PAGE=(int)LINES*(int)COLUMNS*sizeof(CellType) // Entire page size.
  174. };
  175. /*
  176. ** This array contains pointers to the monochrome objects that are assigned
  177. ** to each of the monochrome pages. As the monochrome pages are made visible,
  178. ** they can be shuffled around between the actual locations. The first entry
  179. ** in this table is the one that is visible.
  180. */
  181. static MonoClass * PageUsage[MAX_MONO_PAGES];
  182. /*
  183. ** Fetches pointers to the appropriate mono RAM.
  184. */
  185. MonoPageType * Raw_Ptr(int page) const {
  186. return &((MonoPageType *)0xB0000)[page];
  187. }
  188. MonoPageType * Page_Ptr(void) const {
  189. return(Raw_Ptr(Page));
  190. }
  191. /*
  192. ** If this is true, then monochrome output is allowed. It defaults to false
  193. ** so that monochrome output must be explicitly enabled.
  194. */
  195. static bool Enabled;
  196. };
  197. #ifndef WIN32
  198. int Mono_Printf(int string, ...);
  199. #else
  200. extern void Mono_Set_Cursor(int x, int y);
  201. extern int Mono_Printf(int string, ...);
  202. extern int Mono_Printf(char const * string, ...);
  203. extern void Mono_Clear_Screen(void);
  204. extern void Mono_Text_Print(void const *text, int x, int y, int attrib);
  205. extern void Mono_Draw_Rect(int x, int y, int w, int h, int attrib, int thick);
  206. extern void Mono_Print(void const *text);
  207. extern int Mono_X(void);
  208. extern int Mono_Y(void);
  209. #endif
  210. #endif