Core: Add some debug checks

This commit is contained in:
Vicki Pfau 2017-09-24 17:34:07 -07:00
parent 405eafb969
commit dbeff59c06
1 changed files with 8 additions and 0 deletions

View File

@ -194,6 +194,14 @@ static void _regenerateTile256(struct mTileCache* cache, color_t* tile, unsigned
static inline color_t* _tileLookup(struct mTileCache* cache, unsigned tileId, unsigned paletteId) {
if (mTileCacheConfigurationIsShouldStore(cache->config)) {
unsigned tiles = mTileCacheSystemInfoGetMaxTiles(cache->sysConfig);
#ifndef NDEBUG
if (tileId >= tiles) {
abort();
}
if (paletteId >= 1 << mTileCacheSystemInfoGetPaletteCount(cache->sysConfig)) {
abort();
}
#endif
return &cache->cache[(tileId + paletteId * tiles) << 6];
} else {
return cache->temporaryTile;