diff options
author | Jamieson Christian | 2003-01-10 14:40:22 +0000 |
---|---|---|
committer | Jamieson Christian | 2003-01-10 14:40:22 +0000 |
commit | b942f426706c1d37a9f3b873f2dc0577a8cd299a (patch) | |
tree | 75333150ddee23c2211ef715e91c5ec51d2e3ff9 | |
parent | a8f4c821cf6f615abd90b5bcc90ea0837bec8041 (diff) | |
download | scummvm-rg350-b942f426706c1d37a9f3b873f2dc0577a8cd299a.tar.gz scummvm-rg350-b942f426706c1d37a9f3b873f2dc0577a8cd299a.tar.bz2 scummvm-rg350-b942f426706c1d37a9f3b873f2dc0577a8cd299a.zip |
First-revision SysEx support for -ewindows.
svn-id: r6381
-rw-r--r-- | backends/midi/windows.cpp | 44 | ||||
-rw-r--r-- | scumm/instrument.cpp | 2 | ||||
-rw-r--r-- | scumm/instrument.h | 2 |
3 files changed, 45 insertions, 3 deletions
diff --git a/backends/midi/windows.cpp b/backends/midi/windows.cpp index bb2f33c050..c78dea3a6e 100644 --- a/backends/midi/windows.cpp +++ b/backends/midi/windows.cpp @@ -32,6 +32,9 @@ class MidiDriver_WIN : public MidiDriver_MPU401 { private: + MIDIHDR _streamHeader; + byte _streamBuffer [258]; // SysEx blocks should be no larger than 256 bytes + HANDLE _streamEvent; HMIDIOUT _mo; bool _isOpen; @@ -43,6 +46,7 @@ public: int open(); void close(); void send(uint32 b); + void sysEx (byte *msg, uint16 length); }; int MidiDriver_WIN::open() @@ -50,7 +54,8 @@ int MidiDriver_WIN::open() if (_isOpen) return MERR_ALREADY_OPEN; - MMRESULT res = midiOutOpen((HMIDIOUT *) &_mo, MIDI_MAPPER, 0, 0, 0); + _streamEvent = CreateEvent (NULL, true, true, NULL); + MMRESULT res = midiOutOpen((HMIDIOUT *) &_mo, MIDI_MAPPER, (unsigned long) _streamEvent, 0, CALLBACK_EVENT); if (res != MMSYSERR_NOERROR) { check_error(res); return MERR_DEVICE_NOT_AVAILABLE; @@ -64,6 +69,7 @@ void MidiDriver_WIN::close() { _isOpen = false; check_error(midiOutClose(_mo)); + CloseHandle (_streamEvent); } void MidiDriver_WIN::send(uint32 b) @@ -82,6 +88,42 @@ void MidiDriver_WIN::send(uint32 b) check_error(midiOutShortMsg(_mo, u.dwData)); } +void MidiDriver_WIN::sysEx (byte *msg, uint16 length) +{ + if (!_isOpen) + return; + + if (WaitForSingleObject (_streamEvent, 2000) == WAIT_TIMEOUT) { + warning ("Could not send SysEx - MMSYSTEM is still trying to send data."); + return; + } + + midiOutUnprepareHeader (_mo, &_streamHeader, sizeof (_streamHeader)); + _streamBuffer [0] = 0xFF; + memcpy (&_streamBuffer[1], msg, length); + _streamBuffer [length+1] = 0xF7; + + _streamHeader.lpData = (char *) _streamBuffer; + _streamHeader.dwBufferLength = length + 2; + _streamHeader.dwBytesRecorded = length + 2; + _streamHeader.dwUser = 0; + _streamHeader.dwFlags |= MHDR_ISSTRM; + + MMRESULT result = midiOutPrepareHeader (_mo, &_streamHeader, sizeof (_streamHeader)); + if (result != MMSYSERR_NOERROR) { + check_error (result); + return; + } + + ResetEvent (_streamEvent); + result = midiOutLongMsg (_mo, &_streamHeader, sizeof (_streamHeader)); + if (result != MMSYSERR_NOERROR) { + check_error (result); + SetEvent (_streamEvent); + return; + } +} + void MidiDriver_WIN::check_error(MMRESULT result) { char buf[200]; diff --git a/scumm/instrument.cpp b/scumm/instrument.cpp index 897c6d4086..f7759e81ad 100644 --- a/scumm/instrument.cpp +++ b/scumm/instrument.cpp @@ -25,6 +25,8 @@ #include "scumm/instrument.h" #include "sound/mididrv.h" +#define NATIVE_MT32 true + static const byte mt32_to_gm[128] = { // 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 diff --git a/scumm/instrument.h b/scumm/instrument.h index a3ab367142..9a64243068 100644 --- a/scumm/instrument.h +++ b/scumm/instrument.h @@ -25,8 +25,6 @@ #include "stdafx.h" #include "common/scummsys.h" -#define NATIVE_MT32 false - class Serializer; class MidiChannel; |