/* ================================================================
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL DINGOO GAMES OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ====================================================================
*/ 

#ifndef __GAMEENGINE_H__
#define __GAMEENGINE_H__

#include "Common.h"

//--------------------------------------------------------------------------------------------------------
#include "io.h"
#include "ws.h"

#include "audio.h"

//--------------------------------------------------------------------------------------------------------
class GameEngine : public Engine
{

	//--------------------------------------------------------------------------------------------------------
public:
	GameEngine( void* userdata [] );
	~GameEngine( void );
	//--------------------------------------------------------------------------------------------------------
	//### implement Engine:
public:
	/// init all resources
	result Init( void );

	/// free all resources
	void Free( void );

	/// game logic before render
	void Exec( void );

	/// game logic after render
	void Exec2( void );

	/// pre-render proccess
	void PreRender( void );

	/// render
	void Render( void );

	/// post-render proccess
	void PostRender( void );

	/// display debug info
	void DispDebugInfo( void );

	/// define anim table
	void DefAnimTable( void );

	/// exit game
	void ExitGame( void );

	//emulate standard
	void ws_emulate_standard(void);

	//emulate full
	void ws_emulate_full(void);

	//--------------------------------------------------------------------------------------------------------
public:
	void EnterGame(s32 MapId);
	void ReturnManiUI();
	void PopMenu();
	void ReadHightScore();
	void PutPixel(int x, int y, UINT16 value);
	void ConvertFormat(void);

	void JoyPadControl(void);

	//--------------------------------------------------------------------------------------------------------
	//### data members:
public:
	//Surface
	int A320_SCREEN_WIDTH;
	int A320_SCREEN_HEIGHT;

	int  app_gameRunning;
	int  app_terminate;
	int  app_fullscreen;
	int  app_rotated;

	int  ws_videoEnhancementType;
	int  ws_colourScheme;
	int  ws_system;

	char *ws_rom_path;
	char old_rom_path[4096];

	UINT32  startTime, endTime, totalFrames;
	unsigned int nNormalLast;
	int   nNormalFrac; 
	int   nTime,nCount; 
	int  i;
	int  surfacePitch;

	Input* GetInput( void );

	Texture* m_pImgS2d;

	Rect rcTest;
	
	Pixel* ptr;

	UINT16 r,g,b;

	UINT16 red_mask,green_mask,blue_mask;

};
//--------------------------------------------------------------------------------------------------------

#endif//__GAMEENGINE_H__
