/*=========================================================================
* EngMode.h :       Define the engine modes structure.
* This is a part of the Game project.
*
* Version                      1.0
* Creation date        09/08/96
* Revision date
*
* That file needs to be compatible for all platforms.
*
* (c) Ubi Studios 1996
*=======================================================================*/
/*
*=======================================================================
Modifications: New LST2_M_??? Macros / Michaël / 070297
*=======================================================================*/
 
#if !defined(__ENGMODE_H__)
#define __ENGMODE_H__
 
/******************************************/
#if _MSC_VER >= 1000
#pragma once
#endif /* _MSC_VER >= 1000 */
/******************************************/
 
#ifdef  __cplusplus
extern "C" {
#endif
 
#include "TMR.h"
 
#include "GAM/Header.h"
#include "GAM/GAMHandl.h"
 
 
#define C_NumberOfCounter 16
 
M_BeginDeclareEnumerate(tdeEngineMode)
 EM_ModeInvalid = 0,
 EM_ModeStartingProgram,                  /* first init*/
 EM_ModeStoppingProgram,                  /* last desinit*/
 EM_ModeEnterGame,                        /* init game loop*/
 EM_ModeQuitGame,                         /* desinit game loop*/
 EM_ModeEnterLevel,                       /* init level loop*/
 EM_ModeChangeLevel,                      /* desinit level loop*/
 EM_ModeDeadLoop,                         /* init dead loop*/
 EM_ModePlayerDead,                       /* desinit dead loop*/
 EM_ModePlaying,                          /* playing game*/
 /* FBF {*/
 /*EM_ModeEnterMenu,                        // Init the menu
 EM_ModeMenu,                             // In the start menu
 EM_ModeQuitMenuToEnterGame,              // Go to the game from the menu
 EM_ModeEnterMenuWhenPlaying,             // Init the menu when playing
 EM_ModeEnterMenuWhenPlayingWithoutPause, // Init the menu by AI
 EM_ModeMenuWhenPlaying,                  // In the menu when playing
 EM_ModeMenuWhenPlayingWithoutPause,      // In the menu when playing without pause
 EM_ModeResumeGameFromMenu,               // Return to the game from the menu
 */
 /* FBF }*/
 
 NbTotalEngineMode
M_EndDeclareEnumerate(tdeEngineMode, unsigned char)
 
M_BeginDeclareEnumerate(tdeInputMode)
 IM_Normal,
 IM_Commands,
 IM_NumberOfMode
M_EndDeclareEnumerate(tdeInputMode, unsigned char)
/**** This enum is used as a bitfield ****/
M_BeginDeclareEnumerate(tdeDisplayFixMode)
 DFM_DisplayAll       = 0xff,
 DFM_DisplayHitPoints = 0x01,
 DFM_DisplayGameSave  = 0x02,
 DFM_DisplayNothing   = 0x00,
 DFM_NumberOfMode
M_EndDeclareEnumerate(tdeDisplayFixMode, unsigned char)
 
/*********************************************************************/
/**** This structures define the differents mode or state of play ****/
/**** and the options of game                                     ****/
/*********************************************************************/
 
typedef struct tdstEngineTimerStructure_
{
 unsigned long ulTrameNumber;		/* Number of the frame */
 short sTimerHandle;
 unsigned long ulCurrentTimerCount; /* Current trame timer in msec*/
 unsigned long ulDeltaTimerCount;    /*Between two trames  in msec*/
 unsigned long a_ulCounter[C_NumberOfCounter]; /*Other frequencies counters*/
 unsigned long ulUsefulDeltaTime;/* computed time in msec*/
 unsigned long ulPauseTime; /* When engine is in pause */
 MTH_tdxReal xFrameLength; /* frame length in s    ( 60Hz -> 1/60 s ) */
#ifndef U64
 struct _stTimerCount stRealTimeCount;	/* Current trame timer in tick*/
 struct _stTimerCount stPauseTime;
 unsigned long ulTickPerMS;
#endif /* U64 */
} tdstEngineTimerStructure;
 
typedef struct tdstLanguageStructure_
{
	char	szLanguageCode[20];
	char	szLanguageText[20];
}tdstLanguageStructure;
 
 
 
#define M_ulGetUsefulDeltaTimeInMilliSeconds(stTimer) ((stTimer).ulUsefulDeltaTime)
#define M_xGetUsefulDeltaTimeInSeconds(stTimer)\
	(MTH_M_xDiv(MTH_M_xLongToReal(stTimer.ulUsefulDeltaTime),\
				MTH_M_xFloatToReal(1000.f)))
#define M_xGetFrameLength(stTimer) ((stTimer).xFrameLength)

 
/*ANNECY BBB 24/10/97 {*/
/*#define C_ucMaxNbSubLevels 10*/
/*ENDANNECY BBB 24/10/97 }*/
#define _MAX_NAME_LEVEL		30
typedef struct tdstEngineStructure_
{
	tdeEngineMode eEngineMode;
	char szLevelName[_MAX_NAME_LEVEL];
	char szNextLevelName[_MAX_NAME_LEVEL];
	char szFirstLevelName[_MAX_NAME_LEVEL];
 
	/*ANNECY BBB 24/10/97 {*/
	/*char szSubLevelName[C_ucMaxNbSubLevels][_MAX_PATH];*/
	/*ENDANNECY BBB 24/10/97 }*/
	/*char szCreditsLevelName[_MAX_PATH];*/
	/*char szNextLevelPositionPersoName[50];*/
	/*char szNextLevelPositionCameraName[50];*/
	tdeInputMode eInputMode;
	tdeDisplayFixMode eDisplayFixMode;
	unsigned long ulDisplayMode;
	
	/*unsigned char  bSkipMainMenu;*/
	
	tdstEngineTimerStructure stEngineTimer;
	
/* XB 23/06/99 */
/* not used in N64 engine */
#ifndef U64
	GLD_tdhDevice    hGLDDevice;
	GLD_tdhViewport  hGLDViewport;
#endif /* U64 */
/* End XB 23/06/99 */

	GLD_tdstViewportAttributes stViewportAttr;
	struct GLI_tdstCamera_	*p_stGameViewportCamera;

/* XB 23/06/99 */
/* not used in N64 engine */
#ifndef U64
	void *           hDrawSem;
#endif /* U64 */
/* End XB 23/06/99 */
	
	GLD_tdhViewport  hGLDFixViewport;
	GLD_tdstViewportAttributes stFixViewportAttr;
	GLI_tdstSpecificAttributesFor3D stFixAttributes3D;
	struct GLI_tdstCamera_	*p_stFixCamera;
	
	/* camera's management */
	tdxHandleToViewportManagement	a_hViewportArray;
	
	LST2_M_DynamicAnchorDeclaration(tdxHandleToNodeCamera) hCameraList;
	/* *************** */
	
	LST2_M_DynamicAnchorDeclaration(tdxHandleToFamilyList) hFamilyList;
	LST2_M_DynamicAnchorDeclaration(MC_tdxHandleToMainCharacterNode) hMainCharacterList;
	LST2_M_DynamicAnchorDeclaration(tdxHandleToAlwaysActiveCharacterNode) hAlwaysActiveCharactersList;
	/* *************** */
	
	HIE_tdxHandleToSuperObject	h_StdCamCaracter; /* Standard camera caracter description */
	
	tdstLanguageStructure		*p_stLanguageTable;
	
	/*FIL_tdxHandleToFileNameList hGameSavedNameList;*/
	FIL_tdxHandleToFileNameList hLevelNameList;
	
	/* To restore positions after resurection*/
	POS_tdstCompletePosition	stMainCharacterPosition;
	POS_tdstCompletePosition	stMainCameraPosition;
 
	long						lSubMapNumber;
 
	unsigned char				bEngineIsInPaused;
	unsigned char				bEngineHasInPaused;
	
	char						a_szLevelName[80][_MAX_NAME_LEVEL];
	unsigned char				ucNumberOfLevels;
	unsigned char				ucCurrentLevel;
	
	/* used to know which level we come from, if relevant: should be initialized to 0 at program start*/
	/*then only modified by AI calls or level change requests (no save required)*/
	unsigned char				ucPreviousLevel;
	unsigned char				ucExitIdToQuitPrevLevel;
	unsigned char				ucLevelGlobalCounter;
	
	ACP_tdxBool					xDemoMode; /*AR9807*/
	unsigned char				ucCurrentLanguage; /*for multilanguage texts*/
	unsigned char				ucNbLanguages; /*for multilanguage texts*/
 
	ACP_tdxBool					bEngineFrozen; /* if true, unprotected characters are not treated in the engine loop*/
 
	/* To restore positions after resurection*/
	ACP_tdxBool					bResurection;
	
/* Begin Shaitan ModeLook*/
	/* For camera mode*/
	char						cCameraMode;
/* End Shaitan ModeLook*/
} tdstEngineStructure;
 
/* Begin Shaitan ModeLook*/
#define C_CamModeNormal 0
#define C_CamModeLook	1
/* End Shaitan ModeLook*/
 
EXTERN CPA_EXPORT struct tdstEngineStructure_ g_stEngineStructure;
 
/* Globals varaibles for binarisation*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
EXTERN CPA_EXPORT char	g_cIsLevelOk;
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
EXTERN CPA_EXPORT char	g_cMemMode;
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
EXTERN CPA_EXPORT char  g_a64_cGameDataDirectory[64];
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
EXTERN CPA_EXPORT char	g_cUseBinary;
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*
	 0 : Normal Memory 
	 1 : Binary Memory
	 2 : Binary Memory for pass 1
	 3 : Binary Memory for pass 2
*/
 
#ifdef  __cplusplus
}/* extern "C" */
#endif
 
#endif /* !__ENGMODE_H__ */
