diff --git a/source/sound/sound.cpp b/source/sound/sound.cpp index e0e3792b5..3fa1df958 100644 --- a/source/sound/sound.cpp +++ b/source/sound/sound.cpp @@ -1,3 +1,10 @@ +/* +reverb ( trigger from map? ) +position +adjust channels ( watery-mario64 style music changes ) +*/ + + /*========================================================================= sound.cpp @@ -22,6 +29,7 @@ #include "system\dbg.h" #endif + /* Std Lib ------- */ @@ -44,7 +52,7 @@ typedef struct XMFILEDATA typedef struct SFXDETAILS { int m_channelMask; - int m_pattern; // ..or instrument for loopers + int m_pattern; // ..or instrument number for loopers int m_looping; }; @@ -57,39 +65,7 @@ typedef struct SFXDETAILS Vars ---- */ -static XMFILEDATA s_xmSongData[CSoundMediator::NUM_SONGIDS]= -{ - { MUSIC_HYPERMMX_VH, MUSIC_HYPERMMX_VB, MUSIC_HYPERMMX_PXM }, // HYPERMMX - { MUSIC_DROPPOP_VH, MUSIC_DROPPOP_VB, MUSIC_DROPPOP_PXM }, // DROPPOP - { MUSIC_MUSIC_VH, MUSIC_MUSIC_VB, MUSIC_MUSIC_PXM }, // MUSIC -}; - -static XMFILEDATA s_xmSfxData[CSoundMediator::NUM_SFXBANKIDS]= -{ - { SFX_INGAME_VH, SFX_INGAME_VB, SFX_INGAME_PXM }, // INGAME -}; - -static SFXDETAILS s_sfxDetails[]= -{ - { 1, 6, 1 }, - { 1, 1, 0 }, - { 1, 2, 0 }, - { 1, 0, 1 }, -}; - - - - - - - - - - - - - - +// Static stuff for CSoundMediator int CSoundMediator::s_initialised=false; int CSoundMediator::s_currentVolume[CSoundMediator::NUM_VOLUMETYPES]; @@ -106,7 +82,34 @@ static CSpuSound *s_spuSound; static CXMPlaySound *s_xmplaySound; +// Songs +static XMFILEDATA s_xmSongData[CSoundMediator::NUM_SONGIDS]= +{ + { MUSIC_HYPERMMX_VH, MUSIC_HYPERMMX_VB, MUSIC_HYPERMMX_PXM }, // HYPERMMX + { MUSIC_DROPPOP_VH, MUSIC_DROPPOP_VB, MUSIC_DROPPOP_PXM }, // DROPPOP + { MUSIC_MUSIC_VH, MUSIC_MUSIC_VB, MUSIC_MUSIC_PXM }, // MUSIC +}; +// SFX banks +static XMFILEDATA s_xmSfxData[CSoundMediator::NUM_SFXBANKIDS]= +{ + { SFX_INGAME_VH, SFX_INGAME_VB, SFX_INGAME_PXM }, // INGAME +}; + +// Individual SFX details +static SFXDETAILS s_sfxDetails[]= +{ + { 1, 6, 1 }, + { 1, 1, 0 }, + { 1, 2, 0 }, + { 1, 0, 1 }, +}; + + + +// +int s_songChannelCount=10; +// /*---------------------------------------------------------------------- @@ -261,7 +264,7 @@ void CSoundMediator::playSong() ASSERT(s_songModId!=NO_SONG); ASSERT(s_songPlayingId==NOT_PLAYING); - s_songPlayingId=s_xmplaySound->playSong(s_songSampleId,s_songModId,10); // pkg !? + s_songPlayingId=s_xmplaySound->playSong(s_songSampleId,s_songModId,s_songChannelCount); s_volumeDirty[SONG]=true; // Force a volume update } @@ -334,7 +337,11 @@ xmPlayingId CSoundMediator::playSfx(int _sfxId) else { playId=s_xmplaySound->playSfx(s_sfxSampleId,s_sfxModId,sfx->m_pattern,sfx->m_channelMask,20); - if(playId!=NOT_PLAYING)s_xmplaySound->unlockPlayingId(playId); // We really don't care about one-shot sfx.. + if(playId!=NOT_PLAYING) + { + s_xmplaySound->unlockPlayingId(playId); // We really don't care about one-shot sfx.. + playId=NOT_PLAYING; + } } s_volumeDirty[SFX]=true; // Force a volume update @@ -348,10 +355,10 @@ xmPlayingId CSoundMediator::playSfx(int _sfxId) Params: Returns: ---------------------------------------------------------------------- */ -void CSoundMediator::stopSfx(xmPlayingId _id) +void CSoundMediator::stopSfx(xmPlayingId _playingId) { - s_xmplaySound->stopPlayingId(_id); - s_xmplaySound->unlockPlayingId(_id); + s_xmplaySound->stopPlayingId(_playingId); + s_xmplaySound->unlockPlayingId(_playingId); } diff --git a/source/sound/sound.h b/source/sound/sound.h index e83c8beb4..7f160d2e9 100644 --- a/source/sound/sound.h +++ b/source/sound/sound.h @@ -95,7 +95,7 @@ public: static void setSfxBank(SFXBANKID _bankId); static xmPlayingId playSfx(int _sfxId); // static void setposition(int _playId,vector pos ); - static void stopSfx(xmPlayingId _id); + static void stopSfx(xmPlayingId _playingId); // Speech interface static void playSpeech(SpeechEquate _speech); diff --git a/source/sound/xmplay.cpp b/source/sound/xmplay.cpp index d51c02efb..03bf4d10e 100644 --- a/source/sound/xmplay.cpp +++ b/source/sound/xmplay.cpp @@ -1,6 +1,6 @@ /*========================================================================= - spu.cpp + xmplay.cpp Author: PKG Created: @@ -42,31 +42,10 @@ Tyepdefs && Defines ------------------- */ -#define MAX_XM_SONGS 5 -#define MAX_XM_VABS 5 - - /*---------------------------------------------------------------------- Structure defintions -------------------- */ -typedef struct XMSong -{ - unsigned char *m_xmData; - FileEquate m_file; - int m_refCount; - // refcount these! -}; -static XMSong s_xmSongs[MAX_XM_SONGS]; - -typedef struct XMVab -{ - int m_vabId; - FileEquate m_vhFile,m_vbFile; - int m_refCount; -}; -static XMVab s_xmVabs[MAX_XM_VABS]; - /*---------------------------------------------------------------------- Function Prototypes ------------------- */ @@ -110,8 +89,8 @@ void CXMPlaySound::initialise() // Clear internal data for(i=0;im_refCount=0; + XMMod *mod=&s_xmMods[i]; + mod->m_refCount=0; } for(i=0;im_locked==false&&ch->m_useType==SFX) + // Only unlocked stuff needs to be checked + if(ch->m_locked==false&&ch->m_useType!=SILENT) { id=ch->m_playingId; if(id!=-1) @@ -183,9 +160,6 @@ PAUL_DBGMSG("%d finished.. ( was on chnl %d )",id,i); } ch++; } - -for(i=0;i<24;i++) - spuflags[i]=m_spuChannelUse[i].m_useType; } @@ -214,8 +188,6 @@ xmSampleId CXMPlaySound::loadSampleData(FileEquate _vhFe,FileEquate _vbFe) } } -// PKG - Can be neatened up a bit.. - // Find next free vab slot vabId=0; vab=s_xmVabs; @@ -227,7 +199,6 @@ xmSampleId CXMPlaySound::loadSampleData(FileEquate _vhFe,FileEquate _vbFe) VhPtr=(u8*)CFileIO::loadFile(_vhFe); VbPtr=(u8*)CFileIO::loadFile(_vbFe); vab->m_vabId=XM_VABInit(VhPtr,VbPtr); - //defragSpuMemory(); somewhere around here.. MemFree(VhPtr); MemFree(VbPtr); vab->m_vhFile=_vhFe; @@ -248,43 +219,41 @@ xmSampleId CXMPlaySound::loadSampleData(FileEquate _vhFe,FileEquate _vbFe) Params: Returns: ---------------------------------------------------------------------- */ -xmModId CXMPlaySound::loadModData(FileEquate _songFe) +xmModId CXMPlaySound::loadModData(FileEquate _modFe) { - int songId; - XMSong *song; + int modId; + XMMod *mod; - // Is the song already loaded? - song=s_xmSongs; - for(songId=0;songIdm_refCount&&song->m_file==_songFe) + if(mod->m_refCount&&mod->m_file==_modFe) { // Yup.. - song->m_refCount++; - return(xmModId)songId; + mod->m_refCount++; + return(xmModId)modId; } } -// PKG - Can be neatened up a bit.. - // Find next free song slot - song=s_xmSongs; - songId=0; + mod=s_xmMods; + modId=0; while(1) { - ASSERT(songIdm_refCount==0) + ASSERT(modIdm_refCount==0) { - song->m_xmData=(u8*)CFileIO::loadFile(_songFe); - InitXMData(song->m_xmData,songId,XM_UseS3MPanning); - song->m_file=_songFe; - song->m_refCount=1; + mod->m_xmData=(u8*)CFileIO::loadFile(_modFe); + InitXMData(mod->m_xmData,modId,XM_UseS3MPanning); + mod->m_file=_modFe; + mod->m_refCount=1; break; } - songId++;song++; + modId++;mod++; } - return (xmModId)songId; + return (xmModId)modId; } @@ -313,15 +282,15 @@ void CXMPlaySound::dumpSampleData(xmSampleId _sampleId) Params: Returns: ---------------------------------------------------------------------- */ -void CXMPlaySound::dumpModData(xmModId _songId) +void CXMPlaySound::dumpModData(xmModId _modId) { - XMSong *song; + XMMod *mod; - song=&s_xmSongs[_songId]; - song->m_refCount--; - if(song->m_refCount==0) + mod=&s_xmMods[_modId]; + mod->m_refCount--; + if(mod->m_refCount==0) { - MemFree(song->m_xmData); + MemFree(mod->m_xmData); } } @@ -347,9 +316,9 @@ void CXMPlaySound::setStereo(int _stereo) Params: Returns: ---------------------------------------------------------------------- */ -void CXMPlaySound::setVolume(xmPlayingId _songId,unsigned char _volume) +void CXMPlaySound::setVolume(xmPlayingId _playingId,unsigned char _volume) { - XM_SetMasterVol(_songId,_volume>>1); + XM_SetMasterVol(_playingId,_volume>>1); } @@ -359,9 +328,9 @@ void CXMPlaySound::setVolume(xmPlayingId _songId,unsigned char _volume) Params: Returns: ---------------------------------------------------------------------- */ -void CXMPlaySound::setPanning(xmPlayingId _songId,char _pan) +void CXMPlaySound::setPanning(xmPlayingId _playingId,char _pan) { - XM_SetMasterPan(_songId,_pan); + XM_SetMasterPan(_playingId,_pan); } @@ -379,7 +348,7 @@ xmPlayingId CXMPlaySound::playSong(xmSampleId _sampleId,xmModId _songId,int _cha xmPlayingId retId; ASSERT(s_xmVabs[_sampleId].m_refCount!=0); - ASSERT(s_xmSongs[_songId].m_refCount!=0); + ASSERT(s_xmMods[_songId].m_refCount!=0); baseChannel=findSpareChannels(_channelCount,255); if(baseChannel!=-1) @@ -444,9 +413,6 @@ PAUL_DBGMSG("unlocking %d",_playingId); ---------------------------------------------------------------------- */ void CXMPlaySound::stopPlayingId(xmPlayingId _playingId) { -// ASSERT(m_spuChannelUse[_playingId].m_locked!=true); // Unlock channel first! - - int i; spuChannelUse *ch; @@ -507,7 +473,7 @@ xmPlayingId CXMPlaySound::playSfx(xmSampleId _sampleId,xmModId _songId,int _sfxP xmPlayingId retId; ASSERT(s_xmVabs[_sampleId].m_refCount!=0); - ASSERT(s_xmSongs[_songId].m_refCount!=0); + ASSERT(s_xmMods[_songId].m_refCount!=0); // Count channels maskCopy=_playMask; @@ -634,32 +600,8 @@ int CXMPlaySound::findSpareChannels(int _channelCount,int _priority) i=j; } -/* - // Couldn't find one.. can we kill off a lower priority sound? - if(valid==false) - { - int lowestPrioity=_priority; - int possibleBase=-1; - int id; - - // Find the lowest priority sound with enuf spare channels - i=0; - while(i<24) - { - if(m_spuChannelUse[i].m_priority<=lowestPriority&&m_spuChannelUse[j].m_useType!=SILENT) - { - valid=true; - id=m_spuChannelUse[i].m_id; - for(j=i;j