MONOC.H 7.0 KB

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