reman3/Rayman_X/cpa/tempgrp/SNA/snasnd.c

143 lines
5.0 KiB
C

/*=========================================================================
* Snasnd.c : Save & Read the sound pointers
*
* Version 1.0
* Creation date 03/09/97
* Revision date
*
* (c) Ubi R&D 1997
*=======================================================================*/
#include "ACP_Base.h"
#include "ToolsCPA.h"
#include "SCR.h"
#include "SND.h"
#include "SNA.h"
#include "acp_opfi.h"
FILE *g_xSoundFile; // Sound pointers file
/*-----------------------------------------------------------------------------
* Description : Open sound pointers file
*-----------------------------------------------------------------------------
* Input : Name of the file
* Output : None
*-----------------------------------------------------------------------------
* Creation date : 03/09/97 Author : Michaël
*-----------------------------------------------------------------------------
* Modification date : Modification Author :
* Modifications :
*---------------------------------------------------------------------------*/
void SNA_fn_xWriteOpenSoundTableFile(char *szFileName)
{
SNA_fn_vInitArrays();
g_xSoundFile=fopen(szFileName,"wb");
}
void SNA_fn_xReadOpenSoundTableFile(char *szFileName)
{
SNA_fn_vInitArrays();
//g_xSoundFile=fopen(szFileName,"rb"); Multi-install
ACP_M_OPENFILE(fopen,g_xSoundFile,NULL,szFileName,(szFileName,"rb"));
SNA_M_LoadUsedRelocationTable();
}
/*-----------------------------------------------------------------------------
* Description : Close sound pointers file
*-----------------------------------------------------------------------------
* Input : Name of the file
* Output : None
*-----------------------------------------------------------------------------
* Creation date : 03/09/97 Author : Michaël
*-----------------------------------------------------------------------------
* Modification date : Modification Author :
* Modifications :
*---------------------------------------------------------------------------*/
void SNA_fn_vCloseSoundTableFile()
{
SNA_M_FreeRelocationTable();
fclose(g_xSoundFile);
}
/*-----------------------------------------------------------------------------
* Description : Write a Id/pointer sound couple in file
*-----------------------------------------------------------------------------
* Input : Name of the file
* Output : None
*-----------------------------------------------------------------------------
* Creation date : 03/09/97 Author : Michaël
*-----------------------------------------------------------------------------
* Modification date : Modification Author :
* Modifications :
*---------------------------------------------------------------------------*/
void SNA_fn_vWriteSoundEntryInSoundTableFile(unsigned long ulId,unsigned long ulPointerAdr)
{
if (SNA_fn_ucGetLoadType()==SNA_SAVE_SNAPSHOT)
{
fwrite(&ulId,4,1,g_xSoundFile);
fwrite(&ulPointerAdr,4,1,g_xSoundFile);
}
}
/*-----------------------------------------------------------------------------
* Description : Read and update all sound pointers
*-----------------------------------------------------------------------------
* Input : Name of the file
* Output : None
*-----------------------------------------------------------------------------
* Creation date : 03/09/97 Author : Michaël
*-----------------------------------------------------------------------------
* Modification date : Modification Author :
* Modifications :
*---------------------------------------------------------------------------*/
void SNA_fn_vReadAndUpdateSoundPointers(char *szFileName)
{
unsigned long ulId,ulOldAdrPointer,ulNewPointer;
unsigned long *p_ulSound;
/* unsigned long j; */
struct tdstPtr_ *p_stCurrentPtr = &SNA_g_PTCRelocationTable->p_stBloc[0].p_stPtr[0];
while (!feof(g_xSoundFile))
{
if(!fread(&ulId,4,1,g_xSoundFile))
{
#ifdef DEBUG
OutputDebugString("\n End of SoundFile !!!");
#endif
break;
}
if(!fread(&ulOldAdrPointer,4,1,g_xSoundFile))
{
#ifdef DEBUG
OutputDebugString("\n End of SoundFile !!!");
#endif
break;
}
ulNewPointer=(unsigned long)SND_fn_pGetBinEvent(ulId);
/*
for (j=0;j<SNA_g_PTCRelocationTable->p_stBloc[0].ulSize;j++)
{
unsigned char ucModuleNumber,ucBlocNumber;
ucModuleNumber=SNA_g_PTCRelocationTable->p_stBloc[0].p_stPtr[j].ucTargetModule;
ucBlocNumber=SNA_g_PTCRelocationTable->p_stBloc[0].p_stPtr[j].ucTargetBlock;
if (((unsigned long)p_ulSound==SNA_g_PTCRelocationTable->p_stBloc[0].p_stPtr[j].p_vPtr)&&(g_a_bIsBlocRelocated[ucModuleNumber][ucBlocNumber]))
{
((unsigned long)p_ulSound)+=g_a_ulOffset[ucModuleNumber][ucBlocNumber];
}
}
*/
assert( p_stCurrentPtr->p_vPtr == ulOldAdrPointer );
ulOldAdrPointer += g_a_ulOffset[p_stCurrentPtr->ucTargetModule][p_stCurrentPtr->ucTargetBlock];
p_stCurrentPtr ++;
p_ulSound=(unsigned long *)ulOldAdrPointer;
*p_ulSound=ulNewPointer;
}
fclose(g_xSoundFile);
}