gimex.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* Copyright (C) Electronic Arts Canada Inc. 1994-1998. All rights reserved. */
  19. /* ABSTRACT
  20. gimex.h - Graphics IMport EXport (GIMEX) v2.26
  21. @ */
  22. #ifndef __GIMEX_H
  23. #define __GIMEX_H 1
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #define GimexVersion "2.26"
  28. /****************************************************************************/
  29. /* Data Types */
  30. /****************************************************************************/
  31. /* ARGB structure used for palettes/pixels */
  32. #ifndef _ARGB_T
  33. #define _ARGB_T
  34. #if defined(_MSC_VER) || defined(__WATCOMC__) || defined(PSX) || defined(DC)
  35. typedef struct
  36. {
  37. unsigned char b,g,r,a;
  38. } ARGB;
  39. #elif defined(SGI)
  40. typedef struct
  41. {
  42. unsigned char a,b,g,r;
  43. } ARGB;
  44. #else /* Mac */
  45. typedef struct
  46. {
  47. unsigned char a,r,g,b;
  48. } ARGB;
  49. #endif
  50. #endif
  51. /* Info structure describing bitmaps */
  52. #define GIMEX_FRAMENAME_SIZE 32
  53. #define GIMEX_COMMENT_SIZE 256
  54. #define GIMEX_COLOURTBL_SIZE 256
  55. #define GIMEX_HOTSPOTTBL_SIZE 256
  56. #define GIMEX_HOTSPOTTBL_VALUES 2
  57. typedef struct
  58. {
  59. long signature; /* signature of gimex ie 'tga ' (optional) */
  60. long size; /* size of GINFO structure */
  61. int version; /* version number of GINFO structure (200) */
  62. int framenum; /* current frame */
  63. int width; /* width of bitmap in pixels */
  64. int height; /* height of bitmap in pixels */
  65. int bpp; /* bits per pixel (8 or 32) */
  66. int originalbpp; /* bits per pixel in original image (1 to 32) */
  67. int startcolour; /* first colour in palette */
  68. int numcolours; /* number of colours in original indexed palette */
  69. ARGB colourtbl[GIMEX_COLOURTBL_SIZE]; /* 8 bit palette */
  70. int subtype; /* internal format sub-type 0-default */
  71. int packed; /* type of packing on original image. 0 none, 1 run, n other */
  72. int quality; /* quality of lossy packing 0..100 */
  73. int framesize; /* size of frame in bytes */
  74. int alphabits; /* number of bits in alpha channel */
  75. int redbits; /* number of bits in red channel */
  76. int greenbits; /* number of bits in green channel */
  77. int bluebits; /* number of bits in blue channel */
  78. int centerx; /* center point relative to upper left corner */
  79. int centery;
  80. int defaultx; /* default coordinate point */
  81. int defaulty;
  82. int numhotspots; /* number of hot spots defined */
  83. char framename[GIMEX_FRAMENAME_SIZE]; /* null terminated name of frame/image */
  84. char comment[GIMEX_COMMENT_SIZE]; /* null terminated multiline user comment */
  85. int hotspottbl[GIMEX_HOTSPOTTBL_SIZE][GIMEX_HOTSPOTTBL_VALUES];/* up to 256 hot spots, XY pairs relative to upperleft */
  86. float dpi; /* dots per inch ie 72.0 */
  87. int reserved[3]; /* reserved for future use - set to zero */
  88. } GINFO;
  89. #ifndef _GSTREAM_T
  90. #define _GSTREAM_T GIMEX
  91. typedef void GSTREAM; /* handle used for file functions */
  92. #endif
  93. typedef struct
  94. {
  95. long signature; /* signature of gimex ie 'tga ' (optional) */
  96. long size; /* size of GINSTANCE structure */
  97. int frames; /* Number of frames in file */
  98. int framenum; /* current frame (optional) */
  99. GSTREAM *gstream; /* stream pointer for file */
  100. char *gref; /* gimex reference to additional memory used by module (optional) */
  101. } GINSTANCE;
  102. /* Info structure describing bitmaps */
  103. #define MAXMACTYPES 8
  104. #define MAXEXTENSIONS 8
  105. #define GIMEX_EXTENSION_SIZE 8
  106. #define GIMEX_AUTHORSTR_SIZE 32
  107. #define GIMEX_VERSIONSTR_SIZE 8
  108. #define GIMEX_SHORTTYPESTR_SIZE 8
  109. #define GIMEX_WORDTYPESTR_SIZE 16
  110. #define GIMEX_LONGTYPESTR_SIZE 32
  111. typedef struct
  112. {
  113. long signature; /* signature of gimex ie 'tga ' (optional) */
  114. long size; /* size of GABOUT structure */
  115. int version; /* version number of GABOUT structure (200) */
  116. unsigned int canimport :1; /* supports importing */
  117. unsigned int canexport :1; /* supports exporting */
  118. unsigned int importpacked :2; /* max import packed field 0..3 */
  119. unsigned int exportpacked :2; /* max export packed field 0..3 */
  120. unsigned int import8 :1; /* supports importing 8 bit indexed */
  121. unsigned int export8 :1; /* supports exporting 8 bit indexed */
  122. unsigned int import32 :1; /* supports importing 32 bit direct rgb */
  123. unsigned int export32 :1; /* supports exporting 32 bit direct rgb */
  124. unsigned int multiframe :1; /* supports multiple frames */
  125. unsigned int multifile :1; /* format requires additional files or resource fork */
  126. unsigned int multisize :1; /* supports different size per frame */
  127. unsigned int framebuffer :1; /* module requires memory to buffer entire frame */
  128. unsigned int external :1; /* module requires external tool or plugin */
  129. unsigned int usesfile :1; /* module is file based vs ads/printer/generator */
  130. unsigned int singlepalette :1; /* limited to a single palette per file */
  131. unsigned int greyscale :1; /* use maxcolours for number of levels */
  132. unsigned int startcolour :1; /* supports start colour */
  133. unsigned int dotsubtype :1; /* subtype based on extension */
  134. unsigned int resizable :1; /* read will respect ginfo width & height */
  135. unsigned int pad :11; /* pad bitfield to 32 bit boundary for inter compiler compatibility */
  136. int maxcolours; /* only use in 8 bit, 0 if module does not care */
  137. int maxframename; /* maximum characters in ginfo framename */
  138. int defaultquality; /* default pack quality */
  139. long mactype[MAXMACTYPES]; /* mac file system types used */
  140. char extensions[MAXEXTENSIONS][GIMEX_EXTENSION_SIZE]; /* null terminated extensions with '.' */
  141. char authorstr[GIMEX_AUTHORSTR_SIZE]; /* name of gimex module author */
  142. char versionstr[GIMEX_VERSIONSTR_SIZE]; /* version number of gimex module ie 1.00 */
  143. char shorttypestr[GIMEX_SHORTTYPESTR_SIZE]; /* 3 or 4 character type string ie TGA */
  144. char wordtypestr[GIMEX_WORDTYPESTR_SIZE]; /* single word type string ie Targa */
  145. char longtypestr[GIMEX_LONGTYPESTR_SIZE]; /* full name of data format ie True Vision Targa */
  146. } GABOUT;
  147. /* Bitmap structure (optional) */
  148. typedef struct
  149. {
  150. GINFO *ginfo;
  151. char *image;
  152. int rowbytes;
  153. } GBITMAP;
  154. #define GMAKEID(a,b,c,d) (((long)(a)<<24)|((long)(b)<<16)|((long)(c)<<8)|(long)(d))
  155. #ifndef gmin
  156. #define gmin(a,b) ((a)<(b)?(a):(b))
  157. #endif
  158. #ifndef gmax
  159. #define gmax(a,b) ((a)>(b)?(a):(b))
  160. #endif
  161. #if !defined(GCALL)
  162. #if defined(_MSC_VER) || defined(__WATCOMC__)
  163. #define GCALL __stdcall
  164. #else
  165. #define GCALL
  166. #endif
  167. #endif
  168. /* disable unreferenced parameters warnings */
  169. #if defined(__WATCOMC__)
  170. #pragma warning 202 999999
  171. #endif
  172. #if defined(_MSC_VER)
  173. #pragma warning(disable : 4100)
  174. #endif
  175. #if 0
  176. /****************************************************************************/
  177. /* Gimex Module Example Prototypes */
  178. /****************************************************************************/
  179. /* Example Information Functions */
  180. GABOUT * GCALL aboutbmp(void);
  181. int GCALL isbmp(GSTREAM *g);
  182. /* Example Import Functions */
  183. int GCALL openbmp(GINSTANCE **gx, GSTREAM *g, char *pathname);
  184. GINFO * GCALL infobmp(GINSTANCE *gx, int framenum);
  185. int GCALL readbmp(GINSTANCE *gx, GINFO *ginfo, char *dest, int rowbytes);
  186. int GCALL closebmp(GINSTANCE *gx);
  187. /* Example Export Functions */
  188. int GCALL wopenbmp(GINSTANCE **gx, GSTREAM *g, char *pathname, int numframes);
  189. int GCALL writebmp(GINSTANCE *gx, GINFO *ginfo, char *source, int rowbytes);
  190. int GCALL wclosebmp(GINSTANCE *gx);
  191. #endif
  192. /****************************************************************************/
  193. /* Application Module Prototypes */
  194. /****************************************************************************/
  195. /* File Stream Functions */
  196. GSTREAM * GCALL gopen(const char *pathname);
  197. GSTREAM * GCALL gwopen(const char *pathname);
  198. int GCALL gclose(GSTREAM *g);
  199. int GCALL gread(GSTREAM *g, void *buf, long size);
  200. int GCALL gwrite(GSTREAM *g, void *buf, long size);
  201. int GCALL gseek(GSTREAM *g, long offset);
  202. long GCALL glen(GSTREAM *g);
  203. long GCALL gtell(GSTREAM *g);
  204. /* Memory Functions */
  205. void * GCALL galloc(long size);
  206. int GCALL gfree(void *memptr);
  207. void gputm(void *memptr, unsigned long val, int numbytes);
  208. void gputi(void *memptr, unsigned long val, int numbytes);
  209. unsigned long ggetm(void *memptr, int numbytes);
  210. unsigned long ggeti(void *memptr, int numbytes);
  211. /****************************************************************************/
  212. /* Watcom Memory Functions */
  213. /****************************************************************************/
  214. #if defined(__WATCOMC__) && !defined(__NOINLINE__)
  215. #pragma aux ggeti = \
  216. "mov eax,[eax+ecx-4]" \
  217. "neg ecx" \
  218. "lea ecx,32[ecx*8]" \
  219. "shr eax,cl" \
  220. parm [eax] [ecx] \
  221. modify [eax ecx] \
  222. value [eax];
  223. #pragma aux ggetm = \
  224. ".586" \
  225. "mov eax,[eax]" \
  226. "bswap eax" \
  227. "neg ecx" \
  228. "lea ecx,32[ecx*8]" \
  229. "shr eax,cl" \
  230. parm [eax] [ecx] \
  231. modify [eax ecx] \
  232. value [eax];
  233. unsigned long bswap(unsigned long val);
  234. #pragma aux bswap = "bswap eax" parm [eax] modify [eax] value [eax];
  235. #define gputm(putmdest,putmdata,putmbytes) \
  236. (((int)(putmbytes)==4) ? ((void)(*((unsigned long *) (putmdest)) = bswap((unsigned long)(putmdata)))) \
  237. : (((int)(putmbytes)==1) ? ((void)(*((unsigned char *) (putmdest)) = (unsigned char)(putmdata))) \
  238. : (((int)(putmbytes)==2) ? ((void)(*((unsigned short *) (putmdest)) = (unsigned short)(bswap((unsigned long)(putmdata))>>16))) \
  239. : (((int)(putmbytes)==3) ? ((void)(*((unsigned char *) (putmdest)+2) = (unsigned char)(putmdata)),(void)(*((unsigned short *) (putmdest)) = (unsigned short)(bswap((unsigned long)(putmdata))>>8))) \
  240. : (void)0))))
  241. #define gputi(putidest,putidata,putibytes) \
  242. (((int)(putibytes)==4) ? ((void)(*((unsigned long *) (putidest)) = ((unsigned long)(putidata)))) \
  243. : (((int)(putibytes)==1) ? ((void)(*((unsigned char *) (putidest)) = (unsigned char)(putidata))) \
  244. : (((int)(putibytes)==2) ? ((void)(*((unsigned short *) (putidest)) = (unsigned short)(putidata))) \
  245. : (((int)(putibytes)==3) ? ((void)(*((unsigned short *) (putidest)) = (unsigned short)(putidata)),(void)(*((unsigned char *) (putidest)+2) = (unsigned char)((unsigned long)(putidata)>>16))) \
  246. : (void)0))))
  247. #endif /* __WATCOMC__ */
  248. #ifdef __cplusplus
  249. }
  250. #endif
  251. #endif /* __GIMEX_H */
  252. /* END ABSTRACT */