flic.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. //**************************************************************************
  2. //
  3. // Filename : flic.h
  4. //
  5. // Purpose : to define some flic stuff
  6. //
  7. // Modification history :
  8. //
  9. //**************************************************************************
  10. #ifndef __FLIC_H
  11. #define __FLIC_H
  12. //**************************************************************************
  13. //
  14. // Includes
  15. //
  16. //**************************************************************************
  17. #include "sgp.h"
  18. #include <stdio.h>
  19. //**************************************************************************
  20. //
  21. // Defines
  22. //
  23. //**************************************************************************
  24. #define ErrFlicLibAccess -1
  25. #define ErrFlicAccess -2
  26. #define ErrFlicSeek -3
  27. #define ErrFlicRead -4
  28. #define ErrFlicBad -5
  29. #define ErrFlicBadFrame -6
  30. //**************************************************************************
  31. //
  32. // Typedefs
  33. //
  34. //**************************************************************************
  35. struct _Flic;
  36. typedef signed char Char; /* Signed 8 bits. */
  37. typedef unsigned char Uchar; /* Unsigned 8 bits. */
  38. typedef short Short; /* Signed 16 bits please. */
  39. typedef unsigned short Ushort; /* Unsigned 16 bits please. */
  40. typedef long Long; /* Signed 32 bits. */
  41. typedef unsigned long Ulong; /* Unsigned 32 bits. */
  42. typedef int Boolean; /* TRUE or FALSE value. */
  43. typedef int ErrCode; /* ErrXXX or Success. */
  44. typedef int FileHandle; /* OS file handle. */
  45. typedef Uchar Pixel; /* Pixel type. */
  46. typedef ErrCode FlicOpenFunc(struct _Flic *flic, const char *filename);
  47. typedef ErrCode FlicCheckFrameFunc(struct _Flic *);
  48. typedef ErrCode FlicSeekFunc(struct _Flic *, long offset);
  49. typedef struct
  50. {
  51. Uchar r,g,b;
  52. } Colour; /* One color map entry r,g,b 0-255. */
  53. typedef struct
  54. {
  55. Pixel pixels[2];
  56. } Pixels2; /* For word-oriented run length encoding */
  57. /* Flic Header */
  58. typedef struct
  59. {
  60. Long size; /* Size of flic including this header. */
  61. Ushort type; /* Either FLI_TYPE or FLC_TYPE below. */
  62. Ushort frames; /* Number of frames in flic. */
  63. Ushort width; /* Flic width in pixels. */
  64. Ushort height; /* Flic height in pixels. */
  65. Ushort depth; /* Bits per pixel. (Always 8 now.) */
  66. Ushort flags; /* FLI_FINISHED | FLI_LOOPED ideally. */
  67. Long speed; /* Delay between frames. */
  68. Short reserved1; /* Set to zero. */
  69. Short created1;
  70. Short created2;
  71. //Ulong created; /* Date of flic creation. (FLC only.) */
  72. Short creator1;
  73. Short creator2;
  74. //Ulong creator; /* Serial # of flic creator. (FLC only.) */
  75. Short updated1;
  76. Short updated2;
  77. //Ulong updated; /* Date of flic update. (FLC only.) */
  78. Short updater1;
  79. Short updater2;
  80. //Ulong updater; /* Serial # of flic updater. (FLC only.) */
  81. Ushort aspect_dx; /* Width of square rectangle. (FLC only.) */
  82. Ushort aspect_dy; /* Height of square rectangle. (FLC only.) */
  83. Char reserved2[38]; /* Set to zero. */
  84. Long oframe1; /* Offset to frame 1. (FLC only.) */
  85. Long oframe2; /* Offset to frame 2. (FLC only.) */
  86. Char reserved3[40]; /* Set to zero. */
  87. } FlicHead;
  88. typedef struct
  89. {
  90. Pixel *pixels; /* Set to AOOO:0000 for hardware. */
  91. int width, height; /* Dimensions of screen. (320x200) */
  92. char change_palette; /*True means that the flic changes the palette */
  93. } FlicScreen; /* Device specific screen type. */
  94. typedef struct
  95. {
  96. Ulong max_loop_count,
  97. loop_count;
  98. Ushort max_frame_index,
  99. frame_index;
  100. } FlicFrameStatus;
  101. typedef struct
  102. {
  103. // lmlib_t *names;
  104. long offset,
  105. length;
  106. }FlicLib;
  107. typedef struct _Flic
  108. {
  109. FlicHead head; /* Flic file header. */
  110. FILE *file; /* File handle. */
  111. const char *name; /* Name from flic_open. Helps error reporting. */
  112. int xoff,yoff; /* Offset to display flic at. */
  113. FlicFrameStatus status;
  114. FlicScreen screen;
  115. FlicLib lib;
  116. FlicOpenFunc *open;
  117. FlicCheckFrameFunc *check_frame;
  118. FlicSeekFunc *seek;
  119. } Flic;
  120. /* Values for FlicHead.type */
  121. #define FLI_TYPE 0xAF11u /* 320x200 .FLI type ID */
  122. #define FLC_TYPE 0xAF12u /* Variable rez .FLC type ID */
  123. /* Values for FlicHead.flags */
  124. #define FLI_FINISHED 0x0001
  125. #define FLI_LOOPED 0x0002
  126. /* Optional Prefix Header */
  127. typedef struct
  128. {
  129. Long size; /* Size of prefix including header. */
  130. Ushort type; /* Always PREFIX_TYPE. */
  131. Short chunks; /* Number of subchunks in prefix. */
  132. Char reserved[8];/* Always 0. */
  133. } PrefixHead;
  134. /* Value for PrefixHead.type */
  135. #define PREFIX_TYPE 0xF100u
  136. /* Frame Header */
  137. typedef struct
  138. {
  139. Long size; /* Size of frame including header. */
  140. Ushort type; /* Always FRAME_TYPE */
  141. Short chunks; /* Number of chunks in frame. */
  142. Char reserved[8];/* Always 0. */
  143. } FrameHead;
  144. /* Value for FrameHead.type */
  145. #define FRAME_TYPE 0xF1FAu
  146. /* Chunk Header */
  147. typedef struct
  148. {
  149. Long size; /* Size of chunk including header. */
  150. Ushort type; /* Value from ChunkTypes below. */
  151. } ChunkHead;
  152. typedef enum
  153. {
  154. COLOR_256 = 4, /* 256 level color pallette info. (FLC only.) */
  155. DELTA_FLC = 7, /* Word-oriented delta compression. (FLC only.) */
  156. COLOR_64 = 11, /* 64 level color pallette info. */
  157. DELTA_FLI = 12, /* Byte-oriented delta compression. */
  158. BLACK_FRAME = 13, /* whole frame is color 0 */
  159. BYTE_RUN = 15, /* Byte run-length compression. */
  160. LITERAL = 16, /* Uncompressed pixels. */
  161. PSTAMP = 18, /* "Postage stamp" chunk. (FLC only.) */
  162. } ChunkTypes;
  163. //**************************************************************************
  164. //
  165. // Function prototypes.
  166. //
  167. //**************************************************************************
  168. #ifdef __cplusplus
  169. extern "C" {
  170. #endif /* __cplusplus */
  171. void FlicInit(Flic *flic, unsigned screen_width, unsigned screen_height, char change_palette, char *Buffer);
  172. ErrCode FlicOpen(Flic *flic, const char *filename);
  173. void FlicSetOrigin(Flic *flic, unsigned x, unsigned y);
  174. ErrCode FlicPlay(Flic *flic, Ulong max_loop);
  175. void FlicClose(Flic *flic);
  176. void FlicSeekFirst(Flic *flic);
  177. int FlicAdvance(Flic *flic, BOOL fDecode);
  178. int FlicAdvanceNoDecode(Flic *flic);
  179. int FlicStart(char *filename, int width, int height, char *buffer, Flic *flic, char usepal);
  180. void FlicStop(Flic *flic);
  181. ErrCode FlicGetStats(char *filename, int width, int height, Flic *flic, int *piBufferSize, int *piColourPalSize);
  182. ErrCode FlicGetColourPalette(CHAR *filename, int width, int height, CHAR **ppBuffer, INT *piNumColours);
  183. CHAR *FlicSeekChunk(Flic *flic, INT iFrame, ChunkTypes eType, INT *piChunkSize);
  184. INT FlicFindByteRunBeforeFrame(Flic *flic, INT iFrame);
  185. ErrCode FlicFillBitmapData( Flic *flic, INT iPrevFrame, INT iFrame, HBITMAP hBitmap );
  186. ErrCode FlicFillFrameData( Flic *flic, INT iPrevFrame, INT iFrame, CHAR *, INT * );
  187. void FlicClearBitmap( HBITMAP hBitmap, INT iColourIndex );
  188. #ifdef __cplusplus
  189. }
  190. #endif /* __cplusplus */
  191. extern char FlicPal[768];
  192. #endif