From c6168861176af2a79df5b6405c540a245591c1e6 Mon Sep 17 00:00:00 2001 From: Bill Lord Date: Sat, 20 Jan 2018 23:23:07 -0600 Subject: [PATCH] input: fix a couple bugs with halt-until-next-input --- src/main.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 48ab810..706027d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,19 +46,22 @@ int main(int argc, char* argv[]) { for (int i = 0; i < NUMBER_OF_KEYS; i++) { if (event.key.code == KEYMAP[i]) { cpu.keyInput(i); + break; } } } } } - if (cpu.state.running) { - if (delayTimer.getElapsedTime().asSeconds() > TIMER_FREQUENCY) { + if (delayTimer.getElapsedTime().asSeconds() > TIMER_FREQUENCY) { + if (cpu.state.running) { cpu.tickTimers(); - display.draw(cpu.state.vram); - delayTimer.restart(); } + display.draw(cpu.state.vram); + delayTimer.restart(); + } + if (cpu.state.running) { if (cpuTimer.getElapsedTime().asSeconds() > CPU_FREQUENCY) { try { for (int i = 0; i < NUMBER_OF_KEYS; i++) {