//  DEBUGING for SOUNDxD
#include "SNDinc.h"

#include <windows.h>
#include <mmsystem.h>

#include "snddll.h"

#include "snddbg.h"

#include "sndplay.h"
#include "sndtheme.h"
#include "sndspace.h"



#include "sndld_hy.h"


HINSTANCE hSupervisaterDLL;
SND_tdstInitStruct pInitStructSaved;

//fonction exportée pour SNDDBG.DLL (interface DLL->LIB)

DLL_IMPEXP SndBool	SND_CALL dbgSND_fn_bGetAskedTheme(tduRefRes*,SndBool*);
DLL_IMPEXP SndBool	SND_CALL dbgSND_fn_bGetThemePosition(tduRefRes*,long* ,long* );
DLL_IMPEXP void		SND_CALL dbgSND_fn_vGetInfoForObjectSound(long ,long ,char* ,long );
DLL_IMPEXP long		SND_CALL dbgSND_fn_lGetSizeOfSoundParam(SoundParam* );
DLL_IMPEXP void		SND_CALL SND_fn_vSetResNameCallback(tdpfnResNameCallback);
DLL_IMPEXP const char* SND_CALL SND_fn_czGetResNameFromEdId(unsigned long);

SndBool SND_CALL dbgSND_fn_bGetAskedTheme(tduRefRes* par1,SndBool* par2)
{
	return SND_fn_bGetAskedTheme(par1,par2);
}


SndBool SND_CALL dbgSND_fn_bGetThemePosition(tduRefRes* par1,long* par2,long* par3)
{
	return SND_fn_bGetThemePosition(par1,par2,par3);
}

void SND_CALL dbgSND_fn_vGetInfoForObjectSound(long par1,long par2,char* par3,long par4)
{
	SND_fn_vGetInfoForObjectSound(par1,par2,par3,par4);
}

long SND_CALL dbgSND_fn_lGetSizeOfSoundParam(SoundParam* par)
{
	return SND_M_lGetSizeOfSoundParam(par);
}

tdstBlockResourceMem*	SND_fn_pstGetSelectedResource(void)
{
	return dbgSND_fn_pstGetSelectedResource();
}

SndBool					SND_fn_bDoesSupervisaterSelectResource(void)
{
	return dbgSND_fn_bDoesSupervisaterSelectResource();
}

void SND_fn_vRefreshSupervisater(void)
{
	dbgSND_fn_vRefreshSupervisater();
}

//**********************************************************************************
//					EDITION HELPER FUNCTIONS
//**********************************************************************************

typedef const char * (*tdpfnResNameCallback)(unsigned long);

tdpfnResNameCallback gs_pfnResNameCallback=NULL;

//-----------------------------------------------------------------------------
//  Name : SND_fn_vSetResNameCallback(tdpfnResNameCallback pfnResNameCallback)
//-----------------------------------------------------------------------------
//  Description :   Sets the callback used to return the resource's name.
//-----------------------------------------------------------------------------
//  Input :  tdpfnResNameCallback pfnResNameCallback;  
//  Output : void
//-----------------------------------------------------------------------------
//  Creation date : 04/02/98            Author : Frédéric Décréau
//-----------------------------------------------------------------------------
//  Modification date :                 Modification Author :
//  Modifications :
//-----------------------------------------------------------------------------

void SND_CALL SND_fn_vSetResNameCallback(tdpfnResNameCallback pfnResNameCallback)
{
	gs_pfnResNameCallback=pfnResNameCallback;
}



//-----------------------------------------------------------------------------
//  Name : SND_fn_czGetResNameFromEdId(unsigned long ulId)
//-----------------------------------------------------------------------------
//  Description :   Returns the name of a resource (as set in its editor section),
//					given its editor id. Uses a callback set by the client.
//					Return an empty string if the callback was not set. 
//-----------------------------------------------------------------------------
//  Input :  unsigned long ulId        
//  Output : const char *    
//-----------------------------------------------------------------------------
//  Creation date : 04/02/98            Author : Frédéric Décréau
//-----------------------------------------------------------------------------
//  Modification date :                 Modification Author :
//  Modifications :
//-----------------------------------------------------------------------------
const char* SND_CALL SND_fn_czGetResNameFromEdId(unsigned long ulId)
{
	if (gs_pfnResNameCallback==NULL) 
		return "ResName unavailable";
	else return gs_pfnResNameCallback(ulId);
}



//-----------------------------------------------------------------------------
//  Name : dbgSND_fn_bSetResourceStaticVolume(unsigned long EdId,unsigned char ucVolume)
//-----------------------------------------------------------------------------
//  Description :   Change the static volume for a specific resource,
//					given its editor id.
//					Return TRUE when volume has been changed. 
//-----------------------------------------------------------------------------
//  Input :  unsigned long EdId= resource,s editor-id to change volume of
//			unsigned char ucVolume= new volume for this resource
//  Output : SndBool= TRUE when volume change succeded, FALSE when failed
//-----------------------------------------------------------------------------
SndBool SND_CALL dbgSND_fn_bSetResourceStaticVolume(unsigned long ulEdId,unsigned char ucVolume)
{
	tdstBlockResourceMem* pstRes;
	
	pstRes=SND_fn_pstGetResFromEdIdSnd(ulEdId);

	if (pstRes!=NULL)
		return SND_fn_bSetResourceStaticVolumeSnd(pstRes,ucVolume);
	else
		return FALSE;
}



//-----------------------------------------------------------------------------
//  Name : dbgSND_fn_rGetDopplerFactor()
//-----------------------------------------------------------------------------
//  Description :   Gets the global doppler factor
//-----------------------------------------------------------------------------
//  Input :  None
//  Output : the factor
//-----------------------------------------------------------------------------
//  Creation date : 04/28/99            Author : Pascal Lalancette
//-----------------------------------------------------------------------------
//  Modification date :                 Modification Author :
//  Modifications :
//-----------------------------------------------------------------------------
SndReal SND_CALL dbgSND_fn_rGetDopplerFactor(void)
{
	return SND_fn_rGetDopplerFactor();
}



//-----------------------------------------------------------------------------
//  Name : dbgSND_fn_vSendRequestSound()
//-----------------------------------------------------------------------------
//  Description :   SuperVisater ask the sound engine to play an event
//-----------------------------------------------------------------------------
//  Input :  None
//  Output : the factor
//-----------------------------------------------------------------------------
//  Creation date : 06/09/99            Author : Pascal Lalancette
//-----------------------------------------------------------------------------
//  Modification date :                 Modification Author :
//  Modifications :
//-----------------------------------------------------------------------------
void SND_CALL dbgSND_fn_vSendRequestSound(SND_tduRefEvt evt)
{

	//long SND_fn_lSendRequestSound(SND_C_OBJET_SUPERVISATER, SND_C_TYPE_SUPERVISATER,evt,NULL, NULL);
	SND_fn_lSendRequestSound(SND_C_OBJET_FANTOME, SND_C_TYPE_FANTOME, evt, 0, NULL);
	

}



