MONO.H 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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: F:\projects\c&c\vcs\code\monoc.h_v 2.16 06 Sep 1995 16:29:02 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_H
  37. #define MONOC_H
  38. class MonoClass {
  39. /*
  40. ** This is a private structure that is used to control which characters
  41. ** are used when a box is drawn. Line drawing on the monochrome screen is
  42. ** really made up of characters. This specifies which characters to use.
  43. */
  44. typedef struct {
  45. char UpperLeft;
  46. char TopEdge;
  47. char UpperRight;
  48. char RightEdge;
  49. char BottomRight;
  50. char BottomEdge;
  51. char BottomLeft;
  52. char LeftEdge;
  53. } BoxDataType;
  54. /*
  55. ** Each cell is constructed of the actual character that is displayed and the
  56. ** attribute to use. This character pair is located at every position on the
  57. ** display (80 x 25). Since this cell pair can be represented by a "short"
  58. ** integer, certain speed optimizations are taken in the monochrome drawing
  59. ** code.
  60. */
  61. typedef struct {
  62. char Character; // Character to display.
  63. char Attribute; // Attribute.
  64. } CellType;
  65. /*
  66. ** These private constants are used in the various monochrome operations.
  67. */
  68. enum MonoClassPortEnums {
  69. CONTROL_PORT=0x03B4, // CRTC control register.
  70. DATA_PORT=0x03B5, // CRTC data register.
  71. COLUMNS=80, // Number of columns.
  72. LINES=25, // Number of lines.
  73. SIZE_OF_PAGE=LINES*COLUMNS*sizeof(CellType), // Entire page size.
  74. DEFAULT_ATTRIBUTE=0x02 // Normal white on black color attribute.
  75. };
  76. public:
  77. enum MonoClassPageEnums {
  78. MAX_MONO_PAGES=16, // Maximum RAM pages on mono card.
  79. SEGMENT=0xB000 // Monochrome screen segment.
  80. };
  81. /*
  82. ** These are the various box styles that may be used.
  83. */
  84. typedef enum BoxStyleType {
  85. SINGLE, // Single thickness.
  86. DOUBLE_HORZ, // Double thick on the horizontal axis.
  87. DOUBLE_VERT, // Double thick on the vertical axis.
  88. DOUBLE, // Double thickness.
  89. COUNT
  90. } BoxStyleType;
  91. MonoClass(void);
  92. ~MonoClass(void);
  93. static void Enable(void) {Enabled = 1;};
  94. static void Disable(void) {Enabled = 0;};
  95. static int Is_Enabled(void) {return Enabled;};
  96. static MonoClass * Get_Current(void) {return PageUsage[0];};
  97. void Draw_Box(int x, int y, int w, int h, char attrib=DEFAULT_ATTRIBUTE, BoxStyleType thick=SINGLE);
  98. void Set_Default_Attribute(char attrib) {Attrib = attrib;};
  99. void Clear(void);
  100. void Set_Cursor(int x, int y);
  101. void Print(char const *text);
  102. void Print(int text);
  103. void Printf(char const *text, ...);
  104. void Printf(int text, ...);
  105. void Text_Print(char const *text, int x, int y, char attrib=DEFAULT_ATTRIBUTE);
  106. void Text_Print(int text, int x, int y, char attrib=DEFAULT_ATTRIBUTE);
  107. void View(void);
  108. int Get_X(void) const {return X;};
  109. int Get_Y(void) const {return Y;};
  110. /*
  111. ** Handles deep copies for the mono class objects. This performs what is essentially
  112. ** a screen copy.
  113. */
  114. MonoClass & operator = (MonoClass const & );
  115. /*
  116. ** This merely makes a duplicate of the mono object into a newly created mono
  117. ** object.
  118. */
  119. MonoClass (MonoClass const &);
  120. private:
  121. char X; // Cursor X position.
  122. char Y; // Cursor Y position.
  123. char Attrib; // Normal attribute to use if none specified.
  124. char Page; // The current page to write to.
  125. /*
  126. ** Helper functions to help with display operations.
  127. */
  128. int Offset(int x=0, int y=0) const {return (SIZE_OF_PAGE*Page) + sizeof(CellType)*(x + (y*COLUMNS));};
  129. void Scroll(int lines);
  130. void Store_Cell(CellType &cell, int x, int y) {
  131. *(CellType *)((long)MonoSegment + Offset(x, y)) = cell;
  132. };
  133. /*
  134. ** This is the segment/selector of the monochrome screen.
  135. */
  136. static void * MonoSegment;
  137. /*
  138. ** This the the arrays of characters used for drawing boxes.
  139. */
  140. static BoxDataType const CharData[4];
  141. /*
  142. ** This array contains pointers to the monochrome objects that are assigned
  143. ** to each of the monochrome pages. As the monochrome pages are made visible,
  144. ** they can be shuffled around between the actual locations. The first entry
  145. ** in this table is the one that is visible.
  146. */
  147. static MonoClass * PageUsage[MAX_MONO_PAGES];
  148. /*
  149. ** If this is true, then monochrome output is allowed. It defaults to false
  150. ** so that monochrome output must be explicitly enabled.
  151. */
  152. static int Enabled;
  153. };
  154. void Mono_Set_Cursor(int x, int y);
  155. int Mono_Printf(char const *string, ...);
  156. void Mono_Clear_Screen(void);
  157. void Mono_Text_Print(void const *text, int x, int y, int attrib);
  158. void Mono_Draw_Rect(int x, int y, int w, int h, int attrib, int thick);
  159. void Mono_Print(void const *text);
  160. int Mono_X(void);
  161. int Mono_Y(void);
  162. #endif