#ifndef GAMEFPS_POCKETMAIO_H
#define GAMEFPS_POCKETMAIO_H

#include "PFrogConsole.h"
#include <PocketFrog/PocketFrog.h>

#ifdef FORCE_CONSOLE_ENABLE
	#define FORCE_FPS_CALC
#endif
#ifdef _DEBUG
	#define FORCE_FPS_CALC
#endif

using namespace Frog;

class GameFPS
{

private:
	uint16_t G_min_time_per_frame;  //This time has to limit FPS
	uint32_t G_last_clock;			//previous end of loop clock
	uint16_t G_fps;					//FPS from previous loop
	uint16_t G_msec;				//Milliseconds from previous loop

    int      m_FPSCounter;      // FPS counter
    uint32_t m_FPSTicks[16];    // Ticks for last 16 frames

	static GameFPS* instance_ptr_;
	GameFPS() { };

	// variabile usata per flaggare che vogliamo calcolare gli fps, settata a true quando richiedi i fps tramite funzione
	bool wantAutoCalculateFPS;

public:

	static GameFPS* instance()
    {
            if (instance_ptr_ == NULL)
            {
                instance_ptr_ = new GameFPS;
            }

            return instance_ptr_;
    }


	void init(uint16_t,Display *);
	~GameFPS(void);
	void setfps(uint16_t);
	void beforescreenupdate(Display *);
	bool drawAtBottom;			// draw at bottom of screen (default false)
	uint16_t GetWantedFPS();
	uint16_t GetLastFPS();
};

#endif