all repos — mgba @ 6c2f7b3b731e672c0df42b9ffd6fefdd316c729d

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
39enum {
40	GBA_COLOR_WHITE = 0x00F8F8F8
41};
42
43struct PixelFlags {
44	unsigned priority : 2;
45	unsigned isSprite : 1;
46	unsigned written : 1;
47	unsigned finalized : 1;
48	unsigned target1 : 1;
49	unsigned target2 : 1;
50};
51
52struct GBAVideoSoftwareRenderer {
53	struct GBAVideoRenderer d;
54
55	uint32_t* outputBuffer;
56	unsigned outputBufferStride;
57
58	union GBARegisterDISPCNT dispcnt;
59
60	uint32_t spriteLayer[VIDEO_HORIZONTAL_PIXELS];
61	struct PixelFlags flags[VIDEO_HORIZONTAL_PIXELS];
62
63	// BLDCNT
64	unsigned target1Obj;
65	unsigned target1Bd;
66	unsigned target2Obj;
67	unsigned target2Bd;
68	enum BlendEffect blendEffect;
69	uint32_t normalPalette[512];
70	uint32_t variantPalette[512];
71
72	uint16_t blda;
73	uint16_t bldb;
74	uint16_t bldy;
75
76	struct GBAVideoSoftwareBackground bg[4];
77	struct GBAVideoSoftwareBackground* sortedBg[4];
78
79	uint32_t* row;
80	int start;
81	int end;
82
83	pthread_mutex_t mutex;
84	pthread_cond_t upCond;
85	pthread_cond_t downCond;
86};
87
88void GBAVideoSoftwareRendererCreate(struct GBAVideoSoftwareRenderer* renderer);
89
90#endif