-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpu.hpp
More file actions
50 lines (36 loc) · 853 Bytes
/
gpu.hpp
File metadata and controls
50 lines (36 loc) · 853 Bytes
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
// gb: a Gameboy Emulator by Don Freiday
// File: gpu.hpp
// Description: Emulates the PPU and LCD
//
// Graphics are rendered using the Simple DirectMedia Layer library (SDL 2.0)
#ifndef GB_GPU
#define GB_GPU
#include <SDL2/SDL.h>
#include <SDL2/SDL_opengl.h>
#include "common.hpp"
#include "mmu.hpp"
#include "imgui/imgui.h"
class GPU {
public:
GPU();
~GPU();
void reset();
void step(u8 cycles); // clock step
MMU* mmu;
int modeclock;
int mode;
u8 scanline;
int width;
int height;
bool vsync;
u8 screenData[144][160][3];
private:
void renderScanline(); // write scanline to surface
void renderBackground();
void renderSprites();
void renderScreen();
enum COLOR { WHITE, LIGHT_GRAY, DARK_GRAY, BLACK };
COLOR paletteLookup(u8 colorID, u16 address);
void requestInterrupt(u8 interrupt);
};
#endif