fasterer IRQ check. clean up code.
This commit is contained in:
parent
8fc30d69c5
commit
00a5576492
31
src/ARM.cpp
31
src/ARM.cpp
|
@ -83,6 +83,8 @@ void ARM::Reset()
|
|||
Cycles = 0;
|
||||
Halted = 0;
|
||||
|
||||
IRQ = 0;
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
R[i] = 0;
|
||||
|
||||
|
@ -173,23 +175,6 @@ void ARMv5::JumpTo(u32 addr, bool restorecpsr)
|
|||
// aging cart debug crap
|
||||
//if (addr == 0x0201764C) printf("capture test %d: R1=%08X\n", R[6], R[1]);
|
||||
//if (addr == 0x020175D8) printf("capture test %d: res=%08X\n", R[6], R[0]);
|
||||
// R0=DMA# R1=src R2=size
|
||||
//if (addr==0x02019A88) printf("[%08X] [%03d] GX FIFO CMD %08X\n", R[15], NDS::ARM9Read16(0x04000006), R[0]);
|
||||
//if (addr==0x02022A5C) printf("[%08X] [%03d|%04X] RENDE SHITO %08X\n", R[15], NDS::ARM9Read16(0x04000006), NDS::ARM9Read16(0x04000304), R[0]);
|
||||
/*if (addr==0x0204BE29) printf("%08X -> recvfrom\n", R[15]);
|
||||
if (R[15]==0x0204BE5E) printf("recvfrom() ret:%d errno:%d %08X\n", R[0], NDS::ARM9Read32(0x217F398), addr);
|
||||
if (R[15]==0x0205038A) printf("sgrecvfrom() ret:%d errno:%d %08X\n", R[0], NDS::ARM9Read32(0x217F398), addr);
|
||||
if (addr==0x02050379 || addr==0x0205036D) printf("morp %08X->%08X, %d\n", R[15], addr, R[7]);*/
|
||||
/*if (addr==0x020B5F14) printf("VRAM UNMAP %02X %08X\n", R[0], R[15]);
|
||||
if (addr==0x020B5FAC) printf("VRAM MAP %2X %08X\n", R[0], R[15]);
|
||||
if (addr==0x0209F860) printf("VRAM BLORP %02X %08X\n", R[0], R[15]);
|
||||
if (addr==0x02005A34) printf("VAZAVAZORP %08X. VCOUNT=%d\n", R[15], NDS::ARM9Read16(0x04000006));
|
||||
if (addr==0x0209FBEC) printf("COUILLON. %08X %08X\n", R[0], R[1]);
|
||||
if (addr==0x02004AA8) printf("ANEBATE 1 %d\n", NDS::ARM9Read16(0x04000006));
|
||||
if (addr==0x020058C8) printf("ANEBATE 2 %d\n", NDS::ARM9Read16(0x04000006));
|
||||
if (addr==0x02005398) printf("ANEBATE 3 %d %d\n", NDS::ARM9Read16(0x04000006), (u32)(NDS::ARM9Timestamp-vbltime));
|
||||
if (addr==0x02005A5C) printf("PLAFORP %d\n", NDS::ARM9Read16(0x04000006));
|
||||
if (addr==0x209FBDC) printf("ROLOLORP\n");*/
|
||||
|
||||
u32 oldregion = R[15] >> 24;
|
||||
u32 newregion = addr >> 24;
|
||||
|
@ -518,8 +503,6 @@ void ARMv5::Execute()
|
|||
}
|
||||
else
|
||||
AddCycles_C();
|
||||
|
||||
//if (R[15]>=0x02005A5C && R[15]<=0x02005A84) printf("NORP %08X %d\n", R[15]-8, NDS::ARM9Read16(0x04000006));
|
||||
}
|
||||
|
||||
// TODO optimize this shit!!!
|
||||
|
@ -531,11 +514,12 @@ void ARMv5::Execute()
|
|||
}
|
||||
break;
|
||||
}
|
||||
if (NDS::IF[0] & NDS::IE[0])
|
||||
/*if (NDS::IF[0] & NDS::IE[0])
|
||||
{
|
||||
if (NDS::IME[0] & 0x1)
|
||||
TriggerIRQ();
|
||||
}
|
||||
}*/
|
||||
if (IRQ) TriggerIRQ();
|
||||
|
||||
NDS::ARM9Timestamp += Cycles;
|
||||
Cycles = 0;
|
||||
|
@ -607,11 +591,12 @@ void ARMv4::Execute()
|
|||
}
|
||||
break;
|
||||
}
|
||||
if (NDS::IF[1] & NDS::IE[1])
|
||||
/*if (NDS::IF[1] & NDS::IE[1])
|
||||
{
|
||||
if (NDS::IME[1] & 0x1)
|
||||
TriggerIRQ();
|
||||
}
|
||||
}*/
|
||||
if (IRQ) TriggerIRQ();
|
||||
|
||||
NDS::ARM7Timestamp += Cycles;
|
||||
Cycles = 0;
|
||||
|
|
12
src/ARM.h
12
src/ARM.h
|
@ -51,16 +51,6 @@ public:
|
|||
Halted = halt;
|
||||
}
|
||||
|
||||
// TODO: is this actually used??
|
||||
void CheckIRQ()
|
||||
{
|
||||
if (!(NDS::IME[Num] & 0x1)) return;
|
||||
if (NDS::IF[Num] & NDS::IE[Num])
|
||||
{
|
||||
TriggerIRQ();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Execute() = 0;
|
||||
|
||||
bool CheckCondition(u32 code)
|
||||
|
@ -119,6 +109,8 @@ public:
|
|||
s32 Cycles;
|
||||
u32 Halted;
|
||||
|
||||
u32 IRQ; // nonzero to trigger IRQ
|
||||
|
||||
u32 CodeRegion;
|
||||
s32 CodeCycles;
|
||||
|
||||
|
|
44
src/NDS.cpp
44
src/NDS.cpp
|
@ -1044,14 +1044,30 @@ void SetGBASlotTimings()
|
|||
}
|
||||
|
||||
|
||||
void UpdateIRQ(u32 cpu)
|
||||
{
|
||||
ARM* arm = cpu ? (ARM*)ARM7 : (ARM*)ARM9;
|
||||
|
||||
if (IME[cpu] & 0x1)
|
||||
{
|
||||
arm->IRQ = IE[cpu] & IF[cpu];
|
||||
}
|
||||
else
|
||||
{
|
||||
arm->IRQ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void SetIRQ(u32 cpu, u32 irq)
|
||||
{
|
||||
IF[cpu] |= (1 << irq);
|
||||
UpdateIRQ(cpu);
|
||||
}
|
||||
|
||||
void ClearIRQ(u32 cpu, u32 irq)
|
||||
{
|
||||
IF[cpu] &= ~(1 << irq);
|
||||
UpdateIRQ(cpu);
|
||||
}
|
||||
|
||||
bool HaltInterrupted(u32 cpu)
|
||||
|
@ -2599,7 +2615,7 @@ void ARM9IOWrite8(u32 addr, u8 val)
|
|||
case 0x040001AE: NDSCart::ROMCommand[6] = val; return;
|
||||
case 0x040001AF: NDSCart::ROMCommand[7] = val; return;
|
||||
|
||||
case 0x04000208: IME[0] = val & 0x1; return;
|
||||
case 0x04000208: IME[0] = val & 0x1; UpdateIRQ(0); return;
|
||||
|
||||
case 0x04000240: GPU::MapVRAM_AB(0, val); return;
|
||||
case 0x04000241: GPU::MapVRAM_AB(1, val); return;
|
||||
|
@ -2739,9 +2755,9 @@ void ARM9IOWrite16(u32 addr, u16 val)
|
|||
SetGBASlotTimings();
|
||||
return;
|
||||
|
||||
case 0x04000208: IME[0] = val & 0x1; return;
|
||||
case 0x04000210: IE[0] = (IE[0] & 0xFFFF0000) | val; return;
|
||||
case 0x04000212: IE[0] = (IE[0] & 0x0000FFFF) | (val << 16); return;
|
||||
case 0x04000208: IME[0] = val & 0x1; UpdateIRQ(0); return;
|
||||
case 0x04000210: IE[0] = (IE[0] & 0xFFFF0000) | val; UpdateIRQ(0); return;
|
||||
case 0x04000212: IE[0] = (IE[0] & 0x0000FFFF) | (val << 16); UpdateIRQ(0); return;
|
||||
// TODO: what happens when writing to IF this way??
|
||||
|
||||
case 0x04000240:
|
||||
|
@ -2894,9 +2910,9 @@ void ARM9IOWrite32(u32 addr, u32 val)
|
|||
case 0x040001B0: *(u32*)&ROMSeed0[0] = val; return;
|
||||
case 0x040001B4: *(u32*)&ROMSeed1[0] = val; return;
|
||||
|
||||
case 0x04000208: IME[0] = val & 0x1; return;
|
||||
case 0x04000210: IE[0] = val; return;
|
||||
case 0x04000214: IF[0] &= ~val; GPU3D::CheckFIFOIRQ(); return;
|
||||
case 0x04000208: IME[0] = val & 0x1; UpdateIRQ(0); return;
|
||||
case 0x04000210: IE[0] = val; UpdateIRQ(0); return;
|
||||
case 0x04000214: IF[0] &= ~val; GPU3D::CheckFIFOIRQ(); UpdateIRQ(0); return;
|
||||
|
||||
case 0x04000240:
|
||||
GPU::MapVRAM_AB(0, val & 0xFF);
|
||||
|
@ -3211,7 +3227,7 @@ void ARM7IOWrite8(u32 addr, u8 val)
|
|||
SPI::WriteData(val);
|
||||
return;
|
||||
|
||||
case 0x04000208: IME[1] = val & 0x1; return;
|
||||
case 0x04000208: IME[1] = val & 0x1; UpdateIRQ(1); return;
|
||||
|
||||
case 0x04000300:
|
||||
if (ARM7->R[15] >= 0x4000)
|
||||
|
@ -3333,9 +3349,9 @@ void ARM7IOWrite16(u32 addr, u16 val)
|
|||
SetWifiWaitCnt(val);
|
||||
return;
|
||||
|
||||
case 0x04000208: IME[1] = val & 0x1; return;
|
||||
case 0x04000210: IE[1] = (IE[1] & 0xFFFF0000) | val; return;
|
||||
case 0x04000212: IE[1] = (IE[1] & 0x0000FFFF) | (val << 16); return;
|
||||
case 0x04000208: IME[1] = val & 0x1; UpdateIRQ(1); return;
|
||||
case 0x04000210: IE[1] = (IE[1] & 0xFFFF0000) | val; UpdateIRQ(1); return;
|
||||
case 0x04000212: IE[1] = (IE[1] & 0x0000FFFF) | (val << 16); UpdateIRQ(1); return;
|
||||
// TODO: what happens when writing to IF this way??
|
||||
|
||||
case 0x04000300:
|
||||
|
@ -3445,9 +3461,9 @@ void ARM7IOWrite32(u32 addr, u32 val)
|
|||
case 0x040001B0: *(u32*)&ROMSeed0[8] = val; return;
|
||||
case 0x040001B4: *(u32*)&ROMSeed1[8] = val; return;
|
||||
|
||||
case 0x04000208: IME[1] = val & 0x1; return;
|
||||
case 0x04000210: IE[1] = val; return;
|
||||
case 0x04000214: IF[1] &= ~val; return;
|
||||
case 0x04000208: IME[1] = val & 0x1; UpdateIRQ(1); return;
|
||||
case 0x04000210: IE[1] = val; UpdateIRQ(1); return;
|
||||
case 0x04000214: IF[1] &= ~val; UpdateIRQ(1); return;
|
||||
|
||||
case 0x04000308:
|
||||
if (ARM7BIOSProt == 0)
|
||||
|
|
Loading…
Reference in New Issue