1
0
mirror of https://github.com/jscrane/r65emu.git synced 2024-07-26 19:29:09 +00:00
r65emu/acia.cpp

58 lines
917 B
C++
Raw Permalink Normal View History

#include <Arduino.h>
2018-09-13 10:24:05 +00:00
#include "memory.h"
2019-02-11 18:28:38 +00:00
#include "serialio.h"
2018-09-13 10:24:05 +00:00
#include "acia.h"
2023-09-27 10:27:45 +00:00
void ACIA::write(Memory::address a, uint8_t b) {
2023-09-27 14:38:16 +00:00
if (a & 1)
write_data(b);
else
write_control(b);
}
void ACIA::write_control(uint8_t b) {
2018-09-13 11:56:54 +00:00
if ((b & cd_mask) == reset) {
acia_reset();
2018-09-13 11:56:54 +00:00
return;
}
switch (b & ws_mask) {
case ws7e2:
acia_framing(SERIAL_7E2);
2018-09-13 11:56:54 +00:00
break;
case ws7o2:
acia_framing(SERIAL_7O2);
2018-09-13 11:56:54 +00:00
break;
case ws7e1:
acia_framing(SERIAL_7E1);
2018-09-13 11:56:54 +00:00
break;
case ws7o1:
acia_framing(SERIAL_7O1);
2018-09-13 11:56:54 +00:00
break;
case ws8n2:
acia_framing(SERIAL_8N2);
2018-09-13 11:56:54 +00:00
break;
case ws8n1:
acia_framing(SERIAL_8N1);
2018-09-13 11:56:54 +00:00
break;
case ws8e1:
acia_framing(SERIAL_8E1);
2018-09-13 11:56:54 +00:00
break;
case ws8o1:
acia_framing(SERIAL_8O1);
2018-09-13 11:56:54 +00:00
break;
};
2023-09-27 14:38:16 +00:00
}
2023-09-27 10:27:45 +00:00
uint8_t ACIA::read(Memory::address a) {
if (a == 0)
return read_status();
if (a == 1)
return read_data();
return 0;
2023-09-27 14:38:16 +00:00
}
uint8_t ACIA::read_status() {
return acia_more()? rdrf | tdre: tdre;
2018-09-13 10:24:05 +00:00
}