equal
deleted
inserted
replaced
10 #include "spritecache.h" |
10 #include "spritecache.h" |
11 #include "table/sprites.h" |
11 #include "table/sprites.h" |
12 #include "fileio.h" |
12 #include "fileio.h" |
13 #include "helpers.hpp" |
13 #include "helpers.hpp" |
14 |
14 |
15 #ifndef SPRITE_CACHE_SIZE |
15 |
16 # define SPRITE_CACHE_SIZE 2*1024*1024 |
16 /* Default of 2MB spritecache */ |
17 #endif /* SPRITE_CACHE_SIZE */ |
17 uint _sprite_cache_size = 2; |
18 |
18 |
19 |
19 |
20 struct SpriteCache { |
20 struct SpriteCache { |
21 void *ptr; |
21 void *ptr; |
22 uint32 file_pos; |
22 uint32 file_pos; |
407 |
407 |
408 |
408 |
409 void GfxInitSpriteMem() |
409 void GfxInitSpriteMem() |
410 { |
410 { |
411 /* initialize sprite cache heap */ |
411 /* initialize sprite cache heap */ |
412 if (_spritecache_ptr == NULL) _spritecache_ptr = (MemBlock*)malloc(SPRITE_CACHE_SIZE); |
412 if (_spritecache_ptr == NULL) _spritecache_ptr = (MemBlock*)malloc(_sprite_cache_size * 1024 * 1024); |
413 |
413 |
414 /* A big free block */ |
414 /* A big free block */ |
415 _spritecache_ptr->size = (SPRITE_CACHE_SIZE - sizeof(MemBlock)) | S_FREE_MASK; |
415 _spritecache_ptr->size = ((_sprite_cache_size * 1024 * 1024) - sizeof(MemBlock)) | S_FREE_MASK; |
416 /* Sentinel block (identified by size == 0) */ |
416 /* Sentinel block (identified by size == 0) */ |
417 NextBlock(_spritecache_ptr)->size = 0; |
417 NextBlock(_spritecache_ptr)->size = 0; |
418 |
418 |
419 /* Reset the spritecache 'pool' */ |
419 /* Reset the spritecache 'pool' */ |
420 free(_spritecache); |
420 free(_spritecache); |