aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2009-10-22 07:18:37 +0000
committerFilippos Karapetis2009-10-22 07:18:37 +0000
commit93517e7649da286cd5b86efb3ee2e5cf7e7be436 (patch)
treee3f3e4ffa263dd8ec3768187f48707e7bcf1576b /engines
parentf79d3bb7cd181326e8ddba5d7f5a43a3871dac65 (diff)
downloadscummvm-rg350-93517e7649da286cd5b86efb3ee2e5cf7e7be436.tar.gz
scummvm-rg350-93517e7649da286cd5b86efb3ee2e5cf7e7be436.tar.bz2
scummvm-rg350-93517e7649da286cd5b86efb3ee2e5cf7e7be436.zip
Applied a modified version of patch #2881486 - "Add volume changing to SCI"
svn-id: r45329
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/ksound.cpp20
-rw-r--r--engines/sci/sfx/core.cpp20
-rw-r--r--engines/sci/sfx/core.h4
-rw-r--r--engines/sci/sfx/sci_midi.h13
-rw-r--r--engines/sci/sfx/softseq.h2
-rw-r--r--engines/sci/sfx/softseq/adlib.cpp13
-rw-r--r--engines/sci/sfx/softseq/adlib.h3
7 files changed, 51 insertions, 24 deletions
diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp
index 74a08fdea2..01f20d2f4e 100644
--- a/engines/sci/engine/ksound.cpp
+++ b/engines/sci/engine/ksound.cpp
@@ -352,9 +352,9 @@ static reg_t kDoSoundSci0(EngineState *s, int argc, reg_t *argv) {
int vol = (argc > 1) ? argv[1].toSint16() : -1;
if (vol != -1)
- s->_sound.sfx_set_volume(vol << 0xf);
+ s->_sound.sfx_setVolume(vol);
else
- s->r_acc = make_reg(0, s->_sound.sfx_get_volume() >> 0xf);
+ s->r_acc = make_reg(0, s->_sound.sfx_getVolume());
}
break;
@@ -474,9 +474,9 @@ static reg_t kDoSoundSci1Early(EngineState *s, int argc, reg_t *argv) {
int vol = (argc > 1) ? argv[1].toSint16() : -1;
if (vol != -1)
- s->_sound.sfx_set_volume(vol << 0xf);
+ s->_sound.sfx_setVolume(vol);
else
- s->r_acc = make_reg(0, s->_sound.sfx_get_volume() >> 0xf);
+ s->r_acc = make_reg(0, s->_sound.sfx_getVolume());
break;
}
case _K_SCI01_SOUND_MUTE_SOUND : {
@@ -781,13 +781,13 @@ static reg_t kDoSoundSci1Late(EngineState *s, int argc, reg_t *argv) {
switch (command) {
case _K_SCI1_SOUND_MASTER_VOLME : {
- /*int vol = UPARAM_OR_ALT (1, -1);
+ int vol = (argc > 1 ? argv[1].offset : -1);
- if (vol != -1)
- s->acc = s->sound_server->command(s, SOUND_COMMAND_SET_VOLUME, 0, vol);
- else
- s->acc = s->sound_server->command(s, SOUND_COMMAND_GET_VOLUME, 0, 0);
- break;*/
+ if (vol != -1)
+ s->_sound.sfx_setVolume(vol);
+
+ s->r_acc = make_reg(0, s->_sound.sfx_getVolume());
+ break;
}
case _K_SCI1_SOUND_MUTE_SOUND : {
/* if there's a parameter, we're setting it. Otherwise,
diff --git a/engines/sci/sfx/core.cpp b/engines/sci/sfx/core.cpp
index fe044e98ac..01177837b2 100644
--- a/engines/sci/sfx/core.cpp
+++ b/engines/sci/sfx/core.cpp
@@ -133,6 +133,10 @@ public:
* @param argv the buffer itself
*/
void tell_synth(int buf_nr, byte *buf);
+
+ void setVolume(int vol);
+
+ int getVolume(void);
};
SfxPlayer::SfxPlayer() {
@@ -316,6 +320,13 @@ Common::Error SfxPlayer::resume() {
return Common::kNoError;
}
+void SfxPlayer::setVolume(int vol) {
+ _mididrv->setVolume(vol);
+}
+
+int SfxPlayer::getVolume(void) {
+ return _mididrv->getVolume();
+}
#pragma mark -
@@ -985,13 +996,12 @@ Common::Error SfxState::sfx_send_midi(SongHandle handle, int channel,
return Common::kNoError;
}
-int SfxState::sfx_get_volume() {
- warning("FIXME: Implement volume");
- return 0;
+int SfxState::sfx_getVolume() {
+ return _player->getVolume();
}
-void SfxState::sfx_set_volume(int volume) {
- warning("FIXME: Implement volume");
+void SfxState::sfx_setVolume(int volume) {
+ _player->setVolume(volume);
}
void SfxState::sfx_all_stop() {
diff --git a/engines/sci/sfx/core.h b/engines/sci/sfx/core.h
index 0a80d1fe1a..1cb6540e8e 100644
--- a/engines/sci/sfx/core.h
+++ b/engines/sci/sfx/core.h
@@ -97,12 +97,12 @@ public:
/* Determines the current global volume settings
** Returns : (int) The global volume, between 0 (silent) and 127 (max. volume)
*/
- int sfx_get_volume();
+ int sfx_getVolume();
/* Determines the current global volume settings
** Parameters: (int) volume: The new global volume, between 0 and 127 (see above)
*/
- void sfx_set_volume(int volume);
+ void sfx_setVolume(int volume);
/* Stops all songs currently playing, purges song library
*/
diff --git a/engines/sci/sfx/sci_midi.h b/engines/sci/sfx/sci_midi.h
index 9facca27b8..623dbd9f33 100644
--- a/engines/sci/sfx/sci_midi.h
+++ b/engines/sci/sfx/sci_midi.h
@@ -35,7 +35,8 @@ namespace Sci {
class ResourceManager;
enum {
- MIDI_CHANNELS = 16
+ MIDI_CHANNELS = 16,
+ MIDI_PROP_MASTER_VOLUME = 0
};
@@ -80,12 +81,14 @@ public:
virtual int getPolyphony() const = 0;
virtual void setVolume(byte volume) {
- // Master Volume SysEx message
- const byte message[] = {0x7f, 0x7f, 0x04, 0x01, (volume * 127 / 15) & 0x7f, (volume * 127 / 15) & 0x7f};
-
- _driver->sysEx(message, 6);
+ if(_driver)
+ _driver->property(MIDI_PROP_MASTER_VOLUME, volume);
}
+ virtual int getVolume() {
+ return _driver ? _driver->property(MIDI_PROP_MASTER_VOLUME, -1) : 0;
+ }
+
virtual void playSwitch(bool play) {
if (!play) {
// Send "All Sound Off" on all channels
diff --git a/engines/sci/sfx/softseq.h b/engines/sci/sfx/softseq.h
index 31741785ae..d3f4168ea7 100644
--- a/engines/sci/sfx/softseq.h
+++ b/engines/sci/sfx/softseq.h
@@ -65,7 +65,7 @@ struct sfx_softseq_t {
** Parameters: (sfx_softseq_t *) self: Self reference
*/
- void (*set_volume)(sfx_softseq_t *self, int new_volume);
+ void (*setVolume)(sfx_softseq_t *self, int new_volume);
/* Sets the sequencer volume
** Parameters: (sfx_softseq_t *) self: Self reference
** (int) new_volume: A volume, between 0 (quiet) and 127 (max)
diff --git a/engines/sci/sfx/softseq/adlib.cpp b/engines/sci/sfx/softseq/adlib.cpp
index 15e1ed9089..1623520ea5 100644
--- a/engines/sci/sfx/softseq/adlib.cpp
+++ b/engines/sci/sfx/softseq/adlib.cpp
@@ -629,6 +629,19 @@ bool MidiDriver_Adlib::loadResource(const byte *data, uint size) {
return true;
}
+int32 MidiDriver_Adlib::property(int prop, int32 param) {
+ switch(prop) {
+ case MIDI_PROP_MASTER_VOLUME:
+ if(param != -1)
+ _masterVolume = param;
+ return _masterVolume;
+ default:
+ break;
+ }
+ return -1;
+}
+
+
int MidiPlayer_Adlib::open(ResourceManager *resMan) {
assert(resMan != NULL);
diff --git a/engines/sci/sfx/softseq/adlib.h b/engines/sci/sfx/softseq/adlib.h
index 771bdc3927..fccf0a2c94 100644
--- a/engines/sci/sfx/softseq/adlib.h
+++ b/engines/sci/sfx/softseq/adlib.h
@@ -36,7 +36,7 @@ public:
};
MidiDriver_Adlib(Audio::Mixer *mixer) : MidiDriver_Emulated(mixer), _playSwitch(true), _masterVolume(15), _rhythmKeyMap(0), _opl(0) { }
- ~MidiDriver_Adlib() { }
+ virtual ~MidiDriver_Adlib() { }
// MidiDriver
int open(bool isSCI0);
@@ -55,6 +55,7 @@ public:
void setVolume(byte volume);
void playSwitch(bool play);
bool loadResource(const byte *data, uint size);
+ virtual int32 property(int prop, int32 param);
private:
enum ChannelID {