while we're at it: emulate div/sqrt timings

This commit is contained in:
StapleButter 2017-07-15 19:46:27 +02:00
parent 0d58fcb5d6
commit bb963c35a4
2 changed files with 22 additions and 8 deletions

View File

@ -717,11 +717,9 @@ void TimerStart(u32 id, u16 cnt)
void StartDiv()
void DivDone(u32 param)
{
// TODO: division isn't instant!
DivCnt &= ~0x2000;
DivCnt &= ~0xC000;
switch (DivCnt & 0x0003)
{
@ -792,20 +790,27 @@ void StartDiv()
}
if ((DivDenominator[0] | DivDenominator[1]) == 0)
DivCnt |= 0x2000;
DivCnt |= 0x4000;
}
void StartDiv()
{
NDS::CancelEvent(NDS::Event_Div);
DivCnt |= 0x8000;
NDS::ScheduleEvent(NDS::Event_Div, false, ((DivCnt&0x3)==0) ? 18:34, DivDone, 0);
}
// http://stackoverflow.com/questions/1100090/looking-for-an-efficient-integer-square-root-algorithm-for-arm-thumb2
void StartSqrt()
void SqrtDone(u32 param)
{
// TODO: sqrt isn't instant either. oh well
u64 val;
u32 res = 0;
u64 rem = 0;
u32 prod = 0;
u32 nbits, topshift;
SqrtCnt &= ~0x8000;
if (SqrtCnt & 0x0001)
{
val = *(u64*)&SqrtVal[0];
@ -836,6 +841,13 @@ void StartSqrt()
SqrtRes = res;
}
void StartSqrt()
{
NDS::CancelEvent(NDS::Event_Sqrt);
SqrtCnt |= 0x8000;
NDS::ScheduleEvent(NDS::Event_Sqrt, false, 13, SqrtDone, 0);
}
void debug(u32 param)

View File

@ -34,6 +34,8 @@ enum
Event_ROMTransfer,
Event_ROMSPITransfer,
Event_SPITransfer,
Event_Div,
Event_Sqrt,
Event_MAX
};