Add power support to processor base class.

Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian.Conlon 2017-08-31 12:13:00 +01:00
parent 20c126adfc
commit 1eb127ed72
5 changed files with 13 additions and 1 deletions

View File

@ -19,6 +19,7 @@ void Fuse::TestRunner::initialise() {
m_bus.disableGameRom();
initialiseRegisters();
initialiseMemory();
m_cpu.powerOn();
}
void Fuse::TestRunner::initialiseRegisters() {

View File

@ -18,6 +18,7 @@ Fuse::TestRunner::TestRunner(const Test& test, const ExpectedTestResult& expecte
void Fuse::TestRunner::initialise() {
initialiseRegisters();
initialiseMemory();
m_cpu.powerOn();
}
void Fuse::TestRunner::initialiseRegisters() {

View File

@ -61,6 +61,10 @@ namespace EightBit {
void halt() { --PC().word; m_halted = true; }
void proceed() { ++PC().word; m_halted = false; }
bool powered() const { return m_power; }
void powerOn() { m_power = true; }
void powerOff() { m_power = false; }
virtual void initialise();
void reset();
@ -102,6 +106,8 @@ namespace EightBit {
}
virtual int fetchExecute() {
if (!powered())
return 0;
return execute(fetchByte());
}
@ -142,5 +148,6 @@ namespace EightBit {
register16_t pc;
register16_t m_memptr;
bool m_halted;
bool m_power;
};
}

View File

@ -55,6 +55,8 @@ namespace EightBit {
m_startHostCycles = currentHostCycles();
auto& cpu = m_board.CPU();
cpu.powerOn();
while (!cpu.isHalted()) {
m_totalCycles += cpu.step();
++m_instructions;

View File

@ -4,7 +4,8 @@
EightBit::Processor::Processor(Memory& memory)
: m_memory(memory),
cycles(0),
m_halted(false) {
m_halted(false),
m_power(false) {
PC().word = 0;
}