From aad1689a445bff618f83e4de7a133954010cb79c Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 12 Oct 2000 15:18:47 +0000 Subject: [PATCH] --- source/paul/paul.cpp | 13 ++-- source/sound/cdxa.cpp | 86 ++++++++++---------- source/sound/cdxa.h | 169 +++++++++++++++++++++------------------- source/sound/sound.cpp | 38 ++++++--- source/sound/sound.h | 1 + source/sound/xmplay.cpp | 44 +++++------ source/sound/xmplay.h | 4 +- 7 files changed, 187 insertions(+), 168 deletions(-) diff --git a/source/paul/paul.cpp b/source/paul/paul.cpp index e6d9c2c4c..82173f07b 100644 --- a/source/paul/paul.cpp +++ b/source/paul/paul.cpp @@ -139,6 +139,7 @@ int pkill=0; int mvol=10; int svol=255; VECTOR ppos; +int psp=0; void CPaulScene::think() { @@ -174,9 +175,11 @@ void CPaulScene::think() } if(pad&PAD_START) { - PAUL_DBGMSG("stop loopers.."); - CSoundMediator::stopSfx((xmPlayingId)ploopid1); - CSoundMediator::stopSfx((xmPlayingId)ploopid2); +// PAUL_DBGMSG("stop loopers.."); +// CSoundMediator::stopSfx((xmPlayingId)ploopid1); +// CSoundMediator::stopSfx((xmPlayingId)ploopid2); + PAUL_DBGMSG("speech..\n"); + CSoundMediator::playSpeech((SpeechEquate)psp); } if(pad&PAD_R2) { @@ -218,12 +221,12 @@ void CPaulScene::think() if(svol 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; SpuCommonAttr Attr; -// SsSetSerialVol(SS_SERIAL_A,0,0); - -// Attr.mask = (SPU_COMMON_CDVOLL|SPU_COMMON_CDVOLR|SPU_COMMON_CDMIX); -// Attr.cd.volume.left =0; -// Attr.cd.volume.right=0; -// Attr.cd.mix=SPU_ON; -// SpuSetCommonAttr(&Attr); -SpuSetCommonCDVolume(0,0); -SpuSetCommonCDMix(SPU_ON); + SpuSetCommonCDVolume(0,0); + SpuSetCommonCDMix(SPU_ON); - CDVol.val0 = 0; // CdL -> SpuL - CDVol.val1 = 0; // CdL -> SpuR - CDVol.val2 = 0; // CdR -> SpuR - CDVol.val3 = 0; // CdR -> SpuL - CdMix(&CDVol); - + CDVol.val0 = 0; // CdL -> SpuL + CDVol.val1 = 0; // CdL -> SpuR + CDVol.val2 = 0; // CdR -> SpuR + CDVol.val3 = 0; // CdR -> SpuL + 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; +} + diff --git a/source/sound/cdxa.h b/source/sound/cdxa.h index b81acdd88..6419dfa4d 100644 --- a/source/sound/cdxa.h +++ b/source/sound/cdxa.h @@ -9,104 +9,113 @@ #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<think(); @@ -227,12 +228,12 @@ void CSoundMediator::think(int _frames) s_xmplaySound->setMasterSfxVolume(s_currentVolume[SFX]); s_volumeDirty[SFX]=false; } -// if(s_volumeDirty[SPEECH]) -// { -// int vol=s_currentVolume[SPEECH]<<7; -// CXAStream::SetVolume(vol,vol); -// s_volumeDirty[SPEECH]=false; -// } + if(s_volumeDirty[SPEECH]) + { + int vol=s_currentVolume[SPEECH]<<7; + CXAStream::setMasterVolume(vol,vol); + s_volumeDirty[SPEECH]=false; + } } @@ -414,13 +415,25 @@ void CSoundMediator::stopSfx(xmPlayingId _playingId) ---------------------------------------------------------------------- */ void CSoundMediator::playSpeech(SpeechEquate _speech) { -// if(CXAStream::IsPlaying()) -// CXAStream::Stop(); -// CXAStream::PlaySpeech(_speech); + stopSpeech(); + CXAStream::PlaySpeech(_speech); // s_volumeDirty[SPEECH]=true; // Force a volume update } +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CSoundMediator::stopSpeech() +{ + if(CXAStream::IsPlaying()) + CXAStream::Stop(); +} + + /*---------------------------------------------------------------------- Function: Purpose: @@ -457,6 +470,7 @@ int CSoundMediator::getVolume(VOLUMETYPE _type) void CSoundMediator::stopAllSound() { s_xmplaySound->stopAndUnlockAllSound(); + CXAStream::Stop(); } diff --git a/source/sound/sound.h b/source/sound/sound.h index e432e0baa..1aa864030 100644 --- a/source/sound/sound.h +++ b/source/sound/sound.h @@ -105,6 +105,7 @@ public: // Speech interface static void playSpeech(SpeechEquate _speech); + static void stopSpeech(); // Control static void setVolume(VOLUMETYPE _type,int _val); diff --git a/source/sound/xmplay.cpp b/source/sound/xmplay.cpp index 10cff744f..519ceddd2 100644 --- a/source/sound/xmplay.cpp +++ b/source/sound/xmplay.cpp @@ -147,7 +147,7 @@ void CXMPlaySound::think() 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("%02d] u:%s l:%d pid:%04x",i,text[ch->m_useType],ch->m_locked,ch->m_playingId); } PAUL_DBGMSG("======="); dump=false; @@ -434,12 +434,12 @@ void CXMPlaySound::setStereo(int _stereo) ---------------------------------------------------------------------- */ void CXMPlaySound::setVolume(xmPlayingId _playingId,unsigned char _volume) { - int i; +// int i; spuChannelUse *ch; int vol; - ch=m_spuChannelUse; - for(i=0;im_playingId==_playingId) { @@ -464,12 +464,9 @@ void CXMPlaySound::setVolume(xmPlayingId _playingId,unsigned char _volume) updateLoopingSfx(ch); break; - // Shouldn't ever get a locked FREE channel! case FREE: - ASSERT(0); - break; - case CONTINUE: + ASSERT(0); break; } return; @@ -487,11 +484,11 @@ void CXMPlaySound::setVolume(xmPlayingId _playingId,unsigned char _volume) ---------------------------------------------------------------------- */ void CXMPlaySound::setPanning(xmPlayingId _playingId,char _pan) { - int i; +// int i; spuChannelUse *ch; - ch=m_spuChannelUse; - for(i=0;im_playingId==_playingId) { @@ -514,12 +511,9 @@ void CXMPlaySound::setPanning(xmPlayingId _playingId,char _pan) updateLoopingSfx(ch); break; - // Shouldn't ever get a locked FREE channel! case FREE: - ASSERT(0); - break; - case CONTINUE: + ASSERT(0); break; } return; @@ -582,7 +576,7 @@ xmPlayingId CXMPlaySound::playSong(xmSampleId _sampleId,xmModId _modId) baseChannel=findSpareChannels(channelCount,255); if(baseChannel!=-1) { - retId=getNextSparePlayingId(); + retId=getNextSparePlayingId(baseChannel); vab=&m_xmVabs[_sampleId]; id=XM_Init(vab->m_vabId, // id from XM_VABInit _modId, // XM id ( as passed to InitXMData ) @@ -644,20 +638,17 @@ void CXMPlaySound::unlockPlayingId(xmPlayingId _playingId) ---------------------------------------------------------------------- */ void CXMPlaySound::stopPlayingId(xmPlayingId _playingId) { - int i; +// int i; spuChannelUse *ch; - ch=m_spuChannelUse; - for(i=0;im_playingId==_playingId) { ASSERT(ch->m_locked!=false); // Cant stop unlocked channels! switch(ch->m_useType) { - case SILENT: - break; - case SONG: case SFX: { @@ -675,6 +666,7 @@ void CXMPlaySound::stopPlayingId(xmPlayingId _playingId) XM_StopSample(ch->m_internalId); break; + case SILENT: case FREE: case CONTINUE: ASSERT(0); @@ -728,7 +720,7 @@ xmPlayingId CXMPlaySound::playSfx(xmSampleId _sampleId,xmModId _modId,int _sfxPa baseChannel=findSpareChannels(channelCount,_priority); if(baseChannel!=-1) { - retId=getNextSparePlayingId(); + retId=getNextSparePlayingId(baseChannel); vab=&m_xmVabs[_sampleId]; XM_SetSFXRange(baseChannel,channelCount); 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); if(baseChannel!=-1) { - retId=getNextSparePlayingId(); + 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); @@ -788,7 +780,7 @@ xmPlayingId CXMPlaySound::playLoopingSfx(xmSampleId _sampleId,xmModId _modId,int Params: Returns: ---------------------------------------------------------------------- */ -xmPlayingId CXMPlaySound::getNextSparePlayingId() +xmPlayingId CXMPlaySound::getNextSparePlayingId(int _baseChannel) { xmPlayingId validId; int i; @@ -802,7 +794,7 @@ xmPlayingId CXMPlaySound::getNextSparePlayingId() nextId=(xmPlayingId)((nextId+1)&0xff); // gives 256 unique id numbers // Is this id still in use? - validId=nextId; + validId=(xmPlayingId)((nextId<<8)+_baseChannel); ch=m_spuChannelUse; for(i=0;i