summaryrefslogtreecommitdiff
path: root/nandgame/cpp
diff options
context:
space:
mode:
authoruvok2026-01-11 15:33:44 +0100
committeruvok2026-01-11 15:33:44 +0100
commit95d3f6db0bf4e46f8bc9799548681fe7890225e9 (patch)
treeebd38eefadfba5efc59a8ce93fdafb0460aa9c92 /nandgame/cpp
parent3b380d790d29f91da83338b642566a3476fa6f51 (diff)
Add window for clk/regs
Diffstat (limited to 'nandgame/cpp')
-rw-r--r--nandgame/cpp/simpc_ui.cpp62
1 files changed, 34 insertions, 28 deletions
diff --git a/nandgame/cpp/simpc_ui.cpp b/nandgame/cpp/simpc_ui.cpp
index 53e9b06..4bfc93b 100644
--- a/nandgame/cpp/simpc_ui.cpp
+++ b/nandgame/cpp/simpc_ui.cpp
@@ -12,17 +12,21 @@
{ mvprintw(y, x, __VA_ARGS__); }
#define PRINT_ME_W(w, y, x, ...) \
{ mvwprintw(w, y, x, __VA_ARGS__); }
-#define PRINT_NEXT() \
+#define PRINT_NEXT(dly) \
{ \
refresh(); \
- napms(NCUR_DELAY_MS); \
+ if (dly) { \
+ napms(NCUR_DELAY_MS); \
+ } \
wrefresh(status_top); \
+ wrefresh(clock_regs); \
}
#define SIMPLE_BORDER(w, lr, tb, c) \
{ wborder(w, lr, lr, tb, tb, c, c, c, c); }
static WINDOW *status_top = NULL;
+static WINDOW *clock_regs = NULL;
#include "Vcomputer.h"
#include "Vcomputer___024root.h"
@@ -42,24 +46,22 @@ 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_W(status_top, 0, 0, "Step: %10lu \b%c", i,
+ PRINT_ME_W(status_top, 1, 1, "Step: %10lu \b%c", i,
sp == StepPosition_t::BEFORE_EVAL ? 'A' : 'B');
- PRINT_ME_W(status_top, 1, 0, "%-20s", paused ? "Paused" : "Running");
-
- PRINT_ME(3, NCUR_X, "CLK1: %4d\tPC: @0x%04X\tINS: 0x%04X\tHLT: %d",
- topp->clk_in,
- // wrong
- // topp->computer->clk_in,
- topp->computer->PC_addr_int, opcode, topp->halt);
-
- auto insline = print_decoded(opcode, true);
- PRINT_ME(5, NCUR_X, "%-80s", insline.c_str());
-
- PRINT_ME(7, NCUR_X, "A: 0x%04X\tD: 0x%04X\tM: 0x%04X\tRES: 0x%04X",
- topp->computer->reg_A_int, topp->computer->reg_D_int,
- topp->computer->reg_pA_int, topp->computer->result_int);
- PRINT_ME(
- 8, NCUR_X, "%c%8d\t%c%8d\t%c%8d\t%11d",
+ PRINT_ME_W(status_top, 2, 1, "%-20s", paused ? "Paused" : "Running");
+
+ PRINT_ME_W(clock_regs, 1, NCUR_X,
+ "CLK: %4d\tPC: 0x%04X\tINS: 0x%04X\tHLT: %6d", topp->clk_in,
+ // wrong
+ // topp->computer->clk_in,
+ topp->computer->PC_addr_int, opcode, topp->halt);
+
+ PRINT_ME_W(clock_regs, 2, NCUR_X,
+ "A: 0x%04X\tD: 0x%04X\tM: 0x%04X\tRES: 0x%04X",
+ topp->computer->reg_A_int, topp->computer->reg_D_int,
+ topp->computer->reg_pA_int, topp->computer->result_int);
+ PRINT_ME_W(
+ clock_regs, 3, NCUR_X, "%c%8d\t%c %8d\t%c %8d\t%11d",
topp->computer->store_to_A_int ? '*' : ' ', topp->computer->reg_A_int,
topp->computer->store_to_D_int ? '*' : ' ', topp->computer->reg_D_int,
topp->computer->store_to_pA_int ? '*' : ' ', topp->computer->reg_pA_int,
@@ -115,7 +117,7 @@ void simpc_ui_write(const std::unique_ptr<Vcomputer> &topp, uint64_t &i,
PRINT_ME(getmaxy(stdscr) - 1, 1,
" q - Quit; p - (Un)pause; s - step (while paused) ");
- PRINT_NEXT();
+ PRINT_NEXT(true);
handle_key();
}
@@ -124,7 +126,7 @@ void simpc_ui_finish_message(const std::unique_ptr<VerilatedContext> &contextp,
const std::unique_ptr<Vcomputer> &topp) {
attron(A_BOLD);
auto xpos = 20;
- PRINT_ME_W(status_top, 0, xpos, "Simulation finished.");
+ PRINT_ME_W(status_top, 1, xpos, "Simulation finished.");
const char *msg;
if (topp->halt) {
msg = "Halt encountered.";
@@ -133,11 +135,8 @@ void simpc_ui_finish_message(const std::unique_ptr<VerilatedContext> &contextp,
} else {
msg = "Regular finish.";
}
- PRINT_ME_W(status_top, 1, xpos, "%s", msg);
-#if NCUR
- refresh();
- wrefresh(status_top);
-#endif
+ PRINT_ME_W(status_top, 2, xpos, "%s", msg);
+ PRINT_NEXT(false);
attroff(A_BOLD);
}
@@ -147,9 +146,13 @@ void simpc_ui_init(void) {
curs_set(0);
// lines, cols, ypos, xpos
- status_top = newwin(2, 50, 1, 1);
- // SIMPLE_BORDER(status_top, '!', '~', 'X');
+ status_top = newwin(4, 50, 0, 0);
+ SIMPLE_BORDER(status_top, '!', '~', 'X');
wrefresh(status_top);
+ clock_regs = newwin(5, 80, 3, 0);
+ SIMPLE_BORDER(clock_regs, '!', '~', 'X');
+ wrefresh(clock_regs);
+ wgetch(clock_regs);
int rc;
@@ -174,6 +177,9 @@ void simpc_ui_cleanup(void) {
if (status_top) {
delwin(status_top);
}
+ if (clock_regs) {
+ delwin(clock_regs);
+ }
endwin();
#endif
}