2017-06-04 20:38:34 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "Processor.h"
|
|
|
|
|
2017-09-06 12:22:23 +00:00
|
|
|
EightBit::Processor::Processor(Bus& bus)
|
2017-11-10 22:41:50 +00:00
|
|
|
: m_bus(bus) {
|
2017-06-04 20:38:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EightBit::Processor::reset() {
|
2017-09-01 15:01:40 +00:00
|
|
|
PC().word = MEMPTR().word = 0;
|
2017-06-04 20:38:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EightBit::Processor::initialise() {
|
|
|
|
reset();
|
|
|
|
}
|
2017-08-30 22:17:34 +00:00
|
|
|
|
|
|
|
int EightBit::Processor::run(int limit) {
|
|
|
|
int current = 0;
|
2017-11-20 19:17:49 +00:00
|
|
|
while (LIKELY(powered()) && current < limit) {
|
2017-08-30 22:17:34 +00:00
|
|
|
current += singleStep();
|
2017-08-31 16:19:32 +00:00
|
|
|
}
|
2017-08-30 22:17:34 +00:00
|
|
|
return current;
|
|
|
|
}
|
|
|
|
|
|
|
|
int EightBit::Processor::singleStep() {
|
|
|
|
return step();
|
|
|
|
}
|
2017-11-05 12:47:42 +00:00
|
|
|
|
|
|
|
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() {
|
2017-11-20 19:17:49 +00:00
|
|
|
if (LIKELY(powered()))
|
2017-11-18 14:29:30 +00:00
|
|
|
return execute(fetchByte());
|
|
|
|
return 0;
|
2017-11-05 12:47:42 +00:00
|
|
|
}
|