(svn r23005) -Fix (r23004): Of course there's still the 16-sprite version for shore...
[openttd/fttd.git] / src / spritecache.h
blobf0c124f5acffb6acb5fc10fa681f8f6d5e1a10d4
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD 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, version 2.
6 * OpenTTD 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.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file spritecache.h Functions to cache sprites in memory. */
12 #ifndef SPRITECACHE_H
13 #define SPRITECACHE_H
15 #include "gfx_type.h"
17 /** Data structure describing a sprite. */
18 struct Sprite {
19 byte height; ///< Height of the sprite.
20 uint16 width; ///< Width of the sprite.
21 int16 x_offs; ///< Number of pixels to shift the sprite to the right.
22 int16 y_offs; ///< Number of pixels to shift the sprite downwards.
23 byte data[]; ///< Sprite data.
26 extern uint _sprite_cache_size;
28 typedef void *AllocatorProc(size_t size);
30 void *GetRawSprite(SpriteID sprite, SpriteType type, AllocatorProc *allocator = NULL);
31 bool SpriteExists(SpriteID sprite);
33 SpriteType GetSpriteType(SpriteID sprite);
34 uint GetOriginFileSlot(SpriteID sprite);
35 uint GetMaxSpriteID();
38 static inline const Sprite *GetSprite(SpriteID sprite, SpriteType type)
40 assert(type != ST_RECOLOUR);
41 return (Sprite*)GetRawSprite(sprite, type);
44 static inline const byte *GetNonSprite(SpriteID sprite, SpriteType type)
46 assert(type == ST_RECOLOUR);
47 return (byte*)GetRawSprite(sprite, type);
50 void GfxInitSpriteMem();
51 void IncreaseSpriteLRU();
53 bool LoadNextSprite(int load_index, byte file_index, uint file_sprite_id);
54 bool SkipSpriteData(byte type, uint16 num);
55 void DupSprite(SpriteID old_spr, SpriteID new_spr);
57 #endif /* SPRITECACHE_H */