DC11 code clean-up
This commit is contained in:
parent
c56eb62560
commit
17e5d59d8b
2 changed files with 17 additions and 4 deletions
19
dc11.cpp
19
dc11.cpp
|
@ -131,7 +131,7 @@ void dc11::operator()()
|
||||||
|
|
||||||
registers[line_nr * 4 + 0] |= 128; // DONE: bit 7
|
registers[line_nr * 4 + 0] |= 128; // DONE: bit 7
|
||||||
|
|
||||||
if (registers[line_nr * 4 + 0] & 64) // interrupts enabled?
|
if (is_rx_interrupt_enabled(line_nr))
|
||||||
trigger_interrupt(line_nr);
|
trigger_interrupt(line_nr);
|
||||||
|
|
||||||
have_data[line_nr].notify_all();
|
have_data[line_nr].notify_all();
|
||||||
|
@ -151,6 +151,16 @@ void dc11::reset()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool dc11::is_rx_interrupt_enabled(const int line_nr)
|
||||||
|
{
|
||||||
|
return !!(registers[line_nr * 4 + 0] & 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dc11::is_tx_interrupt_enabled(const int line_nr)
|
||||||
|
{
|
||||||
|
return !!(registers[line_nr * 4 + 2] & 64);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t dc11::read_byte(const uint16_t addr)
|
uint8_t dc11::read_byte(const uint16_t addr)
|
||||||
{
|
{
|
||||||
uint16_t v = read_word(addr & ~1);
|
uint16_t v = read_word(addr & ~1);
|
||||||
|
@ -192,10 +202,11 @@ uint16_t dc11::read_word(const uint16_t addr)
|
||||||
recv_buffers[line_nr].erase(recv_buffers[line_nr].begin());
|
recv_buffers[line_nr].erase(recv_buffers[line_nr].begin());
|
||||||
|
|
||||||
// still data in buffer? generate interrupt
|
// still data in buffer? generate interrupt
|
||||||
if (recv_buffers[line_nr].empty() == false && (registers[line_nr * 4] & 64)) {
|
if (recv_buffers[line_nr].empty() == false) {
|
||||||
registers[line_nr * 4 + 0] |= 128; // DONE: bit 7
|
registers[line_nr * 4 + 0] |= 128; // DONE: bit 7
|
||||||
|
|
||||||
trigger_interrupt(line_nr);
|
if (is_rx_interrupt_enabled(line_nr))
|
||||||
|
trigger_interrupt(line_nr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,7 +247,7 @@ void dc11::write_word(const uint16_t addr, uint16_t v)
|
||||||
// TODO handle failed transmit
|
// TODO handle failed transmit
|
||||||
printf("%ld\r\n", write(pfds[dc11_n_lines + line_nr].fd, &c, 1));
|
printf("%ld\r\n", write(pfds[dc11_n_lines + line_nr].fd, &c, 1));
|
||||||
|
|
||||||
if (registers[line_nr * 4 + 2] & 64)
|
if (is_tx_interrupt_enabled(line_nr))
|
||||||
trigger_interrupt(line_nr);
|
trigger_interrupt(line_nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
dc11.h
2
dc11.h
|
@ -42,6 +42,8 @@ private:
|
||||||
std::mutex input_lock[dc11_n_lines];
|
std::mutex input_lock[dc11_n_lines];
|
||||||
|
|
||||||
void trigger_interrupt(const int line_nr);
|
void trigger_interrupt(const int line_nr);
|
||||||
|
bool is_rx_interrupt_enabled(const int line_nr);
|
||||||
|
bool is_tx_interrupt_enabled(const int line_nr);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
dc11(const int base_port, bus *const b);
|
dc11(const int base_port, bus *const b);
|
||||||
|
|
Loading…
Add table
Reference in a new issue