author | Tero Marttila <terom@fixme.fi> |
Fri, 18 Jul 2008 21:28:42 +0300 | |
changeset 11175 | 020c61e39c94 |
parent 10429 | 1b99254f9607 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10429
1b99254f9607
(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:
8928
diff
changeset
|
3 |
/** @file spritecache.h Functions to cache sprites in memory. */ |
6916
e87d54a598ea
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6574
diff
changeset
|
4 |
|
1349
07514c2cc6d1
(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 |
07514c2cc6d1
(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 |
07514c2cc6d1
(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 |
|
8619
c2434269c3eb
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents:
7404
diff
changeset
|
8 |
#include "gfx_type.h" |
c2434269c3eb
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents:
7404
diff
changeset
|
9 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
10 |
struct Sprite { |
1350
067b22970f19
(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
291c2802243f
(svn r1860) The sprite header endianness issue was solved in r1855
tron
parents:
1352
diff
changeset
|
12 |
uint16 width; |
291c2802243f
(svn r1860) The sprite header endianness issue was solved in r1855
tron
parents:
1352
diff
changeset
|
13 |
int16 x_offs; |
291c2802243f
(svn r1860) The sprite header endianness issue was solved in r1855
tron
parents:
1352
diff
changeset
|
14 |
int16 y_offs; |
1350
067b22970f19
(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]; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
16 |
}; |
1350
067b22970f19
(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 |
|
7299
74e163f03bbc
(svn r10042) -Codechange: Replace hardcoded spritecache size with a configuration
peter1138
parents:
6916
diff
changeset
|
18 |
extern uint _sprite_cache_size; |
74e163f03bbc
(svn r10042) -Codechange: Replace hardcoded spritecache size with a configuration
peter1138
parents:
6916
diff
changeset
|
19 |
|
7365
d484a635f91d
(svn r10109) -Fix [FS#838]: some NewGRFs use the same (unused in the "current" climate) sprite IDs. Normally this gives some artefacts, but when one NewGRF expects it to be a sprite and another NewGRF overwrites it with a non-sprite nasty things happen (drawing a non-sprite crashes OTTD).
rubidium
parents:
7348
diff
changeset
|
20 |
const void *GetRawSprite(SpriteID sprite, bool real_sprite); |
3565
03d870cc3dcd
(svn r4446) - Add function to determine if a Sprite ID exists.
peter1138
parents:
2436
diff
changeset
|
21 |
bool SpriteExists(SpriteID sprite); |
1361 | 22 |
|
23 |
static inline const Sprite *GetSprite(SpriteID sprite) |
|
24 |
{ |
|
7365
d484a635f91d
(svn r10109) -Fix [FS#838]: some NewGRFs use the same (unused in the "current" climate) sprite IDs. Normally this gives some artefacts, but when one NewGRF expects it to be a sprite and another NewGRF overwrites it with a non-sprite nasty things happen (drawing a non-sprite crashes OTTD).
rubidium
parents:
7348
diff
changeset
|
25 |
return (Sprite*)GetRawSprite(sprite, true); |
1361 | 26 |
} |
27 |
||
28 |
static inline const byte *GetNonSprite(SpriteID sprite) |
|
29 |
{ |
|
7365
d484a635f91d
(svn r10109) -Fix [FS#838]: some NewGRFs use the same (unused in the "current" climate) sprite IDs. Normally this gives some artefacts, but when one NewGRF expects it to be a sprite and another NewGRF overwrites it with a non-sprite nasty things happen (drawing a non-sprite crashes OTTD).
rubidium
parents:
7348
diff
changeset
|
30 |
return (byte*)GetRawSprite(sprite, false); |
1361 | 31 |
} |
1349
07514c2cc6d1
(svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents:
diff
changeset
|
32 |
|
6573 | 33 |
void GfxInitSpriteMem(); |
34 |
void IncreaseSpriteLRU(); |
|
1349
07514c2cc6d1
(svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents:
diff
changeset
|
35 |
|
7404
fc0559157f16
(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:
7365
diff
changeset
|
36 |
bool LoadNextSprite(int load_index, byte file_index, uint file_sprite_id); |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
37 |
void DupSprite(SpriteID old_spr, SpriteID new_spr); |
2340
0a9f3eeccb96
(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
|
38 |
|
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2407
diff
changeset
|
39 |
#endif /* SPRITECACHE_H */ |