1
0
mirror of https://github.com/jscrane/r65emu.git synced 2024-12-22 03:30:02 +00:00

acia updates (#22)

This commit is contained in:
Stephen Crane 2023-09-27 15:38:16 +01:00 committed by GitHub
parent 67ff1567af
commit 3e90841500
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 20 deletions

View File

@ -5,46 +5,58 @@
#include "acia.h" #include "acia.h"
void ACIA::write(Memory::address a, uint8_t b) { void ACIA::write(Memory::address a, uint8_t b) {
if (a & 1) { if (a & 1)
_device->write(b); write_data(b);
return; else
write_control(b);
} }
void ACIA::write_control(uint8_t b) {
if ((b & cd_mask) == reset) { if ((b & cd_mask) == reset) {
_device->reset(); _serial->reset();
return; return;
} }
switch (b & ws_mask) { switch (b & ws_mask) {
case ws7e2: case ws7e2:
_device->framing(7, 2, even); _serial->framing(7, 2, even);
break; break;
case ws7o2: case ws7o2:
_device->framing(7, 2, odd); _serial->framing(7, 2, odd);
break; break;
case ws7e1: case ws7e1:
_device->framing(7, 1, even); _serial->framing(7, 1, even);
break; break;
case ws7o1: case ws7o1:
_device->framing(7, 1, odd); _serial->framing(7, 1, odd);
break; break;
case ws8n2: case ws8n2:
_device->framing(8, 2, none); _serial->framing(8, 2, none);
break; break;
case ws8n1: case ws8n1:
_device->framing(8, 1, none); _serial->framing(8, 1, none);
break; break;
case ws8e1: case ws8e1:
_device->framing(8, 1, even); _serial->framing(8, 1, even);
break; break;
case ws8o1: case ws8o1:
_device->framing(8, 1, odd); _serial->framing(8, 1, odd);
break; break;
}; };
// FIXME: more // FIXME: more
} }
uint8_t ACIA::read(Memory::address a) { void ACIA::write_data(uint8_t b) {
if (a & 1) _serial->write(b);
return _device->read(); }
return _device->more()? rdrf | tdre: tdre; uint8_t ACIA::read(Memory::address a) {
return (a & 1)? read_data(): read_status();
}
uint8_t ACIA::read_data() {
return _serial->read();
}
uint8_t ACIA::read_status() {
return _serial->more()? rdrf | tdre: tdre;
} }

11
acia.h
View File

@ -8,7 +8,7 @@ public:
void write(Memory::address, uint8_t); void write(Memory::address, uint8_t);
uint8_t read(Memory::address); uint8_t read(Memory::address);
ACIA(serialio &d): _device(&d) {} ACIA(serialio &s): _serial(&s) {}
// status bits // status bits
// //
@ -47,7 +47,14 @@ public:
static const uint8_t eri = 1 << 7; // enable receive interrupt static const uint8_t eri = 1 << 7; // enable receive interrupt
protected:
// overrideable device memory interface
virtual uint8_t read_status();
virtual uint8_t read_data();
virtual void write_control(uint8_t);
virtual void write_data(uint8_t);
private: private:
class serialio *_device; class serialio *_serial;
}; };
#endif #endif

View File

@ -5,4 +5,8 @@ typedef void (*handler_t)(void);
void timer_create(unsigned freq, handler_t handler); void timer_create(unsigned freq, handler_t handler);
#if !defined(ESP32) && !defined(ESP8266)
#define IRAM_ATTR
#endif
#endif #endif