diff --git a/src/arm/arm.h b/src/arm/arm.h index 99b3d5a1d..f17ea503b 100644 --- a/src/arm/arm.h +++ b/src/arm/arm.h @@ -93,6 +93,7 @@ struct ARMBoard { void (*processEvents)(struct ARMBoard* board); void (*swi16)(struct ARMBoard* board, int immediate); void (*swi32)(struct ARMBoard* board, int immediate); + void (*readCPSR)(struct ARMBoard* board); void (*hitStub)(struct ARMBoard* board, uint32_t opcode); }; diff --git a/src/arm/isa-inlines.h b/src/arm/isa-inlines.h index 9b48513a9..cee86e7d0 100644 --- a/src/arm/isa-inlines.h +++ b/src/arm/isa-inlines.h @@ -97,6 +97,7 @@ static inline void _ARMSetMode(struct ARMCore* cpu, enum ExecutionMode execution static inline void _ARMReadCPSR(struct ARMCore* cpu) { _ARMSetMode(cpu, cpu->cpsr.t); ARMSetPrivilegeMode(cpu, cpu->cpsr.priv); + cpu->board->readCPSR(cpu->board); } #endif diff --git a/src/gba/gba.c b/src/gba/gba.c index a9574f72d..73c3796dc 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -69,6 +69,7 @@ void GBABoardInit(struct GBABoard* board) { board->d.processEvents = GBAProcessEvents; board->d.swi16 = GBASwi16; board->d.swi32 = GBASwi32; + board->d.readCPSR = GBATestIRQ; board->d.hitStub = GBAHitStub; } @@ -372,13 +373,13 @@ void GBARaiseIRQ(struct GBA* gba, enum GBAIRQ irq) { } } -int GBATestIRQ(struct GBA* gba) { +void GBATestIRQ(struct ARMBoard* board) { + struct GBABoard* gbaBoard = (struct GBABoard*) board; + struct GBA* gba = gbaBoard->p; if (gba->memory.io[REG_IME >> 1] && gba->memory.io[REG_IE >> 1] & gba->memory.io[REG_IF >> 1]) { gba->springIRQ = 1; - gba->cpu.nextEvent = gba->cpu.cycles; - return 1; + gba->cpu.nextEvent = 0; } - return 0; } int GBAWaitForIRQ(struct GBA* gba) { diff --git a/src/gba/gba.h b/src/gba/gba.h index 88bc35b41..6484218ea 100644 --- a/src/gba/gba.h +++ b/src/gba/gba.h @@ -109,7 +109,7 @@ void GBATimerWriteTMCNT_HI(struct GBA* gba, int timer, uint16_t value); void GBAWriteIE(struct GBA* gba, uint16_t value); void GBAWriteIME(struct GBA* gba, uint16_t value); void GBARaiseIRQ(struct GBA* gba, enum GBAIRQ irq); -int GBATestIRQ(struct GBA* gba); +void GBATestIRQ(struct ARMBoard* board); int GBAWaitForIRQ(struct GBA* gba); int GBAHalt(struct GBA* gba);