1
0
mirror of https://github.com/jscrane/r65emu.git synced 2024-07-12 23:29:03 +00:00
r65emu/acia.cpp

51 lines
844 B
C++
Raw Normal View History

2018-09-13 10:24:05 +00:00
#include <stdint.h>
#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) {
if (a & 1) {
2018-09-13 10:24:05 +00:00
_device->write(b);
return;
}
2018-09-13 11:56:54 +00:00
if ((b & cd_mask) == reset) {
2018-09-13 10:24:05 +00:00
_device->reset();
2018-09-13 11:56:54 +00:00
return;
}
switch (b & ws_mask) {
case ws7e2:
_device->framing(7, 2, even);
break;
case ws7o2:
_device->framing(7, 2, odd);
break;
case ws7e1:
_device->framing(7, 1, even);
break;
case ws7o1:
_device->framing(7, 1, odd);
break;
case ws8n2:
_device->framing(8, 2, none);
break;
case ws8n1:
_device->framing(8, 1, none);
break;
case ws8e1:
_device->framing(8, 1, even);
break;
case ws8o1:
_device->framing(8, 1, odd);
break;
};
2018-09-13 10:24:05 +00:00
// FIXME: more
}
2023-09-27 10:27:45 +00:00
uint8_t ACIA::read(Memory::address a) {
if (a & 1)
2018-09-13 10:24:05 +00:00
return _device->read();
2018-12-18 08:28:53 +00:00
return _device->more()? rdrf | tdre: tdre;
2018-09-13 10:24:05 +00:00
}