aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/midi/alsa.cpp37
-rw-r--r--backends/midi/camd.cpp33
-rw-r--r--backends/midi/coreaudio.cpp31
-rw-r--r--backends/midi/coremidi.cpp31
-rw-r--r--backends/midi/dmedia.cpp31
-rw-r--r--backends/midi/quicktime.cpp31
-rw-r--r--backends/midi/seq.cpp31
-rw-r--r--backends/midi/timidity.cpp29
-rw-r--r--backends/midi/windows.cpp31
-rw-r--r--backends/midi/ypa1.cpp31
-rw-r--r--backends/midi/zodiac.cpp31
-rw-r--r--backends/platform/null/null.cpp4
-rw-r--r--base/plugins.cpp14
-rw-r--r--base/plugins.h4
-rw-r--r--dists/msvc7/scummvm.vcproj5
-rw-r--r--dists/msvc71/scummvm.vcproj5
-rw-r--r--dists/msvc8/scummvm.vcproj6
-rw-r--r--dists/msvc9/scummvm.vcproj6
-rw-r--r--engines/cine/part.cpp6
-rw-r--r--engines/cine/unpack.cpp73
-rw-r--r--engines/cine/unpack.h64
-rw-r--r--engines/made/database.cpp9
-rw-r--r--engines/made/database.h6
-rw-r--r--engines/made/detection.cpp17
-rw-r--r--engines/made/made.cpp13
-rw-r--r--engines/made/made.h15
-rw-r--r--engines/made/screen.h1
-rw-r--r--engines/made/script.cpp7
-rw-r--r--engines/made/scriptfuncs.cpp22
-rw-r--r--sound/midiplugin.h93
-rw-r--r--sound/module.mk1
-rw-r--r--sound/musicplugin.cpp48
-rw-r--r--sound/musicplugin.h127
-rw-r--r--sound/null.cpp30
-rw-r--r--sound/softsynth/adlib.cpp29
-rw-r--r--sound/softsynth/fluidsynth.cpp29
-rw-r--r--sound/softsynth/mt32.cpp29
-rw-r--r--sound/softsynth/ym2612.cpp29
38 files changed, 644 insertions, 395 deletions
diff --git a/backends/midi/alsa.cpp b/backends/midi/alsa.cpp
index 6b0e424d68..2a252b9323 100644
--- a/backends/midi/alsa.cpp
+++ b/backends/midi/alsa.cpp
@@ -28,7 +28,7 @@
#include "common/config-manager.h"
#include "common/util.h"
-#include "sound/midiplugin.h"
+#include "sound/musicplugin.h"
#include "sound/mpu401.h"
#include <alsa/asoundlib.h>
@@ -79,7 +79,7 @@ MidiDriver_ALSA::MidiDriver_ALSA()
}
int MidiDriver_ALSA::open() {
- char *var;
+ const char *var;
if (_isOpen)
return MERR_ALREADY_OPEN;
@@ -87,7 +87,8 @@ int MidiDriver_ALSA::open() {
if (!(var = getenv("SCUMMVM_PORT"))) {
// use config option if no var specified
- if (parse_addr(ConfMan.get("alsa_port").c_str(), &seq_client, &seq_port) < 0) {
+ var = ConfMan.get("alsa_port").c_str();
+ if (parse_addr(var, &seq_client, &seq_port) < 0) {
error("Invalid port %s", var);
return -1;
}
@@ -241,23 +242,18 @@ void MidiDriver_ALSA::send_event(int do_flush) {
// Plugin interface
-class AlsaMidiPlugin : public MidiPluginObject {
+class AlsaMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "ALSA";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "alsa";
}
- virtual int getCapabilities() const {
- return MDT_MIDI;
- }
-
- virtual Common::StringList getDevices() const;
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
#define perm_ok(pinfo,bits) ((snd_seq_port_info_get_capability(pinfo) & (bits)) == (bits))
@@ -271,8 +267,8 @@ static int check_permission(snd_seq_port_info_t *pinfo)
return 0;
}
-Common::StringList AlsaMidiPlugin::getDevices() const {
- Common::StringList devices;
+MusicDevices AlsaMusicPlugin::getDevices() const {
+ MusicDevices devices;
snd_seq_t *seq;
if (snd_seq_open(&seq, "default", SND_SEQ_OPEN_DUPLEX, 0) < 0)
@@ -292,7 +288,8 @@ Common::StringList AlsaMidiPlugin::getDevices() const {
while (!found_valid_port && snd_seq_query_next_port(seq, pinfo) >= 0) {
if (check_permission(pinfo)) {
found_valid_port = true;
- devices.push_back(snd_seq_client_info_get_name(cinfo));
+ // TODO: Return a different music type depending on the configuration
+ devices.push_back(MusicDevice(this, snd_seq_client_info_get_name(cinfo), MT_GM));
//snd_seq_client_info_get_client(cinfo) : snd_seq_port_info_get_port(pinfo)
}
}
@@ -302,7 +299,7 @@ Common::StringList AlsaMidiPlugin::getDevices() const {
return devices;
}
-PluginError AlsaMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+PluginError AlsaMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_ALSA();
return kNoError;
@@ -311,16 +308,16 @@ PluginError AlsaMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mid
MidiDriver *MidiDriver_ALSA_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- AlsaMidiPlugin p;
+ AlsaMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(ALSA)
- //REGISTER_PLUGIN_DYNAMIC(ALSA, PLUGIN_TYPE_MIDI, AlsaMidiPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(ALSA, PLUGIN_TYPE_MUSIC, AlsaMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(ALSA, PLUGIN_TYPE_MIDI, AlsaMidiPlugin);
+ REGISTER_PLUGIN_STATIC(ALSA, PLUGIN_TYPE_MUSIC, AlsaMusicPlugin);
//#endif
#endif
diff --git a/backends/midi/camd.cpp b/backends/midi/camd.cpp
index 6aa79eb260..d6d5819a6e 100644
--- a/backends/midi/camd.cpp
+++ b/backends/midi/camd.cpp
@@ -28,7 +28,7 @@
#include "common/endian.h"
#include "common/util.h"
-#include "sound/midiplugin.h"
+#include "sound/musicplugin.h"
#include "sound/mpu401.h"
#include <proto/camd.h>
@@ -166,26 +166,29 @@ void MidiDriver_CAMD::closeAll() {
// Plugin interface
-class CamdMidiPlugin : public MidiPluginObject {
+class CamdMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "CAMD";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "camd";
}
- virtual int getCapabilities() const {
- return MDT_MIDI;
- }
-
- //virtual Common::StringList getDevices() const;
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError CamdMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+MusicDevices CamdMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ // TODO: Return a different music type depending on the configuration
+ // TODO: List the available devices
+ devices.push_back(MusicDevice(this, "", MT_GM));
+ return devices;
+}
+
+PluginError CamdMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_CAMD();
return kNoError;
@@ -194,16 +197,16 @@ PluginError CamdMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mid
MidiDriver *MidiDriver_CAMD_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- CamdMidiPlugin p;
+ CamdMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(CAMD)
- //REGISTER_PLUGIN_DYNAMIC(CAMD, PLUGIN_TYPE_MIDI, CamdMidiPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(CAMD, PLUGIN_TYPE_MUSIC, CamdMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(CAMD, PLUGIN_TYPE_MIDI, CamdMidiPlugin);
+ REGISTER_PLUGIN_STATIC(CAMD, PLUGIN_TYPE_MUSIC, CamdMusicPlugin);
//#endif
#endif
diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp
index d7ab93a90a..bf35fb90ba 100644
--- a/backends/midi/coreaudio.cpp
+++ b/backends/midi/coreaudio.cpp
@@ -37,7 +37,7 @@
#include "common/config-manager.h"
#include "common/util.h"
-#include "sound/midiplugin.h"
+#include "sound/musicplugin.h"
#include "sound/mpu401.h"
#include <AudioToolbox/AUGraph.h>
@@ -207,24 +207,29 @@ void MidiDriver_CORE::sysEx(const byte *msg, uint16 length) {
// Plugin interface
-class CoreAudioMidiPlugin : public MidiPluginObject {
+class CoreAudioMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "CoreAudio";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "core";
}
- virtual int getCapabilities() const {
- return MDT_MIDI;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError CoreAudioMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+MusicDevices CoreAudioMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ // TODO: Return a different music type depending on the configuration
+ // TODO: List the available devices
+ devices.push_back(MusicDevice(this, "", MT_GM));
+ return devices;
+}
+
+PluginError CoreAudioMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_CORE();
return kNoError;
@@ -233,16 +238,16 @@ PluginError CoreAudioMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver
MidiDriver *MidiDriver_CORE_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- CoreAudioMidiPlugin p;
+ CoreAudioMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(COREAUDIO)
- //REGISTER_PLUGIN_DYNAMIC(COREAUDIO, PLUGIN_TYPE_MIDI, CoreAudioMidiPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(COREAUDIO, PLUGIN_TYPE_MUSIC, CoreAudioMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(COREAUDIO, PLUGIN_TYPE_MIDI, CoreAudioMidiPlugin);
+ REGISTER_PLUGIN_STATIC(COREAUDIO, PLUGIN_TYPE_MUSIC, CoreAudioMusicPlugin);
//#endif
#endif // MACOSX
diff --git a/backends/midi/coremidi.cpp b/backends/midi/coremidi.cpp
index efbdaad4e4..da82249792 100644
--- a/backends/midi/coremidi.cpp
+++ b/backends/midi/coremidi.cpp
@@ -26,7 +26,7 @@
#include "common/config-manager.h"
#include "common/util.h"
-#include "sound/midiplugin.h"
+#include "sound/musicplugin.h"
#include "sound/mpu401.h"
#include <CoreMIDI/CoreMIDI.h>
@@ -179,24 +179,29 @@ void MidiDriver_CoreMIDI::sysEx(const byte *msg, uint16 length) {
// Plugin interface
-class CoreMIDIMidiPlugin : public MidiPluginObject {
+class CoreMIDIMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "CoreMIDI";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "coremidi";
}
- virtual int getCapabilities() const {
- return MDT_MIDI;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError CoreMIDIMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+MusicDevices CoreMIDIMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ // TODO: Return a different music type depending on the configuration
+ // TODO: List the available devices
+ devices.push_back(MusicDevice(this, "", MT_GM));
+ return devices;
+}
+
+PluginError CoreMIDIMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_CoreMIDI();
return kNoError;
@@ -205,16 +210,16 @@ PluginError CoreMIDIMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver *
MidiDriver *MidiDriver_CoreMIDI_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- CoreMIDIMidiPlugin p;
+ CoreMIDIMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(COREMIDI)
- //REGISTER_PLUGIN_DYNAMIC(COREMIDI, PLUGIN_TYPE_MIDI, CoreMIDIMidiPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(COREMIDI, PLUGIN_TYPE_MUSIC, CoreMIDIMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(COREMIDI, PLUGIN_TYPE_MIDI, CoreMIDIMidiPlugin);
+ REGISTER_PLUGIN_STATIC(COREMIDI, PLUGIN_TYPE_MUSIC, CoreMIDIMusicPlugin);
//#endif
#endif // MACOSX
diff --git a/backends/midi/dmedia.cpp b/backends/midi/dmedia.cpp
index 885081e3e0..b4bd426ca4 100644
--- a/backends/midi/dmedia.cpp
+++ b/backends/midi/dmedia.cpp
@@ -31,7 +31,7 @@
#include "common/scummsys.h"
#include "common/util.h"
-#include "sound/midiplugin.h"
+#include "sound/musicplugin.h"
#include "sound/mpu401.h"
#include <dmedia/midi.h>
@@ -178,24 +178,29 @@ void MidiDriver_DMEDIA::sysEx (const byte *msg, uint16 length) {
// Plugin interface
-class DMediaMidiPlugin : public MidiPluginObject {
+class DMediaMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "DMedia";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "dmedia";
}
- virtual int getCapabilities() const {
- return MDT_MIDI;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError DMediaMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+MusicDevices DMediaMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ // TODO: Return a different music type depending on the configuration
+ // TODO: List the available devices
+ devices.push_back(MusicDevice(this, "", MT_GM));
+ return devices;
+}
+
+PluginError DMediaMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_DMEDIA();
return kNoError;
@@ -204,16 +209,16 @@ PluginError DMediaMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **m
MidiDriver *MidiDriver_DMEDIA_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- DMediaMidiPlugin p;
+ DMediaMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(DMEDIA)
- //REGISTER_PLUGIN_DYNAMIC(DMEDIA, PLUGIN_TYPE_MIDI, DMediaMidiPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(DMEDIA, PLUGIN_TYPE_MUSIC, DMediaMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(DMEDIA, PLUGIN_TYPE_MIDI, DMediaMidiPlugin);
+ REGISTER_PLUGIN_STATIC(DMEDIA, PLUGIN_TYPE_MUSIC, DMediaMusicPlugin);
//#endif
#endif
diff --git a/backends/midi/quicktime.cpp b/backends/midi/quicktime.cpp
index 63905212e6..568adf022b 100644
--- a/backends/midi/quicktime.cpp
+++ b/backends/midi/quicktime.cpp
@@ -38,7 +38,7 @@
#include "common/endian.h"
#include "common/util.h"
-#include "sound/midiplugin.h"
+#include "sound/musicplugin.h"
#include "sound/mpu401.h"
#if defined(MACOSX)
@@ -265,24 +265,29 @@ void MidiDriver_QT::dispose()
// Plugin interface
-class QuickTimeMidiPlugin : public MidiPluginObject {
+class QuickTimeMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "QuickTime";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "qt";
}
- virtual int getCapabilities() const {
- return MDT_MIDI;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError QuickTimeMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+MusicDevices QuickTimeMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ // TODO: Return a different music type depending on the configuration
+ // TODO: List the available devices
+ devices.push_back(MusicDevice(this, "", MT_GM));
+ return devices;
+}
+
+PluginError QuickTimeMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_QT();
return kNoError;
@@ -291,16 +296,16 @@ PluginError QuickTimeMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver
MidiDriver *MidiDriver_QT_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- QuickTimeMidiPlugin p;
+ QuickTimeMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(QUICKTIME)
- //REGISTER_PLUGIN_DYNAMIC(QUICKTIME, PLUGIN_TYPE_MIDI, QuickTimeMidiPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(QUICKTIME, PLUGIN_TYPE_MUSIC, QuickTimeMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(QUICKTIME, PLUGIN_TYPE_MIDI, QuickTimeMidiPlugin);
+ REGISTER_PLUGIN_STATIC(QUICKTIME, PLUGIN_TYPE_MUSIC, QuickTimeMusicPlugin);
//#endif
#endif // MACOSX || macintosh
diff --git a/backends/midi/seq.cpp b/backends/midi/seq.cpp
index 07dfc25142..57a5a1ea32 100644
--- a/backends/midi/seq.cpp
+++ b/backends/midi/seq.cpp
@@ -31,7 +31,7 @@
#if defined(UNIX) && !defined(__BEOS__) && !defined(__MAEMO__)
#include "common/util.h"
-#include "sound/midiplugin.h"
+#include "sound/musicplugin.h"
#include "sound/mpu401.h"
#include <fcntl.h>
@@ -173,24 +173,29 @@ void MidiDriver_SEQ::sysEx (const byte *msg, uint16 length) {
// Plugin interface
-class SeqMidiPlugin : public MidiPluginObject {
+class SeqMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "SEQ";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "seq";
}
- virtual int getCapabilities() const {
- return MDT_MIDI;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError SeqMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+MusicDevices SeqMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ // TODO: Return a different music type depending on the configuration
+ // TODO: List the available devices
+ devices.push_back(MusicDevice(this, "", MT_GM));
+ return devices;
+}
+
+PluginError SeqMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_SEQ();
return kNoError;
@@ -199,16 +204,16 @@ PluginError SeqMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **midi
MidiDriver *MidiDriver_SEQ_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- SeqMidiPlugin p;
+ SeqMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(SEQ)
- //REGISTER_PLUGIN_DYNAMIC(SEQ, PLUGIN_TYPE_MIDI, SeqMidiPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(SEQ, PLUGIN_TYPE_MUSIC, SeqMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(SEQ, PLUGIN_TYPE_MIDI, SeqMidiPlugin);
+ REGISTER_PLUGIN_STATIC(SEQ, PLUGIN_TYPE_MUSIC, SeqMusicPlugin);
//#endif
#endif
diff --git a/backends/midi/timidity.cpp b/backends/midi/timidity.cpp
index 842fb358bf..b262fed88c 100644
--- a/backends/midi/timidity.cpp
+++ b/backends/midi/timidity.cpp
@@ -37,7 +37,7 @@
#if defined (UNIX)
#include "common/util.h"
-#include "sound/midiplugin.h"
+#include "sound/musicplugin.h"
#include "sound/mpu401.h"
#include <fcntl.h>
@@ -514,24 +514,27 @@ void MidiDriver_TIMIDITY::sysEx(const byte *msg, uint16 length) {
// Plugin interface
-class TimidityMidiPlugin : public MidiPluginObject {
+class TimidityMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "TiMidity";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "timidity";
}
- virtual int getCapabilities() const {
- return MDT_MIDI;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError TimidityMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+MusicDevices TimidityMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ devices.push_back(MusicDevice(this, "", MT_GM));
+ return devices;
+}
+
+PluginError TimidityMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_TIMIDITY();
return kNoError;
@@ -540,16 +543,16 @@ PluginError TimidityMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver *
MidiDriver *MidiDriver_TIMIDITY_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- TimidityMidiPlugin p;
+ TimidityMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(TIMIDITY)
- //REGISTER_PLUGIN_DYNAMIC(TIMIDITY, PLUGIN_TYPE_MIDI, TimidityMidiPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(TIMIDITY, PLUGIN_TYPE_MUSIC, TimidityMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(TIMIDITY, PLUGIN_TYPE_MIDI, TimidityMidiPlugin);
+ REGISTER_PLUGIN_STATIC(TIMIDITY, PLUGIN_TYPE_MUSIC, TimidityMusicPlugin);
//#endif
#endif // defined (UNIX)
diff --git a/backends/midi/windows.cpp b/backends/midi/windows.cpp
index 083f0eaf96..c564c124fe 100644
--- a/backends/midi/windows.cpp
+++ b/backends/midi/windows.cpp
@@ -28,7 +28,7 @@
// winnt.h defines ARRAYSIZE, but we want our own one...
#undef ARRAYSIZE
-#include "sound/midiplugin.h"
+#include "sound/musicplugin.h"
#include "sound/mpu401.h"
#include <mmsystem.h>
@@ -147,24 +147,29 @@ void MidiDriver_WIN::check_error(MMRESULT result) {
// Plugin interface
-class WindowsMidiPlugin : public MidiPluginObject {
+class WindowsMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "Windows MIDI";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "windows";
}
- virtual int getCapabilities() const {
- return MDT_MIDI;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError WindowsMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+MusicDevices WindowsMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ // TODO: Return a different music type depending on the configuration
+ // TODO: List the available devices
+ devices.push_back(MusicDevice(this, "", MT_GM));
+ return devices;
+}
+
+PluginError WindowsMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_WIN();
return kNoError;
@@ -173,16 +178,16 @@ PluginError WindowsMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **
MidiDriver *MidiDriver_WIN_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- WindowsMidiPlugin p;
+ WindowsMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(WINDOWS)
- //REGISTER_PLUGIN_DYNAMIC(WINDOWS, PLUGIN_TYPE_MIDI, WindowsMidiPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(WINDOWS, PLUGIN_TYPE_MUSIC, WindowsMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(WINDOWS, PLUGIN_TYPE_MIDI, WindowsMidiPlugin);
+ REGISTER_PLUGIN_STATIC(WINDOWS, PLUGIN_TYPE_MUSIC, WindowsMusicPlugin);
//#endif
#endif
diff --git a/backends/midi/ypa1.cpp b/backends/midi/ypa1.cpp
index 37d90d45b0..88f9c3de8f 100644
--- a/backends/midi/ypa1.cpp
+++ b/backends/midi/ypa1.cpp
@@ -23,7 +23,7 @@
*/
#include "common/util.h"
-#include "sound/midiplugin.h"
+#include "sound/musicplugin.h"
#include "sound/mpu401.h"
#include "Pa1Lib.h"
@@ -106,24 +106,29 @@ void MidiDriver_YamahaPa1::send(uint32 b) {
// Plugin interface
-class YamahaPa1MidiPlugin : public MidiPluginObject {
+class YamahaPa1MusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "Yamaha Pa1";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "ypa1";
}
- virtual int getCapabilities() const {
- return MDT_MIDI;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError YamahaPa1MidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+MusicDevices YamahaPa1MusicPlugin::getDevices() const {
+ MusicDevices devices;
+ // TODO: Return a different music type depending on the configuration
+ // TODO: List the available devices
+ devices.push_back(MusicDevice(this, "", MT_GM));
+ return devices;
+}
+
+PluginError YamahaPa1MusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_YamahaPa1();
return kNoError;
@@ -132,14 +137,14 @@ PluginError YamahaPa1MidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver
MidiDriver *MidiDriver_YamahaPa1_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- YamahaPa1MidiPlugin p;
+ YamahaPa1MusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(YPA1)
- //REGISTER_PLUGIN_DYNAMIC(YPA1, PLUGIN_TYPE_MIDI, YamahaPa1MidiPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(YPA1, PLUGIN_TYPE_MUSIC, YamahaPa1MusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(YPA1, PLUGIN_TYPE_MIDI, YamahaPa1MidiPlugin);
+ REGISTER_PLUGIN_STATIC(YPA1, PLUGIN_TYPE_MUSIC, YamahaPa1MusicPlugin);
//#endif
diff --git a/backends/midi/zodiac.cpp b/backends/midi/zodiac.cpp
index f27c042de8..456e4df43a 100644
--- a/backends/midi/zodiac.cpp
+++ b/backends/midi/zodiac.cpp
@@ -23,7 +23,7 @@
*/
#include "common/util.h"
-#include "sound/midiplugin.h"
+#include "sound/musicplugin.h"
#include "sound/mpu401.h"
#ifndef DISABLE_TAPWAVE
@@ -124,24 +124,29 @@ void MidiDriver_Zodiac::sysEx(const byte *msg, uint16 length) {
// Plugin interface
-class ZodiacMidiPlugin : public MidiPluginObject {
+class ZodiacMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "Tapwave Zodiac";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "zodiac";
}
- virtual int getCapabilities() const {
- return MDT_MIDI;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError ZodiacMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+MusicDevices ZodiacMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ // TODO: Return a different music type depending on the configuration
+ // TODO: List the available devices
+ devices.push_back(MusicDevice(this, "", MT_GM));
+ return devices;
+}
+
+PluginError ZodiacMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_Zodiac();
return kNoError;
@@ -150,16 +155,16 @@ PluginError ZodiacMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **m
MidiDriver *MidiDriver_Zodiac_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- ZodiacMidiPlugin p;
+ ZodiacMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(ZODIAC)
- //REGISTER_PLUGIN_DYNAMIC(ZODIAC, PLUGIN_TYPE_MIDI, ZodiacMidiPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(ZODIAC, PLUGIN_TYPE_MUSIC, ZodiacMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(ZODIAC, PLUGIN_TYPE_MIDI, ZodiacMidiPlugin);
+ REGISTER_PLUGIN_STATIC(ZODIAC, PLUGIN_TYPE_MUSIC, ZodiacMusicPlugin);
//#endif
#endif
diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp
index 194a7b6889..64d429a83e 100644
--- a/backends/platform/null/null.cpp
+++ b/backends/platform/null/null.cpp
@@ -102,6 +102,7 @@ public:
virtual Common::SaveFileManager *getSavefileManager();
virtual Audio::Mixer *getMixer();
+ virtual void getTimeAndDate(struct tm &t) const;
virtual Common::TimerManager *getTimerManager();
};
@@ -295,6 +296,9 @@ Common::TimerManager *OSystem_NULL::getTimerManager() {
return _timer;
}
+void OSystem_NULL::getTimeAndDate(struct tm &t) const {
+}
+
OSystem *OSystem_NULL_create() {
return new OSystem_NULL();
}
diff --git a/base/plugins.cpp b/base/plugins.cpp
index 7c365c7eb6..dcd394495f 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -35,7 +35,7 @@
int pluginTypeVersions[PLUGIN_TYPE_MAX] = {
PLUGIN_TYPE_ENGINE_VERSION,
- PLUGIN_TYPE_MIDI_VERSION,
+ PLUGIN_TYPE_MUSIC_VERSION,
};
@@ -144,7 +144,7 @@ public:
LINK_PLUGIN(TOUCHE)
#endif
- // MIDI plugins
+ // Music plugins
// TODO: Use defines to disable or enable each MIDI driver as a
// static/dynamic plugin, like it's done for the engines
LINK_PLUGIN(NULL)
@@ -393,12 +393,12 @@ const EnginePlugin::List &EngineManager::getPlugins() const {
}
-// MIDI plugins
+// Music plugins
-#include "sound/midiplugin.h"
+#include "sound/musicplugin.h"
-DECLARE_SINGLETON(MidiManager);
+DECLARE_SINGLETON(MusicManager);
-const MidiPlugin::List &MidiManager::getPlugins() const {
- return (const MidiPlugin::List &)PluginManager::instance().getPlugins(PLUGIN_TYPE_MIDI);
+const MusicPlugin::List &MusicManager::getPlugins() const {
+ return (const MusicPlugin::List &)PluginManager::instance().getPlugins(PLUGIN_TYPE_MUSIC);
}
diff --git a/base/plugins.h b/base/plugins.h
index aef95a6650..9d3ce97c3b 100644
--- a/base/plugins.h
+++ b/base/plugins.h
@@ -62,7 +62,7 @@
enum PluginType {
PLUGIN_TYPE_ENGINE = 0,
- PLUGIN_TYPE_MIDI,
+ PLUGIN_TYPE_MUSIC,
/* PLUGIN_TYPE_SCALER, */ // TODO: Add graphics scaler plugins
PLUGIN_TYPE_MAX
@@ -71,7 +71,7 @@ enum PluginType {
// TODO: Make the engine API version depend on ScummVM's version
// because of the backlinking (posibly from the SVN revision)
#define PLUGIN_TYPE_ENGINE_VERSION 1
-#define PLUGIN_TYPE_MIDI_VERSION 1
+#define PLUGIN_TYPE_MUSIC_VERSION 1
extern int pluginTypeVersions[PLUGIN_TYPE_MAX];
diff --git a/dists/msvc7/scummvm.vcproj b/dists/msvc7/scummvm.vcproj
index 89cb1ff697..befbdd8e31 100644
--- a/dists/msvc7/scummvm.vcproj
+++ b/dists/msvc7/scummvm.vcproj
@@ -396,7 +396,10 @@
RelativePath="..\..\sound\midiparser_xmidi.cpp">
</File>
<File
- RelativePath="..\..\sound\midiplugin.h">
+ RelativePath="..\..\sound\musicplugin.cpp">
+ </File>
+ <File
+ RelativePath="..\..\sound\musicplugin.h">
</File>
<File
RelativePath="..\..\sound\mixer.cpp">
diff --git a/dists/msvc71/scummvm.vcproj b/dists/msvc71/scummvm.vcproj
index 08102bd9b2..bc363a67fd 100644
--- a/dists/msvc71/scummvm.vcproj
+++ b/dists/msvc71/scummvm.vcproj
@@ -410,7 +410,10 @@
RelativePath="..\..\sound\midiparser_xmidi.cpp">
</File>
<File
- RelativePath="..\..\sound\midiplugin.h">
+ RelativePath="..\..\sound\musicplugin.cpp">
+ </File>
+ <File
+ RelativePath="..\..\sound\musicplugin.h">
</File>
<File
RelativePath="..\..\sound\mixer.cpp">
diff --git a/dists/msvc8/scummvm.vcproj b/dists/msvc8/scummvm.vcproj
index 3dcaf09f83..2d047bbd1b 100644
--- a/dists/msvc8/scummvm.vcproj
+++ b/dists/msvc8/scummvm.vcproj
@@ -565,7 +565,11 @@
>
</File>
<File
- RelativePath="..\..\sound\midiplugin.h"
+ RelativePath="..\..\sound\musicplugin.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\sound\musicplugin.h"
>
</File>
<File
diff --git a/dists/msvc9/scummvm.vcproj b/dists/msvc9/scummvm.vcproj
index daf6ae6c99..bd6b5af75c 100644
--- a/dists/msvc9/scummvm.vcproj
+++ b/dists/msvc9/scummvm.vcproj
@@ -570,7 +570,11 @@
>
</File>
<File
- RelativePath="..\..\sound\midiplugin.h"
+ RelativePath="..\..\sound\musicplugin.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\sound\musicplugin.h"
>
</File>
<File
diff --git a/engines/cine/part.cpp b/engines/cine/part.cpp
index 535bf841d5..b39f1eff7d 100644
--- a/engines/cine/part.cpp
+++ b/engines/cine/part.cpp
@@ -128,7 +128,7 @@ void CineEngine::readVolCnf() {
f.read(buf, packedSize);
if (packedSize != unpackedSize) {
CineUnpacker cineUnpacker;
- if (!cineUnpacker.unpack(buf, buf, packedSize)) {
+ if (!cineUnpacker.unpack(buf, packedSize, buf, unpackedSize)) {
error("Error while unpacking 'vol.cnf' data");
}
}
@@ -226,7 +226,9 @@ byte *readBundleFile(int16 foundFileIdx) {
byte *unpackBuffer = (byte *)malloc(partBuffer[foundFileIdx].packedSize);
readFromPart(foundFileIdx, unpackBuffer);
CineUnpacker cineUnpacker;
- cineUnpacker.unpack(dataPtr, unpackBuffer, partBuffer[foundFileIdx].packedSize);
+ if (!cineUnpacker.unpack(unpackBuffer, partBuffer[foundFileIdx].packedSize, dataPtr, partBuffer[foundFileIdx].unpackedSize)) {
+ warning("Error unpacking '%s' from bundle file '%s'", partBuffer[foundFileIdx].partName, currentPartName);
+ }
free(unpackBuffer);
} else {
readFromPart(foundFileIdx, dataPtr);
diff --git a/engines/cine/unpack.cpp b/engines/cine/unpack.cpp
index 364331e439..dcd3181242 100644
--- a/engines/cine/unpack.cpp
+++ b/engines/cine/unpack.cpp
@@ -31,13 +31,17 @@
namespace Cine {
uint32 CineUnpacker::readSource() {
+ if (_src < _srcBegin || _src + 4 > _srcEnd) {
+ _error = true;
+ return 0; // The source pointer is out of bounds, returning a default value
+ }
uint32 value = READ_BE_UINT32(_src);
_src -= 4;
return value;
}
-int CineUnpacker::rcr(int inputCarry) {
- int outputCarry = (_chunk32b & 1);
+uint CineUnpacker::rcr(bool inputCarry) {
+ uint outputCarry = (_chunk32b & 1);
_chunk32b >>= 1;
if (inputCarry) {
_chunk32b |= 0x80000000;
@@ -45,20 +49,20 @@ int CineUnpacker::rcr(int inputCarry) {
return outputCarry;
}
-int CineUnpacker::nextBit() {
- int carry = rcr(0);
+uint CineUnpacker::nextBit() {
+ uint carry = rcr(false);
// Normally if the chunk becomes zero then the carry is one as
// the end of chunk marker is always the last to be shifted out.
if (_chunk32b == 0) {
_chunk32b = readSource();
_crc ^= _chunk32b;
- carry = rcr(1); // Put the end of chunk marker in the most significant bit
+ carry = rcr(true); // Put the end of chunk marker in the most significant bit
}
return carry;
}
-uint16 CineUnpacker::getBits(byte numBits) {
- uint16 c = 0;
+uint CineUnpacker::getBits(uint numBits) {
+ uint c = 0;
while (numBits--) {
c <<= 1;
c |= nextBit();
@@ -66,30 +70,45 @@ uint16 CineUnpacker::getBits(byte numBits) {
return c;
}
-void CineUnpacker::unpackRawBytes(uint16 numBytes) {
- _datasize -= numBytes;
+void CineUnpacker::unpackRawBytes(uint numBytes) {
+ if (_dst >= _dstEnd || _dst - numBytes + 1 < _dstBegin) {
+ _error = true;
+ return; // Destination pointer is out of bounds for this operation
+ }
while (numBytes--) {
*_dst = (byte)getBits(8);
--_dst;
}
}
-void CineUnpacker::copyRelocatedBytes(uint16 offset, uint16 numBytes) {
- _datasize -= numBytes;
+void CineUnpacker::copyRelocatedBytes(uint offset, uint numBytes) {
+ if (_dst + offset >= _dstEnd || _dst - numBytes + 1 < _dstBegin) {
+ _error = true;
+ return; // Destination pointer is out of bounds for this operation
+ }
while (numBytes--) {
*_dst = *(_dst + offset);
--_dst;
}
}
-bool CineUnpacker::unpack(byte *dst, const byte *src, int srcLen) {
- _src = src + srcLen - 4;
- _datasize = readSource(); // Unpacked length in bytes
- _dst = dst + _datasize - 1;
+bool CineUnpacker::unpack(const byte *src, uint srcLen, byte *dst, uint dstLen) {
+ // Initialize variables used for detecting errors during unpacking
+ _error = false;
+ _srcBegin = src;
+ _srcEnd = src + srcLen;
+ _dstBegin = dst;
+ _dstEnd = dst + dstLen;
+
+ // Initialize other variables
+ _src = _srcBegin + srcLen - 4;
+ uint32 unpackedLength = readSource(); // Unpacked length in bytes
+ _dst = _dstBegin + unpackedLength - 1;
_crc = readSource();
_chunk32b = readSource();
_crc ^= _chunk32b;
- do {
+
+ while (_dst >= _dstBegin && !_error) {
/*
Bits => Action:
0 0 => unpackRawBytes(3 bits + 1) i.e. unpackRawBytes(1..9)
@@ -101,30 +120,30 @@ bool CineUnpacker::unpack(byte *dst, const byte *src, int srcLen) {
*/
if (!nextBit()) { // 0...
if (!nextBit()) { // 0 0
- uint16 numBytes = getBits(3) + 1;
+ uint numBytes = getBits(3) + 1;
unpackRawBytes(numBytes);
} else { // 0 1
- uint16 numBytes = 2;
- uint16 offset = getBits(8);
+ uint numBytes = 2;
+ uint offset = getBits(8);
copyRelocatedBytes(offset, numBytes);
}
} else { // 1...
- uint16 c = getBits(2);
+ uint c = getBits(2);
if (c == 3) { // 1 1 1
- uint16 numBytes = getBits(8) + 9;
+ uint numBytes = getBits(8) + 9;
unpackRawBytes(numBytes);
} else if (c < 2) { // 1 0 x
- uint16 numBytes = c + 3;
- uint16 offset = getBits(c + 9);
+ uint numBytes = c + 3;
+ uint offset = getBits(c + 9);
copyRelocatedBytes(offset, numBytes);
} else { // 1 1 0
- uint16 numBytes = getBits(8) + 1;
- uint16 offset = getBits(12);
+ uint numBytes = getBits(8) + 1;
+ uint offset = getBits(12);
copyRelocatedBytes(offset, numBytes);
}
}
- } while (_datasize > 0 && _src >= src - 4);
- return _crc == 0;
+ }
+ return !_error && (_crc == 0);
}
} // End of namespace Cine
diff --git a/engines/cine/unpack.h b/engines/cine/unpack.h
index f0a7ee3804..e16cb594a9 100644
--- a/engines/cine/unpack.h
+++ b/engines/cine/unpack.h
@@ -39,41 +39,77 @@ namespace Cine {
*/
class CineUnpacker {
public:
- /** Returns true if unpacking was successful, otherwise false. */
- bool unpack(byte *dst, const byte *src, int srcLen);
+ /**
+ * Unpacks packed data from the source buffer to the destination buffer.
+ * @warning Do NOT call this on data that is not packed.
+ * @note Source and destination buffer pointers can be the same as long as there's space for the unpacked data.
+ * @param src Pointer to the source buffer.
+ * @param srcLen Length of the source buffer.
+ * @param dst Pointer to the destination buffer.
+ * @param dstLen Length of the destination buffer.
+ * @return True if no errors were detected in the source data and unpacking was successful, otherwise false.
+ */
+ bool unpack(const byte *src, uint srcLen, byte *dst, uint dstLen);
private:
- /** Reads a single big endian 32-bit integer from the source and goes backwards 4 bytes. */
+ /**
+ * Reads an unsigned big endian 32-bit integer from the source stream and goes backwards 4 bytes.
+ * @return If the operation is valid, an unsigned big endian 32-bit integer read from the source stream.
+ * @return If the operation is invalid, zero.
+ * @note Sets internal error state if the read operation would be out of source bounds.
+ */
uint32 readSource();
/**
* Shifts the current internal 32-bit chunk to the right by one.
* Puts input carry into internal chunk's topmost (i.e. leftmost) bit.
- * Returns the least significant bit that was shifted out.
+ * @return The least significant bit that was shifted out from the chunk.
*/
- int rcr(int inputCarry);
- int nextBit();
- uint16 getBits(byte numBits);
+ uint rcr(bool inputCarry);
+
+ /**
+ * Get the next bit from the source stream.
+ * @note Changes the bit position in the source stream.
+ * @return The next bit from the source stream.
+ */
+ uint nextBit();
+
+ /**
+ * Get bits from the source stream.
+ * @note Changes the bit position in the source stream.
+ * @param numBits Number of bits to read from the source stream.
+ * @return Integer value consisting of the bits read from the source stream (In range [0, (2 ** numBits) - 1]).
+ * @return Later the bit was read from the source, the less significant it is in the return value.
+ */
+ uint getBits(uint numBits);
/**
* Copy raw bytes from the input stream and write them to the destination stream.
* This is used when no adequately long match is found in the sliding window.
+ * @note Sets internal error state if the operation would be out of bounds.
* @param numBytes Amount of bytes to copy from the input stream
*/
- void unpackRawBytes(uint16 numBytes);
+ void unpackRawBytes(uint numBytes);
/**
* Copy bytes from the sliding window in the destination buffer.
* This is used when a match of two bytes or longer is found.
+ * @note Sets internal error state if the operation would be out of bounds.
* @param offset Offset in the sliding window
* @param numBytes Amount of bytes to copy
*/
- void copyRelocatedBytes(uint16 offset, uint16 numBytes);
+ void copyRelocatedBytes(uint offset, uint numBytes);
private:
- int _datasize; //!< Bytes left to write into the unpacked data stream
- uint32 _crc; //!< Error-detecting code
- uint32 _chunk32b; //!< The current internal 32-bit chunk
- byte *_dst; //!< Destination buffer pointer
- const byte *_src; //!< Source buffer pointer
+ uint32 _crc; //!< Error-detecting code (This should be zero after successful unpacking)
+ uint32 _chunk32b; //!< The current internal 32-bit chunk of source data
+ byte *_dst; //!< Pointer to the current position in the destination buffer
+ const byte *_src; //!< Pointer to the current position in the source buffer
+
+ // These are used for detecting errors (e.g. out of bounds issues) during unpacking
+ bool _error; //!< Did an error occur during unpacking?
+ const byte *_srcBegin; //!< Source buffer's beginning
+ const byte *_srcEnd; //!< Source buffer's end
+ byte *_dstBegin; //!< Destination buffer's beginning
+ byte *_dstEnd; //!< Destination buffer's end
};
} // End of namespace Cine
diff --git a/engines/made/database.cpp b/engines/made/database.cpp
index 4616b63252..55e0e90732 100644
--- a/engines/made/database.cpp
+++ b/engines/made/database.cpp
@@ -301,7 +301,7 @@ int16 GameDatabase::getObjectProperty(int16 objectIndex, int16 propertyId) {
return 0;
int16 propertyFlag;
- int16 *property = getObjectPropertyPtr(objectIndex, propertyId, propertyFlag);
+ int16 *property = findObjectProperty(objectIndex, propertyId, propertyFlag);
if (property) {
return (int16)READ_LE_UINT16(property);
@@ -317,7 +317,7 @@ int16 GameDatabase::setObjectProperty(int16 objectIndex, int16 propertyId, int16
return 0;
int16 propertyFlag;
- int16 *property = getObjectPropertyPtr(objectIndex, propertyId, propertyFlag);
+ int16 *property = findObjectProperty(objectIndex, propertyId, propertyFlag);
if (property) {
if (propertyFlag == 1) {
@@ -430,7 +430,7 @@ int16 GameDatabaseV2::loadgame(const char *filename, int16 version) {
return result;
}
-int16 *GameDatabaseV2::getObjectPropertyPtr(int16 objectIndex, int16 propertyId, int16 &propertyFlag) {
+int16 *GameDatabaseV2::findObjectProperty(int16 objectIndex, int16 propertyId, int16 &propertyFlag) {
Object *obj = getObject(objectIndex);
int16 *prop = (int16*)obj->getData();
@@ -489,6 +489,7 @@ int16 *GameDatabaseV2::getObjectPropertyPtr(int16 objectIndex, int16 propertyId,
}
+ debug(1, "findObjectProperty(%04X, %04X) Property not found", objectIndex, propertyId);
return NULL;
}
@@ -597,7 +598,7 @@ int16 GameDatabaseV3::loadgame(const char *filename, int16 version) {
return result;
}
-int16 *GameDatabaseV3::getObjectPropertyPtr(int16 objectIndex, int16 propertyId, int16 &propertyFlag) {
+int16 *GameDatabaseV3::findObjectProperty(int16 objectIndex, int16 propertyId, int16 &propertyFlag) {
Object *obj = getObject(objectIndex);
int16 *prop = (int16*)obj->getData();
diff --git a/engines/made/database.h b/engines/made/database.h
index 476439c1e2..466d1a8f69 100644
--- a/engines/made/database.h
+++ b/engines/made/database.h
@@ -133,7 +133,7 @@ public:
const char *getObjectString(int16 index);
void setObjectString(int16 index, const char *str);
- virtual int16 *getObjectPropertyPtr(int16 objectIndex, int16 propertyId, int16 &propertyFlag) = 0;
+ virtual int16 *findObjectProperty(int16 objectIndex, int16 propertyId, int16 &propertyFlag) = 0;
virtual const char *getString(uint16 offset) = 0;
virtual bool getSavegameDescription(const char *filename, Common::String &description) = 0;
virtual int16 savegame(const char *filename, const char *description, int16 version) = 0;
@@ -157,7 +157,7 @@ class GameDatabaseV2 : public GameDatabase {
public:
GameDatabaseV2(MadeEngine *vm);
~GameDatabaseV2();
- int16 *getObjectPropertyPtr(int16 objectIndex, int16 propertyId, int16 &propertyFlag);
+ int16 *findObjectProperty(int16 objectIndex, int16 propertyId, int16 &propertyFlag);
const char *getString(uint16 offset);
bool getSavegameDescription(const char *filename, Common::String &description);
int16 savegame(const char *filename, const char *description, int16 version);
@@ -170,7 +170,7 @@ protected:
class GameDatabaseV3 : public GameDatabase {
public:
GameDatabaseV3(MadeEngine *vm);
- int16 *getObjectPropertyPtr(int16 objectIndex, int16 propertyId, int16 &propertyFlag);
+ int16 *findObjectProperty(int16 objectIndex, int16 propertyId, int16 &propertyFlag);
const char *getString(uint16 offset);
bool getSavegameDescription(const char *filename, Common::String &description);
int16 savegame(const char *filename, const char *description, int16 version);
diff --git a/engines/made/detection.cpp b/engines/made/detection.cpp
index 7d30873866..dc7dbdee87 100644
--- a/engines/made/detection.cpp
+++ b/engines/made/detection.cpp
@@ -65,6 +65,7 @@ static const PlainGameDescriptor madeGames[] = {
{"manhole", "The Manhole"},
{"rtz", "Return to Zork"},
{"lgop2", "Leather Goddesses of Phobos 2"},
+ {"rodney", "Rodney's Fun Screen"},
{0, 0}
};
@@ -276,6 +277,22 @@ static const MadeGameDescription gameDescriptions[] = {
0,
},
+ {
+ // Rodney's Fun Screen
+ {
+ "rodney",
+ "",
+ AD_ENTRY1("rodneys.dat", "a79887dbaa47689facd7c6f09258ba5a"),
+ Common::EN_ANY,
+ Common::kPlatformPC,
+ Common::ADGF_NO_FLAGS
+ },
+ GID_RODNEY,
+ 0,
+ GF_FLOPPY,
+ 0,
+ },
+
{ AD_TABLE_END_MARKER, 0, 0, 0, 0 }
};
diff --git a/engines/made/made.cpp b/engines/made/made.cpp
index 09a9a85ec6..59ec487c37 100644
--- a/engines/made/made.cpp
+++ b/engines/made/made.cpp
@@ -35,6 +35,7 @@
#include "base/plugins.h"
#include "base/version.h"
+#include "sound/audiocd.h"
#include "sound/mixer.h"
#include "made/made.h"
@@ -87,7 +88,7 @@ MadeEngine::MadeEngine(OSystem *syst, const MadeGameDescription *gameDesc) : Eng
_res = new ProjectReader();
_screen = new Screen(this);
- if (getGameID() == GID_LGOP2 || getGameID() == GID_MANHOLE) {
+ if (getGameID() == GID_LGOP2 || getGameID() == GID_MANHOLE || getGameID() == GID_RODNEY) {
_dat = new GameDatabaseV2(this);
} else if (getGameID() == GID_RTZ) {
_dat = new GameDatabaseV3(this);
@@ -119,7 +120,7 @@ MadeEngine::MadeEngine(OSystem *syst, const MadeGameDescription *gameDesc) : Eng
// Set default sound frequency
// Return to Zork sets it itself via a script funtion
- if (getGameID() == GID_MANHOLE) {
+ if (getGameID() == GID_MANHOLE || getGameID() == GID_RODNEY) {
_soundRate = 11025;
} else {
_soundRate = 8000;
@@ -238,6 +239,8 @@ void MadeEngine::handleEvents() {
}
}
+
+ AudioCD.updateCD();
}
@@ -245,7 +248,7 @@ int MadeEngine::go() {
for (int i = 0; i < ARRAYSIZE(_timers); i++)
_timers[i] = -1;
-
+
if (getGameID() == GID_RTZ) {
_engineVersion = 3;
if (getFeatures() & GF_DEMO) {
@@ -271,6 +274,10 @@ int MadeEngine::go() {
_engineVersion = 2;
_dat->open("lgop2.dat");
_res->open("lgop2.prj");
+ } else if (getGameID() == GID_RODNEY) {
+ _engineVersion = 2;
+ _dat->open("rodneys.dat");
+ _res->open("rodneys.prj");
} else {
error ("Unknown MADE game");
}
diff --git a/engines/made/made.h b/engines/made/made.h
index f7e3354c4d..461941e5cf 100644
--- a/engines/made/made.h
+++ b/engines/made/made.h
@@ -48,16 +48,17 @@
namespace Made {
enum MadeGameID {
- GID_RTZ = 0,
- GID_MANHOLE = 1,
- GID_LGOP2 = 2
+ GID_RTZ = 0,
+ GID_MANHOLE = 1,
+ GID_LGOP2 = 2,
+ GID_RODNEY = 3
};
enum MadeGameFeatures {
- GF_DEMO = 1 << 0,
- GF_CD = 1 << 1,
- GF_CD_COMPRESSED = 1 << 2,
- GF_FLOPPY = 1 << 3
+ GF_DEMO = 1 << 0,
+ GF_CD = 1 << 1,
+ GF_CD_COMPRESSED = 1 << 2,
+ GF_FLOPPY = 1 << 3
};
const uint32 kTimerResolution = 40;
diff --git a/engines/made/screen.h b/engines/made/screen.h
index 92f3512954..5d55085e5c 100644
--- a/engines/made/screen.h
+++ b/engines/made/screen.h
@@ -95,6 +95,7 @@ public:
void setRGBPalette(byte *palRGB, int start = 0, int count = 256);
bool isPaletteLocked() { return _paletteLock; }
void setPaletteLock(bool lock) { _paletteLock = lock; }
+ bool isScreenLocked() { return _screenLock; }
void setScreenLock(bool lock) { _screenLock = lock; }
void setVisualEffectNum(int visualEffectNum) { _visualEffectNum = visualEffectNum; }
diff --git a/engines/made/script.cpp b/engines/made/script.cpp
index 4bda35dcc3..6f4ff7ace3 100644
--- a/engines/made/script.cpp
+++ b/engines/made/script.cpp
@@ -363,8 +363,7 @@ void ScriptInterpreter::cmd_set() {
void ScriptInterpreter::cmd_print() {
// TODO: This opcode was used for printing debug messages
- Object *obj = _vm->_dat->getObject(_stack.top());
- const char *text = obj->getString();
+ const char *text = _vm->_dat->getObjectString(_stack.top());
debug(4, "%s", text);
_stack.setTop(0);
}
@@ -672,7 +671,7 @@ void ScriptInterpreter::dumpScript(int16 objectIndex, int *opcodeStats, int *ext
debug(1, "Dumping code for object %04X", objectIndex);
Object *obj = _vm->_dat->getObject(objectIndex);
- byte *code = obj->getData(), *codeEnd = code + obj->getSize();
+ byte *code = obj->getData(), *codeStart = code, *codeEnd = code + obj->getSize();
while (code < codeEnd) {
byte opcode = *code++;
@@ -684,6 +683,8 @@ void ScriptInterpreter::dumpScript(int16 objectIndex, int *opcodeStats, int *ext
int16 value;
char tempStr[32];
opcodeStats[opcode - 1]++;
+ snprintf(tempStr, 32, "[%04X] ", (uint16)(code - codeStart - 1));
+ codeLine += tempStr;
codeLine += desc;
for (; *sig != '\0'; sig++) {
codeLine += " ";
diff --git a/engines/made/scriptfuncs.cpp b/engines/made/scriptfuncs.cpp
index 8e06c2e8bf..932447a1eb 100644
--- a/engines/made/scriptfuncs.cpp
+++ b/engines/made/scriptfuncs.cpp
@@ -26,8 +26,8 @@
#include "common/endian.h"
#include "common/util.h"
#include "common/events.h"
-
#include "graphics/cursorman.h"
+#include "sound/audiocd.h"
#include "made/made.h"
#include "made/resource.h"
@@ -94,7 +94,7 @@ void ScriptFunctions::setupExternalsTable() {
External(sfSetSpriteGround);
External(sfLoadResText);
- if (_vm->getGameID() == GID_MANHOLE || _vm->getGameID() == GID_LGOP2) {
+ if (_vm->getGameID() == GID_MANHOLE || _vm->getGameID() == GID_LGOP2 || _vm->getGameID() == GID_RODNEY) {
External(sfAddScreenMask);
External(sfSetSpriteMask);
} else if (_vm->getGameID() == GID_RTZ) {
@@ -183,6 +183,8 @@ int16 ScriptFunctions::sfDrawPicture(int16 argc, int16 *argv) {
}
int16 ScriptFunctions::sfClearScreen(int16 argc, int16 *argv) {
+ if (_vm->_screen->isScreenLocked())
+ return 0;
if (_vm->_autoStopSound) {
_vm->_mixer->stopHandle(_audioStreamHandle);
_vm->_autoStopSound = false;
@@ -548,25 +550,27 @@ int16 ScriptFunctions::sfPlayVoice(int16 argc, int16 *argv) {
}
int16 ScriptFunctions::sfPlayCd(int16 argc, int16 *argv) {
- // This one is called loads of times, so it has been commented out to reduce spam
- //warning("Unimplemented opcode: sfPlayCd");
+ AudioCD.play(argv[0], -1, 0, 0);
return 0;
}
int16 ScriptFunctions::sfStopCd(int16 argc, int16 *argv) {
- warning("Unimplemented opcode: sfStopCd");
- return 0;
+ if (AudioCD.isPlaying()) {
+ AudioCD.stop();
+ return 1;
+ } else {
+ return 0;
+ }
}
int16 ScriptFunctions::sfGetCdStatus(int16 argc, int16 *argv) {
- // This one is called loads of times, so it has been commented out to reduce spam
- //warning("Unimplemented opcode: sfGetCdStatus");
- return 0;
+ return AudioCD.isPlaying() ? 1 : 0;
}
int16 ScriptFunctions::sfGetCdTime(int16 argc, int16 *argv) {
// This one is called loads of times, so it has been commented out to reduce spam
//warning("Unimplemented opcode: sfGetCdTime");
+ // TODO
return 0;
}
diff --git a/sound/midiplugin.h b/sound/midiplugin.h
deleted file mode 100644
index 0247e160e1..0000000000
--- a/sound/midiplugin.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- */
-
-#ifndef BACKENDS_MIDI_MIDIPLUGIN_H
-#define BACKENDS_MIDI_MIDIPLUGIN_H
-
-#include "base/plugins.h"
-#include "sound/mididrv.h"
-
-/**
- * A MidiPluginObject is essentially a factory for MidiDriver instances with
- * the added ability of listing the available devices and their capabilities.
- */
-class MidiPluginObject : public PluginObject {
-public:
- virtual ~MidiPluginObject() {}
-
- /**
- * Returns a unique string identifier which will be used to save the
- * selected MIDI driver to the config file.
- */
- virtual const char *getId() const = 0;
-
- /**
- * Returns the type kind of music supported by this driver, as specified
- * by the MidiDriverFlags enum.
- */
- virtual int getCapabilities() const = 0;
-
- /**
- * Returns a list of the available devices. The empty string means the
- * default device.
- */
- virtual Common::StringList getDevices() const {
- Common::StringList dev;
- dev.push_back("");
- return dev;
- }
-
- /**
- * Tries to instantiate a MIDI Driver instance based on the settings of
- * the currently active ConfMan target. That is, the MidiPluginObject
- * should query the ConfMan singleton for the device name, port, etc.
- *
- * @param mixer Pointer to the global Mixer object
- * @param mididriver Pointer to a pointer which the MidiPluginObject sets
- * to the newly create MidiDriver, or 0 in case of an error
- * @return a PluginError describing the error which occurred, or kNoError
- */
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const = 0;
-};
-
-
-// MIDI plugins
-
-typedef PluginSubclass<MidiPluginObject> MidiPlugin;
-
-/**
- * Singleton class which manages all MIDI plugins.
- */
-class MidiManager : public Common::Singleton<MidiManager> {
-private:
- friend class Common::Singleton<SingletonBaseType>;
-
-public:
- const MidiPlugin::List &getPlugins() const;
-};
-
-/** Convenience shortcut for accessing the MIDI manager. */
-#define MidiMan MidiManager::instance()
-
-#endif
diff --git a/sound/module.mk b/sound/module.mk
index 2f3dc1f987..d99013e7d0 100644
--- a/sound/module.mk
+++ b/sound/module.mk
@@ -15,6 +15,7 @@ MODULE_OBJS := \
mixer.o \
mp3.o \
mpu401.o \
+ musicplugin.o \
null.o \
voc.o \
vorbis.o \
diff --git a/sound/musicplugin.cpp b/sound/musicplugin.cpp
new file mode 100644
index 0000000000..b4754230da
--- /dev/null
+++ b/sound/musicplugin.cpp
@@ -0,0 +1,48 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "sound/musicplugin.h"
+
+MusicDevice::MusicDevice(MusicPluginObject const *musicPlugin, Common::String name, MusicType mt) :
+ _musicDriverName(musicPlugin->getName()), _musicDriverId(musicPlugin->getId()),
+ _name(name), _type(mt) {
+}
+
+Common::String MusicDevice::getCompleteName() {
+ Common::String name;
+
+ if (_name.empty()) {
+ // Default device, just show the driver name
+ name = _musicDriverName;
+ } else {
+ // Show both device and driver names
+ name = _name;
+ name += " [";
+ name += _musicDriverName;
+ name += "]";
+ }
+
+ return name;
+}
diff --git a/sound/musicplugin.h b/sound/musicplugin.h
new file mode 100644
index 0000000000..bdbd07ad31
--- /dev/null
+++ b/sound/musicplugin.h
@@ -0,0 +1,127 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#ifndef SOUND_MUSICPLUGIN_H
+#define SOUND_MUSICPLUGIN_H
+
+#include "base/plugins.h"
+#include "sound/mididrv.h"
+
+/**
+ * Music types that music drivers can implement and engines can rely on.
+ */
+enum MusicType {
+ MT_PCSPK = 1, // PC Speaker
+ MT_PCJR = 2, // PCjr
+ MT_ADLIB = 3, // AdLib
+ MT_TOWNS = 4, // FM-TOWNS
+ MT_GM = 5, // General MIDI
+ MT_MT32 = 6, // MT-32
+ MT_GS = 7 // Roland GS
+};
+
+class MusicPluginObject;
+
+/**
+ * Description of a Music device. Used to list the devices a Music driver
+ * can manage and their capabilities.
+ * A device with an empty name means the default device.
+ */
+class MusicDevice {
+public:
+ MusicDevice(MusicPluginObject const *musicPlugin, Common::String name, MusicType mt);
+
+ Common::String &getName() { return _name; }
+ Common::String &getMusicDriverName() { return _musicDriverName; }
+ Common::String &getMusicDriverId() { return _musicDriverId; }
+ MusicType getMusicType() { return _type; }
+
+ /**
+ * Returns a user readable string that contains the name of the current
+ * device name (if it isn't the default one) and the name of the driver.
+ */
+ Common::String getCompleteName();
+
+private:
+ Common::String _name;
+ Common::String _musicDriverName;
+ Common::String _musicDriverId;
+ MusicType _type;
+};
+
+/** List of music devices. */
+typedef Common::List<MusicDevice> MusicDevices;
+
+/**
+ * A MusicPluginObject is essentially a factory for MidiDriver instances with
+ * the added ability of listing the available devices and their capabilities.
+ */
+class MusicPluginObject : public PluginObject {
+public:
+ virtual ~MusicPluginObject() {}
+
+ /**
+ * Returns a unique string identifier which will be used to save the
+ * selected MIDI driver to the config file.
+ */
+ virtual const char *getId() const = 0;
+
+ /**
+ * Returns a list of the available devices.
+ */
+ virtual MusicDevices getDevices() const = 0;
+
+ /**
+ * Tries to instantiate a MIDI Driver instance based on the settings of
+ * the currently active ConfMan target. That is, the MusicPluginObject
+ * should query the ConfMan singleton for the device name, port, etc.
+ *
+ * @param mixer Pointer to the global Mixer object
+ * @param mididriver Pointer to a pointer which the MusicPluginObject sets
+ * to the newly create MidiDriver, or 0 in case of an error
+ * @return a PluginError describing the error which occurred, or kNoError
+ */
+ virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const = 0;
+};
+
+
+// Music plugins
+
+typedef PluginSubclass<MusicPluginObject> MusicPlugin;
+
+/**
+ * Singleton class which manages all Music plugins.
+ */
+class MusicManager : public Common::Singleton<MusicManager> {
+private:
+ friend class Common::Singleton<SingletonBaseType>;
+
+public:
+ const MusicPlugin::List &getPlugins() const;
+};
+
+/** Convenience shortcut for accessing the Music manager. */
+#define MusicMan MusicManager::instance()
+
+#endif
diff --git a/sound/null.cpp b/sound/null.cpp
index 9bb3a76344..7559a6d816 100644
--- a/sound/null.cpp
+++ b/sound/null.cpp
@@ -22,7 +22,7 @@
* $Id$
*/
-#include "sound/midiplugin.h"
+#include "sound/musicplugin.h"
#include "sound/mpu401.h"
/* NULL driver */
@@ -35,33 +35,37 @@ public:
// Plugin interface
-class NullMidiPlugin : public MidiPluginObject {
+class NullMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "No music";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "null";
}
- virtual int getCapabilities() const {
- return MDT_MIDI | MDT_PCSPK | MDT_ADLIB | MDT_TOWNS;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError NullMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+PluginError NullMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_NULL();
return kNoError;
}
+MusicDevices NullMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ // TODO: return a different music type?
+ devices.push_back(MusicDevice(this, "", MT_GM));
+ return devices;
+}
+
MidiDriver *MidiDriver_NULL_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- NullMidiPlugin p;
+ NullMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
@@ -74,7 +78,7 @@ MidiDriver *MidiDriver_ADLIB_create(Audio::Mixer *mixer) {
#endif
//#if PLUGIN_ENABLED_DYNAMIC(NULL)
- //REGISTER_PLUGIN_DYNAMIC(NULL, PLUGIN_TYPE_MIDI, NullMidiPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(NULL, PLUGIN_TYPE_MUSIC, NullMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(NULL, PLUGIN_TYPE_MIDI, NullMidiPlugin);
+ REGISTER_PLUGIN_STATIC(NULL, PLUGIN_TYPE_MUSIC, NullMusicPlugin);
//#endif
diff --git a/sound/softsynth/adlib.cpp b/sound/softsynth/adlib.cpp
index 3936843f52..3898956e15 100644
--- a/sound/softsynth/adlib.cpp
+++ b/sound/softsynth/adlib.cpp
@@ -25,7 +25,7 @@
#include "sound/softsynth/emumidi.h"
#include "common/util.h"
#include "sound/fmopl.h"
-#include "sound/midiplugin.h"
+#include "sound/musicplugin.h"
#ifdef DEBUG_ADLIB
static int tick;
@@ -1518,24 +1518,27 @@ void MidiDriver_ADLIB::adlib_note_on(int chan, byte note, int mod) {
// Plugin interface
-class AdlibMidiPlugin : public MidiPluginObject {
+class AdlibEmuMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "AdLib Emulator";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "adlib";
}
- virtual int getCapabilities() const {
- return MDT_ADLIB;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError AdlibMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+MusicDevices AdlibEmuMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ devices.push_back(MusicDevice(this, "", MT_ADLIB));
+ return devices;
+}
+
+PluginError AdlibEmuMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_ADLIB(mixer);
return kNoError;
@@ -1544,14 +1547,14 @@ PluginError AdlibMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mi
MidiDriver *MidiDriver_ADLIB_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- AdlibMidiPlugin p;
+ AdlibEmuMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(ADLIB)
- //REGISTER_PLUGIN_DYNAMIC(ADLIB, PLUGIN_TYPE_MIDI, AdlibMidiPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(ADLIB, PLUGIN_TYPE_MUSIC, AdlibEmuMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(ADLIB, PLUGIN_TYPE_MIDI, AdlibMidiPlugin);
+ REGISTER_PLUGIN_STATIC(ADLIB, PLUGIN_TYPE_MUSIC, AdlibEmuMusicPlugin);
//#endif
diff --git a/sound/softsynth/fluidsynth.cpp b/sound/softsynth/fluidsynth.cpp
index ae89a8df8a..eff9f4123c 100644
--- a/sound/softsynth/fluidsynth.cpp
+++ b/sound/softsynth/fluidsynth.cpp
@@ -27,7 +27,7 @@
#ifdef USE_FLUIDSYNTH
#include "common/config-manager.h"
-#include "sound/midiplugin.h"
+#include "sound/musicplugin.h"
#include "sound/mpu401.h"
#include "sound/softsynth/emumidi.h"
@@ -219,24 +219,27 @@ void MidiDriver_FluidSynth::generateSamples(int16 *data, int len) {
// Plugin interface
-class FluidSynthMidiPlugin : public MidiPluginObject {
+class FluidSynthMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "FluidSynth";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "fluidsynth";
}
- virtual int getCapabilities() const {
- return MDT_MIDI;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError FluidSynthMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+MusicDevices FluidSynthMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ devices.push_back(MusicDevice(this, "", MT_GM));
+ return devices;
+}
+
+PluginError FluidSynthMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_FluidSynth(mixer);
return kNoError;
@@ -245,16 +248,16 @@ PluginError FluidSynthMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver
MidiDriver *MidiDriver_FluidSynth_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- FluidSynthMidiPlugin p;
+ FluidSynthMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(FLUIDSYNTH)
- //REGISTER_PLUGIN_DYNAMIC(FLUIDSYNTH, PLUGIN_TYPE_MIDI, FluidSynthMidiPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(FLUIDSYNTH, PLUGIN_TYPE_MUSIC, FluidSynthMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(FLUIDSYNTH, PLUGIN_TYPE_MIDI, FluidSynthMidiPlugin);
+ REGISTER_PLUGIN_STATIC(FLUIDSYNTH, PLUGIN_TYPE_MUSIC, FluidSynthMusicPlugin);
//#endif
#endif
diff --git a/sound/softsynth/mt32.cpp b/sound/softsynth/mt32.cpp
index 2c9c4f24be..053df544b1 100644
--- a/sound/softsynth/mt32.cpp
+++ b/sound/softsynth/mt32.cpp
@@ -29,7 +29,7 @@
#include "sound/softsynth/mt32/mt32emu.h"
#include "sound/softsynth/emumidi.h"
-#include "sound/midiplugin.h"
+#include "sound/musicplugin.h"
#include "sound/mpu401.h"
#include "common/config-manager.h"
@@ -483,24 +483,27 @@ void MidiDriver_ThreadedMT32::onTimer() {
// Plugin interface
-class MT32MidiPlugin : public MidiPluginObject {
+class MT32EmuMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "MT-32 Emulator";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "mt32";
}
- virtual int getCapabilities() const {
- return MDT_MIDI;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError MT32MidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+MusicDevices MT32EmuMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ devices.push_back(MusicDevice(this, "", MT_MT32));
+ return devices;
+}
+
+PluginError MT32EmuMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_MT32(mixer);
return kNoError;
@@ -513,16 +516,16 @@ MidiDriver *MidiDriver_MT32_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- MT32MidiPlugin p;
+ MT32EmuMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(MT32)
- //REGISTER_PLUGIN_DYNAMIC(MT32, PLUGIN_TYPE_MIDI, MT32MidiPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(MT32, PLUGIN_TYPE_MUSIC, MT32EmuMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(MT32, PLUGIN_TYPE_MIDI, MT32MidiPlugin);
+ REGISTER_PLUGIN_STATIC(MT32, PLUGIN_TYPE_MUSIC, MT32EmuMusicPlugin);
//#endif
#endif
diff --git a/sound/softsynth/ym2612.cpp b/sound/softsynth/ym2612.cpp
index 3fcc2c3fc4..2a08bf631e 100644
--- a/sound/softsynth/ym2612.cpp
+++ b/sound/softsynth/ym2612.cpp
@@ -26,7 +26,7 @@
#include "sound/softsynth/ym2612.h"
#include "common/util.h"
-#include "sound/midiplugin.h"
+#include "sound/musicplugin.h"
////////////////////////////////////////
//
@@ -755,24 +755,27 @@ void MidiDriver_YM2612::removeLookupTables() {
// Plugin interface
-class TownsMidiPlugin : public MidiPluginObject {
+class TownsEmuMusicPlugin : public MusicPluginObject {
public:
- virtual const char *getName() const {
+ const char *getName() const {
return "FM Towns Emulator";
}
- virtual const char *getId() const {
+ const char *getId() const {
return "towns";
}
- virtual int getCapabilities() const {
- return MDT_TOWNS;
- }
-
- virtual PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
+ MusicDevices getDevices() const;
+ PluginError createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const;
};
-PluginError TownsMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
+MusicDevices TownsEmuMusicPlugin::getDevices() const {
+ MusicDevices devices;
+ devices.push_back(MusicDevice(this, "", MT_TOWNS));
+ return devices;
+}
+
+PluginError TownsEmuMusicPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mididriver) const {
*mididriver = new MidiDriver_YM2612(mixer);
return kNoError;
@@ -781,14 +784,14 @@ PluginError TownsMidiPlugin::createInstance(Audio::Mixer *mixer, MidiDriver **mi
MidiDriver *MidiDriver_YM2612_create(Audio::Mixer *mixer) {
MidiDriver *mididriver;
- TownsMidiPlugin p;
+ TownsEmuMusicPlugin p;
p.createInstance(mixer, &mididriver);
return mididriver;
}
//#if PLUGIN_ENABLED_DYNAMIC(TOWNS)
- //REGISTER_PLUGIN_DYNAMIC(TOWNS, PLUGIN_TYPE_MIDI, TownsMidiPlugin);
+ //REGISTER_PLUGIN_DYNAMIC(TOWNS, PLUGIN_TYPE_MUSIC, TownsEmuMusicPlugin);
//#else
- REGISTER_PLUGIN_STATIC(TOWNS, PLUGIN_TYPE_MIDI, TownsMidiPlugin);
+ REGISTER_PLUGIN_STATIC(TOWNS, PLUGIN_TYPE_MUSIC, TownsEmuMusicPlugin);
//#endif