Console switches configurable on command line

This commit is contained in:
folkert van heusden 2022-06-19 15:39:46 +02:00
parent ad44232120
commit 88933e303c
5 changed files with 19 additions and 9 deletions

View file

@ -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 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 if (a == 0172540) { // KW11P programmable clock

5
bus.h
View file

@ -39,7 +39,7 @@ private:
uint16_t lf_csr { 0 }; uint16_t lf_csr { 0 };
bool debug_mode { false }; uint16_t console_switches { 0 };
public: public:
bus(); bus();
@ -47,7 +47,8 @@ public:
void clearmem(); 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_cpu(cpu *const c) { this -> c = c; }
void add_tm11(tm_11 *tm11) { this -> tm11 = tm11; } void add_tm11(tm_11 *tm11) { this -> tm11 = tm11; }

View file

@ -120,7 +120,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
cpu *const c = b->getCpu(); cpu *const c = b->getCpu();
b->set_debug_mode(true); b->set_debug_mode();
bool single_step = false; bool single_step = false;

View file

@ -178,7 +178,7 @@ void load_p11_x11(bus *const b, const std::string & file)
break; break;
if (n) { if (n) {
uint8_t byte = strtol(buffer, NULL, 16); uint8_t byte = strtol(buffer, nullptr, 16);
b->writeByte(addr, byte); b->writeByte(addr, byte);
@ -189,8 +189,8 @@ void load_p11_x11(bus *const b, const std::string & file)
else { else {
std::vector<std::string> parts = split(buffer, " "); std::vector<std::string> parts = split(buffer, " ");
addr = strtol(parts[0].c_str(), NULL, 16); addr = strtol(parts[0].c_str(), nullptr, 16);
n = strtol(parts[1].c_str(), NULL, 16); n = strtol(parts[1].c_str(), nullptr, 16);
} }
} }

View file

@ -48,6 +48,7 @@ void help()
printf("-b x enable bootloader (build-in), parameter must be \"rk05\" or \"rl02\"\n"); printf("-b x enable bootloader (build-in), parameter must be \"rk05\" or \"rl02\"\n");
printf("-n ncurses UI\n"); printf("-n ncurses UI\n");
printf("-d enable debugger\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("-t enable tracing (disassemble to stderr, requires -d as well)\n");
printf("-l x log to file x\n"); printf("-l x log to file x\n");
printf("-L x,y set log level for screen (x) and file (y)\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; std::string tape;
uint16_t console_switches = 0;
int opt = -1; 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) { switch(opt) {
case 'h': case 'h':
help(); help();
return 1; return 1;
case 's':
console_switches = strtol(optarg, NULL, 8);
break;
case '3': case '3':
mode_34 = true; // switch from 11/70 to 11/34 mode_34 = true; // switch from 11/70 to 11/34
break; break;
@ -154,6 +161,8 @@ int main(int argc, char *argv[])
bus *b = new bus(); bus *b = new bus();
b->set_console_switches(console_switches);
cpu *c = new cpu(b, &event); cpu *c = new cpu(b, &event);
b->add_cpu(c); b->add_cpu(c);