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