[Scummvm-cvs-logs] SF.net SVN: scummvm:[35180] scummvm/trunk
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Sun Nov 30 05:42:31 CET 2008
Revision: 35180
http://scummvm.svn.sourceforge.net/scummvm/?rev=35180&view=rev
Author: lordhoto
Date: 2008-11-30 04:42:30 +0000 (Sun, 30 Nov 2008)
Log Message:
-----------
- Extended MidiDriver::sysEx to allow 264 byte sysEx messages
- Updated all drivers to allow 264+2 byte sysEx messages
- Implemented sysEx processing for MT-32 for Kyra1 and HoF. MT-32 should now be working properly.
Modified Paths:
--------------
scummvm/trunk/backends/midi/alsa.cpp
scummvm/trunk/backends/midi/camd.cpp
scummvm/trunk/backends/midi/coreaudio.cpp
scummvm/trunk/backends/midi/seq.cpp
scummvm/trunk/backends/midi/stmidi.cpp
scummvm/trunk/backends/midi/timidity.cpp
scummvm/trunk/backends/midi/windows.cpp
scummvm/trunk/backends/midi/zodiac.cpp
scummvm/trunk/engines/kyra/kyra_v1.h
scummvm/trunk/engines/kyra/sound_midi.cpp
scummvm/trunk/sound/mididrv.h
Modified: scummvm/trunk/backends/midi/alsa.cpp
===================================================================
--- scummvm/trunk/backends/midi/alsa.cpp 2008-11-30 02:54:39 UTC (rev 35179)
+++ scummvm/trunk/backends/midi/alsa.cpp 2008-11-30 04:42:30 UTC (rev 35180)
@@ -213,9 +213,9 @@
}
void MidiDriver_ALSA::sysEx(const byte *msg, uint16 length) {
- unsigned char buf[256];
+ unsigned char buf[266];
- assert(length + 2 <= 256);
+ assert(length + 2 <= ARRAYSIZE(buf));
// Add SysEx frame
buf[0] = 0xF0;
Modified: scummvm/trunk/backends/midi/camd.cpp
===================================================================
--- scummvm/trunk/backends/midi/camd.cpp 2008-11-30 02:54:39 UTC (rev 35179)
+++ scummvm/trunk/backends/midi/camd.cpp 2008-11-30 04:42:30 UTC (rev 35180)
@@ -115,9 +115,9 @@
}
void MidiDriver_CAMD::sysEx(const byte *msg, uint16 length) {
- unsigned char buf[256];
+ unsigned char buf[266];
- assert(length + 2 <= 256);
+ assert(length + 2 <= ARRAYSIZE(buf));
// Add SysEx frame
buf[0] = 0xF0;
Modified: scummvm/trunk/backends/midi/coreaudio.cpp
===================================================================
--- scummvm/trunk/backends/midi/coreaudio.cpp 2008-11-30 02:54:39 UTC (rev 35179)
+++ scummvm/trunk/backends/midi/coreaudio.cpp 2008-11-30 04:42:30 UTC (rev 35180)
@@ -190,9 +190,9 @@
}
void MidiDriver_CORE::sysEx(const byte *msg, uint16 length) {
- unsigned char buf[256];
+ unsigned char buf[266];
- assert(length + 2 <= 256);
+ assert(length + 2 <= ARRAYSIZE(buf));
assert(_auGraph != NULL);
// Add SysEx frame
Modified: scummvm/trunk/backends/midi/seq.cpp
===================================================================
--- scummvm/trunk/backends/midi/seq.cpp 2008-11-30 02:54:39 UTC (rev 35179)
+++ scummvm/trunk/backends/midi/seq.cpp 2008-11-30 04:42:30 UTC (rev 35180)
@@ -146,11 +146,11 @@
}
void MidiDriver_SEQ::sysEx (const byte *msg, uint16 length) {
- unsigned char buf [1024];
+ unsigned char buf [1330];
int position = 0;
const byte *chr = msg;
- assert(length + 2 <= 256);
+ assert(length + 2 <= 266);
buf[position++] = SEQ_MIDIPUTC;
buf[position++] = 0xF0;
Modified: scummvm/trunk/backends/midi/stmidi.cpp
===================================================================
--- scummvm/trunk/backends/midi/stmidi.cpp 2008-11-30 02:54:39 UTC (rev 35179)
+++ scummvm/trunk/backends/midi/stmidi.cpp 2008-11-30 04:42:30 UTC (rev 35180)
@@ -91,7 +91,10 @@
}
void MidiDriver_STMIDI::sysEx (const byte *msg, uint16 length) {
- if (length > 254) {
+ // FIXME: LordHoto doesn't know if this will still work
+ // when sending 264 byte sysEx data, as needed by KYRA,
+ // feel free to revert it to 254 again if needed.
+ if (length > 264) {
warning ("Cannot send SysEx block - data too large");
return;
}
Modified: scummvm/trunk/backends/midi/timidity.cpp
===================================================================
--- scummvm/trunk/backends/midi/timidity.cpp 2008-11-30 02:54:39 UTC (rev 35179)
+++ scummvm/trunk/backends/midi/timidity.cpp 2008-11-30 04:42:30 UTC (rev 35180)
@@ -487,11 +487,11 @@
void MidiDriver_TIMIDITY::sysEx(const byte *msg, uint16 length) {
fprintf(stderr, "Timidity::sysEx\n");
- unsigned char buf[1024];
+ unsigned char buf[1330];
int position = 0;
const byte *chr = msg;
- assert(length + 2 <= 256);
+ assert(length + 2 <= 266);
buf[position++] = SEQ_MIDIPUTC;
buf[position++] = 0xF0;
Modified: scummvm/trunk/backends/midi/windows.cpp
===================================================================
--- scummvm/trunk/backends/midi/windows.cpp 2008-11-30 02:54:39 UTC (rev 35179)
+++ scummvm/trunk/backends/midi/windows.cpp 2008-11-30 04:42:30 UTC (rev 35180)
@@ -42,7 +42,7 @@
class MidiDriver_WIN : public MidiDriver_MPU401 {
private:
MIDIHDR _streamHeader;
- byte _streamBuffer[256]; // SysEx blocks should be no larger than 256 bytes
+ byte _streamBuffer[266]; // SysEx blocks should be no larger than 266 bytes
HANDLE _streamEvent;
HMIDIOUT _mo;
bool _isOpen;
@@ -106,7 +106,7 @@
return;
}
- assert(length+2 <= 256);
+ assert(length+2 <= 266);
midiOutUnprepareHeader(_mo, &_streamHeader, sizeof(_streamHeader));
Modified: scummvm/trunk/backends/midi/zodiac.cpp
===================================================================
--- scummvm/trunk/backends/midi/zodiac.cpp 2008-11-30 02:54:39 UTC (rev 35179)
+++ scummvm/trunk/backends/midi/zodiac.cpp 2008-11-30 04:42:30 UTC (rev 35180)
@@ -112,7 +112,7 @@
}
void MidiDriver_Zodiac::sysEx(const byte *msg, uint16 length) {
- unsigned char buf[256];
+ unsigned char buf[266];
buf[0] = 0xF0;
memcpy(buf + 1, msg, length);
Modified: scummvm/trunk/engines/kyra/kyra_v1.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v1.h 2008-11-30 02:54:39 UTC (rev 35179)
+++ scummvm/trunk/engines/kyra/kyra_v1.h 2008-11-30 04:42:30 UTC (rev 35180)
@@ -110,6 +110,7 @@
friend class Debugger;
friend class ::KyraMetaEngine;
friend class GUI;
+friend class SoundMidiPC; // For _eventMan
public:
KyraEngine_v1(OSystem *system, const GameFlags &flags);
virtual ~KyraEngine_v1();
Modified: scummvm/trunk/engines/kyra/sound_midi.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_midi.cpp 2008-11-30 02:54:39 UTC (rev 35179)
+++ scummvm/trunk/engines/kyra/sound_midi.cpp 2008-11-30 04:42:30 UTC (rev 35180)
@@ -182,8 +182,16 @@
_channels[channel].program =
_sources[_curSource].channelProgram[channel] = param1;
} else if (event == 0xB0) { // Controller change
+ for (int i = 0; i < 9; ++i) {
+ Controller &cont = _sources[_curSource].controllers[channel][i];
+ if (cont.controller == param1) {
+ cont.value = param2;
+ break;
+ }
+ }
+
if (param1 == 0x07) {
- param1 = (param1 * _sources[_curSource].volume) >> 8;
+ param2 = (param2 * _sources[_curSource].volume) >> 8;
} else if (param1 == 0x6E) { // Lock Channel
if (param2 >= 0x40) { // Lock Channel
int chan = lockChannel();
@@ -206,15 +214,6 @@
// on track change, we simply ignore it.
return;
}
-
- for (int i = 0; i < 9; ++i) {
- Controller &cont = _sources[_curSource].controllers[channel][i];
- if (cont.controller == param1) {
- cont.value = param2;
- break;
- }
- }
-
} else if (event == 0x90 || event == 0x80) { // Note On/Off
if (!(_channels[channel].flags & kChannelLocked)) {
const bool remove = (event == 0x80) || (param2 == 0x00);
@@ -258,11 +257,7 @@
}
void MidiOutput::sendIntern(const byte event, const byte channel, byte param1, const byte param2) {
- if (event == 0xE0) {
- _channels[channel].pitchWheel = (param2 << 8) | param1;
- } else if (event == 0xC0) {
- _channels[channel].program = param1;
-
+ if (event == 0xC0) {
// MT32 -> GM conversion
if (!_isMT32 && _defaultMT32)
param1 = _mt32ToGm[param1];
@@ -330,8 +325,6 @@
// Controller 0 in the state table should always be '7' aka
// volume control
byte realVol = (_channels[i].controllers[0].value * volume) >> 8;
- _channels[i].controllers[0].value = realVol;
-
sendIntern(0xB0, i, 0x07, realVol);
}
}
@@ -509,11 +502,27 @@
_output->setTimerCallback(this, SoundMidiPC::onTimer);
- /*loadSoundFile("INTRO");
- playTrack(0);
- while (_music->isPlaying())
- _vm->_system->delayMillis(10);*/
+ if (_nativeMT32) {
+ if (_vm->gameFlags().gameID == GI_KYRA1) {
+ loadSoundFile("INTRO");
+ } else if (_vm->gameFlags().gameID == GI_KYRA2) {
+ _vm->resource()->loadPakFile("AUDIO.PAK");
+ loadSoundFile("HOF_SYX");
+ }
+
+ playTrack(0);
+ Common::Event event;
+ while (isPlaying() && !_vm->shouldQuit()) {
+ _vm->_system->updateScreen();
+ _vm->_eventMan->pollEvent(event);
+ _vm->_system->delayMillis(10);
+ }
+
+ if (_vm->gameFlags().gameID == GI_KYRA2)
+ _vm->resource()->unloadPakFile("AUDIO.PAK");
+ }
+
return true;
}
@@ -594,9 +603,12 @@
void SoundMidiPC::playTrack(uint8 track) {
Common::StackLock lock(_mutex);
- _output->initSource(0);
+
_fadeMusicOut = false;
_output->setSourceVolume(0, _musicVolume, true);
+
+ _output->initSource(0);
+ _output->setSourceVolume(0, _musicVolume, true);
_music->setTrack(track);
}
@@ -620,7 +632,7 @@
if (!_sfx[i]->isPlaying()) {
_output->initSource(i+1);
_sfx[i]->setTrack(track);
- break;
+ return;
}
}
}
Modified: scummvm/trunk/sound/mididrv.h
===================================================================
--- scummvm/trunk/sound/mididrv.h 2008-11-30 02:54:39 UTC (rev 35179)
+++ scummvm/trunk/sound/mididrv.h 2008-11-30 04:42:30 UTC (rev 35180)
@@ -216,7 +216,7 @@
* do NOT include the leading 0xF0 and the trailing 0xF7.
*
* Furthermore, the maximal supported length of a SysEx
- * is 254 bytes. Passing longer buffers can lead to
+ * is 264 bytes. Passing longer buffers can lead to
* undefined behavior (most likely, a crash).
*/
virtual void sysEx(const byte *msg, uint16 length) { }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list