optimized display update region
This commit is contained in:
10
main.cpp
10
main.cpp
@@ -25,7 +25,7 @@ int main(int argc, char* argv[]) {
|
||||
BuzzerSDL buzzer(440);
|
||||
DisplaySDL display(1280, 640);
|
||||
TestKeypad keypad;
|
||||
chocochip8::Interpreter chip8(90, display, buzzer, keypad);
|
||||
chocochip8::Interpreter chip8(1000, display, buzzer, keypad);
|
||||
|
||||
auto rom = std::vector<char>();
|
||||
auto romfile = std::ifstream(argv[1] != NULL ? argv[1] : "/dev/stdin", std::ios_base::in | std::ios_base::binary);
|
||||
@@ -38,6 +38,8 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
SDL_Event event;
|
||||
bool done = false;
|
||||
Uint64 start, end;
|
||||
start = SDL_GetTicks64();
|
||||
while(!done) {
|
||||
while(SDL_PollEvent(&event)) {
|
||||
if(event.type == SDL_QUIT) {
|
||||
@@ -46,7 +48,11 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
chip8.tick();
|
||||
display.updateWindow();
|
||||
SDL_Delay(1000.0 / 60);
|
||||
SDL_Delay(1);
|
||||
end = SDL_GetTicks64();
|
||||
if(end - start > 3)
|
||||
std::cout << "Frame took too long: " << end - start << "\n";
|
||||
start = end;
|
||||
}
|
||||
|
||||
buzzer.off();
|
||||
|
||||
Reference in New Issue
Block a user