diff --git a/MC6809/test/Board.cpp b/MC6809/test/Board.cpp index cbd105c..230a7de 100644 --- a/MC6809/test/Board.cpp +++ b/MC6809/test/Board.cpp @@ -33,6 +33,10 @@ void Board::initialise() { CPU().reset(); ACIA().powerOn(); + ACIA().RW() = EightBit::Chip::PinLevel::Low; // Write + ACIA().RS() = EightBit::Chip::PinLevel::Low; // Registers + EightBit::Processor::setFlag(ACIA().DATA(), EightBit::mc6850::CR0 | EightBit::mc6850::CR1); + ACIA().step(1); // Get the reset out of the way... } void Board::Cpu_ExecutingInstruction_Debug(EightBit::mc6809&) { @@ -66,16 +70,15 @@ EightBit::MemoryMapping Board::mapping(uint16_t address) { } void Board::Bus_WritingByte_Acia(EightBit::EventArgs&) { - ACIA().RW() = EightBit::Chip::Low; - updateAciaPins(); + updateAciaPins(EightBit::Chip::Low); } void Board::Bus_ReadingByte_Acia(EightBit::EventArgs&) { - ACIA().RW() = EightBit::Chip::High; - updateAciaPins(); + updateAciaPins(EightBit::Chip::High); } -void Board::updateAciaPins() { +void Board::updateAciaPins(const EightBit::Chip::PinLevel rw) { + ACIA().RW() = rw; ACIA().DATA() = DATA(); ACIA().RS() = ADDRESS().word & EightBit::Chip::Bit0 ? EightBit::Chip::PinLevel::High : EightBit::Chip::PinLevel::Low; ACIA().CS0() = ADDRESS().word & EightBit::Chip::Bit15 ? EightBit::Chip::PinLevel::High : EightBit::Chip::PinLevel::Low; diff --git a/MC6809/test/Board.h b/MC6809/test/Board.h index c21c60f..f93e10a 100644 --- a/MC6809/test/Board.h +++ b/MC6809/test/Board.h @@ -48,8 +48,8 @@ private: void pollKeyboard(); - void Cpu_ExecutingInstruction_Debug(EightBit::mc6809& cpu); - void Cpu_ExecutedInstruction_Debug(EightBit::mc6809& cpu); + void Cpu_ExecutingInstruction_Debug(EightBit::mc6809&); + void Cpu_ExecutedInstruction_Debug(EightBit::mc6809&); void Cpu_ExecutedInstruction_die(EightBit::mc6809&); @@ -60,5 +60,5 @@ private: void Cpu_ExecutedInstruction_Acia(EightBit::mc6809&); - void updateAciaPins(); + void updateAciaPins(EightBit::Chip::PinLevel rw); }; diff --git a/MC6809/test/test.cpp b/MC6809/test/test.cpp index a2ef3e3..13bf177 100644 --- a/MC6809/test/test.cpp +++ b/MC6809/test/test.cpp @@ -11,7 +11,7 @@ int main(int argc, char* argv[]) { Configuration configuration; #ifdef _DEBUG - //configuration.setDebugMode(true); + configuration.setDebugMode(true); #endif //configuration.setDebugMode(true); diff --git a/MC6850/inc/MC6850.h b/MC6850/inc/MC6850.h index dce918e..73c0442 100644 --- a/MC6850/inc/MC6850.h +++ b/MC6850/inc/MC6850.h @@ -94,13 +94,25 @@ namespace EightBit { void step(int cycles); + // External access to RDR + void fillRDR(uint8_t data); + private: + uint8_t& TDR() { return m_TDR; } // Transmit data register; + uint8_t& RDR() { return m_RDR; } // Receive data register; + + uint8_t& status() { return m_status; } + bool selected(); void reset(); void step(); + uint8_t drainRDR(); // External (hacked!) access to RDR + void fillTDR(uint8_t data); // External (hacked!) access to TDR + uint8_t drainTDR(); // External (hacked!) access to TDR + PinLevel m_RXDATA; PinLevel m_TXDATA; @@ -130,6 +142,12 @@ namespace EightBit { int m_receiveControl; // Status registers - bool m_RDRF; + uint8_t m_status; + + // Data registers + uint8_t m_TDR; + uint8_t m_RDR; + + bool m_firstMasterReset = false; }; } diff --git a/MC6850/src/MC6850.cpp b/MC6850/src/MC6850.cpp index 262a0f3..ea1a824 100644 Binary files a/MC6850/src/MC6850.cpp and b/MC6850/src/MC6850.cpp differ diff --git a/inc/Processor.h b/inc/Processor.h index f136bec..f150d1a 100644 --- a/inc/Processor.h +++ b/inc/Processor.h @@ -11,6 +11,17 @@ namespace EightBit { class Processor : public Chip { public: + static void clearFlag(uint8_t& f, const int flag) { f &= ~flag; } + static void setFlag(uint8_t& f, const int flag) { f |= flag; } + + static void setFlag(uint8_t& f, const int flag, const int condition) { setFlag(f, flag, !!condition); } + static void setFlag(uint8_t& f, const int flag, const uint32_t condition) { setFlag(f, flag, !!condition); } + static void setFlag(uint8_t& f, const int flag, const bool condition) { condition ? setFlag(f, flag) : clearFlag(f, flag); } + + static void clearFlag(uint8_t& f, const int flag, const int condition) { clearFlag(f, flag, !!condition); } + static void clearFlag(uint8_t& f, const int flag, const uint32_t condition) { clearFlag(f, flag, !!condition); } + static void clearFlag(uint8_t& f, const int flag, const bool condition) { setFlag(f, flag, !condition); } + // b: number of bits representing the number in x // x: sign extend this b-bit number to r static int8_t signExtend(int b, uint8_t x); @@ -36,17 +47,6 @@ namespace EightBit { virtual register16_t peekWord(register16_t address) = 0; protected: - static void clearFlag(uint8_t& f, const int flag) { f &= ~flag; } - static void setFlag(uint8_t& f, const int flag) { f |= flag; } - - static void setFlag(uint8_t& f, const int flag, const int condition) { setFlag(f, flag, !!condition); } - static void setFlag(uint8_t& f, const int flag, const uint32_t condition) { setFlag(f, flag, !!condition); } - static void setFlag(uint8_t& f, const int flag, const bool condition) { condition ? setFlag(f, flag) : clearFlag(f, flag); } - - static void clearFlag(uint8_t& f, const int flag, const int condition) { clearFlag(f, flag, !!condition); } - static void clearFlag(uint8_t& f, const int flag, const uint32_t condition) { clearFlag(f, flag, !!condition); } - static void clearFlag(uint8_t& f, const int flag, const bool condition) { setFlag(f, flag, !condition); } - Processor(Bus& memory); virtual ~Processor() = default;