aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/gob/demos/batplayer.cpp19
-rw-r--r--engines/gob/demos/batplayer.h8
-rw-r--r--engines/gob/demos/demoplayer.cpp65
-rw-r--r--engines/gob/demos/demoplayer.h20
-rw-r--r--engines/gob/demos/scnplayer.cpp25
-rw-r--r--engines/gob/demos/scnplayer.h9
-rw-r--r--engines/gob/gob.cpp4
-rw-r--r--engines/gob/gob.h3
-rw-r--r--engines/gob/init.cpp58
-rw-r--r--engines/gob/init.h3
10 files changed, 130 insertions, 84 deletions
diff --git a/engines/gob/demos/batplayer.cpp b/engines/gob/demos/batplayer.cpp
index d3aae2691d..700aa6316f 100644
--- a/engines/gob/demos/batplayer.cpp
+++ b/engines/gob/demos/batplayer.cpp
@@ -36,29 +36,12 @@
namespace Gob {
BATPlayer::BATPlayer(GobEngine *vm) : DemoPlayer(vm) {
- _doubleMode = false;
}
BATPlayer::~BATPlayer() {
}
-bool BATPlayer::play(const char *fileName) {
- if (!fileName)
- return false;
-
- debugC(1, kDebugDemo, "Playing BAT \"%s\"", fileName);
-
- init();
-
- Common::File bat;
-
- if (!bat.open(fileName))
- return false;
-
- return play(bat);
-}
-
-bool BATPlayer::play(Common::File &bat) {
+bool BATPlayer::playStream(Common::SeekableReadStream &bat) {
// Iterate over all lines
while (!bat.err() && !bat.eos()) {
Common::String line = bat.readLine();
diff --git a/engines/gob/demos/batplayer.h b/engines/gob/demos/batplayer.h
index 861b0b8749..e9d9916f6a 100644
--- a/engines/gob/demos/batplayer.h
+++ b/engines/gob/demos/batplayer.h
@@ -26,8 +26,6 @@
#ifndef GOB_BATPLAYER_H
#define GOB_BATPLAYER_H
-#include "common/file.h"
-
#include "gob/demos/demoplayer.h"
namespace Gob {
@@ -37,10 +35,8 @@ public:
BATPlayer(GobEngine *vm);
virtual ~BATPlayer();
- virtual bool play(const char *fileName);
-
-private:
- bool play(Common::File &bat);
+protected:
+ virtual bool playStream(Common::SeekableReadStream &bat);
};
} // End of namespace Gob
diff --git a/engines/gob/demos/demoplayer.cpp b/engines/gob/demos/demoplayer.cpp
index f05e1e4aac..423ca1073b 100644
--- a/engines/gob/demos/demoplayer.cpp
+++ b/engines/gob/demos/demoplayer.cpp
@@ -24,6 +24,7 @@
*/
#include "common/endian.h"
+#include "common/file.h"
#include "gob/gob.h"
#include "gob/demos/demoplayer.h"
@@ -35,6 +36,22 @@
namespace Gob {
+DemoPlayer::Script DemoPlayer::_scripts[] = {
+ {kScriptSourceFile, "demo.scn"},
+ {kScriptSourceFile, "wdemo.s24"},
+ {kScriptSourceFile, "play123.scn"},
+ {kScriptSourceFile, "e.scn"},
+ {kScriptSourceFile, "i.scn"},
+ {kScriptSourceFile, "s.scn"},
+ {kScriptSourceDirect,
+ "slide machu.imd 20\nslide conseil.imd 20\nslide cons.imd 20\n" \
+ "slide tumia.imd 1\nslide tumib.imd 1\nslide tumic.imd 1\n" \
+ "slide tumid.imd 1\nslide post.imd 1\nslide posta.imd 1\n" \
+ "slide postb.imd 1\nslide postc.imd 1\nslide xdome.imd 20\n" \
+ "slide xant.imd 20\nslide tum.imd 20\nslide voile.imd 20\n" \
+ "slide int.imd 20\nslide voila.imd 1\nslide voilb.imd 1\n"}
+};
+
DemoPlayer::DemoPlayer(GobEngine *vm) : _vm(vm) {
_doubleMode = false;
}
@@ -42,6 +59,49 @@ DemoPlayer::DemoPlayer(GobEngine *vm) : _vm(vm) {
DemoPlayer::~DemoPlayer() {
}
+bool DemoPlayer::play(const char *fileName) {
+ if (!fileName)
+ return false;
+
+ debugC(1, kDebugDemo, "Playing \"%s\"", fileName);
+
+ init();
+
+ Common::File bat;
+
+ if (!bat.open(fileName))
+ return false;
+
+ return playStream(bat);
+}
+
+bool DemoPlayer::play(uint32 index) {
+ if (index >= ARRAYSIZE(_scripts))
+ return false;
+
+ Script &script = _scripts[index];
+
+ debugC(1, kDebugDemo, "Playing demoIndex %d: %d", index, script.source);
+
+ switch (script.source) {
+ case kScriptSourceFile:
+ return play(script.script);
+
+ case kScriptSourceDirect:
+ {
+ Common::MemoryReadStream stream((const byte *) script.script, strlen(script.script));
+
+ init();
+ return playStream(stream);
+ }
+
+ default:
+ return false;
+ }
+
+ return false;
+}
+
bool DemoPlayer::lineStartsWith(const Common::String &line, const char *start) {
return (strstr(line.c_str(), start) == line.c_str());
}
@@ -85,11 +145,6 @@ void DemoPlayer::playVideo(const char *fileName) {
waitTime = atoi(spaceBack) * 100;
}
- // WORKAROUND: The Inca2 demo wants to play cons2.imd, but that file doesn't exist.
- // cons.imd does, however.
- if ((_vm->getGameType() == kGameTypeInca2) && (!scumm_stricmp(file, "cons2.imd")))
- strcpy(file, "cons.imd");
-
debugC(1, kDebugDemo, "Playing video \"%s\"", file);
if (_vm->_vidPlayer->primaryOpen(file)) {
diff --git a/engines/gob/demos/demoplayer.h b/engines/gob/demos/demoplayer.h
index c26ecacaa9..52c089c8f1 100644
--- a/engines/gob/demos/demoplayer.h
+++ b/engines/gob/demos/demoplayer.h
@@ -26,8 +26,8 @@
#ifndef GOB_DEMOPLAYER_H
#define GOB_DEMOPLAYER_H
-#include "common/file.h"
#include "common/str.h"
+#include "common/stream.h"
#include "common/hashmap.h"
namespace Gob {
@@ -39,12 +39,15 @@ public:
DemoPlayer(GobEngine *vm);
virtual ~DemoPlayer();
- virtual bool play(const char *fileName) = 0;
+ bool play(const char *fileName);
+ bool play(uint32 index);
protected:
GobEngine *_vm;
bool _doubleMode;
+ virtual bool playStream(Common::SeekableReadStream &stream) = 0;
+
bool lineStartsWith(const Common::String &line, const char *start);
void init();
@@ -55,6 +58,19 @@ protected:
void playVideoNormal();
void playVideoDoubled();
+
+private:
+ enum ScriptSource {
+ kScriptSourceFile,
+ kScriptSourceDirect
+ };
+
+ struct Script {
+ ScriptSource source;
+ const char *script;
+ };
+
+ static Script _scripts[];
};
} // End of namespace Gob
diff --git a/engines/gob/demos/scnplayer.cpp b/engines/gob/demos/scnplayer.cpp
index 3b4fd498de..dc86652bd2 100644
--- a/engines/gob/demos/scnplayer.cpp
+++ b/engines/gob/demos/scnplayer.cpp
@@ -36,29 +36,12 @@
namespace Gob {
SCNPlayer::SCNPlayer(GobEngine *vm) : DemoPlayer(vm) {
- _doubleMode = false;
}
SCNPlayer::~SCNPlayer() {
}
-bool SCNPlayer::play(const char *fileName) {
- if (!fileName)
- return false;
-
- debugC(1, kDebugDemo, "Playing SCN \"%s\"", fileName);
-
- init();
-
- Common::File scn;
-
- if (!scn.open(fileName))
- return false;
-
- return play(scn);
-}
-
-bool SCNPlayer::play(Common::File &scn) {
+bool SCNPlayer::playStream(Common::SeekableReadStream &scn) {
// Read labels
LabelMap labels;
if (!readLabels(scn, labels))
@@ -93,7 +76,7 @@ bool SCNPlayer::play(Common::File &scn) {
return true;
}
-bool SCNPlayer::readLabels(Common::File &scn, LabelMap &labels) {
+bool SCNPlayer::readLabels(Common::SeekableReadStream &scn, LabelMap &labels) {
debugC(1, kDebugDemo, "Reading SCN labels");
int32 startPos = scn.pos();
@@ -119,7 +102,9 @@ bool SCNPlayer::readLabels(Common::File &scn, LabelMap &labels) {
return true;
}
-void SCNPlayer::gotoLabel(Common::File &scn, const LabelMap &labels, const char *label) {
+void SCNPlayer::gotoLabel(Common::SeekableReadStream &scn,
+ const LabelMap &labels, const char *label) {
+
debugC(2, kDebugDemo, "Jumping to label \"%s\"", label);
if (!labels.contains(label))
diff --git a/engines/gob/demos/scnplayer.h b/engines/gob/demos/scnplayer.h
index 752e3714c7..9c6a211fc6 100644
--- a/engines/gob/demos/scnplayer.h
+++ b/engines/gob/demos/scnplayer.h
@@ -26,7 +26,6 @@
#ifndef GOB_SCNPLAYER_H
#define GOB_SCNPLAYER_H
-#include "common/file.h"
#include "common/str.h"
#include "common/hashmap.h"
@@ -39,15 +38,15 @@ public:
SCNPlayer(GobEngine *vm);
virtual ~SCNPlayer();
- virtual bool play(const char *fileName);
+protected:
+ virtual bool playStream(Common::SeekableReadStream &scn);
private:
typedef Common::HashMap<Common::String, int32, Common::CaseSensitiveString_Hash, Common::CaseSensitiveString_EqualTo> LabelMap;
- bool play(Common::File &scn);
- bool readLabels(Common::File &scn, LabelMap &labels);
+ bool readLabels(Common::SeekableReadStream &scn, LabelMap &labels);
- void gotoLabel(Common::File &scn, const LabelMap &labels, const char *label);
+ void gotoLabel(Common::SeekableReadStream &scn, const LabelMap &labels, const char *label);
};
} // End of namespace Gob
diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp
index 05ab2d9b5a..e2775fd87e 100644
--- a/engines/gob/gob.cpp
+++ b/engines/gob/gob.cpp
@@ -180,6 +180,10 @@ bool GobEngine::isBATDemo() const {
return (_features & kFeaturesBATDemo) != 0;
}
+bool GobEngine::isDemo() const {
+ return (isSCNDemo() || isBATDemo());
+}
+
Common::Error GobEngine::run() {
if (!initGameParts()) {
GUIErrorMessage("GobEngine::init(): Unknown version of game engine");
diff --git a/engines/gob/gob.h b/engines/gob/gob.h
index 3e7c0bfc0a..d5c704e910 100644
--- a/engines/gob/gob.h
+++ b/engines/gob/gob.h
@@ -232,6 +232,8 @@ public:
char *_startStk;
char *_startTot;
+ uint32 _demoIndex;
+
bool _copyProtection;
bool _noMusic;
@@ -266,6 +268,7 @@ public:
bool hasAdlib() const;
bool isSCNDemo() const;
bool isBATDemo() const;
+ bool isDemo() const;
GobEngine(OSystem *syst);
virtual ~GobEngine();
diff --git a/engines/gob/init.cpp b/engines/gob/init.cpp
index 7f943c068f..1f1942e00c 100644
--- a/engines/gob/init.cpp
+++ b/engines/gob/init.cpp
@@ -48,7 +48,7 @@ Init::Init(GobEngine *vm) : _vm(vm) {
_palDesc = 0;
}
-void Init::cleanup(void) {
+void Init::cleanup() {
_vm->_video->freeDriver();
_vm->_global->_primarySurfDesc = 0;
@@ -57,6 +57,28 @@ void Init::cleanup(void) {
_vm->_dataIO->closeDataFile();
}
+void Init::doDemo() {
+ if (_vm->isSCNDemo()) {
+ // This is a non-interactive demo with a SCN script and VMD videos
+
+ _vm->_video->setPrePalette();
+
+ SCNPlayer scnPlayer(_vm);
+
+ if (_vm->_demoIndex > 0)
+ scnPlayer.play(_vm->_demoIndex - 1);
+ }
+
+ if (_vm->isBATDemo()) {
+ // This is a non-interactive demo with a BAT script and videos
+
+ BATPlayer batPlayer(_vm);
+
+ if (_vm->_demoIndex > 0)
+ batPlayer.play(_vm->_demoIndex - 1);
+ }
+}
+
void Init::initGame() {
int16 handle2;
int16 handle;
@@ -68,10 +90,12 @@ void Init::initGame() {
initVideo();
- handle2 = _vm->_dataIO->openData(_vm->_startStk);
- if (handle2 >= 0) {
- _vm->_dataIO->closeData(handle2);
- _vm->_dataIO->openDataFile(_vm->_startStk);
+ if (!_vm->isDemo()) {
+ handle2 = _vm->_dataIO->openData(_vm->_startStk);
+ if (handle2 >= 0) {
+ _vm->_dataIO->closeData(handle2);
+ _vm->_dataIO->openDataFile(_vm->_startStk);
+ }
}
_vm->_util->initInput();
@@ -95,28 +119,8 @@ void Init::initGame() {
for (int i = 0; i < 8; i++)
_vm->_draw->_fonts[i] = 0;
- if (_vm->isSCNDemo()) {
- // This is a non-interactive demo with a SCN script and VMD videos
-
- _vm->_video->setPrePalette();
-
- SCNPlayer scnPlayer(_vm);
-
- scnPlayer.play(_vm->_startTot);
-
- delete _palDesc;
- _vm->_video->initPrimary(-1);
- cleanup();
- return;
- }
-
- if (_vm->isBATDemo()) {
- // This is a non-interactive demo with a BAT script and videos
-
- BATPlayer batPlayer(_vm);
-
- batPlayer.play(_vm->_startTot);
-
+ if (_vm->isDemo()) {
+ doDemo();
delete _palDesc;
_vm->_video->initPrimary(-1);
cleanup();
diff --git a/engines/gob/init.h b/engines/gob/init.h
index 6ab2fa7e66..a8d4b9833e 100644
--- a/engines/gob/init.h
+++ b/engines/gob/init.h
@@ -44,7 +44,8 @@ protected:
static const char *_fontNames[4];
GobEngine *_vm;
- void cleanup(void);
+ void cleanup();
+ void doDemo();
};
class Init_v1 : public Init {