Debian Codegraph @

src/gfx_sprites.h

raw
1 /**
2 * Graphics - sequences management
3
4 * Copyright (C) 2007, 2008 Sylvain Beucler
5
6 * This file is part of GNU FreeDink
7
8 * GNU FreeDink is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 3 of the
11 * License, or (at your option) any later version.
12
13 * GNU FreeDink is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
21 */
22
23 #ifndef _GFX_SPRITES_H
24 #define _GFX_SPRITES_H
25
26 #include "SDL.h"
27 #include "rect.h"
28 #include "IOGfxSurface.h"
29
30 /* Max number of sprites, minus 1 (GFX_k is indexed from 1) */
31 #define MAX_SPRITES 4000
32 #define MAX_FRAMES_PER_SEQUENCE 50
33 /* Max number of frames the engine was ever abused to load in one
34 sequence (with a buffer overflow on other 'seq' fields). According
35 to a study of existing D-Mods in 2009, the highest frame number is
36 69 (in "The Green Voice in my Head Part I v3.0"). The engine would
37 accept up to 1000 frames but it would probably mess the memory too
38 much. */
39 #define MAX_FRAMES_PER_ABUSED_SEQUENCE 69
40 #define MAX_SEQUENCES 1000 /* Max # of sprite animations */
41
42 /* Store sprites info */
43 struct pic_info {
44 rect box; // Dimensions (0,0,width,height)
45 rect hardbox; // Square where Dink can't block if sprite is hard
46 int yoffset; // Center of the picture
47 int xoffset;
48 };
49 struct GFX_pic_info {
50 IOGfxSurface* k; // Sprites
51 };
52
53 /* Sequence description */
54 struct sequence
55 {
56 char* ini; // matching dink.ini (or init()) line
57 char is_active; // does it contain something
58 short len; // number of initial frames in this sequence
59 // - inaccurate if the sequence is modified by 'set_frame_frame'
60 /* frame: index in GFX_k for the each frame, indexed from 1, ended
61 by '0'. If -1, loop from beginning. Now this one is tricky: the
62 original engine's load_sprite() can load non-animated sequences
63 of more than MAX_FRAMES_PER_SEQUENCE (up to 1000) at the
64 expense of a non-critical buffer overflow in 'delay' and
65 'special'. */
66 short frame[MAX_FRAMES_PER_ABUSED_SEQUENCE+1+1];
67 short delay[MAX_FRAMES_PER_ABUSED_SEQUENCE+1]; // frame duration, indexed from 1
68 unsigned char special[MAX_FRAMES_PER_ABUSED_SEQUENCE+1]; // does this frame 'hit' enemies, indexed from 1
69 };
70
71 extern struct pic_info k[MAX_SPRITES];
72 extern struct GFX_pic_info GFX_k[MAX_SPRITES];
73 extern struct sequence seq[MAX_SEQUENCES];
74
75 extern void sprites_unload(void);
76 extern void load_sprite_pak(char seq_path_prefix[100], int seq_no, int speed, int xoffset, int yoffset,
77 rect hardbox, int flags, int samedir);
78 extern void load_sprites(char seq_path_prefix[100], int seq_no, int speed, int xoffset, int yoffset,
79 rect hardbox, int flags);
80 extern void seq_set_ini(int seq_no, char *line);
81
82 extern void(*gfx_sprites_loading_listener)();
83
84 extern /*bool*/int not_in_this_base(int seq, int base);
85 extern /*bool*/int in_this_base(int seq, int base);
86
87 #endif