aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMartin Kiewitz2015-06-02 17:36:22 +0200
committerMartin Kiewitz2015-06-02 17:36:22 +0200
commit100dd52a8efcb8e2871924c8837dd0747a440eb0 (patch)
tree73ac6c20ba07eb0a9e3d4fa14452a7a843fac8ae /engines
parentc0d71bb900017b3d8b9ba81449dbf0ed4c57f44b (diff)
downloadscummvm-rg350-100dd52a8efcb8e2871924c8837dd0747a440eb0.tar.gz
scummvm-rg350-100dd52a8efcb8e2871924c8837dd0747a440eb0.tar.bz2
scummvm-rg350-100dd52a8efcb8e2871924c8837dd0747a440eb0.zip
SHERLOCK: rename MT32 driver, fix SysExPos
Diffstat (limited to 'engines')
-rw-r--r--engines/sherlock/module.mk2
-rw-r--r--engines/sherlock/music.cpp8
-rw-r--r--engines/sherlock/scalpel/drivers/mididriver.h6
-rw-r--r--engines/sherlock/scalpel/drivers/mt32.cpp (renamed from engines/sherlock/scalpel/drivers/midi.cpp)37
4 files changed, 27 insertions, 26 deletions
diff --git a/engines/sherlock/module.mk b/engines/sherlock/module.mk
index 32ea862533..246b3e1077 100644
--- a/engines/sherlock/module.mk
+++ b/engines/sherlock/module.mk
@@ -4,7 +4,7 @@ MODULE_OBJS = \
scalpel/darts.o \
scalpel/scalpel.o \
scalpel/drivers/adlib.o \
- scalpel/drivers/midi.o \
+ scalpel/drivers/mt32.o \
scalpel/tsage/logo.o \
scalpel/tsage/resources.o \
scalpel/scalpel_scene.o \
diff --git a/engines/sherlock/music.cpp b/engines/sherlock/music.cpp
index d165d924fd..e61785031b 100644
--- a/engines/sherlock/music.cpp
+++ b/engines/sherlock/music.cpp
@@ -201,11 +201,11 @@ Music::Music(SherlockEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
_driver = MidiDriver_AdLib_create();
break;
case MT_MT32:
- _driver = MidiDriver_MIDI_create();
+ _driver = MidiDriver_MT32_create();
break;
case MT_GM:
if (ConfMan.getBool("native_mt32")) {
- _driver = MidiDriver_MIDI_create();
+ _driver = MidiDriver_MT32_create();
_musicType = MT_MT32;
}
default:
@@ -241,7 +241,7 @@ Music::Music(SherlockEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
byte *MT32driverDataPtr = MT32driverData + 12;
MT32driverDataSize -= 12;
- MidiDriver_MIDI_uploadMT32Patches(_driver, MT32driverDataPtr, MT32driverDataSize);
+ MidiDriver_MT32_uploadPatches(_driver, MT32driverDataPtr, MT32driverDataSize);
delete[] MT32driverData;
}
} else {
@@ -339,7 +339,7 @@ bool Music::playMusic(const Common::String &name) {
break;
case MT_MT32:
- MidiDriver_MIDI_newMusicData(_driver, dataPos, dataSize);
+ MidiDriver_MT32_newMusicData(_driver, dataPos, dataSize);
break;
}
}
diff --git a/engines/sherlock/scalpel/drivers/mididriver.h b/engines/sherlock/scalpel/drivers/mididriver.h
index e38f27dc4e..2d989f298a 100644
--- a/engines/sherlock/scalpel/drivers/mididriver.h
+++ b/engines/sherlock/scalpel/drivers/mididriver.h
@@ -32,9 +32,9 @@ namespace Sherlock {
extern MidiDriver *MidiDriver_AdLib_create();
extern void MidiDriver_AdLib_newMusicData(MidiDriver *driver, byte *musicData, int32 musicDataSize);
-extern MidiDriver *MidiDriver_MIDI_create();
-extern void MidiDriver_MIDI_uploadMT32Patches(MidiDriver *driver, byte *driverData, int32 driverSize);
-extern void MidiDriver_MIDI_newMusicData(MidiDriver *driver, byte *musicData, int32 musicDataSize);
+extern MidiDriver *MidiDriver_MT32_create();
+extern void MidiDriver_MT32_uploadPatches(MidiDriver *driver, byte *driverData, int32 driverSize);
+extern void MidiDriver_MT32_newMusicData(MidiDriver *driver, byte *musicData, int32 musicDataSize);
} // End of namespace Sci
diff --git a/engines/sherlock/scalpel/drivers/midi.cpp b/engines/sherlock/scalpel/drivers/mt32.cpp
index fce30afb90..13e2845fa3 100644
--- a/engines/sherlock/scalpel/drivers/midi.cpp
+++ b/engines/sherlock/scalpel/drivers/mt32.cpp
@@ -38,9 +38,9 @@ const byte mt32_reverbDataSysEx[] = {
0x10, 0x00, 0x01, 0x01, 0x05, 0x05, 0xFF
};
-class MidiDriver_MIDI : public MidiDriver {
+class MidiDriver_MT32 : public MidiDriver {
public:
- MidiDriver_MIDI() {
+ MidiDriver_MT32() {
_driver = NULL;
_isOpen = false;
_MT32 = false;
@@ -49,7 +49,7 @@ public:
memset(_MIDIchannelActive, 1, sizeof(_MIDIchannelActive));
}
- virtual ~MidiDriver_MIDI();
+ virtual ~MidiDriver_MT32();
// MidiDriver
int open();
@@ -106,7 +106,7 @@ public:
void MT32SysEx(const byte *&dataPtr, int32 &bytesLeft);
};
-MidiDriver_MIDI::~MidiDriver_MIDI() {
+MidiDriver_MT32::~MidiDriver_MT32() {
Common::StackLock lock(_mutex);
if (_driver) {
_driver->setTimerCallback(0, 0);
@@ -116,7 +116,7 @@ MidiDriver_MIDI::~MidiDriver_MIDI() {
_driver = NULL;
}
-int MidiDriver_MIDI::open() {
+int MidiDriver_MT32::open() {
assert(!_driver);
debugC(kDebugLevelMT32Driver, "MT32: starting driver");
@@ -159,14 +159,14 @@ int MidiDriver_MIDI::open() {
return 0;
}
-void MidiDriver_MIDI::close() {
+void MidiDriver_MT32::close() {
if (_driver) {
_driver->close();
}
}
// Called when a music track got loaded into memory
-void MidiDriver_MIDI::newMusicData(byte *musicData, int32 musicDataSize) {
+void MidiDriver_MT32::newMusicData(byte *musicData, int32 musicDataSize) {
assert(musicDataSize >= 0x7F); // Security check
// MIDI Channel Enable/Disable bytes at offset 0x2 of music data
@@ -185,7 +185,7 @@ void MidiDriver_MIDI::newMusicData(byte *musicData, int32 musicDataSize) {
}
}
-void MidiDriver_MIDI::uploadMT32Patches(byte *driverData, int32 driverSize) {
+void MidiDriver_MT32::uploadMT32Patches(byte *driverData, int32 driverSize) {
if (!_driver)
return;
@@ -208,9 +208,9 @@ void MidiDriver_MIDI::uploadMT32Patches(byte *driverData, int32 driverSize) {
}
}
-void MidiDriver_MIDI::MT32SysEx(const byte *&dataPtr, int32 &bytesLeft) {
+void MidiDriver_MT32::MT32SysEx(const byte *&dataPtr, int32 &bytesLeft) {
byte sysExMessage[270];
- byte sysExPos = 0;
+ uint16 sysExPos = 0;
byte sysExByte = 0;
uint16 sysExChecksum = 0;
@@ -231,12 +231,13 @@ void MidiDriver_MIDI::MT32SysEx(const byte *&dataPtr, int32 &bytesLeft) {
if (sysExByte == 0xff)
break; // Message done
- assert(sysExPos < 260);
+ assert(sysExPos < sizeof(sysExMessage));
sysExMessage[sysExPos++] = sysExByte;
sysExChecksum -= sysExByte;
}
// Calculate checksum
+ assert(sysExPos < sizeof(sysExMessage));
sysExMessage[sysExPos++] = sysExChecksum & 0x7f;
debugC(kDebugLevelMT32Driver, "MT32: uploading patch data, size %d", sysExPos);
@@ -255,7 +256,7 @@ void MidiDriver_MIDI::MT32SysEx(const byte *&dataPtr, int32 &bytesLeft) {
}
// MIDI messages can be found at http://www.midi.org/techspecs/midimessages.php
-void MidiDriver_MIDI::send(uint32 b) {
+void MidiDriver_MT32::send(uint32 b) {
byte command = b & 0xf0;
byte channel = b & 0xf;
@@ -274,16 +275,16 @@ void MidiDriver_MIDI::send(uint32 b) {
}
}
-MidiDriver *MidiDriver_MIDI_create() {
- return new MidiDriver_MIDI();
+MidiDriver *MidiDriver_MT32_create() {
+ return new MidiDriver_MT32();
}
-void MidiDriver_MIDI_newMusicData(MidiDriver *driver, byte *musicData, int32 musicDataSize) {
- static_cast<MidiDriver_MIDI *>(driver)->newMusicData(musicData, musicDataSize);
+void MidiDriver_MT32_newMusicData(MidiDriver *driver, byte *musicData, int32 musicDataSize) {
+ static_cast<MidiDriver_MT32 *>(driver)->newMusicData(musicData, musicDataSize);
}
-void MidiDriver_MIDI_uploadMT32Patches(MidiDriver *driver, byte *driverData, int32 driverSize) {
- static_cast<MidiDriver_MIDI *>(driver)->uploadMT32Patches(driverData, driverSize);
+void MidiDriver_MT32_uploadPatches(MidiDriver *driver, byte *driverData, int32 driverSize) {
+ static_cast<MidiDriver_MT32 *>(driver)->uploadMT32Patches(driverData, driverSize);
}
} // End of namespace Sci