diff --git a/MC6809/test/Board.cpp b/MC6809/test/Board.cpp index 686df01..5b11644 100644 --- a/MC6809/test/Board.cpp +++ b/MC6809/test/Board.cpp @@ -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(); -} \ No newline at end of file +} + +bool Board::accessAcia() { + ACIA().raise(ACIA().E()); + const bool accessed = ACIA().tick(); + ACIA().lower(ACIA().E()); + return accessed; +} diff --git a/MC6809/test/Board.h b/MC6809/test/Board.h index 34def79..bece7aa 100644 --- a/MC6809/test/Board.h +++ b/MC6809/test/Board.h @@ -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(); }; diff --git a/MC6850/inc/MC6850.h b/MC6850/inc/MC6850.h index 51c5796..b899293 100644 --- a/MC6850/inc/MC6850.h +++ b/MC6850/inc/MC6850.h @@ -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; diff --git a/MC6850/src/MC6850.cpp b/MC6850/src/MC6850.cpp index bf7695a..b9b7c6c 100644 Binary files a/MC6850/src/MC6850.cpp and b/MC6850/src/MC6850.cpp differ