Debian Codegraph @

libmve/mvelib.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2002-2024 D2X Project
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef INCLUDED_MVELIB_H
19 #define INCLUDED_MVELIB_H
20
21 #include <cstdio>
22 #include <cstdlib>
23
24 /* callback for reading stream */
25 typedef unsigned int (*mve_cb_Read)(void *stream, void *buffer, unsigned int count);
26 /* callback for memore allocating */
27 typedef void *(*mve_cb_Alloc)(unsigned int size);
28 /* callback for memory freeing */
29 typedef void (*mve_cb_Free)(void *ptr);
30 /* callback for showing frame */
31 typedef void (*mve_cb_ShowFrame)(unsigned char *buffer, unsigned int bufw, unsigned int bufh, unsigned int sx,
32 unsigned int sy, unsigned int w, unsigned int h, unsigned int dstx, unsigned int dsty,
33 unsigned int hicolor);
34 /* callback for setting palette */
35 typedef void (*mve_cb_SetPalette)(const unsigned char *p, unsigned int start, unsigned int count);
36 /* callback for segment type */
37 typedef int (*MVESEGMENTHANDLER)(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context);
38
39 extern mve_cb_Read mve_read;
40 extern mve_cb_Alloc mve_alloc;
41 extern mve_cb_Free mve_free;
42 extern mve_cb_ShowFrame mve_showframe;
43 extern mve_cb_SetPalette mve_setpalette;
44
45 #define MVE_ERR_EOF 1
46
47 typedef struct {
48 int screenWidth;
49 int screenHeight;
50 int width;
51 int height;
52 int truecolor;
53 } MVE_videoSpec;
54
55 /* structure for maintaining info on a MVEFILE stream */
56 typedef struct MVEFILE {
57 void *stream;
58 unsigned char *cur_chunk;
59 int buf_size;
60 int cur_fill;
61 int next_segment;
62 } MVEFILE;
63
64 /* structure for maintaining an MVE stream */
65 typedef struct MVESTREAM {
66 MVEFILE *movie;
67 void *context;
68 MVESEGMENTHANDLER handlers[32];
69 } MVESTREAM;
70
71 MVESTREAM* MVE_rmPrepMovie(void *stream, int x, int y, int track);
72 int MVE_rmStepMovie(MVESTREAM *mve);
73 void MVE_rmHoldMovie();
74 void MVE_rmEndMovie(MVESTREAM *mve);
75
76 void MVE_getVideoSpec(MVE_videoSpec *vSpec);
77
78 // Initialize MVE sound. Set `enable` to false if sound should not be enabled.
79 void MVE_sndInit(const bool enable);
80
81 void MVE_ioCallbacks(mve_cb_Read io_read);
82 void MVE_memCallbacks(mve_cb_Alloc mem_alloc, mve_cb_Free mem_free);
83 void MVE_sfCallbacks(mve_cb_ShowFrame showframe);
84 void MVE_palCallbacks(mve_cb_SetPalette setpalette);
85
86 // Low-level functions
87
88 /* open an MVE file */
89 MVEFILE *mvefile_open(void *stream);
90
91 /* close an MVE file */
92 void mvefile_close(MVEFILE *movie);
93
94 /* get size of next segment in chunk (-1 if no more segments in chunk) */
95 int mvefile_get_next_segment_size(MVEFILE *movie);
96
97 /* get type of next segment in chunk (0xff if no more segments in chunk) */
98 unsigned char mvefile_get_next_segment_major(MVEFILE *movie);
99
100 /* get subtype (version) of next segment in chunk (0xff if no more segments in chunk) */
101 unsigned char mvefile_get_next_segment_minor(MVEFILE *movie);
102
103 /* see next segment (return NULL if no next segment) */
104 unsigned char *mvefile_get_next_segment(MVEFILE *movie);
105
106 /* advance to next segment */
107 void mvefile_advance_segment(MVEFILE *movie);
108
109 /* fetch the next chunk (return 0 if at end of stream) */
110 int mvefile_fetch_next_chunk(MVEFILE *movie);
111
112 /* open an MVE stream */
113 MVESTREAM *mve_open(void *stream);
114
115 /* close an MVE stream */
116 void mve_close(MVESTREAM *movie);
117
118 /* reset an MVE stream */
119 void mve_reset(MVESTREAM *movie);
120
121 /* set segment type handler */
122 void mve_set_handler(MVESTREAM *movie, unsigned char major, MVESEGMENTHANDLER handler);
123
124 /* set segment handler context */
125 void mve_set_handler_context(MVESTREAM *movie, void *context);
126
127 /* play next chunk */
128 int mve_play_next_chunk(MVESTREAM *movie);
129
130 #endif /* INCLUDED_MVELIB_H */