diff options
Diffstat (limited to 'nandgame')
| -rw-r--r-- | nandgame/Vcomputer__main.cpp | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/nandgame/Vcomputer__main.cpp b/nandgame/Vcomputer__main.cpp index 8a2c094..a22d09c 100644 --- a/nandgame/Vcomputer__main.cpp +++ b/nandgame/Vcomputer__main.cpp @@ -18,15 +18,15 @@ #include "../assembler/disas.h" #define NCUR_OFFSET 3 +#define NCUR_X 5 #if NCUR #include <ncurses.h> #define NCUR_DELAY_MS 100 -#define NCUR_X 5 -#define PRINT_ME(x, y, ...) \ +#define PRINT_ME(y, x, ...) \ { \ - mvprintw(x, y, __VA_ARGS__); \ + mvprintw(y, x, __VA_ARGS__); \ } #define PRINT_NEXT() \ { \ @@ -36,9 +36,9 @@ #else -#define PRINT_ME(x, y, ...) \ +#define PRINT_ME(y, x, ...) \ { \ - printf("%*s", x, ""); \ + printf("%*c", x, ' '); \ printf(__VA_ARGS__); \ printf("\n"); \ } @@ -68,22 +68,20 @@ void draw_ui(const std::unique_ptr<Vcomputer> &topp, uint64_t &i, auto insline = print_decoded(opcode, true); PRINT_ME(3 + NCUR_OFFSET, NCUR_X, "%-80s", insline.c_str()); - // keep old state - if (topp->halt) - return; - PRINT_ME(5 + NCUR_OFFSET, 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(6 + NCUR_OFFSET, NCUR_X, - "%9" PRId16 "\t%9" PRId16 "\t%9" PRId16 "\t%11" PRId16, - topp->computer->reg_A_int, topp->computer->reg_D_int, - topp->computer->reg_pA_int, topp->computer->result_int); - 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) + PRINT_ME( + 6 + NCUR_OFFSET, 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, + topp->computer->result_int); + // PRINT_ME(7 + NCUR_OFFSET, NCUR_X, "ALU"); + // PRINT_ME(8 + NCUR_OFFSET, NCUR_X, "X: %5d\tY: %5d", + // topp->computer->CPU->my_alu->int_op_x, + // topp->computer->CPU->my_alu->int_op_y); PRINT_NEXT(); } @@ -140,11 +138,11 @@ int main(int argc, char **argv, char **) { // both bits 14 and 15 need to be set if (topp->halt) - break; - - draw_ui(topp, i, StepPosition_t::AFTER_EVAL); + break; + + draw_ui(topp, i, StepPosition_t::AFTER_EVAL); - // Advance time + // Advance time contextp->timeInc(1); } |
