Initial Commit
This commit is contained in:
31
source/Timer.cpp
Normal file
31
source/Timer.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user