From f58e3ded831e97509f32ec3d4f09ff91b7e72c67 Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Sun, 30 Sep 2018 23:10:03 +0100 Subject: [PATCH] Use corrected MC6850 in MC6809 test board. Working a little better now. Signed-off-by: Adrian Conlon --- MC6809/test/Board.cpp | 26 +++++++++++--------------- MC6809/test/Board.h | 22 ++++++++++------------ 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/MC6809/test/Board.cpp b/MC6809/test/Board.cpp index 5527d7c..c2639ae 100644 --- a/MC6809/test/Board.cpp +++ b/MC6809/test/Board.cpp @@ -32,7 +32,7 @@ void Board::initialise() { ACIA().DATA() = EightBit::mc6850::CR0 | EightBit::mc6850::CR1; // Master reset // Get the reset out of the way... - ACIA().step(1); + ACIA().access(); // Once the reset has completed, we can wire the ACIA event handlers... ACIA().Accessing.connect(std::bind(&Board::Acia_Accessing, this, std::placeholders::_1)); @@ -63,13 +63,7 @@ void Board::Cpu_ExecutingInstruction_Debug(EightBit::mc6809&) { void Board::Cpu_ExecutedInstruction_Debug(EightBit::mc6809&) { if (!m_ignoreDisassembly) - std::cout << m_disassembler.trace(m_disassembleAt) << std::endl; -} - -void Board::Cpu_ExecutedInstruction_die(EightBit::mc6809&) { - static uint64_t instructions = 0UL; - if (++instructions > 90000000) - CPU().powerOff(); + std::cout << m_disassembler.trace(m_disassembleAt) << " " << ACIA().dumpStatus() << std::endl; } EightBit::MemoryMapping Board::mapping(uint16_t address) { @@ -88,13 +82,15 @@ EightBit::MemoryMapping Board::mapping(uint16_t address) { void Board::Bus_WrittenByte_Acia(EightBit::EventArgs&) { updateAciaPins(EightBit::Chip::Low); - if (ACIA().selected()) + if (ACIA().selected()) { ACIA().DATA() = peek(ADDRESS()); + ACIA().access(); + } } void Board::Bus_ReadingByte_Acia(EightBit::EventArgs&) { updateAciaPins(EightBit::Chip::High); - if (ACIA().selected()) + if (ACIA().access()) poke(ADDRESS(), ACIA().DATA()); } @@ -108,14 +104,14 @@ void Board::updateAciaPins(const EightBit::Chip::PinLevel rw) { } void Board::Cpu_ExecutedInstruction_Acia(EightBit::mc6809&) { - ACIA().step(CPU().cycles()); + if (_kbhit()) { + ACIA().RDR() = _getch(); + _getch(); // XXXX Why do I need the second getch?? + ACIA().markReceiveStarting(); + } } void Board::Acia_Accessing(EightBit::EventArgs&) { - if (_kbhit()) { - ACIA().RDR() = _getch(); - ACIA().markReceiveStarting(); - } } void Board::Acia_Accessed(EightBit::EventArgs&) { diff --git a/MC6809/test/Board.h b/MC6809/test/Board.h index 7a877d2..99ccce6 100644 --- a/MC6809/test/Board.h +++ b/MC6809/test/Board.h @@ -23,15 +23,6 @@ protected: virtual EightBit::MemoryMapping mapping(uint16_t address) final; private: - - enum { - Uart = 0xa000, - Ustat = Uart, - Uctrl = Uart, - Recev = Uart + 1, - Trans = Uart + 1, - }; - const Configuration& m_configuration; EightBit::Ram m_ram = 0x8000; // 0000 - 7FFF, 32K RAM EightBit::Rom m_unused2000 = 0x2000; // 8000 - 9FFF, 8K unused @@ -46,17 +37,23 @@ private: EightBit::register16_t m_disassembleAt = 0x0000; bool m_ignoreDisassembly = false; + // CPU events + void Cpu_ExecutingInstruction_Debug(EightBit::mc6809&); void Cpu_ExecutedInstruction_Debug(EightBit::mc6809&); - void Cpu_ExecutedInstruction_die(EightBit::mc6809&); + // Allows us to step the ACIA + void Cpu_ExecutedInstruction_Acia(EightBit::mc6809&); - // ACIA handling + // Bus events + // Allows us to marshal data from memory -> ACIA void Bus_WrittenByte_Acia(EightBit::EventArgs&); + + // Allows us to marshal data from ACIA -> memory void Bus_ReadingByte_Acia(EightBit::EventArgs&); - void Cpu_ExecutedInstruction_Acia(EightBit::mc6809&); + // ACIA events void Acia_Accessing(EightBit::EventArgs&); void Acia_Accessed(EightBit::EventArgs&); @@ -67,5 +64,6 @@ private: void Acia_Receiving(EightBit::EventArgs&); void Acia_Received(EightBit::EventArgs&); + // Use the bus data to update the ACIA access/address pins void updateAciaPins(EightBit::Chip::PinLevel rw); };