diff options
Diffstat (limited to 'sky/music')
-rw-r--r-- | sky/music/adlibchannel.cpp | 10 | ||||
-rw-r--r-- | sky/music/adlibmusic.cpp | 2 | ||||
-rw-r--r-- | sky/music/gmmusic.cpp | 27 | ||||
-rw-r--r-- | sky/music/mt32music.cpp | 2 | ||||
-rw-r--r-- | sky/music/musicbase.cpp | 65 |
5 files changed, 54 insertions, 52 deletions
diff --git a/sky/music/adlibchannel.cpp b/sky/music/adlibchannel.cpp index a206d5f1f9..231a434230 100644 --- a/sky/music/adlibchannel.cpp +++ b/sky/music/adlibchannel.cpp @@ -24,8 +24,7 @@ #include "sky/music/adlibchannel.h" #include "sky/sky.h" -SkyAdlibChannel::SkyAdlibChannel(FM_OPL *opl, uint8 *pMusicData, uint16 startOfData) -{ +SkyAdlibChannel::SkyAdlibChannel(FM_OPL *opl, uint8 *pMusicData, uint16 startOfData) { _opl = opl; _musicData = pMusicData; _channelData.startOfData = startOfData; @@ -50,7 +49,7 @@ SkyAdlibChannel::SkyAdlibChannel(FM_OPL *opl, uint8 *pMusicData, uint16 startOfD //_registerTable = _musicData + 0xE35; //_opOutputTable = _musicData + 0xE47; //_adlibRegMirror = _musicData + 0xF4A; - + instrumentDataLoc = READ_LE_UINT16(_musicData + 0x1204); _frequenceTable = (uint16*)(_musicData + 0x868); _registerTable = _musicData + 0xE68; @@ -106,8 +105,7 @@ void SkyAdlibChannel::stopNote(void) { } } -int32 SkyAdlibChannel::getNextEventTime(void) -{ +int32 SkyAdlibChannel::getNextEventTime(void) { int32 retV = 0; uint8 cnt, lVal; for (cnt = 0; cnt < 4; cnt++) { @@ -135,7 +133,7 @@ uint8 SkyAdlibChannel::process(uint16 aktTime) { while ((_channelData.nextEventTime < 0) && (_channelData.channelActive)) { opcode = _musicData[_channelData.eventDataPtr]; _channelData.eventDataPtr++; - if (opcode&0x80) { + if (opcode & 0x80) { if (opcode == 0xFF) { // dummy opcode } else if (opcode >= 0x90) { diff --git a/sky/music/adlibmusic.cpp b/sky/music/adlibmusic.cpp index d8f80d772a..bfb48ec01f 100644 --- a/sky/music/adlibmusic.cpp +++ b/sky/music/adlibmusic.cpp @@ -83,7 +83,7 @@ void SkyAdlibMusic::premixerCall(int16 *data, uint len) { _nextMusicPoll = _sampleRate/50; } } - + // Convert mono data to stereo for (int i = (origLen - 1); i >= 0; i--) { origData[2 * i] = origData[2 * i + 1] = origData[i]; diff --git a/sky/music/gmmusic.cpp b/sky/music/gmmusic.cpp index 4bdef54e46..b19486f7d1 100644 --- a/sky/music/gmmusic.cpp +++ b/sky/music/gmmusic.cpp @@ -115,17 +115,18 @@ byte SkyGmMusic::_mt32_to_gm[128] = { }; uint8 SkyGmMusic::_veloTab[128] = { -0x00, 0x40, 0x41, 0x41, 0x42, 0x42, 0x43, 0x43, 0x44, 0x44, -0x45, 0x45, 0x46, 0x46, 0x47, 0x47, 0x48, 0x48, 0x49, 0x49, -0x4A, 0x4A, 0x4B, 0x4B, 0x4C, 0x4C, 0x4D, 0x4D, 0x4E, 0x4E, -0x4F, 0x4F, 0x50, 0x50, 0x51, 0x51, 0x52, 0x52, 0x53, 0x53, -0x54, 0x54, 0x55, 0x55, 0x56, 0x56, 0x57, 0x57, 0x58, 0x58, -0x59, 0x59, 0x5A, 0x5A, 0x5B, 0x5B, 0x5C, 0x5C, 0x5D, 0x5D, -0x5E, 0x5E, 0x5F, 0x5F, 0x60, 0x60, 0x61, 0x61, 0x62, 0x62, -0x63, 0x63, 0x64, 0x64, 0x65, 0x65, 0x66, 0x66, 0x67, 0x67, -0x68, 0x68, 0x69, 0x69, 0x6A, 0x6A, 0x6B, 0x6B, 0x6C, 0x6C, -0x6D, 0x6D, 0x6E, 0x6E, 0x6F, 0x6F, 0x70, 0x70, 0x71, 0x71, -0x72, 0x72, 0x73, 0x73, 0x74, 0x74, 0x75, 0x75, 0x76, 0x76, -0x77, 0x77, 0x78, 0x78, 0x79, 0x79, 0x7A, 0x7A, 0x7B, 0x7B, -0x7C, 0x7C, 0x7D, 0x7D, 0x7E, 0x7E, 0x7F, 0x7F }; + 0x00, 0x40, 0x41, 0x41, 0x42, 0x42, 0x43, 0x43, 0x44, 0x44, + 0x45, 0x45, 0x46, 0x46, 0x47, 0x47, 0x48, 0x48, 0x49, 0x49, + 0x4A, 0x4A, 0x4B, 0x4B, 0x4C, 0x4C, 0x4D, 0x4D, 0x4E, 0x4E, + 0x4F, 0x4F, 0x50, 0x50, 0x51, 0x51, 0x52, 0x52, 0x53, 0x53, + 0x54, 0x54, 0x55, 0x55, 0x56, 0x56, 0x57, 0x57, 0x58, 0x58, + 0x59, 0x59, 0x5A, 0x5A, 0x5B, 0x5B, 0x5C, 0x5C, 0x5D, 0x5D, + 0x5E, 0x5E, 0x5F, 0x5F, 0x60, 0x60, 0x61, 0x61, 0x62, 0x62, + 0x63, 0x63, 0x64, 0x64, 0x65, 0x65, 0x66, 0x66, 0x67, 0x67, + 0x68, 0x68, 0x69, 0x69, 0x6A, 0x6A, 0x6B, 0x6B, 0x6C, 0x6C, + 0x6D, 0x6D, 0x6E, 0x6E, 0x6F, 0x6F, 0x70, 0x70, 0x71, 0x71, + 0x72, 0x72, 0x73, 0x73, 0x74, 0x74, 0x75, 0x75, 0x76, 0x76, + 0x77, 0x77, 0x78, 0x78, 0x79, 0x79, 0x7A, 0x7A, 0x7B, 0x7B, + 0x7C, 0x7C, 0x7D, 0x7D, 0x7E, 0x7E, 0x7F, 0x7F +}; diff --git a/sky/music/mt32music.cpp b/sky/music/mt32music.cpp index f30b2969a2..81937d77cb 100644 --- a/sky/music/mt32music.cpp +++ b/sky/music/mt32music.cpp @@ -33,7 +33,7 @@ SkyMT32Music::SkyMT32Music(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk, OSystem *sys : SkyMusicBase(pSkyDisk, system) { _driverFileBase = 60200; - _midiDrv = pMidiDrv; + _midiDrv = pMidiDrv; int midiRes = _midiDrv->open(); if (midiRes != 0) { error("Can't open midi device. Errorcode: %d",midiRes); diff --git a/sky/music/musicbase.cpp b/sky/music/musicbase.cpp index 368a9c308d..640aa64bc4 100644 --- a/sky/music/musicbase.cpp +++ b/sky/music/musicbase.cpp @@ -35,16 +35,19 @@ SkyMusicBase::SkyMusicBase(SkyDisk *pSkyDisk, OSystem *system) { _mutex = _system->create_mutex(); } -SkyMusicBase::~SkyMusicBase(void) -{ - if (_musicData) free(_musicData); +SkyMusicBase::~SkyMusicBase(void) { + + if (_musicData) + free(_musicData); } -void SkyMusicBase::loadSection(uint8 pSection) -{ +void SkyMusicBase::loadSection(uint8 pSection) { + _system->lock_mutex(_mutex); - if (_currentMusic) stopMusic(); - if (_musicData) free(_musicData); + if (_currentMusic) + stopMusic(); + if (_musicData) + free(_musicData); _currentSection = pSection; _musicData = _skyDisk->loadFile(_driverFileBase + FILES_PER_SECTION * pSection, NULL); _allowedCommands = 0; @@ -60,16 +63,16 @@ void SkyMusicBase::loadSection(uint8 pSection) _system->unlock_mutex(_mutex); } -bool SkyMusicBase::musicIsPlaying(void) -{ +bool SkyMusicBase::musicIsPlaying(void) { + for (uint8 cnt = 0; cnt < _numberOfChannels; cnt++) if (_channels[cnt]->isActive()) return true; return false; } -void SkyMusicBase::musicCommand(uint16 command) -{ +void SkyMusicBase::musicCommand(uint16 command) { + if (_musicData == NULL) { debug(1,"Got music command but driver is not yet loaded"); return ; @@ -92,7 +95,7 @@ void SkyMusicBase::musicCommand(uint16 command) debug(1,"SkyMusic: ignored direct call to driverPoll()."); break; case 4: - startMusic(command&0xFF); + startMusic(command & 0xFF); break; case 6: reinitFM(); @@ -101,22 +104,22 @@ void SkyMusicBase::musicCommand(uint16 command) stopMusic(); break; case 13: - setFMVolume(command&0xFF); + setFMVolume(command & 0xFF); break; default: - debug(1,"musicCommand %d ignored.",command>>8); + debug(1,"musicCommand %d ignored.",command >> 8); } } -void SkyMusicBase::setFMVolume(uint16 param) -{ +void SkyMusicBase::setFMVolume(uint16 param) { + _musicVolume = param; for (uint8 cnt = 0; cnt < _numberOfChannels; cnt++) _channels[cnt]->updateVolume(_musicVolume); } -void SkyMusicBase::stopMusic(void) -{ +void SkyMusicBase::stopMusic(void) { + for (uint8 cnt = 0; cnt < _numberOfChannels; cnt++) { _channels[cnt]->stopNote(); delete _channels[cnt]; @@ -124,16 +127,16 @@ void SkyMusicBase::stopMusic(void) _numberOfChannels = 0; } -void SkyMusicBase::updateTempo(void) -{ - uint16 tempoMul = _musicTempo0*_musicTempo1; - uint16 divisor = 0x4446390/23864; - _tempo = (tempoMul / divisor)<<16; - _tempo |= (((tempoMul%divisor)<<16) | (tempoMul/divisor)) / divisor; +void SkyMusicBase::updateTempo(void) { + + uint16 tempoMul = _musicTempo0 * _musicTempo1; + uint16 divisor = 0x4446390/ 23864; + _tempo = (tempoMul / divisor) << 16; + _tempo |= (((tempoMul%divisor) << 16) | (tempoMul / divisor)) / divisor; } -void SkyMusicBase::loadNewMusic(void) -{ +void SkyMusicBase::loadNewMusic(void) { + uint16 musicPos; if (_onNextPoll.musicToProcess > _musicData[_musicDataLoc]) { error("Music %d requested but doesn't exist in file.", _onNextPoll.musicToProcess); @@ -145,9 +148,9 @@ void SkyMusicBase::loadNewMusic(void) _currentMusic = _onNextPoll.musicToProcess; if (_currentMusic != 0) { - musicPos = (_musicData[_musicDataLoc+2]<<8) | _musicData[_musicDataLoc+1]; - musicPos += _musicDataLoc+((_currentMusic-1)<<1); - musicPos = ((_musicData[musicPos+1]<<8) | _musicData[musicPos]) + _musicDataLoc; + musicPos = (_musicData[_musicDataLoc + 2] << 8) | _musicData[_musicDataLoc+1]; + musicPos += _musicDataLoc+((_currentMusic-1) << 1); + musicPos = ((_musicData[musicPos+1] << 8) | _musicData[musicPos]) + _musicDataLoc; _musicTempo0 = _musicData[musicPos]; _musicTempo1 = _musicData[musicPos+1]; @@ -158,8 +161,8 @@ void SkyMusicBase::loadNewMusic(void) } } -void SkyMusicBase::pollMusic(void) -{ +void SkyMusicBase::pollMusic(void) { + _system->lock_mutex(_mutex); uint8 newTempo; if (_onNextPoll.doReInit) startDriver(); |