aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2003-09-07 16:16:19 +0000
committerMax Horn2003-09-07 16:16:19 +0000
commit0012f7fa9669939dbdc4b31b5db432d08d2ce276 (patch)
tree9d6fc2ad879c8ab33a13f2d2922f829dbd208621
parent6a438b86a9d393c9df740ad4281a6c9c3acb5d15 (diff)
downloadscummvm-rg350-0012f7fa9669939dbdc4b31b5db432d08d2ce276.tar.gz
scummvm-rg350-0012f7fa9669939dbdc4b31b5db432d08d2ce276.tar.bz2
scummvm-rg350-0012f7fa9669939dbdc4b31b5db432d08d2ce276.zip
added common base class MusicEngine for iMuse/iMuseDigital/Player_V123 (initial stab, more work to follow)
svn-id: r10066
-rw-r--r--scumm/debugger.cpp16
-rw-r--r--scumm/imuse.cpp14
-rw-r--r--scumm/imuse.h9
-rw-r--r--scumm/imuse_digi.h3
-rw-r--r--scumm/imuse_internal.h2
-rw-r--r--scumm/music.h39
-rw-r--r--scumm/player_v1.cpp5
-rw-r--r--scumm/player_v1.h2
-rw-r--r--scumm/player_v2.cpp5
-rw-r--r--scumm/player_v2.h6
-rw-r--r--scumm/player_v3a.cpp11
-rw-r--r--scumm/player_v3a.h5
-rw-r--r--scumm/scumm.h4
-rw-r--r--scumm/scummvm.cpp9
-rw-r--r--scumm/sound.cpp9
15 files changed, 98 insertions, 41 deletions
diff --git a/scumm/debugger.cpp b/scumm/debugger.cpp
index d631df8047..1f7f48d8ed 100644
--- a/scumm/debugger.cpp
+++ b/scumm/debugger.cpp
@@ -373,7 +373,7 @@ bool ScummDebugger::Cmd_IMuse (int argc, const char **argv) {
if (argc > 1) {
if (!strcmp (argv[1], "panic")) {
if (_s->_imuse)
- _s->_imuse->stop_all_sounds();
+ _s->_imuse->stopAllSounds();
if (_s->_playerV2)
_s->_playerV2->stopAllSounds();
Debug_Printf ("AAAIIIEEEEEE!\n");
@@ -395,13 +395,11 @@ bool ScummDebugger::Cmd_IMuse (int argc, const char **argv) {
Debug_Printf ("Selecting from %d songs...\n", _s->getNumSounds());
sound = _s->_rnd.getRandomNumber (_s->getNumSounds());
}
- _s->ensureResourceLoaded (rtSound, sound);
+ _s->ensureResourceLoaded(rtSound, sound);
if (_s->_imuse)
- _s->_imuse->startSound (sound);
+ _s->_imuse->startSound(sound);
if (_s->_playerV2) {
- byte *ptr = _s->getResourceAddress(rtSound, sound);
- if (ptr)
- _s->_playerV2->startSound (sound, ptr);
+ _s->_playerV2->startSound(sound);
}
Debug_Printf ("Attempted to start music %d.\n", sound);
@@ -413,15 +411,15 @@ bool ScummDebugger::Cmd_IMuse (int argc, const char **argv) {
if (argc > 2 && (!strcmp (argv[2], "all") || atoi (argv[2]) != 0)) {
if (!strcmp (argv[2], "all")) {
if (_s->_imuse)
- _s->_imuse->stop_all_sounds();
+ _s->_imuse->stopAllSounds();
if (_s->_playerV2)
_s->_playerV2->stopAllSounds();
Debug_Printf ("Shutting down all music tracks.\n");
} else {
if (_s->_imuse)
- _s->_imuse->stopSound (atoi (argv[2]));
+ _s->_imuse->stopSound(atoi (argv[2]));
if (_s->_playerV2)
- _s->_playerV2->stopSound (atoi (argv[2]));
+ _s->_playerV2->stopSound(atoi (argv[2]));
Debug_Printf ("Attempted to stop music %d.\n", atoi (argv[2]));
}
} else {
diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp
index a6e092737a..4ba22fa2b0 100644
--- a/scumm/imuse.cpp
+++ b/scumm/imuse.cpp
@@ -299,7 +299,7 @@ int IMuseInternal::stopSound(int sound) {
return r;
}
-int IMuseInternal::stop_all_sounds() {
+int IMuseInternal::stopAllSounds() {
Player *player = _players;
int i;
@@ -610,7 +610,7 @@ int IMuseInternal::get_master_volume() {
}
int IMuseInternal::terminate() {
- stop_all_sounds();
+ stopAllSounds();
if (_midi_adlib) {
_midi_adlib->close();
@@ -699,9 +699,9 @@ int32 IMuseInternal::doCommand (int numargs, int a[]) {
case 9:
return stopSound(a[1]);
case 10: // FIXME: Sam and Max - Not sure if this is correct
- return stop_all_sounds();
+ return stopAllSounds();
case 11:
- return stop_all_sounds();
+ return stopAllSounds();
case 12:
// Sam & Max: Player-scope commands
player = findActivePlayer(a[1]);
@@ -1756,9 +1756,9 @@ int IMuse::set_music_volume(uint vol) { in(); int ret = _target->set_music_volum
int IMuse::get_music_volume() { in(); int ret = _target->get_music_volume(); out(); return ret; }
int IMuse::set_master_volume(uint vol) { in(); int ret = _target->set_master_volume(vol); out(); return ret; }
int IMuse::get_master_volume() { in(); int ret = _target->get_master_volume(); out(); return ret; }
-bool IMuse::startSound(int sound) { in(); bool ret = _target->startSound(sound); out(); return ret; }
-int IMuse::stopSound(int sound) { in(); int ret = _target->stopSound(sound); out(); return ret; }
-int IMuse::stop_all_sounds() { in(); int ret = _target->stop_all_sounds(); out(); return ret; }
+void IMuse::startSound(int sound) { in(); _target->startSound(sound); out(); }
+void IMuse::stopSound(int sound) { in(); _target->stopSound(sound); out(); }
+int IMuse::stopAllSounds() { in(); int ret = _target->stopAllSounds(); out(); return ret; }
int IMuse::getSoundStatus(int sound) { in(); int ret = _target->getSoundStatus(sound, true); out(); return ret; }
bool IMuse::get_sound_active(int sound) { in(); bool ret = _target->getSoundStatus(sound, false) ? 1 : 0; out(); return ret; }
int IMuse::getMusicTimer() { in(); int ret = _target->getMusicTimer(); out(); return ret; }
diff --git a/scumm/imuse.h b/scumm/imuse.h
index 98cd328eb4..6cef659dda 100644
--- a/scumm/imuse.h
+++ b/scumm/imuse.h
@@ -25,6 +25,7 @@
#include "common/scummsys.h"
#include "common/system.h"
+#include "scumm/music.h"
class IMuseInternal;
class MidiDriver;
@@ -33,7 +34,7 @@ class Scumm;
class Serializer;
class SoundMixer;
-class IMuse {
+class IMuse : public MusicEngine {
private:
OSystem *_system;
IMuseInternal *_target;
@@ -62,9 +63,9 @@ public:
int get_music_volume();
int set_master_volume(uint vol);
int get_master_volume();
- bool startSound(int sound);
- int stopSound(int sound);
- int stop_all_sounds();
+ void startSound(int sound);
+ void stopSound(int sound);
+ int stopAllSounds();
int getSoundStatus(int sound);
bool get_sound_active(int sound);
int getMusicTimer();
diff --git a/scumm/imuse_digi.h b/scumm/imuse_digi.h
index a6d1f72b61..baa77c4f8a 100644
--- a/scumm/imuse_digi.h
+++ b/scumm/imuse_digi.h
@@ -24,6 +24,7 @@
#define IMUSE_DIGI_H
#include "common/scummsys.h"
+#include "scumm/music.h"
#include "sound/mixer.h"
#define MAX_DIGITAL_CHANNELS 8
@@ -32,7 +33,7 @@
class Scumm;
-class IMuseDigital {
+class IMuseDigital : public MusicEngine {
private:
struct Channel {
diff --git a/scumm/imuse_internal.h b/scumm/imuse_internal.h
index 81819465ed..b88ea0b7dd 100644
--- a/scumm/imuse_internal.h
+++ b/scumm/imuse_internal.h
@@ -461,7 +461,7 @@ public:
int get_master_volume();
bool startSound(int sound);
int stopSound(int sound);
- int stop_all_sounds();
+ int stopAllSounds();
int getSoundStatus(int sound, bool ignoreFadeouts = true);
int getMusicTimer();
int32 doCommand (int a, int b, int c, int d, int e, int f, int g, int h);
diff --git a/scumm/music.h b/scumm/music.h
new file mode 100644
index 0000000000..445e63f022
--- /dev/null
+++ b/scumm/music.h
@@ -0,0 +1,39 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2001 Ludvig Strigeus
+ * Copyright (C) 2001-2003 The ScummVM project
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * /scummvm/scummvm/scumm/player_v3a.h
+ *
+ */
+
+#ifndef SCUMM_MUSIC_H
+#define SCUMM_MUSIC_H
+
+#include "common/scummsys.h"
+#include "common/system.h"
+
+class MusicEngine {
+public:
+ virtual ~MusicEngine() {}
+
+ virtual void startSound(int sound) = 0;
+ virtual void stopSound(int sound) = 0;
+// virtual void stopAllSounds() = 0;
+// virtual int getSoundStatus(int sound) = 0;
+};
+
+#endif
diff --git a/scumm/player_v1.cpp b/scumm/player_v1.cpp
index 6e8faacbaf..a5032d099e 100644
--- a/scumm/player_v1.cpp
+++ b/scumm/player_v1.cpp
@@ -63,7 +63,10 @@ void Player_V1::chainSound(int nr, byte *data) {
parseSpeakerChunk();
}
-void Player_V1::startSound(int nr, byte *data) {
+void Player_V1::startSound(int nr) {
+ byte *data = _scumm->getResourceAddress(rtSound, nr);
+ assert(data);
+
mutex_up();
int offset = _pcjr ? READ_LE_UINT16(data+4) : 6;
diff --git a/scumm/player_v1.h b/scumm/player_v1.h
index ceefe1c15a..ad10f09d61 100644
--- a/scumm/player_v1.h
+++ b/scumm/player_v1.h
@@ -47,7 +47,7 @@ public:
Player_V1(Scumm *scumm);
~Player_V1();
- void startSound(int nr, byte *data);
+ void startSound(int nr);
void stopAllSounds();
void stopSound(int nr);
int getMusicTimer() const;
diff --git a/scumm/player_v2.cpp b/scumm/player_v2.cpp
index 2d92178674..5543d57fdf 100644
--- a/scumm/player_v2.cpp
+++ b/scumm/player_v2.cpp
@@ -335,6 +335,7 @@ Player_V2::Player_V2(Scumm *scumm) {
// by the 8253 (square wave generator) and a low-band filter.
_isV3Game = (scumm->_version >= 3);
+ _scumm = scumm;
_system = scumm->_system;
_mixer = scumm->_mixer;
_sample_rate = _system->property(OSystem::PROP_GET_SAMPLE_RATE, 0);
@@ -479,8 +480,10 @@ void Player_V2::stopSound(int nr) {
mutex_down();
}
-void Player_V2::startSound(int nr, byte *data) {
+void Player_V2::startSound(int nr) {
+ byte *data = _scumm->getResourceAddress(rtSound, nr);
assert(data);
+
mutex_up();
int cprio = _current_data ? *(_current_data + _header_len) : 0;
diff --git a/scumm/player_v2.h b/scumm/player_v2.h
index 62dcea7820..04ab1e84ed 100644
--- a/scumm/player_v2.h
+++ b/scumm/player_v2.h
@@ -25,6 +25,7 @@
#include "common/scummsys.h"
#include "common/system.h"
+#include "scumm/music.h"
#if !defined(__GNUC__)
#pragma START_PACK_STRUCTS
@@ -70,14 +71,14 @@ class Scumm;
class SoundMixer;
-class Player_V2 {
+class Player_V2 : public MusicEngine {
public:
Player_V2(Scumm *scumm);
virtual ~Player_V2();
virtual void set_master_volume(int vol);
- virtual void startSound(int nr, byte *data);
+ virtual void startSound(int nr);
virtual void stopSound(int nr);
virtual void stopAllSounds();
virtual bool getSoundStatus(int nr) const;
@@ -87,6 +88,7 @@ protected:
bool _isV3Game;
SoundMixer *_mixer;
OSystem *_system;
+ Scumm *_scumm;
bool _pcjr;
int _header_len;
diff --git a/scumm/player_v3a.cpp b/scumm/player_v3a.cpp
index 5f0625f64f..387f74eddc 100644
--- a/scumm/player_v3a.cpp
+++ b/scumm/player_v3a.cpp
@@ -79,12 +79,13 @@ void Player_V3A::stopAllSounds() {
_songData = NULL;
_songPtr = 0;
_songDelay = 0;
- for (int i = 0; i < V3A_MAXCHANS; i++)
+ for (int i = 0; i < V3A_MAXCHANS; i++) {
if (_soundID[i]) {
_mixer->stopID(_soundID[i]);
_soundID[i] = 0;
_timeleft[i] = 0;
}
+ }
}
void Player_V3A::stopSound(int nr) {
@@ -134,7 +135,10 @@ void Player_V3A::playSound (int nr, char *data, int size, int rate, int vol, int
else _mixer->playRaw(NULL, data, size, rate, SoundMixer::FLAG_AUTOFREE, nr, vol, 0);
}
-void Player_V3A::startSound(int nr, byte *data) {
+void Player_V3A::startSound(int nr) {
+ byte *data = _scumm->getResourceAddress(rtSound, nr);
+ assert(data);
+
if (!_isinit) {
int i;
if (_scumm->_gameId == GID_INDY3) {
@@ -191,7 +195,8 @@ void Player_V3A::startSound(int nr, byte *data) {
}
_wavetable[i] = NULL;
}
- else error("player_v3a - unknown game!");
+ else
+ error("player_v3a - unknown game!");
_isinit = true;
}
diff --git a/scumm/player_v3a.h b/scumm/player_v3a.h
index 29bb6faa8b..9ba7348395 100644
--- a/scumm/player_v3a.h
+++ b/scumm/player_v3a.h
@@ -25,20 +25,21 @@
#include "common/scummsys.h"
#include "common/system.h"
+#include "scumm/music.h"
#define V3A_MAXCHANS 8
class Scumm;
class SoundMixer;
-class Player_V3A {
+class Player_V3A : public MusicEngine {
public:
Player_V3A(Scumm *scumm);
virtual ~Player_V3A();
virtual void set_master_volume(int vol);
- virtual void startSound(int nr, byte *data);
+ virtual void startSound(int nr);
virtual void stopSound(int nr);
virtual void stopAllSounds();
virtual int getMusicTimer() const;
diff --git a/scumm/scumm.h b/scumm/scumm.h
index 04a8df3ae9..04152c2b55 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -29,7 +29,7 @@
#include "common/rect.h"
#include "common/str.h"
-#include "gfx.h"
+#include "scumm/gfx.h"
class Actor;
class BaseCostumeRenderer;
@@ -39,6 +39,7 @@ class Dialog;
class GameDetector;
class IMuse;
class IMuseDigital;
+class MusicEngine;
class NewGui;
class Player_V2;
class Player_V3A;
@@ -307,6 +308,7 @@ public:
IMuseDigital *_imuseDigital;
Player_V2 *_playerV2;
Player_V3A *_playerV3A;
+ MusicEngine *_musicEngine;
Sound *_sound;
VerbSlot *_verbs;
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index 56a99c024a..07dd34e23a 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -692,16 +692,17 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
_imuseDigital = NULL;
_playerV2 = NULL;
_playerV3A = NULL;
+ _musicEngine = NULL;
if (_features & GF_DIGI_IMUSE) {
- _imuseDigital = new IMuseDigital(this);
+ _musicEngine = _imuseDigital = new IMuseDigital(this);
} else if ((_features & GF_AMIGA) && (_version == 3)) {
- _playerV3A = new Player_V3A(this);
+ _musicEngine = _playerV3A = new Player_V3A(this);
} else if ((_features & GF_AMIGA) && (_version < 5)) {
_playerV2 = NULL;
} else if (((_midiDriver == MD_PCJR) || (_midiDriver == MD_PCSPK)) && ((_version > 2) && (_version < 5))) {
- _playerV2 = new Player_V2(this);
+ _musicEngine = _playerV2 = new Player_V2(this);
} else if (_version > 2) {
- _imuse = IMuse::create (syst, _mixer, detector->createMidi());
+ _musicEngine = _imuse = IMuse::create(syst, _mixer, detector->createMidi());
if (_imuse) {
if (detector->_gameTempo != 0)
_imuse->property(IMuse::PROP_TEMPO_BASE, detector->_gameTempo);
diff --git a/scumm/sound.cpp b/scumm/sound.cpp
index e0d3323ab1..fb393f0683 100644
--- a/scumm/sound.cpp
+++ b/scumm/sound.cpp
@@ -182,6 +182,7 @@ void Sound::playSound(int soundID) {
// FIXME: Should we replace this by an assert, and/or print an error message?
return;
}
+
if (READ_UINT32(ptr) == MKID('iMUS')){
assert(_scumm->_imuseDigital);
_scumm->_imuseDigital->startSound(soundID);
@@ -478,16 +479,16 @@ void Sound::playSound(int soundID) {
// automatically stop the old song.
if (_scumm->_imuse) {
if (READ_UINT32(ptr) != MKID('ASFX'))
- _scumm->_imuse->stop_all_sounds();
+ _scumm->_imuse->stopAllSounds();
}
}
if (_scumm->_playerV2) {
- _scumm->_playerV2->startSound(soundID, ptr);
+ _scumm->_playerV2->startSound(soundID);
}
if (_scumm->_playerV3A)
- _scumm->_playerV3A->startSound(soundID, ptr);
+ _scumm->_playerV3A->startSound(soundID);
if (_scumm->_imuse) {
_scumm->_imuse->startSound(soundID);
@@ -780,7 +781,7 @@ void Sound::stopAllSounds() {
}
if (_scumm->_imuse) {
- _scumm->_imuse->stop_all_sounds();
+ _scumm->_imuse->stopAllSounds();
_scumm->_imuse->clear_queue();
} else if (_scumm->_playerV2) {
_scumm->_playerV2->stopAllSounds();