/******************************************************************************
*******************************************************************************

	Bubble Fight EX
	relminator
	http://rel.betterwebber.com


	Singleton Fx3D class


*******************************************************************************
******************************************************************************/

#include <nds.h>
#include <math.h>
#include <gl2d.h>
#include <cstdio>

#include "UTIL.h"
#include "Palettes.h"
#include "Vector2df32.h"

#ifndef FX2D_H
#define FX2D_H

class Fx2D {

	static Fx2D* ms_instance;

public:
	static Fx2D* Instance();
	static void Release();

	void Init();
	
	void Fade( unsigned short* Target,    // sub or main bg/oam 
			   const unsigned short* StartPal,  // pal to lerp from 
			   const unsigned short* EndPal,    // pal to lerp to 
			   s32 &Interp,
			   s32 Speed,
		       int MaxColors = 512
			 );
	
	void Fade3D( int Color1,    // Color to fade to 
			     int Color2,
				 int Color3,
				 int Color4,
				 s32 &Interp,
			     s32 Speed
			   );
	
	void AnimateSplashIn( int Palette, glImage* Tile );
	
	void AnimateSplashOut( int Palette, glImage* Tile, int Color = 0xFFFF );
	
	u8* PlasmaTrans();

	u8* PlasmaTrans2();

	void CyclePlasmaPal();
	
	u16* GetPlasmaPal()
	{
		return PlasmaPal;
	}
	
	void LoadPal( const unsigned short *pal );
	
private:
	Fx2D();
	~Fx2D();
	
	u8 Vpage[SCREEN_WIDTH*SCREEN_HEIGHT];

	// some sine LUTs
	u8 Lsin1[2048];
	u8 Lsin2[2048];
	u8 Lsin3[2048];

	// RGB palette
	u16 PlasmaPal[256];    
	
};

#endif // FX2D_H
