summaryrefslogtreecommitdiff
path: root/nandgame/cpp
diff options
context:
space:
mode:
authoruvok2026-01-11 15:07:40 +0100
committeruvok2026-01-11 15:07:40 +0100
commitb66c7c78a9917235f29612b584fbf7f6726d90ea (patch)
tree3bc7cb1d095c66cf6ced58ac134a3ad6f03258c7 /nandgame/cpp
parentdb879929161a7714fdd779fcd2e0d9a114ad40cf (diff)
Start adding/using windows
Diffstat (limited to 'nandgame/cpp')
-rw-r--r--nandgame/cpp/simpc_ui.cpp43
1 files changed, 34 insertions, 9 deletions
diff --git a/nandgame/cpp/simpc_ui.cpp b/nandgame/cpp/simpc_ui.cpp
index 1ee22f0..5b7591e 100644
--- a/nandgame/cpp/simpc_ui.cpp
+++ b/nandgame/cpp/simpc_ui.cpp
@@ -11,12 +11,19 @@
#define PRINT_ME(y, x, ...) \
{ mvprintw(y, x, __VA_ARGS__); }
+#define PRINT_ME_W(w, y, x, ...) \
+ { mvwprintw(w, y, x, __VA_ARGS__); }
#define PRINT_NEXT() \
{ \
refresh(); \
napms(NCUR_DELAY_MS); \
}
+#define SIMPLE_BORDER(w, lr, tb, c) \
+ { wborder(w, lr, lr, tb, tb, c, c, c, c); }
+
+static WINDOW *status_top = NULL;
+
#else
#define attroff(...)
@@ -50,9 +57,11 @@ void simpc_ui_write(const std::unique_ptr<Vcomputer> &topp, uint64_t &i,
StepPosition_t sp) {
uint16_t opcode = topp->computer->PC_content_int;
- PRINT_ME(1, 1, "Step: %10lu \b%c", i,
- sp == StepPosition_t::BEFORE_EVAL ? 'A' : 'B');
- PRINT_ME(2, 1, "%-20s", paused ? "Paused" : "Running");
+ PRINT_ME_W(status_top, 0, 0, "Step: %10lu \b%c", i,
+ sp == StepPosition_t::BEFORE_EVAL ? 'A' : 'B');
+ PRINT_ME_W(status_top, 1, 0, "%-20s", paused ? "Paused" : "Running");
+ wrefresh(status_top);
+
PRINT_ME(3, NCUR_X, "CLK1: %4d\tPC: @0x%04X\tINS: 0x%04X\tHLT: %d",
topp->clk_in,
// wrong
@@ -130,7 +139,8 @@ void simpc_ui_write(const std::unique_ptr<Vcomputer> &topp, uint64_t &i,
void simpc_ui_finish_message(const std::unique_ptr<VerilatedContext> &contextp,
const std::unique_ptr<Vcomputer> &topp) {
attron(A_BOLD);
- PRINT_ME(1, 30, "Simulation finished.");
+ auto xpos = 20;
+ PRINT_ME_W(status_top, 0, xpos, "Simulation finished.");
const char *msg;
if (topp->halt) {
msg = "Halt encountered.";
@@ -139,25 +149,36 @@ void simpc_ui_finish_message(const std::unique_ptr<VerilatedContext> &contextp,
} else {
msg = "Regular finish.";
}
- PRINT_ME(2, 30, "%s", msg);
+ PRINT_ME_W(status_top, 1, xpos, "%s", msg);
#if NCUR
refresh();
+ wrefresh(status_top);
#endif
attroff(A_BOLD);
}
-#define SIMPLE_BORDER(w, lr, tb, c) \
- { wborder(w, lr, lr, tb, tb, c, c, c, c); }
-
void simpc_ui_init(void) {
#if NCUR
initscr();
curs_set(0);
+
+ // lines, cols, ypos, xpos
+ status_top = newwin(2, 50, 1, 1);
+ // SIMPLE_BORDER(status_top, '!', '~', 'X');
+ wrefresh(status_top);
+
+ int rc;
+
+ rc = wresize(stdscr, getmaxy(stdscr) - 3, getmaxx(stdscr));
+ assert(rc == 0);
+ rc = mvwin(stdscr, 3, 0);
+ assert(rc == 0);
+
+ SIMPLE_BORDER(stdscr, '|', '-', '+');
nodelay(stdscr, TRUE);
noecho();
cbreak();
- SIMPLE_BORDER(stdscr, '|', '-', '+');
#endif
}
@@ -165,6 +186,10 @@ void simpc_ui_cleanup(void) {
#if NCUR
nocbreak();
echo();
+
+ if (status_top) {
+ delwin(status_top);
+ }
endwin();
#endif
}