all repos — mgba @ f6755a6e1b7b0cf2b944cd8ca842746f11d6bf82

mGBA Game Boy Advance Emulator

include/mgba/core/bitmap-cache.h (view raw)

 1/* Copyright (c) 2013-2019 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#ifndef M_BITMAP_CACHE_H
 7#define M_BITMAP_CACHE_H
 8
 9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#include <mgba/core/interface.h>
14
15DECL_BITFIELD(mBitmapCacheConfiguration, uint32_t);
16DECL_BIT(mBitmapCacheConfiguration, ShouldStore, 0);
17
18DECL_BITFIELD(mBitmapCacheSystemInfo, uint32_t);
19DECL_BITS(mBitmapCacheSystemInfo, EntryBPP, 0, 3);
20DECL_BIT(mBitmapCacheSystemInfo, UsesPalette, 3);
21DECL_BITS(mBitmapCacheSystemInfo, Width, 4, 10);
22DECL_BITS(mBitmapCacheSystemInfo, Height, 14, 10);
23DECL_BITS(mBitmapCacheSystemInfo, Buffers, 24, 2);
24
25struct mBitmapCacheEntry {
26	uint32_t paletteVersion;
27	uint32_t vramVersion;
28	uint8_t vramClean;
29};
30
31struct mBitmapCache {
32	color_t* cache;
33	struct mBitmapCacheEntry* status;
34
35	uint32_t globalPaletteVersion;
36
37	uint8_t* vram;
38	color_t* palette;
39
40	uint32_t bitsSize;
41	uint32_t bitsStart[2];
42	uint32_t stride;
43	uint8_t buffer;
44
45	mBitmapCacheConfiguration config;
46	mBitmapCacheSystemInfo sysConfig;
47
48	void* context;
49};
50
51void mBitmapCacheInit(struct mBitmapCache* cache);
52void mBitmapCacheDeinit(struct mBitmapCache* cache);
53void mBitmapCacheConfigure(struct mBitmapCache* cache, mBitmapCacheConfiguration config);
54void mBitmapCacheConfigureSystem(struct mBitmapCache* cache, mBitmapCacheSystemInfo config);
55void mBitmapCacheWriteVRAM(struct mBitmapCache* cache, uint32_t address);
56void mBitmapCacheWritePalette(struct mBitmapCache* cache, uint32_t entry, color_t color);
57
58void mBitmapCacheCleanRow(struct mBitmapCache* cache, struct mBitmapCacheEntry* entry, unsigned y);
59bool mBitmapCacheCheckRow(struct mBitmapCache* cache, const struct mBitmapCacheEntry* entry, unsigned y);
60const color_t* mBitmapCacheGetRow(struct mBitmapCache* cache, unsigned y);
61
62CXX_GUARD_END
63
64#endif