diff options
author | Gregory Montoir | 2006-11-05 13:00:20 +0000 |
---|---|---|
committer | Gregory Montoir | 2006-11-05 13:00:20 +0000 |
commit | 424e9e362e55b32406af950cc5e551b9a378f45c (patch) | |
tree | b2c7cdcc12b7396f7830b8b22367fd6e01b5d672 /engines/touche | |
parent | 05dcf9c11db19f0b4da7892cfdc052b0df5f3ab6 (diff) | |
download | scummvm-rg350-424e9e362e55b32406af950cc5e551b9a378f45c.tar.gz scummvm-rg350-424e9e362e55b32406af950cc5e551b9a378f45c.tar.bz2 scummvm-rg350-424e9e362e55b32406af950cc5e551b9a378f45c.zip |
enabled MIDI volume changes
svn-id: r24627
Diffstat (limited to 'engines/touche')
-rw-r--r-- | engines/touche/midi.cpp | 13 | ||||
-rw-r--r-- | engines/touche/midi.h | 15 | ||||
-rw-r--r-- | engines/touche/resource.cpp | 1 | ||||
-rw-r--r-- | engines/touche/saveload.cpp | 4 | ||||
-rw-r--r-- | engines/touche/touche.cpp | 16 | ||||
-rw-r--r-- | engines/touche/touche.h | 10 | ||||
-rw-r--r-- | engines/touche/ui.cpp | 14 |
7 files changed, 25 insertions, 48 deletions
diff --git a/engines/touche/midi.cpp b/engines/touche/midi.cpp index cc07897c30..cbb431ac22 100644 --- a/engines/touche/midi.cpp +++ b/engines/touche/midi.cpp @@ -21,7 +21,6 @@ */ #include "common/stdafx.h" -#include "common/mutex.h" #include "common/stream.h" #include "sound/midiparser.h" @@ -31,7 +30,7 @@ namespace Touche { MidiPlayer::MidiPlayer(MidiDriver *driver) - : _masterVolume(255), _isPlaying(false), _driver(driver), _parser(0), _midiData(0) { + : _driver(driver), _parser(0), _midiData(0), _isLooping(false), _isPlaying(false), _masterVolume(0) { assert(_driver); memset(_channelsTable, 0, sizeof(_channelsTable)); memset(_channelsVolume, 0, sizeof(_channelsVolume)); @@ -75,12 +74,12 @@ void MidiPlayer::updateTimer() { _mutex.unlock(); } +void MidiPlayer::adjustVolume(int diff) { + setVolume(_masterVolume + diff); +} + void MidiPlayer::setVolume(int volume) { - if (volume < 0) { - volume = 0; - } else if (volume > 255) { - volume = 255; - } + _masterVolume = CLIP(volume, 0, 255); for (int i = 0; i < NUM_CHANNELS; ++i) { if (_channelsTable[i]) { _channelsTable[i]->volume(_channelsVolume[i] * _masterVolume / 255); diff --git a/engines/touche/midi.h b/engines/touche/midi.h index e012761d70..1add13d155 100644 --- a/engines/touche/midi.h +++ b/engines/touche/midi.h @@ -24,13 +24,14 @@ #define TOUCHE_MIDI_H #include "common/util.h" +#include "common/mutex.h" + #include "sound/mididrv.h" class MidiParser; namespace Common { class ReadStream; - class Mutex; } namespace Touche { @@ -48,7 +49,9 @@ public: void play(Common::ReadStream &stream, int size, bool loop = false); void stop(); void updateTimer(); + void adjustVolume(int diff); void setVolume(int volume); + int getVolume() const { return _masterVolume; } // MidiDriver interface int open(); @@ -64,14 +67,14 @@ private: static void timerCallback(void *p); - int _masterVolume; - bool _isLooping; - bool _isPlaying; MidiDriver *_driver; MidiParser *_parser; - MidiChannel *_channelsTable[NUM_CHANNELS]; - byte _channelsVolume[NUM_CHANNELS]; uint8 *_midiData; + bool _isLooping; + bool _isPlaying; + int _masterVolume; + MidiChannel *_channelsTable[NUM_CHANNELS]; + uint8 _channelsVolume[NUM_CHANNELS]; Common::Mutex _mutex; }; diff --git a/engines/touche/resource.cpp b/engines/touche/resource.cpp index 6a5dc02428..7262077745 100644 --- a/engines/touche/resource.cpp +++ b/engines/touche/resource.cpp @@ -561,7 +561,6 @@ void ToucheEngine::res_loadSound(int priority, int num) { void ToucheEngine::res_loadMusic(int num) { debugC(9, kDebugResource, "ToucheEngine::res_loadMusic() num=%d", num); - warning("UNIMPLEMENTED ToucheEngine::res_loadMusic() num=%d", num); uint32 size; const uint32 offs = res_getDataOffset(kResourceTypeMusic, num, &size); _fData.seek(offs); diff --git a/engines/touche/saveload.cpp b/engines/touche/saveload.cpp index e46ec24a30..0a227bf900 100644 --- a/engines/touche/saveload.cpp +++ b/engines/touche/saveload.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * $URL$ - * $Id: $ + * $Id$ * */ @@ -269,7 +269,7 @@ void ToucheEngine::loadGameStateData(Common::ReadStream *stream) { clearRoomArea(); int16 room_offs_x, room_offs_y; _currentEpisodeNum = stream->readUint16LE(); - _currentMusicNum = stream->readUint16LE(); + _newMusicNum = stream->readUint16LE(); _currentRoomNum = stream->readUint16LE(); res_loadRoom(_currentRoomNum); room_offs_x = stream->readUint16LE(); diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp index cacf7ded33..2352d22795 100644 --- a/engines/touche/touche.cpp +++ b/engines/touche/touche.cpp @@ -46,12 +46,7 @@ ToucheEngine::ToucheEngine(OSystem *system, Common::Language language) clearDirtyRects(); _defaultSoundPriority = 0; - _snd_midiContext.unk2 = 0; - _snd_midiContext.unkA = 1; - _snd_midiContext.unkB = 0; - _snd_midiContext.volume = 0; - _snd_midiContext.unkF = 0; - _snd_midiContext.currentVolume = 175; + _playSoundCounter = 0; _processRandomPaletteCounter = 0; @@ -1711,15 +1706,10 @@ void ToucheEngine::clearRoomArea() { } void ToucheEngine::startNewMusic() { - _snd_midiContext.unkA = _flagsTable[619] & 0xFF; +// bool unkMidiFlag = _flagsTable[619] != 0; if (_newMusicNum != 0 && _newMusicNum != _currentMusicNum) { - _snd_midiContext.unkB = 3; - if (_snd_midiContext.unkF != 0 && _snd_midiContext.unk2 != 0) { - return; - } - _snd_midiContext.unkB = 0; res_loadMusic(_newMusicNum); - _snd_midiContext.unk2 = 0; + _currentMusicNum = _newMusicNum; _newMusicNum = 0; } } diff --git a/engines/touche/touche.h b/engines/touche/touche.h index a93585e768..aaa62a8317 100644 --- a/engines/touche/touche.h +++ b/engines/touche/touche.h @@ -197,15 +197,6 @@ struct SpriteData { uint16 h; }; -struct MidiContext { - uint8 unk2; - uint8 unkA; - uint8 unkB; - uint16 volume; - uint8 unkF; - uint16 currentVolume; -}; - struct ProgramPointData { int16 x, y, z; int16 priority; @@ -617,7 +608,6 @@ protected: int _playSoundCounter; Audio::SoundHandle _sfxHandle; Audio::SoundHandle _speechHandle; - MidiContext _snd_midiContext; int16 _inventoryList1[101]; int16 _inventoryList2[101]; diff --git a/engines/touche/ui.cpp b/engines/touche/ui.cpp index d41663b864..912ba202fc 100644 --- a/engines/touche/ui.cpp +++ b/engines/touche/ui.cpp @@ -25,6 +25,7 @@ #include "common/savefile.h" #include "touche/graphics.h" +#include "touche/midi.h" #include "touche/touche.h" namespace Touche { @@ -63,7 +64,7 @@ void ToucheEngine::setupUIRect() { Common::Rect(154, 256, 392, 268), Common::Rect(126, 222, 420, 242) }; - + buttonsRectTable1 = inButtonsRectTable1; buttonsRectTable2 = inButtonsRectTable2; } @@ -130,7 +131,7 @@ void ToucheEngine::ui_drawButtonBorders(const Common::Rect *r, int count) { } void ToucheEngine::ui_drawMusicVolumeBar() { - int volume = _snd_midiContext.volume * 232 / 256; + int volume = _midiPlayer->getVolume() * 232 / 255; if (volume != 0) { Graphics::fillRect(_offscreenBuffer, 640, 157, 259, volume, 6, 0xF0); } @@ -394,14 +395,10 @@ void ToucheEngine::ui_handleOptions(int forceDisplay) { _talkTextMode = kTalkModeVoiceAndText; break; case 26: - if (_snd_midiContext.volume > 0) { - _snd_midiContext.volume -= 16; - } + _midiPlayer->adjustVolume(-16); break; case 27: - if (_snd_midiContext.volume < 256) { - _snd_midiContext.volume += 16; - } + _midiPlayer->adjustVolume(+16); break; } } @@ -410,7 +407,6 @@ void ToucheEngine::ui_handleOptions(int forceDisplay) { if (_flagsTable[611] != 0) { _flagsTable[611] = ui_displayQuitDialog(); } - _snd_midiContext.currentVolume = _snd_midiContext.volume; } } |