Add rayman2 source files

This commit is contained in:
2024-09-18 02:33:44 +08:00
parent bcc093f8ed
commit fb036c54fd
14339 changed files with 2596224 additions and 0 deletions

View File

@@ -0,0 +1,139 @@
/*ANNECY CT 20/02/98{*/
#include "TOOLSCPA.h"
#include "GAM.H"
#include "PlayAnim/Anim.h"
#include "ZeMem.h"
#include "GAM\STRUCTUR\anim_s.h"
#include "gam/actions/3ddata.h"
/*******************************************************/
/* Function : fn_vFreeJustStructAnim*/
/* Input : Animation*/
/**/
/* Free just the structure (pointer fields are not freed)*/
/**/
/* Create : 20/02/98 Carlos Torres*/
/*******************************************************/
/*void fn_vFreeJustStructAnim(tdstAnim3d * p_stAnim) {
M_GameFreeInHLM(p_stAnim);
}*/
/*******************************************************/
/* Function : fn_vFreeSubStructAnim*/
/* Input : Animation*/
/**/
/* Free sub structure in the animation structure*/
/* the structre tdstAnim3d is not freed*/
/**/
/* Create : 20/02/98 Carlos Torres*/
/* Modif : Free Morphing table (Carlos Torres) 06/03/98*/
/*******************************************************/
/*void fn_vFreeSubStructAnim(tdstAnim3d * p_stAnim)
{
int iFrame,j;
if (!p_stAnim)
return;
// free Frame Table
if (p_stAnim->d_stFrame3d) {
tdstFrame3d * p_stFrame3d;
MTH3D_tdstVector * p_stPreviousLinearSpeedVector=NULL;
MTH3D_tdstMatrix * p_stPreviousAngularSpeedMatrix=NULL;
tdstPLA_Hierarchy * p_stPreviousHierarchy=NULL;
// free all frames
for(iFrame=0,p_stFrame3d=p_stAnim->d_stFrame3d;iFrame<p_stAnim->uwNumberOfFrames;iFrame++,p_stFrame3d++) {
tdstElement3d * p_stElement3d;
// Free Element table
for(j=0,p_stElement3d=p_stFrame3d->p_stArrayOfElts3d;j<p_stAnim->ucMaxNumberOfElements;j++,p_stElement3d++)
{
if (iFrame==1)
{
M_GameFreeInHLM(p_stElement3d->stMatrix);
}
else if (!POS_fn_vIsMatrixIdentityConst(p_stElement3d->stMatrix))
{
POS_M_GameFree(p_stElement3d->stMatrix);
}
}
//del table of element
M_GameFreeInHLM(p_stFrame3d->p_stArrayOfElts3d);
// free speed if different from the previous
if (p_stFrame3d->p_stAngularSpeedMatrix != p_stPreviousAngularSpeedMatrix) {
p_stPreviousAngularSpeedMatrix = p_stFrame3d->p_stAngularSpeedMatrix;
M_GameFreeInHLM(p_stFrame3d->p_stAngularSpeedMatrix);
}
if (p_stFrame3d->p_stLinearSpeedVector != p_stPreviousLinearSpeedVector) {
p_stPreviousLinearSpeedVector = p_stFrame3d->p_stLinearSpeedVector;
M_GameFreeInHLM(p_stFrame3d->p_stLinearSpeedVector);
}
// free hierarchy if different from the previous
if (p_stFrame3d->p_stHierarchy != p_stPreviousHierarchy) {
p_stPreviousHierarchy = p_stFrame3d->p_stHierarchy;
M_GameFreeInHLM(p_stFrame3d->p_stHierarchy->d_stCouples);
M_GameFreeInHLM(p_stFrame3d->p_stHierarchy);
}
}
M_GameFreeInHLM(p_stAnim->d_stFrame3d);
}
// Free Event Table
if (p_stAnim->d_stAnimEvent) {
M_GameFreeInHLM(p_stAnim->d_stAnimEvent);
}
// Free light Table
if (p_stAnim->p_stLights) {
GLI_tdstLight ** p_p_stLight;
for(j=0,p_p_stLight=p_stAnim->p_stLights->a_p_stLights;j<p_stAnim->p_stLights->uwNumberOfLights;j++,p_p_stLight++)
M_GameFreeInHLM(*p_p_stLight);
M_GameFreeInHLM(p_stAnim->p_stLights->a_p_stLights);
M_GameFreeInHLM(p_stAnim->p_stLights->a_hLightsInSector);
M_GameFreeInHLM(p_stAnim->p_stLights);
}
}*/
/*ENDANNECY CT}*/
/*******************************************************/
/* Function : ANI_fn_vFreeze*/
/* Input : Super Object*/
/**/
/* Freeze tha animation of the character*/
/* no more treat by the anim player*/
/**/
/* Create : 13/03/98 Carlos Torres*/
/*******************************************************/
void ANI_fn_vFreeze(HIE_tdxHandleToSuperObject hSuperObjPerso) {
MS_tdxHandleTo3dData h_Current3dData = M_GetMSHandle(hSuperObjPerso,3dData);
/* set speed to zero (if not freeze)*/
if (fn_uc3dDataGetFrameRate(h_Current3dData))
fn_v3dDataSetFrameRate(h_Current3dData,0);
}
/*******************************************************/
/* Function : ANI_fn_vUnFreeze*/
/* Input : Super Object*/
/**/
/* UnFreeze tha animation of the character*/
/* animation restart at the freezed frame*/
/**/
/* Create : 13/03/98 Carlos Torres*/
/*******************************************************/
void ANI_fn_vUnFreeze(HIE_tdxHandleToSuperObject hSuperObjPerso) {
MS_tdxHandleTo3dData h_Current3dData = M_GetMSHandle(hSuperObjPerso,3dData);
if (!fn_uc3dDataGetFrameRate(h_Current3dData)) {
/* reset speed*/
fn_v3dDataSetFrameRate(h_Current3dData,fn_scGetSpeedInState(fn_h3dDataGetCurrentState(h_Current3dData)));
/* reinit current frame*/
PLA_fn_vSetCurrFrame(hSuperObjPerso,(short)(fn_uw3dDataGetCurrentFrame(h_Current3dData)+1));
}
}

View File

