fix for crash due to logging changes

This commit is contained in:
folkert van heusden 2022-06-13 19:26:54 +02:00
parent 1dfb1ab325
commit a000df36b8
3 changed files with 32 additions and 16 deletions

View file

@ -104,11 +104,11 @@ void setBootLoader(bus *const b, const bootloader_t which)
c -> setRegister(7, offset);
}
uint16_t loadTape(bus *const b, const char *const file)
uint16_t loadTape(bus *const b, const std::string & file)
{
FILE *fh = fopen(file, "rb");
FILE *fh = fopen(file.c_str(), "rb");
if (!fh) {
DOLOG(ll_error, true, "Cannot open %s", file);
DOLOG(ll_error, true, "Cannot open %s", file.c_str());
return -1;
}

View file

@ -8,5 +8,5 @@ typedef enum { BL_NONE, BL_RK05, BL_RL02 } bootloader_t;
void loadbin(bus *const b, uint16_t base, const char *const file);
void setBootLoader(bus *const b, const bootloader_t which);
uint16_t loadTape(bus *const b, const char *const file);
uint16_t loadTape(bus *const b, const std::string & file);
void load_p11_x11(bus *const b, const std::string & file);

View file

@ -57,15 +57,6 @@ int main(int argc, char *argv[])
{
//setlocale(LC_ALL, "");
bus *b = new bus();
cpu *c = new cpu(b, &event);
b->add_cpu(c);
kw11_l *lf = new kw11_l(b);
c -> setEmulateMFPT(true);
std::vector<std::string> rk05_files;
std::vector<std::string> rl02_files;
@ -79,6 +70,13 @@ int main(int argc, char *argv[])
log_level_t ll_screen = none;
log_level_t ll_file = none;
bool mode_34 = false;
uint16_t start_addr= 01000;
bool sa_set = false;
std::string tape;
int opt = -1;
while((opt = getopt(argc, argv, "hm:T:r:R:p:ndtL:b:l:3")) != -1)
{
@ -88,7 +86,7 @@ int main(int argc, char *argv[])
return 1;
case '3':
c->set_34(true); // switch from 11/70 to 11/34
mode_34 = true; // switch from 11/70 to 11/34
break;
case 'b':
@ -114,7 +112,7 @@ int main(int argc, char *argv[])
break;
case 'T':
c->setRegister(7, loadTape(b, optarg));
tape = optarg;
break;
case 'R':
@ -126,7 +124,8 @@ int main(int argc, char *argv[])
break;
case 'p':
c->setRegister(7, atoi(optarg));
start_addr = atoi(optarg);
sa_set = true;
break;
case 'L': {
@ -154,8 +153,25 @@ int main(int argc, char *argv[])
setlog(logfile, ll_file, ll_screen);
bus *b = new bus();
cpu *c = new cpu(b, &event);
b->add_cpu(c);
c->set_34(mode_34);
kw11_l *lf = new kw11_l(b);
c->setEmulateMFPT(true);
std::atomic_bool interrupt_emulation { false };
if (tape.empty() == false)
c->setRegister(7, loadTape(b, tape));
if (sa_set)
c->setRegister(7, start_addr);
if (withUI)
cnsl = new console_ncurses(&event, b);
else {