-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (30 loc) · 766 Bytes
/
main.cpp
File metadata and controls
36 lines (30 loc) · 766 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
#include <iostream>
#include <fstream>
#include <vector>
#include <thread>
#include "C8.h"
#include "Display.h"
auto read_binary_file(char *path) {
std::ifstream input(path, std::ios::binary);
std::vector<unsigned char> buffer(std::istreambuf_iterator<char>(input), {});
return buffer;
}
int main(int argc, char **argv) {
if (argc <= 1) {
std::cout << "Usage: Chip8 <rom path>\n";
return 1;
}
C8 c8(read_binary_file(argv[1]));
Display display;
while (true) {
display.update(c8);
c8.execute_instruction();
auto key = Display::handleInput(c8);
if (key == 'q'){
break;
}
using namespace std;
std::this_thread::sleep_for(1ms);
}
return 0;
}