reman3/Rayman_X/cpa/Appli/CvrtA3DtoA3i/Src/l_global_v6.cpp

248 lines
7.7 KiB
C++

// **********************************************************************************
// * "l_global_v6.c" *
// * Written by : Sébastien Rubens *
// * Tabulations : 4 char *
// **********************************************************************************
#define L_GLOBAL_V6_C
// **********************************************************************************
//#define ShowInfos
//#define WaitGetChar
#define Details
// **********************************************************************************
// Included files
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <assert.h>
#include "SCR.h"
#include "specif\\a3x_pref.h"
#include "a3x_glob.h"
#include "makeanim.h"
#include "l_global_v6.h"
// **********************************************************************************
// Globals datas
#define MaxInStringsTab 40000
#define MaxInVertexesTab 320000
#define MaxInQuaternionsTab 360000
#define MaxInA3dGENERALTab 2000
#define MaxInChannelsTab 12000
#define MaxInFramesTab 300000
#define MaxInFramesNTTOTab 400000
#define MaxInOnlyFramesTab 30000
#define MaxInHierarchiesTab 10000
#define MaxInChannelNamesTab 1000
#define MaxInSavedVertexesTab 200000
#define MaxInSavedQuaternionsTab 200000
#define MaxInSavedNTTOTab 40000
#define MaxInMorphTab 300000
//typedef char tdFileName[50];
tdstBinStackInfos tdstStacks[eStackBinNbMax]=
{ { 0, 0, 0, MaxInStringsTab }, // Strings
{ 0, 0, 0, MaxInVertexesTab }, // Vertexes
{ 0, 0, 0, MaxInQuaternionsTab }, // Quaternions
{ 0, 0, 0, MaxInA3dGENERALTab }, // A3dGENERAL
{ 0, 0, 0, MaxInChannelsTab }, // Channels
{ 0, 0, 0, MaxInFramesTab }, // Frames
{ 0, 0, 0, MaxInOnlyFramesTab }, // OnlyFrames
{ 0, 0, 0, MaxInHierarchiesTab }, // Hierarchies
{ 0, 0, 0, MaxInChannelNamesTab }, // ChannelNames
{ 0, 0, 0, MaxInSavedVertexesTab }, // SavedVertexes
{ 0, 0, 0, MaxInSavedQuaternionsTab}, // SavedQuaternions
{ 0, 0, 0, MaxInSavedNTTOTab }, // Saved FrameNumber and TypeOfObject
{ 0, 0, 0, MaxInFileA3dAnimationGENERALTab },
{ 0, 0, 0, MaxInFileVertexesTab },
{ 0, 0, 0, MaxInFileQuaternionsTab },
{ 0, 0, 0, MaxInFileHierarchyTab },
{ 0, 0, 0, MaxInFileNTTOTab },
{ 0, 0, 0, MaxInFileOnlyFrameTab },
{ 0, 0, 0, MaxInFileKeyFrameTab },
{ 0, 0, 0, MaxInFileFrameTab },
{ 0, 0, 0, MaxInFileChannelTab },
{ 0, 0, 0, MaxInFileEventTab },
{ 0, 0, 0, MaxInMorphTab },
{ 0, 0, 0, MaxInSndEventIdTab },
{ 0, 0, 0, MaxInEventTab }
};
tdFileName ax_xStrings [MaxInStringsTab];
tdxVector3 axa3_xVertexes [MaxInVertexesTab];
tdxQuater4 axa4_xBinQuaternions [MaxInQuaternionsTab];
tdstBinA3dAnimationGENERAL ax_tdstA3dGENERAL [MaxInA3dGENERALTab];
tdstBinChannel ax_tdstChannels [MaxInChannelsTab];
tdstBinFrame ax_tdstFrames [MaxInFramesTab];
unsigned long ax_ulFramesNTTO [MaxInFramesNTTOTab];
tdstBinOnlyFrame ax_tdstOnlyFrames [MaxInOnlyFramesTab];
tdstBinHierarchy ax_tdstHierarchies [MaxInHierarchiesTab];
tdFileName ax_xChannelNames [MaxInChannelNamesTab];
tdxVector3 ax_tdxSavedVertexes [MaxInSavedVertexesTab];
tdxQuater4 ax_tdxSavedQuaternions [MaxInSavedQuaternionsTab];
tdstNTTO ax_tdstSavedNTTO [MaxInSavedNTTOTab];
tdstFileA3dAnimationGENERAL ax_tdstFileA3dGENERAL [MaxInFileA3dAnimationGENERALTab];
tdxULongVector3 ax_tdxFileVertexes [MaxInFileVertexesTab];
tdxSShortQuater4 ax_tdxFileQuaternions [MaxInFileQuaternionsTab];
tdstFileHierarchy ax_tdstFileHierarchy [MaxInFileHierarchyTab];
tdstNTTO ax_tdstFileNTTO [MaxInFileNTTOTab];
tdstFileOnlyFrame ax_tdstFileOnlyFrame [MaxInFileOnlyFrameTab];
tdstFileKeyFrame ax_tdstFileKeyFrame [MaxInFileKeyFrameTab];
tdstFileFrame ax_tdstFileFrame [MaxInFileFrameTab];
unsigned short ax_uwFramesNTTO [];
tdstFileChannel ax_tdstFileChannel [MaxInFileChannelTab];
tdstFileEvent ax_tdstFileEvent [MaxInFileEventTab];
tdstFileMorphData ax_tdstFileMorphInfos [MaxInFileMorphTab];
tdstSndEventId ax_tdstSndEventId [MaxInSndEventIdTab];
tdstBinEvent ax_tdstEvents [MaxInEventTab];
tdstBinMorphData ax_tdstBinMorphInfos [MaxInMorphTab];
tdxVector3 a3_xVector0= { 0, 0, 0 };
tdxVector3 a3_xVector1= { 1, 1, 1 };
tdxQuater4 a4_xQuater0= { 0, 0, 0, 0 };
FILE *ErrorFile, *WarningFile, *SizeOut, *EventFile;
// **********************************************************************************
void fn_v_AllocateOnStack( unsigned short uwNumStack,
signed long slWantedSize )
{
tdstStacks[uwNumStack].slStackPos += slWantedSize;
tdstStacks[uwNumStack].slAllocNeeded += slWantedSize;
if (tdstStacks[uwNumStack].slStackPos > tdstStacks[uwNumStack].slMaxPos)
{ fprintf( ErrorFile, "%s : Stack #%d is full (monty)...\n", AnimationName, uwNumStack );
assert(FALSE);
tdstStacks[uwNumStack].slStackPos= tdstStacks[uwNumStack].slMaxPos - slWantedSize;
}
tdstStacks[uwNumStack].slPosAlloc= tdstStacks[uwNumStack].slStackPos - slWantedSize;
}
// **********************************************************************************
void fn_v_DeAllocateOnStack( unsigned short uwNumStack,
signed long slSize )
{
tdstStacks[uwNumStack].slStackPos-= slSize;
if (tdstStacks[uwNumStack].slStackPos < 0)
{ fprintf( ErrorFile, "%s : Stack #%d is over (2 be) free...\n", AnimationName, uwNumStack );
assert(FALSE);
tdstStacks[uwNumStack].slStackPos= 0;
}
}
// **********************************************************************************
void fn_v_ResetStacks( void )
{ unsigned short uwCnt;
for ( uwCnt=0 ; uwCnt<eStackBinNbMax ; uwCnt++ )
{ tdstStacks[uwCnt].slPosAlloc= 0;
tdstStacks[uwCnt].slStackPos= 0;
}
}
// **********************************************************************************
void fn_vCheckStacks( void )
{ unsigned short uwCnt;
for ( uwCnt=0 ; uwCnt<eStackBinNbMax ; uwCnt++ )
{ if (tdstStacks[uwCnt].slMaxPos < tdstStacks[uwCnt].slAllocNeeded)
fprintf( ErrorFile, "%s : Stack #%d max must be raise over %d (Now MAx = %d)\n", AnimationName,uwCnt,tdstStacks[uwCnt].slAllocNeeded,tdstStacks[uwCnt].slMaxPos);
//else
// fprintf( ErrorFile, "%s : Stack #%d use %d Elemnt and max is %d\n", AnimationName,uwCnt,tdstStacks[uwCnt].slStackPos,tdstStacks[uwCnt].slMaxPos);
}
}
// **********************************************************************************
static int gs_iPrintPos = 0;
void fn_v_LogSectionBegin( int _bFlagNew,
char *_szType,
char *_szString )
{ int iCnt;
char szTxt[1024];
for ( iCnt=0 ; iCnt<gs_iPrintPos ; iCnt++ )
putchar(' ');
gs_iPrintPos++;
if (_bFlagNew)
sprintf( szTxt, "New %s:%s", _szType, _szString );
else sprintf( szTxt, "Old %s:%s", _szType, _szString );
printf( "%s\n", szTxt );
}
void fn_v_LogSectionEnd(void)
{ gs_iPrintPos--;
}
// **********************************************************************************
void fn_v_InitMemV6i( void )
{
Erm_M_InitErrMsg(Erm);
Erm_M_InitErrMsg(Mmg);
Mmg_fn_vFirstInitMmgModule(10);
// For morphing datas -> reset !
memset(ax_tdstBinMorphInfos,0,MaxInMorphTab*sizeof(tdstBinMorphData));
SCR_fn_v_RdL0_Init();
}
// **********************************************************************************
void fn_v_KillMem( void )
{//#ifndef SCR_DM_LightVersion
//fn_v_Anl_CloseModule(); // Destroy CallBack
fn_v_Cxt_CloseModule();
fn_v_Err_CloseModule();
//#endif /* SCR_DM_LightVersion */
fn_v_Link_CloseModule();
fn_v_File_CloseModule();
//#ifndef SCR_DM_LightVersion
fn_v_Ntfy_CloseModule();
fn_v_Sect_CloseModule();
fn_v_Vars_CloseModule();
//#endif /* SCR_DM_LightVersion */
}
// **********************************************************************************
#undef L_GLOBAL_V6_C