-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmuGfx.h
82 lines (57 loc) · 1.32 KB
/
EmuGfx.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
/**
* @brief CHIP8 EMULATOR PROJECT
* @Author esantiago
* @date May, 2018
*
* @description: Header file for chip8 graphics utilizing SDL2 framework
*/
#ifndef EMUGFX_H_
#define EMUGFX_H_
class EmuGfx{
public:
EmuGfx();
~EmuGfx();
// starts up SDL and creates window
bool init();
// update screen if draw flag is set
void drawGfx(Chip8 &myChip8);
// frees media and quits SDL
void close();
// keypad keymap
unsigned char keymap[16] =
{
SDLK_x, // 0
SDLK_1, // 1
SDLK_2, // 2
SDLK_3, // 3
SDLK_q, // 4
SDLK_w, // 5
SDLK_e, // 6
SDLK_a, // 7
SDLK_s, // 8
SDLK_d, // 9
SDLK_z, // A
SDLK_c, // B
SDLK_4, // C
SDLK_r, // D
SDLK_f, // E
SDLK_v, // F
};
// create audio object
Mix_Music *bgMusic;
private:
// the window we'll be rendering to
SDL_Window *gfxWindow;
// create renderer for window
SDL_Renderer *gfxRenderer;
// create a texture for a rendering context
SDL_Texture *gfxTexture;
// screen dimensions constants
const int SCREEN_WIDTH;
const int SCREEN_HEIGHT;
// temporary pixel buffer
uint32_t gfxPixels[2048];
// timeout used to slowdown emulation speed
uint32_t timeout;
};
#endif // EMUGFX_H_