mirror of https://github.com/zeldaret/botw.git
ksys: Add VFR stopwatch utilities
This commit is contained in:
parent
5c6cc59214
commit
053c200741
|
|
@ -91891,10 +91891,10 @@
|
|||
0x00000071011c16a8,VFR::isSlowTime,68,_ZNK4ksys3VFR23hasCustomTimeMultiplierEv
|
||||
0x00000071011c16ec,VFR::setSlowTime,136,
|
||||
0x00000071011c1774,VFR::endSlowTime,120,
|
||||
0x00000071011c17ec,sub_71011C17EC,12,
|
||||
0x00000071011c17f8,sub_71011C17F8,184,
|
||||
0x00000071011c18b0,sub_71011C18B0,176,
|
||||
0x00000071011c1960,sub_71011C1960,200,
|
||||
0x00000071011c17ec,sub_71011C17EC,12,_ZN4ksys3VFR9StopwatchC1Ev
|
||||
0x00000071011c17f8,sub_71011C17F8,184,_ZN4ksys3VFR9StopwatchC1Ejj
|
||||
0x00000071011c18b0,sub_71011C18B0,176,_ZN4ksys3VFR9Stopwatch5startEjj
|
||||
0x00000071011c1960,sub_71011C1960,200,_ZN4ksys3VFR9StopwatchD1Ev
|
||||
0x00000071011c1a28,VFR::isField29Set,8,_ZNK4ksys3VFR19hasIntervalOverrideEv
|
||||
0x00000071011c1a30,VFR::x,8,_ZNK4ksys3VFR19getIntervalOverrideEv
|
||||
0x00000071011c1a38,sub_71011C1A38,44,
|
||||
|
|
|
|||
|
Can't render this file because it is too large.
|
|
|
@ -175,4 +175,30 @@ bool VFR::hasCustomTimeMultiplier() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
VFR::Stopwatch::Stopwatch() = default;
|
||||
|
||||
VFR::Stopwatch::Stopwatch(u32 include_mask, u32 exclude_mask) : Stopwatch() {
|
||||
start(include_mask, exclude_mask);
|
||||
}
|
||||
|
||||
void VFR::Stopwatch::start(u32 include_mask, u32 exclude_mask) {
|
||||
auto* vfr = VFR::instance();
|
||||
if (!vfr)
|
||||
return;
|
||||
|
||||
f32 duration;
|
||||
const auto delta = vfr->setDeltaFromTimeMultipliers(&duration, include_mask, exclude_mask);
|
||||
const auto time = vfr->getDeltaTime();
|
||||
if (delta != time) {
|
||||
mTimeDelta = duration;
|
||||
if (delta > 0.0)
|
||||
mTimeRate = time / delta;
|
||||
}
|
||||
}
|
||||
|
||||
VFR::Stopwatch::~Stopwatch() {
|
||||
if (VFR::instance() && mTimeDelta > 0.0)
|
||||
VFR::instance()->setDelta(mTimeDelta);
|
||||
}
|
||||
|
||||
} // namespace ksys
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <container/seadBuffer.h>
|
||||
#include <container/seadSafeArray.h>
|
||||
#include <heap/seadDisposer.h>
|
||||
#include <mc/seadCoreInfo.h>
|
||||
#include <prim/seadBitFlag.h>
|
||||
#include "KingSystem/Utils/Types.h"
|
||||
|
||||
|
|
@ -30,6 +31,20 @@ public:
|
|||
f32 target_value = 1.0;
|
||||
};
|
||||
|
||||
struct Stopwatch {
|
||||
Stopwatch();
|
||||
Stopwatch(u32 include_mask, u32 exclude_mask);
|
||||
~Stopwatch();
|
||||
Stopwatch(const Stopwatch&) = delete;
|
||||
Stopwatch(Stopwatch&&) = delete;
|
||||
auto operator=(const Stopwatch&) = delete;
|
||||
auto operator=(Stopwatch&&) = delete;
|
||||
void start(u32 include_mask, u32 exclude_mask);
|
||||
|
||||
f32 mTimeRate = 1.0;
|
||||
f32 mTimeDelta = 0.0;
|
||||
};
|
||||
|
||||
void init(u32 interval, int num_speed_multipliers, sead::Heap* heap, u32 mask);
|
||||
|
||||
void setIntervalOverride(u32 interval);
|
||||
|
|
@ -50,6 +65,9 @@ public:
|
|||
// TODO: requires ksys::Sound
|
||||
void resetTimeMultiplier(u32 idx);
|
||||
|
||||
f32 getDeltaTime(u32 core) const { return *mDeltaTimes[core]; }
|
||||
f32 getDeltaTime() const { return getDeltaTime(sead::CoreInfo::getCurrentCoreId()); }
|
||||
|
||||
private:
|
||||
struct TimeSpeedMultipliers : sead::Buffer<TimeSpeedMultiplier> {
|
||||
TimeSpeedMultipliers() {
|
||||
|
|
@ -59,6 +77,7 @@ private:
|
|||
};
|
||||
|
||||
void setDelta(u32 core, f32 delta);
|
||||
void setDelta(f32 delta) { setDelta(sead::CoreInfo::getCurrentCoreId(), delta); }
|
||||
void setDeltaFromTimeMultipliers(u32 core, const sead::BitFlag32& mask);
|
||||
void x_1();
|
||||
void copyAtoB();
|
||||
|
|
|
|||
Loading…
Reference in New Issue