Debian Codegraph @

src/sprite.h

raw symbols SCIP
1 /*
2 * OpenTyrian: A modern cross-platform port of Tyrian
3 * Copyright (C) 2007-2009 The OpenTyrian Development Team
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19 #ifndef SPRITE_H
20 #define SPRITE_H
21
22 #include "opentyr.h"
23
24 #include "SDL.h"
25
26 #include <assert.h>
27 #include <stdio.h>
28
29 #define FONT_SHAPES 0
30 #define SMALL_FONT_SHAPES 1
31 #define TINY_FONT 2
32 #define PLANET_SHAPES 3
33 #define FACE_SHAPES 4
34 #define OPTION_SHAPES 5 /*Also contains help shapes*/
35 #define WEAPON_SHAPES 6
36 #define EXTRA_SHAPES 7 /*Used for Ending pics*/
37
38 #define SPRITE_TABLES_MAX 8
39 #define SPRITES_PER_TABLE_MAX 151
40
41 typedef struct
42 {
43 Uint16 width, height;
44 Uint16 size;
45 Uint8 *data;
46 }
47 Sprite;
48
49 typedef struct
50 {
51 unsigned int count;
52 Sprite sprite[SPRITES_PER_TABLE_MAX];
53 }
54 Sprite_array;
55
56 extern Sprite_array sprite_table[SPRITE_TABLES_MAX]; // fka shapearray, shapex, shapey, shapesize, shapexist, maxshape
57
58 static inline Sprite *sprite(unsigned int table, unsigned int index)
59 {
60 assert(table < COUNTOF(sprite_table));
61 assert(index < COUNTOF(sprite_table->sprite));
62 return &sprite_table[table].sprite[index];
63 }
64
65 static inline bool sprite_exists(unsigned int table, unsigned int index)
66 {
67 return (sprite(table, index)->data != NULL);
68 }
69 static inline Uint16 get_sprite_width(unsigned int table, unsigned int index)
70 {
71 return (sprite_exists(table, index) ? sprite(table, index)->width : 0);
72 }
73 static inline Uint16 get_sprite_height(unsigned int table, unsigned int index)
74 {
75 return (sprite_exists(table, index) ? sprite(table, index)->height : 0);
76 }
77
78 void load_sprites_file(unsigned int table, const char *filename);
79 void load_sprites(unsigned int table, FILE *f);
80 void free_sprites(unsigned int table);
81
82 void blit_sprite(SDL_Surface *, int x, int y, unsigned int table, unsigned int index); // JE_newDrawCShapeNum
83 void blit_sprite_blend(SDL_Surface *, int x, int y, unsigned int table, unsigned int index); // JE_newDrawCShapeTrick
84 void blit_sprite_hv_unsafe(SDL_Surface *, int x, int y, unsigned int table, unsigned int index, Uint8 hue, Sint8 value); // JE_newDrawCShapeBright
85 void blit_sprite_hv(SDL_Surface *, int x, int y, unsigned int table, unsigned int index, Uint8 hue, Sint8 value); // JE_newDrawCShapeAdjust
86 void blit_sprite_hv_blend(SDL_Surface *, int x, int y, unsigned int table, unsigned int index, Uint8 hue, Sint8 value); // JE_newDrawCShapeModify
87 void blit_sprite_dark(SDL_Surface *, int x, int y, unsigned int table, unsigned int index, bool black); // JE_newDrawCShapeDarken, JE_newDrawCShapeShadow
88
89 typedef struct
90 {
91 size_t size;
92 Uint8 *data;
93 }
94 Sprite2_array;
95
96 // Shop icons and arrows sprite sheet.
97 extern Sprite2_array shopSpriteSheet; // fka shapes6
98
99 // Explosions sprite sheet.
100 extern Sprite2_array explosionSpriteSheet; // fka shapes6
101
102 // Enemy sprite sheet banks.
103 extern Sprite2_array enemySpriteSheets[4]; // fka eShapes1, eShapes2, eShapes3, eShapes4
104 extern Uint8 enemySpriteSheetIds[4]; // fka enemyShapeTables
105
106 // Destruct sprite sheet.
107 extern Sprite2_array destructSpriteSheet; // fka shapes6
108
109 // Static sprite sheets. Player shots, player ships, power-ups, coins, etc.
110 extern Sprite2_array spriteSheet8; // fka shapesC1
111 extern Sprite2_array spriteSheet9; // fka shapes9
112 extern Sprite2_array spriteSheet10; // fka eShapes6
113 extern Sprite2_array spriteSheet11; // fka eShapes5
114 extern Sprite2_array spriteSheet12; // fka shapesW2
115
116 void JE_loadCompShapes(Sprite2_array *, char s);
117 void JE_loadCompShapesB(Sprite2_array *, FILE *f);
118 void free_sprite2s(Sprite2_array *);
119
120 void blit_sprite2(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index);
121 void blit_sprite2_clip(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index);
122 void blit_sprite2_blend(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index);
123 void blit_sprite2_darken(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index);
124 void blit_sprite2_filter(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index, Uint8 filter);
125 void blit_sprite2_filter_clip(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index, Uint8 filter);
126
127 void blit_sprite2x2(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index);
128 void blit_sprite2x2_clip(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index);
129 void blit_sprite2x2_blend(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index);
130 void blit_sprite2x2_darken(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index);
131 void blit_sprite2x2_filter(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index, Uint8 filter);
132 void blit_sprite2x2_filter_clip(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index, Uint8 filter);
133
134 void JE_loadMainShapeTables(const char *shpfile);
135 void free_main_shape_tables(void);
136
137 #endif // SPRITE_H