Core: Extend tile cache to return raw bits

This commit is contained in:
Vicki Pfau 2017-02-02 16:33:48 -08:00
parent cea83a5444
commit f3b66397a2
2 changed files with 26 additions and 0 deletions

View File

@ -58,6 +58,8 @@ void mTileCacheSetPalette(struct mTileCache* cache, int palette);
const uint16_t* mTileCacheGetTile(struct mTileCache* cache, unsigned tileId, unsigned paletteId); const uint16_t* mTileCacheGetTile(struct mTileCache* cache, unsigned tileId, unsigned paletteId);
const uint16_t* mTileCacheGetTileIfDirty(struct mTileCache* cache, struct mTileCacheEntry* entry, unsigned tileId, unsigned paletteId); const uint16_t* mTileCacheGetTileIfDirty(struct mTileCache* cache, struct mTileCacheEntry* entry, unsigned tileId, unsigned paletteId);
const uint8_t* mTileCacheGetRawTile(struct mTileCache* cache, unsigned tileId);
const uint16_t* mTileCacheGetPalette(struct mTileCache* cache, unsigned paletteId);
CXX_GUARD_END CXX_GUARD_END

View File

@ -283,3 +283,27 @@ const uint16_t* mTileCacheGetTileIfDirty(struct mTileCache* cache, struct mTileC
} }
return tile; return tile;
} }
const uint8_t* mTileCacheGetRawTile(struct mTileCache* cache, unsigned tileId) {
unsigned bpp = cache->bpp;
switch (bpp) {
case 0:
return NULL;
default:
return (uint8_t*) &cache->vram[tileId << (2 + bpp)];
}
}
const uint16_t* mTileCacheGetPalette(struct mTileCache* cache, unsigned paletteId) {
unsigned bpp = cache->bpp;
switch (bpp) {
default:
return NULL;
case 1:
return &cache->palette[paletteId << 2];
case 2:
return &cache->palette[paletteId << 4];
case 3:
return &cache->palette[paletteId << 8];
}
}