all repos — mgba @ c8b2d2753e185dd4e8d8309a0d93b1064d1a31f2

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	struct PixelFlags flags[VIDEO_HORIZONTAL_PIXELS];
57
58	// BLDCNT
59	unsigned target1Obj;
60	unsigned target1Bd;
61	unsigned target2Obj;
62	unsigned target2Bd;
63	enum BlendEffect blendEffect;
64	uint16_t variantPalette[512];
65
66	uint16_t blda;
67	uint16_t bldb;
68	uint16_t bldy;
69
70	struct GBAVideoSoftwareBackground bg[4];
71	struct GBAVideoSoftwareBackground* sortedBg[4];
72
73	uint16_t* row;
74
75	pthread_mutex_t mutex;
76	pthread_cond_t upCond;
77	pthread_cond_t downCond;
78};
79
80void GBAVideoSoftwareRendererCreate(struct GBAVideoSoftwareRenderer* renderer);
81
82#endif