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 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
53struct GBAVideoSoftwareRenderer {
54 struct GBAVideoRenderer d;
55
56 uint32_t* outputBuffer;
57 unsigned outputBufferStride;
58
59 union GBARegisterDISPCNT dispcnt;
60
61 // BLDCNT
62 unsigned target1Obj;
63 unsigned target1Bd;
64 unsigned target2Obj;
65 unsigned target2Bd;
66 enum BlendEffect blendEffect;
67 uint32_t normalPalette[512];
68 uint32_t variantPalette[512];
69
70 uint16_t blda;
71 uint16_t bldb;
72 uint16_t bldy;
73
74 struct GBAVideoSoftwareBackground bg[4];
75
76 uint32_t* row;
77 int start;
78 int end;
79
80 pthread_mutex_t mutex;
81 pthread_cond_t upCond;
82 pthread_cond_t downCond;
83};
84
85void GBAVideoSoftwareRendererCreate(struct GBAVideoSoftwareRenderer* renderer);
86
87#endif