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