Tidy MC6809 test board/device access.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2018-10-20 16:57:32 +01:00
parent dbc3e192d7
commit 9b0cc4542f
2 changed files with 21 additions and 32 deletions

View File

@ -35,14 +35,7 @@ void Board::initialise() {
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));
ACIA().Accessed.connect(std::bind(&Board::Acia_Accessed, this, std::placeholders::_1));
ACIA().Transmitting.connect(std::bind(&Board::Acia_Transmitting, this, std::placeholders::_1));
ACIA().Transmitted.connect(std::bind(&Board::Acia_Transmitted, this, std::placeholders::_1));
ACIA().Receiving.connect(std::bind(&Board::Acia_Receiving, this, std::placeholders::_1));
ACIA().Received.connect(std::bind(&Board::Acia_Received, this, std::placeholders::_1));
// Wire bus events...
WrittenByte.connect(std::bind(&Board::Bus_WrittenByte_Acia, this, std::placeholders::_1));
@ -104,28 +97,23 @@ void Board::updateAciaPins(const EightBit::Chip::PinLevel rw) {
}
void Board::Cpu_ExecutedInstruction_Acia(EightBit::mc6809&) {
if (_kbhit()) {
ACIA().RDR() = _getch();
ACIA().markReceiveStarting();
const auto cycles = CPU().cycles();
m_totalCycleCount += cycles;
if (m_totalCycleCount < TerminationCycles) {
m_frameCycleCount -= cycles;
if (m_frameCycleCount < 0) {
if (_kbhit()) {
ACIA().RDR() = _getch();
ACIA().markReceiveStarting();
}
m_frameCycleCount = FrameCycleInterval;
}
} else {
CPU().powerOff();
}
}
void Board::Acia_Accessing(EightBit::EventArgs&) {
}
void Board::Acia_Accessed(EightBit::EventArgs&) {
}
void Board::Acia_Transmitting(EightBit::EventArgs&) {
std::cout << ACIA().TDR();
ACIA().markTransmitComplete();
}
void Board::Acia_Transmitted(EightBit::EventArgs&) {
}
void Board::Acia_Receiving(EightBit::EventArgs&) {
}
void Board::Acia_Received(EightBit::EventArgs&) {
}

View File

@ -34,6 +34,13 @@ private:
EightBit::mc6809 m_cpu;
EightBit::Disassembly m_disassembler;
uint64_t m_totalCycleCount = 0UL;
int64_t m_frameCycleCount = 0UL;
static constexpr uint64_t CyclesPerSecond = 2 * 1024 * 1024;
static constexpr uint64_t FrameCycleInterval = CyclesPerSecond / 60;
static constexpr uint64_t TerminationCycles = CyclesPerSecond * 10 * 10;
// The m_disassembleAt and m_ignoreDisassembly are used to skip pin events
EightBit::register16_t m_disassembleAt = 0x0000;
bool m_ignoreDisassembly = false;
@ -55,14 +62,8 @@ private:
// ACIA events
void Acia_Accessing(EightBit::EventArgs&);
void Acia_Accessed(EightBit::EventArgs&);
// Allows us to catch a byte being transmitted
void Acia_Transmitting(EightBit::EventArgs&);
void Acia_Transmitted(EightBit::EventArgs&);
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);