-
Notifications
You must be signed in to change notification settings - Fork 0
/
chip8.hpp
65 lines (47 loc) · 1.24 KB
/
chip8.hpp
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
#include <map>
#include <stack>
#include <random>
#include <fstream>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <unistd.h>
#include <SDL2/SDL.h>
#include "constants.hpp"
class CHIP8
{
public:
uint8_t ram[MEMORY_SIZE]; // memory
std::stack<uint8_t*> stack;
uint8_t delayTimer;
uint8_t soundTimer;
uint8_t* pc; // program counter: current instruction
uint8_t* I; // index register: memory locations
uint8_t vars[NUM_VARS]; // variable registers (V0 - VF)
// Create window and renderer
SDL_Window* window;
SDL_Renderer* renderer;
// Main loop flag
bool running;
// Event handler
SDL_Event event;
// Keyboard status
SDL_Scancode scancode;
bool keyDown;
uint8_t keyHex;
// Keyboard mapping
std::map<SDL_Scancode, uint8_t> keyMap;
CHIP8();
void setupFont();
void readRom();
void setupGUI();
void cycle();
void handleEvents();
void instruction8XYN(uint8_t X, uint8_t Y, uint8_t N);
void instructionDXYN(uint8_t X, uint8_t Y, uint8_t N);
void instructionCXNN(uint8_t X, uint8_t NN);
void instructionFX(uint8_t right, uint8_t X);
void frameCleanup();
void fullCleanup();
bool isRunning();
};