Emulator: Optimize interrupt request checking
This commit is contained in:
+6
-14
@@ -12,6 +12,7 @@
|
|||||||
#include "ruc/format/color.h"
|
#include "ruc/format/color.h"
|
||||||
#include "ruc/format/print.h"
|
#include "ruc/format/print.h"
|
||||||
#include "ruc/meta/assert.h"
|
#include "ruc/meta/assert.h"
|
||||||
|
#include "ruc/meta/core.h"
|
||||||
|
|
||||||
CPU::CPU(uint32_t frequency)
|
CPU::CPU(uint32_t frequency)
|
||||||
: ProcessingUnit(frequency)
|
: ProcessingUnit(frequency)
|
||||||
@@ -95,20 +96,11 @@ void CPU::update()
|
|||||||
uint32_t interrupt_flag = Emu::the().readMemory(0xff0f) & 0x1f;
|
uint32_t interrupt_flag = Emu::the().readMemory(0xff0f) & 0x1f;
|
||||||
|
|
||||||
uint32_t interrupt = interrupt_enabled & interrupt_flag;
|
uint32_t interrupt = interrupt_enabled & interrupt_flag;
|
||||||
if (interrupt & InterruptRequest::VBlank) {
|
for (uint8_t i = 0; i < 5; ++i) {
|
||||||
handleInterrupt(interrupt_flag, InterruptRequest::VBlank, 0x40);
|
if (interrupt & BIT(i)) {
|
||||||
}
|
handleInterrupt(interrupt_flag, BIT(i), i * 8 + 0x40);
|
||||||
else if (interrupt & InterruptRequest::STAT) {
|
break;
|
||||||
handleInterrupt(interrupt_flag, InterruptRequest::STAT, 0x48);
|
}
|
||||||
}
|
|
||||||
else if (interrupt & InterruptRequest::Timer) {
|
|
||||||
handleInterrupt(interrupt_flag, InterruptRequest::Timer, 0x50);
|
|
||||||
}
|
|
||||||
else if (interrupt & InterruptRequest::Serial) {
|
|
||||||
handleInterrupt(interrupt_flag, InterruptRequest::Serial, 0x58);
|
|
||||||
}
|
|
||||||
else if (interrupt & InterruptRequest::Joypad) {
|
|
||||||
handleInterrupt(interrupt_flag, InterruptRequest::Joypad, 0x60);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,19 +13,6 @@
|
|||||||
|
|
||||||
#include "processing-unit.h"
|
#include "processing-unit.h"
|
||||||
#include "ruc/format/formatter.h"
|
#include "ruc/format/formatter.h"
|
||||||
#include "ruc/meta/core.h"
|
|
||||||
|
|
||||||
namespace InterruptRequest {
|
|
||||||
|
|
||||||
enum Enum : uint8_t {
|
|
||||||
VBlank = BIT(0),
|
|
||||||
STAT = BIT(1),
|
|
||||||
Timer = BIT(2),
|
|
||||||
Serial = BIT(3),
|
|
||||||
Joypad = BIT(4),
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace InterruptRequest
|
|
||||||
|
|
||||||
class CPU final : public ProcessingUnit {
|
class CPU final : public ProcessingUnit {
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user