aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/midi/adlib.cpp9
-rw-r--r--common/engine.cpp6
-rw-r--r--common/engine.h1
-rw-r--r--scumm/imuse.cpp33
-rw-r--r--scumm/imuse.h2
-rw-r--r--scumm/imuse_internal.h9
-rw-r--r--scumm/imuse_player.cpp11
-rw-r--r--scumm/scummvm.cpp12
-rw-r--r--simon/simon.cpp2
-rw-r--r--sound/mididrv.h3
10 files changed, 48 insertions, 40 deletions
diff --git a/backends/midi/adlib.cpp b/backends/midi/adlib.cpp
index 5da6601149..a95fa8da38 100644
--- a/backends/midi/adlib.cpp
+++ b/backends/midi/adlib.cpp
@@ -554,7 +554,7 @@ class MidiDriver_ADLIB : public MidiDriver {
friend class AdlibPercussionChannel;
public:
- MidiDriver_ADLIB();
+ MidiDriver_ADLIB(SoundMixer *mixer);
int open();
void close();
@@ -810,14 +810,14 @@ void AdlibPercussionChannel::noteOn(byte note, byte velocity) {
// MidiDriver method implementations
-MidiDriver_ADLIB::MidiDriver_ADLIB() {
+MidiDriver_ADLIB::MidiDriver_ADLIB(SoundMixer *mixer)
+ : _mixer(mixer) {
uint i;
_isOpen = false;
_game_SmallHeader = false;
_adlib_reg_cache = 0;
- _mixer = 0
_timer_proc = 0;
_timer_param = 0;
@@ -839,8 +839,7 @@ int MidiDriver_ADLIB::open() {
if (_isOpen)
return MERR_ALREADY_OPEN;
_isOpen = true;
- _mixer = g_mixer;
-
+
int i;
AdlibVoice *voice;
diff --git a/common/engine.cpp b/common/engine.cpp
index 25213b486f..90d73ed53a 100644
--- a/common/engine.cpp
+++ b/common/engine.cpp
@@ -73,7 +73,6 @@ const char *gScummVMFullVersion = "ScummVM 0.5.3cvs (" __DATE__ " " __TIME__ ")"
/* FIXME - BIG HACK for MidiEmu */
OSystem *g_system = 0;
-SoundMixer *g_mixer = 0;
Engine *g_engine = 0;
Engine::Engine(GameDetector *detector, OSystem *syst)
@@ -83,9 +82,8 @@ Engine::Engine(GameDetector *detector, OSystem *syst)
_gameDataPath = detector->_gameDataPath;
- /* FIXME - BIG HACK for MidiEmu */
- g_system = _system;
- g_mixer = _mixer;
+ g_system = _system; // FIXME - BIG HACK for MidiEmu
+
_timer = new Timer(this);
}
diff --git a/common/engine.h b/common/engine.h
index 6731effd62..bed622bcf2 100644
--- a/common/engine.h
+++ b/common/engine.h
@@ -53,7 +53,6 @@ struct VersionSettings;
/* FIXME - BIG HACK for MidiEmu */
extern OSystem *g_system;
-extern SoundMixer *g_mixer;
class Engine {
public:
diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp
index d61828f7a9..6827086afd 100644
--- a/scumm/imuse.cpp
+++ b/scumm/imuse.cpp
@@ -21,15 +21,18 @@
*/
#include "stdafx.h"
-#include "imuse.h"
-#include "imuse_internal.h"
-#include "instrument.h"
-#include "saveload.h"
-#include "scumm.h"
+
#include "common/util.h"
-#include "sound/mididrv.h"
#include "common/gameDetector.h" // For kDefaultMasterVolume etc.
+#include "scumm/imuse.h"
+#include "scumm/imuse_internal.h"
+#include "scumm/instrument.h"
+#include "scumm/saveload.h"
+#include "scumm/scumm.h"
+
+#include "sound/mididrv.h"
+
////////////////////////////////////////
@@ -78,7 +81,7 @@ MidiDriver *IMuseInternal::getMidiDriver() {
} else {
// Route it through Adlib anyway.
if (!_midi_adlib) {
- _midi_adlib = MidiDriver_ADLIB_create();
+ _midi_adlib = MidiDriver_ADLIB_create(_mixer);
initMidiDriver(_midi_adlib);
}
driver = _midi_adlib;
@@ -186,14 +189,14 @@ MidiDriver *IMuseInternal::getBestMidiDriver(int sound) {
} else {
// Route it through Adlib anyway.
if (!_midi_adlib) {
- _midi_adlib = MidiDriver_ADLIB_create();
+ _midi_adlib = MidiDriver_ADLIB_create(_mixer);
initMidiDriver(_midi_adlib);
}
driver = _midi_adlib;
}
} else {
if (!_midi_adlib &&(_enable_multi_midi || !_midi_native)) {
- _midi_adlib = MidiDriver_ADLIB_create();
+ _midi_adlib = MidiDriver_ADLIB_create(_mixer);
initMidiDriver(_midi_adlib);
}
driver = _midi_adlib;
@@ -1048,6 +1051,7 @@ uint32 IMuseInternal::property(int prop, uint32 value) {
_players[i].clear();
}
driver->close();
+ // FIXME: shouldn't we delete 'driver' here, too ?
}
break;
@@ -1072,15 +1076,16 @@ void IMuseInternal::setBase(byte **base) {
_base_sounds = base;
}
-IMuseInternal *IMuseInternal::create(OSystem *syst, MidiDriver *native_midi) {
+IMuseInternal *IMuseInternal::create(OSystem *syst, SoundMixer *mixer, MidiDriver *native_midi) {
IMuseInternal *i = new IMuseInternal;
- i->initialize(syst, native_midi);
+ i->initialize(syst, mixer, native_midi);
return i;
}
-int IMuseInternal::initialize(OSystem *syst, MidiDriver *native_midi) {
+int IMuseInternal::initialize(OSystem *syst, SoundMixer *mixer, MidiDriver *native_midi) {
int i;
+ _mixer = mixer;
_midi_native = native_midi;
_midi_adlib = NULL;
if (native_midi)
@@ -1736,7 +1741,7 @@ MidiDriver *IMuse::getMidiDriver() { in(); MidiDriver *ret = _target->getMidiDri
// The IMuse::create method provides a front-end factory
// for creating IMuseInternal without exposing that class
// to the client.
-IMuse *IMuse::create(OSystem *syst, MidiDriver *midi) {
- IMuseInternal *engine = IMuseInternal::create(syst, midi);
+IMuse *IMuse::create(OSystem *syst, SoundMixer *mixer, MidiDriver *midi) {
+ IMuseInternal *engine = IMuseInternal::create(syst, mixer, midi);
return new IMuse(syst, engine);
}
diff --git a/scumm/imuse.h b/scumm/imuse.h
index cf785b84d4..2b129e27f3 100644
--- a/scumm/imuse.h
+++ b/scumm/imuse.h
@@ -74,7 +74,7 @@ public:
MidiDriver *getMidiDriver();
// Factory methods
- static IMuse *create(OSystem *syst, MidiDriver *midi);
+ static IMuse *create(OSystem *syst, SoundMixer *mixer, MidiDriver *midi);
};
#endif
diff --git a/scumm/imuse_internal.h b/scumm/imuse_internal.h
index bed969c034..330dd2ea6a 100644
--- a/scumm/imuse_internal.h
+++ b/scumm/imuse_internal.h
@@ -22,9 +22,9 @@
#ifndef DEFINED_IMUSE_INTERNAL
#define DEFINED_IMUSE_INTERNAL
-#include "sound/mididrv.h"
#include "common/scummsys.h"
#include "scumm/instrument.h"
+#include "sound/mididrv.h"
// Unremark this statement to activate some of
// the most common iMuse diagnostic messages.
@@ -45,6 +45,7 @@ class IMuseInternal;
class MidiParser;
class Scumm;
class OSystem;
+class SoundMixer;
@@ -355,6 +356,8 @@ private:
MidiDriver *_midi_native;
byte **_base_sounds;
+
+ SoundMixer *_mixer;
private:
bool _paused;
@@ -439,7 +442,7 @@ public:
IMuseInternal();
~IMuseInternal();
- int initialize(OSystem *syst, MidiDriver *midi);
+ int initialize(OSystem *syst, SoundMixer *mixer, MidiDriver *midi);
void reallocateMidiChannels(MidiDriver *midi);
void setGlobalAdlibInstrument(byte slot, byte *data);
void copyGlobalAdlibInstrument(byte slot, Instrument *dest);
@@ -465,7 +468,7 @@ public:
uint32 property(int prop, uint32 value);
MidiDriver *getMidiDriver();
- static IMuseInternal *create(OSystem *syst, MidiDriver *midi);
+ static IMuseInternal *create(OSystem *syst, SoundMixer *mixer, MidiDriver *midi);
};
#endif
diff --git a/scumm/imuse_player.cpp b/scumm/imuse_player.cpp
index e5806f9d94..0e4ee34fdf 100644
--- a/scumm/imuse_player.cpp
+++ b/scumm/imuse_player.cpp
@@ -20,12 +20,15 @@
*/
#include "stdafx.h"
-#include "scumm/scumm.h"
-#include "sound/midiparser.h"
-#include "scumm/saveload.h"
+
#include "common/util.h"
#include "common/engine.h"
-#include "imuse_internal.h"
+
+#include "scumm/imuse_internal.h"
+#include "scumm/saveload.h"
+#include "scumm/scumm.h"
+
+#include "sound/midiparser.h"
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index 6775a5f3dc..b94b7785f7 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -625,16 +625,16 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
else
_playerV2 = new Player_V2(this);
} else {
- _imuse = IMuse::create (syst, detector->createMidi());
+ _imuse = IMuse::create (syst, _mixer, detector->createMidi());
if (_imuse) {
if (detector->_gameTempo != 0)
_imuse->property(IMuse::PROP_TEMPO_BASE, detector->_gameTempo);
- _imuse->property (IMuse::PROP_OLD_ADLIB_INSTRUMENTS, (_features & GF_SMALL_HEADER) ? 1 : 0);
- _imuse->property (IMuse::PROP_MULTI_MIDI, detector->_multi_midi);
- _imuse->property (IMuse::PROP_NATIVE_MT32, detector->_native_mt32);
+ _imuse->property(IMuse::PROP_OLD_ADLIB_INSTRUMENTS, (_features & GF_SMALL_HEADER) ? 1 : 0);
+ _imuse->property(IMuse::PROP_MULTI_MIDI, detector->_multi_midi);
+ _imuse->property(IMuse::PROP_NATIVE_MT32, detector->_native_mt32);
if (_features & GF_HUMONGOUS) {
- _imuse->property (IMuse::PROP_LIMIT_PLAYERS, 1);
- _imuse->property (IMuse::PROP_RECYCLE_PLAYERS, 1);
+ _imuse->property(IMuse::PROP_LIMIT_PLAYERS, 1);
+ _imuse->property(IMuse::PROP_RECYCLE_PLAYERS, 1);
}
_imuse->set_music_volume(_sound->_sound_volume_music);
}
diff --git a/simon/simon.cpp b/simon/simon.cpp
index c94f353b70..7aeebb7402 100644
--- a/simon/simon.cpp
+++ b/simon/simon.cpp
@@ -443,7 +443,7 @@ SimonEngine::SimonEngine(GameDetector *detector, OSystem *syst)
// Setup midi driver
if (!driver)
- driver = MidiDriver_ADLIB_create();
+ driver = MidiDriver_ADLIB_create(_mixer);
midi.mapMT32toGM (!(_game & GF_SIMON2) && !detector->_native_mt32);
midi.set_driver(driver);
diff --git a/sound/mididrv.h b/sound/mididrv.h
index b72959428f..1e9c95de03 100644
--- a/sound/mididrv.h
+++ b/sound/mididrv.h
@@ -26,6 +26,7 @@
#include "common/scummsys.h"
class MidiChannel;
+class SoundMixer;
// Abstract MIDI Driver Class
class MidiDriver {
@@ -132,7 +133,7 @@ enum {
// Factory functions, for faster compile
extern MidiDriver *MidiDriver_NULL_create();
-extern MidiDriver *MidiDriver_ADLIB_create();
+extern MidiDriver *MidiDriver_ADLIB_create(SoundMixer *mixer);
extern MidiDriver *MidiDriver_WIN_create();
extern MidiDriver *MidiDriver_SEQ_create();
extern MidiDriver *MidiDriver_QT_create();