src/spritecache.h
author rubidium
Wed, 17 Dec 2008 23:08:11 +0000
changeset 10434 3659467c844c
parent 10056 48659f7d4fa5
permissions -rw-r--r--
(svn r14687) -Change: log all configure errors to config.log
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2123
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2123
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8432
diff changeset
     3
/** @file spritecache.h Functions to cache sprites in memory. */
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6248
diff changeset
     4
1349
15979a2e9001 (svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents:
diff changeset
     5
#ifndef SPRITECACHE_H
15979a2e9001 (svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents:
diff changeset
     6
#define SPRITECACHE_H
15979a2e9001 (svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents:
diff changeset
     7
8123
ce31d2843a95 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 6908
diff changeset
     8
#include "gfx_type.h"
ce31d2843a95 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 6908
diff changeset
     9
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    10
struct Sprite {
1350
fd0136012af1 (svn r1854) Split GetSpritePtr() into GetSprite() for regular sprites (returning a Sprite*) and GetNonSprite() for "sprites" of type 0xFF (returning byte*)
tron
parents: 1349
diff changeset
    11
	byte height;
1356
fd5b13fafff3 (svn r1860) The sprite header endianness issue was solved in r1855
tron
parents: 1352
diff changeset
    12
	uint16 width;
fd5b13fafff3 (svn r1860) The sprite header endianness issue was solved in r1855
tron
parents: 1352
diff changeset
    13
	int16 x_offs;
fd5b13fafff3 (svn r1860) The sprite header endianness issue was solved in r1855
tron
parents: 1352
diff changeset
    14
	int16 y_offs;
1350
fd0136012af1 (svn r1854) Split GetSpritePtr() into GetSprite() for regular sprites (returning a Sprite*) and GetNonSprite() for "sprites" of type 0xFF (returning byte*)
tron
parents: 1349
diff changeset
    15
	byte data[VARARRAY_SIZE];
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    16
};
1350
fd0136012af1 (svn r1854) Split GetSpritePtr() into GetSprite() for regular sprites (returning a Sprite*) and GetNonSprite() for "sprites" of type 0xFF (returning byte*)
tron
parents: 1349
diff changeset
    17
6803
9803e56a8d9c (svn r10042) -Codechange: Replace hardcoded spritecache size with a configuration
peter1138
parents: 6420
diff changeset
    18
extern uint _sprite_cache_size;
9803e56a8d9c (svn r10042) -Codechange: Replace hardcoded spritecache size with a configuration
peter1138
parents: 6420
diff changeset
    19
10056
48659f7d4fa5 (svn r14223) -Codechange: make GetSprite aware of the 4 different types of sprites: fonts, recolour, mapgen and normal sprites.
rubidium
parents: 9111
diff changeset
    20
const void *GetRawSprite(SpriteID sprite, SpriteType type);
3565
ef0a9ef56fa0 (svn r4446) - Add function to determine if a Sprite ID exists.
peter1138
parents: 2436
diff changeset
    21
bool SpriteExists(SpriteID sprite);
1361
5833194df433 (svn r1865) Fix some warnings
tron
parents: 1357
diff changeset
    22
10056
48659f7d4fa5 (svn r14223) -Codechange: make GetSprite aware of the 4 different types of sprites: fonts, recolour, mapgen and normal sprites.
rubidium
parents: 9111
diff changeset
    23
static inline const Sprite *GetSprite(SpriteID sprite, SpriteType type)
1361
5833194df433 (svn r1865) Fix some warnings
tron
parents: 1357
diff changeset
    24
{
10056
48659f7d4fa5 (svn r14223) -Codechange: make GetSprite aware of the 4 different types of sprites: fonts, recolour, mapgen and normal sprites.
rubidium
parents: 9111
diff changeset
    25
	assert(type != ST_RECOLOUR);
48659f7d4fa5 (svn r14223) -Codechange: make GetSprite aware of the 4 different types of sprites: fonts, recolour, mapgen and normal sprites.
rubidium
parents: 9111
diff changeset
    26
	return (Sprite*)GetRawSprite(sprite, type);
1361
5833194df433 (svn r1865) Fix some warnings
tron
parents: 1357
diff changeset
    27
}
5833194df433 (svn r1865) Fix some warnings
tron
parents: 1357
diff changeset
    28
10056
48659f7d4fa5 (svn r14223) -Codechange: make GetSprite aware of the 4 different types of sprites: fonts, recolour, mapgen and normal sprites.
rubidium
parents: 9111
diff changeset
    29
static inline const byte *GetNonSprite(SpriteID sprite, SpriteType type)
1361
5833194df433 (svn r1865) Fix some warnings
tron
parents: 1357
diff changeset
    30
{
10056
48659f7d4fa5 (svn r14223) -Codechange: make GetSprite aware of the 4 different types of sprites: fonts, recolour, mapgen and normal sprites.
rubidium
parents: 9111
diff changeset
    31
	assert(type == ST_RECOLOUR);
48659f7d4fa5 (svn r14223) -Codechange: make GetSprite aware of the 4 different types of sprites: fonts, recolour, mapgen and normal sprites.
rubidium
parents: 9111
diff changeset
    32
	return (byte*)GetRawSprite(sprite, type);
1361
5833194df433 (svn r1865) Fix some warnings
tron
parents: 1357
diff changeset
    33
}
1349
15979a2e9001 (svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents:
diff changeset
    34
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 5587
diff changeset
    35
void GfxInitSpriteMem();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 5587
diff changeset
    36
void IncreaseSpriteLRU();
1349
15979a2e9001 (svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents:
diff changeset
    37
6908
6b1324d7a2c9 (svn r10157) -Fix: use as indentified for PNGs, the place of the image as it was in the grf, not the internal SpriteID
truelight
parents: 6869
diff changeset
    38
bool LoadNextSprite(int load_index, byte file_index, uint file_sprite_id);
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
    39
void DupSprite(SpriteID old_spr, SpriteID new_spr);
2340
e18ef06bc59a (svn r2866) Move all functions and tables which aren't directly involved in managing the sprite heap to a new file gfxinit.c.
tron
parents: 2319
diff changeset
    40
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2407
diff changeset
    41
#endif /* SPRITECACHE_H */