aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/demos
diff options
context:
space:
mode:
authorSven Hesse2009-05-20 23:13:44 +0000
committerSven Hesse2009-05-20 23:13:44 +0000
commitc9ff1d74925ad6a381bc714b57ddc8e56c6c235c (patch)
tree25a284c5f2828f11a6e965da82a17cf7531fa128 /engines/gob/demos
parent8e4b31f5220d73a211a2e822c27989fd96b65030 (diff)
downloadscummvm-rg350-c9ff1d74925ad6a381bc714b57ddc8e56c6c235c.tar.gz
scummvm-rg350-c9ff1d74925ad6a381bc714b57ddc8e56c6c235c.tar.bz2
scummvm-rg350-c9ff1d74925ad6a381bc714b57ddc8e56c6c235c.zip
- Changed the demo player to allow playing directly inlined scripts using a new demoIndex field in the detection array
- Changed the Inca 2 demo entry to use a directly included script instead of triggering on "demo.bat" svn-id: r40746
Diffstat (limited to 'engines/gob/demos')
-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
6 files changed, 90 insertions, 56 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