mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2026-03-12 10:41:58 +00:00
Start moving towards reset being just another style of interrupt.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
@@ -5,24 +5,30 @@ EightBit::Processor::Processor(Bus& bus)
|
||||
: m_bus(bus) {
|
||||
}
|
||||
|
||||
void EightBit::Processor::reset() {
|
||||
if (lowered(POWER()))
|
||||
throw std::logic_error("POWER cannot be low");
|
||||
void EightBit::Processor::powerOn() {
|
||||
raise(RESET());
|
||||
raise(HALT());
|
||||
raise(INT());
|
||||
raise(NMI());
|
||||
raise(POWER());
|
||||
}
|
||||
|
||||
void EightBit::Processor::handleRESET() {
|
||||
raise(RESET());
|
||||
PC() = 0;
|
||||
}
|
||||
|
||||
void EightBit::Processor::handleNMI() {
|
||||
raise(NMI());
|
||||
}
|
||||
|
||||
void EightBit::Processor::handleINT() {
|
||||
raise(INT());
|
||||
}
|
||||
|
||||
int EightBit::Processor::run(const int limit) {
|
||||
int current = 0;
|
||||
while (LIKELY(powered()) && current < limit)
|
||||
current += singleStep();
|
||||
current += step();
|
||||
return current;
|
||||
}
|
||||
|
||||
int EightBit::Processor::singleStep() {
|
||||
if (UNLIKELY(lowered(RESET())))
|
||||
reset();
|
||||
return step();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user