From d77c2a1e9d0354c07a07207aaf50dd5af7d4e511 Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Sun, 23 Sep 2018 20:31:55 +0100 Subject: [PATCH] Add more of the MC6850 internals. Signed-off-by: Adrian Conlon --- MC6809/test/Board.cpp | 13 ++++++++----- MC6809/test/Board.h | 6 +++--- MC6809/test/test.cpp | 2 +- MC6850/inc/MC6850.h | 20 +++++++++++++++++++- MC6850/src/MC6850.cpp | Bin 1980 -> 3380 bytes inc/Processor.h | 22 +++++++++++----------- 6 files changed, 42 insertions(+), 21 deletions(-) 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 262a0f38195194931746946d830651ee5b422df3..ea1a82468d4f92b6c9371f48aaa683e2afdf4045 100644 GIT binary patch literal 3380 zcmb_fVNVl55S_1Q;(s_WAtf3G6fg=T2og;o!9wCka+bC>DTTCG2toe3`rb^ZyLVg* zwPv%lcio*g^XAR$^5^#p=}1o+(v_i{OH)!=lq)>{l-HPx@?4%t)tV#OlMQ(<>#`E9 ztX{nZdzlO{n$nkCcGN1@{*X(IE>J(ik2Vl<`Gjw|e89NCKF8oQ_jfTH_`L~lYqE@; zcWNzx#vEx`{KE(QK%&ua68R0LF_b$oOc>n60`_~@b ze+V9K5YI=&zt_KH=o;@ki1ldBbu8iVLp5#%gS!==Du0}T>M~u7)jn`BKIe2Nv zEhd#UC@880?)%CcYlJI1m{bt`x2G+9#{2pHB}NC9m_KSTAkLfL*pe&XP&~s6i0ewV z#H@xYp_)@=uUtXPk*9GD8Ovt90gFA2BaLeI1_-QGveSljGE_q7E6 zTlE&BFRn@C4MvJ?$4t>L>#Jqku1TvrazE7d^nM>m*O+z=ke7YgMa}PyGHM!PN3Ej* zQu(ELby*$vEvh|1JyfaXqO#jqKG>J0`$BJ4puJTLR}Qh9n`-N2j_i~O9Wu6b4+NeD z{MBpA;xVpn5LF-C7{lzMZ9Q$+-8vev#ZsHX+8Qi7Yj30P@4z5^-N8s@tq`H12c=yA zEyrNS%$JaDvNR2UJ;K~5V6InSQacSys-igq7WJ_i#j{zkZD$*qoy@pt`2b3X)g z9&?DW?Bi2zxm8?-e)NAl4tFW{xp;r}_(Da5m}a|?de&T*Wkx(Bai{jR)maOklx@w% UZj9o3VUO|uA<}UzIY);47jw7Wx&QzG delta 113 zcmdlYwTFMhGsej!To#izFmrAG$8?Tq@*mbH_DqH}1_cI<$-h~ZC$D1Tnf!oFN1l_R zh#{4sgrO8j=P_6_@G@{QaDrhih&@@6y?OF7_M*vB91)XMI3*@?acNDK;SAsb%Q8Sn E0Bk86t^fc4 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;