From 88933e303c11baa90ddac43a7f877ba9af48d295 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sun, 19 Jun 2022 15:39:46 +0200 Subject: [PATCH] Console switches configurable on command line --- bus.cpp | 4 ++-- bus.h | 5 +++-- debugger.cpp | 2 +- loaders.cpp | 6 +++--- main.cpp | 11 ++++++++++- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/bus.cpp b/bus.cpp index cce6d3e..4378d01 100644 --- a/bus.cpp +++ b/bus.cpp @@ -67,9 +67,9 @@ uint16_t bus::read(const uint16_t a, const bool word_mode, const bool use_prev, } if (a == 0177570) { // console switch & display register - DOLOG(debug, !peek_only, "read console switch"); + DOLOG(debug, !peek_only, "read console switch (%06o)", console_switches); - return debug_mode ? 128 : 0; + return console_switches; } if (a == 0172540) { // KW11P programmable clock diff --git a/bus.h b/bus.h index 9b8cdd6..b13e352 100644 --- a/bus.h +++ b/bus.h @@ -39,7 +39,7 @@ private: uint16_t lf_csr { 0 }; - bool debug_mode { false }; + uint16_t console_switches { 0 }; public: bus(); @@ -47,7 +47,8 @@ public: void clearmem(); - void set_debug_mode(const bool state) { debug_mode = state; } + void set_console_switches(const uint16_t new_state) { console_switches = new_state; } + void set_debug_mode() { console_switches |= 128; } void add_cpu(cpu *const c) { this -> c = c; } void add_tm11(tm_11 *tm11) { this -> tm11 = tm11; } diff --git a/debugger.cpp b/debugger.cpp index 15e3ac2..88c58a2 100644 --- a/debugger.cpp +++ b/debugger.cpp @@ -120,7 +120,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto cpu *const c = b->getCpu(); - b->set_debug_mode(true); + b->set_debug_mode(); bool single_step = false; diff --git a/loaders.cpp b/loaders.cpp index 0088f42..e6f566b 100644 --- a/loaders.cpp +++ b/loaders.cpp @@ -178,7 +178,7 @@ void load_p11_x11(bus *const b, const std::string & file) break; if (n) { - uint8_t byte = strtol(buffer, NULL, 16); + uint8_t byte = strtol(buffer, nullptr, 16); b->writeByte(addr, byte); @@ -189,8 +189,8 @@ void load_p11_x11(bus *const b, const std::string & file) else { std::vector parts = split(buffer, " "); - addr = strtol(parts[0].c_str(), NULL, 16); - n = strtol(parts[1].c_str(), NULL, 16); + addr = strtol(parts[0].c_str(), nullptr, 16); + n = strtol(parts[1].c_str(), nullptr, 16); } } diff --git a/main.cpp b/main.cpp index 24631da..3fa826e 100644 --- a/main.cpp +++ b/main.cpp @@ -48,6 +48,7 @@ void help() printf("-b x enable bootloader (build-in), parameter must be \"rk05\" or \"rl02\"\n"); printf("-n ncurses UI\n"); printf("-d enable debugger\n"); + printf("-s x set console switches state - octal number\n"); printf("-t enable tracing (disassemble to stderr, requires -d as well)\n"); printf("-l x log to file x\n"); printf("-L x,y set log level for screen (x) and file (y)\n"); @@ -76,14 +77,20 @@ int main(int argc, char *argv[]) std::string tape; + uint16_t console_switches = 0; + int opt = -1; - while((opt = getopt(argc, argv, "hm:T:r:R:p:ndtL:b:l:3")) != -1) + while((opt = getopt(argc, argv, "hm:T:r:R:p:ndtL:b:l:3s:")) != -1) { switch(opt) { case 'h': help(); return 1; + case 's': + console_switches = strtol(optarg, NULL, 8); + break; + case '3': mode_34 = true; // switch from 11/70 to 11/34 break; @@ -154,6 +161,8 @@ int main(int argc, char *argv[]) bus *b = new bus(); + b->set_console_switches(console_switches); + cpu *c = new cpu(b, &event); b->add_cpu(c);