mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-06 01:31:39 +00:00
c79d40e1e3
svn-id: r7617
147 lines
7.1 KiB
C++
147 lines
7.1 KiB
C++
/* ScummVM - Scumm Interpreter
|
|
* Copyright (C) 2003 The ScummVM project
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*
|
|
* $Header$
|
|
*
|
|
*/
|
|
|
|
#include "sky/gmmusic.h"
|
|
|
|
void SkyGmMusic::passTimerFunc(void *param) {
|
|
|
|
((SkyGmMusic*)param)->timerCall();
|
|
}
|
|
|
|
SkyGmMusic::SkyGmMusic(MidiDriver *pMidiDrv, SkyDisk *pSkyDisk)
|
|
: SkyMusicBase(pSkyDisk) {
|
|
|
|
_driverFileBase = 60200;
|
|
_midiDrv = pMidiDrv;
|
|
int midiRes = _midiDrv->open();
|
|
if (midiRes != 0) {
|
|
error("Can't open midi device. Errorcode: %d\n",midiRes);
|
|
}
|
|
_midiDrv->setTimerCallback(this, passTimerFunc);
|
|
_ignoreNextPoll = false;
|
|
}
|
|
|
|
SkyGmMusic::~SkyGmMusic(void) {
|
|
|
|
_midiDrv->setTimerCallback(NULL, NULL);
|
|
if (_currentMusic) stopMusic();
|
|
_midiDrv->close();
|
|
delete _midiDrv;
|
|
}
|
|
|
|
void SkyGmMusic::timerCall(void) {
|
|
|
|
// midi driver polls hundred times per sec. We only want 50 times.
|
|
_ignoreNextPoll = !_ignoreNextPoll;
|
|
if (!_ignoreNextPoll) return;
|
|
|
|
if (_musicData != NULL)
|
|
pollMusic();
|
|
}
|
|
|
|
void SkyGmMusic::setupPointers(void) {
|
|
|
|
_musicDataLoc = (_musicData[0x7DD] << 8) | _musicData[0x7DC];
|
|
_sysExSequence = ((_musicData[0x7E1] << 8) | _musicData[0x7E0]) + _musicData;
|
|
}
|
|
|
|
void SkyGmMusic::setupChannels(uint8 *channelData) {
|
|
|
|
_numberOfChannels = channelData[0];
|
|
channelData++;
|
|
for (uint8 cnt = 0; cnt < _numberOfChannels; cnt++) {
|
|
uint16 chDataStart = ((channelData[(cnt << 1) | 1] << 8) | channelData[cnt << 1]) + _musicDataLoc;
|
|
_channels[cnt] = new SkyGmChannel(_musicData, chDataStart, _midiDrv, _mt32_to_gm + 128 * _currentSection);
|
|
}
|
|
}
|
|
|
|
void SkyGmMusic::startDriver(void) {
|
|
|
|
//_midiDrv->send(0xFF); //ALSA can't handle this.
|
|
// skip all sysEx as it can't be handled anyways.
|
|
}
|
|
|
|
// not sure about these tables. Now it's just 6 copies of jamiesons table in the
|
|
// instruments.cpp, but I still think that there must be something to be done to them.
|
|
|
|
byte SkyGmMusic::_mt32_to_gm[6*128] = {
|
|
// Section 0:
|
|
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
|
0, 1, 0, 2, 4, 4, 5, 3, 16, 17, 18, 16, 16, 19, 20, 21, // 0x
|
|
6, 6, 6, 7, 7, 7, 8, 112, 62, 62, 63, 63, 38, 38, 39, 39, // 1x
|
|
88, 95, 52, 98, 97, 99, 14, 54, 102, 96, 53, 102, 81, 100, 14, 80, // 2x
|
|
48, 48, 49, 45, 41, 40, 42, 42, 43, 46, 45, 24, 25, 28, 27, 104, // 3x
|
|
32, 32, 34, 33, 36, 37, 35, 35, 79, 73, 72, 72, 74, 75, 64, 65, // 4x
|
|
66, 67, 71, 71, 68, 69, 70, 22, 56, 59, 57, 57, 60, 60, 58, 61, // 5x
|
|
61, 11, 11, 98, 14, 9, 14, 13, 12, 107, 107, 77, 78, 78, 76, 76, // 6x
|
|
47, 117, 127, 118, 118, 116, 115, 119, 115, 112, 55, 124, 123, 0, 14, 117, // 7x
|
|
// Section 1:
|
|
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
|
0, 1, 0, 2, 4, 4, 5, 3, 16, 17, 18, 16, 16, 19, 20, 21, // 0x
|
|
6, 6, 6, 7, 7, 7, 8, 112, 62, 62, 63, 63, 38, 38, 39, 39, // 1x
|
|
88, 95, 52, 98, 97, 99, 14, 54, 102, 96, 53, 102, 81, 100, 14, 80, // 2x
|
|
48, 48, 49, 45, 41, 40, 42, 42, 43, 46, 45, 24, 25, 28, 27, 104, // 3x
|
|
32, 32, 34, 33, 36, 37, 35, 35, 79, 73, 72, 72, 74, 75, 64, 65, // 4x
|
|
66, 67, 71, 71, 68, 69, 70, 22, 56, 59, 57, 57, 60, 60, 58, 61, // 5x
|
|
61, 11, 11, 98, 14, 9, 14, 13, 12, 107, 107, 77, 78, 78, 76, 76, // 6x
|
|
47, 117, 127, 118, 118, 116, 115, 119, 115, 112, 55, 124, 123, 0, 14, 117, // 7x
|
|
// Section 2:
|
|
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
|
0, 1, 0, 2, 4, 4, 5, 3, 16, 17, 18, 16, 16, 19, 20, 21, // 0x
|
|
6, 6, 6, 7, 7, 7, 8, 112, 62, 62, 63, 63, 38, 38, 39, 39, // 1x
|
|
88, 95, 52, 98, 97, 99, 14, 54, 102, 96, 53, 102, 81, 100, 14, 80, // 2x
|
|
48, 48, 49, 45, 41, 40, 42, 42, 43, 46, 45, 24, 25, 28, 27, 104, // 3x
|
|
32, 32, 34, 33, 36, 37, 35, 35, 79, 73, 72, 72, 74, 75, 64, 65, // 4x
|
|
66, 67, 71, 71, 68, 69, 70, 22, 56, 59, 57, 57, 60, 60, 58, 61, // 5x
|
|
61, 11, 11, 98, 14, 9, 14, 13, 12, 107, 107, 77, 78, 78, 76, 76, // 6x
|
|
47, 117, 127, 118, 118, 116, 115, 119, 115, 112, 55, 124, 123, 0, 14, 117, // 7x
|
|
// Section 3:
|
|
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
|
0, 1, 0, 2, 4, 4, 5, 3, 16, 17, 18, 16, 16, 19, 20, 21, // 0x
|
|
6, 6, 6, 7, 7, 7, 8, 112, 62, 62, 63, 63, 38, 38, 39, 39, // 1x
|
|
88, 95, 52, 98, 97, 99, 14, 54, 102, 96, 53, 102, 81, 100, 14, 80, // 2x
|
|
48, 48, 49, 45, 41, 40, 42, 42, 43, 46, 45, 24, 25, 28, 27, 104, // 3x
|
|
32, 32, 34, 33, 36, 37, 35, 35, 79, 73, 72, 72, 74, 75, 64, 65, // 4x
|
|
66, 67, 71, 71, 68, 69, 70, 22, 56, 59, 57, 57, 60, 60, 58, 61, // 5x
|
|
61, 11, 11, 98, 14, 9, 14, 13, 12, 107, 107, 77, 78, 78, 76, 76, // 6x
|
|
47, 117, 127, 118, 118, 116, 115, 119, 115, 112, 55, 124, 123, 0, 14, 117, // 7x
|
|
// Section 4:
|
|
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
|
0, 1, 0, 2, 4, 4, 5, 3, 16, 17, 18, 16, 16, 19, 20, 21, // 0x
|
|
6, 6, 6, 7, 7, 7, 8, 112, 62, 62, 63, 63, 38, 38, 39, 39, // 1x
|
|
88, 95, 52, 98, 97, 99, 14, 54, 102, 96, 53, 102, 81, 100, 14, 80, // 2x
|
|
48, 48, 49, 45, 41, 40, 42, 42, 43, 46, 45, 24, 25, 28, 27, 104, // 3x
|
|
32, 32, 34, 33, 36, 37, 35, 35, 79, 73, 72, 72, 74, 75, 64, 65, // 4x
|
|
66, 67, 71, 71, 68, 69, 70, 22, 56, 59, 57, 57, 60, 60, 58, 61, // 5x
|
|
61, 11, 11, 98, 14, 9, 14, 13, 12, 107, 107, 77, 78, 78, 76, 76, // 6x
|
|
47, 117, 127, 118, 118, 116, 115, 119, 115, 112, 55, 124, 123, 0, 14, 117, // 7x
|
|
// Section 5:
|
|
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
|
|
0, 1, 0, 2, 4, 4, 5, 3, 16, 17, 18, 16, 16, 19, 20, 21, // 0x
|
|
6, 6, 6, 7, 7, 7, 8, 112, 62, 62, 63, 63, 38, 38, 39, 39, // 1x
|
|
88, 95, 52, 98, 97, 99, 14, 54, 102, 96, 53, 102, 81, 100, 14, 80, // 2x
|
|
48, 48, 49, 45, 41, 40, 42, 42, 43, 46, 45, 24, 25, 28, 27, 104, // 3x
|
|
32, 32, 34, 33, 36, 37, 35, 35, 79, 73, 72, 72, 74, 75, 64, 65, // 4x
|
|
66, 67, 71, 71, 68, 69, 70, 22, 56, 59, 57, 57, 60, 60, 58, 61, // 5x
|
|
61, 11, 11, 98, 14, 9, 14, 13, 12, 107, 107, 77, 78, 78, 76, 76, // 6x
|
|
47, 117, 127, 118, 118, 116, 115, 119, 115, 112, 55, 124, 123, 0, 14, 117 // 7x
|
|
};
|