@@ -0,0 +1,843 @@
/* ***********************************************************************************/
/* * "a3x_cach.c" **/
/* * Written by : S<>bastien Rubens **/
/* * Tabulations : 4 char **/
/* ***********************************************************************************/
#define A3X_CACH_C
/* ***********************************************************************************/
/* Included files*/
#include "PlayAnim/Interpol/specif/a3x_pref.h"
/*#define LST2_StaticIsOptimised*/
#include "TOOLSCPA.h"
#include "cpa_std.h"
#include "STRUCTUR/Anim_s.h"
#include "STRUCTUR/Engmode.h"
#ifdef A3X_N64
#include "u_dma.h"
#include "memload.h"
#include "ZeMem.h"
#endif
#include "PlayAnim/Interpol/a3x_glob.h"
#include "PlayAnim/Interpol/a3x_load.h"
#include "PlayAnim/Interpol/a3x_mem.h"
#include "PlayAnim/Interpol/a3x_cach.h"
#define UseCompressedAnimations
#ifdef U64
#include "RastMem.h"
#endif /* U64 */
/* ***************************************************************************************************/
#ifdef UseCompressedAnimations
extern void slidstart( unsigned char *, unsigned char * );
#endif
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
unsigned short uwMaxInStackFrame3d= 0, uwMaxInStackElement3d= 0;
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
char *p_cLoadAnimBuf;
char *p_cCompressedAnimBuf;
/*AR9901 For debug -> to be removed !*/
#ifdef ANIM_DEBUG
char* g_p_cSecurityMalloc;
#endif /*ANIM_DEBUG*/
/* ***************************************************************************************************/
unsigned short uwMaxNumberOfAnims= 2000;
/* Input cache*/
#ifdef A3X_CacheIsUsed
#define NbCacheLists 5
#endif
/* Output cache*/
#define uwMaxInTabFrame3d 100
#define uwMaxInTabElement3d 1000
#ifdef A3X_N64
extern char _animsSegmentRomStart[];
extern char _animsSegmentRomEnd[];
#ifndef FORCE_REAL_TIME_LOAD
extern char _anims_rawSegmentRomStart[];
extern char _anims_rawSegmentRomEnd[];
#endif
extern char _shortAnimsSegmentRomStart[];
extern char _shortAnimsSegmentRomEnd[];
extern char _a3dheaderSegmentRomStart[];
extern char _a3dheaderSegmentRomEnd[];
#ifdef A3X_CUT
extern char _cuttableSegmentRomStart[];
extern char _cuttableSegmentRomEnd[];
#endif
#endif
/* Max size of cutted animation*/
#define MaxSizeOfList (MaxRAMSizeOfAnim/1024)
/* ***************************************************************************************************/
/* Input cache*/
#ifdef A3X_N64
unsigned long ulNbIntAnims;
unsigned long *p_ulAnimOffsets;
#endif
#ifdef A3X_CacheIsUsed
unsigned long ulMaxRamSizeOfAnim, ulMaxRomSizeOfAnim;
char *p_cBigMalloc;
tdstCacheLine *p_stCacheLine;
tdstA3dHeader *p_stA3dHeaders;
char *p_cMemBlocs;
unsigned short ax_uwCacheList[NbCacheLists]; /* Tete de liste*/
unsigned short ax_uwCacheListNbElt[]= /* Nombre de cases par zone*/
{
25, /* Zone 1*/
8,
7,
7,
10
};
unsigned short ax_uwCacheListSize[]=
{
1,
3,
5,
7,
10,
(MaxSizeOfList+1)
};
unsigned short ax_uwSizeToList[MaxSizeOfList];
unsigned long ulNumberOfCacheLines;
#endif
/* ***************************************************************************************************/
unsigned short *p_uwLastA3dGENERAL;
/* ***************************************************************************************************/
/* Output cache*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
unsigned long ulLastEngineFrame= 0xFFFFFFFF;
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*tdstOutputCacheLine ax_stOutputCacheLine[uwMaxInTabFrame3d]; // Useless now... AR9808*/
#ifdef A3X_N64
/* Global variables used by loading functions*/
char* g_p_cROMAnimBlocStart=_animsSegmentRomStart;
#ifdef ANIM_DEBUG
char* g_p_cROMAnimBlocStop=_animsSegmentRomEnd;
#endif
#endif
#ifndef FORCE_REAL_TIME_LOAD
int g_bRealTimeAnimationLoad = FALSE;
#endif
#ifdef A3X_N64
/*-----------------------------------------------------------------------------
* Name : fn_vInitROMLoad
*-----------------------------------------------------------------------------
* Description : Initialise the ROM loading system for the animation
* (Real time load or use memory extension)
*-----------------------------------------------------------------------------
* Input :
* Output :
*-----------------------------------------------------------------------------
* Creation date : Oct 98 Author : Al1
*-----------------------------------------------------------------------------*/
#ifndef FORCE_REAL_TIME_LOAD
void fn_vInitROMLoad(void)
{
#ifdef A3X_REAL_TIME_LOAD
g_p_cROMAnimBlocStart=_animsSegmentRomStart;
g_p_cROMAnimBlocStop=_animsSegmentRomEnd;
g_bRealTimeAnimationLoad=TRUE;
return;
#endif /*A3X_REAL_TIME_LOAD*/
if(osMemSize>4194304) /* memory available > 4M*/
{
/* Here we can load all the animation in RAM*/
g_p_cROMAnimBlocStart=_anims_rawSegmentRomStart;
g_p_cROMAnimBlocStop=_anims_rawSegmentRomEnd;
g_bRealTimeAnimationLoad=FALSE;
}
else
{
/* Here we must use real time load system*/
g_p_cROMAnimBlocStart=_animsSegmentRomStart;
g_p_cROMAnimBlocStop=_animsSegmentRomEnd;
g_bRealTimeAnimationLoad=TRUE;
}
}
#endif
#endif /*A3X_N64*/
/* ***************************************************************************************************/
#ifdef A3X_N64
void *fn_p_ReadAnimFromROM( unsigned short _uwNumOfIntAnim )
{
#ifdef A3X_N64
#ifdef ANIM_DEBUG
if ( _uwNumOfIntAnim >= ulNbIntAnims )
{
osSyncPrintf("fn_p_ReadAnimFromROM1 : num<75>ro d'animation trop grand\n");
osSyncPrintf("fn_p_ReadAnimFromROM1 : _uwNumOfIntAnim = %d\n", _uwNumOfIntAnim );
ASM_BREAK;
}
if ( g_p_cROMAnimBlocStart + (0x7FFFFFFF & p_ulAnimOffsets[_uwNumOfIntAnim + 1]) > g_p_cROMAnimBlocStop )
{
osSyncPrintf("fn_p_ReadAnimFromROM2 : chargement d'anims trop grand\n");
osSyncPrintf("fn_p_ReadAnimFromROM2 : _uwNumOfIntAnim = %d\n", _uwNumOfIntAnim );
ASM_BREAK;
}
#endif /*ANIM_DEBUG*/
#endif
#ifdef UseCompressedAnimations
if (p_ulAnimOffsets[_uwNumOfIntAnim] & 0x80000000)
{
LDR_fn_vLoadFromROM( ( g_p_cROMAnimBlocStart + (0x7FFFFFFF & p_ulAnimOffsets[_uwNumOfIntAnim] )),
( g_p_cROMAnimBlocStart + (0x7FFFFFFF & p_ulAnimOffsets[_uwNumOfIntAnim + 1]) ),
p_cCompressedAnimBuf,
MSG_BLOCK );
slidstart(p_cCompressedAnimBuf, p_cLoadAnimBuf);
}
else
#endif
LDR_fn_vLoadFromROM( ( g_p_cROMAnimBlocStart + p_ulAnimOffsets[_uwNumOfIntAnim] ),
( g_p_cROMAnimBlocStart + (0x7FFFFFFF & p_ulAnimOffsets[_uwNumOfIntAnim + 1]) ),
p_cLoadAnimBuf,
MSG_BLOCK );
return ((void *) p_cLoadAnimBuf);
}
#endif
/* ***************************************************************************************************/
#ifdef A3X_CUT
tdstShortA3dGENERAL *fn_p_ReadShortAnimFromROM( unsigned short _uwNumOfIntAnim )
{
LDR_fn_vLoadFromROM( ( _shortAnimsSegmentRomStart + _uwNumOfIntAnim * sizeof(tdstShortA3dGENERAL) ),
( _shortAnimsSegmentRomStart + (_uwNumOfIntAnim + 1) * sizeof(tdstShortA3dGENERAL) ),
p_cLoadAnimBuf,
MSG_BLOCK );
return ((tdstShortA3dGENERAL *) p_cLoadAnimBuf);
}
/* ***************************************************************************************************/
#endif
#ifdef A3X_CacheIsUsed
void *fn_p_Align16( void *p_vPointer )
{
if ( (((unsigned long) p_vPointer) & 0x0000000F) != 0x00000000 )
return ( (void *) ((((unsigned long) p_vPointer) & 0xFFFFFFF0) + 0x00000010) );
else return p_vPointer;
}
#endif
/* ***************************************************************************************************/
#ifdef A3X_CacheIsUsed
void fn_v_CacheAllocation( void )
{
/* p_stOutputCacheLine= (tdstOutputCacheLine *) fn_p_Align16( p_cBigMalloc );*/
p_stCacheLine= (tdstCacheLine *) fn_p_Align16( p_cBigMalloc );
p_ulAnimOffsets= (unsigned long *) fn_p_Align16( &p_stCacheLine[ulNumberOfCacheLines] );
/*HP980806*/
/* p_stFrame3d= (tdstFrame3d *) fn_p_Align16( &p_ulAnimOffsets[1 + ulNbIntAnims] );*/
/* p_p_stElement3d= (tdstElement3d* *) fn_p_Align16( &p_stFrame3d[uwMaxInTabFrame3d] );*/
/* p_stAngularSpeedMatrix= (MTH3D_tdstMatrix *) fn_p_Align16( &p_p_stElement3d[uwMaxInTabElement3d] );*/
/* p_stHierarchy= (tdstPLA_Hierarchy *) fn_p_Align16( &p_stAngularSpeedMatrix[uwMaxInTabFrame3d] );*/
/* p_stElement3d= (tdstElement3d *) fn_p_Align16( &p_stHierarchy[uwMaxInTabFrame3d] );*/
/* p_stPosMatrix= (POS_tdstCompletePosition *) fn_p_Align16( &p_stElement3d[uwMaxInTabElement3d] ); */
/* p_cLoadAnimBuf= (char *) fn_p_Align16( &p_stPosMatrix[uwMaxInTabElement3d] );*/
p_cLoadAnimBuf= (char *) fn_p_Align16( &p_ulAnimOffsets[1 + ulNbIntAnims] );
/* p_cCompressedAnimBuf= (char *) fn_p_Align16( &p_cLoadAnimBuf[ulMaxRamSizeOfAnim] );*/
p_stA3dHeaders= (tdstA3dHeader *) fn_p_Align16( &p_cLoadAnimBuf[ulMaxRamSizeOfAnim] );
#ifdef A3X_CUT
p_uwLastA3dGENERAL= (unsigned short *) fn_p_Align16( &p_stA3dHeaders[ulNbIntAnims] );
p_stCuttedAnim= (tdstCuttedAnim *) fn_p_Align16( &p_uwLastA3dGENERAL[ulNbIntAnims] );
p_cMemBlocs= (char *) fn_p_Align16( &p_stCuttedAnim[ulNbIntAnims] );
#else
p_cMemBlocs= (char *) fn_p_Align16( &p_stA3dHeaders[ulNbIntAnims] );
#endif
}
#endif
#ifdef A3X_CacheIsUsed
/* ***************************************************************************************************/
void fn_v_InitCache( void )
{
unsigned long ulNumOfAnim;
unsigned long ulStart, ulNumInSizeToList, ulOld, ulCnt2;
unsigned long ulNbElem, ulNumOfBloc;
unsigned long ulCnt1;
#ifndef FORCE_REAL_TIME_LOAD
if(g_bRealTimeAnimationLoad)
{
#endif
#if defined(FINAL_VERSION) && !defined(FINAL_VERSION_FOR_TESTERS)
/* When we are in final version mode, we can increase the anim cache */
if(osMemSize>C_4Megs) /* RAM xtension detected */
{
ax_uwCacheListNbElt[0]+=250;
ax_uwCacheListNbElt[1]+=80;
ax_uwCacheListNbElt[2]+=100;
ax_uwCacheListNbElt[3]+=140;
ax_uwCacheListNbElt[4]+=180;
}
#endif /* defined(FINAL_VERSION) && !defined(FINAL_VERSION_FOR_TESTERS) */
/* ----------------------------------------------------------------------------------------------*/
/* Init ax_uwSizeToList table*/
ulNumInSizeToList= 0;
ulOld= 0;
for ( ulCnt1=0 ; ulCnt1<NbCacheLists ; ulCnt1++ )
{
for ( ulCnt2=ulOld ; ulCnt2<ax_uwCacheListSize[ulCnt1] ; ulCnt2++ )
ax_uwSizeToList[ulNumInSizeToList++]= (unsigned short) ulCnt1;
ulOld= ax_uwCacheListSize[ulCnt1];
}
/* ----------------------------------------------------------------------------------------------*/
/* Init p_stCacheLine table*/
ulNumberOfCacheLines= 0;
for ( ulCnt1=0 ; ulCnt1<NbCacheLists ; ulCnt1++ )
ulNumberOfCacheLines+= ax_uwCacheListNbElt[ulCnt1];
/* ----------------------------------------------------------------------------------------------*/
/* p_cBigMalloc= (char *) M_p_GameMallocInHLM( (uwMaxNumberOfAnims+1L)*sizeof(unsigned long) ); // WithoutFree !!!*/
p_cBigMalloc= (char *) fn_pvAllocTmp( (uwMaxNumberOfAnims+1L)*sizeof(unsigned long), 16 ); /* WithFree*/
/* Read number of animations*/
p_ulAnimOffsets= (unsigned long *) fn_p_Align16( p_cBigMalloc );
LDR_fn_vLoadFromROM( ( g_p_cROMAnimBlocStart ),
( g_p_cROMAnimBlocStart + 3*sizeof(unsigned long) ),
(char *) p_ulAnimOffsets,
MSG_BLOCK );
ulNbIntAnims= *((unsigned long *) &p_ulAnimOffsets[0]);
ulMaxRamSizeOfAnim= *((unsigned long *) &p_ulAnimOffsets[1]);
ulMaxRomSizeOfAnim= *((unsigned long *) &p_ulAnimOffsets[2]);
fn_vFreeRomTmp( (void *)p_cBigMalloc ); /* Oliv'*/
#ifdef UseCompressedAnimations
GEO_M_CPAMalloc(p_cCompressedAnimBuf,char *,ulMaxRomSizeOfAnim+16,E_uwGEONotEnoughtMemory);
p_cCompressedAnimBuf=(char*)fn_p_Align16(p_cCompressedAnimBuf); /* 16 bytes aligned for DMA transferts*/
#endif /*UseCompressedAnimations*/
/* ----------------------------------------------------------------------------------------------*/
/* Set relatives pointers*/
p_cBigMalloc= NULL;
fn_v_CacheAllocation();
/* Calculate memory size to allocate*/
ulNumOfAnim= ((unsigned long) p_cMemBlocs) - ((unsigned long) p_cBigMalloc);
for ( ulCnt1=0 ; ulCnt1<NbCacheLists ; ulCnt1++ )
ulNumOfAnim+= ax_uwCacheListSize[ulCnt1] * 1024L * ax_uwCacheListNbElt[ulCnt1];
/* Allocate memory*/
#ifdef U64
RM_fn_vInitAddInfo();
#endif /* U64 */
GEO_M_CPAMalloc(p_cBigMalloc,char *,ulNumOfAnim+16,E_uwGEONotEnoughtMemory); /* +16 because the address allocated can be not aligned to 16 chars !*/
#ifdef U64
RM_fn_vAddInfo(eAnimPlayerCach,eSubAnimPlayerCach,eGeo);
#endif /* U64 */
fn_v_CacheAllocation();
M_PrintfN64((" Malloc animations = %d octets\n", ulNumOfAnim));
#ifdef ANIM_DEBUG
/* 1Ko added For security ! AR9901*/
GEO_M_CPAMalloc(g_p_cSecurityMalloc,char *,1024,E_uwGEONotEnoughtMemory);
memset(g_p_cSecurityMalloc,0xA1,1024);
#endif /*ANIM_DEBUG*/
/* ----------------------------------------------------------------------------------------------*/
/* Used in fn_p_GetEventsAddress to get last cutted animation A3dGENERAL (avoid first cutted animation loading)*/
for ( ulCnt1=0 ; ulCnt1<ulNbIntAnims ; ulCnt1++ )
p_uwLastA3dGENERAL[ulCnt1]= (unsigned short) ulCnt1;
/* ----------------------------------------------------------------------------------------------*/
/* Init p_stCacheLine table*/
ulNumOfBloc= 0;
ulStart= 0;
for ( ulCnt1=0 ; ulCnt1<NbCacheLists ; ulCnt1++ )
{ ax_uwCacheList[ulCnt1]= (unsigned short) ulStart; /* Beginning of list*/
ulNbElem= ax_uwCacheListNbElt[ulCnt1];
for ( ulCnt2=0 ; ulCnt2<ulNbElem ; ulCnt2++ )
{
p_stCacheLine[ulStart + ulCnt2].slCacheValue= -4096;
p_stCacheLine[ulStart + ulCnt2].uwNumOfA3dHeader= SEB_Invalid;
p_stCacheLine[ulStart + ulCnt2].uwNumOfMemBloc= (unsigned short) ulNumOfBloc;
p_stCacheLine[ulStart + ulCnt2].uwNext= (unsigned short) (ulStart + ulCnt2 + 1);
p_stCacheLine[ulStart + ulCnt2].uwPrev= (unsigned short) (ulStart + ulCnt2 - 1);
ulNumOfBloc+= ax_uwCacheListSize[ulCnt1];
}
p_stCacheLine[ulStart].uwPrev= (unsigned short) (ulStart + ulNbElem - 1);
p_stCacheLine[ulStart + ulNbElem - 1].uwNext= (unsigned short) ulStart;
ulStart+= ulNbElem;
}
/* ----------------------------------------------------------------------------------------------*/
/* Read all animations offsets (p_ulAnimOffsets table)*/
LDR_fn_vLoadFromROM( ( g_p_cROMAnimBlocStart + 4*sizeof(unsigned long) ),
( g_p_cROMAnimBlocStart + ((5 + ulNbIntAnims) * sizeof(unsigned long)) ),
(char *) p_ulAnimOffsets,
MSG_BLOCK );
/* Init p_stA3dHeaders table*/
/* for ( ulCnt1=0 ; ulCnt1<ulNbIntAnims ; ulCnt1++ )
{ tdstFileA3dAnimationGENERAL *p_stFileA3dAnimationGENERAL;
unsigned long ulSizeOfAnim;
fn_p_ReadAnimFromROM(ulCnt1);
p_stFileA3dAnimationGENERAL= (tdstFileA3dAnimationGENERAL *) p_cLoadAnimBuf;
ulSizeOfAnim= sizeof(tdstA3dGENERAL) +
sizeof(tdxVector3) * (unsigned long) p_stFileA3dAnimationGENERAL->uwNumberOfVectors +
sizeof(tdxSShortQuater4)* (unsigned long) p_stFileA3dAnimationGENERAL->uwNumberOfQuaternions +
sizeof(tdstHierarchy) * (unsigned long) p_stFileA3dAnimationGENERAL->uwNumberOfHierarchies +
sizeof(tdstNTTO) * (unsigned long) p_stFileA3dAnimationGENERAL->uwNumberOfSavedNTTO +
sizeof(tdstOnlyFrame) * (unsigned long) (p_stFileA3dAnimationGENERAL->uwEndFrame - p_stFileA3dAnimationGENERAL->uwStartFrame) +
sizeof(tdstChannel) * (unsigned long) p_stFileA3dAnimationGENERAL->uwNumberOfChannels +
sizeof(tdstFrame) * (unsigned long) p_stFileA3dAnimationGENERAL->uwNumberOfSavedFrames *
(unsigned long) p_stFileA3dAnimationGENERAL->uwNumberOfChannels +
sizeof(tdstFrameKF) * (unsigned long) (p_stFileA3dAnimationGENERAL->uwEndFrame - p_stFileA3dAnimationGENERAL->uwStartFrame) *
(unsigned long) p_stFileA3dAnimationGENERAL->uwNumberOfChannels;
if ( ((ulSizeOfAnim) & 0x0002) != 0x0000 )
ulSizeOfAnim+= 2;
ulSizeOfAnim+= sizeof(tdstKeyFrame) * (unsigned long) p_stFileA3dAnimationGENERAL->uwNumberOfKeyFrames +
sizeof(tdstEvent) * (unsigned long) p_stFileA3dAnimationGENERAL->uwNumberOfEvents;
/* alignment*/
/* while ( ((ulSizeOfAnim) % 4) != 0 )
ulSizeOfAnim++;
ulSizeOfAnim+= sizeof(tdstMorphData) * (unsigned long) p_stFileA3dAnimationGENERAL->uwNumberOfMorphData; /*AR9804*/
/*#ifdef ANIM_DEBUG
/* if (ulSizeOfAnim > MaxRAMSizeOfAnim)
{
osSyncPrintf("fn_v_InitCache (ulCnt1= %d) : ulSizeOfAnim (%d) > %d\n", ulCnt1, ulSizeOfAnim, MaxRAMSizeOfAnim);
osSyncPrintf(" uwNumberOfVectors = %4d\n", p_stFileA3dAnimationGENERAL->uwNumberOfVectors);
osSyncPrintf(" uwNumberOfQuaternions= %4d\n", p_stFileA3dAnimationGENERAL->uwNumberOfQuaternions);
osSyncPrintf(" uwNumberOfHierarchies= %4d\n", p_stFileA3dAnimationGENERAL->uwNumberOfHierarchies);
osSyncPrintf(" uwNumberOfNTTO = %4d\n", p_stFileA3dAnimationGENERAL->uwNumberOfSavedNTTO);
osSyncPrintf(" uwNumberOfOnlyFrames = %4d\n", (p_stFileA3dAnimationGENERAL->uwEndFrame - p_stFileA3dAnimationGENERAL->uwStartFrame));
osSyncPrintf(" uwNumberOfChannels = %4d\n", p_stFileA3dAnimationGENERAL->uwNumberOfChannels);
osSyncPrintf(" uwNumberOfSavedFrames= %4d\n", p_stFileA3dAnimationGENERAL->uwNumberOfSavedFrames);
osSyncPrintf(" uwNumberOfKeyFrames = %4d\n", p_stFileA3dAnimationGENERAL->uwNumberOfKeyFrames);
osSyncPrintf(" uwNumberOfEvents = %4d\n", p_stFileA3dAnimationGENERAL->uwNumberOfEvents);
osSyncPrintf(" uwNumberOfMorphData = %4d\n", p_stFileA3dAnimationGENERAL->uwNumberOfMorphData);
osSyncPrintf(" uwStartFrame = %4d\n", p_stFileA3dAnimationGENERAL->uwStartFrame);
osSyncPrintf(" uwEndFrame = %4d\n", p_stFileA3dAnimationGENERAL->uwEndFrame);
ASM_BREAK;
}
#endif /*ANIM_DEBUG*/
/* ANTIBUG -------------------------------------------------*/
// AR9904 : Optimisation. Read the a3dheader from the rom
LDR_fn_vLoadFromROM(_a3dheaderSegmentRomStart,_a3dheaderSegmentRomStart+ulNbIntAnims*sizeof(tdstA3dHeader),(char *)p_stA3dHeaders,MSG_BLOCK);
for ( ulCnt1=0 ; ulCnt1<ulNbIntAnims ; ulCnt1++ )
{
unsigned long ulSizeOfAnim;
ulSizeOfAnim=(unsigned long)p_stA3dHeaders[ulCnt1].uwCacheList;
#ifdef ANIM_DEBUG
if (ulSizeOfAnim > MaxRAMSizeOfAnim)
{
osSyncPrintf("Size for %d =%d\n",ulCnt1,ulSizeOfAnim);
ASM_BREAK;
}
#endif /*ANIM_DEBUG*/
if ( (ulSizeOfAnim & 0x03FF) == 0 ) /* mod 1024*/
ulSizeOfAnim= (ulSizeOfAnim >> 10) - 1; /* div 1024 - 1*/
else
ulSizeOfAnim= (ulSizeOfAnim >> 10); /* div 1024*/
p_stA3dHeaders[ulCnt1].uwCacheList= ax_uwSizeToList[ulSizeOfAnim];
}
// }
#ifdef A3X_CUT
LDR_fn_vLoadFromROM( _cuttableSegmentRomStart,
_cuttableSegmentRomEnd,
(char *) p_stCuttedAnim,
MSG_BLOCK );
#endif
#ifndef FORCE_REAL_TIME_LOAD
}
#endif
}
#endif
/* ***************************************************************************************************/
void fn_v_UpdateCache( unsigned short _uwNumOfA3dGENERAL,
unsigned long _ulFrameNumber )
{
#ifdef A3X_CacheIsUsed
register unsigned short uwOffset, uwNumOfCacheList, uwFirstOfCacheList;
#ifdef A3X_N64
#ifdef ANIM_DEBUG
if ( _uwNumOfA3dGENERAL >= ulNbIntAnims )
{
osSyncPrintf("fn_v_UpdateCache : _uwNumOfA3dGENERAL trop grand\n");
osSyncPrintf("_uwNumOfA3dGENERAL = %d\n",_uwNumOfA3dGENERAL);
ASM_BREAK;
}
#endif /*ANIM_DEBUG*/
#endif
uwNumOfCacheList= p_stA3dHeaders[ _uwNumOfA3dGENERAL ].uwCacheList; /* Number of Cache list (static value !)*/
uwOffset= p_stA3dHeaders[ _uwNumOfA3dGENERAL ].uwNumOfCacheEntry; /* NumOfCacheEntry*/
uwFirstOfCacheList= ax_uwCacheList[ uwNumOfCacheList ]; /* First element of the cache list*/
p_stCacheLine[ uwOffset ].slCacheValue= _ulFrameNumber; /* ulFrameNumber*/
if ( uwOffset != uwFirstOfCacheList )
{
while ( ((signed long) _ulFrameNumber > p_stCacheLine[ p_stCacheLine[uwOffset].uwPrev ].slCacheValue) &&
(p_stCacheLine[uwOffset].uwNext != uwFirstOfCacheList) )
{ register unsigned short uwFirst, uwSecond, uwQuat; /* And uwOffset (as third)*/
uwSecond= p_stCacheLine[uwOffset].uwPrev;
uwFirst= p_stCacheLine[uwSecond].uwPrev;
uwQuat= p_stCacheLine[uwOffset].uwNext;
/* And now, we have uwFirst, uwOffset (as second) and uwSecond (as third)*/
p_stCacheLine[uwFirst].uwNext= uwOffset;
p_stCacheLine[uwSecond].uwPrev= uwOffset;
p_stCacheLine[uwSecond].uwNext= uwQuat;
p_stCacheLine[uwOffset].uwPrev= uwFirst;
p_stCacheLine[uwOffset].uwNext= uwSecond;
p_stCacheLine[uwQuat].uwPrev= uwSecond;
}
/* Change first element of CacheList*/
if (p_stCacheLine[uwOffset].uwNext == uwFirstOfCacheList) /* If next element is the old first element*/
ax_uwCacheList[ uwNumOfCacheList ]= uwOffset;
}
#endif
}
/* ***************************************************************************************************/
tdstA3dGENERAL *fn_p_GetA3dGENERAL( unsigned short _uwNumOfA3dGENERAL,
unsigned long _ulFrameNumber )
{
#ifdef A3X_N64
#ifndef FORCE_REAL_TIME_LOAD
if(g_bRealTimeAnimationLoad)
{
#endif
#ifdef ANIM_DEBUG
if ( _uwNumOfA3dGENERAL >= ulNbIntAnims )
{
osSyncPrintf("fn_p_GetA3dGENERAL : _uwNumOfA3dGENERAL trop grand\n");
osSyncPrintf("_uwNumOfA3dGENERAL = %d\n",_uwNumOfA3dGENERAL);
ASM_BREAK;
}
#endif /*ANIM_DEBUG*/
_ulFrameNumber=g_stEngineStructure.stEngineTimer.ulTrameNumber; /*because frame number should be called trame number !*/
if ( p_stA3dHeaders[_uwNumOfA3dGENERAL].uwNumOfCacheEntry == SEB_Invalid )
{ /* Animation is non loaded*/
register unsigned short uwOffset, uwOldestA3dHeader, uwNumOfCacheList;
/* Invalidate oldest cached A3dHeader*/
uwNumOfCacheList= p_stA3dHeaders[ _uwNumOfA3dGENERAL ].uwCacheList; /* Number of Cache list (static value !)*/
uwOffset= ax_uwCacheList[ uwNumOfCacheList ]; /* First element of the cache list*/
uwOffset= p_stCacheLine[ uwOffset ].uwPrev; /* Last element of the cache list*/
uwOldestA3dHeader= p_stCacheLine[ uwOffset ].uwNumOfA3dHeader;
if ( uwOldestA3dHeader != SEB_Invalid ) /* Animation is loaded ???*/
{
p_stA3dHeaders[uwOldestA3dHeader].uwNumOfCacheEntry= SEB_Invalid; /* Yes -> unload animation*/
#ifdef ANIM_DEBUG
if(p_stCacheLine[uwOffset].slCacheValue==_ulFrameNumber)
osSyncPrintf("Saturation cache %d\n",uwNumOfCacheList);
#endif /*ANIM_DEBUG*/
}
/* Update cache values*/
p_stA3dHeaders[_uwNumOfA3dGENERAL].uwNumOfCacheEntry= uwOffset; /* New Element*/
p_stCacheLine[uwOffset].uwNumOfA3dHeader= _uwNumOfA3dGENERAL; /* Change uwNumOfA3dHeader*/
p_stCacheLine[uwOffset].slCacheValue= (signed long) _ulFrameNumber; /* Update slCacheValue*/
/*p_stCacheLine[uwOffset].uwNumOfMemBloc (static value !)*/
/*p_stCacheLine[uwOffset].uwNext (is not changed)*/
/*p_stCacheLine[uwOffset].uwPrev (is not changed)*/
ax_uwCacheList[uwNumOfCacheList]= uwOffset; /* Update first position of the cache list*/
/* Load animation in p_cMemBlocs*/
/* osSyncPrintf("fn_p_GetA3dGENERAL : chargement animation #%d -> cache %d\n", _uwNumOfA3dGENERAL,p_stA3dHeaders[_uwNumOfA3dGENERAL].uwNumOfCacheEntry);*/
fn_v_LoadCachedAnimV6( &p_cMemBlocs[ ((unsigned long) p_stCacheLine[uwOffset].uwNumOfMemBloc) << 10 ],
fn_p_ReadAnimFromROM(_uwNumOfA3dGENERAL),ax_uwCacheListSize[p_stA3dHeaders[_uwNumOfA3dGENERAL].uwCacheList]*1024);
#ifdef ANIM_DEBUG
if ( ((unsigned long)&p_stMorphData[p_stA3dGENERAL->uwNumberOfMorphData] - (unsigned long)p_stA3dGENERAL) > MaxRAMSizeOfAnim )
{
/* ANTIBUG -------------------------------------------------*/
osSyncPrintf("Anim %d too big !!!\n",_uwNumOfA3dGENERAL);
osSyncPrintf("fn_v_LoadCachedAnimV6 (%d > %d)\n", ((unsigned long)&p_stEvents[p_stA3dGENERAL->uwNumberOfEvents] - (unsigned long)p_stA3dGENERAL), MaxRAMSizeOfAnim);
osSyncPrintf(" uwNumberOfFrames = %4d\n", p_stA3dGENERAL->uwNumberOfFrames);
osSyncPrintf(" uwNumberOfVectors = %4d\n", p_stA3dGENERAL->uwNumberOfVectors);
osSyncPrintf(" uwNumberOfQuaternions= %4d\n", p_stA3dGENERAL->uwNumberOfQuaternions);
osSyncPrintf(" uwNumberOfHierarchies= %4d\n", p_stA3dGENERAL->uwNumberOfHierarchies);
osSyncPrintf(" uwNumberOfNTTO = %4d\n", p_stA3dGENERAL->uwNumberOfNTTO);
osSyncPrintf(" uwNumberOfOnlyFrames = %4d\n", (p_stA3dGENERAL->uwEndFrame - p_stA3dGENERAL->uwStartFrame));
osSyncPrintf(" uwNumberOfChannels = %4d\n", p_stA3dGENERAL->uwNumberOfChannels);
osSyncPrintf(" uwNumberOfSavedFrames= %4d\n", p_stA3dGENERAL->uwNumberOfSavedFrames);
osSyncPrintf(" uwNumberOfKeyFrames = %4d\n", p_stA3dGENERAL->uwNumberOfKeyFrames);
osSyncPrintf(" uwNumberOfEvents = %4d\n", p_stA3dGENERAL->uwNumberOfEvents);
osSyncPrintf(" uwNumberOfMorphData = %4d\n", p_stA3dGENERAL->uwNumberOfMorphData);
osSyncPrintf(" uwStartFrame = %4d\n", p_stA3dGENERAL->uwStartFrame);
osSyncPrintf(" uwEndFrame = %4d\n", p_stA3dGENERAL->uwEndFrame);
osSyncPrintf(" p_stA3dGENERAL = %d\n", 0);
osSyncPrintf(" p_a3_xVectors = %d\n", (unsigned long)p_a3_xVectors - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_a4_xQuaternions = %d\n", (unsigned long)p_a4_xQuaternions - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stHierarchies = %d\n", (unsigned long)p_stHierarchies - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stNTTO = %d\n", (unsigned long)p_stNTTO - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stOnlyFrames = %d\n", (unsigned long)p_stOnlyFrames - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stChannels = %d\n", (unsigned long)p_stChannels - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stFrames = %d\n", (unsigned long)p_stFrames - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stFramesKF = %d\n", (unsigned long)p_stFramesKF - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stKeyFrames = %d\n", (unsigned long)p_stKeyFrames - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stEvents = %d\n", (unsigned long)p_stEvents - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stMorphData = %d\n", (unsigned long)p_stMorphData - (unsigned long)p_stA3dGENERAL);
ASM_BREAK;
}
#endif /*ANIM_DEBUG*/
}
else
{
/* Anim is already loaded. We must update the global pointers.*/
fn_v_UpdateCache( _uwNumOfA3dGENERAL, _ulFrameNumber );
p_stA3dGENERAL= (tdstA3dGENERAL *) &p_cMemBlocs[ ((unsigned long) p_stCacheLine[ p_stA3dHeaders[_uwNumOfA3dGENERAL].uwNumOfCacheEntry ].uwNumOfMemBloc) << 10 ];
p_a3_xVectors= (tdxVector3 *) &p_stA3dGENERAL[ 1 ];
p_a4_xQuaternions= (tdxSShortQuater4 *) &p_a3_xVectors[ p_stA3dGENERAL->uwNumberOfVectors ];
p_stHierarchies= (tdstHierarchy *) &p_a4_xQuaternions[ p_stA3dGENERAL->uwNumberOfQuaternions ];
p_stNTTO= (tdstNTTO *) &p_stHierarchies[ p_stA3dGENERAL->uwNumberOfHierarchies ];
p_stOnlyFrames= (tdstOnlyFrame *) &p_stNTTO[ p_stA3dGENERAL->uwNumberOfNTTO ];
p_stChannels= (tdstChannel *) &p_stOnlyFrames[ (p_stA3dGENERAL->uwEndFrame - p_stA3dGENERAL->uwStartFrame) ];
while ( (((unsigned long) p_stChannels) %4) != 0 )
p_stChannels= (tdstChannel *) (((char *) p_stChannels) + 1);
p_stFrames= (tdstFrame *) &p_stChannels[ p_stA3dGENERAL->uwNumberOfChannels ];
p_stFramesKF= (tdstFrameKF *) &p_stFrames[ p_stA3dGENERAL->uwNumberOfSavedFrames * p_stA3dGENERAL->uwNumberOfChannels ];
/* p_stKeyFrames= (tdstKeyFrame *) &p_stFramesKF[ p_stA3dGENERAL->uwNumberOfFrames * p_stA3dGENERAL->uwNumberOfChannels ];*/
p_stKeyFrames= (tdstKeyFrame *) &p_stFramesKF[ (p_stA3dGENERAL->uwEndFrame - p_stA3dGENERAL->uwStartFrame) * p_stA3dGENERAL->uwNumberOfChannels ];
/* Alignment*/
if ( (((unsigned long) p_stKeyFrames) & 0x0002) != 0x0000 )
p_stKeyFrames= (tdstKeyFrame *) (((char *) p_stKeyFrames) + 2);
p_stEvents= (tdstEvent *) &p_stKeyFrames[ p_stA3dGENERAL->uwNumberOfKeyFrames ];
/* due to alignment*/
while ( (((unsigned long) p_stEvents) %4) != 0 )
p_stEvents= (tdstEvent *) (((char *) p_stEvents) + 1);
p_stMorphData= (tdstMorphData *) &p_stEvents[ p_stA3dGENERAL->uwNumberOfEvents ];
#ifdef ANIM_DEBUG
/* ANTIBUG -------------------------------------------------*/
if ( ((unsigned long)&p_stMorphData[p_stA3dGENERAL->uwNumberOfMorphData] - (unsigned long)p_stA3dGENERAL) > MaxRAMSizeOfAnim )
{
osSyncPrintf("Anim %d too big !!!\n",_uwNumOfA3dGENERAL);
osSyncPrintf("fn_v_LoadCachedAnimV6 (%d > %d)\n", ((unsigned long)&p_stEvents[p_stA3dGENERAL->uwNumberOfEvents] - (unsigned long)p_stA3dGENERAL), MaxRAMSizeOfAnim);
osSyncPrintf(" uwNumberOfFrames = %4d\n", p_stA3dGENERAL->uwNumberOfFrames);
osSyncPrintf(" uwNumberOfVectors = %4d\n", p_stA3dGENERAL->uwNumberOfVectors);
osSyncPrintf(" uwNumberOfQuaternions= %4d\n", p_stA3dGENERAL->uwNumberOfQuaternions);
osSyncPrintf(" uwNumberOfHierarchies= %4d\n", p_stA3dGENERAL->uwNumberOfHierarchies);
osSyncPrintf(" uwNumberOfNTTO = %4d\n", p_stA3dGENERAL->uwNumberOfNTTO);
osSyncPrintf(" uwNumberOfOnlyFrames = %4d\n", (p_stA3dGENERAL->uwEndFrame - p_stA3dGENERAL->uwStartFrame));
osSyncPrintf(" uwNumberOfChannels = %4d\n", p_stA3dGENERAL->uwNumberOfChannels);
osSyncPrintf(" uwNumberOfSavedFrames= %4d\n", p_stA3dGENERAL->uwNumberOfSavedFrames);
osSyncPrintf(" uwNumberOfKeyFrames = %4d\n", p_stA3dGENERAL->uwNumberOfKeyFrames);
osSyncPrintf(" uwNumberOfEvents = %4d\n", p_stA3dGENERAL->uwNumberOfEvents);
osSyncPrintf(" uwNumberOfMorphData = %4d\n", p_stA3dGENERAL->uwNumberOfMorphData);
osSyncPrintf(" uwStartFrame = %4d\n", p_stA3dGENERAL->uwStartFrame);
osSyncPrintf(" uwEndFrame = %4d\n", p_stA3dGENERAL->uwEndFrame);
osSyncPrintf(" p_stA3dGENERAL = %d\n", 0);
osSyncPrintf(" p_a3_xVectors = %d\n", (unsigned long)p_a3_xVectors - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_a4_xQuaternions = %d\n", (unsigned long)p_a4_xQuaternions - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stHierarchies = %d\n", (unsigned long)p_stHierarchies - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stNTTO = %d\n", (unsigned long)p_stNTTO - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stOnlyFrames = %d\n", (unsigned long)p_stOnlyFrames - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stChannels = %d\n", (unsigned long)p_stChannels - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stFrames = %d\n", (unsigned long)p_stFrames - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stFramesKF = %d\n", (unsigned long)p_stFramesKF - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stKeyFrames = %d\n", (unsigned long)p_stKeyFrames - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stEvents = %d\n", (unsigned long)p_stEvents - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stMorphData = %d\n", (unsigned long)p_stMorphData - (unsigned long)p_stA3dGENERAL);
ASM_BREAK;;
}
/* ANTIBUG -------------------------------------------------*/
#endif /*ANIM_DEBUG*/
}
return p_stA3dGENERAL;
#ifndef FORCE_REAL_TIME_LOAD
}
else
#endif
#endif /*A3X_N64*/
#ifndef FORCE_REAL_TIME_LOAD
return &p_stA3dGENERAL[ _uwNumOfA3dGENERAL ];
#endif
}
#ifdef U64
void fn_vInvalidateAnimCache(void)
{
unsigned long i,ulNbIntAnims;
char* p_cBigMalloc;
/* Read number of animations*/
p_cBigMalloc=(char *) fn_pvAllocTmp( 4 , 16 );
LDR_fn_vLoadFromROM( ( g_p_cROMAnimBlocStart ),
( g_p_cROMAnimBlocStart + 1*sizeof(unsigned long) ),
(char *) p_cBigMalloc,
MSG_BLOCK );
ulNbIntAnims= *((unsigned long *) &p_cBigMalloc[0]);
fn_vFreeRomTmp( (void *)p_cBigMalloc );
/* Mark all cache entry invalid*/
for(i=0;i<ulNbIntAnims;++i)
p_stA3dHeaders[i].uwNumOfCacheEntry=SEB_Invalid;
}
#endif
/* ***************************************************************************************************/
/*tdstOutputCacheLine *fn_p_GetOutputCacheEntry( unsigned short _uwNumOfA3dGENERAL,
unsigned long _ulFrame,
void *_p_vSuperObject )
{ unsigned short uwCnt;
unsigned long ulMax;
if (ulLastEngineFrame != _ulFrame)
{
#ifndef MESSAGES_OFF
// M_PrintfN64_((ON"Changement frame moteur (%d)\n", _ulFrame ));
#endif // MESSAGES_OFF
M_v_ResetOneStack( eStackFrame3d );
M_v_ResetOneStack( eStackElement3d );
ulLastEngineFrame= _ulFrame;
}
ulMax = fn_ul_GetStackPos(eStackFrame3d);
for ( uwCnt=0 ; uwCnt<ulMax ; uwCnt++ )
if ( _p_vSuperObject == ax_stOutputCacheLine[uwCnt].p_vSuperObject )
return &ax_stOutputCacheLine[uwCnt];
ax_stOutputCacheLine[ulMax].p_vSuperObject= _p_vSuperObject;
ax_stOutputCacheLine[ulMax].p_stAnim3d= (void *) 0xFFFFFFFF;
ax_stOutputCacheLine[ulMax].lNumOfLastFrame= -1;
#ifdef A3X_CUT
ax_stOutputCacheLine[ulMax].p_stFrame3d= &p_stFrame3d[ fn_ul_AllocateOnStack( eStackFrame3d, 1 ) ];
ax_stOutputCacheLine[ulMax].p_stElement3d=
&p_stElement3d[ fn_ul_AllocateOnStack( eStackElement3d, p_stCuttedAnim[_uwNumOfA3dGENERAL].uwMaxNumberOfElements ) ];
#else
ax_stOutputCacheLine[ulMax].p_stFrame3d= &p_stFrame3d[ fn_ul_AllocateOnStack( eStackFrame3d, 1 ) ];
ax_stOutputCacheLine[ulMax].p_stElement3d= &p_stElement3d[ fn_ul_AllocateOnStack(eStackElement3d,fn_p_GetA3dGENERAL(_uwNumOfA3dGENERAL,_ulFrame)->uwNumberOfChannels) ];
#endif
ax_stOutputCacheLine[ulMax].p_stFrame3d->p_stArrayOfElts3d = ax_stOutputCacheLine[ulMax].p_stElement3d;
// ANTIBUG -------------------------------------------------
if ( (fn_ul_GetStackPos(eStackFrame3d) > uwMaxInTabFrame3d) || (fn_ul_GetStackPos(eStackElement3d) > uwMaxInTabElement3d) )
{
M_v_ResetOneStack( eStackFrame3d );
M_v_ResetOneStack( eStackElement3d );
#ifdef A3X_CUT
ax_stOutputCacheLine[ulMax].p_stFrame3d=&p_stFrame3d[ fn_ul_AllocateOnStack( eStackFrame3d, 1 ) ];
ax_stOutputCacheLine[ulMax].p_stElement3d=
&p_stElement3d[ fn_ul_AllocateOnStack( eStackElement3d, p_stCuttedAnim[_uwNumOfA3dGENERAL].uwMaxNumberOfElements ) ];
#else
ax_stOutputCacheLine[ulMax].p_stFrame3d=&p_stFrame3d[ fn_ul_AllocateOnStack( eStackFrame3d, 1 ) ];
ax_stOutputCacheLine[ulMax].p_stElement3d=&p_stElement3d[ fn_ul_AllocateOnStack( eStackElement3d,fn_p_GetA3dGENERAL(_uwNumOfA3dGENERAL,_ulFrame)->uwNumberOfChannels) ];
#endif
#ifdef A3X_N64
#ifndef MESSAGES_OFF
M_PrintfN64(("fn_uw_GetOutputCacheEntry : saturation cache sortie\n"));
// asm("break 0xFF");
#endif // MESSAGES_OFF
#endif
return &ax_stOutputCacheLine[0];
}
if ( (fn_ul_GetStackPos(eStackFrame3d) > uwMaxInStackFrame3d) || (fn_ul_GetStackPos(eStackElement3d) > uwMaxInStackElement3d) )
{ if (fn_ul_GetStackPos(eStackFrame3d) > uwMaxInStackFrame3d)
uwMaxInStackFrame3d = (unsigned short)fn_ul_GetStackPos(eStackFrame3d);
if (fn_ul_GetStackPos(eStackElement3d) > uwMaxInStackElement3d)
uwMaxInStackElement3d = (unsigned short)fn_ul_GetStackPos(eStackElement3d);
#ifdef A3X_N64
#ifndef MESSAGES_OFF
// M_PrintfN64(( "uwMaxInStackFrame3d= %d, uwMaxInStackElement3d= %d\n",
// uwMaxInStackFrame3d, uwMaxInStackElement3d ));
#endif // MESSAGES_OFF
#endif
}
// ANTIBUG -------------------------------------------------
return &ax_stOutputCacheLine[ulMax];
}*/
/* ***************************************************************************************************/
#undef A3X_CACH_C

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,989 @@
/* ***********************************************************************************/
/* * "a3x_intn.c" **/
/* * Written by : S<>bastien Rubens **/
/* * Tabulations : 4 char **/
/* ***********************************************************************************/
#define A3X_INTN_C
/* ***********************************************************************************/
/* Included files*/
#include <math.h>
/*#define LST2_StaticIsOptimised*/
#include "ACP_Base.h"
#include "cpa_std.h"
#include "TOOLSCPA.h"
#include "STRUCTUR/Anim_s.h"
#define D_ObjsTbls_Define
#include "STRUCTUR/ObjsTbls.h"
#include "MTH.h"
#include "POS.h"
#include "PlayAnim/Interpol/specif/a3x_pref.h"
#include "chanlist.h"
#include "PlayAnim/Interpol/a3x_glob.h"
#include "PlayAnim/Interpol/a3x_int.h"
#include "PlayAnim/Interpol/a3x_intn.h"
#include "PlayAnim/Interpol/a3x_mem.h"
#include "PlayAnim/Interpol/a3x_cach.h"
#include "PlayAnim/PlayEvts.h"
/* for allocation*/
#include "ZeMem.h"
#define M_Abs( x ) \
( ((x) > xZero) ? (x) : -(x) )
/* temp*/
extern SEB_xReal xEps;
extern SEB_xReal xOneSubEps;
/*AR9902 To be cleaned...*/
extern tdstA3dHeader* p_stA3dHeaders;
/* ***********************************************************************************/
void fn_v_InterpolBetweenKeys( tdstKeyFrame *_p_stKey1,
tdstKeyFrame *_p_stKey2,
tdstChannel *_p_stChannel,
POS_tdxHandleToPosition _p_stCompletePosition,
register unsigned short _uwInterpolated,
register SEB_xReal _xT )
{ tdxMatrix33 a3a3_xMtxOri, a3a3_xMtxTra;
tdxVector3 a3_xPosition;
static tdxQuater4 a4_xQuatI, a4_xQuatS1, a4_xQuatS2;
static tdxMatrix33 a3a3_xMtxOriSca, a3a3_xMtxSca;
static tdxVector3 a3_xVecSca;
register SEB_xReal xSinOmega;
register SEB_xReal xCoef1, xCoef2;
/* register SEB_xReal xOmega, xCosOmega, xTbyOmega;*/
register tdxVector3 *p_Vect1, *p_Vect2;
register signed short swOmega, swCosOmega, swTbyOmega;
#ifdef ANIM_DEBUG
if(_p_stCompletePosition==NULL)
{
osSyncPrintf("Position is null in fn_v_InterpolBetweenKeys\n");
ASM_BREAK;
}
#endif
POS_fn_vSetIdentityMatrix(_p_stCompletePosition);
MTH3D_M_vSetIdentityMatrix((MTH3D_tdstMatrix*)&a3a3_xMtxOri);
MTH3D_M_vSetIdentityMatrix((MTH3D_tdstMatrix*)&a3a3_xMtxTra);
MTH3D_M_vNullVector((MTH3D_tdstVector*)&a3_xPosition);
/* -- Interpolation of orientation -------*/
if ( (_xT == xZero) || ((_p_stKey1->uwMask & SEB_xMaskQuatOri) != 0x0000) )
{ /* We are on the first KeyFrame or we have a non interpolated quaternion*/
if ((_p_stKey1->uwMask & SEB_xMaskIdQuatOri) == 0x0000)
{ /* Copy of first (KeyFrame) quaternion*/
fn_v_ExpandQuat( a4_xQuatI, p_a4_xQuaternions[_p_stKey1->uwNumOfQuatOri] );
fn_v_QuatToMatrix( a3a3_xMtxOri, a4_xQuatI );
POS_fn_vSetRotationMatrix( _p_stCompletePosition , (MTH3D_tdstVector*)a3a3_xMtxOri[0], (MTH3D_tdstVector*)a3a3_xMtxOri[1] , (MTH3D_tdstVector*)a3a3_xMtxOri[2] );
}
}
else
{ /* Interpolation of orientation*/
fn_v_ExpandQuat( a4_xQuatS1, p_a4_xQuaternions[_p_stKey1->uwNumOfQuatOri] );
fn_v_ExpandQuat( a4_xQuatS2, p_a4_xQuaternions[_p_stKey2->uwNumOfQuatOri] );
fn_v_InterpolQuatWithOmega( a4_xQuatI, a4_xQuatS1, a4_xQuatS2, _xT, _p_stKey1->uwAngQuatOri );
fn_v_QuatToMatrix( a3a3_xMtxOri, a4_xQuatI );
POS_fn_vSetRotationMatrix( _p_stCompletePosition , (MTH3D_tdstVector*)a3a3_xMtxOri[0], (MTH3D_tdstVector*)a3a3_xMtxOri[1] , (MTH3D_tdstVector*)a3a3_xMtxOri[2] );
}
/* -- Linear interpolation of ScaleValues -------*/
if ( ((_p_stKey1->uwMask & (SEB_xMaskScaleValues|SEB_xMaskIdScaleValues)) == (SEB_xMaskScaleValues|SEB_xMaskIdScaleValues))
|| ((_xT==xZero) && ((_p_stKey1->uwMask & SEB_xMaskIdScaleValues) != 0x0000)) )
{ /* Identity vector (we don't use scale)*/
MTH3D_M_vCopyMatrix((MTH3D_tdstMatrix*)&a3a3_xMtxTra,(MTH3D_tdstMatrix*)&a3a3_xMtxOri);
}
/*else we have a non "identity" scale vector*/
/* -- Interpolation of whole scale -------*/
/* -- and creation of TransformMatrix -------*/
else
{ /* Interpolated of ScaleValues*/
fn_v_InterpolVect( a3_xVecSca, p_a3_xVectors[_p_stKey1->uwNumOfScaleValues],
p_a3_xVectors[_p_stKey2->uwNumOfScaleValues], _xT );
if ( (_xT == xZero) || ((_p_stKey1->uwMask & SEB_xMaskQuatSca) != 0x0000) )
{ /* We are on the first KeyFrame or we have a non interpolated quaternion*/
if ((_p_stKey1->uwMask & SEB_xMaskIdQuatSca) != 0x0000)
{ /* Identity quaternion*/
/* Create final Transform matrix*/
/* Final matrix= [scale dir. matrix]*[values scale matrix]*[scale dir. matrix]^-1*/
if(MTH_M_bEqualWithEpsilon(a3_xVecSca[0],a3_xVecSca[1],MTH_M_xFloatToReal(0.01)) &&
MTH_M_bEqualWithEpsilon(a3_xVecSca[0],a3_xVecSca[2],MTH_M_xFloatToReal(0.01)))
{
POS_fn_vSetZoomMatrix( _p_stCompletePosition , (MTH_tdxReal)a3_xVecSca[0] );
POS_fn_vGetTransformMatrix( _p_stCompletePosition , (MTH3D_tdstVector*)a3a3_xMtxTra[0], (MTH3D_tdstVector*)a3a3_xMtxTra[1] , (MTH3D_tdstVector*)a3a3_xMtxTra[2] );
}
else
{
fn_v_MatrixByDia( a3a3_xMtxTra, a3a3_xMtxOri, a3_xVecSca );
POS_fn_vSetTransformMatrix( _p_stCompletePosition , (MTH3D_tdstVector*)a3a3_xMtxTra[0], (MTH3D_tdstVector*)a3a3_xMtxTra[1] , (MTH3D_tdstVector*)a3a3_xMtxTra[2] );
}
}
else
{ /* Copy of first (KeyFrame) quaternion*/
fn_v_ExpandQuat( a4_xQuatI, p_a4_xQuaternions[_p_stKey1->uwNumOfQuatSca] );
fn_v_QuatToMatrix( a3a3_xMtxOriSca, a4_xQuatI );
/* Create final scale matrix*/
/* Final matrix= [scale dir. matrix]*[values scale matrix]*[scale dir. matrix]^-1*/
if(MTH_M_bEqualWithEpsilon(a3_xVecSca[0],a3_xVecSca[1],MTH_M_xFloatToReal(0.01)) &&
MTH_M_bEqualWithEpsilon(a3_xVecSca[0],a3_xVecSca[2],MTH_M_xFloatToReal(0.01)))
{
POS_fn_vSetZoomMatrix( _p_stCompletePosition , (MTH_tdxReal)a3_xVecSca[0] );
POS_fn_vGetTransformMatrix( _p_stCompletePosition , (MTH3D_tdstVector*)a3a3_xMtxTra[0], (MTH3D_tdstVector*)a3a3_xMtxTra[1] , (MTH3D_tdstVector*)a3a3_xMtxTra[2] );
}
else
{
fn_v_InvRotDiaRot( a3a3_xMtxSca, a3a3_xMtxOriSca, a3_xVecSca );
/* Create final Transform matrix*/
fn_v_MultMatrix( a3a3_xMtxTra, a3a3_xMtxOri, a3a3_xMtxSca );
POS_fn_vSetTransformMatrix( _p_stCompletePosition , (MTH3D_tdstVector*)a3a3_xMtxTra[0], (MTH3D_tdstVector*)a3a3_xMtxTra[1] , (MTH3D_tdstVector*)a3a3_xMtxTra[2] );
}
}
}
else
{ /* Interpolation of scale direction*/
fn_v_ExpandQuat( a4_xQuatS1, p_a4_xQuaternions[_p_stKey1->uwNumOfQuatSca] );
fn_v_ExpandQuat( a4_xQuatS2, p_a4_xQuaternions[_p_stKey2->uwNumOfQuatSca] );
fn_v_InterpolQuatWithOmega( a4_xQuatI, a4_xQuatS1, a4_xQuatS2, _xT, _p_stKey1->uwAngQuatSca );
fn_v_QuatToMatrix( a3a3_xMtxOriSca, a4_xQuatI );
/* Create final scale matrix*/
/* Final matrix= [scale dir. matrix]*[values scale matrix]*[scale dir. matrix]^-1*/
if(MTH_M_bEqualWithEpsilon(a3_xVecSca[0],a3_xVecSca[1],MTH_M_xFloatToReal(0.01)) &&
MTH_M_bEqualWithEpsilon(a3_xVecSca[0],a3_xVecSca[2],MTH_M_xFloatToReal(0.01)))
{
POS_fn_vSetZoomMatrix( _p_stCompletePosition , (MTH_tdxReal)a3_xVecSca[0] );
POS_fn_vGetTransformMatrix( _p_stCompletePosition , (MTH3D_tdstVector*)a3a3_xMtxTra[0], (MTH3D_tdstVector*)a3a3_xMtxTra[1] , (MTH3D_tdstVector*)a3a3_xMtxTra[2] );
}
else
{
fn_v_InvRotDiaRot( a3a3_xMtxSca, a3a3_xMtxOriSca, a3_xVecSca );
/* Create final Transform matrix*/
fn_v_MultMatrix( a3a3_xMtxTra, a3a3_xMtxOri, a3a3_xMtxSca );
POS_fn_vSetTransformMatrix( _p_stCompletePosition , (MTH3D_tdstVector*)a3a3_xMtxTra[0], (MTH3D_tdstVector*)a3a3_xMtxTra[1] , (MTH3D_tdstVector*)a3a3_xMtxTra[2] );
}
}
}
/* -- Interpolation of position -------*/
if ( (_xT == xZero) || (_p_stKey1->uwMask & SEB_xMaskPosition) != 0x0000 )
{ register SEB_xReal r_xDistMaster;
p_Vect1= &p_a3_xVectors[_p_stKey1->uwNumOfPosition];
r_xDistMaster= _p_stKey1->xDistMaster;
a3_xPosition[0]= (*p_Vect1)[0] * r_xDistMaster;
a3_xPosition[1]= (*p_Vect1)[1] * r_xDistMaster;
a3_xPosition[2]= (*p_Vect1)[2] * r_xDistMaster;
POS_fn_vSetTranslationVector( _p_stCompletePosition , (MTH3D_tdstVector*)a3_xPosition );
}
else
{
if ( _uwInterpolated == 0x0000 )
{
/* Interpolation with the pivot*/
/* Rotate pivot (local to object)*/
fn_v_MatrixByVector( a3_xVecSca, a3a3_xMtxTra, p_a3_xVectors[_p_stChannel->uwNumOfLocalPivotPos] );
/* Pivot (linear) interpolation in world axes*/
fn_v_InterpolVect( a3_xPosition, _p_stKey1->a3_xWorldPivotPosition, _p_stKey2->a3_xWorldPivotPosition, _xT );
/* Computes the interpolated position*/
a3_xPosition[0]-= a3_xVecSca[0];
a3_xPosition[1]-= a3_xVecSca[1];
a3_xPosition[2]-= a3_xVecSca[2];
POS_fn_vSetTranslationVector( _p_stCompletePosition , (MTH3D_tdstVector*)a3_xPosition );
}
else
{
/* Interpolation with Hierarchy*/
if ( (_p_stKey1->xDistMaster > xEps) || (_p_stKey2->xDistMaster > xEps) )
{
p_Vect1= &p_a3_xVectors[_p_stKey1->uwNumOfPosition];
if ((_p_stKey1->uwMask & SEB_xMaskZeroAngCentre) != 0x0000)
{
/* Linear interpolation of vector length*/
xCoef1= ( _p_stKey2->xDistMaster - _p_stKey1->xDistMaster ) * _xT
+ _p_stKey1->xDistMaster;
/* Computes the interpolated position*/
a3_xPosition[0]= xCoef1 * (*p_Vect1)[0];
a3_xPosition[1]= xCoef1 * (*p_Vect1)[1];
a3_xPosition[2]= xCoef1 * (*p_Vect1)[2];
POS_fn_vSetTranslationVector( _p_stCompletePosition , (MTH3D_tdstVector*)a3_xPosition );
}
else
{
p_Vect2= &p_a3_xVectors[_p_stKey2->uwNumOfPosition];
swOmega= _p_stKey1->uwAngObjCentre;
/* Computes values for "Geodesic" interpolation*/
swCosOmega= ax_SinTab[ swOmega ];
if ( swCosOmega != 0 )
{ xSinOmega= xOne / swCosOmega;
swTbyOmega= (signed short) (_xT * swOmega); /* Always 0 < slTbyOmega < _slOmega*/
xCoef1= ax_SinTab[ swOmega - swTbyOmega ] * xSinOmega;
xCoef2= ax_SinTab[ swTbyOmega ] * xSinOmega;
}
else
{ xCoef1= xOne - _xT;
xCoef2= _xT;
}
/* Linear interpolation of vector length*/
xSinOmega= ( _p_stKey2->xDistMaster - _p_stKey1->xDistMaster ) * _xT
+ _p_stKey1->xDistMaster;
xCoef1*= xSinOmega;
xCoef2*= xSinOmega;
/* Computes the interpolated position*/
a3_xPosition[0]= xCoef1 * (*p_Vect1)[0] + xCoef2 * (*p_Vect2)[0];
a3_xPosition[1]= xCoef1 * (*p_Vect1)[1] + xCoef2 * (*p_Vect2)[1];
a3_xPosition[2]= xCoef1 * (*p_Vect1)[2] + xCoef2 * (*p_Vect2)[2];
POS_fn_vSetTranslationVector( _p_stCompletePosition , (MTH3D_tdstVector*)a3_xPosition );
}
}
}
}
}
/* ***********************************************************************************/
#ifdef A3X_CUT
unsigned short fn_uw_GetNumOfA3dGENERAL( unsigned short _uwNumOfA3dGENERAL,
unsigned short _uwT )
{ register unsigned short uwNumOfA3dGENERAL;
uwNumOfA3dGENERAL= _uwNumOfA3dGENERAL;
while ( _uwT >= p_stCuttedAnim[uwNumOfA3dGENERAL].uwEndFrame )
{ uwNumOfA3dGENERAL= p_stCuttedAnim[uwNumOfA3dGENERAL].uwNextAnim;
if (uwNumOfA3dGENERAL == 0xFFFF)
{
#ifdef ANIM_DEBUG
osSyncPrintf("Cut anim not found\n");
osSyncPrintf("Anim = %d, Frame = %d\n",_uwNumOfA3dGENERAL,_uwT);
ASM_BREAK; /* temporary*/
#endif
return 0xFFFF;
}
}
p_uwLastA3dGENERAL[_uwNumOfA3dGENERAL]= uwNumOfA3dGENERAL;
return uwNumOfA3dGENERAL;
}
#endif
/* ***********************************************************************************/
tdstEvent *fn_p_GetEventsAddress( tdstAnim3d *_p_stAnim3d,
unsigned long _ulFrame,
tdxHandleToObjectsTablesList _h_ObjectsTablesListElement)
{
#ifdef U64
int i;
tdstEvent * p_stEvent, * p_stEventNeverPlay;
if ( _p_stAnim3d->uwNumOfA3dGENERAL != C_uwAnimNotInterpolated )
{ /* Animation is a interpolated animation*/
/* Set Events*/
if ( _p_stAnim3d->ucNumberOfEvents == 0 )
_p_stAnim3d->d_stAnimEvent= NULL;
else
{ tdstA3dGENERAL *p_stCurrentA3dGENERAL;
#ifndef FORCE_REAL_TIME_LOAD
if(g_bRealTimeAnimationLoad)
#endif
p_stCurrentA3dGENERAL= fn_p_GetA3dGENERAL(p_uwLastA3dGENERAL[_p_stAnim3d->uwNumOfA3dGENERAL], _ulFrame);
#ifndef FORCE_REAL_TIME_LOAD
else
p_stCurrentA3dGENERAL= fn_p_GetA3dGENERAL(_p_stAnim3d->uwNumOfA3dGENERAL, _ulFrame );
#endif
_p_stAnim3d->d_stAnimEvent= &p_stEvents[ p_stCurrentA3dGENERAL->uwNumOfFirstEvent ];
/* Update event pointer with sort*/
for(i=0,p_stEvent=NULL,p_stEventNeverPlay=_p_stAnim3d->d_stAnimEvent;i<_p_stAnim3d->ucNumberOfEvents;++i,p_stEventNeverPlay++)
{
if(p_stEventNeverPlay->p_stfEventInTBL==NULL)
{
/* set the tbl event*/
p_stEventNeverPlay->p_stfEventInTBL=
(tdstEventInTable*)_h_ObjectsTablesListElement->d_stObjectsTable[p_stEventNeverPlay->usEventNumberInTBL].h_Target;
/* found first non never play event*/
#ifdef ANIM_DEBUG
if(p_stEventNeverPlay->p_stfEventInTBL==NULL)
{
osSyncPrintf("Probleme d'evenements : p_stfEventInTBL==NULL\n");
osSyncPrintf("Anim = %d, Frame = %d, number in table = %d\n",_p_stAnim3d->uwNumOfA3dGENERAL,_ulFrame,p_stEventNeverPlay->usEventNumberInTBL);
}
#endif
if (!p_stEvent && (GAM_fn_ucGetFirstCallOfEvent(p_stEventNeverPlay) != C_ucNeverPlay))
p_stEvent = p_stEventNeverPlay;
/* found a never play */
else if (GAM_fn_ucGetFirstCallOfEvent(p_stEventNeverPlay) == C_ucNeverPlay)
{
/* set the frame & channel to 0*/
p_stEventNeverPlay->uwChannelNumber = p_stEventNeverPlay->uwFrameNumber = 0;
/* there is a non never play before*/
if (p_stEvent)
{
tdstEvent * p_stTmpEvent;
/* we move up the never play event until the first non never play*/
for(p_stTmpEvent = p_stEventNeverPlay-1;p_stTmpEvent >= p_stEvent;p_stTmpEvent--)
{
/* permute Event*/
tdstEvent stEvent = *(p_stTmpEvent+1);
*(p_stTmpEvent+1) = *p_stTmpEvent;
*p_stTmpEvent = stEvent;
}
/* now the fisrt non never play has moved 1 place down*/
p_stEvent++;
}
}
}
}
}
}
#endif /*U64*/
return _p_stAnim3d->d_stAnimEvent;
}
/* ***********************************************************************************/
void fn_v_CalculateGeneral(tdstAnim3d * _p_stAnim3d,unsigned long _ulFrame ) {
#ifndef FORCE_REAL_TIME_LOAD
tdstA3dGENERAL *p_stCurrentA3dGENERAL;
/* tdxQuater4 a4_xQuat;*/
/* tdxMatrix33 a3x3_Matrix;*/
if(!g_bRealTimeAnimationLoad)
{
p_stCurrentA3dGENERAL = fn_p_GetA3dGENERAL(_p_stAnim3d->uwNumOfA3dGENERAL,_ulFrame);
_p_stAnim3d->uwNumberOfFrames = p_stCurrentA3dGENERAL->uwNumberOfFrames;
_p_stAnim3d->ucFrameRate= (unsigned char) p_stCurrentA3dGENERAL->uwAnimationSpeed;
_p_stAnim3d->ucMaxNumberOfElements= (unsigned char) p_stCurrentA3dGENERAL->uwNumberOfChannels;
_p_stAnim3d->ucNumberOfEvents= (unsigned char) p_stCurrentA3dGENERAL->uwNumberOfEvents;
if ( (p_a3_xVectors[p_stCurrentA3dGENERAL->uwNumOfAnimationTranslationOffset][0] != xZero) ||
(p_a3_xVectors[p_stCurrentA3dGENERAL->uwNumOfAnimationTranslationOffset][1] != xZero) ||
(p_a3_xVectors[p_stCurrentA3dGENERAL->uwNumOfAnimationTranslationOffset][2] != xZero)
)
{
/* POS_fn_vSetTranslationVector( &(_p_stAnim3d->stOffsetMatrix) , (MTH3D_tdstVector*)p_a3_xVectors[p_stCurrentA3dGENERAL->uwNumOfAnimationTranslationOffset] );*/
memcpy(&(_p_stAnim3d->stOffsetMatrix),(MTH3D_tdstVector*)p_a3_xVectors[p_stCurrentA3dGENERAL->uwNumOfAnimationTranslationOffset],sizeof(MTH3D_tdstVector));
}
else
memset(&_p_stAnim3d->stOffsetMatrix,0,sizeof(MTH3D_tdstVector)); /*AR9811*/
/* if ( (p_a4_xQuaternions[p_stCurrentA3dGENERAL->uwNumOfAnimationRotationOffset][0] != 0) ||
(p_a4_xQuaternions[p_stCurrentA3dGENERAL->uwNumOfAnimationRotationOffset][1] != 0) ||
(p_a4_xQuaternions[p_stCurrentA3dGENERAL->uwNumOfAnimationRotationOffset][2] != 0) ||
(p_a4_xQuaternions[p_stCurrentA3dGENERAL->uwNumOfAnimationRotationOffset][3] != lOne)
)
{
fn_v_ExpandQuat( a4_xQuat, p_a4_xQuaternions[p_stCurrentA3dGENERAL->uwNumOfAnimationRotationOffset] );
fn_v_QuatToMatrix( a3x3_Matrix , a4_xQuat );
POS_fn_vSetRotationMatrix( &(_p_stAnim3d->stOffsetMatrix) , (MTH3D_tdstVector*)a3x3_Matrix[0] , (MTH3D_tdstVector*)a3x3_Matrix[1] , (MTH3D_tdstVector*)a3x3_Matrix[2] );
} */
/* Set Events*/
if ( _p_stAnim3d->ucNumberOfEvents == 0 )
_p_stAnim3d->d_stAnimEvent= NULL;
else
_p_stAnim3d->d_stAnimEvent= &p_stEvents[p_stCurrentA3dGENERAL->uwNumOfFirstEvent];
/* Set Morph table*/
if ( p_stCurrentA3dGENERAL->uwNumberOfMorphData == 0 )
_p_stAnim3d->d_stMorphDataArray = NULL;
else
_p_stAnim3d->d_stMorphDataArray = &p_stMorphData[p_stCurrentA3dGENERAL->uwNumOfFirstMorphData];
}
else
{
#endif
#ifdef A3X_CUT
/* If we are in realtime load system, we don't need to load the entire animations, here.*/
register tdstShortA3dGENERAL *p_stShortA3dGENERAL;
p_stShortA3dGENERAL= fn_p_ReadShortAnimFromROM(_p_stAnim3d->uwNumOfA3dGENERAL);
_p_stAnim3d->uwNumberOfFrames= p_stShortA3dGENERAL->uwNumberOfFrames;
_p_stAnim3d->ucFrameRate= p_stShortA3dGENERAL->uwFrameRate;
_p_stAnim3d->ucMaxNumberOfElements= p_stShortA3dGENERAL->uwMaxNumberOfElements;
_p_stAnim3d->ucNumberOfEvents= p_stShortA3dGENERAL->uwNumberOfEvents;
if((p_stShortA3dGENERAL->a3_xAnimationTranslationOffset[0] != xZero)||
(p_stShortA3dGENERAL->a3_xAnimationTranslationOffset[1] != xZero)||
(p_stShortA3dGENERAL->a3_xAnimationTranslationOffset[2] != xZero))
/* POS_fn_vSetTranslationVector(&(_p_stAnim3d->stOffsetMatrix) , (MTH3D_tdstVector*)p_stShortA3dGENERAL->a3_xAnimationTranslationOffset );*/
memcpy(&(_p_stAnim3d->stOffsetMatrix),(MTH3D_tdstVector*)p_stShortA3dGENERAL->a3_xAnimationTranslationOffset,sizeof(MTH3D_tdstVector)); /*AR9811*/
else
memset(&_p_stAnim3d->stOffsetMatrix,0,sizeof(MTH3D_tdstVector)); /*AR9811*/
/* if ((p_stShortA3dGENERAL->a4_uwAnimationRotationOffset[0] != 0) ||
(p_stShortA3dGENERAL->a4_uwAnimationRotationOffset[1] != 0) ||
(p_stShortA3dGENERAL->a4_uwAnimationRotationOffset[2] != 0) ||
(p_stShortA3dGENERAL->a4_uwAnimationRotationOffset[3] != lOne)
)
{
fn_v_ExpandQuat(a4_xQuat, p_stShortA3dGENERAL->a4_uwAnimationRotationOffset );
fn_v_QuatToMatrix( a3x3_Matrix , a4_xQuat );
POS_fn_vSetRotationMatrix( &(_p_stAnim3d->stOffsetMatrix) , (MTH3D_tdstVector*)a3x3_Matrix[0] , (MTH3D_tdstVector*)a3x3_Matrix[1] , (MTH3D_tdstVector*)a3x3_Matrix[2] );
} */
/* Set Events*/
if ( _p_stAnim3d->ucNumberOfEvents == 0 )
_p_stAnim3d->d_stAnimEvent= NULL;
else
_p_stAnim3d->d_stAnimEvent= (struct tdstEvent_ *)0xCCCCCCCC; /* Updated later*/
/* Set Morph table*/
if ( p_stShortA3dGENERAL->uwNumberOfMorphData == 0 )
_p_stAnim3d->d_stMorphDataArray = NULL;
else
_p_stAnim3d->d_stMorphDataArray = (struct stMorphData *)0xCCCCCCCC; /* Updated later*/
#endif
#ifndef FORCE_REAL_TIME_LOAD
}
#endif
}
/* ****************************************************************** fn_vUpdateFrame*/
/* Update Frame structure if it wasn't - but matrix isn't update*/
/* Set Linear and Angular Speed (Alloc or Free Matrix)*/
/* Set Hierarchy*/
/* Fill Element3D Array : ElementNuber,ElementType,ActiveStatus,ChannelNumber*/
/**/
/* 17/07/98 - Carlos Torres*/
/* ***********************************************************************************/
void fn_vUpdateFrame(void * _p_stSuperObject,tdstFrame3d * _p_stFrame,tdstAnim3d * _p_stAnim3d,unsigned short _uwFrame)
{
tdstA3dGENERAL * p_stCurrentA3dGENERAL;
tdstOnlyFrame * p_stCurrentOnlyFrame;
tdstChannel * p_stCurrentChannel;
unsigned short uwT_NTTO;
unsigned short uwCnt1,uwNumOfA3dGENERAL;
tdstElement3d * p_stCurrentElement3d;
unsigned short uwCorrectedFrame;
ACP_tdxBool bMustTest=TRUE;
/* AR9902*/
/* Before returning, we must be sure that the animation is still loaded into the animation cache*/
/* and that it is loaded into the same cache entry*/
/* ----------------------------------------------------------------------------------*/
/* Get A3D General Info*/
#ifdef A3X_N64
#ifndef FORCE_REAL_TIME_LOAD
if(g_bRealTimeAnimationLoad)
#endif
uwNumOfA3dGENERAL= fn_uw_GetNumOfA3dGENERAL(_p_stAnim3d->uwNumOfA3dGENERAL, _uwFrame);
#ifndef FORCE_REAL_TIME_LOAD
else
#endif
#endif
#ifndef FORCE_REAL_TIME_LOAD
uwNumOfA3dGENERAL= _p_stAnim3d->uwNumOfA3dGENERAL;
#endif
#ifdef A3X_N64
if((p_stA3dHeaders[uwNumOfA3dGENERAL].uwNumOfCacheEntry == SEB_Invalid)
||(_p_stFrame->ucCacheEntry!=(unsigned char)p_stA3dHeaders[uwNumOfA3dGENERAL].uwNumOfCacheEntry))
{
/* Animation isn't loaded*/
/* We must load it and fill again the _p_stFrame because the old values aren't valid anymore*/
bMustTest=FALSE;
}
else
#endif /*A3X_N64*/
bMustTest=TRUE;
if(bMustTest)
{
/* if uwFrame>uwNumberOfFrames, no update*/
if ( _uwFrame >= _p_stAnim3d->uwNumberOfFrames )
return; /* Can occur sometimes... AR9808*/
/* check if the frame is already updated*/
if ((_p_stFrame->p_stAnim == _p_stAnim3d) && (_p_stFrame->uwFrameNumber == _uwFrame))
return;
}
else
{
if ( _uwFrame >= _p_stAnim3d->uwNumberOfFrames )
_uwFrame = ( unsigned short ) ( _p_stAnim3d->uwNumberOfFrames - 1 ) ; /*last valid frame*/
}
/* ----------------------------------------------------------------------------------*/
/* set ref of the frame*/
_p_stFrame->p_stAnim = _p_stAnim3d;
_p_stFrame->uwFrameNumber = _uwFrame;
_p_stFrame->ucMatrixUpdated = FALSE;
/* Here, we load the animation in cache again*/
p_stCurrentA3dGENERAL = fn_p_GetA3dGENERAL(uwNumOfA3dGENERAL,_uwFrame);
/* ----------------------------------------------------------------------------------*/
/* check if anim cutting is well done*/
#if defined(A3X_N64) && defined(ANIM_DEBUG)
if ((_uwFrame < p_stCurrentA3dGENERAL->uwStartFrame) ||
(_uwFrame >= p_stCurrentA3dGENERAL->uwEndFrame) )
{
osSyncPrintf("Probleme decoupage d'animation (anim= %d, Frame= %d, StartFrame= %d, EndFrame= %d)\n", uwNumOfA3dGENERAL, _uwFrame, p_stCurrentA3dGENERAL->uwStartFrame, p_stCurrentA3dGENERAL->uwEndFrame);
ASM_BREAK;
}
#endif /* ANIM_DEBUG */
#ifdef A3X_N64
if(!bMustTest)
{
/*Here, the anim has been loaded and we can updade the number of the cache entry into the frame structure*/
_p_stFrame->ucCacheEntry=(unsigned char)p_stA3dHeaders[uwNumOfA3dGENERAL].uwNumOfCacheEntry;
}
/* End of AR9902*/
#endif /*A3X_N64*/
uwCorrectedFrame = (unsigned short) (_uwFrame - p_stCurrentA3dGENERAL->uwStartFrame);
/* ----------------------------------------------------------------------------------*/
/* Get information to update frame info*/
p_stCurrentChannel = &p_stChannels [p_stCurrentA3dGENERAL->uwNumOfFirstChannel];
p_stCurrentOnlyFrame = &p_stOnlyFrames[p_stCurrentA3dGENERAL->uwNumOfFirstOnlyFrame + uwCorrectedFrame];
uwT_NTTO = p_stCurrentOnlyFrame->uwNumOfSavedFrame;
/* ----------------------------------------------------------------------------------*/
/* Set Angular Speed Matrix if exist*/
#ifndef U64
if (p_stCurrentOnlyFrame->uwNumOfAngularSpeedQuat == SEB_Invalid)
{
/* free matrix if allocated*/
if (_p_stFrame->p_stAngularSpeedMatrix)
{
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeSpeedMatrix , 0 );
TMP_M_Free(_p_stFrame->p_stAngularSpeedMatrix);
}
_p_stFrame->p_stAngularSpeedMatrix= NULL;
}
else
{
tdxQuater4 a4_xQuatOri;
/* allocate matrix if it wasn't*/
if (!_p_stFrame->p_stAngularSpeedMatrix)
{
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeSpeedMatrix , 0 );
_p_stFrame->p_stAngularSpeedMatrix = TMP_M_p_Malloc(sizeof(MTH3D_tdstMatrix));
}
fn_v_ExpandQuat(a4_xQuatOri,p_a4_xQuaternions[p_stCurrentOnlyFrame->uwNumOfAngularSpeedQuat]);
fn_v_QuatToMatrix(*((tdxMatrix33 *) (_p_stFrame->p_stAngularSpeedMatrix)),a4_xQuatOri);
}
/* ----------------------------------------------------------------------------------*/
/* Set Linear Speed Vector if exist*/
if (p_stCurrentOnlyFrame->uwNumOfSpeedVector == SEB_Invalid)
{
_p_stFrame->p_stLinearSpeedVector = NULL;
}
else
{
_p_stFrame->p_stLinearSpeedVector = (MTH3D_tdstVector *) &p_a3_xVectors[p_stCurrentOnlyFrame->uwNumOfSpeedVector];
}
#endif
/* ---------------------------------------------------------------------------------- */
/* Set Hierarchy */
if (p_stCurrentOnlyFrame->uwHierarchyNbCouples)
{
#ifdef U64
/* Begin AR9902 Copy hierarchy instead of pointing it */
if(_p_stFrame->stHierarchy.d_stCouples!=NULL)
{
if((memcmp(_p_stFrame->stHierarchy.d_stCouples,
&p_stHierarchies[p_stCurrentOnlyFrame->uwNumOfFirstHierarchyCouple],
sizeof(tdstCouple)*p_stCurrentOnlyFrame->uwHierarchyNbCouples)!=0) ||
(p_stCurrentOnlyFrame->uwHierarchyNbCouples != _p_stFrame->stHierarchy.ulNbOfCouples))
{
/* hierarchy is different */
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeHierarchies , 0 );
_p_stFrame->stHierarchy.d_stCouples = TMP_M_p_Malloc(sizeof(tdstCouple)*p_stCurrentOnlyFrame->uwHierarchyNbCouples);
memcpy(_p_stFrame->stHierarchy.d_stCouples,
&p_stHierarchies[p_stCurrentOnlyFrame->uwNumOfFirstHierarchyCouple],
sizeof(tdstCouple)*p_stCurrentOnlyFrame->uwHierarchyNbCouples);
/* The old hierarchy is freed into the anim player (PLA_fn_vInitAllChildInHeapNewAnim) */
}
}
else
{
/* no previous hierarchy */
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeHierarchies , 0 );
_p_stFrame->stHierarchy.d_stCouples = TMP_M_p_Malloc(sizeof(tdstCouple)*p_stCurrentOnlyFrame->uwHierarchyNbCouples);
memcpy(_p_stFrame->stHierarchy.d_stCouples,
&p_stHierarchies[p_stCurrentOnlyFrame->uwNumOfFirstHierarchyCouple],
sizeof(tdstCouple)*p_stCurrentOnlyFrame->uwHierarchyNbCouples);
}
/* End AR9902 */
#else
_p_stFrame->stHierarchy.d_stCouples = (tdstCouple *) &p_stHierarchies[p_stCurrentOnlyFrame->uwNumOfFirstHierarchyCouple];
#endif
}
else
_p_stFrame->stHierarchy.d_stCouples = NULL;
_p_stFrame->stHierarchy.ulNbOfCouples = p_stCurrentOnlyFrame->uwHierarchyNbCouples;
/* ----------------------------------------------------------------------------------*/
/* Set Frame Info - don't compute matrix*/
for (uwCnt1=0,p_stCurrentElement3d=_p_stFrame->p_stArrayOfElts3d;uwCnt1<p_stCurrentA3dGENERAL->uwNumberOfChannels;uwCnt1++)
{
tdstFrame * p_stCurrentFrame;
/* Get Current Frame info*/
p_stCurrentFrame = &p_stFrames[p_stCurrentChannel->uwNumOfFirstFrame + uwT_NTTO];
/* ----------------------------------------------------------------------------------*/
/* Fill element 3D structure*/
if(p_stCurrentFrame->uwNumOfNTTO!=(unsigned short)0xFFFF) /* empty object AR9810*/
{
/* Element Number in TBL*/
p_stCurrentElement3d->wElement = p_stNTTO[p_stCurrentFrame->uwNumOfNTTO].ucNumberInTable;
/* Channel Number*/
p_stCurrentElement3d->ucChannelNumber = (unsigned char)(p_stCurrentChannel->uwChannelNumber);
/* Active Status*/
p_stCurrentElement3d->bf1ActiveStatus = TRUE;
/* Type Of Element*/
p_stCurrentElement3d->eTypeOfElement = (tdeTypeOfElement)(p_stNTTO[p_stCurrentFrame->uwNumOfNTTO].uwTypeOfObject & 0x00FF);
/* ucTransparency*/
p_stCurrentElement3d->ucTransparency= p_stNTTO[ p_stCurrentFrame->uwNumOfNTTO ].ucTransparency;
}
else
{
/* XB 05/05/99 : typeof(wElement)=unsigned char on N64 !! */
#ifndef U64
p_stCurrentElement3d->wElement = (unsigned short) -1;
#else
p_stCurrentElement3d->wElement = (unsigned char) -1;
#endif
/* End XB 05/05/99 */
p_stCurrentElement3d->ucChannelNumber = (unsigned char)(p_stCurrentChannel->uwChannelNumber);
p_stCurrentElement3d->bf1ActiveStatus = TRUE;
p_stCurrentElement3d->eTypeOfElement = TE_EmptyObject;
p_stCurrentElement3d->ucTransparency = 0;
}
p_stCurrentChannel++;
p_stCurrentElement3d++;
}
}
/* ************************************************************ fn_vUpdateFrameMatrix*/
/* Update Frame if it wasn't update*/
/* Update Matrix in Channel Array*/
/* if they weren't updated*/
/* or if bolean ForceUpdate is TRUE*/
/**/
/* 17/07/98 - Carlos Torres*/
/* ***********************************************************************************/
void fn_vUpdateFrameMatrix(void * _p_stSuperObject,tdstFrame3d * _p_stFrame,tdstAnim3d * _p_stAnim3d,
unsigned short _uwFrame,unsigned char ucForceUpdate,tdstAChannel * d_stChannelArray) {
tdstA3dGENERAL * p_stCurrentA3dGENERAL;
tdstChannel * p_stCurrentChannel;
unsigned short uwT_NTTO;
unsigned short uwCnt1,uwNumOfA3dGENERAL;
unsigned short uwCorrectedFrame;
ACP_tdxBool bHierarchized;
/* ----------------------------------------------------------------------------------*/
/* update frame*/
fn_vUpdateFrame(_p_stSuperObject,_p_stFrame,_p_stAnim3d,_uwFrame);
/* ----------------------------------------------------------------------------------*/
/* check if the frame matrix is already updated*/
if (_p_stFrame->ucMatrixUpdated && !ucForceUpdate)
return;
/* ----------------------------------------------------------------------------------*/
/* set ref of the frame*/
_p_stFrame->ucMatrixUpdated = TRUE;
/* ----------------------------------------------------------------------------------*/
/* Get A3D General Info*/
#ifdef A3X_N64
#ifndef FORCE_REAL_TIME_LOAD
if(g_bRealTimeAnimationLoad)
#endif
uwNumOfA3dGENERAL= fn_uw_GetNumOfA3dGENERAL(_p_stAnim3d->uwNumOfA3dGENERAL, _uwFrame);
#ifndef FORCE_REAL_TIME_LOAD
else
#endif
#endif
#ifndef FORCE_REAL_TIME_LOAD
uwNumOfA3dGENERAL= _p_stAnim3d->uwNumOfA3dGENERAL;
#endif
p_stCurrentA3dGENERAL = fn_p_GetA3dGENERAL(uwNumOfA3dGENERAL,_uwFrame);
#ifdef A3X_N64
/* ----------------------------------------------------------------------------------*/
/* check if anim cutting is well done*/
#ifdef ANIM_DEBUG
if ((_uwFrame < p_stCurrentA3dGENERAL->uwStartFrame) ||
(_uwFrame >= p_stCurrentA3dGENERAL->uwEndFrame) )
{
osSyncPrintf("Probleme decoupage d'animation (anim= %d, frame= %d, StartFrame= %d, EndFrame= %d)\n", uwNumOfA3dGENERAL, _uwFrame, p_stCurrentA3dGENERAL->uwStartFrame, p_stCurrentA3dGENERAL->uwEndFrame);
osSyncPrintf("Num<EFBFBD>ro original d'anim : %d\n",_p_stAnim3d->uwNumOfA3dGENERAL);
ASM_BREAK;
}
#endif /* ANIM_DEBUG */
#endif
uwCorrectedFrame = (unsigned short) (_uwFrame - p_stCurrentA3dGENERAL->uwStartFrame);
/* ----------------------------------------------------------------------------------*/
/* Get information to update frame info*/
p_stCurrentChannel = &p_stChannels [p_stCurrentA3dGENERAL->uwNumOfFirstChannel];
uwT_NTTO = p_stOnlyFrames[p_stCurrentA3dGENERAL->uwNumOfFirstOnlyFrame + uwCorrectedFrame].uwNumOfSavedFrame;
/* ----------------------------------------------------------------------------------*/
/* Interpolate all channels Matrix*/
for (uwCnt1=0;uwCnt1<p_stCurrentA3dGENERAL->uwNumberOfChannels;uwCnt1++) {
tdstFrame * p_stCurrentFrame;
tdstFrameKF * p_stCurrentFrameKF;
tdstKeyFrame * p_stCurrentKeyFrame, * p_stOldKeyFrame;
register SEB_xReal xDT= xZero;
/* TEMP ANTI BUG - to avoid crash with bad Anim*/
/* Later replace by an assert in debuf version*/
if ((p_stCurrentChannel->uwChannelNumber != SEB_Invalid) &&
(!d_stChannelArray[p_stCurrentChannel->uwChannelNumber].bControlledChannel))
{
/* Get Current frame information*/
p_stCurrentFrame = &p_stFrames[p_stCurrentChannel->uwNumOfFirstFrame + uwT_NTTO];
p_stCurrentFrameKF = &p_stFramesKF[p_stCurrentChannel->ulNumOfFirstFrameKF + uwCorrectedFrame];
p_stOldKeyFrame = &p_stKeyFrames[p_stCurrentFrameKF->uwNumOfKeyFrame];
/* get key frame for interpolation*/
if ((p_stOldKeyFrame->uwMask & SEB_xMaskLastKey) != 0x0000)
{
if ((p_stOldKeyFrame->uwMask & SEB_xTypeWrapLastKey) != 0x0000)
{
p_stCurrentKeyFrame= &p_stKeyFrames[ p_stFramesKF[p_stCurrentChannel->ulNumOfFirstFrameKF].uwNumOfKeyFrame ];
xDT= ((SEB_xReal) (_uwFrame - p_stOldKeyFrame->uwFrameNumber)) / ((SEB_xReal) (p_stCurrentA3dGENERAL->uwNumberOfFrames + p_stCurrentKeyFrame->uwFrameNumber - p_stOldKeyFrame->uwFrameNumber));
}
else
{
p_stCurrentKeyFrame = p_stOldKeyFrame;
xDT = xZero;
}
}
else {
p_stCurrentKeyFrame = p_stOldKeyFrame + 1;
if (p_stCurrentKeyFrame->uwFrameNumber == p_stOldKeyFrame->uwFrameNumber)
xDT = xZero;
else
xDT = ((SEB_xReal)(_uwFrame - p_stOldKeyFrame->uwFrameNumber)) / ((SEB_xReal)(p_stCurrentKeyFrame->uwFrameNumber - p_stOldKeyFrame->uwFrameNumber));
}
/* InterpolationParameter*/
if ( (p_stOldKeyFrame->swInterpolationParameter != 0x0000) && (xDT != xZero) )
{ register SEB_xReal xTmp;
xTmp= p_stCurrentKeyFrame->swInterpolationParameter * ((SEB_xReal) (1.0f / 8192.0f));
xDT= xDT * (xDT * xTmp + xOne - xTmp);
}
if(p_stNTTO[p_stCurrentFrame->uwNumOfNTTO].uwTypeOfObject!=(unsigned short)0xFFFF)
bHierarchized=(ACP_tdxBool)(p_stNTTO[p_stCurrentFrame->uwNumOfNTTO].uwTypeOfObject & SEB_xTypeHierarchized);
else
bHierarchized=FALSE;
/* Interpolate channel matrix*/
fn_v_InterpolBetweenKeys(
p_stOldKeyFrame,
p_stCurrentKeyFrame,
p_stCurrentChannel,
d_stChannelArray[p_stCurrentChannel->uwChannelNumber].hSupObject->hLocalMatrix,
bHierarchized,
xDT);
}
p_stCurrentChannel++;
}
}
/* ****************************************************** fn_p_stGetLinearSpeedVector*/
/* Return the Linear Speed Vector*/
/* the vector returned is a reference so*/
/* DON'T Modify it or Free it*/
/* if there is no speed, return NULL*/
/* reference remain valid until animation is free*/
/**/
/* 20/07/98 - Carlos Torres*/
/* ***********************************************************************************/
MTH3D_tdstVector * fn_p_stGetLinearSpeedVector(tdstAnim3d * _p_stAnim3d,unsigned short _uwFrame) {
unsigned short uwNumOfA3dGENERAL;
tdstA3dGENERAL * p_stCurrentA3dGENERAL;
tdstOnlyFrame * p_stCurrentOnlyFrame;
if ( _uwFrame >= _p_stAnim3d->uwNumberOfFrames )
return NULL; /* Can occur sometimes... AR9808*/
/* ----------------------------------------------------------------------------------*/
/* Get A3D General Info*/
#ifdef A3X_N64
#ifndef FORCE_REAL_TIME_LOAD
if(g_bRealTimeAnimationLoad)
#endif
uwNumOfA3dGENERAL= fn_uw_GetNumOfA3dGENERAL(_p_stAnim3d->uwNumOfA3dGENERAL, _uwFrame);
#ifndef FORCE_REAL_TIME_LOAD
else
#endif
#endif
#ifndef FORCE_REAL_TIME_LOAD
uwNumOfA3dGENERAL= _p_stAnim3d->uwNumOfA3dGENERAL;
#endif
p_stCurrentA3dGENERAL = fn_p_GetA3dGENERAL(uwNumOfA3dGENERAL,_uwFrame);
#ifdef A3X_N64
/* ----------------------------------------------------------------------------------*/
/* check if anim cutting is well done*/
#ifdef ANIM_DEBUG
if ((_uwFrame < p_stCurrentA3dGENERAL->uwStartFrame) ||
(_uwFrame >= p_stCurrentA3dGENERAL->uwEndFrame) )
{
osSyncPrintf("Probleme decoupage d'animation (anim= %d, Frame= %d, StartFrame= %d, EndFrame= %d)\n", uwNumOfA3dGENERAL, _uwFrame, p_stCurrentA3dGENERAL->uwStartFrame, p_stCurrentA3dGENERAL->uwEndFrame);
osSyncPrintf("Numero original d'anim : %d\n",_p_stAnim3d->uwNumOfA3dGENERAL);
ASM_BREAK;
}
#endif /* ANIM_DEBUG */
#endif
#ifndef U64
#pragma warning(disable:4244)
#endif
_uwFrame -= p_stCurrentA3dGENERAL->uwStartFrame;
#ifndef U64
#pragma warning(default:4244)
#endif
/* ----------------------------------------------------------------------------------*/
/* Get information to update frame info*/
p_stCurrentOnlyFrame = &p_stOnlyFrames[p_stCurrentA3dGENERAL->uwNumOfFirstOnlyFrame + _uwFrame];
/* ----------------------------------------------------------------------------------*/
/* Set Linear Speed Vector if exist*/
if (p_stCurrentOnlyFrame->uwNumOfSpeedVector == SEB_Invalid) {
return NULL;
}
else {
return (MTH3D_tdstVector *) &p_a3_xVectors[p_stCurrentOnlyFrame->uwNumOfSpeedVector];
}
}
/* ***************************************************** fn_p_stGetAngularSpeedMatrix*/
/* Return the Angular Speed Matrix*/
/* Fill the Matrix if exist and return pointer*/
/* If no angular speed return NULL*/
/* The matrix pass in parameter must be allocate by the calling function*/
/**/
/* 20/07/98 - Carlos Torres*/
/* ***********************************************************************************/
MTH3D_tdstMatrix * fn_p_stGetAngularSpeedMatrix(tdstAnim3d * _p_stAnim3d,unsigned short _uwFrame,MTH3D_tdstMatrix * p_stMatrix) {
unsigned short uwNumOfA3dGENERAL;
tdstA3dGENERAL * p_stCurrentA3dGENERAL;
tdstOnlyFrame * p_stCurrentOnlyFrame;
if ( _uwFrame >= _p_stAnim3d->uwNumberOfFrames )
return NULL; /* Can occur sometimes... AR9808*/
/* ----------------------------------------------------------------------------------*/
/* Get A3D General Info*/
#ifdef A3X_N64
#ifndef FORCE_REAL_TIME_LOAD
if(g_bRealTimeAnimationLoad)
#endif
uwNumOfA3dGENERAL= fn_uw_GetNumOfA3dGENERAL(_p_stAnim3d->uwNumOfA3dGENERAL, _uwFrame);
#ifndef FORCE_REAL_TIME_LOAD
else
#endif
#endif
#ifndef FORCE_REAL_TIME_LOAD
uwNumOfA3dGENERAL= _p_stAnim3d->uwNumOfA3dGENERAL;
#endif
p_stCurrentA3dGENERAL = fn_p_GetA3dGENERAL(uwNumOfA3dGENERAL,_uwFrame);
#ifdef A3X_N64
/* ----------------------------------------------------------------------------------*/
/* check if anim cutting is well done*/
#ifdef ANIM_DEBUG
if ((_uwFrame < p_stCurrentA3dGENERAL->uwStartFrame) ||
(_uwFrame >= p_stCurrentA3dGENERAL->uwEndFrame) )
{
osSyncPrintf("Probleme decoupage d'animation (anim= %d, Frame= %d, StartFrame= %d, EndFrame= %d)\n", uwNumOfA3dGENERAL, _uwFrame, p_stCurrentA3dGENERAL->uwStartFrame, p_stCurrentA3dGENERAL->uwEndFrame);
osSyncPrintf("Animation originelle : %d\n",_p_stAnim3d->uwNumOfA3dGENERAL);
ASM_BREAK;
}
#endif /* ANIM_DEBUG */
#endif /*A3X_N64*/
#ifndef U64
#pragma warning(disable:4244)
#endif
_uwFrame -= p_stCurrentA3dGENERAL->uwStartFrame;
#ifndef U64
#pragma warning(default:4244)
#endif
/* ----------------------------------------------------------------------------------*/
/* Get information to update frame info*/
p_stCurrentOnlyFrame = &p_stOnlyFrames[p_stCurrentA3dGENERAL->uwNumOfFirstOnlyFrame + _uwFrame];
/* ----------------------------------------------------------------------------------*/
/* Set Angular Speed Matrix if exist*/
if (p_stCurrentOnlyFrame->uwNumOfAngularSpeedQuat == SEB_Invalid) {
return NULL;
}
else {
tdxQuater4 a4_xQuatOri;
fn_v_ExpandQuat(a4_xQuatOri,p_a4_xQuaternions[p_stCurrentOnlyFrame->uwNumOfAngularSpeedQuat]);
/* if (_uwFrame != 1)
fn_v_InterpolQuatWithOmega( a4_xQuatOri, a4_xQuater1, a4_xQuatOri, (SEB_xReal)_uwFrame, p_stCurrentOnlyFrame->uwAngSpeedQuat ); */
fn_v_QuatToMatrix(*((tdxMatrix33 *) (p_stMatrix)),a4_xQuatOri);
return p_stMatrix;
}
}
#undef A3X_INTN_C

