Revert "improve(?) irq handling"

This reverts commit 443ecb313d.
This commit is contained in:
Jaklyy 2024-12-15 21:48:27 -05:00
parent 93242e1189
commit c96b49e9cd
3 changed files with 16 additions and 25 deletions

View File

@ -160,7 +160,6 @@ void ARM::Reset()
Halted = 0;
DataCycles = 0;
IRQTimestamp = -1;
IRQ = 0;
for (int i = 0; i < 16; i++)
@ -706,7 +705,7 @@ void ARMv5::StartExecTHUMB()
else NullFetch = false;
PC = R[15];
if (!(CPSR & 0x80) && (NDS.ARM9Timestamp > IRQTimestamp)) TriggerIRQ<CPUExecuteMode::Interpreter>();
if (IRQ && !(CPSR & 0x80)) TriggerIRQ<CPUExecuteMode::Interpreter>();
else if (CurInstr > 0xFFFFFFFF) [[unlikely]] // handle aborted instructions
{
PrefetchAbort();
@ -729,7 +728,7 @@ void ARMv5::StartExecARM()
NullFetch = false;
PC = R[15];
if (!(CPSR & 0x80) && (NDS.ARM9Timestamp > IRQTimestamp)) TriggerIRQ<CPUExecuteMode::Interpreter>();
if (IRQ && !(CPSR & 0x80)) TriggerIRQ<CPUExecuteMode::Interpreter>();
else if (CurInstr & ((u64)1<<63)) [[unlikely]] // handle aborted instructions
{
PrefetchAbort();
@ -772,13 +771,14 @@ void ARMv5::Execute()
else if (NDS.HaltInterrupted(0))
{
Halted = 0;
NDS.ARM9Timestamp = IRQTimestamp;
#ifdef JIT_ENABLED
if (NDS.IME[0] & 0x1)
{
#ifdef JIT_ENABLED
if constexpr (mode == CPUExecuteMode::JIT) TriggerIRQ<mode>();
}
else
#endif
IRQ = 1;
}
}
else
{
@ -921,7 +921,7 @@ void ARMv4::StartExecTHUMB()
CodeRead16(R[15]);
QueueFunction(&ARMv4::UpdateNextInstr1);
if (!(CPSR & 0x80) && (NDS.ARM7Timestamp > IRQTimestamp)) TriggerIRQ<CPUExecuteMode::Interpreter>();
if (IRQ && !(CPSR & 0x80)) TriggerIRQ<CPUExecuteMode::Interpreter>();
else
{
// actually execute
@ -939,7 +939,7 @@ void ARMv4::StartExecARM()
CodeRead32(R[15]);
QueueFunction(&ARMv4::UpdateNextInstr1);
if (!(CPSR & 0x80) && (NDS.ARM7Timestamp > IRQTimestamp)) TriggerIRQ<CPUExecuteMode::Interpreter>();
if (IRQ && !(CPSR & 0x80)) TriggerIRQ<CPUExecuteMode::Interpreter>();
else if (CheckCondition(CurInstr >> 28)) // actually execute
{
u32 icode = ((CurInstr >> 4) & 0xF) | ((CurInstr >> 16) & 0xFF0);
@ -964,16 +964,13 @@ void ARMv4::Execute()
else if (NDS.HaltInterrupted(1))
{
Halted = 0;
NDS.ARM7Timestamp = IRQTimestamp;
if (NDS.IME[1] & 0x1)
{
#ifdef JIT_ENABLED
if constexpr (mode == CPUExecuteMode::JIT) TriggerIRQ<mode>();
else
#endif
}
else
{
IRQTimestamp = -1;
IRQ = 1;
}
}
else

View File

@ -213,8 +213,6 @@ public:
u32 StopExecution;
};
u64 IRQTimestamp;
u32 CodeRegion;
s32 CodeCycles;

View File

@ -1838,7 +1838,7 @@ u32 NDS::RunFrame()
if (!MainRAMHandle()) break;
}
}
CurCPU = 2;
RunSystem(target);
if (CPUStop & CPUStop_Sleep)
@ -2160,20 +2160,16 @@ void NDS::SetGBASlotTimings()
void NDS::UpdateIRQ(u32 cpu)
{
ARM& arm = cpu ? (ARM&)ARM7 : (ARM&)ARM9;
u64 curtime = ((CurCPU == 2) ? SysTimestamp : ((CurCPU == 1) ? ARM7Timestamp : ((ARM9Timestamp + ((1<<ARM9ClockShift)-1)) >> ARM9ClockShift)));
if (!cpu) curtime <<= ARM9ClockShift;
if (IME[cpu] & 0x1 || (arm.Halted == 1))
if (IME[cpu] & 0x1)
{
//arm.IRQ = !!(IE[cpu] & IF[cpu]);
if (IE[cpu] & IF[cpu]) { if (curtime < arm.IRQTimestamp) arm.IRQTimestamp = curtime; }
else arm.IRQTimestamp = -1;
if ((ConsoleType == 1) && cpu && (IE2 & IF2) && (curtime < arm.IRQTimestamp))
arm.IRQTimestamp = curtime;
arm.IRQ = !!(IE[cpu] & IF[cpu]);
if ((ConsoleType == 1) && cpu)
arm.IRQ |= !!(IE2 & IF2);
}
else
{
arm.IRQTimestamp = -1;
arm.IRQ = 0;
}
}