CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

MONOC.H (8159B)


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