mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2026-03-12 10:41:58 +00:00
1) No forward declarations 2) No virtual methods defined inline. Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
46 lines
818 B
C++
46 lines
818 B
C++
#include "stdafx.h"
|
|
#include "Processor.h"
|
|
|
|
EightBit::Processor::Processor(Bus& bus)
|
|
: m_bus(bus),
|
|
m_cycles(0),
|
|
m_halted(false),
|
|
m_power(false) {
|
|
PC().word = MEMPTR().word = 0;
|
|
}
|
|
|
|
void EightBit::Processor::reset() {
|
|
PC().word = MEMPTR().word = 0;
|
|
}
|
|
|
|
void EightBit::Processor::initialise() {
|
|
reset();
|
|
}
|
|
|
|
int EightBit::Processor::run(int limit) {
|
|
int current = 0;
|
|
while (powered() && current < limit) {
|
|
current += singleStep();
|
|
}
|
|
return current;
|
|
}
|
|
|
|
int EightBit::Processor::singleStep() {
|
|
return step();
|
|
}
|
|
|
|
uint8_t EightBit::Processor::fetchByte() {
|
|
return getByte(PC().word++);
|
|
}
|
|
|
|
void EightBit::Processor::fetchWord(register16_t& output) {
|
|
output.low = fetchByte();
|
|
output.high = fetchByte();
|
|
}
|
|
|
|
int EightBit::Processor::fetchExecute() {
|
|
if (!powered())
|
|
return 0;
|
|
return execute(fetchByte());
|
|
}
|