[Scummvm-cvs-logs] SF.net SVN: scummvm:[40746] scummvm/trunk/engines/gob
drmccoy at users.sourceforge.net
drmccoy at users.sourceforge.net
Thu May 21 01:13:45 CEST 2009
Revision: 40746
http://scummvm.svn.sourceforge.net/scummvm/?rev=40746&view=rev
Author: drmccoy
Date: 2009-05-20 23:13:44 +0000 (Wed, 20 May 2009)
Log Message:
-----------
- 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"
Modified Paths:
--------------
scummvm/trunk/engines/gob/demos/batplayer.cpp
scummvm/trunk/engines/gob/demos/batplayer.h
scummvm/trunk/engines/gob/demos/demoplayer.cpp
scummvm/trunk/engines/gob/demos/demoplayer.h
scummvm/trunk/engines/gob/demos/scnplayer.cpp
scummvm/trunk/engines/gob/demos/scnplayer.h
scummvm/trunk/engines/gob/gob.cpp
scummvm/trunk/engines/gob/gob.h
scummvm/trunk/engines/gob/init.cpp
scummvm/trunk/engines/gob/init.h
Modified: scummvm/trunk/engines/gob/demos/batplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/demos/batplayer.cpp 2009-05-20 21:00:52 UTC (rev 40745)
+++ scummvm/trunk/engines/gob/demos/batplayer.cpp 2009-05-20 23:13:44 UTC (rev 40746)
@@ -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();
Modified: scummvm/trunk/engines/gob/demos/batplayer.h
===================================================================
--- scummvm/trunk/engines/gob/demos/batplayer.h 2009-05-20 21:00:52 UTC (rev 40745)
+++ scummvm/trunk/engines/gob/demos/batplayer.h 2009-05-20 23:13:44 UTC (rev 40746)
@@ -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 @@
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
Modified: scummvm/trunk/engines/gob/demos/demoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/demos/demoplayer.cpp 2009-05-20 21:00:52 UTC (rev 40745)
+++ scummvm/trunk/engines/gob/demos/demoplayer.cpp 2009-05-20 23:13:44 UTC (rev 40746)
@@ -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() {
}
+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 @@
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)) {
Modified: scummvm/trunk/engines/gob/demos/demoplayer.h
===================================================================
--- scummvm/trunk/engines/gob/demos/demoplayer.h 2009-05-20 21:00:52 UTC (rev 40745)
+++ scummvm/trunk/engines/gob/demos/demoplayer.h 2009-05-20 23:13:44 UTC (rev 40746)
@@ -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 @@
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 @@
void playVideoNormal();
void playVideoDoubled();
+
+private:
+ enum ScriptSource {
+ kScriptSourceFile,
+ kScriptSourceDirect
+ };
+
+ struct Script {
+ ScriptSource source;
+ const char *script;
+ };
+
+ static Script _scripts[];
};
} // End of namespace Gob
Modified: scummvm/trunk/engines/gob/demos/scnplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/demos/scnplayer.cpp 2009-05-20 21:00:52 UTC (rev 40745)
+++ scummvm/trunk/engines/gob/demos/scnplayer.cpp 2009-05-20 23:13:44 UTC (rev 40746)
@@ -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 @@
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 @@
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))
Modified: scummvm/trunk/engines/gob/demos/scnplayer.h
===================================================================
--- scummvm/trunk/engines/gob/demos/scnplayer.h 2009-05-20 21:00:52 UTC (rev 40745)
+++ scummvm/trunk/engines/gob/demos/scnplayer.h 2009-05-20 23:13:44 UTC (rev 40746)
@@ -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 @@
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
Modified: scummvm/trunk/engines/gob/gob.cpp
===================================================================
--- scummvm/trunk/engines/gob/gob.cpp 2009-05-20 21:00:52 UTC (rev 40745)
+++ scummvm/trunk/engines/gob/gob.cpp 2009-05-20 23:13:44 UTC (rev 40746)
@@ -180,6 +180,10 @@
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");
Modified: scummvm/trunk/engines/gob/gob.h
===================================================================
--- scummvm/trunk/engines/gob/gob.h 2009-05-20 21:00:52 UTC (rev 40745)
+++ scummvm/trunk/engines/gob/gob.h 2009-05-20 23:13:44 UTC (rev 40746)
@@ -232,6 +232,8 @@
char *_startStk;
char *_startTot;
+ uint32 _demoIndex;
+
bool _copyProtection;
bool _noMusic;
@@ -266,6 +268,7 @@
bool hasAdlib() const;
bool isSCNDemo() const;
bool isBATDemo() const;
+ bool isDemo() const;
GobEngine(OSystem *syst);
virtual ~GobEngine();
Modified: scummvm/trunk/engines/gob/init.cpp
===================================================================
--- scummvm/trunk/engines/gob/init.cpp 2009-05-20 21:00:52 UTC (rev 40745)
+++ scummvm/trunk/engines/gob/init.cpp 2009-05-20 23:13:44 UTC (rev 40746)
@@ -48,7 +48,7 @@
_palDesc = 0;
}
-void Init::cleanup(void) {
+void Init::cleanup() {
_vm->_video->freeDriver();
_vm->_global->_primarySurfDesc = 0;
@@ -57,6 +57,28 @@
_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 @@
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,34 +119,14 @@
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);
-
+ if (_vm->isDemo()) {
+ doDemo();
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);
-
- delete _palDesc;
- _vm->_video->initPrimary(-1);
- cleanup();
- return;
- }
-
handle = _vm->_dataIO->openData("intro.inf");
if (handle < 0) {
Modified: scummvm/trunk/engines/gob/init.h
===================================================================
--- scummvm/trunk/engines/gob/init.h 2009-05-20 21:00:52 UTC (rev 40745)
+++ scummvm/trunk/engines/gob/init.h 2009-05-20 23:13:44 UTC (rev 40746)
@@ -44,7 +44,8 @@
static const char *_fontNames[4];
GobEngine *_vm;
- void cleanup(void);
+ void cleanup();
+ void doDemo();
};
class Init_v1 : public Init {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list