Core: Fix "macro" tile dynamic sizing

This commit is contained in:
Vicki Pfau 2017-09-23 18:12:44 -07:00
parent 229d138dac
commit f27be6e5f2
4 changed files with 11 additions and 15 deletions

View File

@ -21,8 +21,8 @@ DECL_BITS(mMapCacheSystemInfo, PaletteBPP, 0, 2);
DECL_BITS(mMapCacheSystemInfo, PaletteCount, 2, 4); DECL_BITS(mMapCacheSystemInfo, PaletteCount, 2, 4);
DECL_BITS(mMapCacheSystemInfo, TilesWide, 8, 4); DECL_BITS(mMapCacheSystemInfo, TilesWide, 8, 4);
DECL_BITS(mMapCacheSystemInfo, TilesHigh, 12, 4); DECL_BITS(mMapCacheSystemInfo, TilesHigh, 12, 4);
DECL_BITS(mMapCacheSystemInfo, MaxTiles, 16, 13); DECL_BITS(mMapCacheSystemInfo, MacroTileSize, 16, 7);
DECL_BITS(mMapCacheSystemInfo, MapAlign, 29, 2); DECL_BITS(mMapCacheSystemInfo, MapAlign, 23, 2);
DECL_BITFIELD(mMapCacheEntryFlags, uint16_t); DECL_BITFIELD(mMapCacheEntryFlags, uint16_t);
DECL_BITS(mMapCacheEntryFlags, PaletteId, 0, 4); DECL_BITS(mMapCacheEntryFlags, PaletteId, 0, 4);

View File

@ -117,14 +117,14 @@ static inline void _cleanTile(struct mMapCache* cache, const color_t* tile, colo
static inline size_t _tileId(struct mMapCache* cache, unsigned x, unsigned y) { static inline size_t _tileId(struct mMapCache* cache, unsigned x, unsigned y) {
int tilesWide = mMapCacheSystemInfoGetTilesWide(cache->sysConfig); int tilesWide = mMapCacheSystemInfoGetTilesWide(cache->sysConfig);
int tilesHigh = mMapCacheSystemInfoGetTilesHigh(cache->sysConfig); int tilesHigh = mMapCacheSystemInfoGetTilesHigh(cache->sysConfig);
int stride = tilesHigh < 5 ? (1 << tilesHigh) : 32; int stride = 1 << mMapCacheSystemInfoGetMacroTileSize(cache->sysConfig);
x &= (1 << tilesWide) - 1; x &= (1 << tilesWide) - 1;
y &= (1 << tilesHigh) - 1; y &= (1 << tilesHigh) - 1;
unsigned xMajor = x & ~0x1F; unsigned xMajor = x & ~(stride - 1);
unsigned yMajor = y >> 5; unsigned yMajor = y >> mMapCacheSystemInfoGetMacroTileSize(cache->sysConfig);
x &= 0x1F; x &= stride - 1;
y &= 0x1F; y &= stride - 1;
yMajor <<= tilesHigh; yMajor <<= tilesWide;
y += xMajor + yMajor; y += xMajor + yMajor;
return stride * y + x; return stride * y + x;
} }

View File

@ -117,11 +117,7 @@ void GBVideoCacheWriteVideoRegister(struct mCacheSet* cache, uint16_t address, u
} }
map->tileStart = tileStart; map->tileStart = tileStart;
window->tileStart = tileStart; window->tileStart = tileStart;
if (sysconfig) { sysconfig = mMapCacheSystemInfoSetMacroTileSize(sysconfig, 5);
sysconfig = mMapCacheSystemInfoSetMaxTiles(sysconfig, 896);
} else {
sysconfig = mMapCacheSystemInfoSetMaxTiles(sysconfig, 384);
}
sysconfig = mMapCacheSystemInfoSetPaletteBPP(sysconfig, 1); sysconfig = mMapCacheSystemInfoSetPaletteBPP(sysconfig, 1);
sysconfig = mMapCacheSystemInfoSetMapAlign(sysconfig, 0); sysconfig = mMapCacheSystemInfoSetMapAlign(sysconfig, 0);
sysconfig = mMapCacheSystemInfoSetTilesHigh(sysconfig, 5); sysconfig = mMapCacheSystemInfoSetTilesHigh(sysconfig, 5);

View File

@ -114,7 +114,7 @@ static void GBAVideoCacheWriteBGCNT(struct mCacheSet* cache, size_t bg, uint16_t
if (map->mapParser == mapParser0) { if (map->mapParser == mapParser0) {
sysconfig = mMapCacheSystemInfoSetPaletteBPP(sysconfig, 2 + p); sysconfig = mMapCacheSystemInfoSetPaletteBPP(sysconfig, 2 + p);
sysconfig = mMapCacheSystemInfoSetPaletteCount(sysconfig, 4 * !p); sysconfig = mMapCacheSystemInfoSetPaletteCount(sysconfig, 4 * !p);
sysconfig = mMapCacheSystemInfoSetMaxTiles(sysconfig, 1024); sysconfig = mMapCacheSystemInfoSetMacroTileSize(sysconfig, 5);
sysconfig = mMapCacheSystemInfoSetMapAlign(sysconfig, 1); sysconfig = mMapCacheSystemInfoSetMapAlign(sysconfig, 1);
tilesWide = 5; tilesWide = 5;
tilesHigh = 5; tilesHigh = 5;
@ -128,7 +128,7 @@ static void GBAVideoCacheWriteBGCNT(struct mCacheSet* cache, size_t bg, uint16_t
} else if (map->mapParser == mapParser2) { } else if (map->mapParser == mapParser2) {
sysconfig = mMapCacheSystemInfoSetPaletteBPP(sysconfig, 3); sysconfig = mMapCacheSystemInfoSetPaletteBPP(sysconfig, 3);
sysconfig = mMapCacheSystemInfoSetPaletteCount(sysconfig, 0); sysconfig = mMapCacheSystemInfoSetPaletteCount(sysconfig, 0);
sysconfig = mMapCacheSystemInfoSetMaxTiles(sysconfig, 256); sysconfig = mMapCacheSystemInfoSetMacroTileSize(sysconfig, 4 + size);
sysconfig = mMapCacheSystemInfoSetMapAlign(sysconfig, 0); sysconfig = mMapCacheSystemInfoSetMapAlign(sysconfig, 0);
tilesHigh = 4 + size; tilesHigh = 4 + size;