View File

@@ -0,0 +1,813 @@
/* ***********************************************************************************/
/* * "a3x_load.c" **/
/* * Written by : S<>bastien Rubens **/
/* * Tabulations : 4 char **/
/* ***********************************************************************************/
/* ***********************************************************************************/
#define A3X_LOAD_C
/* ***********************************************************************************/
/* Included files*/
#include <math.h>
#include <stdio.h>
#include "PlayAnim/Interpol/specif/a3x_pref.h"
/*#define LST2_StaticIsOptimised*/
#include "TOOLSCPA.h"
#include "cpa_std.h"
#include "STRUCTUR/Anim_s.h"
#include "PlayAnim/Interpol/a3x_glob.h"
#include "PlayAnim/Interpol/a3x_int.h"
#include "PlayAnim/Interpol/a3x_mem.h"
#include "PlayAnim/Interpol/a3x_load.h"
/* ***********************************************************************************/
/* Globals datas*/
static void *p_vCurrentFile;
static tdstFileA3dAnimationGENERAL *p_stFileA3dGENERAL;
static tdxULongVector3 *p_stFileVector3;
static tdxSShortQuater4 *p_stFileQuater4;
static tdstFileHierarchy *p_stFileHierarchy;
static tdstFileNTTO *p_stFileNTTO;
static tdstFileOnlyFrame *p_stFileOnlyFrame;
static tdstFileChannel *p_stFileChannel;
static tdstFileFrame *p_stFileFrame;
static tdstFileKeyFrame *p_stFileKeyFrame;
static tdstFileEvent *p_stFileEvent;
static tdstFileMorphData *p_stFileMorphData;
static tdstA3dGENERAL *p_stCurrentA3dGENERAL;
static tdxULongVector3 *p_stCurrentVector3;
static tdxSShortQuater4 *p_stCurrentQuater4;
static tdstHierarchy *p_stCurrentHierarchy;
static tdstNTTO *p_stCurrentNTTO;
static tdstOnlyFrame *p_stCurrentOnlyFrame;
static tdstChannel *p_stCurrentChannel, *p_stFirstChannel;
static tdstFrame *p_stCurrentFrame;
static tdstKeyFrame *p_stCurrentKeyFrame, *p_stOldKeyFrame;
static tdstEvent *p_stCurrentEvent;
static tdstMorphData *p_stCurrentMorphData;
static tdxMatrix33 a3a3_xMtxOri, a3a3_xMtxSca, a3a3_xScaleMatrix;
static tdxQuater4 a4_xOldQuatOri, a4_xOldQuatSca;
static tdxQuater4 a4_xQuatOri, a4_xQuatSca;
static tdxVector3 a3_xTmpVec;
static unsigned short uwNumOfFirstVector, uwNumOfFirstQuaternion, uwNumOfFirstHierarchy;
#ifdef ANIM_DEBUG
extern char* g_p_cSecurityMalloc; /* for debug -> to be removed !!!*/
#endif /*ANIM_DEBUG*/
/* ***********************************************************************************/
#ifdef A3xDebug
void fn_v_A3dVerify( char *a4_cNeededString,
char *p_cString )
{
if ( (a4_cNeededString[0] != p_cString[0]) ||
(a4_cNeededString[1] != p_cString[1]) ||
(a4_cNeededString[2] != p_cString[2]) ||
(a4_cNeededString[3] != p_cString[3]) )
{ printf("Error in %s hunk\n", a4_cNeededString );
}
}
#define M_A3xDebug( String, Type, p_xFile ) \
{ fn_v_A3dVerify( String, (char *) (p_xFile) ); \
p_xFile= (Type *) ( ((char *) (p_xFile)) + 8 ); \
}
#else
#define M_A3xDebug( String, Type, p_xFile )
#endif
#ifdef U64
/* XB 05/05/99 */
extern void *fast_memcpy( register void *dest, register void *src, register size_t n);
/* End XB 05/05/99 */
#define memcpy(a,b,c) fast_memcpy(a,b,c)
#endif /*U64*/
/* ***********************************************************************************/
void fn_v_LoadA3dGENERAL( void )
{
p_stCurrentA3dGENERAL= &p_stA3dGENERAL[ fn_ul_AllocateOnStack( eStackA3dGENERAL, 1 ) ];
p_stFileA3dGENERAL= (tdstFileA3dAnimationGENERAL *) p_vCurrentFile;
M_A3xDebug( "GENE", tdstFileA3dAnimationGENERAL, p_stFileA3dGENERAL );
/* p_stCurrentA3dGENERAL->uwAnimationSpeed= p_stFileA3dGENERAL->uwAnimationSpeed;
p_stCurrentA3dGENERAL->uwNumberOfVectors= p_stFileA3dGENERAL->uwNumberOfVectors;
p_stCurrentA3dGENERAL->uwNumberOfQuaternions= p_stFileA3dGENERAL->uwNumberOfQuaternions;
p_stCurrentA3dGENERAL->uwNumberOfHierarchies= p_stFileA3dGENERAL->uwNumberOfHierarchies;
p_stCurrentA3dGENERAL->uwNumberOfNTTO= p_stFileA3dGENERAL->uwNumberOfSavedNTTO;
p_stCurrentA3dGENERAL->uwNumberOfSavedFrames= p_stFileA3dGENERAL->uwNumberOfSavedFrames;
p_stCurrentA3dGENERAL->uwNumberOfChannels= p_stFileA3dGENERAL->uwNumberOfChannels;
p_stCurrentA3dGENERAL->uwNumberOfFrames= p_stFileA3dGENERAL->uwNumberOfFrames;
p_stCurrentA3dGENERAL->uwNumberOfKeyFrames= p_stFileA3dGENERAL->uwNumberOfKeyFrames;
p_stCurrentA3dGENERAL->uwNumberOfEvents= p_stFileA3dGENERAL->uwNumberOfEvents;
p_stCurrentA3dGENERAL->uwNumberOfMorphData= p_stFileA3dGENERAL->uwNumberOfMorphData;
p_stCurrentA3dGENERAL->uwNumOfAnimationTranslationOffset= p_stFileA3dGENERAL->uwNumOfAnimationTranslationOffset;
p_stCurrentA3dGENERAL->uwNumOfAnimationRotationOffset= p_stFileA3dGENERAL->uwNumOfAnimationRotationOffset;
p_stCurrentA3dGENERAL->uwNumOfFirstPosition= p_stFileA3dGENERAL->uwNumOfFirstPosition;
p_stCurrentA3dGENERAL->uwStartFrame= p_stFileA3dGENERAL->uwStartFrame;
p_stCurrentA3dGENERAL->uwEndFrame= p_stFileA3dGENERAL->uwEndFrame;
p_stCurrentA3dGENERAL->uwFlags= p_stFileA3dGENERAL->uwFlags;
p_stCurrentA3dGENERAL->uwFakeAnimSpeed= p_stFileA3dGENERAL->uwFakeAnimSpeed; */
/* p_stCurrentA3dGENERAL->uwAlign= 0;*/
/* optim AR9811*/
memcpy(p_stCurrentA3dGENERAL,p_stFileA3dGENERAL,sizeof(tdstFileA3dAnimationGENERAL));
p_stFileA3dGENERAL++;
p_vCurrentFile= (void *) p_stFileA3dGENERAL;
/*unsigned short uwNumOfFirstVector; will be set in fn_v_LoadVectors*/
/*unsigned short uwNumOfFirstQuaternion; will be set in fn_v_LoadQuaternions*/
/*unsigned short uwNumOfFirstHierarchy; will be set in fn_v_LoadHierarchies*/
/*unsigned short uwNumOfFirstNTTO; will be set in fn_v_LoadNTTO*/
/*unsigned short uwNumOfFirstOnlyFrame; will be set in fn_v_LoadOnlyFrames*/
/*unsigned short uwNumOfFirstChannel; will be set in fn_v_LoadChannels*/
/*unsigned short uwNumOfFirstEvent; will be set in fn_v_LoadEvents*/
/*unsigned short uwNumOfFirstPosition; will be add in fn_v_LoadVectors*/
/*unsigned short uwNumOfAnimationTranslationOffset; will be add in fn_v_LoadVectors*/
/*unsigned short uwNumOfAnimationRotationOffset; will be add in fn_v_LoadQuaternions*/
}
/* ***********************************************************************************/
void fn_v_LoadVectors( void )
{ register unsigned short uwMax/*, uwCnt1*/;
register unsigned long ulInd;
uwMax= p_stCurrentA3dGENERAL->uwNumberOfVectors;
ulInd= fn_ul_AllocateOnStack( eStackVertexes, uwMax );
uwNumOfFirstVector = p_stCurrentA3dGENERAL->uwNumOfFirstVector = (unsigned short)ulInd;
p_stCurrentVector3= (tdxULongVector3 *) &p_a3_xVectors[ ulInd ];
p_stFileVector3= (tdxULongVector3 *) p_vCurrentFile;
M_A3xDebug( "VERT", tdxULongVector3, p_stFileVector3 );
/* for ( uwCnt1=0 ; uwCnt1<uwMax ; uwCnt1++ )
{
(*p_stCurrentVector3)[0]= (*p_stFileVector3)[0];
(*p_stCurrentVector3)[1]= (*p_stFileVector3)[1];
(*p_stCurrentVector3)[2]= (*p_stFileVector3)[2];
p_stFileVector3++;
p_stCurrentVector3++;
}*/
memcpy(p_stCurrentVector3,p_stFileVector3,sizeof(tdxULongVector3)*uwMax); /* optim AR9811*/
/* p_vCurrentFile= (void *) p_stFileVector3;*/
p_vCurrentFile= (void *) (p_stFileVector3+uwMax);
p_stCurrentVector3 += uwMax;
#pragma warning(disable:4244)
p_stCurrentA3dGENERAL->uwNumOfFirstPosition+= uwNumOfFirstVector;
p_stCurrentA3dGENERAL->uwNumOfAnimationTranslationOffset+= uwNumOfFirstVector;
#pragma warning(default:4244)
}
/* ***********************************************************************************/
void fn_v_LoadQuaternions( void )
{ register unsigned short uwMax/*, uwCnt1*/;
register unsigned long ulInd;
uwMax= p_stCurrentA3dGENERAL->uwNumberOfQuaternions;
ulInd= fn_ul_AllocateOnStack( eStackQuaternions, uwMax );
uwNumOfFirstQuaternion = p_stCurrentA3dGENERAL->uwNumOfFirstQuaternion = (unsigned short)ulInd;
p_stCurrentQuater4= &p_a4_xQuaternions[ ulInd ];
p_stFileQuater4= (tdxSShortQuater4 *) p_vCurrentFile;
M_A3xDebug( "QUAT", tdxSShortQuater4, p_stFileQuater4 );
/* for ( uwCnt1=0 ; uwCnt1<uwMax ; uwCnt1++ )
{
(*p_stCurrentQuater4)[0]= (*p_stFileQuater4)[0];
(*p_stCurrentQuater4)[1]= (*p_stFileQuater4)[1];
(*p_stCurrentQuater4)[2]= (*p_stFileQuater4)[2];
(*p_stCurrentQuater4)[3]= (*p_stFileQuater4)[3];
p_stFileQuater4++;
p_stCurrentQuater4++;
} */
memcpy(p_stCurrentQuater4,p_stFileQuater4,sizeof(tdxSShortQuater4)*uwMax); /* optim AR9811*/
/* p_vCurrentFile= (void *) p_stFileQuater4;*/
p_vCurrentFile= (void *) (p_stFileQuater4+uwMax);
p_stCurrentQuater4 += uwMax;
#pragma warning(disable:4244)
p_stCurrentA3dGENERAL->uwNumOfAnimationRotationOffset+= uwNumOfFirstQuaternion;
#pragma warning(default:4244)
}
/* ***********************************************************************************/
void fn_v_LoadHierarchies( void )
{ register unsigned short uwMax/*, uwCnt1*/;
register unsigned long ulInd;
uwMax= p_stCurrentA3dGENERAL->uwNumberOfHierarchies;
ulInd= fn_ul_AllocateOnStack( eStackHierarchies, uwMax );
uwNumOfFirstHierarchy = p_stCurrentA3dGENERAL->uwNumOfFirstHierarchy = (unsigned short)ulInd;
p_stCurrentHierarchy= &p_stHierarchies[ ulInd ];
p_stFileHierarchy= (tdstFileHierarchy *) p_vCurrentFile;
M_A3xDebug( "HIER", tdstFileHierarchy, p_stFileHierarchy );
/* for ( uwCnt1=0 ; uwCnt1<uwMax ; uwCnt1++ )
{
p_stCurrentHierarchy->uwChild= p_stFileHierarchy->uwChild;
p_stCurrentHierarchy->uwFather= p_stFileHierarchy->uwFather;
p_stFileHierarchy++;
p_stCurrentHierarchy++;
} */
memcpy(p_stCurrentHierarchy,p_stFileHierarchy,sizeof(tdstFileHierarchy)*uwMax); /* optim AR9811*/
/* p_vCurrentFile= (void *) p_stFileHierarchy;*/
p_vCurrentFile= (void *) (p_stFileHierarchy+uwMax);
p_stCurrentHierarchy+=uwMax;
}
/* ***********************************************************************************/
void fn_v_LoadNTTO( void )
{ register unsigned short uwMax/*, uwCnt1*/;
register unsigned long ulInd;
uwMax= p_stCurrentA3dGENERAL->uwNumberOfNTTO;
ulInd= fn_ul_AllocateOnStack( eStackNTTO, uwMax );
p_stCurrentA3dGENERAL->uwNumOfFirstNTTO = (unsigned short)ulInd;
p_stCurrentNTTO= &p_stNTTO[ ulInd ];
p_stFileNTTO= (tdstFileNTTO *) p_vCurrentFile;
M_A3xDebug( "NTTO", tdstFileNTTO, p_stFileNTTO );
/* for ( uwCnt1=0 ; uwCnt1<uwMax ; uwCnt1++ )
{
p_stCurrentNTTO->ucNumberInTable= p_stFileNTTO->ucNumberInTable;
p_stCurrentNTTO->uwTypeOfObject= p_stFileNTTO->uwTypeOfObject;
p_stCurrentNTTO->ucTransparency= p_stFileNTTO->ucTransparency;
p_stFileNTTO++;
p_stCurrentNTTO++;
} */
memcpy(p_stCurrentNTTO,p_stFileNTTO,sizeof(tdstFileNTTO)*uwMax); /* optim AR9811*/
/* p_vCurrentFile= (void *) p_stFileNTTO;*/
p_vCurrentFile= (void *) (p_stFileNTTO+uwMax);
p_stCurrentNTTO+=uwMax;
}
/* ***********************************************************************************/
void fn_v_LoadOnlyFrames( void )
{ register unsigned short uwCnt1, uwMax;
register unsigned long ulInd;
uwMax= (unsigned short)(p_stCurrentA3dGENERAL->uwEndFrame - p_stCurrentA3dGENERAL->uwStartFrame);
ulInd= fn_ul_AllocateOnStack( eStackOnlyFrames, uwMax );
p_stCurrentA3dGENERAL->uwNumOfFirstOnlyFrame = (unsigned short)ulInd;
p_stCurrentOnlyFrame= &p_stOnlyFrames[ ulInd ];
p_stFileOnlyFrame= (tdstFileOnlyFrame *) p_vCurrentFile;
M_A3xDebug( "OFRM", tdstFileOnlyFrame, p_stFileOnlyFrame );
for ( uwCnt1=0 ; uwCnt1<uwMax ; uwCnt1++ )
{
if ( p_stFileOnlyFrame->uwNumOfAngularSpeedQuat != SEB_Invalid )
{ p_stCurrentOnlyFrame->uwNumOfAngularSpeedQuat= (unsigned short) (uwNumOfFirstQuaternion + p_stFileOnlyFrame->uwNumOfAngularSpeedQuat);
/* fn_v_ExpandQuat( a4_xQuatOri, p_a4_xQuaternions[ p_stCurrentOnlyFrame->uwNumOfAngularSpeedQuat ] );
p_stCurrentOnlyFrame->uwAngSpeedQuat= fn_uw_AngleBetweenQuat( a4_xQuatOri, a4_xQuater1 ); */
}
else
{ p_stCurrentOnlyFrame->uwNumOfAngularSpeedQuat= SEB_Invalid;
}
if ( p_stFileOnlyFrame->uwNumOfSpeedVector != SEB_Invalid )
p_stCurrentOnlyFrame->uwNumOfSpeedVector=(unsigned short)(uwNumOfFirstVector + p_stFileOnlyFrame->uwNumOfSpeedVector);
else p_stCurrentOnlyFrame->uwNumOfSpeedVector= SEB_Invalid;
p_stCurrentOnlyFrame->uwHierarchyNbCouples= p_stFileOnlyFrame->uwHierarchyNbCouples;
p_stCurrentOnlyFrame->uwNumOfFirstHierarchyCouple= (unsigned short)(uwNumOfFirstHierarchy + p_stFileOnlyFrame->uwNumOfHierarchyCouples);
p_stCurrentOnlyFrame->uwNumOfSavedFrame= p_stFileOnlyFrame->uwNumOfSavedFrame;
p_stFileOnlyFrame++;
p_stCurrentOnlyFrame++;
}
p_vCurrentFile= (void *) p_stFileOnlyFrame;
}
/* ***********************************************************************************/
void fn_v_LoadChannels( void )
{ register unsigned short uwCnt1, uwMax;
register unsigned long ulInd;
uwMax= p_stCurrentA3dGENERAL->uwNumberOfChannels;
ulInd= fn_ul_AllocateOnStack( eStackChannels, uwMax );
p_stCurrentA3dGENERAL->uwNumOfFirstChannel = (unsigned short)ulInd;
p_stFirstChannel= &p_stChannels[ ulInd ];
p_stCurrentChannel= p_stFirstChannel;
p_stFileChannel= (tdstFileChannel *) p_vCurrentFile;
M_A3xDebug( "CHAN", tdstFileChannel, p_stFileChannel );
for ( uwCnt1=0 ; uwCnt1<uwMax ; uwCnt1++ )
{
p_stCurrentChannel->uwNumberOfKeys= p_stFileChannel->uwNumberOfKeys;
p_stCurrentChannel->uwChannelNumber= p_stFileChannel->uwChannelNumber;
p_stCurrentChannel->uwNumOfLocalPivotPos= (unsigned short)(uwNumOfFirstVector + p_stFileChannel->uwNumOfLocalPivotPos);
p_stFileChannel++;
p_stCurrentChannel++;
}
p_vCurrentFile= (void *) p_stFileChannel;
/*unsigned short uwNumOfFirstFrame; will be set in fn_v_LoadFrames*/
/*unsigned short uwNumOfFirstFrameKF; will be set in fn_v_LoadFrames*/
/*unsigned short uwNumOfFirstKeyFrame; will be set in fn_v_LoadKeyFrames*/
}
/* ***********************************************************************************/
void fn_v_LoadFrames( void )
{ register unsigned short uwCnt1, uwCnt2, uwMax;
register unsigned long ulInd;
p_stCurrentChannel= p_stFirstChannel;
p_stFileFrame= (tdstFileFrame *) p_vCurrentFile;
M_A3xDebug( "FRMS", tdstFileFrame, p_stFileFrame );
for ( uwCnt1=0 ; uwCnt1<p_stCurrentA3dGENERAL->uwNumberOfChannels ; uwCnt1++ )
{
uwMax= p_stCurrentA3dGENERAL->uwNumberOfSavedFrames;
ulInd= fn_ul_AllocateOnStack( eStackFrames, uwMax );
p_stCurrentChannel->uwNumOfFirstFrame=(unsigned short)ulInd;
p_stCurrentFrame= &p_stFrames[ ulInd ];
for ( uwCnt2=0 ; uwCnt2<uwMax ; uwCnt2++ )
{
if(p_stFileFrame->uwNumOfNTTO!=(unsigned short)0xFFFF) /*AR9810 0xFFFF means simple empty object*/
p_stCurrentFrame->uwNumOfNTTO= (unsigned short)(p_stCurrentA3dGENERAL->uwNumOfFirstNTTO + p_stFileFrame->uwNumOfNTTO);
else
p_stCurrentFrame->uwNumOfNTTO=(unsigned short)0xFFFF;
p_stFileFrame++;
p_stCurrentFrame++;
}
uwMax= (unsigned short)(p_stCurrentA3dGENERAL->uwEndFrame - p_stCurrentA3dGENERAL->uwStartFrame);
ulInd= fn_ul_AllocateOnStack( eStackFramesKF, uwMax );
p_stCurrentChannel->ulNumOfFirstFrameKF = ulInd;
p_stCurrentChannel++;
}
p_vCurrentFile= (void *) p_stFileFrame;
/*unsigned short uwNumOfKeyFrame; will be set in fn_v_LoadKeyFrames*/
}
/* ***********************************************************************************/
void fn_v_LoadKeyFrames( void )
{ register unsigned short uwCnt1, uwCnt2, uwCnt3, uwMax;
register unsigned long ulInd;
unsigned short uwNumOfPosition;
unsigned long ulNumOfFirstFrameKF;
unsigned short uwNumOfOldKeyFrame= 0, uwNumOfCurrentKeyFrame;
unsigned short uwNumOfOldFrameNumber= 0, uwNumOfCurrentFrameNumber;
unsigned short uwNumOfOldPosition= 0;
p_stCurrentChannel= p_stFirstChannel;
p_stFileKeyFrame= (tdstFileKeyFrame *) p_vCurrentFile;
M_A3xDebug( "KFRM", tdstFileKeyFrame, p_stFileKeyFrame );
for ( uwCnt1=0 ; uwCnt1<p_stCurrentA3dGENERAL->uwNumberOfChannels ; uwCnt1++ )
{
/* Allocate KeyFrames*/
uwMax= p_stCurrentChannel->uwNumberOfKeys;
ulInd= fn_ul_AllocateOnStack( eStackKeyFrames, uwMax );
p_stCurrentChannel->uwNumOfFirstKeyFrame = (unsigned short)ulInd;
p_stCurrentKeyFrame= &p_stKeyFrames[ ulInd ];
/* Warning : don't change uwInd value (it will use at the end of this routine to get first keyframe)*/
ulNumOfFirstFrameKF= p_stCurrentChannel->ulNumOfFirstFrameKF;
uwNumOfCurrentKeyFrame= (unsigned short)ulInd;
uwNumOfCurrentFrameNumber= 0;
ulInd= 0;
uwCnt3= p_stCurrentChannel->uwNumOfLocalPivotPos;
if ( (p_a3_xVectors[uwCnt3][0] != xZero) ||
(p_a3_xVectors[uwCnt3][1] != xZero) ||
(p_a3_xVectors[uwCnt3][2] != xZero) )
{ ulInd= 1;
}
for ( uwCnt2=0 ; uwCnt2<uwMax ; uwCnt2++ )
{
/* Copy Key Frame information*/
p_stCurrentKeyFrame->uwFrameNumber= p_stFileKeyFrame->uwFrameNumber;
p_stCurrentKeyFrame->uwMask= p_stFileKeyFrame->uwMask;
p_stCurrentKeyFrame->uwNumOfQuatOri= (unsigned short)(uwNumOfFirstQuaternion + p_stFileKeyFrame->uwNumOfQuatOri);
p_stCurrentKeyFrame->uwNumOfQuatSca= (unsigned short)(uwNumOfFirstQuaternion + p_stFileKeyFrame->uwNumOfQuatSca);
p_stCurrentKeyFrame->uwNumOfScaleValues= (unsigned short)(uwNumOfFirstVector + p_stFileKeyFrame->uwNumOfScaleValues);
p_stCurrentKeyFrame->uwNumOfPosition= (unsigned short)(uwNumOfFirstVector + p_stFileKeyFrame->uwNumOfPosition);
p_stCurrentKeyFrame->swInterpolationParameter= p_stFileKeyFrame->swInterpolationParameter;
/* World Pivot position*/
fn_v_ExpandQuat ( a4_xQuatOri, p_a4_xQuaternions[ p_stCurrentKeyFrame->uwNumOfQuatOri ] );
fn_v_ExpandQuat( a4_xQuatSca, p_a4_xQuaternions[ p_stCurrentKeyFrame->uwNumOfQuatSca ] );
if (ulInd == 0)
{ register SEB_xReal xTmp;
xTmp= 0.0f;
p_stCurrentKeyFrame->a3_xWorldPivotPosition[0]= xTmp;
p_stCurrentKeyFrame->a3_xWorldPivotPosition[1]= xTmp;
p_stCurrentKeyFrame->a3_xWorldPivotPosition[2]= xTmp;
}
else
{
fn_v_QuatToMatrix( a3a3_xMtxOri, a4_xQuatOri );
/* optim AR9811*/
if((a4_xQuatSca[0]!=0.0f)||(a4_xQuatSca[1]!=0.0f)||(a4_xQuatSca[2]!=0.0f)||(a4_xQuatSca[3]!=1.0f))
{
fn_v_QuatToMatrix( a3a3_xMtxSca, a4_xQuatSca );
fn_v_InvRotDiaRot( a3a3_xScaleMatrix, a3a3_xMtxSca, p_a3_xVectors[ p_stCurrentKeyFrame->uwNumOfScaleValues ] );
fn_v_MatrixByVector( a3_xTmpVec, a3a3_xScaleMatrix, p_a3_xVectors[ p_stCurrentChannel->uwNumOfLocalPivotPos ] );
}
else
{
a3_xTmpVec[0]=p_a3_xVectors[ p_stCurrentKeyFrame->uwNumOfScaleValues ][0]*p_a3_xVectors[ p_stCurrentChannel->uwNumOfLocalPivotPos ][0];
a3_xTmpVec[1]=p_a3_xVectors[ p_stCurrentKeyFrame->uwNumOfScaleValues ][1]*p_a3_xVectors[ p_stCurrentChannel->uwNumOfLocalPivotPos ][1];
a3_xTmpVec[2]=p_a3_xVectors[ p_stCurrentKeyFrame->uwNumOfScaleValues ][2]*p_a3_xVectors[ p_stCurrentChannel->uwNumOfLocalPivotPos ][2];
}
fn_v_MatrixByVector( p_stCurrentKeyFrame->a3_xWorldPivotPosition, a3a3_xMtxOri, a3_xTmpVec );
}
uwNumOfPosition= p_stCurrentKeyFrame->uwNumOfPosition;
p_stCurrentKeyFrame->a3_xWorldPivotPosition[0]+= p_a3_xVectors[ uwNumOfPosition ][0];
p_stCurrentKeyFrame->a3_xWorldPivotPosition[1]+= p_a3_xVectors[ uwNumOfPosition ][1];
p_stCurrentKeyFrame->a3_xWorldPivotPosition[2]+= p_a3_xVectors[ uwNumOfPosition ][2];
/* DistMaster*/
p_stCurrentKeyFrame->xDistMaster= fn_x_VectorLength( p_a3_xVectors[ uwNumOfPosition ] );
/* If we are not on the first keyframe*/
if ( uwCnt2 > 0 )
{
p_stOldKeyFrame->uwAngQuatOri= 0x0000;
if ((p_stOldKeyFrame->uwMask & SEB_xMaskQuatOri) == 0x0000)
p_stOldKeyFrame->uwAngQuatOri= fn_uw_AngleBetweenQuat( a4_xOldQuatOri, a4_xQuatOri );
p_stOldKeyFrame->uwAngQuatSca= 0x0000;
if ((p_stOldKeyFrame->uwMask & SEB_xMaskQuatSca) == 0x0000)
p_stOldKeyFrame->uwAngQuatSca= fn_uw_AngleBetweenQuat( a4_xOldQuatSca, a4_xQuatSca );
/* Copy KeyFrames references*/
uwNumOfCurrentFrameNumber= p_stFileKeyFrame->uwFrameNumber;
if ( uwNumOfCurrentFrameNumber > p_stCurrentA3dGENERAL->uwEndFrame )
uwNumOfCurrentFrameNumber= p_stCurrentA3dGENERAL->uwEndFrame;
#pragma warning(disable:4244)
uwNumOfCurrentFrameNumber-= p_stCurrentA3dGENERAL->uwStartFrame;
#pragma warning(default:4244)
for ( uwCnt3=uwNumOfOldFrameNumber ; uwCnt3<uwNumOfCurrentFrameNumber ; uwCnt3++ )
p_stFramesKF[ulNumOfFirstFrameKF + uwCnt3].uwNumOfKeyFrame= uwNumOfOldKeyFrame;
}
/* Copy old informations*/
p_stOldKeyFrame= p_stCurrentKeyFrame;
fn_v_CopyQuat( a4_xOldQuatOri, a4_xQuatOri );
fn_v_CopyQuat( a4_xOldQuatSca, a4_xQuatSca );
uwNumOfOldPosition= uwNumOfPosition;
uwNumOfOldFrameNumber= uwNumOfCurrentFrameNumber;
uwNumOfOldKeyFrame= uwNumOfCurrentKeyFrame;
uwNumOfCurrentKeyFrame++;
p_stFileKeyFrame++;
p_stCurrentKeyFrame++;
}
/* For last keyframe*/
p_stCurrentKeyFrame= &p_stKeyFrames[ p_stCurrentChannel->uwNumOfFirstKeyFrame ];
fn_v_ExpandQuat ( a4_xQuatOri, p_a4_xQuaternions[ p_stCurrentKeyFrame->uwNumOfQuatOri ] );
fn_v_ExpandQuat ( a4_xQuatSca, p_a4_xQuaternions[ p_stCurrentKeyFrame->uwNumOfQuatSca ] );
p_stOldKeyFrame->uwAngQuatOri= 0x0000;
if ((p_stOldKeyFrame->uwMask & SEB_xMaskQuatOri) == 0x0000)
p_stOldKeyFrame->uwAngQuatOri= fn_uw_AngleBetweenQuat( a4_xOldQuatOri, a4_xQuatOri );
p_stOldKeyFrame->uwAngQuatSca= 0x0000;
if ((p_stOldKeyFrame->uwMask & SEB_xMaskQuatSca) == 0x0000)
p_stOldKeyFrame->uwAngQuatSca= fn_uw_AngleBetweenQuat( a4_xOldQuatSca, a4_xQuatSca );
for ( uwCnt3=uwNumOfOldFrameNumber ; uwCnt3<(p_stCurrentA3dGENERAL->uwEndFrame - p_stCurrentA3dGENERAL->uwStartFrame) ; uwCnt3++ )
p_stFramesKF[ulNumOfFirstFrameKF + uwCnt3].uwNumOfKeyFrame= uwNumOfOldKeyFrame;
p_stCurrentChannel++;
}
/* Normalization of positions*/
for ( uwCnt1=p_stCurrentA3dGENERAL->uwNumOfFirstPosition ; uwCnt1<uwNumOfFirstVector+p_stCurrentA3dGENERAL->uwNumberOfVectors ; uwCnt1++ )
fn_v_NormalizeVector( p_a3_xVectors[ uwCnt1 ] );
/* Calculate (uwAngObjCentre) and (WorldPivotPosition with hierarchy)*/
p_stCurrentChannel= p_stFirstChannel;
for ( uwCnt1=0 ; uwCnt1<p_stCurrentA3dGENERAL->uwNumberOfChannels ; uwCnt1++ )
{
p_stOldKeyFrame= &p_stKeyFrames[ p_stCurrentChannel->uwNumOfFirstKeyFrame ];
p_stCurrentKeyFrame= &p_stOldKeyFrame[1];
uwMax= p_stCurrentChannel->uwNumberOfKeys;
for ( uwCnt2=1 ; uwCnt2<uwMax ; uwCnt2++ )
{ /* uwAngObjCentre*/
p_stOldKeyFrame->uwAngObjCentre=
fn_uw_AngleBetweenVect( p_a3_xVectors[ p_stOldKeyFrame->uwNumOfPosition ],
p_a3_xVectors[ p_stCurrentKeyFrame->uwNumOfPosition ] );
p_stOldKeyFrame++;
p_stCurrentKeyFrame++;
}
/* For last keyframe*/
p_stOldKeyFrame->uwAngObjCentre=
fn_uw_AngleBetweenVect( p_a3_xVectors[ p_stOldKeyFrame->uwNumOfPosition ], p_a3_xVectors[ p_stKeyFrames[p_stCurrentChannel->uwNumOfFirstKeyFrame].uwNumOfPosition ] );
p_stCurrentChannel++;
}
p_vCurrentFile= (void *) p_stFileKeyFrame;
}
/*----------------------------------------------------------------------------
// Description : fn_v_LoadMorphingData
// Load morphing data from the rom
----------------------------------------------------------------------------//
// Methods : None
----------------------------------------------------------------------------//
// Input :
// Output :
----------------------------------------------------------------------------//
// Creation date : Mar 98 Author: Alain Robin
----------------------------------------------------------------------------//
// Modifications :
// Modification date : Modification author :
----------------------------------------------------------------------------*/
void fn_v_LoadMorphingData ( void )
{
register unsigned short uwMax/*, uwCnt1*/;
register unsigned long ulInd;
/* Alignment*/
while ( (((unsigned long) p_vCurrentFile) % 4) != 0 )
p_vCurrentFile= (void *) (((unsigned char *) p_vCurrentFile) + 1);
uwMax= p_stCurrentA3dGENERAL->uwNumberOfMorphData;
ulInd= fn_ul_AllocateOnStack( eStackMorphData, p_stCurrentA3dGENERAL->uwNumberOfMorphData);
p_stCurrentA3dGENERAL->uwNumOfFirstMorphData = (unsigned short)ulInd;
p_stCurrentMorphData= &p_stMorphData[ulInd];
p_stFileMorphData= (tdstFileMorphData *) p_vCurrentFile;
/* for ( uwCnt1=0 ; uwCnt1<uwMax ; uwCnt1++ )
{
p_stCurrentMorphData->ucTarget=p_stFileMorphData->ucTarget;
p_stCurrentMorphData->ucMorphingAmount=p_stFileMorphData->ucMorphingAmount;
p_stCurrentMorphData->uwChannelNumber=p_stFileMorphData->uwChannelNumber;
p_stCurrentMorphData->uwFrameNumber=p_stFileMorphData->uwFrameNumber;
p_stFileMorphData++;
p_stCurrentMorphData++;
} */
memcpy(p_stCurrentMorphData,p_stFileMorphData,sizeof(tdstFileMorphData)*uwMax); /* optim AR9811*/
/* p_vCurrentFile= (void *) p_stFileMorphData;*/
p_vCurrentFile= (void *) (p_stFileMorphData+uwMax);
p_stCurrentMorphData+=uwMax;
}
/*AR9809 Now, this function can be in the common part (same structure used)*/
void fn_v_LoadEvents()
{ register unsigned short uwCnt1, uwMax;
register unsigned long ulInd;
/* Alignment*/
while ( (((unsigned long) p_vCurrentFile) % 4) != 0 )
p_vCurrentFile= (void *) (((unsigned char *) p_vCurrentFile) + 1);
uwMax= p_stCurrentA3dGENERAL->uwNumberOfEvents;
ulInd= fn_ul_AllocateOnStack( eStackEvents, uwMax );
p_stCurrentA3dGENERAL->uwNumOfFirstEvent = (unsigned short)ulInd;
p_stCurrentEvent= &p_stEvents[ulInd];
p_stFileEvent= (tdstFileEvent *) p_vCurrentFile;
M_A3xDebug( "EVNT", tdstFileEvent, p_stFileEvent );
for ( uwCnt1=0 ; uwCnt1<uwMax ; uwCnt1++ )
{
p_stCurrentEvent->uwFrameNumber= p_stFileEvent->uwFrameNumber;
p_stCurrentEvent->usEventNumberInTBL= p_stFileEvent->usEventNumberInTBL;
p_stCurrentEvent->p_stfEventInTBL= NULL;
p_stCurrentEvent->uwChannelNumber= p_stFileEvent->uwChannelNumber;
p_stFileEvent++;
p_stCurrentEvent++;
}
p_vCurrentFile= (void *) p_stFileEvent;
}
/* ***********************************************************************************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC 04/06/99 */
unsigned short fn_uw_LoadAnimV6 ( void *_p_vStartFile )
{
p_vCurrentFile= _p_vStartFile;
fn_v_LoadA3dGENERAL ();
fn_v_LoadVectors ();
fn_v_LoadQuaternions();
fn_v_LoadHierarchies();
fn_v_LoadNTTO ();
fn_v_LoadOnlyFrames ();
fn_v_LoadChannels ();
fn_v_LoadFrames ();
fn_v_LoadKeyFrames ();
fn_v_LoadEvents ();
/* fn_v_LoadLights ();*/
fn_v_LoadMorphingData(); /*AR980306*/
return (unsigned short)(fn_ul_GetStackAlloc(eStackA3dGENERAL));
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC 04/06/99 */
/* ***********************************************************************************/
void fn_v_LoadCachedAnimV6 ( char *_p_cDestMem,
void *_p_vStartFile,
unsigned long _ulMaxlength )
{
#ifdef ANIM_PROFILE
u64 ulBefore,ulAfter;
if(_ulMaxlength==10240)
ulBefore=osGetTime();
#endif
#ifdef A3X_CacheIsUsed
/* Reset Stacks*/
M_v_ResetOneStack( eStackA3dGENERAL );
M_v_ResetOneStack( eStackVertexes );
M_v_ResetOneStack( eStackQuaternions );
M_v_ResetOneStack( eStackHierarchies );
M_v_ResetOneStack( eStackNTTO );
M_v_ResetOneStack( eStackOnlyFrames );
M_v_ResetOneStack( eStackChannels );
M_v_ResetOneStack( eStackFrames );
M_v_ResetOneStack( eStackFramesKF );
M_v_ResetOneStack( eStackKeyFrames );
M_v_ResetOneStack( eStackEvents );
M_v_ResetOneStack( eStackMorphData );
p_vCurrentFile= _p_vStartFile;
p_stA3dGENERAL= (tdstA3dGENERAL *) _p_cDestMem;
fn_v_LoadA3dGENERAL ();
p_a3_xVectors= (tdxVector3 *) &p_stA3dGENERAL[1];
fn_v_LoadVectors ();
p_a4_xQuaternions= (tdxSShortQuater4 *) p_stCurrentVector3;
fn_v_LoadQuaternions();
p_stHierarchies= (tdstHierarchy *) p_stCurrentQuater4;
fn_v_LoadHierarchies();
p_stNTTO= (tdstNTTO *) p_stCurrentHierarchy;
fn_v_LoadNTTO ();
p_stOnlyFrames= (tdstOnlyFrame *) p_stCurrentNTTO;
fn_v_LoadOnlyFrames ();
p_stChannels= (tdstChannel *) p_stCurrentOnlyFrame;
while ( (((unsigned long) p_stChannels) %4) != 0 )
p_stChannels= (tdstChannel *) (((char *) p_stChannels) + 1);
fn_v_LoadChannels ();
p_stFrames= (tdstFrame *) p_stCurrentChannel;
fn_v_LoadFrames ();
p_stFramesKF= (tdstFrameKF *) p_stCurrentFrame;
/*p_stKeyFrames= (tdstKeyFrame *) &p_stFramesKF[ p_stCurrentA3dGENERAL->uwNumberOfChannels * p_stCurrentA3dGENERAL->uwNumberOfFrames ];*/
p_stKeyFrames= (tdstKeyFrame *) &p_stFramesKF[ p_stCurrentA3dGENERAL->uwNumberOfChannels *
(p_stCurrentA3dGENERAL->uwEndFrame - p_stCurrentA3dGENERAL->uwStartFrame) ];
/* Alignment*/
if ( (((unsigned long) p_stKeyFrames) & 0x0002) != 0x0000 )
p_stKeyFrames= (tdstKeyFrame *) (((char *) p_stKeyFrames) + 2);
fn_v_LoadKeyFrames ();
p_stEvents= (tdstEvent *) p_stCurrentKeyFrame;
fn_v_LoadEvents ();
/* fn_v_LoadLights ();*/
/* due to alignment*/
while ( (((unsigned long) p_stCurrentEvent) %4) != 0 )
p_stCurrentEvent= (tdstEvent *) (((char *) p_stCurrentEvent) + 1);
p_stMorphData= (tdstMorphData *) p_stCurrentEvent; /*AR9803*/
fn_v_LoadMorphingData(); /*AR9803*/
#ifdef ANIM_PROFILE
if(_ulMaxlength==10240)
{
ulAfter=osGetTime();
osSyncPrintf("%llu\n",ulAfter-ulBefore);
}
#endif
/*AR9901 For debug only -> to be removed !!!*/
#ifdef ANIM_DEBUG
if(*((unsigned char*)(g_p_cSecurityMalloc))!=0xA1)
{
ASM_BREAK;
}
#endif /*#ifdef ANIM_DEBUG*/
#ifdef ANIM_DEBUG
/* due to alignment*/
while ( (((unsigned long) p_stCurrentMorphData) %4) != 0 )
p_stCurrentMorphData= (tdstMorphData *) (((char *) p_stCurrentMorphData) + 1);
if ( abs((unsigned long)p_stCurrentMorphData - (unsigned long)p_stCurrentA3dGENERAL) > _ulMaxlength )
{
osSyncPrintf("fn_v_LoadCachedAnimV6 (%d > %d)\n", ((unsigned long)p_stCurrentMorphData - (unsigned long)p_stCurrentA3dGENERAL),_ulMaxlength);
osSyncPrintf(" uwNumberOfFrames = %4d\n", p_stCurrentA3dGENERAL->uwNumberOfFrames);
osSyncPrintf(" uwNumberOfVectors = %4d\n", p_stCurrentA3dGENERAL->uwNumberOfVectors);
osSyncPrintf(" uwNumberOfQuaternions= %4d\n", p_stCurrentA3dGENERAL->uwNumberOfQuaternions);
osSyncPrintf(" uwNumberOfHierarchies= %4d\n", p_stCurrentA3dGENERAL->uwNumberOfHierarchies);
osSyncPrintf(" uwNumberOfNTTO = %4d\n", p_stCurrentA3dGENERAL->uwNumberOfNTTO);
osSyncPrintf(" uwNumberOfOnlyFrames = %4d\n", (p_stCurrentA3dGENERAL->uwEndFrame - p_stCurrentA3dGENERAL->uwStartFrame));
osSyncPrintf(" uwNumberOfChannels = %4d\n", p_stCurrentA3dGENERAL->uwNumberOfChannels);
osSyncPrintf(" uwNumberOfSavedFrames= %4d\n", p_stCurrentA3dGENERAL->uwNumberOfSavedFrames);
osSyncPrintf(" uwNumberOfKeyFrames = %4d\n", p_stCurrentA3dGENERAL->uwNumberOfKeyFrames);
osSyncPrintf(" uwNumberOfEvents = %4d\n", p_stCurrentA3dGENERAL->uwNumberOfEvents);
osSyncPrintf(" uwNumberOfMorphData = %4d\n", p_stCurrentA3dGENERAL->uwNumberOfMorphData);
osSyncPrintf(" uwStartFrame = %4d\n", p_stCurrentA3dGENERAL->uwStartFrame);
osSyncPrintf(" uwEndFrame = %4d\n", p_stCurrentA3dGENERAL->uwEndFrame);
osSyncPrintf(" p_stA3dGENERAL = %d\n", 0);
osSyncPrintf(" p_a3_xVectors = %d\n", (unsigned long)p_a3_xVectors - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_a4_xQuaternions = %d\n", (unsigned long)p_a4_xQuaternions - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stHierarchies = %d\n", (unsigned long)p_stHierarchies - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stNTTO = %d\n", (unsigned long)p_stNTTO - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stOnlyFrames = %d\n", (unsigned long)p_stOnlyFrames - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stChannels = %d\n", (unsigned long)p_stChannels - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stFrames = %d\n", (unsigned long)p_stFrames - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stFramesKF = %d\n", (unsigned long)p_stFramesKF - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stKeyFrames = %d\n", (unsigned long)p_stKeyFrames - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stEvents = %d\n", (unsigned long)p_stEvents - (unsigned long)p_stA3dGENERAL);
osSyncPrintf(" p_stMorphData = %d\n", (unsigned long)p_stMorphData - (unsigned long)p_stA3dGENERAL);
ASM_BREAK;
}
#endif /* ANIM_DEBUG */
#endif
}
/* ***********************************************************************************/
#undef A3X_LOAD_C

View File

@@ -0,0 +1,464 @@
/* ***********************************************************************************/
/* * "a3x_mem.c" **/
/* * Written by : S<>bastien Rubens **/
/* * Tabulations : 4 char **/
/* ***********************************************************************************/
#define A3X_MEM_C
/* ***********************************************************************************/
/* Included files*/
#include <stdlib.h>
#include "PlayAnim/Interpol/specif/a3x_pref.h"
/*#define LST2_StaticIsOptimised*/
#include "TOOLSCPA.h"
#include "cpa_std.h"
#include "STRUCTUR/Anim_s.h"
#include "STRUCTUR/ErrGame.h"
#include "PlayAnim/Interpol/a3x_glob.h"
#include "PlayAnim/Interpol/a3x_cach.h"
#include "PlayAnim/Interpol/a3x_int.h"
#include "PlayAnim/Interpol/a3x_mem.h"
#include "zemem.h"
#ifndef U64
#include "SNA\snaglob.h"
#endif
#ifndef RETAIL
#include "STRUCTUR/GameScpt.h"
#endif
/* ***********************************************************************************/
/* Defines*/
/*#ifndef A3X_CacheIsUsed*/
/*#ifndef U64
#define MaxInTabA3dGENERAL 1500
#define MaxInTabVertexes 60000
#define MaxInTabQuaternions 60000
#define MaxInTabHierarchies 5000
#define MaxInTabNTTO 10000
#define MaxInTabOnlyFrames 30000
#define MaxInTabChannels 30000
#define MaxInTabFrames 40000
#define MaxInTabFramesKF 140000
#define MaxInTabKeyFrames 65500
#define MaxInTabEvents 5000
#define MaxInTabMorphData 30000
#define MaxInTabCuttedAnim 3000
#define MaxInTabHandleElement3d 1000
#else*/
#ifdef U64
#define MaxInTabA3dGENERAL 1500
#define MaxInTabVertexes 30000
#define MaxInTabQuaternions 20000
#define MaxInTabHierarchies 5000
#define MaxInTabNTTO 10000
#define MaxInTabOnlyFrames 15000
#define MaxInTabChannels 10000
#define MaxInTabFrames 33000
#define MaxInTabFramesKF 80000
#define MaxInTabKeyFrames 30000
#define MaxInTabEvents 5000
#define MaxInTabMorphData 5000
#define MaxInTabCuttedAnim 3000
#define MaxInTabHandleElement3d 1000
#endif /*U64*/
/*#else
#define MaxInTabA3dGENERAL 1
#define MaxInTabVertexes 1
#define MaxInTabQuaternions 1
#define MaxInTabHierarchies 1
#define MaxInTabNTTO 1
#define MaxInTabOnlyFrames 1
#define MaxInTabChannels 1
#define MaxInTabFrames 1
#define MaxInTabFramesKF 1
#define MaxInTabKeyFrames 1
#define MaxInTabEvents 1
#define MaxInTabMorphData 1
#define MaxInTabCuttedAnim 1
#define MaxInTabHandleElement3d 1
// Output cache
#define uwMaxInTabFrame3d 100
#define uwMaxInTabElement3d 1000
#endif */
/* ***********************************************************************************/
/* Globals datas*/
tdstStackInfos tdstStacks[eStackNbMax]=
{
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 }
};
#ifdef A3X_StaticTables
tdstA3dGENERAL ax_stA3dGENERAL [MaxInTabA3dGENERAL];
tdxVector3 axa3_xVectors [MaxInTabVertexes];
tdxSShortQuater4 axa4_xQuaternions [MaxInTabQuaternions];
tdstHierarchy ax_stHierarchies [MaxInTabHierarchies];
tdstNTTO ax_stNTTO [MaxInTabNTTO];
tdstOnlyFrame ax_stOnlyFrames [MaxInTabOnlyFrames];
tdstChannel ax_stChannels [MaxInTabChannels];
tdstFrame ax_stFrames [MaxInTabFrames];
tdstFrameKF ax_stFramesKF [MaxInTabFramesKF];
tdstKeyFrame ax_stKeyFrames [MaxInTabKeyFrames];
tdstEvent ax_stEvents [MaxInTabEvents];
tdstMorphData ax_stMorphData [MaxInTabMorphData];
tdstCuttedAnim ax_stCuttedAnim [MaxInTabCuttedAnim];
#endif
tdstA3dGENERAL *p_stA3dGENERAL;
tdxVector3 *p_a3_xVectors;
tdxSShortQuater4 *p_a4_xQuaternions;
tdstHierarchy *p_stHierarchies;
tdstNTTO *p_stNTTO;
tdstOnlyFrame *p_stOnlyFrames;
tdstChannel *p_stChannels;
tdstFrame *p_stFrames;
tdstFrameKF *p_stFramesKF;
tdstKeyFrame *p_stKeyFrames;
tdstEvent *p_stEvents;
tdstMorphData *p_stMorphData; /*AR9803*/
tdstCuttedAnim *p_stCuttedAnim;
/* ***********************************************************************************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC 07/06/99 */
unsigned long fn_ul_GetStackAlloc( unsigned short _uwNumStack )
{
return (tdstStacks[_uwNumStack].ulPosAlloc);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC 07/06/99 */
/* ***********************************************************************************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
unsigned long fn_ul_GetStackPos( unsigned short _uwNumStack )
{
return (tdstStacks[_uwNumStack].ulStackPos);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/* ***********************************************************************************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_v_AllocateOnStack( unsigned short _uwNumStack,
unsigned short _uwWantedSize )
{
#ifndef A3X_CacheIsUsed /*AR9807*/
if ((tdstStacks[_uwNumStack].ulStackPos+_uwWantedSize)>tdstStacks[_uwNumStack].ulMaxPos) {
char szMessage[50];
sprintf(szMessage,"Stack %d exceed maximum elements(%d), change it in Game.dsc",_uwNumStack,tdstStacks[_uwNumStack].ulMaxPos);
Erm_M_UpdateLastError( Game, C_ucErmDefaultChannel, E_uwGameErrorWhileLoadingAnimation,
C_lErmNoDebugData,C_ucErmOpenInfoWindow, C_ucAllowStopForDebug,szMessage);
}
#endif
tdstStacks[_uwNumStack].ulStackPos+= _uwWantedSize;
tdstStacks[_uwNumStack].ulPosAlloc= tdstStacks[_uwNumStack].ulStackPos - _uwWantedSize;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/* ***********************************************************************************/
unsigned long fn_ul_AllocateOnStack( unsigned short _uwNumStack,
unsigned short _uwWantedSize )
{
#ifndef A3X_CacheIsUsed /*AR9807*/
#ifndef U64
if ((tdstStacks[_uwNumStack].ulStackPos+_uwWantedSize)>tdstStacks[_uwNumStack].ulMaxPos) {
char szMessage[50];
sprintf(szMessage,"Stack %d exceed maximum elements(%d), change it in Game.dsc",_uwNumStack,tdstStacks[_uwNumStack].ulMaxPos);
Erm_M_UpdateLastError( Game, C_ucErmDefaultChannel, E_uwGameErrorWhileLoadingAnimation,
C_lErmNoDebugData,C_ucErmOpenInfoWindow, C_ucAllowStopForDebug,szMessage);
}
#else
if((tdstStacks[_uwNumStack].ulStackPos+_uwWantedSize)>=tdstStacks[_uwNumStack].ulMaxPos)
osSyncPrintf("No enough place in stack %d (%d)\n",_uwNumStack,_uwWantedSize);
#endif
#endif
tdstStacks[_uwNumStack].ulStackPos+= _uwWantedSize;
tdstStacks[_uwNumStack].ulPosAlloc= tdstStacks[_uwNumStack].ulStackPos - _uwWantedSize;
return tdstStacks[_uwNumStack].ulPosAlloc;
}
/* ***********************************************************************************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_v_DeAllocateOnStack( unsigned short _uwNumStack,
unsigned short _uwSize )
{
tdstStacks[_uwNumStack].ulStackPos-= _uwSize;
assert(tdstStacks[_uwNumStack].ulStackPos >= 0);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/* ************************************************** fn_v_UnclearPreviousLoadedAnims*/
/* Allow to keep the N First Anims when clear*/
/* Must be call after loading the N anims*/
/* 03/07/98 Carlos Torres*/
/* ***********************************************************************************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_v_UnclearPreviousLoadedAnims( void ) {
unsigned short uwCnt;
for ( uwCnt=0 ; uwCnt<eStackNbMax ; uwCnt++ )
tdstStacks[uwCnt].ulResetPos=tdstStacks[uwCnt].ulStackPos;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/* ************************************************************ fn_v_ClearLoadedAnims*/
/* Clear Loaded Anims depending on parameter ucClearAll*/
/* False : Until the position set by fn_v_UnclearPreviousLoadedAnims*/
/* True : ALL anims*/
/* 03/07/98 Carlos Torres*/
/* ***********************************************************************************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_v_ClearLoadedAnims(unsigned char ucClearAll) {
unsigned short uwCnt;
for ( uwCnt=0 ; uwCnt<eStackNbMax ; uwCnt++ ) {
if (ucClearAll)
tdstStacks[uwCnt].ulResetPos=0;
M_v_ResetOneStack(uwCnt);
}
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/* **************************************************************** fn_v_InitInterpol*/
/* Make allocation and init structure for anim management*/
/* Must be called only once*/
/**/
/* 03/07/98 Carlos Torres*/
/* 17/07/98 : Erase table of Frame and table of Element3d*/
/* ***********************************************************************************/
void fn_v_InitInterpol( void )
{
#ifdef U64
#ifndef FORCE_REAL_TIME_LOAD
fn_vInitROMLoad(); /* To initialise the animation loading system*/
#endif
#endif /*U64*/
#ifndef FORCE_REAL_TIME_LOAD
if(!g_bRealTimeAnimationLoad)
{
#ifdef A3X_StaticTables
p_stA3dGENERAL= ax_stA3dGENERAL;
p_a3_xVectors= axa3_xVectors;
p_a4_xQuaternions= axa4_xQuaternions;
p_stHierarchies= ax_stHierarchies;
p_stNTTO= ax_stNTTO;
p_stOnlyFrames= ax_stOnlyFrames;
p_stChannels= ax_stChannels;
p_stFrames= ax_stFrames;
p_stFramesKF= ax_stFramesKF;
p_stKeyFrames= ax_stKeyFrames;
p_stEvents= ax_stEvents;
p_stMorphData= ax_stMorphData;
p_stCuttedAnim= ax_stCuttedAnim;
#else
#ifndef A3X_N64
if (SNA_fn_ucGetLoadType()!=SNA_LOAD_SNAPSHOT)
#endif
{
unsigned char ucOldACPModeMalloc;
ucOldACPModeMalloc = GEO_M_ucGetMemMallocMode();
GEO_xSelectMemoryChannel(ACP_FixMemoryChannel);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeA3dGENERAL , 0 );
#ifndef U64
/* check if all stack size is set*/
{
unsigned short uwCnt;
for ( uwCnt=0 ; uwCnt<eStackNbMax ; uwCnt++ ) {
if (!tdstStacks[uwCnt].ulMaxPos) {
char szMessage[50];
sprintf(szMessage,"To Load Animation All stacks must be sized, correct Game.dsc for stack %d",uwCnt);
Erm_M_UpdateLastError( Game, C_ucErmDefaultChannel, E_uwGameErrorWhileLoadingAnimation,
C_lErmNoDebugData,C_ucErmOpenInfoWindow, C_ucAllowStopForDebug,szMessage);
}
}
}
GEO_M_CPAMalloc(p_stA3dGENERAL, tdstA3dGENERAL * , tdstStacks[eStackA3dGENERAL].ulMaxPos * sizeof(tdstA3dGENERAL) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeVectors , 0 );
GEO_M_CPAMalloc(p_a3_xVectors, tdxVector3 * , tdstStacks[eStackVertexes].ulMaxPos * sizeof(tdxVector3) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeQuaternions , 0 );
GEO_M_CPAMalloc(p_a4_xQuaternions, tdxSShortQuater4 * , tdstStacks[eStackQuaternions].ulMaxPos * sizeof(tdxSShortQuater4) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeHierarchies , 0 );
GEO_M_CPAMalloc(p_stHierarchies, tdstHierarchy * , tdstStacks[eStackHierarchies].ulMaxPos * sizeof(tdstHierarchy) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeNTTO , 0 );
GEO_M_CPAMalloc(p_stNTTO, tdstNTTO * , tdstStacks[eStackNTTO].ulMaxPos * sizeof(tdstNTTO) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeOnlyFrames , 0 );
GEO_M_CPAMalloc(p_stOnlyFrames, tdstOnlyFrame * , tdstStacks[eStackOnlyFrames].ulMaxPos * sizeof(tdstOnlyFrame) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeChannels , 0 );
GEO_M_CPAMalloc(p_stChannels, tdstChannel * , tdstStacks[eStackChannels].ulMaxPos * sizeof(tdstChannel) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeFrames , 0 );
GEO_M_CPAMalloc(p_stFrames, tdstFrame * , tdstStacks[eStackFrames].ulMaxPos * sizeof(tdstFrame) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeFramesKF , 0 );
GEO_M_CPAMalloc(p_stFramesKF, tdstFrameKF * , tdstStacks[eStackFramesKF].ulMaxPos * sizeof(tdstFrameKF) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeKeyFrames , 0 );
GEO_M_CPAMalloc(p_stKeyFrames, tdstKeyFrame * , tdstStacks[eStackKeyFrames].ulMaxPos * sizeof(tdstKeyFrame) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeEvents , 0 );
GEO_M_CPAMalloc(p_stEvents, tdstEvent * , tdstStacks[eStackEvents].ulMaxPos * sizeof(tdstEvent) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeMorphData , 0 );
GEO_M_CPAMalloc(p_stMorphData, tdstMorphData * , tdstStacks[eStackMorphData].ulMaxPos * sizeof(tdstMorphData) , E_uwGEONotEnoughtMemory);
#else /* U64 */
GEO_M_CPAMalloc(p_stA3dGENERAL, tdstA3dGENERAL * , MaxInTabA3dGENERAL * sizeof(tdstA3dGENERAL) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeVectors , 0 );
GEO_M_CPAMalloc(p_a3_xVectors, tdxVector3 * , MaxInTabVertexes * sizeof(tdxVector3) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeQuaternions , 0 );
GEO_M_CPAMalloc(p_a4_xQuaternions, tdxSShortQuater4 * , MaxInTabQuaternions * sizeof(tdxSShortQuater4) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeHierarchies , 0 );
GEO_M_CPAMalloc(p_stHierarchies, tdstHierarchy * , MaxInTabHierarchies * sizeof(tdstHierarchy) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeNTTO , 0 );
GEO_M_CPAMalloc(p_stNTTO, tdstNTTO * , MaxInTabNTTO * sizeof(tdstNTTO) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeOnlyFrames , 0 );
GEO_M_CPAMalloc(p_stOnlyFrames, tdstOnlyFrame * , MaxInTabOnlyFrames * sizeof(tdstOnlyFrame) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeChannels , 0 );
GEO_M_CPAMalloc(p_stChannels, tdstChannel * , MaxInTabChannels * sizeof(tdstChannel) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeFrames , 0 );
GEO_M_CPAMalloc(p_stFrames, tdstFrame * , MaxInTabFrames * sizeof(tdstFrame) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeFramesKF , 0 );
GEO_M_CPAMalloc(p_stFramesKF, tdstFrameKF * , MaxInTabFramesKF * sizeof(tdstFrameKF) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeKeyFrames , 0 );
GEO_M_CPAMalloc(p_stKeyFrames, tdstKeyFrame * , MaxInTabKeyFrames * sizeof(tdstKeyFrame) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeEvents , 0 );
GEO_M_CPAMalloc(p_stEvents, tdstEvent * , MaxInTabEvents * sizeof(tdstEvent) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeMorphData , 0 );
GEO_M_CPAMalloc(p_stMorphData, tdstMorphData * , MaxInTabMorphData * sizeof(tdstMorphData) , E_uwGEONotEnoughtMemory);
MMG_fn_vAddMemoryInfo( MMG_C_lTypeInterpol , MMG_C_lSubTypeSpeedCuttedAnim, 0 );
GEO_M_CPAMalloc(p_stCuttedAnim, tdstCuttedAnim * , MaxInTabCuttedAnim * sizeof(tdstCuttedAnim) , E_uwGEONotEnoughtMemory);
#endif /* U64 */
GEO_xSelectMemoryChannel(ucOldACPModeMalloc);
}
#endif /*A3X_StaticTables*/
}
#endif
#ifdef U64
#ifndef FORCE_REAL_TIME_LOAD
else
#endif
fn_v_InitCache();
#endif
fn_v_InitSinTab();
}
/* ***************************************************************** fn_vSetStackSize*/
/* Set the stack size */
/* Must be called only once for all stack to configure it*/
/**/
/* 27/10/98 Carlos Torres*/
/* ***********************************************************************************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vSetStackSize(unsigned short uwNumStack,unsigned long ulSize) {
/* change only if is not previously set*/
if (!tdstStacks[uwNumStack].ulMaxPos)
tdstStacks[uwNumStack].ulMaxPos = ulSize;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#if !defined(RETAIL) && !defined(U64)
/* ***************************************************************** fn_vAnimStackLog*/
/* Make a log of Memory used for each stack in an open file*/
/**/
/* 11/12/98 Carlos Torres*/
/* ***********************************************************************************/
void fn_vAnimStackLog(FILE * fLogFile) {
unsigned short uwCnt;
unsigned long ulMemFix=0,ulMemGlob=0;
struct {
char szName[16];
unsigned long ulSize;
} stStackData[eStackNbMax] = {
C_Entry_A3dGeneral,sizeof(tdstA3dGENERAL),
C_Entry_Vertexes,sizeof(tdxVector3),
C_Entry_Quaternions,sizeof(tdxSShortQuater4),
C_Entry_Hierarchies,sizeof(tdstHierarchy),
C_Entry_NTTO,sizeof(tdstNTTO),
C_Entry_OnlyFrames,sizeof(tdstOnlyFrame),
C_Entry_Channels,sizeof(tdstChannel),
C_Entry_Frames,sizeof(tdstFrame),
C_Entry_FramesKF,sizeof(tdstFrameKF),
C_Entry_KeyFrames,sizeof(tdstKeyFrame),
C_Entry_Events,sizeof(tdstEvent),
C_Entry_MorphData,sizeof(tdstMorphData)
};
if (!fLogFile)
return;
fprintf (fLogFile,"\tStack Name\tFix Nb: FixMem \tLvl Nb: Lvl Mem \tTot Nb( Max. ): Tot Mem \n");
/* log for each stack*/
for (uwCnt=0 ; uwCnt<eStackNbMax ; uwCnt++) {
fprintf (fLogFile,"\t%10s\t%6d:%8do\t%6d:%8do\t%6d(%6d):%8do\n",
stStackData[uwCnt].szName,
tdstStacks[uwCnt].ulResetPos,tdstStacks[uwCnt].ulResetPos*stStackData[uwCnt].ulSize,
tdstStacks[uwCnt].ulStackPos-tdstStacks[uwCnt].ulResetPos,
(tdstStacks[uwCnt].ulStackPos-tdstStacks[uwCnt].ulResetPos)*stStackData[uwCnt].ulSize,
tdstStacks[uwCnt].ulStackPos,
tdstStacks[uwCnt].ulMaxPos,
tdstStacks[uwCnt].ulStackPos*stStackData[uwCnt].ulSize);
ulMemFix += tdstStacks[uwCnt].ulResetPos*stStackData[uwCnt].ulSize;
ulMemGlob += tdstStacks[uwCnt].ulStackPos*stStackData[uwCnt].ulSize;
}
/* Total*/
fprintf(fLogFile,"\t---------------------------------------------------------------------------------\n");
fprintf (fLogFile,"\tTotal \t %8do\t %8do\t %8do\n\n",
ulMemFix,ulMemGlob-ulMemFix,ulMemGlob);
}
#endif /* RETAIL */
/* ***********************************************************************************/
#undef A3X_MEM_C

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,706 @@
/*=========================================================================
* PlayEvrs.cpp : This module contain all functions used to play events
* This is a part of the Game project.
*
* Version 1.0
* Creation date 6/11/96
* Revision date
*
* That file needs to be compatible for all platforms.
*
* (c) Ubi Studios 1996
*=======================================================================*/
#if defined (WIN32)
#include <stdio.h>
#endif /* WIN32 */
#include "ToolsCPA.h"
/* SOUND 14/02/97*/
#include "SND.h"
/* SOUND fin*/
#include "Options/Options.h"
#include "Macros.h"
#include "Actions/AllActs.h"
#include "Structur/Anim_s.h"
#include "Structur/MemGame.h"
#include "Structur/Objects.h"
#include "Structur/EngMode.h" /* For interpolated animations*/
#include "Structur/State.h"
#include "PlayAnim/PlayEvts.h"
/* JO 01/07/97*/
#include "PlayAnim/PlayAnim.h"
#include "ZeMem.h"
#include "Micros.h"
#include "ia_dnm.h"
#include "objinit.h"
#include "Chanlist.h"
/* For interpolated animations*/
#include "PlayAnim/Interpol/a3x_intn.h"
/*-----------------------------------------------------------------------------
* Description : init animation events for a character
* this should be called when the anim of a character did change
* Aim : init the array of activation (there is one activation value for each event
* of the anim. The event is played when the activation is 0
*-----------------------------------------------------------------------------
* Input : object
* Output : void
*-----------------------------------------------------------------------------
* Creation date : 16/10/96 Author : blef
*---------------------------------------------------------------------------*/
void fn_vInitAllEvents(HIE_tdxHandleToSuperObject p_stSuperObject,unsigned short uwFirstFrame)
{
MS_tdxHandleTo3dData h_3dData;
tdxHandleToState h_State;
tdstAnim3d * p_stAnim;
tdstEvent * p_stEvent;
unsigned char i;
/* get the anim*/
h_3dData = M_GetMSHandle( p_stSuperObject, 3dData );
h_State = fn_h3dDataGetCurrentState(h_3dData);
if ( h_State == NULL ) return; /* not a good object (camera) ...*/
p_stAnim = fn_p_stGetAnimInState(h_State);
/* get the events array*/
p_stEvent= fn_p_GetEventsAddress( p_stAnim, uwFirstFrame,fn_h3dDataGetCurrentObjectsTable(h_3dData) );
/* init all events*/
if ( p_stEvent != NULL ) {
/* allocate array of event activation*/
fn_v3dDataAllocateEventActivation(h_3dData,p_stAnim->ucNumberOfEvents);
/* do not start a the first framE*/
if (uwFirstFrame) {
/* search next Event to play*/
for (i = 0;(i < p_stAnim->ucNumberOfEvents) && (p_stEvent[i].uwFrameNumber < uwFirstFrame);i++);
fn_v3dDataSetNextEvent(h_3dData,i);
}
/* start at first frame*/
else {
if ( fn_scGetSpeedInState(h_State) > 0 )
fn_v3dDataSetNextEvent(h_3dData,0);
else
fn_v3dDataSetNextEvent(h_3dData,(unsigned char)(p_stAnim->ucNumberOfEvents - 1));
}
/* fill rest of array of activation*/
for (i=0; i < p_stAnim->ucNumberOfEvents;i++,p_stEvent++)
fn_v3dDataSetEventActivationByIndex(h_3dData,i,GAM_fn_ucGetFirstCallOfEvent(p_stEvent));
}
}
/*-----------------------------------------------------------------------------
* Description : DesInit animation events for a character
* Should be called when the anim is about to change
* Do not call if the next anim is the same as the current one
* If the next anim normally follows the current one, call with
* bStopEvents set to FALSE.
* If the next anim interrupt the current one, call with bStopEvents
* set to TRUE.
* Never Play are played only when bStopEvents & if are not present
* in the next state
*-----------------------------------------------------------------------------
* Input : object
the future state
* bStopEvents must be set to TRUE if we want 'NeverPlay' stop events
* to be played
* Output : void
*-----------------------------------------------------------------------------
* Creation date : 16/10/96 Author : blef
*-----------------------------------------------------------------------------
* Modif 08/10/98 : add next in parameter and check for never play in the next state - Carlos Torres
*-----------------------------------------------------------------------------
* Modif 25/01/99 : Fix for real time load and short cache - AR
*---------------------------------------------------------------------------*/
void fn_vDesInitAllEvents(HIE_tdxHandleToSuperObject p_stSuperObject,tdxHandleToState hNextState,BOOL bStopEvents)
{
MS_tdxHandleTo3dData h_3dData;
tdxHandleToState h_State;
tdstAnim3d * p_stAnim;
tdstEvent * p_stEvent;
int i,j;
unsigned short uwFrameNumber;
/* MR1006*/
/* fn_vPlayEventsSinceLastOneNoLoop(p_stSuperObject);*/
/* get the anim*/
h_3dData = M_GetMSHandle( p_stSuperObject, 3dData );
h_State = fn_h3dDataGetCurrentState(h_3dData);
if ( h_State == NULL )
return; /* not a good object (camera) ...*/
p_stAnim = fn_p_stGetAnimInState(h_State);
if ((p_stAnim)&&(p_stAnim->ucNumberOfEvents!=0))
{
uwFrameNumber=h_3dData->uwCurrentFrame;
if ( uwFrameNumber >= p_stAnim -> uwNumberOfFrames )
uwFrameNumber = ( unsigned short ) ( p_stAnim -> uwNumberOfFrames - 1 );
/* get the events array*/
p_stEvent= fn_p_GetEventsAddress( p_stAnim,uwFrameNumber,fn_h3dDataGetCurrentObjectsTable(h_3dData) );
/* des-init all events*/
if ( p_stEvent != NULL )
{
if ( bStopEvents )
{
tdstAnim3d * p_stNextAnim = NULL;
tdstEvent * p_stNextEvent = NULL;
tdstEvent * p_stNextEvent2;
/* get next event table*/
if (hNextState)
{
p_stNextAnim = fn_p_stGetAnimInState(hNextState);
if ((p_stNextAnim)&&(p_stNextAnim->ucNumberOfEvents!=0))
{
p_stNextEvent = fn_p_GetEventsAddress(p_stNextAnim,0,fn_h3dDataGetCurrentObjectsTable(h_3dData));
/* Store events into a temporary array*/
if(p_stNextEvent!=NULL)
{
p_stNextEvent2 = (tdstEvent*)TMP_M_p_Malloc(sizeof(tdstEvent) * p_stNextAnim->ucNumberOfEvents);
memcpy(p_stNextEvent2,p_stNextEvent,sizeof(tdstEvent) * p_stNextAnim->ucNumberOfEvents);
p_stNextEvent=p_stNextEvent2;
/* Reinit Event pointer (load it in cache if n<>cessary)*/
p_stEvent = fn_p_GetEventsAddress(p_stAnim,uwFrameNumber,fn_h3dDataGetCurrentObjectsTable(h_3dData));
/* play 'NeverPlay' stop events*/
for (i = 0; i < p_stAnim->ucNumberOfEvents;i++,p_stEvent++)
{
int bNeverPlayFound = FALSE;
if (GAM_fn_ucGetFirstCallOfEvent(p_stEvent) == C_ucNeverPlay )
{
/* search event in next anim */
/* reinit NextEvent*/
p_stNextEvent=p_stNextEvent2;
for (j = 0;j < p_stNextAnim->ucNumberOfEvents;j++,p_stNextEvent++)
{
/* found a never play*/
if (GAM_fn_ucGetFirstCallOfEvent(p_stNextEvent) == C_ucNeverPlay)
{
/* check if is the same never play*/
if (GAM_fn_p_xGetEventOfEvent(p_stEvent) == GAM_fn_p_xGetEventOfEvent(p_stNextEvent))
{
bNeverPlayFound = TRUE;
break;
}
}
/* no more never play*/
else
break;
}
/* this is a 'NeverPlay' stop event, play it*/
if (!bNeverPlayFound)
fn_vPlayEvent(p_stEvent,C_ucStopEvent,p_stSuperObject);
}
/* all stop event are in the beginnig of the array (ucFrameNumber == 0)*/
/* so if we find a non 'NeverPlay' event, we can stop*/
else
break;
}
TMP_M_Free(p_stNextEvent2);
}
else
{
/* no event into the next anim -> play all neverplay events*/
/* Reinit Event pointer (load it in cache if n<>cessary)*/
p_stEvent = fn_p_GetEventsAddress(p_stAnim,0,fn_h3dDataGetCurrentObjectsTable(h_3dData));
/* play 'NeverPlay' stop events*/
for (i = 0; i < p_stAnim->ucNumberOfEvents;i++,p_stEvent++)
{
if (GAM_fn_ucGetFirstCallOfEvent(p_stEvent) == C_ucNeverPlay )
fn_vPlayEvent(p_stEvent,C_ucStopEvent,p_stSuperObject);
}
}
}
else
{
/* no next anim -> play all neverplay events*/
/* Reinit Event pointer (load it in cache if n<>cessary)*/
p_stEvent = fn_p_GetEventsAddress(p_stAnim,0,fn_h3dDataGetCurrentObjectsTable(h_3dData));
/* play 'NeverPlay' stop events*/
for (i = 0; i < p_stAnim->ucNumberOfEvents;i++,p_stEvent++)
{
if (GAM_fn_ucGetFirstCallOfEvent(p_stEvent) == C_ucNeverPlay )
fn_vPlayEvent(p_stEvent,C_ucStopEvent,p_stSuperObject);
}
}
}
}
}
}
fn_v3dDataSetNextEvent(h_3dData,0);
/* free array of event activation*/
fn_v3dDataFreeEventActivation(h_3dData);
}
/*-----------------------------------------------------------------------------
* Description : play animation events for a character since the last played
* call this function if the anim did not restart.
* If the anim is about to loop, call fn_vPlayLastEventsBeforeRestart
* for the current anim, then call this function when new current frame
* has been set.
*-----------------------------------------------------------------------------
* Input : object
* Output : void
*-----------------------------------------------------------------------------
* Creation date : 16/10/96 Author : blef
*---------------------------------------------------------------------------*/
void fn_vPlayEventsSinceLastOneNoLoop( HIE_tdxHandleToSuperObject p_stSuperObject )
{
MS_tdxHandleTo3dData h_3dData;
tdxHandleToState h_State;
tdstAnim3d * p_stAnim;
tdstEvent * p_stEvent;
/* get the anim*/
h_3dData = M_GetMSHandle( p_stSuperObject, 3dData );
h_State = fn_h3dDataGetCurrentState(h_3dData);
if ( h_State == NULL ) return; /* not a good object (camera) ...*/
p_stAnim = fn_p_stGetAnimInState(h_State);
/* get the events array*/
p_stEvent= fn_p_GetEventsAddress( p_stAnim, h_3dData->uwCurrentFrame,fn_h3dDataGetCurrentObjectsTable(h_3dData) );
if ( p_stEvent != NULL )
{
if ( fn_scGetSpeedInState(h_State) > 0 )
{
/* play events from past frames*/
while ( fn_uc3dDataGetNextEvent(h_3dData) !=p_stAnim->ucNumberOfEvents && p_stEvent[ fn_uc3dDataGetNextEvent(h_3dData) ].uwFrameNumber <= fn_uw3dDataGetCurrentFrame(h_3dData))
{
/* is it time to play event ?*/
if ( fn_uc3dDataGetEventActivationByIndex(h_3dData,fn_uc3dDataGetNextEvent(h_3dData)) == 0 )
{
/* play the event*/
fn_vPlayEvent( &p_stEvent[ fn_uc3dDataGetNextEvent(h_3dData) ], C_ucNormal ,p_stSuperObject);
/* update activation*/
fn_v3dDataSetEventActivationByIndex(h_3dData,fn_uc3dDataGetNextEvent(h_3dData),GAM_fn_ucGetPeriodOfEvent(&(p_stEvent[ fn_uc3dDataGetNextEvent(h_3dData) ])));
}
else
{
/* may be next loop : update activation if not NevrPlay*/
if ( fn_uc3dDataGetEventActivationByIndex(h_3dData,fn_uc3dDataGetNextEvent(h_3dData)) != C_ucNeverPlay )
fn_v3dDataAddEventActivationByIndex(h_3dData,fn_uc3dDataGetNextEvent(h_3dData),-1);
}
/* next event*/
fn_v3dDataAddNextEvent(h_3dData,1);
}
}
/* reverse play animation*/
else /* SpeedAnim < 0*/
{
/* play events from past frames*/
while ( fn_uc3dDataGetNextEvent(h_3dData) != 255 && p_stEvent[ fn_uc3dDataGetNextEvent(h_3dData) ].uwFrameNumber >= fn_uw3dDataGetCurrentFrame(h_3dData))
{
/* is it time to play event ?*/
if ( fn_uc3dDataGetEventActivationByIndex(h_3dData,fn_uc3dDataGetNextEvent(h_3dData)) == 0 )
{
fn_vPlayEvent( &p_stEvent[ fn_uc3dDataGetNextEvent(h_3dData) ], C_ucReverse ,p_stSuperObject);
fn_v3dDataSetEventActivationByIndex(h_3dData,fn_uc3dDataGetNextEvent(h_3dData),GAM_fn_ucGetPeriodOfEvent(&(p_stEvent[ fn_uc3dDataGetNextEvent(h_3dData) ])));
}
else
{
/* may be next loop*/
if ( fn_uc3dDataGetEventActivationByIndex(h_3dData,fn_uc3dDataGetNextEvent(h_3dData) ) != C_ucNeverPlay )
fn_v3dDataAddEventActivationByIndex(h_3dData,fn_uc3dDataGetNextEvent(h_3dData),-1);
}
fn_v3dDataAddNextEvent(h_3dData,-1);
/* we do not loop (unsigned values)*/
/* if last event has been treated, next event will be 255 and will stop the while*/
}
}
}
}
/*-----------------------------------------------------------------------------
* Description : play all remaining animation events for a character
* since the last played.
* Call this function if the anim is about to change
* then after changing anim (or restarting anim) and setting the
* current frame, call fn_vPlayEventsSinceLastOneNoLoop
*-----------------------------------------------------------------------------
* Input : object
* Number of complete loops
* Output : void
*-----------------------------------------------------------------------------
* Creation date : 16/10/96 Author : blef
*---------------------------------------------------------------------------*/
void fn_vPlayLastEventsBeforeRestart( HIE_tdxHandleToSuperObject p_stSuperObject )
{
MS_tdxHandleTo3dData h_3dData;
tdxHandleToState h_State;
tdstAnim3d * p_stAnim;
tdstEvent * p_stEvent;
/*XB980504*/
/*unsigned*/ char i;
/*End XB*/
/* get the anim*/
h_3dData = M_GetMSHandle( p_stSuperObject, 3dData );
h_State = fn_h3dDataGetCurrentState(h_3dData);
if ( h_State == NULL ) return; /* not a good object (camera) ...*/
p_stAnim = fn_p_stGetAnimInState(h_State);
/* get the events array*/
p_stEvent= fn_p_GetEventsAddress( p_stAnim, h_3dData->uwCurrentFrame-1,fn_h3dDataGetCurrentObjectsTable(h_3dData) );
/*SEB p_stEvent = p_stAnim->d_stAnimEvent;*/
if ( p_stEvent != NULL )
{
if ( fn_scGetSpeedInState(h_State) > 0 )
{
/* play last frames events*/
for ( i = fn_uc3dDataGetNextEvent(h_3dData); i < p_stAnim->ucNumberOfEvents; i++ )
{
/* is it time to play event ?*/
if ( fn_uc3dDataGetEventActivationByIndex(h_3dData,i) == 0 )
{
fn_vPlayEvent( &p_stEvent[ i ], C_ucNormal ,p_stSuperObject);
fn_v3dDataSetEventActivationByIndex(h_3dData, i, GAM_fn_ucGetPeriodOfEvent(&(p_stEvent[ i ])));
}
else
{
/* may be next loop*/
if ( fn_uc3dDataGetEventActivationByIndex(h_3dData,i) != C_ucNeverPlay )
fn_v3dDataAddEventActivationByIndex(h_3dData, i , -1);
}
}
/* set next event if the animation in case the animation is looping*/
fn_v3dDataSetNextEvent(h_3dData,0);
}
else /* SpeedAnim < 0*/
{
/* play 'first' frames events*/
/* this test is here if the last event has been treated (unsigned values)*/
if ( fn_uc3dDataGetNextEvent(h_3dData) != 255 )
{
for ( i = fn_uc3dDataGetNextEvent(h_3dData); i >= 0; i-- )
{
/* is it time to play event ?*/
if ( fn_uc3dDataGetEventActivationByIndex(h_3dData,i) == 0 )
{
fn_vPlayEvent( &p_stEvent[ i ], C_ucReverse ,p_stSuperObject);
fn_v3dDataSetEventActivationByIndex(h_3dData, i, GAM_fn_ucGetPeriodOfEvent(&(p_stEvent[ i ])));
}
else
{
/* may be next loop*/
if ( fn_uc3dDataGetEventActivationByIndex(h_3dData,i) != C_ucNeverPlay )
fn_v3dDataAddEventActivationByIndex(h_3dData, i , -1);
}
}
}
/* set next event if the animation in case the animation is looping*/
fn_v3dDataSetNextEvent(h_3dData,(unsigned char)(p_stAnim->ucNumberOfEvents - 1));
}
}
}
/*-----------------------------------------------------------------------------
* Description : play one animation event
*-----------------------------------------------------------------------------
* Input : event to be played
* mode ( normal or reverse )
* Output : void
*-----------------------------------------------------------------------------
* Creation date : 16/10/96 Author : blef
*---------------------------------------------------------------------------*/
void fn_vPlayEvent( tdstEvent * p_stEvent, unsigned char ucMode ,HIE_tdxHandleToSuperObject p_stSuperObject)
{
SND_tduRefEvt SoundEvt;
/* switch( p_stEvent->ucTypeOfEvent )
{
case C_ucSOUND_EVENT :
break;
case C_ucACTION_EVENT :
break;
case C_ucGENERATE_EVENT :
break;
default :
break;
}*/
/* test events : uses TRACE*/
#if defined(_DEBUG) && defined(WIN32) && defined(__cplusplus)
char szType[25];
char szMode[25];
#endif /* _DEBUG && WIN32 && __cplusplus */
/*long lTmpTypeOfMechEvt;*/
/* LRM_eKindOfRequest eMechEvent;*/
switch( GAM_fn_ucGetTypeOfEvent(p_stEvent) )
{
case C_ucSOUND_EVENT :
SoundEvt.pstPtr=(SND_tdstBlockEvent*)GAM_fn_p_xGetEventOfEvent(p_stEvent);
SND_fn_lSendRequestSound((long)p_stSuperObject,g_lSoundObjectTypeAnim,SoundEvt,0,NULL);
#if defined(_DEBUG) && defined(WIN32) && defined(__cplusplus)
strcpy( szType, "SoundEvent");
#endif /* _DEBUG && WIN32 && __cplusplus */
break;
/* MR2803: Add a mechanics event to the LRM list*/
/* case C_ucMECHANIC_EVENT :
lTmpTypeOfMechEvt=(long)GAM_fn_p_xGetEventOfEvent(p_stEvent);
eMechEvent = (LRM_eKindOfRequest)lTmpTypeOfMechEvt;
if(M_GetMSHandle(p_stSuperObject,Dynam) != NULL )
LRM_fn_xBoolAddRequest
(fn_pDynamGetListOfRequests(M_GetMSHandle(p_stSuperObject,Dynam)),
eMechEvent ,
fn_h_GetCurrentDNMIdCard(p_stSuperObject));
if(eMechEvent == LRM_eRequest_Jump)
LRM_fn_xBoolDelAllRequestsOfThisType(fn_pDynamGetListOfRequests(M_GetMSHandle(p_stSuperObject,Dynam)),
LRM_eRequest_GoRelative);
fn_v3dDataSetNbEngineFrameSinceLastMechEvent(M_GetMSHandle(p_stSuperObject,3dData),0);
strcpy( szType, "MechanicEvent");
break;*/
case C_ucGENERATE_EVENT :
break;
/* MR1206*/
case C_ucGENERIC_EVENT :
{
long lEvent;
unsigned char ucTypeOfEvent;
/*unsigned short uwChannel;*/
HIE_tdxHandleToSuperObject hSupObjTakenObject;
lEvent=(long)GAM_fn_p_xGetEventOfEvent(p_stEvent);
ucTypeOfEvent=(unsigned char)(lEvent&0xff);
/*uwChannel=(unsigned short)(lEvent>>8);*/
if ( (ucTypeOfEvent >= C_ucEvent_User0) && (ucTypeOfEvent <= C_ucEvent_User7) )
{
MTH3D_tdstVector stPosition;
/*get the channel superobject*/
hSupObjTakenObject = fn_hGetSuperObjectInChannel(fn_h3dDataGetChannelSOList(M_GetMSHandle(p_stSuperObject,3dData)),p_stEvent->uwChannelNumber);
if ( hSupObjTakenObject )
{
unsigned long ulCustomBits = fn_ulStandardGameGetCustomBitsSO(p_stSuperObject);
/* check if position have been update by the player*/
if(!(ulCustomBits & GAM_C_CustBitNeedModuleMatrices))
{
fn_vStandardGameSetCustomBitsSO(p_stSuperObject,ulCustomBits|GAM_C_CustBitNeedModuleMatrices);
PLA_fn_vRefreshGlobalMatrixUnderCharacter(p_stSuperObject);
fn_vStandardGameSetCustomBitsSO(p_stSuperObject,ulCustomBits);
}
POS_fn_vGetTranslationVector(HIE_fn_hGetSuperObjectGlobalMatrix(hSupObjTakenObject), &stPosition);
fn_v3dDataSetUserEventFlag
(
M_GetMSHandle(p_stSuperObject,3dData),
(unsigned char) (ucTypeOfEvent - C_ucEvent_User0),
TRUE,
&stPosition
);
}
}
}
break;
default :
break;
}
#if defined(_DEBUG) && defined(WIN32) && defined(__cplusplus)
switch( ucMode )
{
case C_ucNormal :
strcpy( szMode, "Normal");
break;
case C_ucReverse :
strcpy( szMode, "Reverse");
break;
case C_ucStopEvent :
strcpy( szMode, "Stop");
break;
default :
break;
}
TRACE3( "%s %s %d\n", szType, szMode, (long)p_stEvent->p_xEvent );
#endif /* _DEBUG && WIN32 && __cplusplus */
}
unsigned short fn_uwGetNbEngineFrameSinceLastMechEvent(HIE_tdxHandleToSuperObject p_stSuperObject)
{
return fn_uw3dDataGetNbEngineFrameSinceLastMechEvent(M_GetMSHandle(p_stSuperObject,3dData));
}
/*-----------------------------------------------------------------------------
* Description : Get the type of an event (V5 or V6 format)
*-----------------------------------------------------------------------------
* Input : _p_stEvent : pointer to the event
* Output : the type
*-----------------------------------------------------------------------------
* Creation date : Jan 98 Author : Alain Robin
*---------------------------------------------------------------------------*/
unsigned char GAM_fn_ucGetTypeOfEvent(tdstEvent* _p_stEvent)
{
return _p_stEvent->p_stfEventInTBL->ucTypeOfEvent;
}
/*-----------------------------------------------------------------------------
* Description : Get the pointed event of an event (V5 or V6 format)
*-----------------------------------------------------------------------------
* Input : _p_stEvent : pointer to the event
* Output : the event
*-----------------------------------------------------------------------------
* Creation date : Jan 98 Author : Alain Robin
*---------------------------------------------------------------------------*/
void* GAM_fn_p_xGetEventOfEvent(tdstEvent* _p_stEvent)
{
return _p_stEvent->p_stfEventInTBL->p_xEvent;
}
/*-----------------------------------------------------------------------------
* Description : Get the address pointed event of an event (V5 or V6 format)
*-----------------------------------------------------------------------------
* Input : _p_stEvent : pointer to the event
* Output : the address
*-----------------------------------------------------------------------------
* Creation date : Jan 98 Author : Alain Robin
*---------------------------------------------------------------------------*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void** GAM_fn_p_xGetAdressOfEventOfEvent(tdstEvent* _p_stEvent)
{
return &(_p_stEvent->p_stfEventInTBL->p_xEvent);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*-----------------------------------------------------------------------------
* Description : Set the pointed event of an event (V5 or V6 format)
*-----------------------------------------------------------------------------
* Input : _p_stEvent : pointer to the animation event
* _p_xRealEvent : pointed event
* Output :
*-----------------------------------------------------------------------------
* Creation date : Jan 98 Author : Alain Robin
*---------------------------------------------------------------------------*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void GAM_fn_vSetEventOfEvent(tdstEvent* _p_stEvent,void* _p_xRealEvent)
{
_p_stEvent->p_stfEventInTBL->p_xEvent=_p_xRealEvent;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*-----------------------------------------------------------------------------
* Description : Get the first call field of an event (V5 or V6 format)
*-----------------------------------------------------------------------------
* Input : _p_stEvent : pointer to the event
* Output : the first call
*-----------------------------------------------------------------------------
* Creation date : Jan 98 Author : Alain Robin
*---------------------------------------------------------------------------*/
unsigned char GAM_fn_ucGetFirstCallOfEvent(tdstEvent* _p_stEvent)
{
return _p_stEvent->p_stfEventInTBL->ucFirstCall;
}
/*-----------------------------------------------------------------------------
* Description : Get the first call field of an event (V5 or V6 format)
*-----------------------------------------------------------------------------
* Input : _p_stEvent : pointer to the event
* Output : the first call
*-----------------------------------------------------------------------------
* Creation date : Jan 98 Author : Alain Robin
*---------------------------------------------------------------------------*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void GAM_fn_vSetFirstCallOfEvent(tdstEvent* _p_stEvent,unsigned char _ucFirstCall)
{
_p_stEvent->p_stfEventInTBL->ucFirstCall=_ucFirstCall;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*-----------------------------------------------------------------------------
* Description : Get the period field of an event (V5 or V6 format)
*-----------------------------------------------------------------------------
* Input : _p_stEvent : pointer to the event
* Output : the period
*-----------------------------------------------------------------------------
* Creation date : Jan 98 Author : Alain Robin
*---------------------------------------------------------------------------*/
unsigned char GAM_fn_ucGetPeriodOfEvent(tdstEvent* _p_stEvent)
{
return _p_stEvent->p_stfEventInTBL->ucPeriod;
}
/*-----------------------------------------------------------------------------
* Description : Get the first call field of an event (V5 or V6 format)
*-----------------------------------------------------------------------------
* Input : _p_stEvent : pointer to the event
* Output : the first call
*-----------------------------------------------------------------------------
* Creation date : Jan 98 Author : Alain Robin
*---------------------------------------------------------------------------*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void GAM_fn_vSetPeriodOfEvent(tdstEvent* _p_stEvent,unsigned char _ucPeriod)
{
_p_stEvent->p_stfEventInTBL->ucPeriod=_ucPeriod;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*-----------------------------------------------------------------------------
* Description : Get the binary event id of an event (V5 or V6 format)
*-----------------------------------------------------------------------------
* Input : _p_stEvent : pointer to the event
* Output : the binary event id
*-----------------------------------------------------------------------------
* Creation date : Jan 98 Author : Alain Robin
*---------------------------------------------------------------------------*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
/*
unsigned long GAM_fn_ulGetBinaryEventIdOfEvent(tdstEvent* _p_stEvent)
{
return _p_stEvent->p_stfEventInTBL->ulBinaryEventId;
}
*/
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*-----------------------------------------------------------------------------
* Description : Get the first call field of an event (V5 or V6 format)
*-----------------------------------------------------------------------------
* Input : _p_stEvent : pointer to the event
* Output : the first call
*-----------------------------------------------------------------------------
* Creation date : Jan 98 Author : Alain Robin
*---------------------------------------------------------------------------*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
/*
void GAM_fn_vSetBinaryEventIdOfEvent(tdstEvent* _p_stEvent,unsigned long _ulBinaryEventId)
{
_p_stEvent->p_stfEventInTBL->ulBinaryEventId=_ulBinaryEventId;
}
*/
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */