summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/settings.cpp2
-rw-r--r--src/spritecache.cpp10
-rw-r--r--src/spritecache.h2
3 files changed, 9 insertions, 5 deletions
diff --git a/src/settings.cpp b/src/settings.cpp
index ea4e289fb..01065f4eb 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -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()
};
diff --git a/src/spritecache.cpp b/src/spritecache.cpp
index 50d880dd3..c45c92d96 100644
--- a/src/spritecache.cpp
+++ b/src/spritecache.cpp
@@ -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;
diff --git a/src/spritecache.h b/src/spritecache.h
index 747fbdecb..c979b73c5 100644
--- a/src/spritecache.h
+++ b/src/spritecache.h
@@ -14,6 +14,8 @@ struct Sprite {
byte data[VARARRAY_SIZE];
};
+extern uint _sprite_cache_size;
+
const void *GetRawSprite(SpriteID sprite);
bool SpriteExists(SpriteID sprite);