From 237a7c482affb186b17c086b789d6fe7bc657334 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Tue, 28 Mar 2023 10:45:42 +0200 Subject: [PATCH] code clean-up --- tty.cpp | 21 +++++++++++---------- tty.h | 2 ++ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/tty.cpp b/tty.cpp index b31b2db..b38a920 100644 --- a/tty.cpp +++ b/tty.cpp @@ -45,6 +45,14 @@ uint8_t tty::readByte(const uint16_t addr) return v; } +void tty::notify_rx() +{ + registers[(PDP11TTY_TKS - PDP11TTY_BASE) / 2] |= 128; + + if (registers[(PDP11TTY_TKS - PDP11TTY_BASE) / 2] & 64) + b->getCpu()->queue_interrupt(4, 060); +} + uint16_t tty::readWord(const uint16_t addr) { const int reg = (addr - PDP11TTY_BASE) / 2; @@ -69,12 +77,8 @@ uint16_t tty::readWord(const uint16_t addr) vtemp = ch | (parity(ch) << 7); - if (chars.empty() == false) { - registers[(PDP11TTY_TKS - PDP11TTY_BASE) / 2] |= 128; - - if (registers[(PDP11TTY_TKS - PDP11TTY_BASE) / 2] & 64) - b->getCpu()->queue_interrupt(4, 060); - } + if (chars.empty() == false) + notify_rx(); } } else if (addr == PDP11TTY_TPS) { @@ -96,10 +100,7 @@ void tty::operator()() chars.push_back(c->get_char()); - registers[(PDP11TTY_TKS - PDP11TTY_BASE) / 2] |= 128; - - if (registers[(PDP11TTY_TKS - PDP11TTY_BASE) / 2] & 64) - b->getCpu()->queue_interrupt(4, 060); + notify_rx(); } else { myusleep(100000); diff --git a/tty.h b/tty.h index 2491bc5..b5792a3 100644 --- a/tty.h +++ b/tty.h @@ -35,6 +35,8 @@ private: std::thread *th { nullptr }; std::atomic_bool stop_flag { false }; + void notify_rx(); + public: tty(console *const c, bus *const b); virtual ~tty();