This commit is contained in:
parent
27b7ee5531
commit
aad1689a44
7 changed files with 187 additions and 168 deletions
|
@ -139,6 +139,7 @@ int pkill=0;
|
||||||
int mvol=10;
|
int mvol=10;
|
||||||
int svol=255;
|
int svol=255;
|
||||||
VECTOR ppos;
|
VECTOR ppos;
|
||||||
|
int psp=0;
|
||||||
|
|
||||||
void CPaulScene::think()
|
void CPaulScene::think()
|
||||||
{
|
{
|
||||||
|
@ -174,9 +175,11 @@ void CPaulScene::think()
|
||||||
}
|
}
|
||||||
if(pad&PAD_START)
|
if(pad&PAD_START)
|
||||||
{
|
{
|
||||||
PAUL_DBGMSG("stop loopers..");
|
// PAUL_DBGMSG("stop loopers..");
|
||||||
CSoundMediator::stopSfx((xmPlayingId)ploopid1);
|
// CSoundMediator::stopSfx((xmPlayingId)ploopid1);
|
||||||
CSoundMediator::stopSfx((xmPlayingId)ploopid2);
|
// CSoundMediator::stopSfx((xmPlayingId)ploopid2);
|
||||||
|
PAUL_DBGMSG("speech..\n");
|
||||||
|
CSoundMediator::playSpeech((SpeechEquate)psp);
|
||||||
}
|
}
|
||||||
if(pad&PAD_R2)
|
if(pad&PAD_R2)
|
||||||
{
|
{
|
||||||
|
@ -218,12 +221,12 @@ void CPaulScene::think()
|
||||||
if(svol<CSoundMediator::MIN_VOLUME)svol=CSoundMediator::MIN_VOLUME;
|
if(svol<CSoundMediator::MIN_VOLUME)svol=CSoundMediator::MIN_VOLUME;
|
||||||
setSfxVolume=true;
|
setSfxVolume=true;
|
||||||
}
|
}
|
||||||
if(setSongVolume) CSoundMediator::setVolume(CSoundMediator::SONG,mvol);
|
if(setSongVolume) CSoundMediator::setVolume(CSoundMediator::SPEECH,mvol);
|
||||||
if(setSfxVolume) CSoundMediator::setVolume(CSoundMediator::SFX,svol);
|
if(setSfxVolume) CSoundMediator::setVolume(CSoundMediator::SFX,svol);
|
||||||
|
|
||||||
if(setSongVolume||setSfxVolume)
|
if(setSongVolume||setSfxVolume)
|
||||||
{
|
{
|
||||||
PAUL_DBGMSG("song:%d sfx:%d",mvol,svol);
|
PAUL_DBGMSG("speech:%d sfx:%d",mvol,svol);
|
||||||
}
|
}
|
||||||
|
|
||||||
//CXAStream::ControlXA();
|
//CXAStream::ControlXA();
|
||||||
|
|
|
@ -32,21 +32,28 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
XA_MODE CXAStream::Mode=XA_MODE_NOTINIT;
|
CXAStream::XA_MODE CXAStream::Mode=XA_MODE_NOTINIT;
|
||||||
int CXAStream::Status;
|
int CXAStream::Status;
|
||||||
int CXAStream::StartSector;
|
int CXAStream::StartSector;
|
||||||
sXAStream CXAStream::Stream[XA_STREAM_MAX];
|
CXAStream::sXAStream CXAStream::Stream[XA_STREAM_MAX];
|
||||||
int CXAStream::CurrentStream;
|
int CXAStream::CurrentStream;
|
||||||
int CXAStream::PauseFlag;
|
int CXAStream::PauseFlag;
|
||||||
|
|
||||||
// Speech
|
// Speech
|
||||||
SpeechEquate CXAStream::Queue[XA_QUEUE_MAX];
|
SpeechEquate CXAStream::Queue[XA_QUEUE_MAX];
|
||||||
u16 CXAStream::QueueCount;
|
u16 CXAStream::QueueCount;
|
||||||
|
|
||||||
|
|
||||||
|
// Volume
|
||||||
|
int CXAStream::s_masterVolumeL=XA_DEFAULT_VOL;
|
||||||
|
int CXAStream::s_masterVolumeR=XA_DEFAULT_VOL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void XACDReadyCallback(int Intr, u8 *Result)
|
void CXAStream::XACDReadyCallback(int Intr, u8 *Result)
|
||||||
{
|
{
|
||||||
static int ErrorRetry;
|
static int ErrorRetry;
|
||||||
u32 XABuffer[8];
|
u32 XABuffer[8];
|
||||||
|
@ -226,7 +233,7 @@ sXAStream &ThisStream=Stream[CurrentStream];
|
||||||
break;
|
break;
|
||||||
case XA_MODE_PLAY:
|
case XA_MODE_PLAY:
|
||||||
if (Status==CdlDiskError) Mode=XA_MODE_RESUME;
|
if (Status==CdlDiskError) Mode=XA_MODE_RESUME;
|
||||||
SetVolume(XA_DEFAULT_VOL,XA_DEFAULT_VOL);
|
SetVolume(s_masterVolumeL,s_masterVolumeL);
|
||||||
break;
|
break;
|
||||||
case XA_MODE_END:
|
case XA_MODE_END:
|
||||||
SetVolumeOff();
|
SetVolumeOff();
|
||||||
|
@ -292,26 +299,15 @@ void CXAStream::SetVolume(s32 LVol,s32 RVol)
|
||||||
{
|
{
|
||||||
CdlATV CDVol;
|
CdlATV CDVol;
|
||||||
SpuCommonAttr Attr;
|
SpuCommonAttr Attr;
|
||||||
//int VolumeSetting;
|
|
||||||
//
|
|
||||||
// if (CurrentStream==XA_STREAM_SPEECH)
|
|
||||||
// VolumeSetting=CSfxFactory::SNDVOL_SFX;
|
|
||||||
// else
|
|
||||||
// VolumeSetting=CSfxFactory::SNDVOL_MUSIC;
|
|
||||||
//
|
|
||||||
// LVol=(LVol*CSfxFactory::getVolumeLevel(VolumeSetting))/256;
|
|
||||||
// RVol=(RVol*CSfxFactory::getVolumeLevel(VolumeSetting))/256;
|
|
||||||
Attr.mask = (SPU_COMMON_CDVOLL|SPU_COMMON_CDVOLR|SPU_COMMON_CDMIX);
|
|
||||||
Attr.cd.volume.left =LVol;
|
|
||||||
Attr.cd.volume.right=RVol;
|
|
||||||
Attr.cd.mix=SPU_ON;
|
|
||||||
SpuSetCommonAttr(&Attr);
|
|
||||||
CDVol.val0 = 127; // CdL -> SpuL
|
|
||||||
CDVol.val1 = 127; // CdL -> SpuR
|
|
||||||
CDVol.val2 = 127; // CdR -> SpuR
|
|
||||||
CDVol.val3 = 127; // CdR -> SpuL
|
|
||||||
CdMix(&CDVol);
|
|
||||||
|
|
||||||
|
SpuSetCommonCDVolume(LVol,RVol);
|
||||||
|
SpuSetCommonCDMix(SPU_ON);
|
||||||
|
|
||||||
|
CDVol.val0 = 127; // CdL -> SpuL
|
||||||
|
CDVol.val1 = 127; // CdL -> SpuR
|
||||||
|
CDVol.val2 = 127; // CdR -> SpuR
|
||||||
|
CDVol.val3 = 127; // CdR -> SpuL
|
||||||
|
CdMix(&CDVol);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -319,23 +315,25 @@ void CXAStream::SetVolumeOff()
|
||||||
{
|
{
|
||||||
CdlATV CDVol;
|
CdlATV CDVol;
|
||||||
SpuCommonAttr Attr;
|
SpuCommonAttr Attr;
|
||||||
// SsSetSerialVol(SS_SERIAL_A,0,0);
|
|
||||||
|
|
||||||
|
SpuSetCommonCDVolume(0,0);
|
||||||
// Attr.mask = (SPU_COMMON_CDVOLL|SPU_COMMON_CDVOLR|SPU_COMMON_CDMIX);
|
SpuSetCommonCDMix(SPU_ON);
|
||||||
// Attr.cd.volume.left =0;
|
|
||||||
// Attr.cd.volume.right=0;
|
|
||||||
// Attr.cd.mix=SPU_ON;
|
|
||||||
// SpuSetCommonAttr(&Attr);
|
|
||||||
SpuSetCommonCDVolume(0,0);
|
|
||||||
SpuSetCommonCDMix(SPU_ON);
|
|
||||||
|
|
||||||
CDVol.val0 = 0; // CdL -> SpuL
|
CDVol.val0 = 0; // CdL -> SpuL
|
||||||
CDVol.val1 = 0; // CdL -> SpuR
|
CDVol.val1 = 0; // CdL -> SpuR
|
||||||
CDVol.val2 = 0; // CdR -> SpuR
|
CDVol.val2 = 0; // CdR -> SpuR
|
||||||
CDVol.val3 = 0; // CdR -> SpuL
|
CDVol.val3 = 0; // CdR -> SpuL
|
||||||
CdMix(&CDVol);
|
CdMix(&CDVol);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CXAStream::setMasterVolume(int _volumeL,int _volumeR)
|
||||||
|
{
|
||||||
|
ASSERT(_volumeL>=MIN_VOLUME) ASSERT(_volumeL<=MAX_VOLUME);
|
||||||
|
ASSERT(_volumeR>=MIN_VOLUME) ASSERT(_volumeR<=MAX_VOLUME);
|
||||||
|
|
||||||
|
s_masterVolumeL=_volumeL;
|
||||||
|
s_masterVolumeR=_volumeR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,104 +9,113 @@
|
||||||
#include "sound/Speech.h"
|
#include "sound/Speech.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
enum XA_ENUM
|
|
||||||
{
|
|
||||||
XA_MUSIC_TRACK =1,
|
|
||||||
XA_SPEECH_TRACK =2,
|
|
||||||
XA_QUEUE_MAX =8,
|
|
||||||
XA_TRACK_MAX =32,
|
|
||||||
XA_DEFAULT_VOL =32000,
|
|
||||||
XA_CHANNEL_SHIFT =16,
|
|
||||||
XA_CHANNEL_MASK =(0xffffffff<<XA_CHANNEL_SHIFT),
|
|
||||||
XA_SPEECH_MASK =(0xffffffff-XA_CHANNEL_MASK),
|
|
||||||
};
|
|
||||||
|
|
||||||
enum XA_STREAMS
|
|
||||||
{
|
|
||||||
XA_STREAM_MUSIC=0,
|
|
||||||
XA_STREAM_SPEECH,
|
|
||||||
|
|
||||||
XA_STREAM_MAX
|
|
||||||
};
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
enum XA_MODE
|
|
||||||
{
|
|
||||||
XA_MODE_NOTINIT=-1,
|
|
||||||
XA_MODE_IDLE=0,
|
|
||||||
XA_MODE_START,
|
|
||||||
XA_MODE_PLAY,
|
|
||||||
XA_MODE_END,
|
|
||||||
XA_MODE_PAUSE,
|
|
||||||
XA_MODE_RESUME,
|
|
||||||
XA_MODE_STOP,
|
|
||||||
};
|
|
||||||
struct sXAEntry
|
|
||||||
{
|
|
||||||
u32 Channel;
|
|
||||||
u32 StartSector,CurrentSector;
|
|
||||||
s32 LVol,RVol;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct sXAStream
|
|
||||||
{
|
|
||||||
int BaseChannel;
|
|
||||||
sXAEntry Entry;
|
|
||||||
// int Volume;
|
|
||||||
CdlLOC CDPos;
|
|
||||||
} ;
|
|
||||||
/*
|
|
||||||
struct sXAStream
|
|
||||||
{
|
|
||||||
int BaseChannel,Channel;
|
|
||||||
// int Volume;
|
|
||||||
int CurrentSector;
|
|
||||||
CdlLOC CDPos;
|
|
||||||
} ;
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
class CXAStream
|
class CXAStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MIN_VOLUME=0,
|
||||||
|
MAX_VOLUME=0x7fff,
|
||||||
|
};
|
||||||
|
|
||||||
CXAStream(){};
|
CXAStream(){};
|
||||||
~CXAStream(){};
|
~CXAStream(){};
|
||||||
|
|
||||||
static void Init();
|
static void Init();
|
||||||
static void Start(int Str,u32 Sector,u32 Channel,s32 LVol,s32 RVol);
|
static void Start(int Str,u32 Sector,u32 Channel,s32 LVol,s32 RVol);
|
||||||
static void Stop();
|
static void Stop();
|
||||||
|
|
||||||
static void PlayMusic(u32 Track);
|
static void PlayMusic(u32 Track);
|
||||||
static void StopMusic() {Stop();}
|
static void PlaySpeech(SpeechEquate SpeechNo,int ForcePlay=0);
|
||||||
static void PlaySpeech(SpeechEquate SpeechNo,int ForcePlay=0);
|
|
||||||
static void StopSpeech() {Stop();}
|
|
||||||
|
|
||||||
static void ControlXA();
|
static void ControlXA();
|
||||||
static void SetVolumeOff();
|
static int IsPlaying() {return(Mode==XA_MODE_PLAY);}
|
||||||
static void SetVolume(s32 LVol,s32 RVol);
|
|
||||||
static void Interrupt();
|
|
||||||
static void Pause();
|
|
||||||
static void Resume();
|
|
||||||
static void SetSector(u32 Sector) {StartSector=Sector;}
|
|
||||||
static void SetLanguage(int Lang) {Stream[XA_STREAM_SPEECH].BaseChannel=XA_SPEECH_TRACK+Lang;}
|
|
||||||
|
|
||||||
static void Reset();
|
static void setMasterVolume(int _volumeL,int _volumeR);
|
||||||
static int IsPlaying() {return(Mode==XA_MODE_PLAY);}
|
|
||||||
static XA_MODE Mode;
|
|
||||||
static int Status;
|
|
||||||
static int StartSector;
|
|
||||||
static sXAStream Stream[XA_STREAM_MAX];
|
|
||||||
static int CurrentStream;
|
|
||||||
static int PauseFlag;
|
|
||||||
|
|
||||||
static int CurrentChannel;
|
|
||||||
|
private:
|
||||||
|
enum XA_ENUM
|
||||||
|
{
|
||||||
|
XA_MUSIC_TRACK =1,
|
||||||
|
XA_SPEECH_TRACK =2,
|
||||||
|
XA_QUEUE_MAX =8,
|
||||||
|
XA_TRACK_MAX =32,
|
||||||
|
XA_DEFAULT_VOL =32000,
|
||||||
|
XA_CHANNEL_SHIFT =16,
|
||||||
|
XA_CHANNEL_MASK =(0xffffffff<<XA_CHANNEL_SHIFT),
|
||||||
|
XA_SPEECH_MASK =(0xffffffff-XA_CHANNEL_MASK),
|
||||||
|
};
|
||||||
|
|
||||||
// Speech
|
enum XA_STREAMS
|
||||||
static SpeechEquate Queue[XA_QUEUE_MAX];
|
{
|
||||||
static u16 QueueCount;
|
XA_STREAM_MUSIC=0,
|
||||||
static int SpeechChannel;
|
XA_STREAM_SPEECH,
|
||||||
|
|
||||||
|
XA_STREAM_MAX
|
||||||
|
};
|
||||||
|
|
||||||
|
enum XA_MODE
|
||||||
|
{
|
||||||
|
XA_MODE_NOTINIT=-1,
|
||||||
|
XA_MODE_IDLE=0,
|
||||||
|
XA_MODE_START,
|
||||||
|
XA_MODE_PLAY,
|
||||||
|
XA_MODE_END,
|
||||||
|
XA_MODE_PAUSE,
|
||||||
|
XA_MODE_RESUME,
|
||||||
|
XA_MODE_STOP,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sXAEntry
|
||||||
|
{
|
||||||
|
u32 Channel;
|
||||||
|
u32 StartSector,CurrentSector;
|
||||||
|
s32 LVol,RVol;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sXAStream
|
||||||
|
{
|
||||||
|
int BaseChannel;
|
||||||
|
sXAEntry Entry;
|
||||||
|
CdlLOC CDPos;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
static void SetVolumeOff();
|
||||||
|
static void SetVolume(s32 LVol,s32 RVol);
|
||||||
|
static void Interrupt();
|
||||||
|
static void Pause();
|
||||||
|
static void Resume();
|
||||||
|
static void SetSector(u32 Sector) {StartSector=Sector;}
|
||||||
|
static void SetLanguage(int Lang) {Stream[XA_STREAM_SPEECH].BaseChannel=XA_SPEECH_TRACK+Lang;}
|
||||||
|
|
||||||
|
static void Reset();
|
||||||
|
|
||||||
|
static XA_MODE Mode;
|
||||||
|
static int Status;
|
||||||
|
static int StartSector;
|
||||||
|
static sXAStream Stream[XA_STREAM_MAX];
|
||||||
|
static int CurrentStream;
|
||||||
|
static int PauseFlag;
|
||||||
|
|
||||||
|
static int CurrentChannel;
|
||||||
|
|
||||||
|
// Speech
|
||||||
|
static SpeechEquate Queue[XA_QUEUE_MAX];
|
||||||
|
static u16 QueueCount;
|
||||||
|
static int SpeechChannel;
|
||||||
|
|
||||||
|
static int s_masterVolumeL,s_masterVolumeR;
|
||||||
|
|
||||||
|
|
||||||
|
static void XACDReadyCallback(int Intr, u8 *Result);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -140,8 +140,9 @@ void CSoundMediator::initialise()
|
||||||
s_targetVolume[i]=INITIAL_VOLUME;
|
s_targetVolume[i]=INITIAL_VOLUME;
|
||||||
s_volumeDirty[i]=true;
|
s_volumeDirty[i]=true;
|
||||||
}
|
}
|
||||||
// ASSERT(CXAStream::MIN_VOLUME==0); // Just incase someone decides to change any of these.. things in here will break ( PKG )
|
|
||||||
// ASSERT(CXAStream::MAX_VOLUME==32767);
|
ASSERT(CXAStream::MIN_VOLUME==0); // Just incase someone decides to change any of these.. things in here will break ( PKG )
|
||||||
|
ASSERT(CXAStream::MAX_VOLUME==32767);
|
||||||
|
|
||||||
// Initial reverb settings
|
// Initial reverb settings
|
||||||
setReverbType(NONE);//ECHO_TEST);
|
setReverbType(NONE);//ECHO_TEST);
|
||||||
|
@ -212,7 +213,7 @@ void CSoundMediator::think(int _frames)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update of anything that needs it
|
// Update of anything that needs it
|
||||||
// CXAStream::ControlXA();
|
CXAStream::ControlXA();
|
||||||
s_xmplaySound->think();
|
s_xmplaySound->think();
|
||||||
|
|
||||||
|
|
||||||
|
@ -227,12 +228,12 @@ void CSoundMediator::think(int _frames)
|
||||||
s_xmplaySound->setMasterSfxVolume(s_currentVolume[SFX]);
|
s_xmplaySound->setMasterSfxVolume(s_currentVolume[SFX]);
|
||||||
s_volumeDirty[SFX]=false;
|
s_volumeDirty[SFX]=false;
|
||||||
}
|
}
|
||||||
// if(s_volumeDirty[SPEECH])
|
if(s_volumeDirty[SPEECH])
|
||||||
// {
|
{
|
||||||
// int vol=s_currentVolume[SPEECH]<<7;
|
int vol=s_currentVolume[SPEECH]<<7;
|
||||||
// CXAStream::SetVolume(vol,vol);
|
CXAStream::setMasterVolume(vol,vol);
|
||||||
// s_volumeDirty[SPEECH]=false;
|
s_volumeDirty[SPEECH]=false;
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -414,13 +415,25 @@ void CSoundMediator::stopSfx(xmPlayingId _playingId)
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
void CSoundMediator::playSpeech(SpeechEquate _speech)
|
void CSoundMediator::playSpeech(SpeechEquate _speech)
|
||||||
{
|
{
|
||||||
// if(CXAStream::IsPlaying())
|
stopSpeech();
|
||||||
// CXAStream::Stop();
|
CXAStream::PlaySpeech(_speech);
|
||||||
// CXAStream::PlaySpeech(_speech);
|
|
||||||
// s_volumeDirty[SPEECH]=true; // Force a volume update
|
// s_volumeDirty[SPEECH]=true; // Force a volume update
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
void CSoundMediator::stopSpeech()
|
||||||
|
{
|
||||||
|
if(CXAStream::IsPlaying())
|
||||||
|
CXAStream::Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
Function:
|
Function:
|
||||||
Purpose:
|
Purpose:
|
||||||
|
@ -457,6 +470,7 @@ int CSoundMediator::getVolume(VOLUMETYPE _type)
|
||||||
void CSoundMediator::stopAllSound()
|
void CSoundMediator::stopAllSound()
|
||||||
{
|
{
|
||||||
s_xmplaySound->stopAndUnlockAllSound();
|
s_xmplaySound->stopAndUnlockAllSound();
|
||||||
|
CXAStream::Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ public:
|
||||||
|
|
||||||
// Speech interface
|
// Speech interface
|
||||||
static void playSpeech(SpeechEquate _speech);
|
static void playSpeech(SpeechEquate _speech);
|
||||||
|
static void stopSpeech();
|
||||||
|
|
||||||
// Control
|
// Control
|
||||||
static void setVolume(VOLUMETYPE _type,int _val);
|
static void setVolume(VOLUMETYPE _type,int _val);
|
||||||
|
|
|
@ -147,7 +147,7 @@ void CXMPlaySound::think()
|
||||||
PAUL_DBGMSG("=======");
|
PAUL_DBGMSG("=======");
|
||||||
for(int i=0;i<24;i++,ch++)
|
for(int i=0;i<24;i++,ch++)
|
||||||
{
|
{
|
||||||
PAUL_DBGMSG("%02d] u:%s l:%d pid:%d",i,text[ch->m_useType],ch->m_locked,ch->m_playingId);
|
PAUL_DBGMSG("%02d] u:%s l:%d pid:%04x",i,text[ch->m_useType],ch->m_locked,ch->m_playingId);
|
||||||
}
|
}
|
||||||
PAUL_DBGMSG("=======");
|
PAUL_DBGMSG("=======");
|
||||||
dump=false;
|
dump=false;
|
||||||
|
@ -434,12 +434,12 @@ void CXMPlaySound::setStereo(int _stereo)
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
void CXMPlaySound::setVolume(xmPlayingId _playingId,unsigned char _volume)
|
void CXMPlaySound::setVolume(xmPlayingId _playingId,unsigned char _volume)
|
||||||
{
|
{
|
||||||
int i;
|
// int i;
|
||||||
spuChannelUse *ch;
|
spuChannelUse *ch;
|
||||||
int vol;
|
int vol;
|
||||||
|
|
||||||
ch=m_spuChannelUse;
|
ch=&m_spuChannelUse[_playingId&0xff];
|
||||||
for(i=0;i<NUM_SPU_CHANNELS;i++,ch++)
|
// for(i=0;i<NUM_SPU_CHANNELS;i++,ch++)
|
||||||
{
|
{
|
||||||
if(ch->m_playingId==_playingId)
|
if(ch->m_playingId==_playingId)
|
||||||
{
|
{
|
||||||
|
@ -464,12 +464,9 @@ void CXMPlaySound::setVolume(xmPlayingId _playingId,unsigned char _volume)
|
||||||
updateLoopingSfx(ch);
|
updateLoopingSfx(ch);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Shouldn't ever get a locked FREE channel!
|
|
||||||
case FREE:
|
case FREE:
|
||||||
ASSERT(0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CONTINUE:
|
case CONTINUE:
|
||||||
|
ASSERT(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -487,11 +484,11 @@ void CXMPlaySound::setVolume(xmPlayingId _playingId,unsigned char _volume)
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
void CXMPlaySound::setPanning(xmPlayingId _playingId,char _pan)
|
void CXMPlaySound::setPanning(xmPlayingId _playingId,char _pan)
|
||||||
{
|
{
|
||||||
int i;
|
// int i;
|
||||||
spuChannelUse *ch;
|
spuChannelUse *ch;
|
||||||
|
|
||||||
ch=m_spuChannelUse;
|
ch=&m_spuChannelUse[_playingId&0xff];
|
||||||
for(i=0;i<NUM_SPU_CHANNELS;i++,ch++)
|
// for(i=0;i<NUM_SPU_CHANNELS;i++,ch++)
|
||||||
{
|
{
|
||||||
if(ch->m_playingId==_playingId)
|
if(ch->m_playingId==_playingId)
|
||||||
{
|
{
|
||||||
|
@ -514,12 +511,9 @@ void CXMPlaySound::setPanning(xmPlayingId _playingId,char _pan)
|
||||||
updateLoopingSfx(ch);
|
updateLoopingSfx(ch);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Shouldn't ever get a locked FREE channel!
|
|
||||||
case FREE:
|
case FREE:
|
||||||
ASSERT(0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CONTINUE:
|
case CONTINUE:
|
||||||
|
ASSERT(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -582,7 +576,7 @@ xmPlayingId CXMPlaySound::playSong(xmSampleId _sampleId,xmModId _modId)
|
||||||
baseChannel=findSpareChannels(channelCount,255);
|
baseChannel=findSpareChannels(channelCount,255);
|
||||||
if(baseChannel!=-1)
|
if(baseChannel!=-1)
|
||||||
{
|
{
|
||||||
retId=getNextSparePlayingId();
|
retId=getNextSparePlayingId(baseChannel);
|
||||||
vab=&m_xmVabs[_sampleId];
|
vab=&m_xmVabs[_sampleId];
|
||||||
id=XM_Init(vab->m_vabId, // id from XM_VABInit
|
id=XM_Init(vab->m_vabId, // id from XM_VABInit
|
||||||
_modId, // XM id ( as passed to InitXMData )
|
_modId, // XM id ( as passed to InitXMData )
|
||||||
|
@ -644,20 +638,17 @@ void CXMPlaySound::unlockPlayingId(xmPlayingId _playingId)
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
void CXMPlaySound::stopPlayingId(xmPlayingId _playingId)
|
void CXMPlaySound::stopPlayingId(xmPlayingId _playingId)
|
||||||
{
|
{
|
||||||
int i;
|
// int i;
|
||||||
spuChannelUse *ch;
|
spuChannelUse *ch;
|
||||||
|
|
||||||
ch=m_spuChannelUse;
|
ch=&m_spuChannelUse[_playingId&0xff];
|
||||||
for(i=0;i<NUM_SPU_CHANNELS;i++,ch++)
|
// for(i=0;i<NUM_SPU_CHANNELS;i++,ch++)
|
||||||
{
|
{
|
||||||
if(ch->m_playingId==_playingId)
|
if(ch->m_playingId==_playingId)
|
||||||
{
|
{
|
||||||
ASSERT(ch->m_locked!=false); // Cant stop unlocked channels!
|
ASSERT(ch->m_locked!=false); // Cant stop unlocked channels!
|
||||||
switch(ch->m_useType)
|
switch(ch->m_useType)
|
||||||
{
|
{
|
||||||
case SILENT:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SONG:
|
case SONG:
|
||||||
case SFX:
|
case SFX:
|
||||||
{
|
{
|
||||||
|
@ -675,6 +666,7 @@ void CXMPlaySound::stopPlayingId(xmPlayingId _playingId)
|
||||||
XM_StopSample(ch->m_internalId);
|
XM_StopSample(ch->m_internalId);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SILENT:
|
||||||
case FREE:
|
case FREE:
|
||||||
case CONTINUE:
|
case CONTINUE:
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
|
@ -728,7 +720,7 @@ xmPlayingId CXMPlaySound::playSfx(xmSampleId _sampleId,xmModId _modId,int _sfxPa
|
||||||
baseChannel=findSpareChannels(channelCount,_priority);
|
baseChannel=findSpareChannels(channelCount,_priority);
|
||||||
if(baseChannel!=-1)
|
if(baseChannel!=-1)
|
||||||
{
|
{
|
||||||
retId=getNextSparePlayingId();
|
retId=getNextSparePlayingId(baseChannel);
|
||||||
vab=&m_xmVabs[_sampleId];
|
vab=&m_xmVabs[_sampleId];
|
||||||
XM_SetSFXRange(baseChannel,channelCount);
|
XM_SetSFXRange(baseChannel,channelCount);
|
||||||
id=XM_Init(vab->m_vabId, // id from XM_VABInit
|
id=XM_Init(vab->m_vabId, // id from XM_VABInit
|
||||||
|
@ -767,7 +759,7 @@ xmPlayingId CXMPlaySound::playLoopingSfx(xmSampleId _sampleId,xmModId _modId,int
|
||||||
baseChannel=findSpareChannels(1,_priority);
|
baseChannel=findSpareChannels(1,_priority);
|
||||||
if(baseChannel!=-1)
|
if(baseChannel!=-1)
|
||||||
{
|
{
|
||||||
retId=getNextSparePlayingId();
|
retId=getNextSparePlayingId(baseChannel);
|
||||||
//PAUL_DBGMSG("playLoopingSfx %d/- ( on %d-%d )",retId,baseChannel,baseChannel);
|
//PAUL_DBGMSG("playLoopingSfx %d/- ( on %d-%d )",retId,baseChannel,baseChannel);
|
||||||
XM_PlaySample(XM_GetSampleAddress(_sampleId,_soundId),baseChannel,0x3fff,0x3fff,_pitch);
|
XM_PlaySample(XM_GetSampleAddress(_sampleId,_soundId),baseChannel,0x3fff,0x3fff,_pitch);
|
||||||
markChannelsAsActive(baseChannel,1,LOOPINGSFX,retId,baseChannel,_priority);
|
markChannelsAsActive(baseChannel,1,LOOPINGSFX,retId,baseChannel,_priority);
|
||||||
|
@ -788,7 +780,7 @@ xmPlayingId CXMPlaySound::playLoopingSfx(xmSampleId _sampleId,xmModId _modId,int
|
||||||
Params:
|
Params:
|
||||||
Returns:
|
Returns:
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
xmPlayingId CXMPlaySound::getNextSparePlayingId()
|
xmPlayingId CXMPlaySound::getNextSparePlayingId(int _baseChannel)
|
||||||
{
|
{
|
||||||
xmPlayingId validId;
|
xmPlayingId validId;
|
||||||
int i;
|
int i;
|
||||||
|
@ -802,7 +794,7 @@ xmPlayingId CXMPlaySound::getNextSparePlayingId()
|
||||||
nextId=(xmPlayingId)((nextId+1)&0xff); // gives 256 unique id numbers
|
nextId=(xmPlayingId)((nextId+1)&0xff); // gives 256 unique id numbers
|
||||||
|
|
||||||
// Is this id still in use?
|
// Is this id still in use?
|
||||||
validId=nextId;
|
validId=(xmPlayingId)((nextId<<8)+_baseChannel);
|
||||||
ch=m_spuChannelUse;
|
ch=m_spuChannelUse;
|
||||||
for(i=0;i<NUM_SPU_CHANNELS&&validId!=NOT_PLAYING;i++)
|
for(i=0;i<NUM_SPU_CHANNELS&&validId!=NOT_PLAYING;i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
typedef enum {NO_SAMPLE=-1} xmSampleId;
|
typedef enum {NO_SAMPLE=-1} xmSampleId;
|
||||||
typedef enum {NO_SONG=-1} xmModId;
|
typedef enum {NO_SONG=-1} xmModId;
|
||||||
typedef enum {NOT_PLAYING=-1} xmPlayingId;
|
typedef enum {NOT_PLAYING=-1} xmPlayingId;
|
||||||
|
// Note that a playing id is a 16 bit value. Top 8 bits are an ( effectively ) random number and the bottom
|
||||||
|
// 8 bits are the base channel of the playing sound.
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
|
@ -132,7 +134,7 @@ private:
|
||||||
u8 m_vol,m_pan;
|
u8 m_vol,m_pan;
|
||||||
} spuChannelUse;
|
} spuChannelUse;
|
||||||
|
|
||||||
xmPlayingId getNextSparePlayingId();
|
xmPlayingId getNextSparePlayingId(int _baseChannel);
|
||||||
int findSpareChannels(int _channelCount,int _priority);
|
int findSpareChannels(int _channelCount,int _priority);
|
||||||
void markChannelsAsActive(int _baseChannel,int _channelCount,CHANNELUSETYPE _useType,xmPlayingId _playingId,int _internalId,u8 _priority);
|
void markChannelsAsActive(int _baseChannel,int _channelCount,CHANNELUSETYPE _useType,xmPlayingId _playingId,int _internalId,u8 _priority);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue