diff options
author | Sven Hesse | 2012-07-01 03:45:09 +0200 |
---|---|---|
committer | Sven Hesse | 2012-07-30 01:44:44 +0200 |
commit | 34cf81a4b614dee5f2657bf24d9f867165e6ced9 (patch) | |
tree | 9267b9f4da5f47d9758cbd57926ceb4bb1cd2cde /engines/gob | |
parent | 233a3f54fc3913669fd4c56a6c3a16da5aa5f5b6 (diff) | |
download | scummvm-rg350-34cf81a4b614dee5f2657bf24d9f867165e6ced9.tar.gz scummvm-rg350-34cf81a4b614dee5f2657bf24d9f867165e6ced9.tar.bz2 scummvm-rg350-34cf81a4b614dee5f2657bf24d9f867165e6ced9.zip |
GOB: Add some PreGob sound utility functions
Diffstat (limited to 'engines/gob')
-rw-r--r-- | engines/gob/pregob/onceupon/onceupon.cpp | 10 | ||||
-rw-r--r-- | engines/gob/pregob/onceupon/onceupon.h | 8 | ||||
-rw-r--r-- | engines/gob/pregob/pregob.cpp | 35 | ||||
-rw-r--r-- | engines/gob/pregob/pregob.h | 11 |
4 files changed, 63 insertions, 1 deletions
diff --git a/engines/gob/pregob/onceupon/onceupon.cpp b/engines/gob/pregob/onceupon/onceupon.cpp index 67004d2912..ad6befaea2 100644 --- a/engines/gob/pregob/onceupon/onceupon.cpp +++ b/engines/gob/pregob/onceupon/onceupon.cpp @@ -246,6 +246,10 @@ const OnceUpon::MenuButton OnceUpon::kIngameButtons[3] = { {true, 180, 83, 211, 116, 72, 0, 103, 34, 180, 83, 2} }; +const char *OnceUpon::kSound[kSoundMAX] = { + "diamant.snd" +}; + OnceUpon::OnceUpon(GobEngine *vm) : PreGob(vm), _jeudak(0), _lettre(0), _plettre(0), _glettre(0), _openedArchives(false), _animalsButton(0) { @@ -286,6 +290,8 @@ void OnceUpon::init() { "please contact the ScummVM team with details about this version.\n" "Thanks", _vm->getLangDesc(_vm->_global->_language)); + loadSounds(kSound, kSoundMAX); + initScreen(); _difficulty = kDifficultyMAX; @@ -293,6 +299,8 @@ void OnceUpon::init() { } void OnceUpon::deinit() { + freeSounds(); + delete _jeudak; delete _lettre; delete _plettre; @@ -671,7 +679,7 @@ void OnceUpon::stopTitleMusic() { _vm->_sound->blasterStopComposition(); _vm->_sound->protrackerStop(); - for (int i = 0; i < Sound::kSoundsCount; i++) + for (int i = 0; i < ::Gob::Sound::kSoundsCount; i++) _vm->_sound->sampleFree(_vm->_sound->sampleGetBySlot(i)); } diff --git a/engines/gob/pregob/onceupon/onceupon.h b/engines/gob/pregob/onceupon/onceupon.h index 640e61383d..9ad563903e 100644 --- a/engines/gob/pregob/onceupon/onceupon.h +++ b/engines/gob/pregob/onceupon/onceupon.h @@ -64,6 +64,11 @@ protected: kDifficultyMAX }; + enum Sound { + kSoundClick = 0, + kSoundMAX + }; + struct MenuButton { bool needDraw; int16 left, top, right, bottom; @@ -110,6 +115,9 @@ private: static const MenuButton kSectionButtons[4]; static const MenuButton kIngameButtons[3]; + static const char *kSound[kSoundMAX]; + + void setCopyProtectionPalette(); void setAnimState(ANIObject &ani, uint16 state, bool once, bool pause) const; diff --git a/engines/gob/pregob/pregob.cpp b/engines/gob/pregob/pregob.cpp index 582ebc6677..9c6cfb717a 100644 --- a/engines/gob/pregob/pregob.cpp +++ b/engines/gob/pregob/pregob.cpp @@ -32,6 +32,8 @@ #include "gob/video.h" #include "gob/aniobject.h" +#include "gob/sound/sound.h" + #include "gob/pregob/pregob.h" static char kLanguageSuffix[5] = { 't', 'g', 'a', 'e', 'i' }; @@ -141,6 +143,39 @@ bool PreGob::isCursorVisible() const { return CursorMan.isVisible(); } +void PreGob::loadSounds(const char * const *sounds, uint soundCount) { + freeSounds(); + + _sounds.resize(soundCount); + + for (uint i = 0; i < soundCount; i++) { + int32 size; + byte *data = _vm->_dataIO->getFile(sounds[i], size); + + if (!data || !_sounds[i].load(SOUND_SND, data, size)) { + delete data; + + warning("PreGob::loadSounds(): Failed to load sound \"%s\"", sounds[i]); + continue; + } + } +} + +void PreGob::freeSounds() { + _sounds.clear(); +} + +void PreGob::playSound(uint sound, int16 frequency, int16 repCount) { + if (sound >= _sounds.size()) + return; + + _vm->_sound->blasterPlay(&_sounds[sound], repCount, frequency); +} + +void PreGob::stopSound() { + _vm->_sound->blasterStop(0); +} + void PreGob::endFrame(bool doInput) { _vm->_draw->blitInvalidated(); _vm->_util->waitEndFrame(); diff --git a/engines/gob/pregob/pregob.h b/engines/gob/pregob/pregob.h index 902a7c437d..b91758876e 100644 --- a/engines/gob/pregob/pregob.h +++ b/engines/gob/pregob/pregob.h @@ -24,9 +24,12 @@ #define GOB_PREGOB_PREGOB_H #include "common/str.h" +#include "common/array.h" #include "gob/util.h" +#include "gob/sound/sounddesc.h" + #include "gob/pregob/txtfile.h" namespace Gob { @@ -70,6 +73,12 @@ protected: bool isCursorVisible() const; + void loadSounds(const char * const *sounds, uint soundCount); + void freeSounds(); + + void playSound(uint sound, int16 frequency = 0, int16 repCount = 0); + void stopSound(); + void endFrame(bool doInput); int16 checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons); @@ -89,6 +98,8 @@ protected: private: bool _fadedOut; ///< Did we fade out? + + Common::Array<SoundDesc> _sounds; }; } // End of namespace Gob |