small rework of timer class
This commit is contained in:
@@ -94,7 +94,7 @@ void Engine::gameLoop()
|
||||
fps = timer.getFPS();
|
||||
fpsDelayer = 0;
|
||||
}
|
||||
timer.primeTimer();
|
||||
timer.prime();
|
||||
renderer->endFrame(fps);
|
||||
/** -6~ FPS */
|
||||
SetAlarm(150, &Engine::wakeup, &mainThreadId);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#define _TYRA_TIMER_
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include <timer.h>
|
||||
|
||||
/** Class responsible for fps counting */
|
||||
class Timer
|
||||
@@ -22,7 +23,7 @@ public:
|
||||
~Timer();
|
||||
|
||||
u32 getTimeDelta();
|
||||
void primeTimer();
|
||||
inline void prime() { lastTime = *T3_COUNT; }
|
||||
float getFPS();
|
||||
|
||||
private:
|
||||
|
||||
@@ -10,16 +10,11 @@
|
||||
|
||||
#include "../include/modules/timer.hpp"
|
||||
|
||||
#include <timer.h>
|
||||
|
||||
// ----
|
||||
// Constructors/Destructors
|
||||
// ----
|
||||
|
||||
Timer::Timer()
|
||||
{
|
||||
this->lastTime = *T3_COUNT;
|
||||
}
|
||||
Timer::Timer() { prime(); }
|
||||
|
||||
Timer::~Timer() {}
|
||||
|
||||
@@ -29,20 +24,13 @@ Timer::~Timer() {}
|
||||
|
||||
u32 Timer::getTimeDelta()
|
||||
{
|
||||
this->time = *T3_COUNT;
|
||||
time = *T3_COUNT;
|
||||
|
||||
if (this->time < this->lastTime) // The counter has wrapped
|
||||
this->change = this->time + (65536 - this->lastTime);
|
||||
if (time < lastTime) // The counter has wrapped
|
||||
change = time + (65536 - lastTime);
|
||||
else
|
||||
this->change = this->time - this->lastTime;
|
||||
|
||||
this->lastTime = this->time;
|
||||
return this->change;
|
||||
}
|
||||
|
||||
void Timer::primeTimer()
|
||||
{
|
||||
lastTime = *T3_COUNT;
|
||||
change = time - lastTime;
|
||||
return change;
|
||||
}
|
||||
|
||||
float Timer::getFPS()
|
||||
|
||||
Reference in New Issue
Block a user