mirror of https://github.com/zeldaret/botw.git
ksys: Rename VFR members, functions and types for clarity
This commit is contained in:
parent
51755635aa
commit
e33476bbc0
|
|
@ -91886,15 +91886,15 @@
|
|||
0x00000071011c10fc,sub_71011C10FC,544,_ZN4ksys3VFR14updateIntervalEj
|
||||
0x00000071011c131c,VFR::x_0,132,_ZN4ksys3VFR10useBufferBEv
|
||||
0x00000071011c13a0,sub_71011C13A0,132,_ZN4ksys3VFR10useBufferAEv
|
||||
0x00000071011c1424,sub_71011C1424,328,_ZN4ksys3VFR27setDeltaFromTimeMultipliersEPfjj
|
||||
0x00000071011c1424,sub_71011C1424,328,_ZN4ksys3VFR17getDeltaAndSetMinEPfjj
|
||||
0x00000071011c156c,VFR::initBeforeStageGenB,316,_ZN4ksys3VFR20resetTimeMultipliersEv
|
||||
0x00000071011c16a8,VFR::isSlowTime,68,_ZNK4ksys3VFR23hasCustomTimeMultiplierEv
|
||||
0x00000071011c16ec,VFR::setSlowTime,136,
|
||||
0x00000071011c1774,VFR::endSlowTime,120,
|
||||
0x00000071011c17ec,sub_71011C17EC,12,_ZN4ksys3VFR9StopwatchC1Ev
|
||||
0x00000071011c17f8,sub_71011C17F8,184,_ZN4ksys3VFR9StopwatchC1Ejj
|
||||
0x00000071011c18b0,sub_71011C18B0,176,_ZN4ksys3VFR9Stopwatch5startEjj
|
||||
0x00000071011c1960,sub_71011C1960,200,_ZN4ksys3VFR9StopwatchD1Ev
|
||||
0x00000071011c17ec,sub_71011C17EC,12,_ZN4ksys3VFR17ScopedDeltaSetterC1Ev
|
||||
0x00000071011c17f8,sub_71011C17F8,184,_ZN4ksys3VFR17ScopedDeltaSetterC1Ejj
|
||||
0x00000071011c18b0,sub_71011C18B0,176,_ZN4ksys3VFR17ScopedDeltaSetter3setEjj
|
||||
0x00000071011c1960,sub_71011C1960,200,_ZN4ksys3VFR17ScopedDeltaSetterD1Ev
|
||||
0x00000071011c1a28,VFR::isField29Set,8,_ZNK4ksys3VFR19hasIntervalOverrideEv
|
||||
0x00000071011c1a30,VFR::x,8,_ZNK4ksys3VFR19getIntervalOverrideEv
|
||||
0x00000071011c1a38,sub_71011C1A38,44,
|
||||
|
|
|
|||
|
Can't render this file because it is too large.
|
|
|
@ -7,10 +7,10 @@ SEAD_SINGLETON_DISPOSER_IMPL(VFR)
|
|||
|
||||
VFR::VFR() {
|
||||
for (int i = 0; i < NumCores; ++i) {
|
||||
mPtrs1[i] = &mFloats1a[i];
|
||||
mDeltaTimes[i] = &mFloats2a[i];
|
||||
mPtrs3[i] = &mFloats3a[i];
|
||||
mDeltaFrames[i] = &mFloats4a[i];
|
||||
mRawDeltaFrames[i] = &mStorage[0].raw_delta_frames[i];
|
||||
mDeltaFrames[i] = &mStorage[0].delta_frames[i];
|
||||
mRawDeltaTimes[i] = &mStorage[0].raw_delta_times[i];
|
||||
mDeltaTimes[i] = &mStorage[0].delta_times[i];
|
||||
mIntervals[i] = &mIntervalA;
|
||||
mIntervalRatios[i] = &mIntervalRatioA;
|
||||
}
|
||||
|
|
@ -22,13 +22,13 @@ VFR::~VFR() {
|
|||
|
||||
void VFR::setDelta(u32 core, f32 delta) {
|
||||
delta = sead::Mathf::max(delta, 0.01f);
|
||||
*mPtrs1[core] = delta;
|
||||
*mDeltaTimes[core] = delta * *mIntervalRatios[core];
|
||||
*mPtrs3[core] = delta * mFrameTime;
|
||||
*mDeltaFrames[core] = *mDeltaTimes[core] * mFrameTime;
|
||||
*mRawDeltaFrames[core] = delta;
|
||||
*mDeltaFrames[core] = delta * *mIntervalRatios[core];
|
||||
*mRawDeltaTimes[core] = delta * mFrameTime;
|
||||
*mDeltaTimes[core] = *mDeltaFrames[core] * mFrameTime;
|
||||
}
|
||||
|
||||
void VFR::setDeltaFromTimeMultipliers(u32 core, const sead::BitFlag32& mask) {
|
||||
void VFR::setMinDelta(u32 core, const sead::BitFlag32& mask) {
|
||||
f32 min = 1.0;
|
||||
for (s32 i = 0; i < mTimeSpeedMultipliers.size(); ++i) {
|
||||
if (mask.isOnBit(i))
|
||||
|
|
@ -43,26 +43,26 @@ void VFR::resetTimeMultipliers() {
|
|||
entry.target_value = 1.0;
|
||||
entry.is_custom = false;
|
||||
}
|
||||
x_1();
|
||||
setMinDelta();
|
||||
}
|
||||
|
||||
void VFR::x_1() {
|
||||
setDeltaFromTimeMultipliers(0, mMask);
|
||||
void VFR::setMinDelta() {
|
||||
setMinDelta(0, mMask);
|
||||
|
||||
for (s32 i = 0; i < NumCores; ++i) {
|
||||
mFloats2a[i] = mFloats2a[0];
|
||||
mFloats3a[i] = mFloats3a[0];
|
||||
mFloats4a[i] = mFloats4a[0];
|
||||
mFloats1a[i] = mFloats1a[0];
|
||||
mStorage[0].delta_frames[i] = mStorage[0].delta_frames[0];
|
||||
mStorage[0].raw_delta_times[i] = mStorage[0].raw_delta_times[0];
|
||||
mStorage[0].delta_times[i] = mStorage[0].delta_times[0];
|
||||
mStorage[0].raw_delta_frames[i] = mStorage[0].raw_delta_frames[0];
|
||||
}
|
||||
}
|
||||
|
||||
void VFR::copyAtoB() {
|
||||
for (s32 i = 0; i < NumCores; ++i) {
|
||||
mFloats1b[i] = mFloats1a[i];
|
||||
mFloats2b[i] = mFloats2a[i];
|
||||
mFloats3b[i] = mFloats3a[i];
|
||||
mFloats4b[i] = mFloats4a[i];
|
||||
mStorage[1].raw_delta_frames[i] = mStorage[0].raw_delta_frames[i];
|
||||
mStorage[1].delta_frames[i] = mStorage[0].delta_frames[i];
|
||||
mStorage[1].raw_delta_times[i] = mStorage[0].raw_delta_times[i];
|
||||
mStorage[1].delta_times[i] = mStorage[0].delta_times[i];
|
||||
mIntervalB = mIntervalA;
|
||||
mIntervalRatioB = mIntervalRatioA;
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ void VFR::init(u32 interval, int num_speed_multipliers, sead::Heap* heap, u32 ma
|
|||
mFrameTime = 1.0f / mFrameRate;
|
||||
mTimeSpeedMultipliers.allocBufferAssert(num_speed_multipliers, heap);
|
||||
mMask = mask;
|
||||
x_1();
|
||||
setMinDelta();
|
||||
copyAtoB();
|
||||
}
|
||||
|
||||
|
|
@ -136,34 +136,34 @@ void VFR::updateInterval(u32 new_interval) {
|
|||
mTimeSpeedMultipliers[i].update(mIntervalRatioA);
|
||||
}
|
||||
|
||||
x_1();
|
||||
setMinDelta();
|
||||
}
|
||||
|
||||
void VFR::useBufferB() {
|
||||
const u32 core = sead::CoreInfo::getCurrentCoreId();
|
||||
mPtrs1[core] = &mFloats1b[core];
|
||||
mDeltaTimes[core] = &mFloats2b[core];
|
||||
mPtrs3[core] = &mFloats3b[core];
|
||||
mDeltaFrames[core] = &mFloats4b[core];
|
||||
mRawDeltaFrames[core] = &mStorage[1].raw_delta_frames[core];
|
||||
mDeltaFrames[core] = &mStorage[1].delta_frames[core];
|
||||
mRawDeltaTimes[core] = &mStorage[1].raw_delta_times[core];
|
||||
mDeltaTimes[core] = &mStorage[1].delta_times[core];
|
||||
mIntervals[core] = &mIntervalB;
|
||||
mIntervalRatios[core] = &mIntervalRatioB;
|
||||
}
|
||||
|
||||
void VFR::useBufferA() {
|
||||
const u32 core = sead::CoreInfo::getCurrentCoreId();
|
||||
mPtrs1[core] = &mFloats1a[core];
|
||||
mDeltaTimes[core] = &mFloats2a[core];
|
||||
mPtrs3[core] = &mFloats3a[core];
|
||||
mDeltaFrames[core] = &mFloats4a[core];
|
||||
mRawDeltaFrames[core] = &mStorage[0].raw_delta_frames[core];
|
||||
mDeltaFrames[core] = &mStorage[0].delta_frames[core];
|
||||
mRawDeltaTimes[core] = &mStorage[0].raw_delta_times[core];
|
||||
mDeltaTimes[core] = &mStorage[0].delta_times[core];
|
||||
mIntervals[core] = &mIntervalA;
|
||||
mIntervalRatios[core] = &mIntervalRatioA;
|
||||
}
|
||||
|
||||
f32 VFR::setDeltaFromTimeMultipliers(f32* value, u32 include_mask, u32 exclude_mask) {
|
||||
f32 VFR::getDeltaAndSetMin(f32* raw_delta_frames, u32 include_mask, u32 exclude_mask) {
|
||||
const u32 core = sead::CoreInfo::getCurrentCoreId();
|
||||
*value = *mPtrs1[core];
|
||||
const f32 delta = *mDeltaTimes[core];
|
||||
setDeltaFromTimeMultipliers(core, (mMask.getDirect() | include_mask) & ~exclude_mask);
|
||||
*raw_delta_frames = *mRawDeltaFrames[core];
|
||||
const f32 delta = *mDeltaFrames[core];
|
||||
setMinDelta(core, (mMask.getDirect() | include_mask) & ~exclude_mask);
|
||||
return delta;
|
||||
}
|
||||
|
||||
|
|
@ -175,30 +175,31 @@ bool VFR::hasCustomTimeMultiplier() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
VFR::Stopwatch::Stopwatch() = default;
|
||||
VFR::ScopedDeltaSetter::ScopedDeltaSetter() = default;
|
||||
|
||||
VFR::Stopwatch::Stopwatch(u32 include_mask, u32 exclude_mask) : Stopwatch() {
|
||||
start(include_mask, exclude_mask);
|
||||
VFR::ScopedDeltaSetter::ScopedDeltaSetter(u32 include_mask, u32 exclude_mask)
|
||||
: ScopedDeltaSetter() {
|
||||
set(include_mask, exclude_mask);
|
||||
}
|
||||
|
||||
void VFR::Stopwatch::start(u32 include_mask, u32 exclude_mask) {
|
||||
void VFR::ScopedDeltaSetter::set(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);
|
||||
f32 raw_delta;
|
||||
const auto delta = vfr->getDeltaAndSetMin(&raw_delta, include_mask, exclude_mask);
|
||||
const auto time = vfr->getDeltaTime();
|
||||
if (delta != time) {
|
||||
mTimeDelta = duration;
|
||||
mPreviousDelta = raw_delta;
|
||||
if (delta > 0.0)
|
||||
mTimeRate = time / delta;
|
||||
}
|
||||
}
|
||||
|
||||
VFR::Stopwatch::~Stopwatch() {
|
||||
if (VFR::instance() && mTimeDelta > 0.0)
|
||||
VFR::instance()->setDelta(mTimeDelta);
|
||||
VFR::ScopedDeltaSetter::~ScopedDeltaSetter() {
|
||||
if (VFR::instance() && mPreviousDelta > 0.0)
|
||||
VFR::instance()->setDelta(mPreviousDelta);
|
||||
}
|
||||
|
||||
} // namespace ksys
|
||||
|
|
|
|||
|
|
@ -31,18 +31,19 @@ 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);
|
||||
/// Changes the delta timing and restores the original value when going out of scope.
|
||||
struct ScopedDeltaSetter {
|
||||
ScopedDeltaSetter();
|
||||
ScopedDeltaSetter(u32 include_mask, u32 exclude_mask);
|
||||
~ScopedDeltaSetter();
|
||||
ScopedDeltaSetter(const ScopedDeltaSetter&) = delete;
|
||||
ScopedDeltaSetter(ScopedDeltaSetter&&) = delete;
|
||||
auto operator=(const ScopedDeltaSetter&) = delete;
|
||||
auto operator=(ScopedDeltaSetter&&) = delete;
|
||||
void set(u32 include_mask, u32 exclude_mask);
|
||||
|
||||
f32 mTimeRate = 1.0;
|
||||
f32 mTimeDelta = 0.0;
|
||||
f32 mPreviousDelta = 0.0;
|
||||
};
|
||||
|
||||
void init(u32 interval, int num_speed_multipliers, sead::Heap* heap, u32 mask);
|
||||
|
|
@ -57,7 +58,7 @@ public:
|
|||
void useBufferB();
|
||||
void useBufferA();
|
||||
|
||||
f32 setDeltaFromTimeMultipliers(f32* value, u32 include_mask, u32 exclude_mask);
|
||||
f32 getDeltaAndSetMin(f32* raw_delta_frames, u32 include_mask, u32 exclude_mask);
|
||||
void resetTimeMultipliers();
|
||||
bool hasCustomTimeMultiplier() const;
|
||||
// TODO: requires ksys::Sound
|
||||
|
|
@ -65,7 +66,7 @@ public:
|
|||
// TODO: requires ksys::Sound
|
||||
void resetTimeMultiplier(u32 idx);
|
||||
|
||||
f32 getDeltaTime(u32 core) const { return *mDeltaTimes[core]; }
|
||||
f32 getDeltaTime(u32 core) const { return *mDeltaFrames[core]; }
|
||||
f32 getDeltaTime() const { return getDeltaTime(sead::CoreInfo::getCurrentCoreId()); }
|
||||
|
||||
private:
|
||||
|
|
@ -78,8 +79,8 @@ 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 setMinDelta(u32 core, const sead::BitFlag32& mask);
|
||||
void setMinDelta();
|
||||
void copyAtoB();
|
||||
|
||||
bool mHasIntervalChanged = false;
|
||||
|
|
@ -99,20 +100,22 @@ private:
|
|||
TimeSpeedMultipliers mTimeSpeedMultipliers;
|
||||
sead::BitFlag32 mMask = 0xffffffff;
|
||||
|
||||
sead::SafeArray<f32, NumCores> mFloats1a{};
|
||||
sead::SafeArray<f32, NumCores> mFloats2a{};
|
||||
sead::SafeArray<f32, NumCores> mFloats3a{};
|
||||
sead::SafeArray<f32, NumCores> mFloats4a{};
|
||||
struct Storage {
|
||||
sead::SafeArray<f32, NumCores> raw_delta_frames{};
|
||||
sead::SafeArray<f32, NumCores> delta_frames{};
|
||||
sead::SafeArray<f32, NumCores> raw_delta_times{};
|
||||
sead::SafeArray<f32, NumCores> delta_times{};
|
||||
};
|
||||
sead::SafeArray<Storage, 2> mStorage{};
|
||||
|
||||
sead::SafeArray<f32, NumCores> mFloats1b{};
|
||||
sead::SafeArray<f32, NumCores> mFloats2b{};
|
||||
sead::SafeArray<f32, NumCores> mFloats3b{};
|
||||
sead::SafeArray<f32, NumCores> mFloats4b{};
|
||||
|
||||
sead::SafeArray<f32*, NumCores> mPtrs1;
|
||||
sead::SafeArray<f32*, NumCores> mDeltaTimes;
|
||||
sead::SafeArray<f32*, NumCores> mPtrs3;
|
||||
/// Delta frames.
|
||||
sead::SafeArray<f32*, NumCores> mRawDeltaFrames;
|
||||
/// Delta frames, adjusted for present interval changes.
|
||||
sead::SafeArray<f32*, NumCores> mDeltaFrames;
|
||||
/// Delta times. Equals raw_delta_frame * frame_time.
|
||||
sead::SafeArray<f32*, NumCores> mRawDeltaTimes;
|
||||
/// Delta times, adjusted for present interval changes. Equals delta_frame * frame_time.
|
||||
sead::SafeArray<f32*, NumCores> mDeltaTimes;
|
||||
/// Present interval.
|
||||
u32 mInterval = 1;
|
||||
/// Frames per second.
|
||||
|
|
|
|||
Loading…
Reference in New Issue