Files
snes9xgx/source/ngc/gctime.cpp
dborth 7305f0ee6c [What Was New 001 - July 12, 2008]
- compiles with latest devkitppc (r15)
- now uses libfat (can use front sd slot on wii)
- updated menu items a bit
- wiimote support
- fixed: autoload sram/freeze
- fixed: rom plays immediately after loading
2008-10-16 01:49:12 +00:00

52 lines
1.3 KiB
C++

/****************************************************************************
* gctime.cpp
****************************************************************************/
#include "gctime.h"
#define TB_CLOCK 40500000
unsigned long tb_diff_msec(tb_t *end, tb_t *start)
{
unsigned long upper, lower;
upper = end->u - start->u;
if (start->l > end->l)
upper--;
lower = end->l - start->l;
return ((upper*((unsigned long)0x80000000/(TB_CLOCK/2000))) + (lower/(TB_CLOCK/1000)));
}
unsigned long tb_diff_usec(tb_t *end, tb_t *start)
{
unsigned long upper, lower;
upper = end->u - start->u;
if (start->l > end->l)
upper--;
lower = end->l - start->l;
return ((upper*((unsigned long)0x80000000/(TB_CLOCK/2000000))) + (lower/(TB_CLOCK/1000000)));
}
void udelay(unsigned int us)
{
tb_t start, end;
mftb(&start);
while (1)
{
mftb(&end);
if (tb_diff_usec(&end, &start) >= us)
break;
}
}
void mdelay(unsigned int ms)
{
tb_t start, end;
mftb(&start);
while (1)
{
mftb(&end);
if (tb_diff_msec(&end, &start) >= ms)
break;
}
}