all repos — mgba @ 373fbe89708dc4fc195dec926b281c42e198c505

mGBA Game Boy Advance Emulator

GBA Video: Fix map cache for 256-color mode 0 backgrounds
Vicki Pfau vi@endrift.com
Sun, 07 Jan 2018 23:29:00 -0800
commit

373fbe89708dc4fc195dec926b281c42e198c505

parent

69db3f41a3acc87467ac698718d649327e70e74b

1 files changed, 16 insertions(+), 7 deletions(-)

jump to
M src/gba/renderers/cache-set.csrc/gba/renderers/cache-set.c

@@ -57,12 +57,15 @@ GBAVideoCacheWriteVideoRegister(cache, REG_BG3CNT, video->p->memory.io[REG_BG3CNT >> 1]);

} static void mapParser0(struct mMapCache* cache, struct mMapCacheEntry* entry, void* vram) { - UNUSED(cache); uint16_t map = *(uint16_t*) vram; entry->tileId = GBA_TEXT_MAP_TILE(map); entry->flags = mMapCacheEntryFlagsSetHMirror(entry->flags, !!GBA_TEXT_MAP_HFLIP(map)); entry->flags = mMapCacheEntryFlagsSetVMirror(entry->flags, !!GBA_TEXT_MAP_VFLIP(map)); - entry->flags = mMapCacheEntryFlagsSetPaletteId(entry->flags, GBA_TEXT_MAP_PALETTE(map)); + if (mMapCacheSystemInfoGetPaletteBPP(cache->sysConfig) == 3) { + entry->flags = mMapCacheEntryFlagsClearPaletteId(entry->flags); + } else { + entry->flags = mMapCacheEntryFlagsSetPaletteId(entry->flags, GBA_TEXT_MAP_PALETTE(map)); + } } static void mapParser2(struct mMapCache* cache, struct mMapCacheEntry* entry, void* vram) {

@@ -82,10 +85,14 @@ mMapCacheSetGetPointer(&cache->maps, 1)->mapParser = mapParser0;

mMapCacheSetGetPointer(&cache->maps, 2)->mapParser = mapParser0; mMapCacheSetGetPointer(&cache->maps, 3)->mapParser = mapParser0; - mMapCacheSetGetPointer(&cache->maps, 0)->tileCache = mTileCacheSetGetPointer(&cache->tiles, 0); - mMapCacheSetGetPointer(&cache->maps, 1)->tileCache = mTileCacheSetGetPointer(&cache->tiles, 0); - mMapCacheSetGetPointer(&cache->maps, 2)->tileCache = mTileCacheSetGetPointer(&cache->tiles, 0); - mMapCacheSetGetPointer(&cache->maps, 3)->tileCache = mTileCacheSetGetPointer(&cache->tiles, 0); + mMapCacheSetGetPointer(&cache->maps, 0)->tileCache = mTileCacheSetGetPointer(&cache->tiles, + mMapCacheSystemInfoGetPaletteBPP(mMapCacheSetGetPointer(&cache->maps, 0)->sysConfig) == 3); + mMapCacheSetGetPointer(&cache->maps, 1)->tileCache = mTileCacheSetGetPointer(&cache->tiles, + mMapCacheSystemInfoGetPaletteBPP(mMapCacheSetGetPointer(&cache->maps, 1)->sysConfig) == 3); + mMapCacheSetGetPointer(&cache->maps, 2)->tileCache = mTileCacheSetGetPointer(&cache->tiles, + mMapCacheSystemInfoGetPaletteBPP(mMapCacheSetGetPointer(&cache->maps, 2)->sysConfig) == 3); + mMapCacheSetGetPointer(&cache->maps, 3)->tileCache = mTileCacheSetGetPointer(&cache->tiles, + mMapCacheSystemInfoGetPaletteBPP(mMapCacheSetGetPointer(&cache->maps, 3)->sysConfig) == 3); break; case 1: case 2:

@@ -113,6 +120,7 @@ int tilesWide = 0;

int tilesHigh = 0; mMapCacheSystemInfo sysconfig = 0; if (map->mapParser == mapParser0) { + map->tileCache = mTileCacheSetGetPointer(&cache->tiles, p); sysconfig = mMapCacheSystemInfoSetPaletteBPP(sysconfig, 2 + p); sysconfig = mMapCacheSystemInfoSetPaletteCount(sysconfig, 4 * !p); sysconfig = mMapCacheSystemInfoSetMacroTileSize(sysconfig, 5);

@@ -125,8 +133,9 @@ }

if (size & 2) { ++tilesHigh; } - map->tileStart = tileStart * 2; + map->tileStart = tileStart * (2 - p); } else if (map->mapParser == mapParser2) { + map->tileCache = mTileCacheSetGetPointer(&cache->tiles, 1); sysconfig = mMapCacheSystemInfoSetPaletteBPP(sysconfig, 3); sysconfig = mMapCacheSystemInfoSetPaletteCount(sysconfig, 0); sysconfig = mMapCacheSystemInfoSetMacroTileSize(sysconfig, 4 + size);