-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgpu_2d.h
112 lines (91 loc) · 3.76 KB
/
gpu_2d.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
Copyright 2019-2020 Hydr8gon
This file is part of NooDS.
NooDS is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
NooDS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with NooDS. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef GPU_2D_H
#define GPU_2D_H
#include <cstdint>
class Core;
class Gpu2D
{
public:
Gpu2D(Core *core, bool engine);
void drawGbaScanline(int line);
void drawScanline(int line);
void finishScanline(int line);
uint16_t *getFramebuffer(int line) { return &framebuffer[256 * line]; }
uint32_t readDispCnt() { return dispCnt; }
uint16_t readBgCnt(int bg) { return bgCnt[bg]; }
uint16_t readWinIn() { return winIn; }
uint16_t readWinOut() { return winOut; }
uint16_t readBldCnt() { return bldCnt; }
uint16_t readBldAlpha() { return bldAlpha; }
uint16_t readMasterBright() { return masterBright; }
void writeDispCnt(uint32_t mask, uint32_t value);
void writeBgCnt(int bg, uint16_t mask, uint16_t value);
void writeBgHOfs(int bg, uint16_t mask, uint16_t value);
void writeBgVOfs(int bg, uint16_t mask, uint16_t value);
void writeBgPA(int bg, uint16_t mask, uint16_t value);
void writeBgPB(int bg, uint16_t mask, uint16_t value);
void writeBgPC(int bg, uint16_t mask, uint16_t value);
void writeBgPD(int bg, uint16_t mask, uint16_t value);
void writeBgX(int bg, uint32_t mask, uint32_t value);
void writeBgY(int bg, uint32_t mask, uint32_t value);
void writeWinH(int win, uint16_t mask, uint16_t value);
void writeWinV(int win, uint16_t mask, uint16_t value);
void writeWinIn(uint16_t mask, uint16_t value);
void writeWinOut(uint16_t mask, uint16_t value);
void writeBldCnt(uint16_t mask, uint16_t value);
void writeBldAlpha(uint16_t mask, uint16_t value);
void writeBldY(uint8_t value);
void writeMasterBright(uint16_t mask, uint16_t value);
private:
Core *core;
bool engine;
uint32_t bgVramAddr, objVramAddr;
uint8_t *palette, *oam;
uint8_t **extPalettes;
__attribute__((aligned(16))) uint16_t framebuffer[256 * 192 * 2] = {};
uint32_t layers[5][256] = {};
uint8_t objPrio[256] = {};
int gbaBlock = 0;
int internalX[2] = {};
int internalY[2] = {};
uint32_t dispCnt = 0;
uint16_t bgCnt[4] = {};
uint16_t bgHOfs[4] = {};
uint16_t bgVOfs[4] = {};
int16_t bgPA[2] = {};
int16_t bgPB[2] = {};
int16_t bgPC[2] = {};
int16_t bgPD[2] = {};
int32_t bgX[2] = {};
int32_t bgY[2] = {};
uint16_t winX1[2] = {};
uint16_t winX2[2] = {};
uint16_t winY1[2] = {};
uint16_t winY2[2] = {};
uint16_t winIn = 0;
uint16_t winOut = 0;
uint16_t bldCnt = 0;
uint16_t bldAlpha = 0;
uint8_t bldY = 0;
uint16_t masterBright = 0;
uint32_t rgb5ToRgb6(uint32_t color);
void drawText(int bg, int line);
void drawAffine(int bg, int line);
void drawExtended(int bg, int line);
void drawLarge(int bg, int line);
void drawObjects(int line);
};
#endif // GPU_2D_H