snes9xgx/source/ngc/gctime.cpp
dborth 850b301978 [What Was New 003 - July 25, 2008]
- added: alphabetical file sorting
- added: background logo/backdrop + nicer menus
- added: scrolling in ROM selector
- fixed: switching between pal/ntsc ROMS doesn't mess up timings
- fixed: GC controller config works now
- fixed: freeze autoloading on ROM load
- fixed: zipped ROMS should now load in a reasonable time
- fixed: precompiled dols for autosaving to various locations (see readme)
- changed: GC default quickload slot (to sd) (thanks kerframil)
- changed: default load/save dirs are now "/snes9x/roms" and 
           "/snes9x/saves/"  (thanks kerframil)
- changed: Classic X and Y defaults aren't switched
- changed: if autosave is enabled, it doesn't ask to save SRAM 
           anymore. It is saved in the background.
- updated README
2008-10-16 01:50:21 +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;
}
}