(svn r10042) -Codechange: Replace hardcoded spritecache size with a configuration

option, sprite_cache_size. The default size is 2MB and the value can 
range from 1 to 64MB. If you experience slow-downs when scrolling the 
map, try increasing this setting.
pull/155/head
peter1138 17 years ago
parent 0e09964973
commit de7e370240

@ -46,6 +46,7 @@
#include "gfx.h"
#include "fontcache.h"
#endif
#include "spritecache.h"
/** The patch values that are used for new games and/or modified in config file */
Patches _patches_newgame;
@ -1257,6 +1258,7 @@ static const SettingDescGlobVarList _misc_settings[] = {
SDTG_VAR("medium_size", SLE_UINT, S, 0, _freetype.medium_size, 10, 0, 72, 0, STR_NULL, NULL),
SDTG_VAR("large_size", SLE_UINT, S, 0, _freetype.large_size, 16, 0, 72, 0, STR_NULL, NULL),
#endif
SDTG_VAR("sprite_cache_size",SLE_UINT, S, 0, _sprite_cache_size, 2, 1, 64, 0, STR_NULL, NULL),
SDTG_END()
};

@ -12,9 +12,9 @@
#include "fileio.h"
#include "helpers.hpp"
#ifndef SPRITE_CACHE_SIZE
# define SPRITE_CACHE_SIZE 2*1024*1024
#endif /* SPRITE_CACHE_SIZE */
/* Default of 2MB spritecache */
uint _sprite_cache_size = 2;
struct SpriteCache {
@ -409,10 +409,10 @@ const void *GetRawSprite(SpriteID sprite)
void GfxInitSpriteMem()
{
/* initialize sprite cache heap */
if (_spritecache_ptr == NULL) _spritecache_ptr = (MemBlock*)malloc(SPRITE_CACHE_SIZE);
if (_spritecache_ptr == NULL) _spritecache_ptr = (MemBlock*)malloc(_sprite_cache_size * 1024 * 1024);
/* A big free block */
_spritecache_ptr->size = (SPRITE_CACHE_SIZE - sizeof(MemBlock)) | S_FREE_MASK;
_spritecache_ptr->size = ((_sprite_cache_size * 1024 * 1024) - sizeof(MemBlock)) | S_FREE_MASK;
/* Sentinel block (identified by size == 0) */
NextBlock(_spritecache_ptr)->size = 0;

@ -14,6 +14,8 @@ struct Sprite {
byte data[VARARRAY_SIZE];
};
extern uint _sprite_cache_size;
const void *GetRawSprite(SpriteID sprite);
bool SpriteExists(SpriteID sprite);

Loading…
Cancel
Save