This commit is contained in:
Adrian Conlon 2017-12-02 23:55:44 +00:00
commit 4f5e231dc4
4 changed files with 16 additions and 27 deletions

View File

@ -26,8 +26,7 @@ namespace EightBit {
Signal<Intel8080> ExecutingInstruction;
bool isInterruptable() const;
int interrupt(uint8_t value);
bool& INT() { return m_interruptLine; }
virtual int execute(uint8_t opcode);
int step();
@ -38,7 +37,8 @@ namespace EightBit {
virtual register16_t& HL() override;
private:
bool m_interrupt;
bool m_interruptEnable = false;
bool m_interruptLine = false;
InputOutput& m_ports;
register16_t af;

View File

@ -3,7 +3,6 @@
EightBit::Intel8080::Intel8080(Bus& bus, InputOutput& ports)
: IntelProcessor(bus),
m_interrupt(false),
m_ports(ports) {
bc.word = de.word = hl.word = Mask16;
}
@ -27,23 +26,11 @@ EightBit::register16_t& EightBit::Intel8080::HL() {
}
void EightBit::Intel8080::di() {
m_interrupt = false;
m_interruptEnable = false;
}
void EightBit::Intel8080::ei() {
m_interrupt = true;
}
int EightBit::Intel8080::interrupt(uint8_t value) {
if (isInterruptable()) {
di();
return execute(value);
}
return 0;
}
bool EightBit::Intel8080::isInterruptable() const {
return m_interrupt;
m_interruptEnable = true;
}
void EightBit::Intel8080::increment(uint8_t& f, uint8_t& operand) {
@ -278,7 +265,17 @@ void EightBit::Intel8080::readPort() {
int EightBit::Intel8080::step() {
ExecutingInstruction.fire(*this);
resetCycles();
return fetchExecute();
if (LIKELY(powered())) {
uint8_t instruction;
if (UNLIKELY(INT() && m_interruptEnable)) {
INT() = false;
di();
instruction = BUS().DATA();
} else {
instruction = fetchByte();
}
return execute(instruction);
}
}
int EightBit::Intel8080::execute(uint8_t opcode) {

View File

@ -99,8 +99,6 @@ namespace EightBit {
fetchWord(MEMPTR());
}
virtual int fetchExecute();
uint8_t getByte() { return BUS().read(); }
template<class T> uint8_t getByte(T offset) { return BUS().read(offset); }

View File

@ -33,9 +33,3 @@ void EightBit::Processor::fetchWord(register16_t& output) {
output.low = fetchByte();
output.high = fetchByte();
}
int EightBit::Processor::fetchExecute() {
if (LIKELY(powered()))
return execute(fetchByte());
return 0;
}