mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-01-12 08:29:50 +00:00
First stage "halt" reimplementation: allow the clock to run during halt, but nothing else.
Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
parent
42b0fdc23d
commit
57e48e389f
@ -335,23 +335,24 @@ int EightBit::LR35902::run(int limit) {
|
|||||||
do {
|
do {
|
||||||
auto interruptEnable = m_bus.readRegister(Bus::IE);
|
auto interruptEnable = m_bus.readRegister(Bus::IE);
|
||||||
auto interruptFlags = m_bus.readRegister(Bus::IF);
|
auto interruptFlags = m_bus.readRegister(Bus::IF);
|
||||||
|
auto ime = IME();
|
||||||
|
|
||||||
auto masked = (IME() ? interruptEnable : 0) & interruptFlags;
|
auto masked = interruptEnable & interruptFlags;
|
||||||
if (masked)
|
if (ime && masked)
|
||||||
m_bus.writeRegister(Bus::IF, 0);
|
m_bus.writeRegister(Bus::IF, 0);
|
||||||
|
|
||||||
if (masked & Bus::Interrupts::VerticalBlank) {
|
if (ime && (masked & Bus::Interrupts::VerticalBlank)) {
|
||||||
current += interrupt(0x40);
|
current += interrupt(0x40);
|
||||||
} else if (masked & Bus::Interrupts::DisplayControlStatus) {
|
} else if (ime && (masked & Bus::Interrupts::DisplayControlStatus)) {
|
||||||
current += interrupt(0x48);
|
current += interrupt(0x48);
|
||||||
} else if (masked & Bus::Interrupts::TimerOverflow) {
|
} else if (ime && (masked & Bus::Interrupts::TimerOverflow)) {
|
||||||
current += interrupt(0x50);
|
current += interrupt(0x50);
|
||||||
} else if (masked & Bus::Interrupts::SerialTransfer) {
|
} else if (ime && (masked & Bus::Interrupts::SerialTransfer)) {
|
||||||
current += interrupt(0x58);
|
current += interrupt(0x58);
|
||||||
} else if (masked & Bus::Interrupts::Keypad) {
|
} else if (ime && (masked & Bus::Interrupts::Keypad)) {
|
||||||
current += interrupt(0x60);
|
current += interrupt(0x60);
|
||||||
} else {
|
} else {
|
||||||
current += step();
|
current += isHalted() ? 1 : step();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bus.checkTimers(current);
|
m_bus.checkTimers(current);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user