summaryrefslogtreecommitdiff
path: root/src/KingSystem/System/SystemTimers.cpp
blob: 31c8756299707724b45972aec76dad060c5af449 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "KingSystem/System/SystemTimers.h"

#include "KingSystem/System/VFR.h"

namespace ksys {

SEAD_SINGLETON_DISPOSER_IMPL(SystemTimers)

SystemTimers::~SystemTimers() = default;

void SystemTimers::init() {
    mVfrTimer = 0;
    mFrameCounterB = 0;
    mVfrTimer2 = 0;
    mFrameCounterB2 = 0;
    mFrameCounter = 0;
    mFrameCounter2 = 0;
}

void SystemTimers::init2() {
    init();
}

void SystemTimers::prepareStageUnload() {}

void SystemTimers::incrementCountersAndUpdate() {
    mFrameCounter++;
    mFrameCounter2++;
    f32 deltaTime = VFR::instance()->getDeltaFrame();
    mVfrTimer += deltaTime;

    while (mVfrTimer >= 1) {
        mFrameCounterB++;
        mVfrTimer--;
    }

    mVfrTimer2 += deltaTime;
    while (mVfrTimer2 >= 1) {
        mFrameCounterB2++;
        mVfrTimer2--;
    }
}

void SystemTimers::incrementCounters() {
    mFrameCounter++;
    mFrameCounterB++;
}

}  // namespace ksys