My Project
Loading...
Searching...
No Matches
sprite.h
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 152
40
41typedef struct
42{
43 Uint16 width, height;
44 Uint16 size;
45 Uint8 *data;
46}
47Sprite;
48
49typedef struct
50{
51 unsigned int count;
52 Sprite sprite[SPRITES_PER_TABLE_MAX];
53}
55
56extern Sprite_array sprite_table[SPRITE_TABLES_MAX]; // fka shapearray, shapex, shapey, shapesize, shapexist, maxshape
57
58static 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
65static inline bool sprite_exists(unsigned int table, unsigned int index)
66{
67 return (sprite(table, index)->data != NULL);
68}
69static inline Uint16 get_sprite_width(unsigned int table, unsigned int index)
70{
71 return (sprite_exists(table, index) ? sprite(table, index)->width : 0);
72}
73static 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
78void load_sprites_file(unsigned int table, const char *filename);
79void load_sprites(unsigned int table, FILE *f);
80void free_sprites(unsigned int table);
81
82void blit_sprite(SDL_Surface *, int x, int y, unsigned int table, unsigned int index); // JE_newDrawCShapeNum
83void blit_sprite_blend(SDL_Surface *, int x, int y, unsigned int table, unsigned int index); // JE_newDrawCShapeTrick
84void blit_sprite_hv_unsafe(SDL_Surface *, int x, int y, unsigned int table, unsigned int index, Uint8 hue, Sint8 value); // JE_newDrawCShapeBright
85void blit_sprite_hv(SDL_Surface *, int x, int y, unsigned int table, unsigned int index, Uint8 hue, Sint8 value); // JE_newDrawCShapeAdjust
86void blit_sprite_hv_blend(SDL_Surface *, int x, int y, unsigned int table, unsigned int index, Uint8 hue, Sint8 value); // JE_newDrawCShapeModify
87void blit_sprite_dark(SDL_Surface *, int x, int y, unsigned int table, unsigned int index, bool black); // JE_newDrawCShapeDarken, JE_newDrawCShapeShadow
88
89typedef struct
90{
91 size_t size;
92 Uint8 *data;
93}
95
96// Shop icons and arrows sprite sheet.
97extern Sprite2_array shopSpriteSheet; // fka shapes6
98
99// Explosions sprite sheet.
100extern Sprite2_array explosionSpriteSheet; // fka shapes6
101
102// Enemy sprite sheet banks.
103extern Sprite2_array enemySpriteSheets[4]; // fka eShapes1, eShapes2, eShapes3, eShapes4
104extern Uint8 enemySpriteSheetIds[4]; // fka enemyShapeTables
105
106// Destruct sprite sheet.
107extern Sprite2_array destructSpriteSheet; // fka shapes6
108
109// Static sprite sheets. Player shots, player ships, power-ups, coins, etc.
110extern Sprite2_array spriteSheet8; // fka shapesC1
111extern Sprite2_array spriteSheet9; // fka shapes9
112extern Sprite2_array spriteSheet10; // fka eShapes6
113extern Sprite2_array spriteSheet11; // fka eShapes5
114extern Sprite2_array spriteSheet12; // fka shapesW2
115extern Sprite2_array spriteSheetT2000; // fka shapesT2k
116
117void JE_loadCompShapes(Sprite2_array *, char s);
118void JE_loadCompShapesB(Sprite2_array *, FILE *f);
119void free_sprite2s(Sprite2_array *);
120
121void blit_sprite2(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index);
122void blit_sprite2_clip(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index);
123void blit_sprite2_blend(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index);
124void blit_sprite2_darken(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index);
125void blit_sprite2_filter(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index, Uint8 filter);
126void blit_sprite2_filter_clip(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index, Uint8 filter);
127
128void blit_sprite2x2(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index);
129void blit_sprite2x2_clip(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index);
130void blit_sprite2x2_blend(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index);
131void blit_sprite2x2_darken(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index);
132void blit_sprite2x2_filter(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index, Uint8 filter);
133void blit_sprite2x2_filter_clip(SDL_Surface *, int x, int y, Sprite2_array, unsigned int index, Uint8 filter);
134
135void JE_loadMainShapeTables(const char *shpfile);
136void free_main_shape_tables(void);
137
138#endif // SPRITE_H
#define COUNTOF(a)
Calculate the number of elements in a fixed-length array.
Definition config_file.h:51
Definition sprite.h:90
Definition sprite.h:50
Definition sprite.h:42