2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file spritecache.h Functions to cache sprites in memory. */
|
2007-04-04 01:35:16 +00:00
|
|
|
|
2005-02-10 05:43:30 +00:00
|
|
|
#ifndef SPRITECACHE_H
|
|
|
|
#define SPRITECACHE_H
|
|
|
|
|
2007-12-23 10:56:02 +00:00
|
|
|
#include "gfx_type.h"
|
|
|
|
|
2009-06-26 23:20:32 +00:00
|
|
|
/** Data structure describing a sprite. */
|
2007-03-07 12:11:48 +00:00
|
|
|
struct Sprite {
|
2011-11-24 12:38:48 +00:00
|
|
|
uint16 height; ///< Height of the sprite.
|
|
|
|
uint16 width; ///< Width of the sprite.
|
|
|
|
int16 x_offs; ///< Number of pixels to shift the sprite to the right.
|
|
|
|
int16 y_offs; ///< Number of pixels to shift the sprite downwards.
|
|
|
|
byte data[]; ///< Sprite data.
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2005-02-10 12:14:38 +00:00
|
|
|
|
2007-06-05 10:40:29 +00:00
|
|
|
extern uint _sprite_cache_size;
|
|
|
|
|
2011-01-14 15:34:33 +00:00
|
|
|
typedef void *AllocatorProc(size_t size);
|
|
|
|
|
2011-01-14 16:36:34 +00:00
|
|
|
void *GetRawSprite(SpriteID sprite, SpriteType type, AllocatorProc *allocator = NULL);
|
2006-04-16 11:26:23 +00:00
|
|
|
bool SpriteExists(SpriteID sprite);
|
2005-02-13 08:12:03 +00:00
|
|
|
|
2010-04-25 16:27:30 +00:00
|
|
|
SpriteType GetSpriteType(SpriteID sprite);
|
|
|
|
uint GetOriginFileSlot(SpriteID sprite);
|
|
|
|
uint GetMaxSpriteID();
|
|
|
|
|
|
|
|
|
2008-09-02 15:20:38 +00:00
|
|
|
static inline const Sprite *GetSprite(SpriteID sprite, SpriteType type)
|
2005-02-13 08:12:03 +00:00
|
|
|
{
|
2008-09-02 15:20:38 +00:00
|
|
|
assert(type != ST_RECOLOUR);
|
|
|
|
return (Sprite*)GetRawSprite(sprite, type);
|
2005-02-13 08:12:03 +00:00
|
|
|
}
|
|
|
|
|
2008-09-02 15:20:38 +00:00
|
|
|
static inline const byte *GetNonSprite(SpriteID sprite, SpriteType type)
|
2005-02-13 08:12:03 +00:00
|
|
|
{
|
2008-09-02 15:20:38 +00:00
|
|
|
assert(type == ST_RECOLOUR);
|
|
|
|
return (byte*)GetRawSprite(sprite, type);
|
2005-02-13 08:12:03 +00:00
|
|
|
}
|
2005-02-10 05:43:30 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void GfxInitSpriteMem();
|
2011-11-24 12:26:44 +00:00
|
|
|
void GfxClearSpriteCache();
|
2007-03-07 11:47:46 +00:00
|
|
|
void IncreaseSpriteLRU();
|
2005-02-10 05:43:30 +00:00
|
|
|
|
2012-02-04 13:29:04 +00:00
|
|
|
void ReadGRFSpriteOffsets(byte container_version);
|
|
|
|
size_t GetGRFSpriteOffset(uint32 id);
|
|
|
|
bool LoadNextSprite(int load_index, byte file_index, uint file_sprite_id, byte container_version);
|
2010-01-17 15:05:25 +00:00
|
|
|
bool SkipSpriteData(byte type, uint16 num);
|
2007-01-10 18:56:51 +00:00
|
|
|
void DupSprite(SpriteID old_spr, SpriteID new_spr);
|
2005-08-14 18:10:18 +00:00
|
|
|
|
2005-09-18 20:56:44 +00:00
|
|
|
#endif /* SPRITECACHE_H */
|