CnC_Remastered_Collection

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

SHAPE.H (7549B)


      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    S T U D I O S        **
     18  ***************************************************************************
     19  *                                                                         *
     20  *                 Project Name : WWLIB32                                  *
     21  *                                                                         *
     22  *                    File Name : SHAPE.H                                  *
     23  *                                                                         *
     24  *                   Programmer : Bill Randolph                            *
     25  *                                                                         *
     26  *                   Start Date : May 25, 1994                             *
     27  *                                                                         *
     28  *                  Last Update : September 14, 1994   [IML]               *
     29  *                                                                         *
     30  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     31 #ifndef SHAPE_H
     32 #define SHAPE_H
     33 
     34 #ifndef GBUFFER_H
     35 #include "gbuffer.h"
     36 #endif
     37 /*
     38 *********************************** Types ***********************************
     39 */
     40 /*
     41 --------------------------- Shape creation flags ----------------------------
     42 */
     43 typedef enum : unsigned short {
     44 	MAKESHAPE_NORMAL	 = 0x0000,	// 256-color compressed shape
     45 	MAKESHAPE_COMPACT  = 0x0001,	// 16-color shape (with built-in color table)
     46 	MAKESHAPE_NOCOMP	 = 0x0002,	// Uncompressed shape
     47 	MAKESHAPE_VARIABLE =	0x0004	// <16-color shape
     48 } MakeShapeFlags_Type;
     49 
     50 inline MakeShapeFlags_Type operator|(MakeShapeFlags_Type a, MakeShapeFlags_Type b)
     51 {return static_cast<MakeShapeFlags_Type>(static_cast<int>(a) | static_cast<int>(b));}
     52 
     53 inline MakeShapeFlags_Type operator&(MakeShapeFlags_Type a, MakeShapeFlags_Type b)
     54 {return static_cast<MakeShapeFlags_Type>(static_cast<int>(a) & static_cast<int>(b));}
     55 
     56 inline MakeShapeFlags_Type operator~(MakeShapeFlags_Type a)
     57 {return static_cast<MakeShapeFlags_Type>(~static_cast<int>(a));}
     58 
     59 /*---------------------------------------------------------------------------
     60 Shape drawing flags:
     61 - The low byte is for coordinate transformations.
     62 - The high byte is for drawing effects.
     63 ---------------------------------------------------------------------------*/
     64 typedef enum : unsigned short {
     65 	SHAPE_NORMAL 			= 0x0000,		// Standard shape
     66 	SHAPE_HORZ_REV 		= 0x0001,		// Flipped horizontally
     67 	SHAPE_VERT_REV 		= 0x0002,		// Flipped vertically
     68 	SHAPE_SCALING 			= 0x0004,		// Scaled (WORD scale_x, WORD scale_y)
     69 	SHAPE_VIEWPORT_REL 	= 0x0010,		// Coords are window-relative
     70 	SHAPE_WIN_REL 			= 0x0010,		// Coordinates are window relative instead of absolute.
     71 	SHAPE_CENTER 			= 0x0020,		// Coords are based on shape's center pt
     72 	SHAPE_BOTTOM			= 0x0040,		// Y coord is based on shape's bottom pt
     73 	SHAPE_FADING 			= 0x0100,		// Fading effect (void * fading_table,
     74 													//  WORD fading_num)
     75 	SHAPE_PREDATOR 		= 0x0200,		// Transparent warping effect
     76 	SHAPE_COMPACT 			= 0x0400,		// Never use this bit
     77 	SHAPE_PRIORITY 		= 0x0800,		// Use priority system when drawing
     78 	SHAPE_GHOST				= 0x1000,		// Shape is drawn ghosted
     79 	SHAPE_SHADOW			= 0x2000,
     80 	SHAPE_PARTIAL  		= 0x4000,
     81 	SHAPE_COLOR 			= 0x8000			// Remap the shape's colors
     82 													//  (void * color_table)
     83 } ShapeFlags_Type;
     84 
     85 inline ShapeFlags_Type operator|(ShapeFlags_Type a, ShapeFlags_Type b)
     86 {return static_cast<ShapeFlags_Type>(static_cast<int>(a) | static_cast<int>(b));}
     87 
     88 inline ShapeFlags_Type operator&(ShapeFlags_Type a, ShapeFlags_Type b)
     89 {return static_cast<ShapeFlags_Type>(static_cast<int>(a) & static_cast<int>(b));}
     90 
     91 inline ShapeFlags_Type operator~(ShapeFlags_Type a)
     92 {return static_cast<ShapeFlags_Type>(~static_cast<int>(a));}
     93 
     94 /*
     95 ------------------------------- Shape header --------------------------------
     96 */
     97 typedef struct {
     98 	unsigned short		ShapeType;			// 0 = normal, 1 = 16 colors,
     99 										//  2 = uncompressed, 4 = 	<16 colors
    100 	unsigned char		Height;				// Height of the shape in scan lines
    101 	unsigned short		Width;				// Width of the shape in bytes
    102 	unsigned char		OriginalHeight;	// Original height of shape in scan lines
    103 	unsigned short		ShapeSize;			// Size of the shape, including header
    104 	unsigned short		DataLength;			// Size of the uncompressed shape (just data)
    105 	unsigned char		Colortable[16];	// Optional color table for compact shape
    106 } Shape_Type;
    107 
    108 /*
    109 ------------------------------- Shape block ---------------------------------
    110 */
    111 #pragma warning (disable : 4200)
    112 typedef struct {
    113 	unsigned short		NumShapes;			// number of shapes in the block
    114 	long		Offsets[];			// array of offsets to shape data
    115 										//  (offsets within the shape block, with
    116 										//  0 being the first offset value, not the
    117 										//  start of the shape block)
    118 } ShapeBlock_Type;
    119 
    120 
    121 /*
    122 ******************************** Prototypes *********************************
    123 */
    124 
    125 /*
    126 -------------------------------- prioinit.c ---------------------------------
    127 */
    128 
    129 extern "C" {
    130 extern void  *MaskPage;
    131 extern void  *BackGroundPage;
    132 extern long  _ShapeBufferSize;
    133 extern char  *_ShapeBuffer;
    134 }
    135 
    136 
    137 void __cdecl Init_Priority_System (GraphicBufferClass *mask,
    138 											GraphicBufferClass *back);
    139 
    140 
    141 /*
    142 -------------------------------- drawshp.asm --------------------------------
    143 */
    144 
    145 extern "C" {
    146 int Draw_Shape(GraphicViewPortClass *gvp, void const *shape, LONG x, LONG y, LONG flags, ...);
    147 }
    148 
    149 /*
    150 ---------------------------------- shape.c ----------------------------------
    151 */
    152 short __cdecl Get_Shape_Data(void const *shape, int data);
    153 int __cdecl Extract_Shape_Count(void const *buffer);
    154 void * __cdecl Extract_Shape(void const *buffer, int shape);
    155 int __cdecl Restore_Shape_Height(void *shape);
    156 int __cdecl Set_Shape_Height(void const *shape, int newheight);
    157 
    158 extern "C" {
    159 int __cdecl Get_Shape_Width(void const *shape);
    160 int __cdecl Get_Shape_Height(void const *shape);
    161 int __cdecl Get_Shape_Original_Height(void const *shape);
    162 int __cdecl Get_Shape_Uncomp_Size(void const *shape);
    163 }
    164 
    165 
    166 /*
    167 ------------------------------- setshape.asm --------------------------------
    168 */
    169 extern "C" {
    170 void __cdecl Set_Shape_Buffer(void const *buffer, int size);
    171 }
    172 /*
    173 ------------------------------- shapeinf.asm --------------------------------
    174 */
    175 int __cdecl Get_Shape_Flags(void const *shape);
    176 int  __cdecl Get_Shape_Size(void const *shape);
    177 int  __cdecl Get_Shape_Scaled_Width(void const *shape, int scale);
    178 int  __cdecl Get_Shape_Scaled_Height(void const *shape, int scale);
    179 
    180 #endif // SHAPE_H
    181 
    182 /****************************** End of shape.h *****************************/
    183 
    184