Core: Extend tile cache to return raw bits
Vicki Pfau vi@endrift.com
Thu, 02 Feb 2017 16:33:48 -0800
2 files changed,
26 insertions(+),
0 deletions(-)
M
include/mgba/core/tile-cache.h
→
include/mgba/core/tile-cache.h
@@ -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* 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
M
src/core/tile-cache.c
→
src/core/tile-cache.c
@@ -283,3 +283,27 @@ entry[paletteId] = *status;
} 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]; + } +}