all repos — mgba @ f3b66397a2a598e5cfb63acd0c0b84f5796d0802

mGBA Game Boy Advance Emulator

Core: Extend tile cache to return raw bits
Vicki Pfau vi@endrift.com
Thu, 02 Feb 2017 16:33:48 -0800
commit

f3b66397a2a598e5cfb63acd0c0b84f5796d0802

parent

cea83a54442957023710fb6cd6101163fdc76948

2 files changed, 26 insertions(+), 0 deletions(-)

jump to
M include/mgba/core/tile-cache.hinclude/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.csrc/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]; + } +}