summaryrefslogtreecommitdiffstats
path: root/plug-ins/file-fli/fli.h
blob: 40f0f76bcf33a779e243174a768474f8305c054b (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
/*
 * Written 1998 Jens Ch. Restemeier <jchrr@hrz.uni-bielefeld.de>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 */
#ifndef _FLI_H
#define _FLI_H

/** structures */

typedef struct _fli_header
{
  unsigned long  filesize;
  unsigned short magic;
  unsigned short frames;
  unsigned short width;
  unsigned short height;
  unsigned short depth;
  unsigned short flags;
  unsigned long  speed;
  unsigned long  created;
  unsigned long  creator;
  unsigned long  updated;
  unsigned short aspect_x, aspect_y;
  unsigned long  oframe1, oframe2;
} s_fli_header;

typedef struct _fli_frame
{
  unsigned long  size;
  unsigned short magic;
  unsigned short chunks;
} s_fli_frame;

typedef struct _fli_chunk
{
  unsigned long   size;
  unsigned short  magic;
  unsigned char  *data;
} s_fli_chunk;

/** chunk magics */
#define NO_HEADER       0
#define HEADER_FLI      0xAF11
#define HEADER_FLC      0xAF12
#define FRAME           0xF1FA

/** codec magics */
#define FLI_COLOR       11
#define FLI_BLACK       13
#define FLI_BRUN        15
#define FLI_COPY        16
#define FLI_LC          12
#define FLI_LC_2        7
#define FLI_COLOR_2     4
#define FLI_MINI        18

/** codec masks */
#define W_COLOR         0x0001
#define W_BLACK         0x0002
#define W_BRUN          0x0004
#define W_COPY          0x0008
#define W_LC            0x0010
#define W_LC_2          0x0020
#define W_COLOR_2       0x0040
#define W_MINI          0x0080
#define W_ALL           0xFFFF

/** functions */
void fli_read_header   (FILE          *f,
                        s_fli_header  *fli_header);
void fli_read_frame    (FILE          *f,
                        s_fli_header  *fli_header,
                        unsigned char *old_framebuf,
                        unsigned char *old_cmap,
                        unsigned char *framebuf,
                        unsigned char *cmap);

void fli_read_color    (FILE          *f,
                        s_fli_header  *fli_header,
                        unsigned char *old_cmap,
                        unsigned char *cmap);
void fli_read_color_2  (FILE          *f,
                        s_fli_header  *fli_header,
                        unsigned char *old_cmap,
                        unsigned char *cmap);
void fli_read_black    (FILE          *f,
                        s_fli_header  *fli_header,
                        unsigned char *framebuf);
void fli_read_brun     (FILE          *f,
                        s_fli_header  *fli_header,
                        unsigned char *framebuf);
void fli_read_copy     (FILE          *f,
                        s_fli_header  *fli_header,
                        unsigned char *framebuf);
void fli_read_lc       (FILE          *f,
                        s_fli_header  *fli_header,
                        unsigned char *old_framebuf,
                        unsigned char *framebuf);
void fli_read_lc_2     (FILE          *f,
                        s_fli_header  *fli_header,
                        unsigned char *old_framebuf,
                        unsigned char *framebuf);

void fli_write_header  (FILE          *f,
                        s_fli_header  *fli_header);
void fli_write_frame   (FILE          *f,
                        s_fli_header  *fli_header,
                        unsigned char *old_framebuf,
                        unsigned char *old_cmap,
                        unsigned char *framebuf,
                        unsigned char *cmap,
                        unsigned short codec_mask);

int  fli_write_color   (FILE          *f,
                        s_fli_header  *fli_header,
                        unsigned char *old_cmap,
                        unsigned char *cmap);
int  fli_write_color_2 (FILE          *f,
                        s_fli_header  *fli_header,
                        unsigned char *old_cmap,
                        unsigned char *cmap);
void fli_write_black   (FILE          *f,
                        s_fli_header  *fli_header,
                        unsigned char *framebuf);
void fli_write_brun    (FILE          *f,
                        s_fli_header  *fli_header,
                        unsigned char *framebuf);
void fli_write_copy    (FILE          *f,
                        s_fli_header  *fli_header,
                        unsigned char *framebuf);
void fli_write_lc      (FILE          *f,
                        s_fli_header  *fli_header,
                        unsigned char *old_framebuf,
                        unsigned char *framebuf);
void fli_write_lc_2    (FILE          *f,
                        s_fli_header  *fli_header,
                        unsigned char *old_framebuf,
                        unsigned char *framebuf);

#endif