all repos — mgba @ 27f5468e01d4361705a1dd0615c195e138e17710

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	int32_t refx;
 23	int32_t refy;
 24	int16_t dx;
 25	int16_t dmx;
 26	int16_t dy;
 27	int16_t dmy;
 28	int32_t sx;
 29	int32_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	OFFSET_PRIORITY = 29
 42};
 43
 44enum PixelFlags {
 45	FLAG_FINALIZED = 0x80000000,
 46	FLAG_PRIORITY = 0x60000000,
 47	FLAG_IS_BACKGROUND = 0x10000000,
 48	FLAG_UNWRITTEN = 0x08000000,
 49	FLAG_TARGET_1 = 0x04000000,
 50	FLAG_TARGET_2 = 0x02000000
 51};
 52
 53union Window {
 54	struct {
 55		uint8_t end;
 56		uint8_t start;
 57	};
 58	uint16_t packed;
 59};
 60
 61union WindowControl {
 62	struct {
 63		unsigned bg0EnableLo : 1;
 64		unsigned bg1EnableLo : 1;
 65		unsigned bg2EnableLo : 1;
 66		unsigned bg3EnableLo : 1;
 67		unsigned objEnableLo : 1;
 68		unsigned blendEnableLo : 1;
 69		unsigned : 2;
 70		unsigned bg0EnableHi : 1;
 71		unsigned bg1EnableHi : 1;
 72		unsigned bg2EnableHi : 1;
 73		unsigned bg3EnableHi : 1;
 74		unsigned objEnableHi : 1;
 75		unsigned blendEnableHi : 1;
 76		unsigned : 2;
 77	};
 78	uint16_t packed;
 79};
 80
 81struct GBAVideoSoftwareRenderer {
 82	struct GBAVideoRenderer d;
 83
 84	uint32_t* outputBuffer;
 85	unsigned outputBufferStride;
 86
 87	union GBARegisterDISPCNT dispcnt;
 88
 89	uint32_t spriteLayer[VIDEO_HORIZONTAL_PIXELS];
 90
 91	// BLDCNT
 92	unsigned target1Obj;
 93	unsigned target1Bd;
 94	unsigned target2Obj;
 95	unsigned target2Bd;
 96	enum BlendEffect blendEffect;
 97	uint32_t normalPalette[512];
 98	uint32_t variantPalette[512];
 99
100	uint16_t blda;
101	uint16_t bldb;
102	uint16_t bldy;
103
104	union Window win0H;
105	union Window win0V;
106	union Window win1H;
107	union Window win1V;
108
109	union WindowControl winin;
110	union WindowControl winout;
111
112	struct GBAVideoSoftwareBackground bg[4];
113
114	uint32_t* row;
115	int start;
116	int end;
117
118	uint32_t enabledBitmap[4];
119
120	pthread_mutex_t mutex;
121	pthread_cond_t upCond;
122	pthread_cond_t downCond;
123};
124
125void GBAVideoSoftwareRendererCreate(struct GBAVideoSoftwareRenderer* renderer);
126
127#endif