mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-12-04 16:34:21 +01:00
fb27030208
- added: classic and nunchuk support - added: all controllers can now be configured - added: GC version (untested) - changed: mappings are no longer stored in SRAM, but in config file. This means no per-game configurations, but one global config per controller. - one makefile to make all versions. (thanks to snes9x143 SVN)
52 lines
1.3 KiB
C++
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;
|
|
}
|
|
}
|