From b7512ae3cde80310eee31669afd92b2bbd7f8050 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sun, 19 Mar 2023 15:05:00 +0100 Subject: [PATCH] show console LEDs --- bus.cpp | 2 +- bus.h | 8 ++++---- console_ncurses.cpp | 9 ++++++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bus.cpp b/bus.cpp index 2032b41..c8eba21 100644 --- a/bus.cpp +++ b/bus.cpp @@ -858,7 +858,7 @@ void bus::write(const uint16_t a, const bool word_mode, uint16_t value, const bo } if (a == ADDR_CONSW) { // switch register - switch_register = value; + console_leds = value; return; } diff --git a/bus.h b/bus.h index 7669b89..dd2dd81 100644 --- a/bus.h +++ b/bus.h @@ -84,11 +84,10 @@ private: uint16_t MMR0 { 0 }, MMR1 { 0 }, MMR2 { 0 }, MMR3 { 0 }, CPUERR { 0 }, PIR { 0 }, CSR { 0 }; - uint16_t switch_register { 0 }; - uint16_t lf_csr { 0 }; uint16_t console_switches { 0 }; + uint16_t console_leds { 0 }; uint16_t read_pdr (const uint32_t a, const int run_mode, const bool word_mode, const bool peek_only); uint16_t read_par (const uint32_t a, const int run_mode, const bool word_mode, const bool peek_only); @@ -102,8 +101,11 @@ public: void clearmem(); void set_console_switches(const uint16_t new_state) { console_switches = new_state; } + uint16_t get_console_switches() { return console_switches; } void set_debug_mode() { console_switches |= 128; } + uint16_t get_console_leds() { return console_leds; } + void add_cpu(cpu *const c) { this -> c = c; } void add_tm11(tm_11 *tm11) { this -> tm11 = tm11; } void add_rk05(rk05 *rk05_) { this -> rk05_ = rk05_; } @@ -146,8 +148,6 @@ public: void clearMMR0Bit(const int bit); void setMMR2(const uint16_t value); - uint16_t get_switch_register() const { return switch_register; } - uint32_t calculate_physical_address(const int run_mode, const uint16_t a, const bool trap_on_failure, const bool is_write, const bool peek_only, const bool is_data); bool get_use_data_space(const int run_mode); diff --git a/console_ncurses.cpp b/console_ncurses.cpp index 5720b85..0d37a64 100644 --- a/console_ncurses.cpp +++ b/console_ncurses.cpp @@ -114,7 +114,7 @@ void console_ncurses::resize_terminal() create_win_border(0, 0, 80, 25, "terminal", &w_main_b, &w_main, false); - create_win_border(0, 27, 100, 4, "panel", &w_panel_b, &w_panel, false); + create_win_border(0, 27, 100, 5, "panel", &w_panel_b, &w_panel, false); scrollok(w_main -> win, TRUE); @@ -163,6 +163,13 @@ void console_ncurses::panel_update_thread() for(uint8_t b=0; b<16; b++) mvwprintw(w_panel->win, 1, 1 + 16 - b + 17, "%c", current_instr & (1 << b) ? '1' : '0'); + mvwprintw(w_panel->win, 4, 1, "LEDs:"); + + uint16_t leds = b->get_console_leds(); + + for(uint8_t b=0; b<16; b++) + mvwprintw(w_panel->win, 4, 1 + 22 - b, "%c", leds & (1 << b) ? '1' : '0'); + wattron(w_panel->win, COLOR_PAIR(5)); mvwprintw(w_panel->win, 1, 1 + 35, "%c%c%c",