summaryrefslogtreecommitdiff
path: root/nandgame/cpp/simpc_ui.cpp
diff options
context:
space:
mode:
authoruvok2026-01-11 11:17:13 +0100
committeruvok2026-01-11 11:17:13 +0100
commit4d78cf157bd14755bcc39520d523a6d21a56966a (patch)
tree71b0b5c510946f560ab8eee9c3a2ec55daf915d1 /nandgame/cpp/simpc_ui.cpp
parent68b1ea87aa8d2bb7be4706f9888944978013ae57 (diff)
Add paused state, print help
fix separate "wait for feedback"
Diffstat (limited to 'nandgame/cpp/simpc_ui.cpp')
-rw-r--r--nandgame/cpp/simpc_ui.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/nandgame/cpp/simpc_ui.cpp b/nandgame/cpp/simpc_ui.cpp
index 44d3424..e3435bc 100644
--- a/nandgame/cpp/simpc_ui.cpp
+++ b/nandgame/cpp/simpc_ui.cpp
@@ -42,12 +42,15 @@
#include <cstdio>
#include <sched.h>
+bool paused = false;
+
void simpc_ui_write(const std::unique_ptr<Vcomputer> &topp, int &i,
- StepPosition_t sp) {
+ StepPosition_t sp) {
uint16_t opcode = topp->computer->PC_content_int;
PRINT_ME(1, 1, "Step: %10d \b%c", i,
sp == StepPosition_t::BEFORE_EVAL ? 'A' : 'B');
+ PRINT_ME(2, 1, "%-20s", paused ? "Paused" : "Running");
PRINT_ME(1 + NCUR_OFFSET, NCUR_X,
"CLK1: %4d\tPC: @0x%04X\tINS: 0x%04X\tHLT: %d", topp->clk_in,
// wrong
@@ -72,13 +75,24 @@ void simpc_ui_write(const std::unique_ptr<Vcomputer> &topp, int &i,
PRINT_ME(7 + NCUR_OFFSET, NCUR_X, "ALU");
PRINT_ME(8 + NCUR_OFFSET, NCUR_X, "X: %5" PRId16 "\tY: %5" PRId16,
topp->computer->CPU->my_alu->int_op_x,
- topp->computer->CPU->my_alu->int_op_y)
+ topp->computer->CPU->my_alu->int_op_y);
+ PRINT_ME(getmaxy(stdscr) - 1, 1, "q - Quit; p - (Un)pause; any key in pause - step");
+
PRINT_NEXT();
+
+ int ch = getch();
+ if (ch == 'p') {
+ nodelay(stdscr, paused);
+ paused = !paused;
+ } else if (ch == 'q') {
+ simpc_ui_cleanup();
+ exit(0);
+ }
}
void simpc_ui_finish_message(const std::unique_ptr<VerilatedContext> &contextp,
- const std::unique_ptr<Vcomputer> &topp) {
+ const std::unique_ptr<Vcomputer> &topp) {
#if NCUR
refresh();
#endif
@@ -96,12 +110,20 @@ void simpc_ui_init(void) {
#if NCUR
initscr();
curs_set(0);
+ nodelay(stdscr, TRUE);
+ noecho();
#endif
}
void simpc_ui_cleanup(void) {
#if NCUR
- getch();
endwin();
#endif
}
+
+void simpc_ui_confirm_finish(void) {
+#if NCUR
+ nodelay(stdscr, FALSE);
+ getch();
+#endif
+} \ No newline at end of file