aboutsummaryrefslogtreecommitdiff
path: root/modules/mod_flic/mod_flic.h
blob: 65f4eb72b64dcc3493dcd66300a0a8cbff55b67f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
 *  Copyright � 2006-2013 SplinterGU (Fenix/Bennugd)
 *  Copyright � 2002-2006 Fenix Team (Fenix)
 *  Copyright � 1999-2002 Jos� Luis Cebri�n Pag�e (Fenix)
 *
 *  This file is part of Bennu - Game Development
 *
 *  This software is provided 'as-is', without any express or implied
 *  warranty. In no event will the authors be held liable for any damages
 *  arising from the use of this software.
 *
 *  Permission is granted to anyone to use this software for any purpose,
 *  including commercial applications, and to alter it and redistribute it
 *  freely, subject to the following restrictions:
 *
 *     1. The origin of this software must not be misrepresented; you must not
 *     claim that you wrote the original software. If you use this software
 *     in a product, an acknowledgment in the product documentation would be
 *     appreciated but is not required.
 *
 *     2. Altered source versions must be plainly marked as such, and must not be
 *     misrepresented as being the original software.
 *
 *     3. This notice may not be removed or altered from any source
 *     distribution.
 *
 */

#ifndef __FLIC_H
#define __FLIC_H

#include "libgrbase.h"
#include "files.h"
#include "xstrings.h"

#include <SDL_types.h>

#ifndef __GNUC__
#define __PACKED
#define inline __inline
#else
#define __PACKED __attribute__ ((packed))
#endif

#ifdef _MSC_VER
#pragma pack(push, 1)
#endif

/* Reproducci�n de FLI */
/* ------------------- */

typedef struct
{
    uint32_t  size;          /* Size of FLIC including this header */
    uint16_t  type;          /* File type 0xAF11, 0xAF12, 0xAF30, 0xAF44, ... */
    uint16_t  frames;        /* Number of frames in first segment */
    uint16_t  width;         /* FLIC width in pixels */
    uint16_t  height;        /* FLIC height in pixels */
    uint16_t  depth;         /* Bits per pixel (usually 8) */
    uint16_t  flags;         /* Set to zero or to three */
    uint32_t  speed;         /* Delay between frames */
    uint16_t  reserved1;     /* Set to zero */
    uint32_t  created;       /* Date of FLIC creation (FLC only) */
    uint32_t  creator;       /* Serial number or compiler id (FLC only) */
    uint32_t  updated;       /* Date of FLIC update (FLC only) */
    uint32_t  updater;       /* Serial number (FLC only), see creator */
    uint16_t  aspect_dx;     /* Width of square rectangle (FLC only) */
    uint16_t  aspect_dy;     /* Height of square rectangle (FLC only) */
    uint16_t  ext_flags;     /* EGI: flags for specific EGI extensions */
    uint16_t  keyframes;     /* EGI: key-image frequency */
    uint16_t  totalframes;   /* EGI: total number of frames (segments) */
    uint32_t  req_memory;    /* EGI: maximum chunk size (uncompressed) */
    uint16_t  max_regions;   /* EGI: max. number of regions in a CHK_REGION chunk */
    uint16_t  transp_num;    /* EGI: number of transparent levels */
    uint8_t   reserved2[24]; /* Set to zero */
    uint32_t  oframe1;       /* Offset to frame 1 (FLC only) */
    uint32_t  oframe2;       /* Offset to frame 2 (FLC only) */
    uint8_t   reserved3[40]; /* Set to zero */
}
__PACKED
FLIC_HEADER;

typedef union
{
    struct
    {
        uint32_t size;           /* Size of the chunk */
        uint16_t type;           /* Chunk type */
    }
    header ;

    struct
    {
        uint32_t size;           /* Size of the chunk */
        uint16_t type;           /* Chunk type: 12 */
        uint16_t first_line;     /* First line */
        uint16_t line_count;     /* Number of lines in the chunk */
        uint8_t  data[0];
    }
    delta_fli ;

    struct
    {
        uint32_t size;           /* Size of the chunk  */
        uint16_t type;           /* Chunk type: 15, 12, etc. */
        uint8_t  data[0];
    }
    raw ;
}
FLIC_CHUNK ;

typedef struct
{
    uint32_t size;  /* Size of the frame, including subchunks */
    uint16_t type;  /* Chunk type: 0xF1FA */
    uint16_t chunks; /* Number of subchunks */
    uint8_t  expand[8];
}
FLIC_FRAME ;

typedef struct
{
    FLIC_HEADER header ;
    FLIC_CHUNK  * chunk ;
    FLIC_FRAME  * frame ;
    uint32_t      frame_reserved ;

    GRAPH       * bitmap ;

    file        * fp ;

    int         objid;

    int         current_frame ;
    int         speed_ms ;
    int         last_frame_ms ;
    int         finished ;

    int         x;
    int         y;
    int         z;
    int         angle;
    int         size;
    int         flags;

    int         saved_x;
    int         saved_y;
    int         saved_z;
    int         saved_angle;
    int         saved_size;
    int         saved_flags;

}
FLIC ;

/* Tipos de chunk */

#define CHUNK_COLOR_256  4
#define CHUNK_COLOR_64   11
#define CHUNK_DELTA_FLI  12
#define CHUNK_DELTA_FLC  7
#define CHUNK_BLACK      13
#define CHUNK_BYTE_RUN  15
#define CHUNK_FLI_COPY  16
#define CHUNK_STAMP     18
#define CHUNK_PREFIX  0xF100
#define CHUNK_FRAME   0xF1FA

#ifdef _MSC_VER
#pragma pack(pop)
#endif

#endif