[Scummvm-cvs-logs] SF.net SVN: scummvm:[45329] scummvm/trunk/engines/sci
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Thu Oct 22 09:18:38 CEST 2009
Revision: 45329
http://scummvm.svn.sourceforge.net/scummvm/?rev=45329&view=rev
Author: thebluegr
Date: 2009-10-22 07:18:37 +0000 (Thu, 22 Oct 2009)
Log Message:
-----------
Applied a modified version of patch #2881486 - "Add volume changing to SCI"
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/ksound.cpp
scummvm/trunk/engines/sci/sfx/core.cpp
scummvm/trunk/engines/sci/sfx/core.h
scummvm/trunk/engines/sci/sfx/sci_midi.h
scummvm/trunk/engines/sci/sfx/softseq/adlib.cpp
scummvm/trunk/engines/sci/sfx/softseq/adlib.h
scummvm/trunk/engines/sci/sfx/softseq.h
Modified: scummvm/trunk/engines/sci/engine/ksound.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/ksound.cpp 2009-10-22 06:50:59 UTC (rev 45328)
+++ scummvm/trunk/engines/sci/engine/ksound.cpp 2009-10-22 07:18:37 UTC (rev 45329)
@@ -352,9 +352,9 @@
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 @@
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 @@
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,
Modified: scummvm/trunk/engines/sci/sfx/core.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/core.cpp 2009-10-22 06:50:59 UTC (rev 45328)
+++ scummvm/trunk/engines/sci/sfx/core.cpp 2009-10-22 07:18:37 UTC (rev 45329)
@@ -133,6 +133,10 @@
* @param argv the buffer itself
*/
void tell_synth(int buf_nr, byte *buf);
+
+ void setVolume(int vol);
+
+ int getVolume(void);
};
SfxPlayer::SfxPlayer() {
@@ -316,7 +320,14 @@
return Common::kNoError;
}
+void SfxPlayer::setVolume(int vol) {
+ _mididrv->setVolume(vol);
+}
+int SfxPlayer::getVolume(void) {
+ return _mididrv->getVolume();
+}
+
#pragma mark -
@@ -985,13 +996,12 @@
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() {
Modified: scummvm/trunk/engines/sci/sfx/core.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/core.h 2009-10-22 06:50:59 UTC (rev 45328)
+++ scummvm/trunk/engines/sci/sfx/core.h 2009-10-22 07:18:37 UTC (rev 45329)
@@ -97,12 +97,12 @@
/* 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
*/
Modified: scummvm/trunk/engines/sci/sfx/sci_midi.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/sci_midi.h 2009-10-22 06:50:59 UTC (rev 45328)
+++ scummvm/trunk/engines/sci/sfx/sci_midi.h 2009-10-22 07:18:37 UTC (rev 45329)
@@ -35,7 +35,8 @@
class ResourceManager;
enum {
- MIDI_CHANNELS = 16
+ MIDI_CHANNELS = 16,
+ MIDI_PROP_MASTER_VOLUME = 0
};
@@ -80,12 +81,14 @@
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
Modified: scummvm/trunk/engines/sci/sfx/softseq/adlib.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/softseq/adlib.cpp 2009-10-22 06:50:59 UTC (rev 45328)
+++ scummvm/trunk/engines/sci/sfx/softseq/adlib.cpp 2009-10-22 07:18:37 UTC (rev 45329)
@@ -629,6 +629,19 @@
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);
Modified: scummvm/trunk/engines/sci/sfx/softseq/adlib.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/softseq/adlib.h 2009-10-22 06:50:59 UTC (rev 45328)
+++ scummvm/trunk/engines/sci/sfx/softseq/adlib.h 2009-10-22 07:18:37 UTC (rev 45329)
@@ -36,7 +36,7 @@
};
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 @@
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 {
Modified: scummvm/trunk/engines/sci/sfx/softseq.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/softseq.h 2009-10-22 06:50:59 UTC (rev 45328)
+++ scummvm/trunk/engines/sci/sfx/softseq.h 2009-10-22 07:18:37 UTC (rev 45329)
@@ -65,7 +65,7 @@
** 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)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list