This commit is contained in:
Paul 2001-07-09 15:32:51 +00:00
parent 08d3b3132f
commit bb895ddd22
5 changed files with 51 additions and 45 deletions

View File

@ -306,6 +306,21 @@ CFX *NewFX=CFX::Create(Type);
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
void CFX::leftThinkZone(int _frames)
{
if(Flags & FX_FLAG_NO_THINK_KILL)
{
killFX();
}
if( m_soundId != NOT_PLAYING )
{
CSoundMediator::stopAndUnlockSfx(m_soundId);
m_soundId=NOT_PLAYING;
}
}
/*****************************************************************************/
void CFX::init()
{
@ -404,14 +419,15 @@ void CFX::killFX()
{
CFX::Create((CFX::FX_TYPE)AfterEffect,getPos());
}
if( m_soundId != NOT_PLAYING )
{
CSoundMediator::stopAndUnlockSfx(m_soundId);
m_soundId=NOT_PLAYING;
}
if (EndSnd)
{
CSoundMediator::playSfx( (CSoundMediator::SFXID)EndSnd,false);
}
if( m_soundId != NOT_PLAYING )
{
CSoundMediator::stopAndUnlockSfx(m_soundId );
}
}

View File

@ -102,7 +102,7 @@ static CFX *Create(const FX_TYPE Type,CThing *Parent);
static CFX *Create(const FX_TYPE Type,DVECTOR const &Pos);
bool alwaysThink() {return(Flags & FX_FLAG_SCREEN_FX);}
void leftThinkZone(int _frames) {if (Flags & FX_FLAG_NO_THINK_KILL) killFX();}
void leftThinkZone(int _frames);
void init();
virtual void init(DVECTOR const &Pos);

View File

@ -31,7 +31,6 @@ void CFXSteam::init(DVECTOR const &_Pos)
DieOut=false;
SetSize(DefSize);
IsHorizontal=false;
m_soundId=CSoundMediator::playSfx( CSoundMediator::SFX_HAZARD__STEAM,true);
}
/*****************************************************************************/
@ -112,12 +111,21 @@ int TotalLife=0;
TotalLife+=ThisElem.Shade;
}
if(m_soundId==NOT_PLAYING)
{
m_soundId=CSoundMediator::playSfx( CSoundMediator::SFX_HAZARD__STEAM,true);
}
else
{
if(!CSoundMediator::isSfxStillPlaying(m_soundId))
{
CSoundMediator::stopAndUnlockSfx(m_soundId);
m_soundId=NOT_PLAYING;
}
}
if (DieOut && TotalLife==0)
{
if( m_soundId != NOT_PLAYING )
{
CSoundMediator::stopAndUnlockSfx(m_soundId );
}
setToShutdown();
}
}

View File

