/*=========================================================================
* Memory.h : Contain the memory's functions.
*            (based on CAP memory (see Pierrick))
* This is a part of the Game project.
*
* Version              1.0
* Creation date        30/08/96
* Revision date
*
* That file needs to be compatible for all platforms.
*
* (c) Ubi Studios 1996
*=======================================================================*/
 
#if !defined(__ZEMEM_H__)
#define __ZEMEM_H__
 
/******************************************/
#if _MSC_VER >= 1000
#pragma once
#endif /* _MSC_VER >= 1000 */
/******************************************/
 
#include "GAM/Header.h"
 
#define ACP_TextMemoryChannel          0
/*XB 98/10/05*/
#if !defined(U64)
#define ACP_FixMemoryChannel           1
#define ACP_LevelMemoryChannel         2
#else
	#define ACP_FixMemoryChannel           0
	#define ACP_LevelMemoryChannel         1
	#define ACP_U64_FixMemoryChannel       2
	#define ACP_U64_LevelMemoryChannel     3
	//XB 16/06/99
	#define ACP_U64_LDDMemoryChannel       4
	//End XB 16/06/99
#endif /* !U64 */
/*End XB*/
#define GAM_C_ActionMalloc  0
#define GAM_C_ActionRealloc 1
#define GAM_C_ActionFree    2
 
/**** Here are functions definition ****/
void fn_vFirstInitGameMemory(void);
void fn_vLastDesinitGameMemory(void);
 
void GAM_fn_vSetGameMemoryInFix(void);
void GAM_fn_vSetGameMemoryInLevel(void);
 
void *fnp_vGameDebugMallocInHLM(unsigned long ulSize,char *szFile,unsigned long ulLine);
void *fnp_vGameMallocInHLM(unsigned long ulSize);
void fn_vGameFreeInHLM(void *p_vPointer);
 
void GAM_fn_vMemoryLogFile(void *p_vPointer,unsigned char ucAction,char *szFile,unsigned long ulLine,unsigned long ulSize);
void GAM_fn_vPrintMemoryInformation(void);
 
void fn_vGameTestMemory(void);
void GAM_PrintUsedStaticMemory(void);
void GAM_PrintAllUsedStaticMemory(void);
void fn_vFreeFixAllowedMemory(void);
void fn_vFreeLevelAllowedMemory(void);
 
#if !defined(U64)
SCR_tde_Anl_ReturnValue fn_eScriptCallBackMemoryDescription(SCR_tdst_File_Description *_p_stFile,char *_p_szName,char *_ap_szParams[],SCR_tde_Anl_Action	_eAction);
#endif /* U64 */
 
#ifndef RETAIL
#define M_p_GameMallocInHLM(ulSize) \
 fnp_vGameDebugMallocInHLM(ulSize,__FILE__,__LINE__)
#else
#define M_p_GameMallocInHLM(ulSize) \
 fnp_vGameMallocInHLM(ulSize)
#endif
 
#define M_GameFreeInHLM(p_vPointer) \
{ \
 GAM_fn_vMemoryLogFile(p_vPointer,GAM_C_ActionFree,__FILE__,__LINE__,0); \
 fn_vGameFreeInHLM((void*)p_vPointer); \
 p_vPointer = NULL; \
}
 
EXTERN unsigned char GAM_g_ucHLMMemoryBlock;
 
#if defined(U64)
extern struct MTH3D_tdstVector_ *g_p_stVectorNull;
extern struct MTH3D_tdstMatrix_ *g_p_stIdentityMatrix;
#endif
 
#endif /* __ZEMEM_H__ */
