MONOC.H 8.0 KB

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