mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r2865) Push the responsibility for allocating the sprite heap into GfxInitSpriteMem()
This commit is contained in:
parent
bdd5d4ebb1
commit
26d24f64fc
|
@ -785,13 +785,13 @@ static void LoadSpriteTables(void)
|
||||||
_compact_cache_counter = 0;
|
_compact_cache_counter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GfxInitSpriteMem(void *ptr, uint32 size)
|
static void GfxInitSpriteMem(void)
|
||||||
{
|
{
|
||||||
// initialize sprite cache heap
|
// initialize sprite cache heap
|
||||||
_spritecache_ptr = ptr;
|
if (_spritecache_ptr == NULL) _spritecache_ptr = malloc(SPRITE_CACHE_SIZE);
|
||||||
|
|
||||||
// A big free block
|
// A big free block
|
||||||
_spritecache_ptr->size = (size - sizeof(MemBlock)) | S_FREE_MASK;
|
_spritecache_ptr->size = (SPRITE_CACHE_SIZE - sizeof(MemBlock)) | S_FREE_MASK;
|
||||||
// Sentinel block (identified by size == 0)
|
// Sentinel block (identified by size == 0)
|
||||||
NextBlock(_spritecache_ptr)->size = 0;
|
NextBlock(_spritecache_ptr)->size = 0;
|
||||||
|
|
||||||
|
@ -801,8 +801,6 @@ static void GfxInitSpriteMem(void *ptr, uint32 size)
|
||||||
|
|
||||||
void GfxLoadSprites(void)
|
void GfxLoadSprites(void)
|
||||||
{
|
{
|
||||||
static byte *_sprite_mem;
|
|
||||||
|
|
||||||
// Need to reload the sprites only if the landscape changed
|
// Need to reload the sprites only if the landscape changed
|
||||||
if (_sprite_page_to_load != _opt.landscape) {
|
if (_sprite_page_to_load != _opt.landscape) {
|
||||||
_sprite_page_to_load = _opt.landscape;
|
_sprite_page_to_load = _opt.landscape;
|
||||||
|
@ -810,9 +808,7 @@ void GfxLoadSprites(void)
|
||||||
// Sprite cache
|
// Sprite cache
|
||||||
DEBUG(spritecache, 1) ("Loading sprite set %d.", _sprite_page_to_load);
|
DEBUG(spritecache, 1) ("Loading sprite set %d.", _sprite_page_to_load);
|
||||||
|
|
||||||
// Reuse existing memory?
|
GfxInitSpriteMem();
|
||||||
if (_sprite_mem == NULL) _sprite_mem = malloc(SPRITE_CACHE_SIZE);
|
|
||||||
GfxInitSpriteMem(_sprite_mem, SPRITE_CACHE_SIZE);
|
|
||||||
LoadSpriteTables();
|
LoadSpriteTables();
|
||||||
GfxInitPalettes();
|
GfxInitPalettes();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue