aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/chewy/chewy.cpp26
-rw-r--r--engines/chewy/chewy.h7
-rw-r--r--engines/chewy/module.mk4
-rw-r--r--engines/chewy/sound.cpp87
-rw-r--r--engines/chewy/sound.h53
5 files changed, 165 insertions, 12 deletions
diff --git a/engines/chewy/chewy.cpp b/engines/chewy/chewy.cpp
index a040e16315..b5271d5969 100644
--- a/engines/chewy/chewy.cpp
+++ b/engines/chewy/chewy.cpp
@@ -30,8 +30,10 @@
#include "engines/util.h"
#include "chewy/chewy.h"
+#include "chewy/console.h"
#include "chewy/graphics.h"
#include "chewy/resource.h"
+#include "chewy/sound.h"
namespace Chewy {
@@ -40,8 +42,6 @@ ChewyEngine::ChewyEngine(OSystem *syst, const ChewyGameDescription *gameDesc)
_gameDescription(gameDesc),
_rnd("chewy") {
- _console = new Console(this);
-
const Common::FSNode gameDataDir(ConfMan.get("path"));
SearchMan.addSubDirectoryMatching(gameDataDir, "back");
@@ -54,17 +54,28 @@ ChewyEngine::ChewyEngine(OSystem *syst, const ChewyGameDescription *gameDesc)
}
ChewyEngine::~ChewyEngine() {
+ delete _console;
+ delete _sound;
+ delete _graphics;
+}
+
+void ChewyEngine::initialize() {
+ _console = new Console(this);
+ _graphics = new Graphics();
+ _sound = new Sound();
}
Common::Error ChewyEngine::run() {
// Initialize backend
- initGraphics(640, 480, true);
+ //initGraphics(640, 480, true);
+ initGraphics(320, 200, false);
initialize();
- Graphics *g = new Graphics();
- g->drawImage("comic.tgp", 0);
- delete g;
+ _graphics->drawImage("episode1.tgp", 0);
+ //_sound->playSpeech(1);
+ //_sound->playSound(1);
+ //_sound->playMusic(2);
// Run a dummy loop
Common::Event event;
@@ -84,7 +95,4 @@ Common::Error ChewyEngine::run() {
return Common::kNoError;
}
-void ChewyEngine::initialize() {
-}
-
} // End of namespace Chewy
diff --git a/engines/chewy/chewy.h b/engines/chewy/chewy.h
index b832144efa..2235d5f1cf 100644
--- a/engines/chewy/chewy.h
+++ b/engines/chewy/chewy.h
@@ -33,11 +33,13 @@
#include "common/random.h"
#include "engines/engine.h"
-#include "chewy/console.h"
namespace Chewy {
struct ChewyGameDescription;
+class Console;
+class Graphics;
+class Sound;
class ChewyEngine : public Engine {
@@ -63,6 +65,9 @@ public:
const ChewyGameDescription *_gameDescription;
Common::RandomSource _rnd;
+
+ Graphics *_graphics;
+ Sound *_sound;
};
} // End of namespace Chewy
diff --git a/engines/chewy/module.mk b/engines/chewy/module.mk
index df932c7056..5b96ab9ba3 100644
--- a/engines/chewy/module.mk
+++ b/engines/chewy/module.mk
@@ -5,8 +5,8 @@ MODULE_OBJS = \
console.o \
detection.o \
graphics.o \
- resource.o
-
+ resource.o \
+ sound.o
# This module can be built as a plugin
ifeq ($(ENABLE_CHEWY), DYNAMIC_PLUGIN)
diff --git a/engines/chewy/sound.cpp b/engines/chewy/sound.cpp
new file mode 100644
index 0000000000..41f91d0886
--- /dev/null
+++ b/engines/chewy/sound.cpp
@@ -0,0 +1,87 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "audio/audiostream.h"
+#include "audio/mixer.h"
+#include "audio/decoders/raw.h"
+#include "common/system.h"
+
+#include "chewy/resource.h"
+#include "chewy/sound.h"
+
+namespace Chewy {
+
+Sound::Sound() {
+ _speechRes = new Resource("speech.tvp");
+ _soundRes = new Resource("details.tap");
+}
+
+Sound::~Sound() {
+ delete _soundRes;
+ delete _speechRes;
+}
+
+void Sound::playSound(int num, bool loop) {
+ Chunk *chunk = _soundRes->getChunk(num);
+ byte *data = _soundRes->getChunkData(num);
+
+ Audio::AudioStream *stream = Audio::makeLoopingAudioStream(
+ Audio::makeRawStream(data,
+ chunk->size, 22050, Audio::FLAG_UNSIGNED,
+ DisposeAfterUse::NO),
+ loop ? 0 : 1);
+
+ g_engine->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, stream);
+}
+
+void Sound::playMusic(int num, bool loop) {
+ uint32 musicNum = _soundRes->getChunkCount() - 1 - num;
+ Chunk *chunk = _soundRes->getChunk(musicNum);
+ byte *data = _soundRes->getChunkData(musicNum);
+
+ // TODO: TMF music files are similar to MOD files. With the following
+ // incorrect implementation, the PCM parts of these files can be played
+ warning("The current music playing implementation is wrong");
+
+ Audio::AudioStream *stream = Audio::makeLoopingAudioStream(
+ Audio::makeRawStream(data,
+ chunk->size, 22050, Audio::FLAG_UNSIGNED,
+ DisposeAfterUse::NO),
+ loop ? 0 : 1);
+
+ g_engine->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, stream);
+}
+
+void Sound::playSpeech(int num) {
+ Chunk *chunk = _speechRes->getChunk(num);
+ byte *data = _speechRes->getChunkData(num);
+
+ Audio::AudioStream *stream = Audio::makeLoopingAudioStream(
+ Audio::makeRawStream(data,
+ chunk->size, 22050, Audio::FLAG_UNSIGNED,
+ DisposeAfterUse::NO),
+ 1);
+
+ g_engine->_mixer->playStream(Audio::Mixer::kSpeechSoundType, &_speechHandle, stream);
+}
+
+} // End of namespace Chewy
diff --git a/engines/chewy/sound.h b/engines/chewy/sound.h
new file mode 100644
index 0000000000..6537f3eabe
--- /dev/null
+++ b/engines/chewy/sound.h
@@ -0,0 +1,53 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHEWY_SOUND_H
+#define CHEWY_SOUND_H
+
+#include "audio/mixer.h"
+#include "chewy/chewy.h"
+
+namespace Chewy {
+
+class Resource;
+
+class Sound {
+public:
+ Sound();
+ ~Sound();
+
+ void playSound(int num, bool loop = false);
+ void playMusic(int num, bool loop = false);
+ void playSpeech(int num);
+
+private:
+ Audio::SoundHandle _soundHandle;
+ Audio::SoundHandle _musicHandle;
+ Audio::SoundHandle _speechHandle;
+
+ Resource *_speechRes;
+ Resource *_soundRes;
+};
+
+} // End of namespace Chewy
+
+#endif