SHAPE.H 7.4 KB

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