Refactor MC6850 for C++14/17 updates

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2018-10-27 21:58:23 +01:00
parent 1a317c7907
commit 99692ce6c7
4 changed files with 43 additions and 25 deletions

View File

@ -28,7 +28,7 @@ void Board::initialise() {
updateAciaPins(EightBit::Chip::PinLevel::Low);
ACIA().lower(ACIA().CTS());
ACIA().powerOn();
ACIA().access();
accessAcia();
// Once the reset has completed, we can wire the ACIA event handlers...
ACIA().Transmitting.connect(std::bind(&Board::Acia_Transmitting, this, std::placeholders::_1));
@ -75,13 +75,13 @@ void Board::Bus_WrittenByte_Acia(EightBit::EventArgs&) {
updateAciaPins(EightBit::Chip::Low);
if (ACIA().selected()) {
ACIA().DATA() = peek(ADDRESS());
ACIA().access();
accessAcia();
}
}
void Board::Bus_ReadingByte_Acia(EightBit::EventArgs&) {
updateAciaPins(EightBit::Chip::High);
if (ACIA().access())
if (accessAcia())
poke(ADDRESS(), ACIA().DATA());
}
@ -115,4 +115,11 @@ void Board::Cpu_ExecutedInstruction_Acia(EightBit::mc6809&) {
void Board::Acia_Transmitting(EightBit::EventArgs&) {
std::cout << ACIA().TDR();
ACIA().markTransmitComplete();
}
}
bool Board::accessAcia() {
ACIA().raise(ACIA().E());
const bool accessed = ACIA().tick();
ACIA().lower(ACIA().E());
return accessed;
}

View File

@ -14,8 +14,8 @@ class Board : public EightBit::Bus {
public:
Board(const Configuration& configuration);
EightBit::mc6809& CPU() { return m_cpu; }
EightBit::mc6850& ACIA() { return m_acia; }
auto& CPU() { return m_cpu; }
auto& ACIA() { return m_acia; }
void initialise();
@ -35,7 +35,7 @@ private:
EightBit::Disassembly m_disassembler;
uint64_t m_totalCycleCount = 0UL;
int64_t m_frameCycleCount = 0UL;
int64_t m_frameCycleCount = 0L;
// The m_disassembleAt and m_ignoreDisassembly are used to skip pin events
EightBit::register16_t m_disassembleAt = 0x0000;
@ -64,4 +64,6 @@ private:
// Use the bus data to update the ACIA access/address pins
void updateAciaPins(EightBit::Chip::PinLevel rw);
bool accessAcia();
};

View File

@ -190,59 +190,59 @@ namespace EightBit {
};
// Receive data, (I) Active high
PinLevel& RXDATA() { return m_RXDATA; }
auto& RXDATA() { return m_RXDATA; }
// Transmit data, (O) Active high
PinLevel& TXDATA() { return m_TXDATA; }
auto& TXDATA() { return m_TXDATA; }
// Request to send, (O) Active low
PinLevel& RTS() { return m_RTS; }
auto& RTS() { return m_RTS; }
// Clear to send, (I) Active low
PinLevel& CTS() { return m_CTS; }
auto& CTS() { return m_CTS; }
// Data carrier detect, (I) Active low
PinLevel& DCD() { return m_DCD; }
auto& DCD() { return m_DCD; }
// Transmit clock, (I) Active high
PinLevel& RXCLK() { return m_RXCLK; }
auto& RXCLK() { return m_RXCLK; }
// Receive clock, (I) Active high
PinLevel& TXCLK() { return m_TXCLK; }
auto& TXCLK() { return m_TXCLK; }
// Chip select, bit 0, (I) Active high
PinLevel& CS0() { return m_CS0; }
auto& CS0() { return m_CS0; }
// Chip select, bit 1, (I) Active high
PinLevel& CS1() { return m_CS1; }
auto& CS1() { return m_CS1; }
// Chip select, bit 2, (I) Active low
PinLevel& CS2() { return m_CS2; }
auto& CS2() { return m_CS2; }
// Register select, (I) Active high
PinLevel& RS() { return m_RS; }
auto& RS() { return m_RS; }
// Read/Write, (I) Read high, write low
PinLevel& RW() { return m_RW; }
auto& RW() { return m_RW; }
// ACIA Enable, (I) Active high
PinLevel& E() { return m_E; }
auto& E() { return m_E; }
// Interrupt request, (O) Active low
PinLevel& IRQ() { return m_IRQ; }
auto& IRQ() { return m_IRQ; }
// Data, (I/O)
uint8_t& DATA() { return m_data; }
auto& DATA() { return m_data; }
// Expose these internal registers, so we can update internal state
// Transmit data register;
uint8_t& TDR() { return m_TDR; }
auto& TDR() { return m_TDR; }
// Receive data register;
uint8_t& RDR() { return m_RDR; }
auto& RDR() { return m_RDR; }
bool access();
bool tick();
bool selected();
@ -272,12 +272,19 @@ namespace EightBit {
bool isTransmitInterruptRequired() const;
bool isReceiveInterruptRequired() const;
bool transmitInterruptEnabled() const { return m_transmitControl == ReadyLowInterruptEnabled; }
bool receiveInterruptEnabled() const { return m_receiveControl == ReceiveInterruptEnable; }
bool transmitReadyHigh() const { return m_transmitControl == ReadyHighInterruptDisabled; }
bool transmitReadyLow() const { return !transmitReadyHigh(); }
PinLevel m_RXDATA;
PinLevel m_TXDATA;
PinLevel m_RTS;
PinLevel m_CTS;
PinLevel m_DCD;
PinLevel m_oldDCD; // So we can detect low -> high transition
PinLevel m_RXCLK;
PinLevel m_TXCLK;
@ -294,6 +301,8 @@ namespace EightBit {
uint8_t m_data;
bool m_statusRead = false;
// Control registers
CounterDivideSelect m_counterDivide;
WordSelect m_wordSelect;

Binary file not shown.