all repos — mgba @ dfd360bfbb9355f13f2cc896f5da9a26f5094033

mGBA Game Boy Advance Emulator

src/gba/renderers/video-software.h (view raw)

 1#ifndef VIDEO_SOFTWARE_H
 2#define VIDEO_SOFTWARE_H
 3
 4#include "gba-video.h"
 5
 6#include <pthread.h>
 7
 8struct GBAVideoSoftwareBackground {
 9	int index;
10	int enabled;
11	int priority;
12	uint32_t charBase;
13	int mosaic;
14	int multipalette;
15	uint32_t screenBase;
16	int overflow;
17	int size;
18	int target1;
19	int target2;
20	uint16_t x;
21	uint16_t y;
22	uint32_t refx;
23	uint32_t refy;
24	uint16_t dx;
25	uint16_t dmx;
26	uint16_t dy;
27	uint16_t dmy;
28	uint32_t sx;
29	uint32_t sy;
30};
31
32enum BlendEffect {
33	BLEND_NONE = 0,
34	BLEND_ALPHA = 1,
35	BLEND_BRIGHTEN = 2,
36	BLEND_DARKEN = 3
37};
38
39struct PixelFlags {
40	unsigned priority : 2;
41	unsigned isSprite : 1;
42	unsigned written : 1;
43	unsigned finalized : 1;
44	unsigned target1 : 1;
45	unsigned target2 : 1;
46};
47
48struct GBAVideoSoftwareRenderer {
49	struct GBAVideoRenderer d;
50
51	uint16_t* outputBuffer;
52	unsigned outputBufferStride;
53
54	union GBARegisterDISPCNT dispcnt;
55
56	uint16_t spriteLayer[VIDEO_HORIZONTAL_PIXELS];
57	struct PixelFlags flags[VIDEO_HORIZONTAL_PIXELS];
58
59	// BLDCNT
60	unsigned target1Obj;
61	unsigned target1Bd;
62	unsigned target2Obj;
63	unsigned target2Bd;
64	enum BlendEffect blendEffect;
65	uint16_t variantPalette[512];
66
67	uint16_t blda;
68	uint16_t bldb;
69	uint16_t bldy;
70
71	struct GBAVideoSoftwareBackground bg[4];
72	struct GBAVideoSoftwareBackground* sortedBg[4];
73
74	uint16_t* row;
75
76	pthread_mutex_t mutex;
77	pthread_cond_t upCond;
78	pthread_cond_t downCond;
79};
80
81void GBAVideoSoftwareRendererCreate(struct GBAVideoSoftwareRenderer* renderer);
82
83#endif