aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/gob/pregob/onceupon/onceupon.cpp10
-rw-r--r--engines/gob/pregob/onceupon/onceupon.h8
-rw-r--r--engines/gob/pregob/pregob.cpp35
-rw-r--r--engines/gob/pregob/pregob.h11
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