diff --git a/makefile.gfx b/makefile.gfx index 0ab4c467b..86cb19421 100644 --- a/makefile.gfx +++ b/makefile.gfx @@ -146,7 +146,7 @@ GFX_DATA_OUT += $(SFX_ALL_OUT) MUSIC_IN_DIR := data/music MUSIC_OUT_DIR := $(DATA_OUT)/music -MUSIC_LIST := hypermmx droppop +MUSIC_LIST := hypermmx droppop music MUSIC_ALL_IN := $(foreach MUSIC,$(MUSIC_LIST),$(MUSIC_IN_DIR)/$(MUSIC)/$(MUSIC).PXM $(MUSIC_IN_DIR)/$(MUSIC)/$(MUSIC).VH $(MUSIC_IN_DIR)/$(MUSIC)/$(MUSIC).VB) MUSIC_ALL_OUT := $(foreach MUSIC,$(MUSIC_LIST),$(MUSIC_OUT_DIR)/$(MUSIC).PXM $(MUSIC_OUT_DIR)/$(MUSIC).VH $(MUSIC_OUT_DIR)/$(MUSIC).VB) diff --git a/source/paul/paul.cpp b/source/paul/paul.cpp index 292e5691f..719ddab8e 100644 --- a/source/paul/paul.cpp +++ b/source/paul/paul.cpp @@ -77,13 +77,13 @@ char *s_mem[3]; void CPaulScene::init() { s_fontBank.initialise(&standardFont); - CSoundMediator::initialise(); - - CSoundMediator::setSong(CSoundMediator::DROPPOP); -// CSoundMediator::playSong(); + CSoundMediator::setSfxBank(CSoundMediator::INGAME); + CSoundMediator::setSong(CSoundMediator::MUSIC); + CSoundMediator::playSong(); + //CXAStream::Init(); PAUL_DBGMSG("initialised.."); @@ -140,7 +140,11 @@ void CPaulScene::think() int setVolumes=false; pad=PadGetDown(0); - if(pad&PAD_CROSS) + if(pad&PAD_R1) + { + PAUL_DBGMSG("-------------------"); + } + else if(pad&PAD_CROSS) { sfxId=psfx; } @@ -195,7 +199,6 @@ void CPaulScene::think() CSoundMediator::setVolume(CSoundMediator::SFX,svol); } - CSoundMediator::think(GameState::getTimeSinceLast()); //CXAStream::ControlXA(); } diff --git a/source/sound/sound.cpp b/source/sound/sound.cpp index 5e2b92123..bd10bf05c 100644 --- a/source/sound/sound.cpp +++ b/source/sound/sound.cpp @@ -41,6 +41,13 @@ typedef struct XMFILEDATA FileEquate m_vh,m_vb,m_pxm; }; +typedef struct SFXDETAILS +{ + int m_channels; + int m_pattern; + int m_looping; +}; + /*---------------------------------------------------------------------- Function Prototypes @@ -54,6 +61,7 @@ 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]= @@ -61,6 +69,26 @@ static XMFILEDATA s_xmSfxData[CSoundMediator::NUM_SFXBANKIDS]= { SFX_INGAME_VH, SFX_INGAME_VB, SFX_INGAME_PXM }, // INGAME }; +static SFXDETAILS s_sfxDetails[]= +{ + { 1, 0, 0 }, + { 1, 1, 0 }, + { 1, 2, 0 }, + { 1, 3, 0 }, +}; + + + + + + + + + + + + + int CSoundMediator::s_initialised=false; int /*CSoundMediator::*/s_currentVolume[CSoundMediator::NUM_VOLUMETYPES]; @@ -110,6 +138,8 @@ void CSoundMediator::initialise() // ASSERT(CXAStream::MAX_VOLUME==32767); +PAUL_DBGMSG("song: %d-%d (%d)",SONG_BASE_CHANNEL,SONG_MAX_CHANNEL,SONG_CHANNELS); +PAUL_DBGMSG("sfx: %d-%d (%d)",SFX_BASE_CHANNEL,SFX_MAX_CHANNEL,SFX_CHANNELS); SOUND_DBGMSG("Sound mediator initialised"); s_initialised=true; @@ -162,13 +192,33 @@ void CSoundMediator::think(int _frames) int id; id=-1; -for(i=10;i<24;i++) +for(i=SONG_CHANNELS;i<24;i++) { if(id!=s_spuChannelUse[i]) { id=s_spuChannelUse[i]; if(id!=-1) { +/* + if(id>=5000) + { +PAUL_DBGMSG("%d is now free.. ( was on chnl %d )",id-5000,i); + while(s_spuChannelUse[i]==id&&i<24) + { + s_spuChannelUse[i++]=-1; + } + i--; + } + else if(id>=100) + { + while(s_spuChannelUse[i]==id&&i<24) + { + s_spuChannelUse[i++]+=100; + } + i--; + } + else +*/ if(!s_xmplaySound->isSfxActive((xmPlayingSongId)id)) { PAUL_DBGMSG("%d end.. ( was on chnl %d )",id,i); @@ -176,7 +226,12 @@ PAUL_DBGMSG("%d end.. ( was on chnl %d )",id,i); { s_spuChannelUse[i++]=-1; } + i--; } +//else +//{ +// PAUL_DBGMSG("channel %d playing",i); +//} } } @@ -348,18 +403,17 @@ sfxChannelMask=3; } // Find some spare channels to play on - valid=true; - for(i=SFX_BASE_CHANNEL;iplaySfx(s_sfxSampleId,s_sfxDataId,baseChannel,_sfxId,sfxChannelMask); diff --git a/source/sound/sound.h b/source/sound/sound.h index 3531781f3..f843a8f31 100644 --- a/source/sound/sound.h +++ b/source/sound/sound.h @@ -51,6 +51,7 @@ public: { HYPERMMX, DROPPOP, + MUSIC, NUM_SONGIDS, }; typedef enum SFXBANKID @@ -108,10 +109,15 @@ private: enum { NUM_SPU_CHANNELS=24, - SONG_BASE_CHANNEL=0, - SONG_CHANNELS=10, - SFX_BASE_CHANNEL=SONG_BASE_CHANNEL+SONG_CHANNELS, - SFX_CHANNELS=NUM_SPU_CHANNELS-SFX_BASE_CHANNEL, + + SONG_BASE_CHANNEL =0, + SONG_CHANNELS =10, + SONG_MAX_CHANNEL =SONG_BASE_CHANNEL+SONG_CHANNELS-1, + + SFX_BASE_CHANNEL =SONG_MAX_CHANNEL+1, + SFX_CHANNELS =NUM_SPU_CHANNELS-SFX_BASE_CHANNEL, + SFX_MAX_CHANNEL =SFX_BASE_CHANNEL+SFX_CHANNELS-1, + VOLUME_CHANGE_SPEED=2, INITIAL_VOLUME=192, }; diff --git a/source/sound/xmplay.cpp b/source/sound/xmplay.cpp index 4a85761c4..c46dec94d 100644 --- a/source/sound/xmplay.cpp +++ b/source/sound/xmplay.cpp @@ -43,7 +43,6 @@ unsigned char *xmPtr; Tyepdefs && Defines ------------------- */ -#define XM_SONGID 0 #define MAX_XM_SONGS 5 #define MAX_XM_VABS 5 @@ -161,6 +160,8 @@ xmSampleId CXMPlaySound::loadSamples(FileEquate _vhFe,FileEquate _vbFe) return(xmSampleId)vabId; } } + +// PKG - Can be neatened up a bit.. // Find next free vab slot vabId=0; @@ -210,7 +211,9 @@ xmSongId CXMPlaySound::loadSongData(FileEquate _songFe) return(xmSongId)songId; } } - + +// PKG - Can be neatened up a bit.. + // Find next free song slot song=s_xmSongs; songId=0; @@ -328,7 +331,7 @@ xmPlayingSongId CXMPlaySound::playSong(xmSampleId _sampleId,xmSongId _songId,int vab=&s_xmVabs[_sampleId]; id=XM_Init(vab->m_vabId, // id from XM_VABInit _songId, // XM id ( as passed to InitXMData ) - -1, // Song id + 0, // Song id _baseChannel, // First channel XM_Loop, // Loop -1, // Play mask @@ -361,6 +364,9 @@ void CXMPlaySound::stopSong(xmPlayingSongId _songId) int SONGNUM=1; xmPlayingSongId CXMPlaySound::playSfx(xmSampleId _sampleId,xmSongId _songId,int _baseChannel,int _sfxPattern,int _playMask=-1) { +// XM_PlaySample(XM_GetSampleAddress(_sampleId,_sfxPattern),23,0x3fff,0x3fff,0x800); +// return (xmPlayingSongId)0; + int i, maskCopy,channelCount=0; XMVab *vab; int id; @@ -386,11 +392,11 @@ xmPlayingSongId CXMPlaySound::playSfx(xmSampleId _sampleId,xmSongId _songId,int XM_NoLoop, // Loop _playMask, // Play mask XM_SFX, // Music - _sfxPattern); // Pattern to start at + _sfxPattern); // Pattern to start at SONGNUM++; if(SONGNUM>=24)SONGNUM=1; -PAUL_DBGMSG("sfx - ret:%d",id); +//PAUL_DBGMSG("sfx - ret:%d",id); return (xmPlayingSongId)id; } @@ -404,13 +410,8 @@ PAUL_DBGMSG("sfx - ret:%d",id); int CXMPlaySound::isSfxActive(xmPlayingSongId _id) { XM_Feedback fb; - int ret; - XM_GetFeedback(_id,&fb); - - ret=fb.Status==XM_PLAYING; -//PAUL_DBGMSG("check %d ( %d )",_id,fb.Status); - return ret; + return XM_GetFeedback(_id,&fb)==0; } diff --git a/source/system/main.cpp b/source/system/main.cpp index 372ab0aca..9ca8f64ff 100644 --- a/source/system/main.cpp +++ b/source/system/main.cpp @@ -25,6 +25,11 @@ #include "locale\textdbase.h" #endif +#ifndef __SOUND_SOUND_H__ +#include "sound\sound.h" +#endif + + #define SCREEN_GRAB @@ -66,6 +71,8 @@ void InitSystem() // reordered to reduce black screen (hope all is well GameState::initialise(); + CSoundMediator::initialise(); + #ifdef __USER_paul__ s_paulScene.init(); #endif @@ -85,6 +92,8 @@ void MainLoop() GameState::think(); GameState::render(); + CSoundMediator::think(GameState::getTimeSinceLast()); + #ifdef __USER_paul__ s_paulScene.think(); s_paulScene.render();