home *** CD-ROM | disk | FTP | other *** search
/ Dream 44 / Amiga_Dream_44.iso / Linux / Apps / xanim.tgz / xanim / xanim27064 / xanim.h < prev    next >
C/C++ Source or Header  |  1997-01-26  |  24KB  |  940 lines

  1.  
  2. /*
  3.  * xanim.h
  4.  *
  5.  * Copyright (C) 1990,1991,1992,1993,1994,1995,1996,1997 by Mark Podlipec. 
  6.  * All rights reserved.
  7.  *
  8.  * This software may be freely copied, modified and redistributed without
  9.  * fee for non-commerical purposes provided that this copyright notice is
  10.  * preserved intact on all copies and modified copies.
  11.  * 
  12.  * There is no warranty or other guarantee of fitness of this software.
  13.  * It is provided solely "as is". The author(s) disclaim(s) all
  14.  * responsibility and liability with respect to this software's usage
  15.  * or its effect upon hardware or computer systems.
  16.  *
  17.  */
  18. #include <Xos.h>
  19. #include <stdio.h>
  20. #include <sys/types.h>
  21. #include <stdio.h>
  22. #ifndef VMS
  23.  
  24. #ifndef __QNX__
  25. #include <sys/param.h>
  26. #include <memory.h>
  27. #endif
  28.  
  29. #ifdef __bsdi__
  30. #include <sys/malloc.h>
  31. #else
  32. #ifndef __FreeBSD__
  33. #include <malloc.h>
  34. #endif
  35. #endif
  36.  
  37. #include <unistd.h>
  38. #else
  39. #include <unixio.h>
  40. #endif
  41. #include <stdlib.h>
  42. #include <Xlib.h>
  43. #include "xa_config.h"
  44.  
  45. #ifdef XA_XTPOINTER
  46. typedef void* XtPointer;
  47. #endif
  48.  
  49. #ifdef XA_PETUNIA
  50. #define XA_REMOTE_CONTROL 1
  51. #endif
  52.  
  53. #ifdef XA_ATHENA
  54. #define XA_REMOTE_CONTROL 1
  55. #endif
  56.  
  57. #ifdef XA_MOTIF
  58. #define XA_REMOTE_CONTROL 1
  59. #endif
  60.  
  61. /*
  62.  * MSDOS needs to be specifically told to open file for binary reading.
  63.  * For VMS systems, specify "Stream_LF" mode for VAX C.
  64.  */
  65. #ifdef MSDOS
  66. #define XA_OPEN_MODE "rb"
  67. #else
  68. #ifdef VMS
  69. #define XA_OPEN_MODE "r","ctx=stm"
  70. #else
  71. #define XA_OPEN_MODE "r"
  72. #endif
  73. #endif
  74.  
  75. typedef int        xaLONG;
  76. typedef unsigned int    xaULONG;
  77. typedef short        xaSHORT;
  78. typedef unsigned short    xaUSHORT;
  79. typedef char        xaBYTE;
  80. typedef unsigned char    xaUBYTE;
  81.  
  82. #define xaFALSE  0
  83. #define xaTRUE   1
  84. #define xaNOFILE 2
  85. #define xaERROR  3
  86. #define xaPAUSE  4
  87.  
  88.  
  89. #define xaMIN(x,y)   ( ((x)>(y))?(y):(x) )
  90. #define xaMAX(x,y)   ( ((x)>(y))?(x):(y) )
  91. #define xaABS(x)     (((x)<0)?(-(x)):(x))
  92.  
  93. /* X11 variables */
  94.  
  95. #define XA_GRAYSCALE    0x06
  96. #define XA_STATICGRAY    0x03
  97. #define XA_PSEUDOCOLOR    0x14
  98. #define XA_STATICCOLOR    0x11
  99. #define XA_DIRECTCOLOR    0x18
  100. #define XA_TRUECOLOR    0x19
  101. #define XA_MONOCHROME    0x00
  102.  
  103. #define XA_X11_STATIC    0x01
  104. #define XA_X11_GRAY    0x02
  105. #define XA_X11_CMAP    0x04
  106. #define XA_X11_TRUE    0x08
  107. #define XA_X11_COLOR    0x10
  108.  
  109. extern xaLONG x11_depth;
  110. extern xaLONG x11_class;
  111. extern xaLONG x11_bytes_pixel;
  112. extern xaLONG x11_bits_per_pixel;
  113. extern xaLONG x11_bitmap_pad;
  114. extern xaLONG x11_bitmap_unit;
  115. extern xaLONG x11_bit_order;
  116. extern xaLONG x11_byte_order;
  117. extern xaLONG x11_pack_flag;
  118. extern xaLONG x11_cmap_flag;
  119. extern xaLONG x11_cmap_size;
  120. extern xaLONG x11_disp_bits;
  121. extern xaLONG x11_cmap_type;
  122. extern xaLONG x11_depth_mask;
  123. extern xaLONG x11_display_type;
  124. extern xaLONG x11_red_mask;
  125. extern xaLONG x11_green_mask;
  126. extern xaLONG x11_blue_mask;
  127. extern xaLONG x11_red_shift;
  128. extern xaLONG x11_green_shift;
  129. extern xaLONG x11_blue_shift;
  130. extern xaLONG x11_red_bits;
  131. extern xaLONG x11_green_bits;
  132. extern xaLONG x11_blue_bits;
  133. extern xaLONG x11_black;
  134. extern xaLONG x11_white;
  135. extern xaLONG x11_verbose_flag;
  136. extern xaULONG x11_kludge_1;
  137.  
  138. #define X11_MSB  1
  139. #define X11_LSB  0
  140.  
  141. extern xaLONG xa_anim_holdoff;
  142. extern xaLONG xa_anim_status;
  143.  
  144. /*------*/
  145. #define XA_NEXT_MASK    0x01
  146. #define XA_STOP_MASK    0x02
  147. #define XA_STEP_MASK    0x04
  148. #define XA_RUN_MASK    0x08
  149. #define XA_ISTP_MASK    0x10
  150. #define XA_FILE_MASK    0x20
  151. #define XA_CLEAR_MASK    0x01
  152. #define XA_BEGIN_MASK    0x01
  153. /*------*/
  154. #define XA_UNSTARTED   0x00
  155. #define XA_BEGINNING   0x80
  156. #define XA_STOP_PREV   0x02
  157. #define XA_STOP_NEXT   0x03
  158. #define XA_STEP_PREV   0x04
  159. #define XA_STEP_NEXT   0x05
  160. #define XA_RUN_PREV    0x08
  161. #define XA_RUN_NEXT    0x09
  162. #define XA_ISTP_PREV   0x14
  163. #define XA_ISTP_NEXT   0x15
  164. #define XA_FILE_PREV   0x24
  165. #define XA_FILE_NEXT   0x25
  166.  
  167. #define XA_SHOW_NORM   0
  168. #define XA_SHOW_SKIP   1
  169.  
  170. #define XA_SPEED_NORM (1<<4)
  171. #define XA_SPEED_MIN  (1)
  172. #define XA_SPEED_MAX  (1<<8)
  173. #define XA_SPEED_ADJ(x,s)  (((x)*(s))>>4)
  174.  
  175. #define NOFILE_ANIM   0xffff
  176. #define UNKNOWN_ANIM  0
  177. /*************************** VIDEO FILES *************/
  178. #define IFF_ANIM      1
  179. #define FLI_ANIM      2
  180. #define GIF_ANIM      3
  181. #define TXT_ANIM      4
  182. #define FADE_ANIM     5
  183. #define DL_ANIM       6
  184. #define JFIF_ANIM     7
  185. #define PFX_ANIM      8
  186. #define SET_ANIM      9
  187. #define RLE_ANIM     10
  188. #define AVI_ANIM     11
  189. #define QT_ANIM      12
  190. #define MPG_ANIM     13
  191. #define JMOV_ANIM    14
  192. #define ARM_ANIM     15
  193. #define SGI_ANIM     16
  194. /*************************** AUDIO FILES *************/
  195. #define WAV_ANIM     128
  196. #define AU_ANIM      129
  197.  
  198. typedef struct
  199. {
  200.   xaUSHORT red,green,blue,gray;
  201. } ColorReg;
  202.  
  203. typedef struct
  204. {
  205.   xaUBYTE r0,g0,b0;
  206.   xaUBYTE r1,g1,b1;
  207.   xaUBYTE r2,g2,b2;
  208.   xaUBYTE r3,g3,b3;
  209.   xaULONG clr0_0,clr0_1,clr0_2,clr0_3;
  210.   xaULONG clr1_0,clr1_1,clr1_2,clr1_3;
  211.   xaULONG clr2_0,clr2_1,clr2_2,clr2_3;
  212.   xaULONG clr3_0,clr3_1,clr3_2,clr3_3;
  213. } XA_2x2_Color;
  214.  
  215. typedef struct XA_ACTION_STRUCT
  216. {
  217.  xaLONG type;        /* type of action */
  218.  xaLONG cmap_rev;          /* rev of cmap */
  219.  xaUBYTE *data;        /* data ptr */
  220.  struct XA_ACTION_STRUCT *next;
  221.  struct XA_CHDR_STRUCT *chdr;
  222.  ColorReg *h_cmap;    /* For IFF HAM images */
  223.  xaULONG *map;
  224.  struct XA_ACTION_STRUCT *next_same_chdr; /*ptr to next action with same cmap*/
  225. } XA_ACTION;
  226.  
  227. typedef struct XA_CHDR_STRUCT
  228. {
  229.  xaLONG rev;
  230.  ColorReg *cmap;
  231.  xaULONG csize,coff;
  232.  xaULONG *map;
  233.  xaULONG msize,moff;
  234.  struct XA_CHDR_STRUCT *next;
  235.  XA_ACTION *acts;
  236.  struct XA_CHDR_STRUCT *new_chdr;
  237. } XA_CHDR;
  238.  
  239. typedef struct
  240. {
  241.  xaULONG csize,coff;
  242.  xaUBYTE data[4];
  243. } ACT_CMAP_HDR;
  244.  
  245. typedef struct XA_FRAME_STRUCT
  246. {
  247.   XA_ACTION *act;    /* ptr to relevant Action. */
  248.   xaLONG time_dur;    /* duration of Frame in ms. */
  249.   xaLONG zztime;        /* time at start of Frame in ms. */
  250. } XA_FRAME;
  251.  
  252. typedef struct
  253. {
  254.   xaULONG count;    /* number of loops */
  255.   xaLONG cnt_var;   /* var to keep track of loops */
  256.   xaULONG end_frame; /* last frame of loop */
  257. } ACT_BEG_LP_HDR;
  258.  
  259. typedef struct ACT_END_LP_STRUCT
  260. {
  261.   xaULONG *count;       /* points back to beg_lp->count */
  262.   xaLONG *cnt_var;      /* points back to beg_lp->cnt_var */
  263.   xaULONG begin_frame;  /* first frame of loop */
  264.   xaULONG *end_frame;   /* points back to beg_lp->end_frame */
  265.   XA_ACTION *prev_end_act; /* used to nest loops during creation */
  266. } ACT_END_LP_HDR;
  267.  
  268. /** AUDIO SECTION ************************/
  269.  
  270. typedef struct
  271. {
  272.   xaULONG enable;
  273.   xaULONG mute;
  274.   xaLONG  volume;
  275.   xaULONG newvol;
  276.   xaULONG port;
  277.   xaULONG playrate;
  278.   xaULONG divtest;
  279.   xaULONG synctst;
  280.   xaULONG fromfile;
  281.   xaULONG bufferit;
  282.   double scale;
  283.   char *device;
  284. } XA_AUD_FLAGS;
  285.  
  286.  
  287. /* POD temporary til complete overhaul */
  288. #define XAAUD audiof
  289.  
  290. #ifdef XA_SPARC_AUDIO
  291. #define XA_AUDIO 1
  292. #endif
  293. #ifdef XA_MMS_AUDIO
  294. #define XA_AUDIO 1
  295. #endif
  296. #ifdef XA_AIX_AUDIO
  297. #define XA_AUDIO 1
  298. #endif
  299. #ifdef XA_NetBSD_AUDIO
  300. #define XA_AUDIO 1
  301. #endif
  302. #ifdef XA_LINUX_AUDIO
  303. #define XA_AUDIO 1
  304. #endif
  305. #ifdef XA_SGI_AUDIO
  306. #define XA_AUDIO 1
  307. #endif
  308. #ifdef XA_HPDEV_AUDIO
  309. #define XA_AUDIO 1
  310. #endif
  311. #ifdef XA_HP_AUDIO
  312. #define XA_AUDIO 1
  313. #endif
  314. #ifdef XA_EWS_AUDIO
  315. #define XA_AUDIO 1
  316. #endif
  317. #ifdef XA_SONY_AUDIO
  318. #define XA_AUDIO 1
  319. #endif
  320. #ifdef XA_AF_AUDIO
  321. #define XA_AUDIO 1
  322. #endif
  323. #ifdef XA_NAS_AUDIO
  324. #define XA_AUDIO 1
  325. #endif
  326.  
  327. /* AUDIO PORT MASKS */
  328. #define XA_AUDIO_PORT_INT    1
  329. #define XA_AUDIO_PORT_HEAD    2
  330. #define XA_AUDIO_PORT_EXT    4
  331. #define XA_AUDIO_PORT_NONE    8
  332.  
  333. #define XA_AUDIO_STEREO_MSK    0x000001
  334. #define XA_AUDIO_BPS_2_MSK    0x000002
  335. #define XA_AUDIO_BIGEND_MSK    0x000004
  336. #define XA_AUDIO_INVALID    0x000000
  337. #define XA_AUDIO_LINEAR        0x000010
  338. #define XA_AUDIO_SIGNED        0x000020
  339. #define XA_AUDIO_ULAW          0x000030
  340. #define XA_AUDIO_ADPCM        0x000040
  341. #define XA_AUDIO_NOP          0x000050
  342. #define XA_AUDIO_ARMLAW        0x000060
  343. #define XA_AUDIO_IMA4         0x000070
  344. #define XA_AUDIO_DVI          0x000080
  345. #define XA_AUDIO_TYPE_MASK      0xfffff0
  346.  
  347. /*NOTES: 
  348.  * last ending is [1|2](BPS),[M|S](Mono/Stereo),[B|L](big/little endian)
  349.  */
  350.  
  351. #define XA_AUDIO_LINEAR_1M    0x000010
  352. #define XA_AUDIO_LINEAR_1S    0x000011
  353. #define XA_AUDIO_LINEAR_2ML    0x000012
  354. #define XA_AUDIO_LINEAR_2SL    0x000013
  355. #define XA_AUDIO_LINEAR_2MB    0x000016
  356. #define XA_AUDIO_LINEAR_2SB    0x000017
  357.  
  358. #define XA_AUDIO_SIGNED_1M    0x000020
  359. #define XA_AUDIO_SIGNED_1S    0x000021
  360. #define XA_AUDIO_SIGNED_2ML    0x000022
  361. #define XA_AUDIO_SIGNED_2SL    0x000023
  362. #define XA_AUDIO_SIGNED_2MB    0x000026
  363. #define XA_AUDIO_SIGNED_2SB    0x000027
  364.  
  365. #define XA_AUDIO_SUN_AU        0x000030
  366. #define XA_AUDIO_ULAWM         0x000030
  367. #define XA_AUDIO_ULAWS         0x000031
  368.  
  369. #define XA_AUDIO_ARMLAWM    0x000060
  370. #define XA_AUDIO_ARMLAWS    0x000061
  371.  
  372. #define XA_AUDIO_ADPCM_M    0x000040
  373. #define XA_AUDIO_ADPCM_S    0x000041
  374.  
  375. #define XA_AUDIO_IMA4_M     0x000070
  376. #define XA_AUDIO_IMA4_S     0x000071
  377.  
  378. #define XA_AUDIO_DVI_M        0x000080
  379. #define XA_AUDIO_DVI_S        0x000081
  380.  
  381. #define XA_AUDIO_FILE_FLAG   0x0001
  382.  
  383. typedef struct XA_SND_STRUCT
  384. {
  385.   xaULONG type;        /* type, chans, bps, */
  386.   xaULONG flag;        /* flags */
  387.   xaLONG  fpos;        /* starting file position */
  388.   xaULONG itype;        /* input sample type */
  389.   xaULONG ifreq;        /* input sample freq */
  390.   xaULONG hfreq;        /* closest hardware freq */
  391.   xaULONG inc;        /* inc for i to h converstion << 24 */
  392.   xaULONG tot_bytes;    /* total size in bytes*/
  393.   xaULONG tot_samps;    /* total samples in chunk */
  394.   xaULONG inc_cnt;    /* dynamic var for freq conv */
  395.   xaULONG bit_cnt;    /* dynamic var for partial bytes - not used yet */
  396.   xaULONG byte_cnt;    /* dynamic var for counting bytes */
  397.   xaULONG samp_cnt;    /* samples used so far */
  398.   xaULONG blk_size;    /* size of blocks - used by some codecs */
  399.   xaULONG blk_cnt;    /* dynamic var for cnting inside a block */
  400.   xaULONG (*delta)();    /* conversion routine */
  401.   xaULONG snd_time;    /* time at start of snd struct ms */ 
  402.   xaULONG ch_time;    /* chunk time ms */
  403.   xaULONG ch_timelo;    /* chunk time fractional ms */
  404.   xaULONG ch_size;    /* size of chunk */
  405.   xaULONG spec;        /* used by decoder */
  406.   xaLONG dataL;        /* data Left channel */
  407.   xaLONG dataR;        /* data Right channel */
  408.   xaUBYTE *snd;        /* sound if present */
  409.   struct XA_SND_STRUCT *prev;
  410.   struct XA_SND_STRUCT *next;
  411. } XA_SND;
  412.  
  413. #define XA_SND_CHUNK_SIZE 65536
  414.  
  415. typedef struct
  416. {
  417.   char        *file;        /* is this a duplication of xanim_hdr->file?*/
  418.   FILE        *fin;           /* buffer file */
  419.   int        csock;          /* control socket */
  420.   int        dsock;          /* data socket */
  421.   xaULONG    fpos;        /* bytes read so far */
  422.   xaLONG    eof;        /* size of file - set by client */
  423.   xaULONG    err_flag;    /* set on errors and/or EOF */
  424.   xaULONG    type_flag;    /* random/sequential access? */
  425.   xaULONG    load_flag;    /* from file, from memory, buffered? */
  426.   xaULONG    (*Open_File)();
  427.   xaULONG    (*Close_File)();
  428.   xaULONG    (*Read_U8)();
  429.   xaULONG    (*Read_LSB_U16)();
  430.   xaULONG    (*Read_MSB_U16)();
  431.   xaULONG    (*Read_LSB_U32)();
  432.   xaULONG    (*Read_MSB_U32)();
  433.   xaLONG    (*Read_Block)();
  434.   xaLONG    (*At_EOF)();
  435.   void        (*Set_EOF)();
  436.   xaLONG    (*Seek_FPos)();
  437.   xaLONG    (*Get_FPos)();
  438.     /* This Buffer is used initially to Determine File type and later *
  439.      * to contruct u8, u16 and u32 entities for certain input methods */
  440.   xaUBYTE    *buf;
  441.   xaULONG    buf_size;
  442.   xaUBYTE    *buf_ptr;
  443.   xaULONG    buf_cnt;
  444.   void        *net;        /* generic structure for addition info */
  445. } XA_INPUT;
  446.  
  447.     /* load into memory and play from there */
  448. #define XA_IN_LOAD_MEM        0x00
  449.     /* don't load into mem, play from file */
  450. #define XA_IN_LOAD_FILE        0x01
  451.     /* decompress into X11 images and play those */
  452. #define XA_IN_LOAD_BUF        0x02
  453.  
  454.     /* Input Method supports Random access (otherwise Sequential only) */
  455. #define XA_IN_TYPE_RANDOM    0x01
  456. #define XA_IN_TYPE_SEQUENTIAL    0x00
  457.  
  458. #define XA_IN_ERR_NONE        0x00
  459. #define XA_IN_ERR_EOF        0x01
  460. #define XA_IN_ERR_ERR        0x02
  461.  
  462. typedef struct XA_PAUSE_STRUCT
  463. {
  464.   xaULONG frame;
  465.   struct XA_PAUSE_STRUCT *next;
  466. } XA_PAUSE;
  467.  
  468. typedef struct XA_FUNC_STRUCT
  469. {
  470.   xaULONG var1,var2;
  471.   void (*function)();
  472.   struct XA_FUNC_STRUCT *next;
  473. } XA_FUNC_CHAIN;
  474.  
  475. typedef struct XA_ANIM_HDR_STRUCT
  476. {
  477.   xaLONG    file_num;
  478.   xaLONG    anim_type;    /* animation type */
  479.   xaLONG    imagex;        /* width */
  480.   xaLONG    imagey;        /* height */
  481.   xaLONG    imagec;        /* number of colors */
  482.   xaLONG    imaged;        /* depth in planes */
  483.   xaLONG    dispx;        /* display width */
  484.   xaLONG    dispy;        /* display height */
  485.   xaLONG    buffx;        /* buffered width */
  486.   xaLONG    buffy;        /* buffered height */
  487.   xaLONG    anim_flags;
  488.   xaLONG    loop_num;    /* number of times to loop animation */
  489.   xaLONG    loop_frame;    /* index of loop frame */
  490.   xaLONG    last_frame;    /* index of last frame */
  491.   xaLONG    total_time;    /* Length of Anim in ms */
  492.   char        *name;        /* name of anim */
  493.   char        *fname;        /* name of anim data file(video and audio) */
  494.   char        *desc;        /* descriptive string */
  495. /* char         *fsndname;       eventually have separate sound file name */
  496.   XA_INPUT    *xin;        /* XAnim Input structure */
  497.   xaULONG    (*Read_File)();    /* Routine to Parse Animation */
  498.   xaLONG    max_fvid_size;    /* Largest video codec size */
  499.   xaLONG    max_faud_size;    /* Largest audio codec size */
  500.   XA_FRAME    *frame_lst;    /* array of Frames making up the animation */
  501.   XA_ACTION    *acts;        /* actions associated with this animation */
  502.   XA_SND    *first_snd;    /* ptr to first sound chunk */
  503.   XA_SND    *last_snd;    /* ptr to last sound chunk */
  504.   XA_PAUSE    *pause_lst;    /* pause list */
  505.   void        (*init_vid)();    /* routine to init video */
  506.   void        (*init_aud)();    /* routine to init audio */
  507.  
  508.   XA_FUNC_CHAIN *free_chain;    /* list of routines to call on exit */
  509.   struct XA_ANIM_HDR_STRUCT *next_file;
  510.   struct XA_ANIM_HDR_STRUCT *prev_file;
  511. } XA_ANIM_HDR;
  512.  
  513. #define ANIM_HAM    0x00000009
  514. #define ANIM_HAM6    0x00000001
  515. #define ANIM_LACE    0x00000002
  516. #define ANIM_CYCLE    0x00000004
  517. #define ANIM_HAM8    0x00000008
  518. #define ANIM_PIXMAP    0x00000100
  519. #define ANIM_FULL_IM    0x00001000
  520. #define ANIM_PING    0x00010000
  521. #define ANIM_NOLOOP    0x00020000
  522. /* single buffered, x11_bytes_pixel */
  523. #define ANIM_SNG_BUF    0x01000000
  524. /* double buffered, 1 byte per pixel */
  525. #define ANIM_DBL_BUF    0x02000000
  526. #define ANIM_3RD_BUF    0x04000000
  527. /* open anim_hdr->fname when starting anim */
  528. #define ANIM_USE_FILE    0x08000000
  529.  
  530. typedef struct
  531. {
  532.  xaLONG imagex;
  533.  xaLONG imagey;
  534.  xaLONG xoff;
  535.  xaLONG yoff;
  536. } SIZE_HDR;
  537.  
  538. typedef struct
  539.  xaULONG flag;
  540.  xaLONG xpos;
  541.  xaLONG ypos;
  542.  xaLONG xsize;
  543.  xaLONG ysize;
  544.  XImage *image;
  545.  xaUBYTE *clip;
  546. } ACT_IMAGE_HDR;
  547.  
  548. typedef struct
  549.  xaULONG flag;
  550.  xaLONG xpos;
  551.  xaLONG ypos;
  552.  xaLONG xsize;
  553.  xaLONG ysize;
  554.  Pixmap pixmap;
  555.  Pixmap clip;
  556. } ACT_PIXMAP_HDR;
  557.  
  558. typedef struct
  559.  xaLONG xpos;
  560.  xaLONG ypos;
  561.  xaLONG xsize;
  562.  xaLONG ysize;
  563.  XA_ACTION *act;
  564. } ACT_APTR_HDR;
  565.  
  566. #define ACT_BUFF_VALID 0x01
  567.  
  568. typedef struct
  569.   xaULONG xapi_rev;
  570.   xaULONG (*delta)();
  571.   xaULONG flags;
  572.   xaULONG xpos,ypos;
  573.   xaULONG xsize,ysize;
  574.   xaULONG special;
  575.   void *extra;
  576.   xaULONG fpos;
  577.   xaULONG fsize;
  578.   xaUBYTE data[4];
  579. } ACT_DLTA_HDR;
  580.  
  581. /* ACT_DLTA_HDR Flag Values */
  582. /* ALSO ACT_BUFF_VALID  0x0001   defined above */
  583. #define ACT_SNGL_BUF    0x0100   /* delta is from sngl buffer anim */
  584. #define ACT_DBL_BUF     0x0200   /* delta is from sngl buffer anim */
  585. #define ACT_3RD_BUF     0x0400   /* needs 3rd buffer for HAM or Dither */
  586. #define DLTA_DATA    0x1000   /* delta data is present */
  587.  
  588. /* DELTA Return VALUES */
  589. #define ACT_DLTA_NORM   0x00000000   /* nothing special */
  590. #define ACT_DLTA_BODY   0x00000001   /* IFF BODY - used for dbl buffer */
  591. #define ACT_DLTA_XOR    0x00000002   /* delta work in both directions */
  592. #define ACT_DLTA_NOP    0x00000004   /* delta didn't change anything */
  593. #define ACT_DLTA_MAPD   0x00000008   /* delta was able to map image */
  594. #define ACT_DLTA_DROP   0x00000010   /* drop this one */
  595. #define ACT_DLTA_BAD    0x80000000   /* uninitialize value if needed */
  596.  
  597.  
  598. typedef struct
  599. {
  600.   xaULONG cfunc_type;
  601.   void (*color_RGB)();
  602.   void (*color_Gray)();
  603.   void (*color_CLR8)();
  604.   void (*color_CLR16)();
  605.   void (*color_CLR32)();
  606.   void (*color_332)();
  607.   void (*color_CF4)();
  608.   void (*color_332_Dither)();
  609.   void (*color_CF4_Dither)();
  610. } XA_COLOR_FUNC;
  611.  
  612.  
  613. typedef struct
  614. {
  615.   xaULONG imagex,max_imagex;
  616.   xaULONG imagey,max_imagey;
  617.   xaULONG imagec;
  618.   xaULONG depth;
  619.   xaULONG compression;
  620.   xaUBYTE *pic;
  621.   xaULONG pic_size;
  622.   xaULONG max_fvid_size,max_faud_size;
  623.   xaULONG vid_time,vid_timelo;
  624.   xaULONG aud_time,aud_timelo;
  625.   xaULONG cmap_flag;
  626.   xaULONG cmap_cnt;
  627.   xaULONG color_cnt;
  628.   xaULONG color_retries;
  629.   xaULONG cmap_frame_num;
  630.   ColorReg cmap[256];
  631.   XA_CHDR  *chdr;
  632. } XA_ANIM_SETUP;
  633.  
  634.  
  635. typedef struct STRUCT_ACT_SETTER_HDR
  636.  XA_ACTION *work;
  637.  xaLONG xback,yback;
  638.  xaLONG xpback,ypback; 
  639.  XA_ACTION *back;
  640.  xaLONG xface,yface;
  641.  xaLONG xpface,ypface;
  642.  xaLONG depth;
  643.  XA_ACTION *face;
  644.  struct STRUCT_ACT_SETTER_HDR *next;
  645. } ACT_SETTER_HDR;
  646.  
  647. typedef struct
  648.   xaLONG xpos;
  649.   xaLONG ypos;
  650.   xaLONG xsize;
  651.   xaLONG ysize;
  652.   xaLONG psize;
  653.   xaUBYTE *clip;
  654.   xaUBYTE *data; 
  655. } ACT_MAPPED_HDR;
  656.  
  657. typedef struct
  658.   xaLONG xpos;
  659.   xaLONG ypos;
  660.   xaLONG xsize;
  661.   xaLONG ysize;
  662.   xaLONG psize;
  663.   xaLONG rbits;
  664.   xaLONG gbits;
  665.   xaLONG bbits;
  666.   xaUBYTE *clip;
  667.   xaUBYTE *data; 
  668. } ACT_TRUE_HDR;
  669.  
  670. typedef struct
  671.   xaLONG xpos;
  672.   xaLONG ypos;
  673.   xaLONG xsize;
  674.   xaLONG ysize;
  675.   xaLONG pk_size;
  676.   xaUBYTE *clip;
  677.   xaUBYTE data[4]; 
  678. } ACT_PACKED_HDR;
  679.  
  680. typedef struct
  681.  xaLONG xpos;
  682.  xaLONG ypos;
  683.  xaLONG xsize;
  684.  xaLONG ysize;
  685.  XImage *image;
  686.  xaUBYTE *clip_ptr;
  687. } ACT_CLIP_HDR;
  688.  
  689. #define ACT_NOP        0x0000
  690. #define ACT_DELAY    0x0001
  691. #define ACT_IMAGE    0x0002
  692. #define ACT_CMAP    0x0003
  693. #define ACT_SIZE    0x0004
  694. #define ACT_FADE    0x0005
  695. #define ACT_CLIP    0x0006
  696. #define ACT_PIXMAP    0x0007
  697. #define ACT_SETTER    0x0008
  698. #define ACT_RAW        0x0009
  699. #define ACT_PACKED    0x000A
  700. #define ACT_DISP    0x000B
  701. #define ACT_MAPPED    0x000C
  702. #define ACT_TRUE    0x000D
  703. #define ACT_PIXMAPS    0x000E
  704. #define ACT_IMAGES    0x000F
  705. #define ACT_CYCLE    0x0010
  706. #define ACT_DELTA    0x0011
  707. #define ACT_APTR     0x0012
  708. #define ACT_BEG_LP    0x0100
  709. #define ACT_END_LP    0x0101
  710. #define ACT_JMP2END    0x0102
  711.  
  712. /* flags */
  713. extern xaLONG xa_verbose;
  714. extern xaLONG xa_debug;
  715. extern xaLONG xa_jiffy_flag;
  716. extern xaLONG xa_buffer_flag;
  717. extern xaLONG xa_file_flag;
  718. extern xaLONG xa_optimize_flag;
  719. extern xaLONG xa_use_depth_flag;
  720.  
  721. #define DEBUG_LEVEL1   if (xa_debug >= 1) 
  722. #define DEBUG_LEVEL2   if (xa_debug >= 2) 
  723. #define DEBUG_LEVEL3   if (xa_debug >= 3) 
  724. #define DEBUG_LEVEL4   if (xa_debug >= 4) 
  725. #define DEBUG_LEVEL5   if (xa_debug >= 5) 
  726.  
  727. #define XA_CMAP_SIZE 256
  728. #define XA_HMAP_SIZE  64
  729. #define XA_HMAP6_SIZE 16
  730. #define XA_HMAP8_SIZE 64
  731.  
  732. /* CMAP function flags for ACT_Setup_CMAP */
  733. #define CMAP_DIRECT        0x000000
  734. #define CMAP_ALLOW_REMAP    0x000001
  735.  
  736.  
  737. #define CMAP_SCALE4 4369
  738. #define CMAP_SCALE5 2114
  739. #define CMAP_SCALE6 1040
  740. #define CMAP_SCALE8  257
  741. #define CMAP_SCALE9  128
  742. #define CMAP_SCALE10  64
  743. #define CMAP_SCALE11  32
  744. #define CMAP_SCALE13   8
  745. extern xaULONG cmap_scale[17];
  746. extern xaLONG cmap_true_to_332;
  747. extern xaLONG cmap_true_to_gray;
  748. extern xaLONG cmap_true_to_1st;
  749. extern xaLONG cmap_true_to_all;
  750. extern xaLONG cmap_true_map_flag;
  751. extern xaLONG cmap_dither_type;
  752.  
  753. extern xaULONG cmap_sample_cnt;  /* how many times to sample colors for +CF4 */
  754. extern xaULONG cmap_color_func;
  755. extern xaLONG cmap_luma_sort;
  756. extern xaLONG cmap_map_to_1st_flag;
  757. extern xaLONG cmap_play_nice;
  758. extern XA_CHDR *xa_chdr_start;
  759. extern XA_CHDR *xa_chdr_cur;
  760. extern XA_CHDR *xa_chdr_now;
  761. extern ColorReg *xa_cmap;
  762. extern xaULONG xa_cmap_size;
  763. extern xaULONG xa_cmap_off;
  764. extern xaLONG cmap_median_type;
  765. extern xaSHORT cmap_floyd_error;
  766. extern xaLONG cmap_map_to_one_flag;
  767. extern xaLONG pod_max_colors;
  768. extern xaLONG cmap_hist_flag;
  769. extern xaLONG cmap_median_bits;
  770. extern xaULONG cmap_cache_size;
  771. extern xaULONG cmap_cache_bits;
  772. extern xaULONG cmap_cache_rmask;
  773. extern xaULONG cmap_cache_gmask;
  774. extern xaULONG cmap_cache_bmask;
  775. extern xaUSHORT *cmap_cache,*cmap_cache2;
  776. extern XA_CHDR *cmap_cache_chdr;
  777.  
  778. extern xaULONG xa_gamma_flag;
  779. extern xaUSHORT xa_gamma_adj[];
  780.  
  781.  
  782. extern xaULONG xa_r_shift,xa_g_shift,xa_b_shift;
  783. extern xaULONG xa_r_mask,xa_g_mask,xa_b_mask;
  784. extern xaULONG xa_gray_bits,xa_gray_shift;
  785.  
  786. #define XA_HAM_MAP_INVALID 0xffffffff
  787. #define XA_HAM6_CACHE_SIZE   4096
  788. #define XA_HAM8_CACHE_SIZE 262144
  789.  
  790. typedef struct
  791. {
  792.  xaULONG rate;    /* rate at which to cycle colors in milliseconds */
  793.  xaULONG flags;   /* flags */
  794.  xaULONG size;    /* size of color array */
  795.  xaULONG curpos;  /* curpos in array */
  796.  xaUBYTE data[4];  /* array of cmap pixel values to cycle */
  797. } ACT_CYCLE_HDR;
  798.  
  799. /* ACT_CYCLE flags values */
  800. /* NOTE: ACTIVE isn't currently checked. It's assumed to be active or
  801.  *       else it shouldn't have been created by anim reader. */
  802. #define ACT_CYCLE_ACTIVE  0x01
  803. #define ACT_CYCLE_REVERSE 0x02
  804. #define ACT_CYCLE_STARTED 0x80000000
  805.  
  806. extern void TheEnd();
  807. extern void TheEnd1();
  808. extern void XAnim_Looped();
  809. extern void Cycle_It();
  810. extern xaULONG X11_Get_True_Color();
  811. extern xaULONG X11_Get_Line_Size();
  812.  
  813.  
  814. /* AUDIO STUFF */
  815.  
  816. #define XA_AUDIO_STOPPED 0
  817. #define XA_AUDIO_STARTED 1
  818. #define XA_AUDIO_NICHTDA 2
  819.  
  820. #define XA_AUDIO_OK   0
  821. #define XA_AUDIO_UNK  1
  822. #define XA_AUDIO_NONE 2
  823. #define XA_AUDIO_ERR  3
  824.  
  825. #define XA_AUDIO_MAXVOL  100
  826. #define XA_AUDIO_MINVOL  0
  827.  
  828. extern xaULONG xa_audio_enable;
  829.  
  830.  
  831. /* 
  832.  * Useful Macros 
  833.  */
  834.  
  835. #define CMAP_GET_GRAY(r,g,b,scale) \
  836. ( ((scale)*((r)*11+(g)*16+(b)*5) ) >> xa_gray_shift)
  837.  
  838. #define CMAP_GET_332(r,g,b,scale) ( \
  839. ( (((r)*(scale)) & xa_r_mask) >> xa_r_shift) | \
  840. ( (((g)*(scale)) & xa_g_mask) >> xa_g_shift) | \
  841. ( (((b)*(scale)) & xa_b_mask) >> xa_b_shift) )
  842.  
  843. #define X11_Get_Bitmap_Width(x) \
  844.   ( ((x + x11_bitmap_unit - 1)/x11_bitmap_unit) * x11_bitmap_unit )
  845.  
  846. #define X11_Make_Pixel(p)  (x11_cmap_type == 0)?(p): \
  847.         ( (((p)<<24)|((p)<<16)|((p)<<8)|(p)) & x11_depth_mask )
  848.  
  849. #define XA_PIC_SIZE(p) ( (xa_use_depth_flag==xaTRUE)?((p) * x11_bytes_pixel): \
  850.         (p) )
  851.  
  852. #define XA_GET_TIME(t) ( (xa_jiffy_flag)?(xa_jiffy_flag):(t) )
  853.  
  854. #define XA_MEMSET(p,d,size) \
  855. { if (x11_bytes_pixel==4) { xaULONG _sz=(size); \
  856.     xaULONG *_lp=(xaULONG *)p; while(_sz--) *_lp++ = (xaULONG)(d); } \
  857.   else if (x11_bytes_pixel==2) { xaULONG _sz=(size); \
  858.     xaUSHORT *_sp=(xaUSHORT *)p; while(_sz--) *_sp++ = (xaUSHORT)(d); } \
  859.   else { memset(p,d,size); } \
  860. }
  861.  
  862. #define XA_REALLOC(p,cur_size,new_size) { if (new_size > cur_size) \
  863. { char *_tmp; \
  864.   if (p == 0) _tmp=(char *)malloc(new_size); \
  865.   else _tmp=(char *)realloc(p,new_size); \
  866.   if (_tmp == 0) TheEnd1("XA_Realloc: malloc err"); \
  867.   p = _tmp; cur_size = new_size; } \
  868.  
  869. #define FREE(_p,_q) free(_p)
  870. /* For Debug
  871. #include <errno.h>
  872. #define FREE(_p,_q) { int ret; ret = free(_p); \
  873. fprintf(stderr,"FREE %lx %lx ret=%ld err=%ld\n",_p,_q,ret,errno); }
  874. */
  875.  
  876.  
  877. /* REV 1 */
  878. typedef struct
  879. {
  880.   xaULONG cmd;            /* decode or query */
  881.   xaULONG skip_flag;        /* skip_flag */
  882.   xaULONG imagex,imagey;    /* Image Buffer Size */
  883.   xaULONG imaged;         /* Image depth */
  884.   XA_CHDR *chdr;        /* Color Map Header */
  885.   xaULONG map_flag;        /* remap image? */
  886.   xaULONG *map;            /* map to use */
  887.   xaULONG xs,ys;        /* pos of changed area */
  888.   xaULONG xe,ye;        /* size of change area */
  889.   xaULONG special;        /* Special Info */
  890.   void *extra;            /* Decompression specific info */
  891. } XA_DEC_INFO;
  892.  
  893. /* REV 2 */
  894. typedef struct
  895. {
  896.   xaULONG cmd;            /* decode or query */
  897.   xaULONG skip_flag;        /* skip_flag */
  898.   xaULONG imagex,imagey;    /* Image Buffer Size */
  899.   xaULONG imaged;         /* Image depth */
  900.   XA_CHDR *chdr;        /* Color Map Header */
  901.   xaULONG map_flag;        /* remap image? */
  902.   xaULONG *map;            /* map to use */
  903.   xaULONG xs,ys;        /* pos of changed area */
  904.   xaULONG xe,ye;        /* size of change area */
  905.   xaULONG special;        /* Special Info */
  906.   xaULONG bytes_pixel;        /* bytes per pixel */
  907.   xaULONG image_type;        /* type of image */
  908.   xaULONG tmp1;            /* future expansion */
  909.   xaULONG tmp2;            /* future expansion */
  910.   xaULONG tmp3;            /* future expansion */
  911.   xaULONG tmp4;            /* future expansion */
  912.   void *extra;            /* Decompression specific info */
  913. } XA_DEC2_INFO;
  914.  
  915. #define XA_DEC_SPEC_RGB        0x0001
  916. #define XA_DEC_SPEC_CF4        0x0002
  917. #define XA_DEC_SPEC_DITH    0x0004
  918.  
  919. #define XA_IMTYPE_RGB        0x0001
  920. #define XA_IMTYPE_GRAY        0x0002
  921. #define XA_IMTYPE_CLR8        0x0003
  922. #define XA_IMTYPE_CLR16        0x0004
  923. #define XA_IMTYPE_CLR32        0x0005
  924. #define XA_IMTYPE_332        0x0006
  925. #define XA_IMTYPE_332DITH    0x0007
  926. #define XA_IMTYPE_CF4        0x0008
  927. #define XA_IMTYPE_CF4DITH    0x0009
  928.  
  929.  
  930.