_getcount.c
583 Bytes
#include <ultra64.h>
#ifdef BBPLAYER
#include "osint.h"
u32 __osBbLastRCount;
u32 __osBbRCountWraps;
u32 __osBbLastVCount;
u32 __osBbVCountWraps;
u32 osGetCount(void) {
u32 count;
u32 mask;
mask = __osDisableInt();
__asm__ (
"mfc0\t%0,$9\n\t"
: "=r" (count));
if (count < __osBbLastRCount) ++__osBbRCountWraps;
__osBbLastRCount = count;
count = (((((u64)__osBbRCountWraps)<<32)|count)*125ULL)/192ULL;
if (count < __osBbLastVCount) ++__osBbVCountWraps;
__osBbLastVCount = count;
__osRestoreInt(mask);
return count;
}
#endif