mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-12-23 00:29:47 +00:00
Add power support to processor base class.
Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
parent
20c126adfc
commit
1eb127ed72
@ -19,6 +19,7 @@ void Fuse::TestRunner::initialise() {
|
||||
m_bus.disableGameRom();
|
||||
initialiseRegisters();
|
||||
initialiseMemory();
|
||||
m_cpu.powerOn();
|
||||
}
|
||||
|
||||
void Fuse::TestRunner::initialiseRegisters() {
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
};
|
||||
}
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user