mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-11-08 22:06:20 +00:00
Match the GameBoy code to the updated handling of reset (etc.) interrupts.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
6d4223c368
commit
17c46264e9
@ -40,10 +40,12 @@ namespace EightBit {
|
|||||||
virtual register16_t& HL() final { return hl; }
|
virtual register16_t& HL() final { return hl; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void reset() final;
|
|
||||||
virtual int execute(uint8_t opcode) final;
|
virtual int execute(uint8_t opcode) final;
|
||||||
virtual int step() final;
|
virtual int step() final;
|
||||||
|
|
||||||
|
virtual void handleRESET() override;
|
||||||
|
virtual void handleINT() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Bus& m_bus;
|
Bus& m_bus;
|
||||||
|
|
||||||
|
@ -9,11 +9,19 @@ EightBit::GameBoy::LR35902::LR35902(Bus& memory)
|
|||||||
m_bus(memory) {
|
m_bus(memory) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EightBit::GameBoy::LR35902::reset() {
|
void EightBit::GameBoy::LR35902::handleRESET() {
|
||||||
IntelProcessor::reset();
|
Processor::handleRESET();
|
||||||
di();
|
di();
|
||||||
SP() = Mask16 - 1;
|
SP() = Mask16 - 1;
|
||||||
m_prefixCB = false;
|
addCycles(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EightBit::GameBoy::LR35902::handleINT() {
|
||||||
|
Processor::handleINT();
|
||||||
|
raise(HALT());
|
||||||
|
di();
|
||||||
|
restart(BUS().DATA());
|
||||||
|
addCycles(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EightBit::GameBoy::LR35902::di() {
|
void EightBit::GameBoy::LR35902::di() {
|
||||||
@ -282,7 +290,6 @@ int EightBit::GameBoy::LR35902::step() {
|
|||||||
ExecutingInstruction.fire(*this);
|
ExecutingInstruction.fire(*this);
|
||||||
m_prefixCB = false;
|
m_prefixCB = false;
|
||||||
resetCycles();
|
resetCycles();
|
||||||
int ran = 0;
|
|
||||||
if (LIKELY(powered())) {
|
if (LIKELY(powered())) {
|
||||||
|
|
||||||
const auto interruptEnable = BUS().peek(IoRegisters::BASE + IoRegisters::IE);
|
const auto interruptEnable = BUS().peek(IoRegisters::BASE + IoRegisters::IE);
|
||||||
@ -301,24 +308,22 @@ int EightBit::GameBoy::LR35902::step() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UNLIKELY(lowered(INT()))) {
|
if (UNLIKELY(lowered(RESET()))) {
|
||||||
raise(HALT());
|
handleRESET();
|
||||||
raise(INT());
|
} else if (UNLIKELY(lowered(INT()))) {
|
||||||
di();
|
handleINT();
|
||||||
restart(BUS().DATA());
|
|
||||||
ran = 4;
|
|
||||||
} else if (UNLIKELY(lowered(HALT()))) {
|
} else if (UNLIKELY(lowered(HALT()))) {
|
||||||
ran = execute(0); // NOP
|
execute(0); // NOP
|
||||||
} else {
|
} else {
|
||||||
ran = execute(fetchByte());
|
execute(fetchByte());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bus.IO().checkTimers(ran);
|
m_bus.IO().checkTimers(clockCycles());
|
||||||
m_bus.IO().transferDma();
|
m_bus.IO().transferDma();
|
||||||
|
|
||||||
}
|
}
|
||||||
ExecutedInstruction.fire(*this);
|
ExecutedInstruction.fire(*this);
|
||||||
return ran;
|
return clockCycles();
|
||||||
}
|
}
|
||||||
|
|
||||||
int EightBit::GameBoy::LR35902::execute(uint8_t opcode) {
|
int EightBit::GameBoy::LR35902::execute(uint8_t opcode) {
|
||||||
|
Loading…
Reference in New Issue
Block a user