CnC_Remastered_Collection

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

GBUFFER.H (66488B)


      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 /***************************************************************************
     17  **   C O N F I D E N T I A L --- W E S T W O O D   A S S O C I A T E S   **
     18  ***************************************************************************
     19  *                                                                         *
     20  *                 Project Name : Westwood 32 Bit Library						*
     21  *                                                                         *
     22  *                    File Name : GBUFFER.H                                *
     23  *                                                                         *
     24  *                   Programmer : Phil W. Gorrow                           *
     25  *                                                                         *
     26  *                   Start Date : May 26, 1994                             *
     27  *                                                                         *
     28  *                  Last Update : October 9, 1995   []                     *
     29  *                                                                         *
     30  ***************************************************************************
     31  *                                                                         *
     32  *	This module contains the definition for the graphic buffer class.  The	*
     33  * primary functionality of the graphic buffer class is handled by inline	*
     34  * functions that make a call through function pointers to the correct		*
     35  * routine.  This has two benefits:														*
     36  *																									*
     37  *																									*
     38  *		1) C++ name mangling is not a big deal since the function pointers	*
     39  *		   point to functions in standard C format.									*
     40  *		2) The function pointers can be changed when we set a different		*
     41  *       graphic mode.  This allows us to have both supervga and mcga		*
     42  *			routines present in memory at once.											*
     43  *																									*
     44  * In the basic library, these functions point to stub routines which just	*
     45  * return.  This makes a product that just uses a graphic buffer take the	*
     46  * minimum amount of code space.  For programs that require MCGA or VESA	*
     47  * support, all that is necessary to do is link either the MCGA or VESA		*
     48  * specific libraries in, previous to WWLIB32.  The linker will then 		*
     49  * overide the the necessary stub functions automatically.						*
     50  *																									*
     51  * In addition, there are helpful inline function calls for parameter		*
     52  * ellimination.  This header file gives the defintion for all					*
     53  * GraphicViewPort and GraphicBuffer classes.  										*
     54  *																									*
     55  * Terminology:																				*
     56  *																									*
     57  *	Buffer Class - A class which consists of a pointer to an allocated		*
     58  *		buffer and the size of the buffer that was allocated.						*
     59  *																									*
     60  *	Graphic ViewPort - The Graphic ViewPort defines a window into a 			*
     61  *		Graphic Buffer.  This means that although a Graphic Buffer 				*
     62  *		represents linear memory, this may not be true with a Graphic			*
     63  *		Viewport.  All low level functions that act directly on a graphic		*
     64  *		viewport are included within this class.  This includes but is not	*
     65  *		limited to most of the functions which can act on a Video Viewport	*
     66  *		Video Buffer.																			*
     67  *																									*
     68  * Graphic Buffer - A Graphic Buffer is an instance of an allocated buffer	*
     69  *		used to represent a rectangular region of graphics memory.				*
     70  *		The HidBuff	and BackBuff are excellent examples of a Graphic Buffer.	*
     71  *																									*
     72  * Below is a tree which shows the relationship of the VideoBuffer and 		*
     73  * Buffer classes to the GraphicBuffer class:										*
     74  *																									*
     75  *	  BUFFER.H				 GBUFFER.H			  BUFFER.H				 VBUFFER.H	*
     76  *  ----------          ----------         ----------          ----------	*
     77  * |  Buffer  |        | Graphic  |       |  Buffer  |        |  Video   |	*
     78  * |  Class   |        | ViewPort |       |  Class   |        | ViewPort |	*
     79  *  ----------          ----------         ----------          ----------	*
     80  *            \        /                             \        /				*
     81  *             \      /                               \      /					*
     82  *            ----------                             ----------				*
     83  *           |  Graphic |                           |  Video   |				*
     84  *           |  Buffer  |                           |  Buffer  |				*
     85  *            ----------                             ---------- 				*
     86  *	  			  GBUFFER.H			                       VBUFFER.H					*
     87  *-------------------------------------------------------------------------*
     88  * Functions:                                                              *
     89  *   GBC::GraphicBufferClass -- inline constructor for GraphicBufferClass  *
     90  *   GVPC::Remap -- Short form to remap an entire graphic view port        *
     91  *   GVPC::Get_XPos -- Returns x offset for a graphic viewport class       *
     92  *   GVPC::Get_Ypos -- Return y offset in a GraphicViewPortClass           *
     93  *   VVPC::Get_XPos -- Get the x pos of the VP on the Video                *
     94  *   VVPC::Get_YPos -- Get the y pos of the VP on the video                *
     95  *   GBC::Get_Graphic_Buffer -- Get the graphic buffer of the VP.          *
     96  *   GVPC::Draw_Line -- Stub function to draw line in Graphic Viewport Class*
     97  *   GVPC::Fill_Rect -- Stub function to fill rectangle in a GVPC          *
     98  *   GVPC::Remap -- Stub function to remap a GVPC                          *
     99  *   GVPC::Print -- stub func to print a text string                       *
    100  *   GVPC::Print -- Stub function to print an integer                      *
    101  *   GVPC::Print -- Stub function to print a short to a graphic viewport   *
    102  *   GVPC::Print -- stub function to print a long on a graphic view port   *
    103  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
    104 
    105 #ifndef _WIN32 // Denzil 6/2/98 Watcom 11.0 complains without this check
    106 #define _WIN32
    107 #endif // _WIN32
    108 
    109 #define WIN32_LEAN_AND_MEAN
    110 #include <ddraw.h>
    111 
    112 
    113 #ifndef GBUFFER_H
    114 #define GBUFFER_H
    115 
    116 /*=========================================================================*/
    117 /* If we have not already loaded the standard library header, than we can	*/
    118 /*		load it.																					*/
    119 /*=========================================================================*/
    120 
    121 #ifndef WWSTD_H
    122 #include "wwstd.h"
    123 #endif
    124 
    125 #ifndef DRAWBUFF_H
    126 #include "drawbuff.h"
    127 #endif
    128 
    129 //#ifndef BUFFER_H
    130 #include "buffer.h"
    131 //#endif
    132 
    133 #ifndef WINDOWS_H
    134 #include "ww_win.h"
    135 #endif
    136 #include <stdlib.h>
    137 
    138 #include "iconcach.h"
    139 
    140 
    141 
    142 #ifndef FUNCTION_H
    143 
    144 //#pragma off (unreferenced)
    145 
    146 #ifndef BITMAPCLASS
    147 #define BITMAPCLASS
    148 class BitmapClass
    149 {
    150 	public:
    151 		BitmapClass(int w, int h, unsigned char * data) :
    152 			Width(w), Height(h), Data(data) {};
    153 
    154 		int Width;
    155 		int Height;
    156 		unsigned char * Data;
    157 };
    158 
    159 class TPoint2D
    160 {
    161 	public:
    162 		TPoint2D(int xx, int yy) : x(xx), y(yy) {};
    163 		TPoint2D(void) : x(0), y(0) {};
    164 
    165 		int x;
    166 		int y;
    167 };
    168 #endif
    169 
    170 //#pragma on (unreferenced)
    171 #endif
    172 
    173 
    174 //////////////////////////////////////////////////////////////////////////
    175 //
    176 // Defines for direct draw
    177 //
    178 //
    179 extern	LPDIRECTDRAW	DirectDrawObject;	//pointer to direct draw object
    180 extern	HWND			MainWindow;			//handle to programs main window
    181 
    182 /*
    183 ** Pointer to function to call if we detect a focus loss
    184 */
    185 extern	void (*Gbuffer_Focus_Loss_Function)(void);
    186 
    187 enum GBC_Enum {
    188 	GBC_NONE				= 0,
    189 	GBC_VIDEOMEM		= 1,
    190 	GBC_VISIBLE			= 2,
    191 };
    192 
    193 #define	NOT_LOCKED		NULL
    194 
    195 /*=========================================================================*/
    196 /* Define the screen width and height to make portability to other modules	*/
    197 /*		easier.																					*/
    198 /*=========================================================================*/
    199 #define	DEFAULT_SCREEN_WIDTH		356
    200 #define	DEFAULT_SCREEN_HEIGHT	200
    201 
    202 /*=========================================================================*/
    203 /* Let the compiler know that a GraphicBufferClass exists so that it can	*/
    204 /*		keep a pointer to it in a VideoViewPortClass.								*/
    205 /*=========================================================================*/
    206 class GraphicViewPortClass;
    207 class GraphicBufferClass;
    208 class VideoViewPortClass;
    209 class VideoBufferClass;
    210 
    211 GraphicViewPortClass *Set_Logic_Page(GraphicViewPortClass *ptr);
    212 GraphicViewPortClass *Set_Logic_Page(GraphicViewPortClass &ptr);
    213 
    214 /*=========================================================================*/
    215 /* GraphicViewPortClass - Holds viewport information on a viewport which	*/
    216 /*		has been attached to a GraphicBuffer.  A viewport is effectively a	*/
    217 /*		rectangular subset of the full buffer which is used for clipping and	*/
    218 /*		the like.																				*/
    219 /*																									*/
    220 /*			char	  	*Buffer	-		is the offset to view port buffer			*/
    221 /*			int	  	Width		-		is the width of view port						*/
    222 /*			int	  	Height	-		is the height of view port						*/
    223 /*			int	  	XAdd		-		is add value to go from the end of a line	*/
    224 /*											to the beginning of the next line			*/
    225 /*			int		XPos;		- 		x offset into its associated VideoBuffer	*/
    226 /*			int		YPos;		-		y offset into its associated VideoBuffer	*/
    227 /*=========================================================================*/
    228 class GraphicViewPortClass {
    229 	public:
    230 
    231 		/*===================================================================*/
    232 		/* Define the base constructor and destructors for the class			*/
    233 		/*===================================================================*/
    234 		GraphicViewPortClass(GraphicBufferClass* graphic_buff, int x, int y, int w, int h);
    235 		GraphicViewPortClass();
    236 		~GraphicViewPortClass();
    237 
    238 		/*===================================================================*/
    239 		/* define functions to get at the private data members					*/
    240 		/*===================================================================*/
    241 		long	Get_Offset(void);
    242 		int	Get_Height(void);
    243 		int	Get_Width(void);
    244 		int	Get_XAdd(void);
    245 		int	Get_XPos(void);
    246 		int	Get_YPos(void);
    247 		int	Get_Pitch(void);
    248 		inline BOOL	Get_IsDirectDraw(void);
    249 		GraphicBufferClass	*Get_Graphic_Buffer(void);
    250 
    251 		/*===================================================================*/
    252 		/* Define a function which allows us to change a video viewport on	*/
    253 		/*		the fly.																			*/
    254 		/*===================================================================*/
    255 		BOOL Change(int x, int y, int w, int h);
    256 
    257 		/*===================================================================*/
    258 		/* Define the set of common graphic functions that are supported by	*/
    259 		/*		both Graphic ViewPorts and VideoViewPorts.							*/
    260 		/*===================================================================*/
    261 		long	Size_Of_Region(int w, int h);
    262 		void	Put_Pixel(int x, int y, unsigned char color);
    263 		int	Get_Pixel(int x, int y);
    264 		void	Clear(unsigned char color = 0);
    265 		long	To_Buffer(int x, int y, int w, int h, void *buff, long size);
    266 		long	To_Buffer(int x, int y, int w, int h, BufferClass *buff);
    267 		long	To_Buffer(BufferClass *buff);
    268 		HRESULT	Blit(	GraphicViewPortClass& dest, int x_pixel, int y_pixel, int dx_pixel,
    269 						int dy_pixel, int pixel_width, int pixel_height, BOOL trans = FALSE);
    270 		HRESULT	Blit(	GraphicViewPortClass& dest, int dx, int dy, BOOL trans = FALSE);
    271 		HRESULT	Blit(	GraphicViewPortClass& dest, BOOL trans = FALSE);
    272 		HRESULT	Blit(	VideoViewPortClass& dest, int x_pixel, int y_pixel, int dx_pixel,
    273 						int dy_pixel, int pixel_width, int pixel_height, BOOL trans = FALSE);
    274 		HRESULT	Blit(	VideoViewPortClass& dest, int dx, int dy, BOOL trans = FALSE);
    275 		HRESULT	Blit(	VideoViewPortClass& dest, BOOL trans = FALSE);
    276 		BOOL	Scale(	GraphicViewPortClass &dest, int src_x, int src_y, int dst_x,
    277 							int dst_y, int src_w, int src_h, int dst_w, int dst_h, BOOL trans = FALSE, char *remap = NULL);
    278 		BOOL	Scale(	GraphicViewPortClass &dest, int src_x, int src_y, int dst_x,
    279 							int dst_y, int src_w, int src_h, int dst_w, int dst_h, char *remap);
    280 		BOOL	Scale(	GraphicViewPortClass &dest, BOOL trans = FALSE, char *remap = NULL);
    281 		BOOL	Scale(	GraphicViewPortClass &dest, char *remap);
    282 		BOOL	Scale(	VideoViewPortClass &dest, int src_x, int src_y, int dst_x,
    283 							int dst_y, int src_w, int src_h, int dst_w, int dst_h, BOOL trans = FALSE, char *remap = NULL);
    284 		BOOL	Scale(	VideoViewPortClass &dest, int src_x, int src_y, int dst_x,
    285 							int dst_y, int src_w, int src_h, int dst_w, int dst_h, char *remap);
    286 		BOOL	Scale(	VideoViewPortClass &dest, BOOL trans = FALSE, char *remap = NULL);
    287 		BOOL	Scale(	VideoViewPortClass &dest, char *remap);
    288 		unsigned long	Print(char const *string, int x_pixel, int y_pixel, int fcolor, int bcolor);
    289 		unsigned long	Print(short num, int x_pixel, int y_pixel, int fcol, int bcol);
    290 		unsigned long	Print(int num, int x_pixel, int y_pixel, int fcol, int bcol);
    291 		unsigned long	Print(long num, int x_pixel, int y_pixel, int fcol, int bcol);
    292 
    293 		/*===================================================================*/
    294 		/* Define the list of graphic functions which work only with a 		*/
    295 		/*		graphic buffer.																*/
    296 		/*===================================================================*/
    297 		VOID Draw_Line(int sx, int sy, int dx, int dy, unsigned char color);
    298 		VOID Draw_Rect(int sx, int sy, int dx, int dy, unsigned char color);
    299 		VOID Fill_Rect(int sx, int sy, int dx, int dy, unsigned char color);
    300 		VOID Fill_Quad(VOID *span_buff, int x0, int y0, int x1, int y1,
    301 							int x2, int y2, int x3, int y3, int color);
    302 		VOID Remap(int sx, int sy, int width, int height, VOID *remap);
    303 		VOID Remap(VOID *remap);
    304 		void Draw_Stamp(void const *icondata, int icon, int x_pixel, int y_pixel, void const *remap);
    305 		void Draw_Stamp(void const *icondata, int icon, int x_pixel, int y_pixel, void const *remap, int clip_window);
    306 
    307 //	This doesnt seem to exist anywhere?? - Steve T 9/26/95 6:05PM
    308 //		VOID Grey_Out_Region(int x, int y, int width, int height, int color);
    309 
    310 		//
    311 		// New members to lock and unlock the direct draw video memory
    312 		//
    313 		inline BOOL 	Lock ();
    314 		inline BOOL 	Unlock();
    315 		inline int		Get_LockCount();
    316 
    317 		// Member to blit using direct draw access to hardware blitter
    318 		HRESULT DD_Linear_Blit_To_Linear ( GraphicViewPortClass &dest, int source_x, int source_y, int dest_x, int dest_y, int width	, int height, BOOL mask );
    319 
    320 		/*===================================================================*/
    321 		/* Define functions to attach the viewport to a graphicbuffer			*/
    322 		/*===================================================================*/
    323 		VOID Attach(GraphicBufferClass *graphic_buff, int x, int y, int w, int h);
    324 		void Attach(GraphicBufferClass *video_buff, int w, int h);
    325 
    326 	protected:
    327 
    328 		/*===================================================================*/
    329 		/* Define the data used by a GraphicViewPortClass							*/
    330 		/*===================================================================*/
    331 		long					Offset;			// offset to graphic page
    332 		int						Width;			// width of graphic page
    333 		int						Height;			// height of graphic page
    334 		int						XAdd;			// xadd for graphic page (0)
    335 		int						XPos;			// x offset in relation to graphicbuff
    336 		int						YPos;			// y offset in relation to graphicbuff
    337 		long					Pitch;			//Distance from one line to the next
    338 		GraphicBufferClass		*GraphicBuff;	// related graphic buff
    339 		BOOL					IsDirectDraw;	//Flag to let us know if it is a direct draw surface
    340 		int						LockCount;		// Count for stacking locks if non-zero the buffer
    341 };                                              //   is a locked DD surface
    342 
    343 /*=========================================================================*/
    344 /* GraphicBufferClass - A GraphicBuffer refers to an actual instance of an	*/
    345 /*		allocated buffer.  The GraphicBuffer may be drawn to directly 			*/
    346 /*		becuase it inherits a ViewPort which represents its physcial size.	*/
    347 /*																									*/
    348 /*			BYTE	  	*Buffer	-		is the offset to graphic buffer				*/
    349 /*			int	  	Width		-		is the width of graphic buffer				*/
    350 /*			int	  	Height	-		is the height of graphic buffer				*/
    351 /*			int	  	XAdd		-		is the xadd of graphic buffer					*/
    352 /*			int		XPos;		- 		will be 0 because it is graphicbuff			*/
    353 /*			int		YPos;		-		will be 0 because it is graphicbuff			*/
    354 /*			long	Pitch		-		modulo of buffer for reading and writing																						*/
    355 /*			BOOL	IsDirectDraw - 		flag if its a direct draw surface																						*/
    356 /*=========================================================================*/
    357 class GraphicBufferClass : public GraphicViewPortClass, public BufferClass {
    358 
    359 	public:
    360 		GraphicBufferClass(int w, int h, GBC_Enum flags);
    361 		GraphicBufferClass(int w, int h,	void *buffer, long size);
    362 		GraphicBufferClass(int w, int h, void *buffer = 0);
    363 		GraphicBufferClass(void);
    364 		~GraphicBufferClass();
    365 
    366 		void DD_Init(GBC_Enum flags);
    367 		void Init(int w, int h, void *buffer, long size, GBC_Enum flags);
    368 		void Un_Init(void);
    369 		void GraphicBufferClass::Attach_DD_Surface (GraphicBufferClass * attach_buffer);
    370 		BOOL Lock(void);
    371 		BOOL Unlock(void);
    372 
    373 		void Scale_Rotate(BitmapClass &bmp,TPoint2D const &pt,long scale,unsigned char angle);
    374 
    375 		// Member to get a pointer to a direct draw surface
    376 		LPDIRECTDRAWSURFACE Get_DD_Surface ( void );
    377 
    378 	protected:
    379 		LPDIRECTDRAWSURFACE	VideoSurfacePtr;		//Pointer to the related direct draw surface
    380 		DDSURFACEDESC			VideoSurfaceDescription;//Description of the said surface
    381 
    382 };
    383 
    384 
    385 
    386 inline int GraphicViewPortClass::Get_LockCount(void)
    387 {
    388 	return (LockCount);
    389 }
    390 
    391 
    392 
    393 /***********************************************************************************************
    394  * GVPC::Get_IsDirectDraw -- provide read access to the IsDirectDraw flag                      *
    395  *                                                                                             *
    396  *                                                                                             *
    397  *                                                                                             *
    398  * INPUT:    Nothing                                                                           *
    399  *                                                                                             *
    400  * OUTPUT:   IsDirectDraw                                                                      *
    401  *                                                                                             *
    402  * WARNINGS: None                                                                              *
    403  *                                                                                             *
    404  * HISTORY:                                                                                    *
    405  *    11/29/95 1:02PM ST : Created                                                             *
    406  *=============================================================================================*/
    407 inline BOOL GraphicViewPortClass::Get_IsDirectDraw(void)
    408 {
    409 	return (IsDirectDraw);
    410 }
    411 
    412 
    413 
    414 /***********************************************************************************************
    415  * GBC::Get_DD_Surface -- returns a pointer to the buffer direct draw surface                  *
    416  *                                                                                             *
    417  *                                                                                             *
    418  *                                                                                             *
    419  * INPUT:    Nothing                                                                           *
    420  *                                                                                             *
    421  * OUTPUT:   ptr to direct draw surface                                                        *
    422  *                                                                                             *
    423  * WARNINGS: None                                                                              *
    424  *                                                                                             *
    425  * HISTORY:                                                                                    *
    426  *    9/29/95 9:43AM ST : Created                                                              *
    427  *=============================================================================================*/
    428 inline LPDIRECTDRAWSURFACE GraphicBufferClass::Get_DD_Surface ( void )
    429 {
    430 	return ( VideoSurfacePtr );
    431 
    432 }
    433 
    434 
    435 
    436 /***********************************************************************************************
    437  * GVPC::Lock -- lock the graphics buffer for reading or writing                               *
    438  *                                                                                             *
    439  *                                                                                             *
    440  *                                                                                             *
    441  * INPUT:    Nothing                                                                           *
    442  *                                                                                             *
    443  * OUTPUT:   TRUE if surface was successfully locked                                           *
    444  *                                                                                             *
    445  * WARNINGS: None                                                                              *
    446  *                                                                                             *
    447  * HISTORY:                                                                                    *
    448  *   09-19-95 12:33pm ST : Created                                                             *
    449  *   10/09/1995     : Moved actually functionality to GraphicBuffer                            *
    450  *=============================================================================================*/
    451 inline BOOL GraphicViewPortClass::Lock(void)
    452 {
    453 	BOOL lock = GraphicBuff->Lock();
    454 	if ( !lock ) return(FALSE);
    455 
    456 	if (this != GraphicBuff) {
    457 		Attach(GraphicBuff, XPos, YPos,  Width, Height);
    458 	}
    459 	return(TRUE);
    460 }
    461 
    462 /***********************************************************************************************
    463  * GVPC::Unlock -- unlock the video buffer                                                     *
    464  *                                                                                             *
    465  *                                                                                             *
    466  *                                                                                             *
    467  * INPUT:    Nothing                                                                           *
    468  *                                                                                             *
    469  * OUTPUT:   TRUE if surface was successfully unlocked                                         *
    470  *                                                                                             *
    471  * WARNINGS: None                                                                              *
    472  *                                                                                             *
    473  * HISTORY:                                                                                    *
    474  *   09-19-95 02:20pm ST : Created                                                             *
    475  *   10/09/1995     : Moved actually functionality to GraphicBuffer                            *
    476  *=============================================================================================*/
    477 inline BOOL GraphicViewPortClass::Unlock(void)
    478 {
    479 	BOOL unlock = GraphicBuff->Unlock();
    480 	if (!unlock) return(FALSE);
    481 	if (this != GraphicBuff && IsDirectDraw && !GraphicBuff->LockCount) {
    482 		Offset = 0;
    483 	}
    484 	return(TRUE);
    485 }
    486 
    487 
    488 /***************************************************************************
    489  * GVPC::GET_OFFSET -- Get offset for virtual view port class instance     *
    490  *                                                                         *
    491  * INPUT:		none                                                        *
    492  *                                                                         *
    493  * OUTPUT:     long the offset for the virtual viewport instance           *
    494  *                                                                         *
    495  * HISTORY:                                                                *
    496  *   06/07/1994 PWG : Created.                                             *
    497  *=========================================================================*/
    498 inline long GraphicViewPortClass::Get_Offset(void)
    499 {
    500 	return(Offset);
    501 }
    502 
    503 /***************************************************************************
    504  * GVPC::GET_HEIGHT -- Gets the height of a virtual viewport instance      *
    505  *                                                                         *
    506  * INPUT:		none                                                        *
    507  *                                                                         *
    508  * OUTPUT:     WORD the height of the virtual viewport instance            *
    509  *                                                                         *
    510  * HISTORY:                                                                *
    511  *   06/07/1994 PWG : Created.                                             *
    512  *=========================================================================*/
    513 inline int GraphicViewPortClass::Get_Height(void)
    514 {
    515 	return(Height);
    516 }
    517 
    518 /***************************************************************************
    519  * GVPC::GET_WIDTH -- Get the width of a virtual viewport instance			*
    520  *                                                                         *
    521  * INPUT:		none                                                        *
    522  *                                                                         *
    523  * OUTPUT:     WORD the width of the virtual viewport instance             *
    524  *                                                                         *
    525  * HISTORY:                                                                *
    526  *   06/07/1994 PWG : Created.                                             *
    527  *=========================================================================*/
    528 inline int GraphicViewPortClass::Get_Width(void)
    529 {
    530 	return(Width);
    531 }
    532 
    533 
    534 /***************************************************************************
    535  * GVPC::GET_XADD -- Get the X add offset for virtual viewport instance    *
    536  *                                                                         *
    537  * INPUT:		none                                                        *
    538  *                                                                         *
    539  * OUTPUT:     WORD the xadd for a virtual viewport instance               *
    540  *                                                                         *
    541  * HISTORY:                                                                *
    542  *   06/07/1994 PWG : Created.                                             *
    543  *=========================================================================*/
    544 inline int GraphicViewPortClass::Get_XAdd(void)
    545 {
    546 	return(XAdd);
    547 }
    548 /***************************************************************************
    549  * GVPC::GET_XPOS -- Get the x pos of the VP on the Video                  *
    550  *                                                                         *
    551  * INPUT:		none                                                        *
    552  *                                                                         *
    553  * OUTPUT:     WORD the x offset to VideoBufferClass								*
    554  *                                                                         *
    555  * HISTORY:                                                                *
    556  *   08/22/1994 SKB : Created.                                             *
    557  *=========================================================================*/
    558 inline int GraphicViewPortClass::Get_XPos(void)
    559 {
    560 	return(XPos);
    561 }
    562 
    563 
    564 /***************************************************************************
    565  * GVPC::GET_YPOS -- Get the y pos of the VP on the video                  *
    566  *                                                                         *
    567  * INPUT:		none                                                        *
    568  *                                                                         *
    569  * OUTPUT:     WORD the x offset to VideoBufferClass								*
    570  *                                                                         *
    571  * WARNINGS:                                                               *
    572  *                                                                         *
    573  * HISTORY:                                                                *
    574  *   08/22/1994 SKB : Created.                                             *
    575  *=========================================================================*/
    576 inline int GraphicViewPortClass::Get_YPos(void)
    577 {
    578 	return(YPos);
    579 }
    580 
    581 /***************************************************************************
    582  * GVPC::GET_GRAPHIC_BUFFER -- Get the graphic buffer of the VP.            *
    583  *                                                                         *
    584  * INPUT:                                                                  *
    585  *                                                                         *
    586  * OUTPUT:                                                                 *
    587  *                                                                         *
    588  * HISTORY:                                                                *
    589  *   08/22/1994 SKB : Created.                                             *
    590  *=========================================================================*/
    591 inline GraphicBufferClass *GraphicViewPortClass::Get_Graphic_Buffer(void)
    592 {
    593 	return (GraphicBuff);
    594 }
    595 
    596 /***************************************************************************
    597  * GVPC::SIZE_OF_REGION -- stub to call curr graphic mode Size_Of_Region	*
    598  *                                                                         *
    599  * INPUT:                                                                  *
    600  *                                                                         *
    601  * OUTPUT:                                                                 *
    602  *                                                                         *
    603  * WARNINGS:                                                               *
    604  *                                                                         *
    605  * HISTORY:                                                                *
    606  *   03/01/1995 BWG : Created.                                             *
    607  *=========================================================================*/
    608 inline long	GraphicViewPortClass::Size_Of_Region(int w, int h)
    609 {
    610 	return Buffer_Size_Of_Region(this, w, h);
    611 }
    612 
    613 
    614 /***************************************************************************
    615  * GVPC::PUT_PIXEL -- stub to call curr graphic mode Put_Pixel					*
    616  *                                                                         *
    617  * INPUT:                                                                  *
    618  *                                                                         *
    619  * OUTPUT:                                                                 *
    620  *                                                                         *
    621  * WARNINGS:                                                               *
    622  *                                                                         *
    623  * HISTORY:                                                                *
    624  *   01/06/1995 PWG : Created.                                             *
    625  *=========================================================================*/
    626 inline void	GraphicViewPortClass::Put_Pixel(int x, int y, unsigned char color)
    627 {
    628 
    629 	if (Lock()){
    630 		Buffer_Put_Pixel(this, x, y, color);
    631 	}
    632 	Unlock();
    633 
    634 
    635 }
    636 
    637 /***************************************************************************
    638  * GVPC::GET_PIXEL -- stub to call curr graphic mode Get_Pixel          	*
    639  *                                                                         *
    640  * INPUT:                                                                  *
    641  *                                                                         *
    642  * OUTPUT:                                                                 *
    643  *                                                                         *
    644  * WARNINGS:                                                               *
    645  *                                                                         *
    646  * HISTORY:                                                                *
    647  *   01/06/1995 PWG : Created.                                             *
    648  *=========================================================================*/
    649 inline int	GraphicViewPortClass::Get_Pixel(int x, int y)
    650 {
    651 	int		return_code=0;
    652 
    653 	if (Lock()){
    654 		return_code=(Buffer_Get_Pixel(this, x, y));
    655 	}
    656 	Unlock();
    657 	return(return_code);
    658 
    659 }
    660 
    661 /***************************************************************************
    662  * GVPC::CLEAR -- stub to call curr graphic mode Clear	                  *
    663  *                                                                         *
    664  * INPUT:                                                                  *
    665  *                                                                         *
    666  * OUTPUT:                                                                 *
    667  *                                                                         *
    668  * WARNINGS:                                                               *
    669  *                                                                         *
    670  * HISTORY:                                                                *
    671  *   01/06/1995 PWG : Created.                                             *
    672  *=========================================================================*/
    673 inline void	GraphicViewPortClass::Clear(unsigned char color)
    674 {
    675 	if (Lock()){
    676 		Buffer_Clear(this, color);
    677 	}
    678 	Unlock();
    679 
    680 }
    681 
    682 /***************************************************************************
    683  * GVPC::TO_BUFFER -- stub 1 to call curr graphic mode To_Buffer				*
    684  *                                                                         *
    685  * INPUT:                                                                  *
    686  *                                                                         *
    687  * OUTPUT:                                                                 *
    688  *                                                                         *
    689  * WARNINGS:                                                               *
    690  *                                                                         *
    691  * HISTORY:                                                                *
    692  *   01/06/1995 PWG : Created.                                             *
    693  *=========================================================================*/
    694 inline long	GraphicViewPortClass::To_Buffer(int x, int y, int w, int h, void *buff, long size)
    695 {
    696 	long	return_code=0;
    697 	if (Lock()){
    698 		return_code = (Buffer_To_Buffer(this, x, y, w, h, buff, size));
    699 	}
    700 	Unlock();
    701 	return ( return_code );
    702 }
    703 
    704 /***************************************************************************
    705  * GVPC::TO_BUFFER -- stub 2 to call curr graphic mode To_Buffer 				*
    706  *                                                                         *
    707  * INPUT:                                                                  *
    708  *                                                                         *
    709  * OUTPUT:                                                                 *
    710  *                                                                         *
    711  * WARNINGS:                                                               *
    712  *                                                                         *
    713  * HISTORY:                                                                *
    714  *   01/06/1995 PWG : Created.                                             *
    715  *=========================================================================*/
    716 inline long	GraphicViewPortClass::To_Buffer(int x, int y, int w, int h, BufferClass *buff)
    717 {
    718 	long	return_code=0;
    719 	if (Lock()){
    720 		return_code = (Buffer_To_Buffer(this, x, y, w, h, buff->Get_Buffer(), buff->Get_Size()));
    721 	}
    722 	Unlock();
    723 	return ( return_code );
    724 }
    725 
    726 /***************************************************************************
    727  * GVPC::TO_BUFFER -- stub 3 to call curr graphic mode To_Buffer 				*
    728  *                                                                         *
    729  * INPUT:                                                                  *
    730  *                                                                         *
    731  * OUTPUT:                                                                 *
    732  *                                                                         *
    733  * WARNINGS:                                                               *
    734  *                                                                         *
    735  * HISTORY:                                                                *
    736  *   01/06/1995 PWG : Created.                                             *
    737  *=========================================================================*/
    738 inline long	GraphicViewPortClass::To_Buffer(BufferClass *buff)
    739 {
    740 	long	return_code=0;
    741 	if (Lock()){
    742 		return_code = (Buffer_To_Buffer(this, 0, 0, Width, Height, buff->Get_Buffer(), buff->Get_Size()));
    743 	}
    744 	Unlock();
    745 	return ( return_code );
    746 }
    747 
    748 /***************************************************************************
    749  * GVPC::BLIT -- stub 1 to call curr graphic mode Blit to GVPC					*
    750  *                                                                         *
    751  * INPUT:                                                                  *
    752  *                                                                         *
    753  * OUTPUT:                                                                 *
    754  *                                                                         *
    755  * WARNINGS:                                                               *
    756  *                                                                         *
    757  * HISTORY:                                                                *
    758  *   01/06/1995 PWG : Created.                                             *
    759  *=========================================================================*/
    760 inline HRESULT	GraphicViewPortClass::Blit(	GraphicViewPortClass& dest, int x_pixel, int y_pixel, int dx_pixel,
    761 				int dy_pixel, int pixel_width, int pixel_height, BOOL trans)
    762 {
    763 	HRESULT		return_code=0;
    764 
    765 	if ( IsDirectDraw && dest.IsDirectDraw ){
    766 	return(DD_Linear_Blit_To_Linear( dest, XPos+x_pixel, YPos+y_pixel
    767 								, dest.Get_XPos()+dx_pixel, dest.Get_YPos()+dy_pixel
    768 								, pixel_width, pixel_height, trans));
    769 	} else {
    770 
    771 		if (Lock()){
    772 			if (dest.Lock()){
    773 				return_code=(Linear_Blit_To_Linear(this, &dest, x_pixel, y_pixel
    774 														, dx_pixel, dy_pixel
    775 														, pixel_width, pixel_height, trans));
    776 			}
    777 			dest.Unlock();
    778 		}
    779 		Unlock();
    780 	}
    781 
    782 	return ( return_code );
    783 }
    784 
    785 /***************************************************************************
    786  * GVPC::BLIT -- Stub 2 to call curr graphic mode Blit to GVPC					*
    787  *                                                                         *
    788  * INPUT:                                                                  *
    789  *                                                                         *
    790  * OUTPUT:                                                                 *
    791  *                                                                         *
    792  * WARNINGS:                                                               *
    793  *                                                                         *
    794  * HISTORY:                                                                *
    795  *   01/06/1995 PWG : Created.                                             *
    796  *=========================================================================*/
    797 inline HRESULT	GraphicViewPortClass::Blit(	GraphicViewPortClass& dest, int dx, int dy, BOOL trans)
    798 {
    799 	HRESULT		return_code=0;
    800 
    801 
    802 	if ( IsDirectDraw && dest.IsDirectDraw ){
    803 	return(DD_Linear_Blit_To_Linear( dest, XPos, YPos
    804 								, dest.Get_XPos()+dx, dest.Get_YPos()+dy
    805 								, Width, Height, trans));
    806 	} else {
    807 
    808 		if (Lock()){
    809 			if (dest.Lock()){
    810 				return_code=(Linear_Blit_To_Linear(this, &dest, 0, 0
    811 														, dx, dy
    812 														, Width, Height, trans));
    813 			}
    814 			dest.Unlock();
    815 		}
    816 		Unlock();
    817 	}
    818 
    819 	return (return_code);
    820 
    821 }
    822 
    823 /***************************************************************************
    824  * GVPC::BLIT -- stub 3 to call curr graphic mode Blit to GVPC					*
    825  *                                                                         *
    826  * INPUT:                                                                  *
    827  *                                                                         *
    828  * OUTPUT:                                                                 *
    829  *                                                                         *
    830  * WARNINGS:                                                               *
    831  *                                                                         *
    832  * HISTORY:                                                                *
    833  *   01/06/1995 PWG : Created.                                             *
    834  *=========================================================================*/
    835 inline HRESULT	GraphicViewPortClass::Blit(	GraphicViewPortClass& dest, BOOL trans)
    836 {
    837 	HRESULT		return_code=0;
    838 
    839 
    840 	if ( IsDirectDraw && dest.IsDirectDraw ){
    841 	return(DD_Linear_Blit_To_Linear( dest, XPos, YPos
    842 								, dest.Get_XPos(), dest.Get_YPos()
    843 								, MAX( Width, dest.Get_Width())
    844 								, MAX( Height, dest.Get_Height())
    845 								, trans));
    846 	} else {
    847 
    848 		if (Lock()){
    849 			if (dest.Lock()){
    850 				return_code=(Linear_Blit_To_Linear(this, &dest, 0, 0
    851 														, 0, 0
    852 														, Width, Height, trans));
    853 			}
    854 			dest.Unlock();
    855 		}
    856 		Unlock();
    857 	}
    858 
    859 	return (return_code);
    860 
    861 }
    862 
    863 
    864 /***************************************************************************
    865  * GVPC::SCALE -- stub 1 to call curr graphic mode Scale to GVPC				*
    866  *                                                                         *
    867  * INPUT:                                                                  *
    868  *                                                                         *
    869  * OUTPUT:                                                                 *
    870  *                                                                         *
    871  * WARNINGS:                                                               *
    872  *                                                                         *
    873  * HISTORY:                                                                *
    874  *   01/06/1995 PWG : Created.                                             *
    875  *=========================================================================*/
    876 inline BOOL	GraphicViewPortClass::Scale(	GraphicViewPortClass &dest, int src_x, int src_y, int dst_x,
    877 					int dst_y, int src_w, int src_h, int dst_w, int dst_h, BOOL trans, char *remap)
    878 {
    879 	BOOL	return_code=0;
    880 	if (Lock()){
    881 		if (dest.Lock()){
    882 			return_code = (Linear_Scale_To_Linear(this, &dest, src_x, src_y, dst_x, dst_y, src_w, src_h, dst_w, dst_h, trans, remap));
    883 		}
    884 		dest.Unlock();
    885 	}
    886 	Unlock();
    887 	return ( return_code );
    888 }
    889 
    890 /***************************************************************************
    891  * GVPC::SCALE -- stub 2 to call curr graphic mode Scale to GVPC				*
    892  *                                                                         *
    893  * INPUT:                                                                  *
    894  *                                                                         *
    895  * OUTPUT:                                                                 *
    896  *                                                                         *
    897  * WARNINGS:                                                               *
    898  *                                                                         *
    899  * HISTORY:                                                                *
    900  *   01/06/1995 PWG : Created.                                             *
    901  *=========================================================================*/
    902 inline BOOL	GraphicViewPortClass::Scale(	GraphicViewPortClass &dest, int src_x, int src_y, int dst_x,
    903 					int dst_y, int src_w, int src_h, int dst_w, int dst_h, char *remap)
    904 {
    905 	BOOL	return_code=0;
    906 	if (Lock()){
    907 		if (dest.Lock()){
    908 			return_code = (Linear_Scale_To_Linear(this, &dest, src_x, src_y, dst_x, dst_y, src_w, src_h, dst_w, dst_h, FALSE, remap));
    909 		}
    910 		dest.Unlock();
    911 	}
    912 	Unlock();
    913 	return ( return_code );
    914 }
    915 
    916 /***************************************************************************
    917  * GVPC::SCALE -- stub 3 to call curr graphic mode Scale to GVPC				*
    918  *                                                                         *
    919  * INPUT:                                                                  *
    920  *                                                                         *
    921  * OUTPUT:                                                                 *
    922  *                                                                         *
    923  * WARNINGS:                                                               *
    924  *                                                                         *
    925  * HISTORY:                                                                *
    926  *   01/06/1995 PWG : Created.                                             *
    927  *=========================================================================*/
    928 inline BOOL	GraphicViewPortClass::Scale(	GraphicViewPortClass &dest, BOOL trans, char *remap)
    929 {
    930 	BOOL	return_code=0;
    931 	if (Lock()){
    932 		if (dest.Lock()){
    933 			return_code = (Linear_Scale_To_Linear(this,	&dest, 0, 0, 0, 0, Width, Height, dest.Get_Width(), dest.Get_Height(), trans, remap));
    934 		}
    935 		dest.Unlock();
    936 	}
    937 	Unlock();
    938 	return ( return_code );
    939 }
    940 
    941 /***************************************************************************
    942  * GVPC::SCALE -- stub 4 to call curr graphic mode Scale to GVPC				*
    943  *                                                                         *
    944  * INPUT:                                                                  *
    945  *                                                                         *
    946  * OUTPUT:                                                                 *
    947  *                                                                         *
    948  * WARNINGS:                                                               *
    949  *                                                                         *
    950  * HISTORY:                                                                *
    951  *   01/06/1995 PWG : Created.                                             *
    952  *=========================================================================*/
    953 inline BOOL	GraphicViewPortClass::Scale(	GraphicViewPortClass &dest, char *remap)
    954 {
    955 	BOOL	return_code=0;
    956 	if (Lock()){
    957 		if (dest.Lock()){
    958 			return_code = (Linear_Scale_To_Linear(this, &dest, 0, 0, 0, 0, Width, Height, dest.Get_Width(), dest.Get_Height(), FALSE, remap));
    959 		}
    960 		dest.Unlock();
    961 	}
    962 	Unlock();
    963 	return ( return_code );
    964 }
    965 /***************************************************************************
    966  * GVPC::PRINT -- stub func to print a text string                         *
    967  *                                                                         *
    968  * INPUT:                                                                  *
    969  *                                                                         *
    970  * OUTPUT:                                                                 *
    971  *                                                                         *
    972  * WARNINGS:                                                               *
    973  *                                                                         *
    974  * HISTORY:                                                                *
    975  *   01/17/1995 PWG : Created.                                             *
    976  *=========================================================================*/
    977 inline unsigned long	GraphicViewPortClass::Print(char const *str, int x, int y, int fcol, int bcol)
    978 {
    979 	unsigned long	return_code=0;
    980 	if (Lock()){
    981 		return_code = (Buffer_Print(this, str, x, y, fcol, bcol));
    982 	}
    983 	Unlock();
    984 	return ( return_code );
    985 }
    986 
    987 /***************************************************************************
    988  * GVPC::PRINT -- Stub function to print an integer                        *
    989  *                                                                         *
    990  * INPUT:                                                                  *
    991  *                                                                         *
    992  * OUTPUT:                                                                 *
    993  *                                                                         *
    994  * WARNINGS:                                                               *
    995  *                                                                         *
    996  * HISTORY:                                                                *
    997  *=========================================================================*/
    998 inline unsigned long	GraphicViewPortClass::Print(int num, int x, int y, int fcol, int bcol)
    999 {
   1000 	char str[17];
   1001 
   1002 	unsigned long	return_code=0;
   1003 	if (Lock()){
   1004 		return_code = (Buffer_Print(this, itoa(num, str, 10), x, y, fcol, bcol));
   1005 	}
   1006 	Unlock();
   1007 	return ( return_code );
   1008 }
   1009 
   1010 /***************************************************************************
   1011  * GVPC::PRINT -- Stub function to print a short to a graphic viewport     *
   1012  *                                                                         *
   1013  * INPUT:                                                                  *
   1014  *                                                                         *
   1015  * OUTPUT:                                                                 *
   1016  *                                                                         *
   1017  * WARNINGS:                                                               *
   1018  *                                                                         *
   1019  * HISTORY:                                                                *
   1020  *=========================================================================*/
   1021 inline unsigned long	GraphicViewPortClass::Print(short num, int x, int y, int fcol, int bcol)
   1022 {
   1023 	char str[17];
   1024 
   1025 	unsigned long	return_code=0;
   1026 	if (Lock()){
   1027 		return_code = (Buffer_Print(this, itoa(num, str, 10), x, y, fcol, bcol));
   1028 	}
   1029 	Unlock();
   1030 	return ( return_code );
   1031 }
   1032 
   1033 /***************************************************************************
   1034  * GVPC::PRINT -- stub function to print a long on a graphic view port     *
   1035  *                                                                         *
   1036  * INPUT:                                                                  *
   1037  *                                                                         *
   1038  * OUTPUT:                                                                 *
   1039  *                                                                         *
   1040  * WARNINGS:                                                               *
   1041  *                                                                         *
   1042  * HISTORY:                                                                *
   1043  *=========================================================================*/
   1044 inline unsigned long	GraphicViewPortClass::Print(long num, int x, int y, int fcol, int bcol)
   1045 {
   1046 	char str[33];
   1047 
   1048 	unsigned long	return_code=0;
   1049 	if (Lock()){
   1050 		return_code = (Buffer_Print(this, ltoa(num, str,10), x, y, fcol, bcol));
   1051 	}
   1052 	Unlock();
   1053 	return ( return_code );
   1054 }
   1055 
   1056 /***************************************************************************
   1057  * GVPC::DRAW_STAMP -- stub function to draw a tile on a graphic view port *
   1058  *                                                                         *
   1059  * INPUT:                                                                  *
   1060  *                                                                         *
   1061  * OUTPUT:                                                                 *
   1062  *                                                                         *
   1063  * WARNINGS:                                                               *
   1064  *                                                                         *
   1065  * HISTORY:                                                                *
   1066  *=========================================================================*/
   1067 inline void GraphicViewPortClass::Draw_Stamp(void const *icondata, int icon, int x_pixel, int y_pixel, void const *remap)
   1068 {
   1069 	if (Lock()){
   1070 		Buffer_Draw_Stamp(this, icondata, icon, x_pixel, y_pixel, remap);
   1071 	}
   1072 	Unlock();
   1073 }
   1074 
   1075 
   1076 
   1077 /***************************************************************************
   1078  * GVPC::DRAW_STAMP -- stub function to draw a tile on a graphic view port *
   1079  *                     This version clips the tile to a window             *
   1080  *                                                                         *
   1081  * INPUT:                                                                  *
   1082  *                                                                         *
   1083  * OUTPUT:                                                                 *
   1084  *                                                                         *
   1085  * WARNINGS:                                                               *
   1086  *                                                                         *
   1087  * HISTORY:                                                                *
   1088  *    07/31/1995 BWG : Created.                                            *
   1089  *=========================================================================*/
   1090 extern BOOL IconCacheAllowed;
   1091 inline void GraphicViewPortClass::Draw_Stamp(void const * icondata, int icon, int x_pixel, int y_pixel, void const * remap, int clip_window)
   1092 {
   1093 	int	cache_index=-1;
   1094 
   1095    int drewit = 0;
   1096 	if (IconCacheAllowed){
   1097 		if (IsDirectDraw){
   1098 			if (!remap){
   1099 				cache_index = Is_Icon_Cached(icondata,icon);
   1100 			}
   1101 
   1102 			if (cache_index != -1){
   1103 				if (CachedIcons[cache_index].Get_Is_Cached()  ){
   1104 					CachedIcons[cache_index].Draw_It (GraphicBuff->Get_DD_Surface() , x_pixel, y_pixel,
   1105 																WindowList[clip_window][WINDOWX] + XPos,
   1106 																WindowList[clip_window][WINDOWY] +YPos,
   1107 																WindowList[clip_window][WINDOWWIDTH],
   1108 																WindowList[clip_window][WINDOWHEIGHT]);
   1109 					CachedIconsDrawn++;
   1110                drewit = 1;
   1111 				}
   1112 			}
   1113 		}
   1114 	}
   1115 
   1116 
   1117    if (drewit == 0) {
   1118 		if (Lock()){
   1119 			UnCachedIconsDrawn++;
   1120 			Buffer_Draw_Stamp_Clip(this, icondata, icon, x_pixel, y_pixel, remap, WindowList[clip_window][WINDOWX], WindowList[clip_window][WINDOWY], WindowList[clip_window][WINDOWWIDTH], WindowList[clip_window][WINDOWHEIGHT]);
   1121 		}
   1122    }
   1123 	Unlock();
   1124 }
   1125 
   1126 
   1127 /***************************************************************************
   1128  * GVPC::DRAW_LINE -- Stub function to draw line in Graphic Viewport Class *
   1129  *                                                                         *
   1130  * INPUT:                                                                  *
   1131  *                                                                         *
   1132  * OUTPUT:                                                                 *
   1133  *                                                                         *
   1134  * WARNINGS:                                                               *
   1135  *                                                                         *
   1136  * HISTORY:                                                                *
   1137  *   01/16/1995 PWG : Created.                                             *
   1138  *=========================================================================*/
   1139 inline VOID GraphicViewPortClass::Draw_Line(int sx, int sy, int dx, int dy, unsigned char color)
   1140 {
   1141 	if (Lock()){
   1142 		Buffer_Draw_Line(this, sx, sy, dx, dy, color);
   1143 	}
   1144 	Unlock();
   1145 }
   1146 
   1147 /***************************************************************************
   1148  * GVPC::FILL_RECT -- Stub function to fill rectangle in a GVPC            *
   1149  *                                                                         *
   1150  * INPUT:                                                                  *
   1151  *                                                                         *
   1152  * OUTPUT:                                                                 *
   1153  *                                                                         *
   1154  * WARNINGS:                                                               *
   1155  *                                                                         *
   1156  * HISTORY:                                                                *
   1157  *   01/16/1995 PWG : Created.                                             *
   1158  *=========================================================================*/
   1159 inline VOID GraphicViewPortClass::Fill_Rect(int sx, int sy, int dx, int dy, unsigned char color)
   1160 {
   1161 	if (  AllowHardwareBlitFills
   1162 			&& IsDirectDraw
   1163 			&& ( (dx-sx) * (dy-sy) >= (32*32) )
   1164 			&& GraphicBuff->Get_DD_Surface()->GetBltStatus(DDGBS_CANBLT) == DD_OK){
   1165 		DDBLTFX	blit_effects;
   1166 		RECT	dest_rectangle;
   1167 
   1168 		dest_rectangle.left	=sx+XPos;
   1169 		dest_rectangle.top	=sy+YPos;
   1170 		dest_rectangle.right	=dx+XPos;
   1171 		dest_rectangle.bottom=dy+YPos;
   1172 
   1173 		if (dest_rectangle.left<XPos){
   1174 			dest_rectangle.left=XPos;
   1175 		}
   1176 
   1177 		if (dest_rectangle.right >= Width + XPos){
   1178 			dest_rectangle.right = Width +XPos -1;
   1179 		}
   1180 
   1181 		if (dest_rectangle.top<YPos){
   1182 			dest_rectangle.top=YPos;
   1183 		}
   1184 
   1185 		if (dest_rectangle.bottom >= Height + YPos){
   1186 			dest_rectangle.bottom = Height + YPos -1;
   1187 		}
   1188 
   1189 		if (dest_rectangle.left >= dest_rectangle.right)  return;
   1190 		if (dest_rectangle.top  >= dest_rectangle.bottom) return;
   1191 
   1192 		dest_rectangle.right++;
   1193 		dest_rectangle.bottom++;
   1194 
   1195 		blit_effects.dwSize=sizeof(blit_effects);
   1196 		blit_effects.dwFillColor = color;
   1197 		GraphicBuff->Get_DD_Surface()->Blt(&dest_rectangle,
   1198 														NULL,
   1199 														NULL,
   1200 														DDBLT_WAIT | DDBLT_ASYNC | DDBLT_COLORFILL,
   1201 														&blit_effects);
   1202 	} else {
   1203 		if (Lock()){
   1204 			Buffer_Fill_Rect(this, sx, sy, dx, dy, color);
   1205 			Unlock();
   1206 		}
   1207 	}
   1208 }
   1209 
   1210 
   1211 /***************************************************************************
   1212  * GVPC::REMAP -- Stub function to remap a GVPC                            *
   1213  *                                                                         *
   1214  * INPUT:                                                                  *
   1215  *                                                                         *
   1216  * OUTPUT:                                                                 *
   1217  *                                                                         *
   1218  * WARNINGS:                                                               *
   1219  *                                                                         *
   1220  * HISTORY:                                                                *
   1221  *   01/16/1995 PWG : Created.                                             *
   1222  *=========================================================================*/
   1223 inline VOID GraphicViewPortClass::Remap(int sx, int sy, int width, int height, VOID *remap)
   1224 {
   1225 	if (Lock()){
   1226 		Buffer_Remap(this, sx, sy, width, height, remap);
   1227 	}
   1228 	Unlock();
   1229 }
   1230 
   1231 
   1232 inline VOID GraphicViewPortClass::Fill_Quad(VOID *span_buff, int x0, int y0, int x1, int y1,
   1233 							int x2, int y2, int x3, int y3, int color)
   1234 {
   1235 	if (Lock()){
   1236 		Buffer_Fill_Quad(this, span_buff, x0, y0, x1, y1, x2, y2, x3, y3, color);
   1237 	}
   1238 	Unlock();
   1239 }
   1240 
   1241 /***************************************************************************
   1242  * GVPC::REMAP -- Short form to remap an entire graphic view port          *
   1243  *                                                                         *
   1244  * INPUT:		BYTE * to the remap table to use										*
   1245  *                                                                         *
   1246  * OUTPUT:     none                                                        *
   1247  *                                                                         *
   1248  * HISTORY:                                                                *
   1249  *   07/01/1994 PWG : Created.                                             *
   1250  *=========================================================================*/
   1251 inline VOID GraphicViewPortClass::Remap(VOID *remap)
   1252 {
   1253 	if (Lock()){
   1254 		Buffer_Remap(this, 0, 0, Width, Height, remap);
   1255 	}
   1256 	Unlock();
   1257 }
   1258 
   1259 inline int GraphicViewPortClass::Get_Pitch(void)
   1260 {
   1261 	return(Pitch);
   1262 }
   1263 /*=========================================================================*/
   1264 /* The following BufferClass functions are defined here because they act	*/
   1265 /*		on graphic viewports.																*/
   1266 /*=========================================================================*/
   1267 
   1268 
   1269 /***************************************************************************
   1270  * BUFFER_TO_PAGE -- Generic 'c' callable form of Buffer_To_Page           *
   1271  *                                                                         *
   1272  * INPUT: 																						*
   1273  *                                                                         *
   1274  * OUTPUT:                                                                 *
   1275  *                                                                         *
   1276  * WARNINGS:                                                               *
   1277  *                                                                         *
   1278  * HISTORY:                                                                *
   1279  *   01/12/1995 PWG : Created.                                             *
   1280  *=========================================================================*/
   1281 inline long Buffer_To_Page(int x, int y, int w, int h, void *Buffer, GraphicViewPortClass &view)
   1282 {
   1283 	long	return_code=0;
   1284 	if (view.Lock()){
   1285 		return_code = (Buffer_To_Page(x, y, w, h, Buffer, &view));
   1286 	}
   1287 	view.Unlock();
   1288 	return ( return_code );
   1289 }
   1290 
   1291 /***************************************************************************
   1292  * BC::TO_PAGE -- Copys a buffer class to a page with definable w, h 		*
   1293  *                                                                         *
   1294  * INPUT:		int	width		- the width of copy region							*
   1295  *					int	height	- the height of copy region						*
   1296  *					GVPC&	dest		- virtual viewport to copy to						*
   1297  *                                                                         *
   1298  * OUTPUT:		none                                                        *
   1299  *																									*
   1300  * WARNINGS:	x and y position are the upper left corner of the dest		*
   1301  *						viewport																	*
   1302  *                                                                         *
   1303  * HISTORY:                                                                *
   1304  *   07/01/1994 PWG : Created.                                             *
   1305  *=========================================================================*/
   1306 inline long BufferClass::To_Page(int w, int h, GraphicViewPortClass &view)
   1307 {
   1308 	long	return_code=0;
   1309 	if (view.Lock()){
   1310 		return_code = (Buffer_To_Page(0, 0, w, h, Buffer, &view));
   1311 	}
   1312 	view.Unlock();
   1313 	return ( return_code );
   1314 }
   1315 /***************************************************************************
   1316  * BC::TO_PAGE -- Copys a buffer class to a page with definable w, h 		*
   1317  *                                                                         *
   1318  * INPUT:		GVPC&	dest		- virtual viewport to copy to						*
   1319  *                                                                         *
   1320  * OUTPUT:		none                                                        *
   1321  *																									*
   1322  * WARNINGS:	x and y position are the upper left corner of the dest		*
   1323  *						viewport.  width and height are assumed to be the			*
   1324  *						viewport's width and height.										*
   1325  *                                                                         *
   1326  * HISTORY:                                                                *
   1327  *   07/01/1994 PWG : Created.                                             *
   1328  *=========================================================================*/
   1329 inline long BufferClass::To_Page(GraphicViewPortClass &view)
   1330 {
   1331 	long	return_code=0;
   1332 	if (view.Lock()){
   1333 		return_code = (Buffer_To_Page(0, 0, view.Get_Width(), view.Get_Height(), Buffer, &view));
   1334 	}
   1335 	view.Unlock();
   1336 	return ( return_code );
   1337 }
   1338 /***************************************************************************
   1339  * BC::TO_PAGE -- Copys a buffer class to a page with definable x, y, w, h *
   1340  *                                                                         *
   1341  * INPUT:	int	x			- x pixel on viewport to copy from					*
   1342  *				int	y			- y pixel on viewport to copy from					*
   1343  *				int	width		- the width of copy region								*
   1344  *				int	height	- the height of copy region							*
   1345  *				GVPC&	dest		- virtual viewport to copy to							*
   1346  *                                                                         *
   1347  * OUTPUT:	none                                                           *
   1348  *                                                                         *
   1349  * HISTORY:                                                                *
   1350  *   07/01/1994 PWG : Created.                                             *
   1351  *=========================================================================*/
   1352 inline long BufferClass::To_Page(int x, int y, int w, int h, GraphicViewPortClass &view)
   1353 {
   1354 	long	return_code=0;
   1355 	if (view.Lock()){
   1356 		return_code = (Buffer_To_Page(x, y, w, h, Buffer, &view));
   1357 	}
   1358 	view.Unlock();
   1359 	return ( return_code );
   1360 }
   1361 
   1362 
   1363 #endif