aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorThomas Fach-Pedersen2014-05-25 15:01:06 +0200
committerEugene Sandulenko2016-09-29 22:33:28 +0200
commit5cb4ba9a9b52705d84e30b07de1badb780e4b02e (patch)
tree51c336bfea4bdf11d9a07105ac7a1ef72846b9b3 /engines
parentd260f993aad56cf699d8ba298c84e603650edf8f (diff)
downloadscummvm-rg350-5cb4ba9a9b52705d84e30b07de1badb780e4b02e.tar.gz
scummvm-rg350-5cb4ba9a9b52705d84e30b07de1badb780e4b02e.tar.bz2
scummvm-rg350-5cb4ba9a9b52705d84e30b07de1badb780e4b02e.zip
BLADERUNNER: Add basic Scene, Set, and Script support.
Diffstat (limited to 'engines')
-rw-r--r--engines/bladerunner/bladerunner.cpp24
-rw-r--r--engines/bladerunner/bladerunner.h9
-rw-r--r--engines/bladerunner/chapters.cpp8
-rw-r--r--engines/bladerunner/chapters.h2
-rw-r--r--engines/bladerunner/module.mk4
-rw-r--r--engines/bladerunner/outtake.cpp2
-rw-r--r--engines/bladerunner/scene.cpp112
-rw-r--r--engines/bladerunner/scene.h64
-rw-r--r--engines/bladerunner/script/rc01.cpp43
-rw-r--r--engines/bladerunner/script/script.cpp55
-rw-r--r--engines/bladerunner/script/script.h83
-rw-r--r--engines/bladerunner/set.cpp45
-rw-r--r--engines/bladerunner/set.h47
-rw-r--r--engines/bladerunner/settings.cpp45
-rw-r--r--engines/bladerunner/vqa_decoder.cpp12
-rw-r--r--engines/bladerunner/vqa_decoder.h1
-rw-r--r--engines/bladerunner/vqa_player.cpp19
-rw-r--r--engines/bladerunner/vqa_player.h2
18 files changed, 527 insertions, 50 deletions
diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp
index e914f1c032..ff8ea2890e 100644
--- a/engines/bladerunner/bladerunner.cpp
+++ b/engines/bladerunner/bladerunner.cpp
@@ -26,6 +26,8 @@
#include "bladerunner/gameinfo.h"
#include "bladerunner/image.h"
#include "bladerunner/outtake.h"
+#include "bladerunner/scene.h"
+#include "bladerunner/script/script.h"
#include "bladerunner/settings.h"
#include "bladerunner/vqa_decoder.h"
@@ -46,6 +48,8 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst) : Engine(syst) {
_gameIsRunning = true;
_chapters = nullptr;
+ _scene = new Scene(this);
+ _script = new Script(this);
_settings = new Settings(this);
}
@@ -105,12 +109,12 @@ bool BladeRunnerEngine::startup() {
if (!r)
return false;
- initActors();
+ initChapterAndScene();
return true;
}
-void BladeRunnerEngine::initActors() {
+void BladeRunnerEngine::initChapterAndScene() {
// TODO: Init actors...
_settings->setChapter(1);
@@ -168,10 +172,6 @@ void BladeRunnerEngine::gameTick() {
// TODO: Only run if not in Kia, script, nor AI
_settings->openNewScene();
- outtakePlay(28, true);
- outtakePlay(41, true);
- outtakePlay( 0, false);
-
// TODO: Autosave
// TODO: Kia
// TODO: Spinner
@@ -184,11 +184,17 @@ void BladeRunnerEngine::gameTick() {
// TODO: ZBUF repair dirty rects
// TODO: Tick Ambient Audio (in Replicant)
- // TODO: Advance frame (in Replicant)
+ bool backgroundChanged = false;
+ int frame = _scene->advanceFrame(_surface1);
+ if (frame >= 0) {
+ _script->SceneFrameAdvanced(frame);
+ backgroundChanged = true;
+ }
+
// TODO: Render overlays (mostly in Replicant)
// TODO: Tick Actor AI and Timers (timers in Replicant)
- if (_settings->getNewScene() == -1 /* || in_script_counter || in_ai */) {
+ if (_settings->getNewScene() == -1 || _script->_inScriptCounter /* || in_ai */) {
// TODO: Tick and draw all actors in current set (drawing works in Replicant)
// TODO: Draw items (drawing works in Replicant)
@@ -198,7 +204,9 @@ void BladeRunnerEngine::gameTick() {
// TODO: Process AUD (audio in Replicant)
// TODO: Footstep sound
+ _system->copyRectToScreen((const byte *) _surface1.getBasePtr(0, 0), _surface1.pitch, 0, 0, 640, 480);
_system->updateScreen();
+ _system->delayMillis(10);
}
}
}
diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h
index 836450fd70..c13f6a8d0d 100644
--- a/engines/bladerunner/bladerunner.h
+++ b/engines/bladerunner/bladerunner.h
@@ -38,17 +38,20 @@ namespace BladeRunner {
const Graphics::PixelFormat RGB555(2, 5, 5, 5, 0, 10, 5, 0, 0);
class Chapters;
+class Scene;
+class Script;
class Settings;
class GameInfo;
class BladeRunnerEngine : public Engine {
- GameInfo *_gameInfo;
-
public:
bool _gameIsRunning;
bool _windowIsActive;
Chapters *_chapters;
+ GameInfo *_gameInfo;
+ Scene *_scene;
+ Script *_script;
Settings *_settings;
int in_script_counter;
@@ -67,7 +70,7 @@ public:
Common::Error BladeRunnerEngine::run();
bool startup();
- void initActors();
+ void initChapterAndScene();
void shutdown();
void loadSplash();
diff --git a/engines/bladerunner/chapters.cpp b/engines/bladerunner/chapters.cpp
index 280ce92ea2..a573ffffa3 100644
--- a/engines/bladerunner/chapters.cpp
+++ b/engines/bladerunner/chapters.cpp
@@ -32,10 +32,10 @@ bool Chapters::enterChapter(int chapter) {
if (!_vm->openArchive("A.TLK"))
return false;
- if (!_vm->openArchive(Common::String::format("VQA%d.MIX", MAX(id, 3))))
+ if (!_vm->openArchive(Common::String::format("VQA%d.MIX", MIN(id, 3))))
return false;
- if (!_vm->openArchive(Common::String::format("%d.TLK", MAX(id, 3))))
+ if (!_vm->openArchive(Common::String::format("%d.TLK", MIN(id, 3))))
return false;
if (!_vm->openArchive(Common::String::format("OUTTAKE%d.MIX", id)))
@@ -50,8 +50,8 @@ void Chapters::closeResources() {
int id = _resourceIds[_chapter];
_vm->closeArchive("A.TLK");
- _vm->closeArchive(Common::String::format("VQA%d.MIX", MAX(id, 3)));
- _vm->closeArchive(Common::String::format("%d.TLK", MAX(id, 3)));
+ _vm->closeArchive(Common::String::format("VQA%d.MIX", MIN(id, 3)));
+ _vm->closeArchive(Common::String::format("%d.TLK", MIN(id, 3)));
_vm->closeArchive(Common::String::format("OUTTAKE%d.MIX", id));
_hasOpenResources = false;
}
diff --git a/engines/bladerunner/chapters.h b/engines/bladerunner/chapters.h
index f167e1b068..9778209d04 100644
--- a/engines/bladerunner/chapters.h
+++ b/engines/bladerunner/chapters.h
@@ -54,7 +54,7 @@ public:
void closeResources();
bool hasOpenResources() { return _hasOpenResources; }
- int currentResouceId() { return _chapter ? _resourceIds[_chapter] : -1; }
+ int currentResourceId() { return _chapter ? _resourceIds[_chapter] : -1; }
};
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/module.mk b/engines/bladerunner/module.mk
index b1de94deae..752543b684 100644
--- a/engines/bladerunner/module.mk
+++ b/engines/bladerunner/module.mk
@@ -11,6 +11,10 @@ MODULE_OBJS = \
gameinfo.o \
image.o \
outtake.o \
+ scene.o \
+ script/rc01.o \
+ script/script.o \
+ set.o \
settings.o \
vqa_decoder.o \
vqa_player.o
diff --git a/engines/bladerunner/outtake.cpp b/engines/bladerunner/outtake.cpp
index 092dc51ebe..5bb63944c6 100644
--- a/engines/bladerunner/outtake.cpp
+++ b/engines/bladerunner/outtake.cpp
@@ -53,7 +53,7 @@ void OuttakePlayer::play(const Common::String &name, bool noLocalization, int co
while (!_vm->shouldQuit()) {
Common::Event event;
while (_vm->_system->getEventManager()->pollEvent(event))
- if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP)
+ if (event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE)
return;
int frame = vqa_player.update();
diff --git a/engines/bladerunner/scene.cpp b/engines/bladerunner/scene.cpp
new file mode 100644
index 0000000000..7cb3b017f2
--- /dev/null
+++ b/engines/bladerunner/scene.cpp
@@ -0,0 +1,112 @@
+/* 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 "bladerunner/scene.h"
+
+#include "bladerunner/bladerunner.h"
+#include "bladerunner/chapters.h"
+#include "bladerunner/gameinfo.h"
+#include "bladerunner/script/script.h"
+
+#include "common/str.h"
+#include "common/stream.h"
+
+namespace BladeRunner {
+
+bool Scene::open(int setId, int sceneId, bool isLoadingGame) {
+ if (!isLoadingGame) {
+ // flush ADQ
+ }
+
+ _setId = setId;
+ _sceneId = sceneId;
+
+ const Common::String setName = _vm->_gameInfo->getSetName(_sceneId);
+
+ if (isLoadingGame) {
+ // TODO: Set up overlays
+ } else {
+ // TODO: Clear regions
+ // TODO: Destroy all overlays
+ _defaultLoop = 0;
+ _frame = -1;
+ }
+
+ Common::String vqaName;
+ int currentResourceId = _vm->_chapters->currentResourceId();
+ if (currentResourceId == 1) {
+ vqaName = Common::String::format("%s.VQA", setName.c_str());
+ } else {
+ vqaName = Common::String::format("%s_%d.VQA", setName.c_str(), MIN(currentResourceId, 3));
+ }
+
+ if (!_vqaPlayer.open(vqaName))
+ return false;
+
+ Common::String sceneName = _vm->_gameInfo->getSetName(sceneId);
+ if (!_vm->_script->open(sceneName))
+ return false;
+
+ if (!isLoadingGame)
+ _vm->_script->InitializeScene();
+
+ Common::String setResourceName = Common::String::format("%s-MIN.SET", sceneName.c_str());
+ // if (!_set->open(setResourceName))
+ // return false;
+
+ // TODO: Set view
+ if (isLoadingGame) {
+ if (sceneId >= 73 && sceneId <= 76)
+ _vm->_script->InitializeScene();
+ return true;
+ }
+
+ // TODO: set VQADecoder parameters
+ // TODO: Set actor position from scene info
+ // TODO: Set actor set
+ // TODO: call SCRIPT_Scene_Loaded
+ _vm->_script->SceneLoaded();
+
+#if 0
+ // Init click map
+ int actorCount = _vm->_gameInfo->getActorCount();
+ for (int i = 0; i != actorCount; ++i) {
+ Actor *actor = _vm->_actors[i];
+ if (actor->getSet() == setId) {
+
+ }
+ }
+ // TODO: Update click map for set, items
+#endif
+
+ return true;
+}
+
+int Scene::advanceFrame(Graphics::Surface &surface) {
+ int frame = _vqaPlayer.update();
+ if (frame >= 0) {
+ surface.copyFrom(*_vqaPlayer.getSurface());
+ }
+ return frame;
+}
+
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/scene.h b/engines/bladerunner/scene.h
new file mode 100644
index 0000000000..b69d99decb
--- /dev/null
+++ b/engines/bladerunner/scene.h
@@ -0,0 +1,64 @@
+/* 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 BLADERUNNER_SCENE_H
+#define BLADERUNNER_SCENE_H
+
+#include "bladerunner/vqa_player.h"
+
+namespace BladeRunner {
+
+class BladeRunnerEngine;
+
+class Scene {
+ BladeRunnerEngine *_vm;
+
+public:
+ int _setId;
+ int _sceneId;
+ VQAPlayer _vqaPlayer;
+ int _defaultLoop;
+ int _nextSetId;
+ int _nextSceneId;
+ int _frame;
+ bool _playerWalkedIn;
+
+public:
+ Scene(BladeRunnerEngine *vm)
+ : _vm(vm),
+ _setId(-1),
+ _sceneId(-1),
+ _vqaPlayer(vm),
+ _defaultLoop(0),
+ _nextSetId(-1),
+ _nextSceneId(-1),
+ _playerWalkedIn(false)
+ {
+ }
+
+ bool open(int setId, int sceneId, bool isLoadingGame);
+ int advanceFrame(Graphics::Surface &surface);
+};
+
+} // End of namespace BladeRunner
+
+#endif
diff --git a/engines/bladerunner/script/rc01.cpp b/engines/bladerunner/script/rc01.cpp
new file mode 100644
index 0000000000..24cb27ca44
--- /dev/null
+++ b/engines/bladerunner/script/rc01.cpp
@@ -0,0 +1,43 @@
+/* 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 "bladerunner/script/script.h"
+
+#include "bladerunner/bladerunner.h"
+
+namespace BladeRunner {
+
+void ScriptRC01::InitializeScene() {
+ _vm->outtakePlay(28, true);
+ _vm->outtakePlay(41, true);
+ _vm->outtakePlay( 0, false);
+}
+
+void ScriptRC01::SceneLoaded() {
+
+}
+
+void ScriptRC01::SceneFrameAdvanced(int frame) {
+
+}
+
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/script/script.cpp b/engines/bladerunner/script/script.cpp
new file mode 100644
index 0000000000..948e8b8096
--- /dev/null
+++ b/engines/bladerunner/script/script.cpp
@@ -0,0 +1,55 @@
+/* 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 "bladerunner/script/script.h"
+
+#include "bladerunner/bladerunner.h"
+
+namespace BladeRunner {
+
+bool Script::open(const Common::String &name) {
+ delete _currentScript;
+
+ if (name == "RC01") { _currentScript = new ScriptRC01(_vm); return true; }
+
+ return false;
+}
+
+void Script::InitializeScene() {
+ _inScriptCounter++;
+ _currentScript->InitializeScene();
+ _inScriptCounter--;
+}
+
+void Script::SceneLoaded() {
+ _inScriptCounter++;
+ _currentScript->SceneLoaded();
+ _inScriptCounter--;
+}
+
+void Script::SceneFrameAdvanced(int frame) {
+ _inScriptCounter++;
+ _currentScript->SceneFrameAdvanced(frame);
+ _inScriptCounter--;
+}
+
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/script/script.h b/engines/bladerunner/script/script.h
new file mode 100644
index 0000000000..b9580358ce
--- /dev/null
+++ b/engines/bladerunner/script/script.h
@@ -0,0 +1,83 @@
+/* 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 BLADERUNNER_SCRIPT_H
+#define BLADERUNNER_SCRIPT_H
+
+#include "common/str.h"
+
+namespace BladeRunner {
+
+class BladeRunnerEngine;
+class ScriptBase;
+
+class Script {
+public:
+ BladeRunnerEngine *_vm;
+ int _inScriptCounter;
+ ScriptBase *_currentScript;
+
+ Script(BladeRunnerEngine *vm)
+ : _vm(vm),
+ _inScriptCounter(0),
+ _currentScript(nullptr)
+ {}
+
+ bool open(const Common::String &name);
+
+ void InitializeScene();
+ void SceneLoaded();
+ void SceneFrameAdvanced(int frame);
+};
+
+class ScriptBase {
+protected:
+ BladeRunnerEngine *_vm;
+
+ ScriptBase(BladeRunnerEngine *vm)
+ : _vm(vm)
+ {}
+
+public:
+ virtual void InitializeScene() = 0;
+ virtual void SceneLoaded() = 0;
+ virtual void SceneFrameAdvanced(int frame) = 0;
+};
+
+#define DECLARE_SCRIPT(name) \
+class Script##name : public ScriptBase { \
+public: \
+ Script##name(BladeRunnerEngine *_vm) \
+ : ScriptBase(_vm) \
+ {} \
+ void InitializeScene(); \
+ void SceneLoaded(); \
+ void SceneFrameAdvanced(int frame); \
+};
+
+DECLARE_SCRIPT(RC01)
+
+#undef DECLARE_SCRIPT
+
+} // End of namespace BladeRunner
+
+#endif
diff --git a/engines/bladerunner/set.cpp b/engines/bladerunner/set.cpp
new file mode 100644
index 0000000000..2751c1dc48
--- /dev/null
+++ b/engines/bladerunner/set.cpp
@@ -0,0 +1,45 @@
+/* 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 "bladerunner/set.h"
+
+#include "bladerunner/bladerunner.h"
+
+#include "common/ptr.h"
+#include "common/str.h"
+#include "common/stream.h"
+
+namespace BladeRunner {
+
+#define kSet0 0x53657430
+
+bool Set::open(const Common::String &name) {
+ Common::ScopedPtr<Common::SeekableReadStream> s(_vm->getResourceStream(name));
+
+ uint32 sig = s->readUint32BE();
+ if (sig != kSet0)
+ return false;
+
+ return true;
+}
+
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/set.h b/engines/bladerunner/set.h
new file mode 100644
index 0000000000..b2982781c9
--- /dev/null
+++ b/engines/bladerunner/set.h
@@ -0,0 +1,47 @@
+/* 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 BLADERUNNER_SET_H
+#define BLADERUNNER_SET_H
+
+#include "common/str.h"
+
+namespace BladeRunner {
+
+class BladeRunnerEngine;
+
+class VQADecoder;
+
+class Set {
+ BladeRunnerEngine *_vm;
+
+public:
+ Set(BladeRunnerEngine *vm)
+ {
+ }
+
+ bool open(const Common::String &name);
+};
+
+} // End of namespace BladeRunner
+
+#endif
diff --git a/engines/bladerunner/settings.cpp b/engines/bladerunner/settings.cpp
index c31d4a37db..0759762e95 100644
--- a/engines/bladerunner/settings.cpp
+++ b/engines/bladerunner/settings.cpp
@@ -24,6 +24,9 @@
#include "bladerunner/bladerunner.h"
#include "bladerunner/chapters.h"
+#include "bladerunner/scene.h"
+
+#include "common/debug.h"
namespace BladeRunner {
@@ -33,17 +36,16 @@ Settings::Settings(BladeRunnerEngine *vm)
_chapter = 1;
_gamma = 1.0f;
- _chapterChanged;
- _newChapter;
- _newScene;
- _newSet;
-
- _startingGame;
- _loadingGame;
+ _chapterChanged = false;
+ _newChapter = -1;
+ _newScene = -1;
+ _newSet = -1;
- _fullHDFrames;
- _mst3k;
+ _startingGame = true;
+ _loadingGame = false;
+ _fullHDFrames = true;
+ _mst3k = false;
}
bool Settings::openNewScene() {
@@ -57,9 +59,9 @@ bool Settings::openNewScene() {
// Stop ambient audio and music
}
- // int currentSet = _vm->scene()->getSet();
- // int newSet = _newSet;
- // int newScene = _newScene;
+ int currentSet = _vm->_scene->_setId;
+ int newSet = _newSet;
+ int newScene = _newScene;
_newSet = -1;
_newScene = -1;
@@ -71,8 +73,7 @@ bool Settings::openNewScene() {
int newChapter = _newChapter;
_chapterChanged = false;
_newChapter = 0;
- if (!_vm->_chapters->enterChapter(newChapter))
- {
+ if (!_vm->_chapters->enterChapter(newChapter)) {
_vm->_gameIsRunning = false;
return false;
}
@@ -81,16 +82,14 @@ bool Settings::openNewScene() {
_startingGame = false;
}
- // if (!_vm->scene()->open(newSet, newScene, _loadingGame))
- // {
- // _vm->_gameIsRunning = false;
- // return false;
- // }
-
- // if (!_loadingGame && currentSet != newSet) {
- // // TODO: Reset actors for new set
+ if (!_vm->_scene->open(newSet, newScene, _loadingGame)) {
+ _vm->_gameIsRunning = false;
+ return false;
+ }
- // }
+ if (!_loadingGame && currentSet != newSet) {
+ // TODO: Reset actors for new set
+ }
_loadingGame = false;
return true;
diff --git a/engines/bladerunner/vqa_decoder.cpp b/engines/bladerunner/vqa_decoder.cpp
index d97c1d8c46..4f484caf4b 100644
--- a/engines/bladerunner/vqa_decoder.cpp
+++ b/engines/bladerunner/vqa_decoder.cpp
@@ -295,9 +295,11 @@ bool VQADecoder::readVQHD(Common::SeekableReadStream *s, uint32 size)
}
assert(_header.version == 2);
- assert(_header.freq == 22050);
- assert(_header.channels == 1);
- assert(_header.bits == 16);
+ if (_header.channels != 0) {
+ assert(_header.freq == 22050);
+ assert(_header.channels == 1);
+ assert(_header.bits == 16);
+ }
assert(_header.colors == 0);
return true;
@@ -497,9 +499,11 @@ bool VQADecoder::readLNIN(Common::SeekableReadStream *s, uint32 size)
for (int i = 0; i != loopNamesCount; ++i) {
char *begin = names + loopNameOffsets[i];
- uint32 len = ((i == loopNamesCount) ? chd.size : loopNameOffsets[i+1]) - loopNameOffsets[i];
+ uint32 len = ((i == loopNamesCount - 1) ? chd.size : loopNameOffsets[i+1]) - loopNameOffsets[i];
_loopInfo.loops[i].name = Common::String(begin, len);
+
+ // debug("%2d: %s", i, _loopInfo.loops[i].name.c_str());
}
return true;
diff --git a/engines/bladerunner/vqa_decoder.h b/engines/bladerunner/vqa_decoder.h
index f5b00f5c33..d07d73f0f8 100644
--- a/engines/bladerunner/vqa_decoder.h
+++ b/engines/bladerunner/vqa_decoder.h
@@ -57,6 +57,7 @@ public:
uint16 offsetX() const { return _header.offsetX; }
uint16 offsetY() const { return _header.offsetY; }
+ bool hasAudio() const { return _header.channels != 0; }
uint16 frequency() const { return _header.freq; }
protected:
diff --git a/engines/bladerunner/vqa_player.cpp b/engines/bladerunner/vqa_player.cpp
index ad269efc75..8259625c0b 100644
--- a/engines/bladerunner/vqa_player.cpp
+++ b/engines/bladerunner/vqa_player.cpp
@@ -41,7 +41,9 @@ bool VQAPlayer::open(const Common::String &name) {
return false;
}
- _audioStream = Audio::makeQueuingAudioStream(_decoder.frequency(), false);
+ _hasAudio = _decoder.hasAudio();
+ if (_hasAudio)
+ _audioStream = Audio::makeQueuingAudioStream(_decoder.frequency(), false);
return true;
}
@@ -59,18 +61,22 @@ int VQAPlayer::update() {
_curFrame = 0;
if (_curFrame >= 0) {
_decoder.readNextPacket();
- queueAudioFrame(_decoder.decodeAudioFrame());
+ if (_hasAudio)
+ queueAudioFrame(_decoder.decodeAudioFrame());
_surface = _decoder.decodeVideoFrame();
}
_decodedFrame = calcNextFrame(_curFrame);
if (_decodedFrame >= 0) {
_decoder.readNextPacket();
- queueAudioFrame(_decoder.decodeAudioFrame());
+ if (_hasAudio)
+ queueAudioFrame(_decoder.decodeAudioFrame());
}
- _vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, _audioStream);
- _audioStarted = true;
+ if (_hasAudio) {
+ _vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, _audioStream);
+ _audioStarted = true;
+ }
_nextFrameTime = now + 60000 / 15;
return _curFrame;
@@ -85,7 +91,8 @@ int VQAPlayer::update() {
_decodedFrame = calcNextFrame(_curFrame);
if (_decodedFrame >= 0) {
_decoder.readNextPacket();
- queueAudioFrame(_decoder.decodeAudioFrame());
+ if (_hasAudio)
+ queueAudioFrame(_decoder.decodeAudioFrame());
}
_nextFrameTime += 60000 / 15;
diff --git a/engines/bladerunner/vqa_player.h b/engines/bladerunner/vqa_player.h
index 128bbe604d..9e9266ed45 100644
--- a/engines/bladerunner/vqa_player.h
+++ b/engines/bladerunner/vqa_player.h
@@ -48,6 +48,7 @@ class VQAPlayer {
int _loopDefault;
uint32 _nextFrameTime;
+ bool _hasAudio;
bool _audioStarted;
Audio::SoundHandle _soundHandle;
@@ -64,6 +65,7 @@ public:
_loopSpecial(-1),
_loopDefault(-1),
_nextFrameTime(0),
+ _hasAudio(false),
_audioStarted(false)
{}