Rearrange DriverSystem::select
[openttd/fttd.git] / src / spritecache.h
bloba7158fcfced70a00bd74f2ef595c0a45c5f59565
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 "core/alloc_type.hpp"
16 #include "blitter/blitter.h"
17 #include "gfx_type.h"
19 extern uint _sprite_cache_size;
21 void *GetRawSprite (SpriteID sprite, SpriteType type, bool cache = true);
22 bool SpriteExists(SpriteID sprite);
24 SpriteType GetSpriteType(SpriteID sprite);
25 uint GetOriginFileSlot(SpriteID sprite);
26 uint GetSpriteCountForSlot(uint file_slot, SpriteID begin, SpriteID end);
27 uint GetMaxSpriteID();
30 static inline const Sprite *GetSprite(SpriteID sprite, SpriteType type)
32 assert(type != ST_MAPGEN);
33 assert(type != ST_RECOLOUR);
34 return (Sprite*)GetRawSprite(sprite, type);
37 static inline const byte *GetNonSprite(SpriteID sprite, SpriteType type)
39 assert(type == ST_RECOLOUR);
40 return (byte*)GetRawSprite(sprite, type);
43 /** Data structure describing a map generator sprite. */
44 struct MapGenSprite : Sprite {
45 byte data[]; ///< Sprite data
48 const MapGenSprite *GetMapGenSprite (SpriteID sprite);
50 void GfxInitSpriteMem();
51 void GfxClearSpriteCache();
52 void IncreaseSpriteLRU();
54 void ReadGRFSpriteOffsets(byte container_version);
55 size_t GetGRFSpriteOffset(uint32 id);
56 bool LoadNextSprite(int load_index, byte file_index, uint file_sprite_id, byte container_version);
57 bool SkipSpriteData(byte type, uint16 num);
58 void DupSprite(SpriteID old_spr, SpriteID new_spr);
60 #endif /* SPRITECACHE_H */