From e5dd0105afc23321dce96e2ca92ae492a10cf862 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Tue, 12 Apr 2022 21:02:02 +0200 Subject: [PATCH] flag handling --- console.cpp | 5 ++++- debugger.cpp | 2 +- main.cpp | 8 +++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/console.cpp b/console.cpp index c176c48..07e63bf 100644 --- a/console.cpp +++ b/console.cpp @@ -98,6 +98,9 @@ std::string console::read_line(const std::string & prompt) for(;;) { char c = wait_char(500); + if (*terminate || stop_thread_flag) + return ""; + if (c == -1) continue; @@ -193,7 +196,7 @@ void console::operator()() continue; if (c == 3) // ^c - *terminate = true; + *interrupt_emulation = *terminate = true; else if (c == 5) // ^e *interrupt_emulation = true; else if (c == 12) // ^l diff --git a/debugger.cpp b/debugger.cpp index 0f2fdad..3505b30 100644 --- a/debugger.cpp +++ b/debugger.cpp @@ -170,7 +170,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_bool *const interru c->emulation_start(); - while(!event && !terminate && !*interrupt_emulation) { + while(!event && !*interrupt_emulation) { if (tracing || single_step) disassemble(c, single_step ? cnsl : nullptr, c->getPC(), false); diff --git a/main.cpp b/main.cpp index 1a719c9..ba1610e 100644 --- a/main.cpp +++ b/main.cpp @@ -274,8 +274,14 @@ int main(int argc, char *argv[]) else { c->emulation_start(); // for statistics - while(!event && !terminate) + while(!event) { + if (interrupt_emulation) { + if (terminate) + break; + } + c->step(); + } } *running = false;