make timers not suck. fixes issues (Worms2 intro FMV plays at the right speed, aging cart tests get further...)

This commit is contained in:
StapleButter
2017-03-20 17:39:42 +01:00
parent f38bc94011
commit a56bf5c76c
7 changed files with 95 additions and 89 deletions

View File

@ -20,7 +20,6 @@
#include "NDS.h"
#include "ARM.h"
#include "ARMInterpreter.h"
#include "GPU3D.h"
u32 ARM::ConditionTable[16] =
@ -328,20 +327,19 @@ s32 ARM::Execute()
else
{
Cycles = CyclesToRun;
GPU3D::Run(CyclesToRun >> 1);
if (Num == 0) NDS::RunTimingCriticalDevices(0, CyclesToRun >> 1);
else NDS::RunTimingCriticalDevices(1, CyclesToRun);
return Cycles;
}
}
Cycles = 0;
s32 lastcycles = 0;
u32 addr = R[15] - (CPSR&0x20 ? 4:8);
u32 cpsr = CPSR;
while (Cycles < CyclesToRun)
{
//if(Num==1)printf("%08X %08X\n", R[15] - (CPSR&0x20 ? 4:8), NextInstr);
if (CPSR & 0x20) // THUMB
{
// prefetch
@ -376,15 +374,18 @@ s32 ARM::Execute()
//if (R[15]==0x037F9364) printf("R8=%08X R9=%08X\n", R[8], R[9]);
// gross hack
// TODO, though: move timer code here too?
// quick testing shows that moving this to the NDS loop doesn't really slow things down
if (Num==0)
{
s32 diff = Cycles - lastcycles;
GPU3D::Run(diff >> 1);
NDS::RunTimingCriticalDevices(0, diff >> 1);
lastcycles = Cycles - (diff&1);
}
else
{
s32 diff = Cycles - lastcycles;
NDS::RunTimingCriticalDevices(1, diff);
lastcycles = Cycles;
}
// TODO optimize this shit!!!
if (Halted)
@ -398,10 +399,6 @@ s32 ARM::Execute()
if (NDS::IME[Num]&1)
TriggerIRQ();
}
// temp. debug cruft
addr = R[15] - (CPSR&0x20 ? 4:8);
cpsr = CPSR;
}
if (Halted == 2)