@ -440,6 +440,7 @@ void CGameScene::think(int _frames)
// Song is loaded/dumped by the level, and played from here. This just gives some
// better timing over when it starts (pkg)
CSoundMediator::playSong();
CSoundMediator::setCanPlaySfx(true);
m_musicStarted=true;
}
@ -702,10 +703,12 @@ int CGameScene::getTotalSpatCountForThisLevel()
/*****************************************************************************/
void CGameScene::respawnLevel()
{
CSoundMediator::setCanPlaySfx(false);
m_player->respawn();
Level.respawnLevel();
m_gamestate=GAMESTATE_SHOWING_LIVES;
m_showingLivesTimer=0;
CSoundMediator::setCanPlaySfx(true);
}
@ -733,6 +736,8 @@ void CGameScene::hitBossArenaTrigger()
/*****************************************************************************/
void CGameScene::initLevel()
{
CSoundMediator::setCanPlaySfx(false);
SYSTEM_DBGMSG("InitLevel\n");
CThingManager::init();

View File

@ -191,22 +191,12 @@ void CXMPlaySound::think()
case SILENT:
if(!ch->m_locked)
{
if(XM_GetFeedback(ch->m_internalId,&fb))
do
{
///PAUL_DBGMSG("freeing channels:");
///int j=i;
do
{
///PAUL_DBGMSG(" %d (%d)",j++,ch->m_playingId);
ch->m_useType=FREE;
ch++;
}
while(ch->m_useType==CONTINUE);
ch->m_useType=FREE;
ch++;
}
/// else
///{
/// PAUL_DBGMSG("channel %d not stopped",i);
///}
while(ch->m_useType==CONTINUE);
}
break;
@ -215,13 +205,14 @@ void CXMPlaySound::think()
case SONG:
case SFX:
if(XM_GetFeedback(ch->m_internalId,&fb))
// XM_GetFeedback(ch->m_internalId,&fb);
// if(fb.Status==XM_STOPPED)
{
// Just mark it as silent, if it's unlocked then it'll die next frame
ch->m_useType=SILENT;
// And kill it in the player
XM_Quit(ch->m_internalId);
///PAUL_DBGMSG("marked %d (%d) as silent",i,ch->m_internalId);
}
break;
@ -706,7 +697,6 @@ xmPlayingId CXMPlaySound::playSong(xmSampleId _sampleId,xmModId _modId,int _star
_startPattern); // Where to start from
markChannelsAsActive(baseChannel,channelCount,SONG,retId,id,255);
setVolume(retId,MAX_VOLUME);
//PAUL_DBGMSG("playSong %d/%d ( on %d-%d )",retId,id,baseChannel,baseChannel+channelCount-1);
}
else
{
@ -751,14 +741,8 @@ void CXMPlaySound::unlockPlayingId(xmPlayingId _playingId)
ch=&m_spuChannelUse[_playingId&0xff];
if(ch->m_playingId==_playingId)
{
//PAUL_DBGMSG("unlocking %d",_playingId);
ASSERT(ch->m_locked!=false); // Can't do this on an unlocked sound!
do
{
ch->m_locked=false;
ch++;
}
while(ch->m_useType==CONTINUE);
ch->m_locked=false;
return;
}
@ -785,19 +769,15 @@ void CXMPlaySound::stopPlayingId(xmPlayingId _playingId)
case SONG:
case SFX:
{
// XM_Feedback fb;
// do
// {
XM_PlayStop(ch->m_internalId);
// XM_GetFeedback(ch->m_internalId,&fb);
// }
// while(fb.Status!=XM_STOPPED);
XM_PlayStop(ch->m_internalId);
XM_Quit(ch->m_internalId);
ch->m_useType=SILENT;
}
break;
case LOOPINGSFX:
XM_StopSample(ch->m_internalId);
ch->m_useType=SILENT;
break;
case SILENT:
@ -809,7 +789,6 @@ void CXMPlaySound::stopPlayingId(xmPlayingId _playingId)
break;
}
ch->m_useType=SILENT;
return;
}
@ -853,17 +832,16 @@ xmPlayingId CXMPlaySound::playSfx(xmSampleId _sampleId,xmModId _modId,int _sfxPa
{
retId=getNextSparePlayingId(baseChannel);
vab=&m_xmVabs[_sampleId];
XM_SetSFXRange(baseChannel,channelCount);
// XM_SetSFXRange(baseChannel,channelCount);
id=XM_Init(vab->m_vabId, // id from XM_VABInit
_modId, // XM id ( as passed to InitXMData )
-1, // Let xmplay give us a song id
-1, // Use SFX range to get first channel
baseChannel, // Base cahnnel to play on
XM_NoLoop, // One-shot
_playMask, // Play mask
XM_SFX, // SFX
_sfxPattern); // SFX pattern to play
XM_ClearSFXRange();
//PAUL_DBGMSG("playSfx %d/%d ( on %d-%d )",retId,id,baseChannel,baseChannel+channelCount-1);
markChannelsAsActive(baseChannel,channelCount,SFX,retId,id,_priority);
setVolume(retId,MAX_VOLUME);
}
@ -891,7 +869,6 @@ xmPlayingId CXMPlaySound::playLoopingSfx(xmSampleId _sampleId,xmModId _modId,int
if(baseChannel!=-1)
{
retId=getNextSparePlayingId(baseChannel);
//PAUL_DBGMSG("playLoopingSfx %d/- ( on %d-%d )",retId,baseChannel,baseChannel);
XM_PlaySample(XM_GetSampleAddress(_sampleId,_soundId),baseChannel,0x3fff,0x3fff,_pitch);
markChannelsAsActive(baseChannel,1,LOOPINGSFX,retId,baseChannel,_priority);
setVolume(retId,MAX_VOLUME);