all repos — mgba @ df9616c15c58454332c0dfb7f2b37e0098f518b9

mGBA Game Boy Advance Emulator

src/gb/renderers/cache-set.c (view raw)

 1/* Copyright (c) 2013-2017 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#include <mgba/internal/gb/renderers/cache-set.h>
 7
 8#include <mgba/core/cache-set.h>
 9#include <mgba/internal/gb/video.h>
10
11void GBVideoCacheInit(struct mCacheSet* cache) {
12	mCacheSetInit(cache, 0, 1);
13	mTileCacheConfiguration config = 0;
14	config = mTileCacheSystemInfoSetPaletteBPP(config, 1); // 2^(2^1) = 4 entries
15	config = mTileCacheSystemInfoSetPaletteCount(config, 4); // 16 palettes
16	config = mTileCacheSystemInfoSetMaxTiles(config, 1024);
17	mTileCacheInit(mTileCacheSetGetPointer(&cache->tiles, 0));
18	mTileCacheConfigureSystem(mTileCacheSetGetPointer(&cache->tiles, 0), config, 0, 0);
19}
20
21void GBVideoCacheAssociate(struct mCacheSet* cache, struct GBVideo* video) {
22	mCacheSetAssignVRAM(cache, video->vram);
23	video->renderer->cache = cache;
24	size_t i;
25	for (i = 0; i < 64; ++i) {
26		mCacheSetWritePalette(cache, i, mColorFrom555(video->palette[i]));
27	}
28}