mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-02-22 20:28:58 +00:00
Sort out why cycle counting wasn't working as I thought it should on the MC6809
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
fc7b6e49ca
commit
edbc2784d9
@ -15,9 +15,9 @@ void EightBit::mc6809::powerOn() {
|
|||||||
|
|
||||||
int EightBit::mc6809::step() {
|
int EightBit::mc6809::step() {
|
||||||
resetCycles();
|
resetCycles();
|
||||||
|
ExecutingInstruction.fire(*this);
|
||||||
if (LIKELY(powered())) {
|
if (LIKELY(powered())) {
|
||||||
m_prefix10 = m_prefix11 = false;
|
m_prefix10 = m_prefix11 = false;
|
||||||
ExecutingInstruction.fire(*this);
|
|
||||||
if (UNLIKELY(lowered(HALT())))
|
if (UNLIKELY(lowered(HALT())))
|
||||||
handleHALT();
|
handleHALT();
|
||||||
else if (UNLIKELY(lowered(RESET())))
|
else if (UNLIKELY(lowered(RESET())))
|
||||||
@ -30,8 +30,8 @@ int EightBit::mc6809::step() {
|
|||||||
handleIRQ();
|
handleIRQ();
|
||||||
else
|
else
|
||||||
execute(fetchByte());
|
execute(fetchByte());
|
||||||
ExecutedInstruction.fire(*this);
|
|
||||||
}
|
}
|
||||||
|
ExecutedInstruction.fire(*this);
|
||||||
return cycles();
|
return cycles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +51,7 @@ void EightBit::mc6809::handleRESET() {
|
|||||||
setFlag(CC(), IF); // Disable IRQ
|
setFlag(CC(), IF); // Disable IRQ
|
||||||
setFlag(CC(), FF); // Disable FIRQ
|
setFlag(CC(), FF); // Disable FIRQ
|
||||||
jump(getWordPaged(0xff, RESETvector));
|
jump(getWordPaged(0xff, RESETvector));
|
||||||
|
addCycles(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EightBit::mc6809::handleNMI() {
|
void EightBit::mc6809::handleNMI() {
|
||||||
|
@ -44,7 +44,7 @@ void Board::initialise() {
|
|||||||
CPU().ExecutedInstruction.connect(std::bind(&Board::Cpu_ExecutedInstruction_Debug, this, std::placeholders::_1));
|
CPU().ExecutedInstruction.connect(std::bind(&Board::Cpu_ExecutedInstruction_Debug, this, std::placeholders::_1));
|
||||||
}
|
}
|
||||||
if (m_configuration.terminatesEarly())
|
if (m_configuration.terminatesEarly())
|
||||||
CPU().ExecutingInstruction.connect(std::bind(&Board::Cpu_ExecutedInstruction_Terminator, this, std::placeholders::_1));
|
CPU().ExecutedInstruction.connect(std::bind(&Board::Cpu_ExecutedInstruction_Terminator, this, std::placeholders::_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Board::Cpu_ExecutingInstruction_Debug(EightBit::mc6809&) {
|
void Board::Cpu_ExecutingInstruction_Debug(EightBit::mc6809&) {
|
||||||
@ -95,14 +95,15 @@ void Board::updateAciaPins(const EightBit::Chip::PinLevel rw) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Board::Cpu_ExecutedInstruction_Terminator(EightBit::mc6809&) {
|
void Board::Cpu_ExecutedInstruction_Terminator(EightBit::mc6809&) {
|
||||||
|
assert(CPU().cycles() > 0);
|
||||||
|
m_totalCycleCount += CPU().cycles();
|
||||||
if (m_totalCycleCount > Configuration::TerminationCycles)
|
if (m_totalCycleCount > Configuration::TerminationCycles)
|
||||||
CPU().powerOff();
|
CPU().powerOff();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Board::Cpu_ExecutedInstruction_Acia(EightBit::mc6809&) {
|
void Board::Cpu_ExecutedInstruction_Acia(EightBit::mc6809&) {
|
||||||
const auto cycles = CPU().cycles();
|
assert(CPU().cycles() > 0);
|
||||||
m_totalCycleCount += cycles;
|
m_frameCycleCount -= CPU().cycles();
|
||||||
m_frameCycleCount -= cycles;
|
|
||||||
if (m_frameCycleCount < 0) {
|
if (m_frameCycleCount < 0) {
|
||||||
if (_kbhit()) {
|
if (_kbhit()) {
|
||||||
ACIA().RDR() = _getch();
|
ACIA().RDR() = _getch();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user