-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
34 lines (25 loc) · 941 Bytes
/
main.cpp
File metadata and controls
34 lines (25 loc) · 941 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
#include "core/Chip8.cpp"
#include "platform/Platform.cpp"
#include <iostream>
int main(int argc, char **argv) {
int vscale = std::stoi(argv[1]);
int cdelay = std::stoi(argv[2]);
char const* rom = argv[3];
Platform p("Chip-8", VIDEO_WIDTH * vscale, VIDEO_HEIGHT * vscale, VIDEO_WIDTH, VIDEO_HEIGHT);
Chip8 chip;
chip.LoadROM(rom);
int videopitch = sizeof(chip.display[0]) * VIDEO_WIDTH;
auto lastCycleTime = std::chrono::high_resolution_clock::now();
bool quit = false;
while(!quit) {
quit = p.process_input(chip.keys);
auto currentTime = std::chrono::high_resolution_clock::now();
float dt = std::chrono::duration<float, std::chrono::milliseconds::period>(currentTime - lastCycleTime).count();
if (dt > cdelay) {
lastCycleTime = currentTime;
chip.Cycle();
p.update(chip.display, videopitch);
}
}
return 0;
}