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