code clean-up

This commit is contained in:
folkert van heusden 2023-03-28 10:45:42 +02:00
parent 8eb01e558d
commit 237a7c482a
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
2 changed files with 13 additions and 10 deletions

21
tty.cpp
View file

@ -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);

2
tty.h
View file

@ -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();