diff --git a/main.cpp b/main.cpp index 8ca0573..7f445f2 100644 --- a/main.cpp +++ b/main.cpp @@ -255,7 +255,7 @@ int main(int argc, char *argv[]) running = cnsl->get_running_flag(); - tty *tty_ = new tty(cnsl); + tty *tty_ = new tty(cnsl, b); b->add_tty(tty_); diff --git a/tty.cpp b/tty.cpp index 688f16b..5aeacef 100644 --- a/tty.cpp +++ b/tty.cpp @@ -1,10 +1,11 @@ -// (C) 2018 by Folkert van Heusden +// (C) 2018-2023 by Folkert van Heusden // // Released under Apache License v2.0 #include #include #include #include "tty.h" +#include "cpu.h" #include "gen.h" #include "log.h" #include "memory.h" @@ -18,7 +19,9 @@ const char * const regnames[] = { "puncher buffer" }; -tty::tty(console *const c) : c(c) +tty::tty(console *const c, bus *const b) : + c(c), + b(b) { } @@ -65,7 +68,7 @@ uint16_t tty::readWord(const uint16_t addr) } } else if (addr == PDP11TTY_TPS) { - vtemp = 128; + vtemp |= 128; } DOLOG(debug, true, "PDP11TTY read addr %o (%s): %d, 7bit: %d", addr, regnames[reg], vtemp, vtemp & 127); @@ -103,6 +106,11 @@ void tty::writeWord(const uint16_t addr, uint16_t v) DOLOG(debug, true, "PDP11TTY print '%c'", ch); c->put_char(ch); + + registers[(PDP11TTY_TPS - PDP11TTY_BASE) / 2] |= 128; + + if (registers[(PDP11TTY_TPS - PDP11TTY_BASE) / 2] & 64) + b->getCpu()->queue_interrupt(4, 064); } DOLOG(debug, true, "set register %o to %o", addr, v); diff --git a/tty.h b/tty.h index abe6090..33f230f 100644 --- a/tty.h +++ b/tty.h @@ -1,4 +1,4 @@ -// (C) 2018-2022 by Folkert van Heusden +// (C) 2018-2023 by Folkert van Heusden // Released under Apache License v2.0 #pragma once @@ -6,6 +6,7 @@ #include #include +#include "bus.h" #include "console.h" @@ -22,12 +23,13 @@ class tty { private: console *const c { nullptr }; + bus *const b { nullptr }; bool have_char_1 { false }; // RCVR BUSY bit high (11) bool have_char_2 { false }; // RCVR DONE bit high (7) uint16_t registers[4] { 0 }; public: - tty(console *const c); + tty(console *const c, bus *const b); virtual ~tty(); uint8_t readByte(const uint16_t addr);