This commit is contained in:
parent
45a65d892c
commit
27b7ee5531
3 changed files with 145 additions and 44 deletions
|
@ -74,7 +74,8 @@ char *s_mem[3];
|
||||||
Params:
|
Params:
|
||||||
Returns:
|
Returns:
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
int ploopid=0;
|
int ploopid1=0;
|
||||||
|
int ploopid2=0;
|
||||||
void CPaulScene::init()
|
void CPaulScene::init()
|
||||||
{
|
{
|
||||||
s_fontBank.initialise(&standardFont);
|
s_fontBank.initialise(&standardFont);
|
||||||
|
@ -89,7 +90,8 @@ void CPaulScene::init()
|
||||||
//CXAStream::Init();
|
//CXAStream::Init();
|
||||||
PAUL_DBGMSG("initialised..");
|
PAUL_DBGMSG("initialised..");
|
||||||
|
|
||||||
ploopid=CSoundMediator::playSfx(0);
|
ploopid1=CSoundMediator::playSfx(0);
|
||||||
|
ploopid2=CSoundMediator::playSfx(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,14 +174,22 @@ void CPaulScene::think()
|
||||||
}
|
}
|
||||||
if(pad&PAD_START)
|
if(pad&PAD_START)
|
||||||
{
|
{
|
||||||
PAUL_DBGMSG("stop %d",pkill);
|
PAUL_DBGMSG("stop loopers..");
|
||||||
CSoundMediator::stopSfx((xmPlayingId)pkill);
|
CSoundMediator::stopSfx((xmPlayingId)ploopid1);
|
||||||
|
CSoundMediator::stopSfx((xmPlayingId)ploopid2);
|
||||||
}
|
}
|
||||||
if(pad&PAD_R2)
|
if(pad&PAD_R2)
|
||||||
{
|
{
|
||||||
PAUL_DBGMSG("stop all");
|
PAUL_DBGMSG("stop all");
|
||||||
CSoundMediator::stopAllSound();
|
CSoundMediator::stopAllSound();
|
||||||
}
|
}
|
||||||
|
#ifdef __USER_paul__
|
||||||
|
if(pad&PAD_L2)
|
||||||
|
{
|
||||||
|
extern int dump;
|
||||||
|
dump=true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//CSoundMediator::setposition((xmPlayingId)ploopid,&ppos);
|
//CSoundMediator::setposition((xmPlayingId)ploopid,&ppos);
|
||||||
|
|
||||||
|
|
|
@ -100,8 +100,13 @@ void CXMPlaySound::initialise()
|
||||||
|
|
||||||
for(i=0;i<NUM_SPU_CHANNELS;i++)
|
for(i=0;i<NUM_SPU_CHANNELS;i++)
|
||||||
{
|
{
|
||||||
m_spuChannelUse[i].m_useType=SILENT;
|
m_spuChannelUse[i].m_useType=FREE;
|
||||||
|
m_spuChannelUse[i].m_playingId=NOT_PLAYING;
|
||||||
|
m_spuChannelUse[i].m_internalId=0;
|
||||||
|
m_spuChannelUse[i].m_priority=0;
|
||||||
m_spuChannelUse[i].m_locked=false;
|
m_spuChannelUse[i].m_locked=false;
|
||||||
|
m_spuChannelUse[i].m_vol=MIN_VOLUME;
|
||||||
|
m_spuChannelUse[i].m_pan=PAN_CENTRE;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_masterSongVolume=0;
|
m_masterSongVolume=0;
|
||||||
|
@ -129,8 +134,26 @@ void CXMPlaySound::shutdown()
|
||||||
Params:
|
Params:
|
||||||
Returns:
|
Returns:
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
|
#ifdef __USER_paul__
|
||||||
|
int dump=false;
|
||||||
|
#endif
|
||||||
void CXMPlaySound::think()
|
void CXMPlaySound::think()
|
||||||
{
|
{
|
||||||
|
#ifdef __USER_paul__
|
||||||
|
if(dump)
|
||||||
|
{
|
||||||
|
static char *text[]={"SONG","SFX","LOOPINGSFX","SILENT","FREE","CONTINUE"};
|
||||||
|
spuChannelUse *ch=m_spuChannelUse;
|
||||||
|
PAUL_DBGMSG("=======");
|
||||||
|
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("=======");
|
||||||
|
dump=false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
int id;
|
int id;
|
||||||
spuChannelUse *ch;
|
spuChannelUse *ch;
|
||||||
|
@ -138,29 +161,54 @@ void CXMPlaySound::think()
|
||||||
|
|
||||||
// Check to see if any of the sounds have finished
|
// Check to see if any of the sounds have finished
|
||||||
id=-1;
|
id=-1;
|
||||||
ch=m_spuChannelUse;
|
|
||||||
for(i=0;i<NUM_SPU_CHANNELS;i++)
|
for(i=0;i<NUM_SPU_CHANNELS;i++)
|
||||||
{
|
{
|
||||||
// Only unlocked stuff needs to be checked
|
ch=&m_spuChannelUse[i]; // I know!
|
||||||
if(ch->m_locked==false&&ch->m_useType!=SILENT)
|
switch(ch->m_useType)
|
||||||
{
|
{
|
||||||
id=ch->m_playingId;
|
// Silent and unlocked sounds can be freed
|
||||||
if(id!=-1)
|
case SILENT:
|
||||||
{
|
if(!ch->m_locked)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
PAUL_DBGMSG("freed channel %d ( %d )",i,ch->m_playingId);
|
||||||
|
ch->m_useType=FREE;
|
||||||
|
#ifdef __VERSION_DEBUG__
|
||||||
|
ch->m_internalId=0;
|
||||||
|
ch->m_playingId=NOT_PLAYING;
|
||||||
|
ch->m_priority=0;
|
||||||
|
ch->m_locked=false;
|
||||||
|
ch->m_vol=MIN_VOLUME;
|
||||||
|
ch->m_pan=PAN_CENTRE;
|
||||||
|
#endif
|
||||||
|
ch++;
|
||||||
|
}
|
||||||
|
while(ch->m_useType==CONTINUE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
// See if these have finished playing
|
||||||
|
case SONG:
|
||||||
|
case SFX:
|
||||||
if(XM_GetFeedback(ch->m_internalId,&fb))
|
if(XM_GetFeedback(ch->m_internalId,&fb))
|
||||||
{
|
{
|
||||||
//PAUL_DBGMSG("%d finished.. ( was on chnl %d )",id,i);
|
do
|
||||||
while(ch->m_playingId==id&&i<NUM_SPU_CHANNELS)
|
|
||||||
{
|
{
|
||||||
|
// Just mark it as silent, if it's unlocked then it'll die next frame
|
||||||
ch->m_useType=SILENT;
|
ch->m_useType=SILENT;
|
||||||
ch++;
|
ch++;
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
ch--;
|
while(ch->m_useType==CONTINUE);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
|
|
||||||
|
case LOOPINGSFX:
|
||||||
|
case FREE:
|
||||||
|
case CONTINUE:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
ch++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,6 +463,14 @@ void CXMPlaySound::setVolume(xmPlayingId _playingId,unsigned char _volume)
|
||||||
case LOOPINGSFX:
|
case LOOPINGSFX:
|
||||||
updateLoopingSfx(ch);
|
updateLoopingSfx(ch);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Shouldn't ever get a locked FREE channel!
|
||||||
|
case FREE:
|
||||||
|
ASSERT(0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CONTINUE:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -457,6 +513,14 @@ void CXMPlaySound::setPanning(xmPlayingId _playingId,char _pan)
|
||||||
case LOOPINGSFX:
|
case LOOPINGSFX:
|
||||||
updateLoopingSfx(ch);
|
updateLoopingSfx(ch);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Shouldn't ever get a locked FREE channel!
|
||||||
|
case FREE:
|
||||||
|
ASSERT(0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CONTINUE:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -475,20 +539,21 @@ void CXMPlaySound::setPanning(xmPlayingId _playingId,char _pan)
|
||||||
void CXMPlaySound::stopAndUnlockAllSound()
|
void CXMPlaySound::stopAndUnlockAllSound()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
spuChannelUse *ch;
|
spuChannelUse *ch;
|
||||||
|
|
||||||
ch=m_spuChannelUse;
|
ch=m_spuChannelUse;
|
||||||
for(i=0;i<NUM_SPU_CHANNELS;i++,ch++)
|
for(i=0;i<NUM_SPU_CHANNELS;i++,ch++)
|
||||||
{
|
{
|
||||||
if(ch->m_useType!=SILENT)
|
if(ch->m_useType==SONG||
|
||||||
|
ch->m_useType==SFX||
|
||||||
|
ch->m_useType==LOOPINGSFX)
|
||||||
{
|
{
|
||||||
int oldLock=ch->m_locked; // hmm..
|
ch->m_locked=true; // hmm.. not too ugly I suppose
|
||||||
ch->m_locked=true; // not too..
|
setVolume(ch->m_playingId,0);
|
||||||
stopPlayingId(ch->m_playingId);
|
stopPlayingId(ch->m_playingId);
|
||||||
ch->m_locked=oldLock; // ..ugly I suppose
|
|
||||||
|
|
||||||
// Need to unlock too
|
// Need to unlock too
|
||||||
if(oldLock)unlockPlayingId(ch->m_playingId);
|
unlockPlayingId(ch->m_playingId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -558,11 +623,12 @@ void CXMPlaySound::unlockPlayingId(xmPlayingId _playingId)
|
||||||
{
|
{
|
||||||
//PAUL_DBGMSG("unlocking %d",_playingId);
|
//PAUL_DBGMSG("unlocking %d",_playingId);
|
||||||
ASSERT(ch->m_locked!=false);
|
ASSERT(ch->m_locked!=false);
|
||||||
while(ch->m_playingId==_playingId)
|
do
|
||||||
{
|
{
|
||||||
ch->m_locked=false;
|
ch->m_locked=false;
|
||||||
ch++;
|
ch++;
|
||||||
}
|
}
|
||||||
|
while(ch->m_useType==CONTINUE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -593,23 +659,34 @@ void CXMPlaySound::stopPlayingId(xmPlayingId _playingId)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SONG:
|
case SONG:
|
||||||
XM_PlayStop(ch->m_internalId);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFX:
|
case SFX:
|
||||||
XM_PlayStop(ch->m_internalId);
|
{
|
||||||
|
XM_Feedback fb;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
XM_PlayStop(ch->m_internalId);
|
||||||
|
XM_GetFeedback(ch->m_internalId,&fb);
|
||||||
|
}
|
||||||
|
while(fb.Status!=XM_STOPPED);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LOOPINGSFX:
|
case LOOPINGSFX:
|
||||||
XM_StopSample(ch->m_internalId);
|
XM_StopSample(ch->m_internalId);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case FREE:
|
||||||
|
case CONTINUE:
|
||||||
|
ASSERT(0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(ch->m_playingId==_playingId)
|
do
|
||||||
{
|
{
|
||||||
ch->m_useType=SILENT;
|
ch->m_useType=SILENT;
|
||||||
ch++;
|
ch++;
|
||||||
}
|
}
|
||||||
|
while(ch->m_useType==CONTINUE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -758,7 +835,7 @@ int CXMPlaySound::findSpareChannels(int _channelCount,int _priority)
|
||||||
valid=true;
|
valid=true;
|
||||||
for(j=i;j<i+_channelCount&&valid;j++)
|
for(j=i;j<i+_channelCount&&valid;j++)
|
||||||
{
|
{
|
||||||
if(m_spuChannelUse[j].m_useType!=SILENT) valid=false; // pkg - tidy up
|
if(m_spuChannelUse[j].m_useType!=FREE) valid=false;
|
||||||
}
|
}
|
||||||
if(valid) return i;
|
if(valid) return i;
|
||||||
i=j;
|
i=j;
|
||||||
|
@ -780,20 +857,31 @@ int CXMPlaySound::findSpareChannels(int _channelCount,int _priority)
|
||||||
void CXMPlaySound::markChannelsAsActive(int _baseChannel,int _channelCount,CHANNELUSETYPE _useType,xmPlayingId _playingId,int _internalId,u8 _priority)
|
void CXMPlaySound::markChannelsAsActive(int _baseChannel,int _channelCount,CHANNELUSETYPE _useType,xmPlayingId _playingId,int _internalId,u8 _priority)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
spuChannelUse *ch,details;
|
spuChannelUse *ch;
|
||||||
|
|
||||||
|
|
||||||
details.m_useType=_useType;
|
|
||||||
details.m_internalId=_internalId;
|
|
||||||
details.m_playingId=_playingId;
|
|
||||||
details.m_priority=_priority;
|
|
||||||
details.m_locked=true;
|
|
||||||
details.m_vol=MAX_VOLUME;
|
|
||||||
details.m_pan=PAN_CENTRE;
|
|
||||||
|
|
||||||
ch=&m_spuChannelUse[_baseChannel];
|
ch=&m_spuChannelUse[_baseChannel];
|
||||||
for(i=_baseChannel;i<_baseChannel+_channelCount;i++,ch++)
|
ch->m_useType=_useType;
|
||||||
*ch=details;
|
ch->m_internalId=_internalId;
|
||||||
|
ch->m_playingId=_playingId;
|
||||||
|
ch->m_priority=_priority;
|
||||||
|
ch->m_locked=true;
|
||||||
|
ch->m_vol=MAX_VOLUME;
|
||||||
|
ch->m_pan=PAN_CENTRE;
|
||||||
|
|
||||||
|
ch++;
|
||||||
|
for(i=_baseChannel+1;i<_baseChannel+_channelCount;i++,ch++)
|
||||||
|
{
|
||||||
|
ch->m_useType=CONTINUE;
|
||||||
|
#ifdef __VERSION_DEBUG__
|
||||||
|
ch->m_internalId=0;
|
||||||
|
ch->m_playingId=NOT_PLAYING;
|
||||||
|
ch->m_priority=0;
|
||||||
|
ch->m_locked=false;
|
||||||
|
ch->m_vol=MIN_VOLUME;
|
||||||
|
ch->m_pan=PAN_CENTRE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -95,10 +95,13 @@ private:
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
SILENT,
|
|
||||||
SONG,
|
SONG,
|
||||||
SFX,
|
SFX,
|
||||||
LOOPINGSFX,
|
LOOPINGSFX,
|
||||||
|
|
||||||
|
SILENT, // Channel is silent
|
||||||
|
FREE, // Channel is free for re-allocation
|
||||||
|
CONTINUE, // Channel is a continuation of the previous channel
|
||||||
} CHANNELUSETYPE;
|
} CHANNELUSETYPE;
|
||||||
|
|
||||||
// Internal representation of loaded mods
|
// Internal representation of loaded mods
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue