-
Notifications
You must be signed in to change notification settings - Fork 0
/
Graphics.h
61 lines (48 loc) · 1.07 KB
/
Graphics.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
#pragma once
#include "Types.h"
#include <iomanip>
#include <functional>
#define CYCLES_PER_SCANLINE 456
#define LCDC 0xFF40
#define STAT 0xFF41
#define SCROLL_Y 0xFF42
#define SCROLL_X 0xFF43
#define LY 0xFF44
#define LYC 0xFF45
#define WINDOW_Y 0xFF4A
#define WINDOW_X 0xFF4B
#define BGPI 0xFF68
#define BGPD 0xFF69
#define OBPI 0xFF6A
#define OBPD 0xFF6B
class Memory;
class CPU;
class GB;
class Serializer;
class Graphics {
private:
int currentCycles;
byte* display;
Memory &MMU;
CPU &Cpu;
GB *gb;
bool STATInterrupt = false;
std::function<void(void)> vBlankCallback;
public:
Graphics(GB *gb, Memory &MMU, CPU &Cpu);
~Graphics();
void Update(int cycles);
byte* GetDisplayPixels();
void SetVblankCallback(std::function<void(void)> cb);
void Reset();
void Serialize(Serializer & s);
void Deserialize(Serializer & s);
private:
bool LCDEnabled();
void SetMode(int mode);
void DrawScanline();
void DrawBackgroundTiles();
void DrawWindowTiles();
void DrawSprites();
Color GetColor(int colorId, byte bgAttrs, bool isObj, byte objAttrs);
};