mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-09-23 07:54:30 +00:00
d818095815
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
30 lines
537 B
C++
30 lines
537 B
C++
#include "stdafx.h"
|
|
#include "Processor.h"
|
|
|
|
EightBit::Processor::Processor(Bus& bus)
|
|
: m_bus(bus) {
|
|
}
|
|
|
|
void EightBit::Processor::reset() {
|
|
if (lowered(POWER()))
|
|
throw std::logic_error("POWER cannot be low");
|
|
raise(INT());
|
|
raise(NMI());
|
|
raise(RESET());
|
|
PC().word = 0;
|
|
}
|
|
|
|
int EightBit::Processor::run(int limit) {
|
|
int current = 0;
|
|
while (LIKELY(powered()) && current < limit) {
|
|
current += singleStep();
|
|
}
|
|
return current;
|
|
}
|
|
|
|
int EightBit::Processor::singleStep() {
|
|
if (UNLIKELY(lowered(RESET())))
|
|
reset();
|
|
return step();
|
|
}
|