summaryrefslogtreecommitdiff
path: root/src/libultra/reg/_setcompare.c
blob: 810afcd8fba3b91a3174ff46eb3e798d363f741f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#ifdef BBPLAYER
#include "ultra64.h"

extern u32 __osBbLastRCount;
extern u32 __osBbRCountWraps;
extern u32 __osBbLastVCount;
extern u32 __osBbVCountWraps;

void __osSetCompare(u32 v) {
    if (v != 0) {
        u32 mask = __osDisableInt();
        u32 wraps = (v < __osBbLastVCount) ? (__osBbVCountWraps + 1) : __osBbVCountWraps;

        v = (((u64)wraps << 32) | v) * 192ull / 125ull;

        __osRestoreInt(mask);
    }
    __asm__("mtc0 %0, $%1" ::"r"(v), "i"(C0_COMPARE));
}
#endif