#ifndef __SNAMMG_H__
#define __SNAMMG_H__
 
#ifdef  __cplusplus
extern "C" {
#endif
 
#define SNA_C_ucBlockOfFix           1             /* Indicates a block that is part of the fix*/
#define SNA_C_ucBlockOfLevel         2             /* Indicates a block that is part of the level*/
#define SNA_C_ucEmptyBlock           255           /* Only infos are saved for this block.*/
 
#define SNA_C_ulBlockNotLoaded       0
#define SNA_C_ulBlockLoaded          1
 
 
typedef struct tdstModuleBloc_
{
	unsigned char *p_ucModuleId;
	unsigned char ucBlockId;
/*	unsigned char ucIsBlockLoaded;*/
} tdstModuleBloc;
 
#define SNA_M_SetBlocForSaving( Module, Block ) { &g_uc##Module##ModuleId, Block }
#define SNA_M_NbElementOfBlocArray(Array) (sizeof(Array)/sizeof(struct tdstModuleBloc_))
 
 
typedef struct tdstPtr_
{
	unsigned long p_vPtr;
	unsigned char ucTargetModule;
	unsigned char ucTargetBlock;
} tdstPtr;
 
#ifndef __CRB_Includes_SNA__	/* { */
 
typedef struct tdstBloc_
{
	unsigned char ucModuleNumber;
	unsigned char ucBlocNumber;
	unsigned long ulSize;
	struct tdstPtr_ *p_stPtr;
} tdstBloc;
 
typedef struct tdstRelocTable_
{
	struct tdstBloc_ *p_stBloc;
	unsigned char ucBlocNumber;
} tdstRelocTable;
 
typedef struct tdstReducedRelocTable_
{
    unsigned long ulBlockIndex;
    unsigned long ulPointerIndex;
} tdstReducedRelocTable;
 
 
extern CPA_EXPORT void SNA_fn_vSetSaveLoadFix();
extern CPA_EXPORT void SNA_fn_vSetSaveLoadLevel();

extern CPA_EXPORT void SNA_fn_xWriteOpenMemoryFile(char *szFilename);
extern CPA_EXPORT void SNA_fn_vCloseMemoryFile();
extern CPA_EXPORT void SNA_fn_vWriteAllMemoryBlocks(char *szFilename);
extern CPA_EXPORT BOOL SNA_fn_bReadAllMemoryBlocks(char *szFilename);
extern CPA_EXPORT void SNA_fn_bRelocateMemoryBlocks(char *szFilename);
extern CPA_EXPORT void SNA_fn_bDelocateMemoryBlocks();
 
extern CPA_EXPORT void SNA_fn_vInitArrays();	/* MR2711*/
 
extern ACP_tdxBool g_a_bIsBlocRelocated[C_ucNbOfMaxModule][10];
extern long g_a_ulOffset[C_ucNbOfMaxModule][10];
extern struct tdstModuleBloc_ g_a_stModuleBlocToSaveInLevel[];
extern struct tdstModuleBloc_ g_a_stModuleBlocToSaveInFix[];
extern unsigned long SNA_g_ulNbBlocksInFix;
extern unsigned long SNA_g_ulNbBlocksInLevel;
 
 
#ifndef RETAIL
void CPA_EXPORT SNA_fn_vCheckAllMMGBlocks();
void SNA_fn_vCheckMMGBlock( unsigned char _ucModule, unsigned char _ucBlock, unsigned char _ucLog );
#endif
 
#define SNA_M_vValidateLst(hFather, hLastElement, hCurrent, hNext)		\
{	\
	for(hCurrent=hLastElement,hNext=NULL; hCurrent!=NULL; hCurrent=LST2_M_DynamicGetPrevElement(hCurrent))\
	{\
		LST2_M_DynamicSetFather(hCurrent, hFather);\
		LST2_M_DynamicSetNextElement(hCurrent, hNext);\
		hNext=hCurrent; \
	}\
}	\
 
#define SNA_M_vValidateStaticLst(hFather, hLastElement, hCurrent, hNext)		\
{	\
	for(hCurrent=hLastElement,hNext=NULL; hCurrent!=NULL; hCurrent=LST2_M_StaticGetPrevElement(hCurrent))\
	{\
		LST2_M_StaticSetFather(hCurrent, hFather);\
		LST2_M_StaticSetNextElement(hCurrent, hNext);\
		hNext=hCurrent; \
	}\
}	\
 
#endif /* } ! __CRB_Includes_SNA__*/
 
#ifdef  __cplusplus
}/* extern "C" */
#endif
 
#endif /* __SNAMMG_H__*/
