palladium/source/Timer.cpp
2024-07-12 19:48:34 +02:00

31 lines
686 B
C++

#include <pd/Timer.hpp>
// Ticks per MSEC
#define TPMS 268111.856
namespace Palladium {
Timer::Timer(bool autostart) {
if (autostart) is_running = true;
last = svcGetSystemTick();
current = last;
}
void Timer::Reset() {
last = svcGetSystemTick();
current = last;
}
void Timer::Tick() {
if (is_running) current = svcGetSystemTick();
}
void Timer::Pause() { is_running = false; }
void Timer::Resume() { is_running = true; }
bool Timer::Running() { return is_running; }
float Timer::Get() { return (float)((current - last) / TPMS); }
float Timer::GetLive() { return (float)((svcGetSystemTick() - last) / TPMS); }
} // namespace Palladium