1
0
mirror of https://github.com/jscrane/r65emu.git synced 2025-01-02 13:30:53 +00:00

refactor ACIA + allow compile with no hw def

This commit is contained in:
steve 2024-07-19 11:40:49 +01:00
parent 2baab0f856
commit 072c15ff33
6 changed files with 23 additions and 31 deletions

View File

@ -1,4 +1,4 @@
#include <stdint.h>
#include <Arduino.h>
#include "memory.h"
#include "serialio.h"
@ -13,40 +13,35 @@ void ACIA::write(Memory::address a, uint8_t b) {
void ACIA::write_control(uint8_t b) {
if ((b & cd_mask) == reset) {
_serial->reset();
acia_reset();
return;
}
switch (b & ws_mask) {
case ws7e2:
_serial->framing(7, 2, even);
acia_framing(SERIAL_7E2);
break;
case ws7o2:
_serial->framing(7, 2, odd);
acia_framing(SERIAL_7O2);
break;
case ws7e1:
_serial->framing(7, 1, even);
acia_framing(SERIAL_7E1);
break;
case ws7o1:
_serial->framing(7, 1, odd);
acia_framing(SERIAL_7O1);
break;
case ws8n2:
_serial->framing(8, 2, none);
acia_framing(SERIAL_8N2);
break;
case ws8n1:
_serial->framing(8, 1, none);
acia_framing(SERIAL_8N1);
break;
case ws8e1:
_serial->framing(8, 1, even);
acia_framing(SERIAL_8E1);
break;
case ws8o1:
_serial->framing(8, 1, odd);
acia_framing(SERIAL_8O1);
break;
};
// FIXME: more
}
void ACIA::write_data(uint8_t b) {
_serial->write(b);
}
uint8_t ACIA::read(Memory::address a) {
@ -57,10 +52,6 @@ uint8_t ACIA::read(Memory::address a) {
return 0;
}
uint8_t ACIA::read_data() {
return _serial->read();
}
uint8_t ACIA::read_status() {
return _serial->more()? rdrf | tdre: tdre;
return acia_more()? rdrf | tdre: tdre;
}

12
acia.h
View File

@ -8,8 +8,7 @@ public:
void write(Memory::address, uint8_t);
uint8_t read(Memory::address);
ACIA(serialio &s): _serial(&s) {}
void set_device(serialio *s) { _serial = s; }
virtual void acia_reset() {}
// status bits
//
@ -51,11 +50,10 @@ public:
protected:
// overrideable device memory interface
virtual uint8_t read_status();
virtual uint8_t read_data();
virtual uint8_t read_data() = 0;
virtual void write_control(uint8_t);
virtual void write_data(uint8_t);
private:
serialio *_serial;
virtual void write_data(uint8_t) = 0;
virtual void acia_framing(uint32_t config) {}
virtual bool acia_more() = 0;
};
#endif

View File

@ -1,5 +1,4 @@
#include <stdarg.h>
#include <stdint.h>
#include <Arduino.h>
#include "hardware.h"
#include "memory.h"
#include "display.h"

View File

@ -1,6 +1,10 @@
#include <stdint.h>
#include <stddef.h>
#include "hardware.h"
#if defined(USE_SD) || defined(USE_SPIFFS) || defined(USE_LITTLEFS) || defined(USE_SPIRAM)
#include <SPI.h>
#endif
#if defined(USE_SD)
#include <SD.h>

View File

@ -1,3 +1,3 @@
// user-configured hardware description
#error "hw/user.h not configured!"
#warning "hw/user.h not configured!"

View File

@ -10,7 +10,7 @@ enum parity {
class serialio {
public:
virtual void reset() {}
virtual void framing(unsigned data_bits, unsigned stop_bits, parity p) {}
virtual void framing(uint32_t) {}
virtual void write(uint8_t) {}
virtual uint8_t read() =0;