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