diff options
Diffstat (limited to 'nandgame')
| -rw-r--r-- | nandgame/Vcomputer__main.cpp | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/nandgame/Vcomputer__main.cpp b/nandgame/Vcomputer__main.cpp index 4ca2029..1857f1e 100644 --- a/nandgame/Vcomputer__main.cpp +++ b/nandgame/Vcomputer__main.cpp @@ -4,6 +4,7 @@ #include "Vcomputer.h" #include "Vcomputer___024root.h" #include "Vcomputer_alu.h" +#include "Vcomputer_comb_mem.h" #include "Vcomputer_computer.h" #include "Vcomputer_instruction_decode.h" #include "Vcomputer_my_mem__D10_DB10000.h" @@ -21,7 +22,7 @@ #if NCUR #include <ncurses.h> -#define NCUR_DELAY_MS 10 +#define NCUR_DELAY_MS 100 #define PRINT_ME(y, x, ...) \ { \ @@ -76,16 +77,48 @@ void draw_ui(const std::unique_ptr<Vcomputer> &topp, uint64_t &i, 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(10, NCUR_X, "--- ROM ---"); - for (int i = -1; i <= 1; i++) { +#define MEMORY_CONTEXT 3 + + const int ram1_pos_offset = 35 + 1; + const int ram2_pos_offset = ram1_pos_offset + 14 + 1; + PRINT_ME(10, NCUR_X, "%-35s", "--- ROM ---"); + PRINT_ME(10, NCUR_X + ram1_pos_offset, "%-35s", "--- RAM1 ---"); + PRINT_ME(10, NCUR_X + ram2_pos_offset, "%-35s", "-- RAM2 --"); + for (int i = -MEMORY_CONTEXT; i <= MEMORY_CONTEXT; i++) { + const int ypos_base = 10 + 1 + MEMORY_CONTEXT; const char *prefix = i == 0 ? "> " : " "; - uint16_t curadr = topp->computer->PC_addr_int + i; - const uint16_t p = curadr; - const uint16_t program_op_code = topp->computer->ROM->r_datastore[p]; - auto disas_code = print_decoded(program_op_code, true); - PRINT_ME(12 + i, NCUR_X, "%04X %s%04X %-30s", curadr, prefix, - program_op_code, disas_code.c_str()); + int32_t current_ROM_address = topp->computer->PC_addr_int + i; + int32_t current_RAM_address = topp->computer->reg_A_int + i; + if (current_ROM_address < 0) { + PRINT_ME( + ypos_base + i, NCUR_X, "%.35s", + "---------------------------------------------------------------"); + } else { + const uint16_t p = current_ROM_address; + const uint16_t program_op_code = topp->computer->ROM->r_datastore[p]; + auto disas_code = print_decoded(program_op_code, true); + PRINT_ME(ypos_base + i, NCUR_X, "%04X %s%04X %-30s", + current_ROM_address, prefix, program_op_code, + disas_code.c_str()); + } + if (current_RAM_address < 0) { + PRINT_ME( + ypos_base + i, NCUR_X + ram1_pos_offset, "%.12s", + "---------------------------------------------------------------"); + } else { + const uint16_t p = current_RAM_address; + const uint16_t mem_content = + topp->computer->RAM->nand_memory->r_datastore[p]; + PRINT_ME(ypos_base + i, NCUR_X + ram1_pos_offset, "%04X %s%04X", + current_RAM_address, prefix, mem_content); + } + { + const uint16_t p = MEMORY_CONTEXT + i; + const uint16_t mem_content = + topp->computer->RAM->nand_memory->r_datastore[p]; + PRINT_ME(ypos_base + i, NCUR_X + ram2_pos_offset, "%04X %04X%30c", p, + mem_content, ' '); + } } // PRINT_ME(7 + NCUR_OFFSET, NCUR_X, "ALU"); // PRINT_ME(8 + NCUR_OFFSET, NCUR_X, "X: %5d\tY: %5d", |
