[Scummvm-cvs-logs] SF.net SVN: scummvm:[40129] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Sat Apr 25 00:29:21 CEST 2009


Revision: 40129
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40129&view=rev
Author:   drmccoy
Date:     2009-04-24 22:29:17 +0000 (Fri, 24 Apr 2009)

Log Message:
-----------
Added supported for BAT-based non-interactive demos, namely the Inca2 one

Modified Paths:
--------------
    scummvm/trunk/engines/gob/detection.cpp
    scummvm/trunk/engines/gob/gob.cpp
    scummvm/trunk/engines/gob/gob.h
    scummvm/trunk/engines/gob/init.cpp
    scummvm/trunk/engines/gob/module.mk
    scummvm/trunk/engines/gob/scnplayer.cpp
    scummvm/trunk/engines/gob/scnplayer.h

Added Paths:
-----------
    scummvm/trunk/engines/gob/batplayer.cpp
    scummvm/trunk/engines/gob/batplayer.h
    scummvm/trunk/engines/gob/demoplayer.cpp
    scummvm/trunk/engines/gob/demoplayer.h

Added: scummvm/trunk/engines/gob/batplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/batplayer.cpp	                        (rev 0)
+++ scummvm/trunk/engines/gob/batplayer.cpp	2009-04-24 22:29:17 UTC (rev 40129)
@@ -0,0 +1,81 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/endian.h"
+
+#include "gob/gob.h"
+#include "gob/batplayer.h"
+#include "gob/global.h"
+#include "gob/util.h"
+#include "gob/draw.h"
+#include "gob/inter.h"
+#include "gob/videoplayer.h"
+
+namespace Gob {
+
+BATPlayer::BATPlayer(GobEngine *vm) : DemoPlayer(vm) {
+	_doubleMode = false;
+}
+
+BATPlayer::~BATPlayer() {
+}
+
+bool BATPlayer::play(const char *fileName) {
+	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) {
+	// Iterate over all lines
+	while (!bat.err() && !bat.eos()) {
+		Common::String line = bat.readLine();
+
+		// Interpret
+		if (lineStartsWith(line, "slide ")) {
+			playVideo(line.c_str() + 6);
+			clearScreen();
+		}
+
+		// Mind user input
+		_vm->_util->processInput();
+		if (_vm->shouldQuit())
+			return true;
+	}
+
+	if (bat.err())
+		return false;
+
+	return true;
+}
+
+} // End of namespace Gob


Property changes on: scummvm/trunk/engines/gob/batplayer.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Added: scummvm/trunk/engines/gob/batplayer.h
===================================================================
--- scummvm/trunk/engines/gob/batplayer.h	                        (rev 0)
+++ scummvm/trunk/engines/gob/batplayer.h	2009-04-24 22:29:17 UTC (rev 40129)
@@ -0,0 +1,48 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef GOB_BATPLAYER_H
+#define GOB_BATPLAYER_H
+
+#include "common/file.h"
+
+#include "demoplayer.h"
+
+namespace Gob {
+
+class BATPlayer : public DemoPlayer {
+public:
+	BATPlayer(GobEngine *vm);
+	virtual ~BATPlayer();
+
+	virtual bool play(const char *fileName);
+
+private:
+	bool play(Common::File &bat);
+};
+
+} // End of namespace Gob
+
+#endif // GOB_BATPLAYER_H


Property changes on: scummvm/trunk/engines/gob/batplayer.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Added: scummvm/trunk/engines/gob/demoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/demoplayer.cpp	                        (rev 0)
+++ scummvm/trunk/engines/gob/demoplayer.cpp	2009-04-24 22:29:17 UTC (rev 40129)
@@ -0,0 +1,107 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/endian.h"
+
+#include "gob/gob.h"
+#include "gob/demoplayer.h"
+#include "gob/global.h"
+#include "gob/util.h"
+#include "gob/draw.h"
+#include "gob/inter.h"
+#include "gob/videoplayer.h"
+
+namespace Gob {
+
+DemoPlayer::DemoPlayer(GobEngine *vm) : _vm(vm) {
+	_doubleMode = false;
+}
+
+DemoPlayer::~DemoPlayer() {
+}
+
+bool DemoPlayer::lineStartsWith(const Common::String &line, const char *start) {
+	return (strstr(line.c_str(), start) == line.c_str());
+}
+
+void DemoPlayer::init() {
+	// The video player needs some fake variables
+	_vm->_inter->allocateVars(32);
+
+	// Init the screen
+	_vm->_draw->initScreen();
+	_vm->_draw->_cursorIndex = -1;
+
+	_vm->_util->longDelay(200); // Letting everything settle
+
+}
+
+void DemoPlayer::clearScreen() {
+	debugC(1, kDebugDemo, "Clearing the screen");
+	_vm->_video->clearScreen();
+}
+
+void DemoPlayer::playVideo(const char *fileName) {
+	uint32 waitTime = 0;
+
+	// Trimming spaces front
+	while (*fileName == ' ')
+		fileName++;
+
+	char *spaceBack = strchr(fileName, ' ');
+	if (spaceBack) {
+		char *nextSpace = strchr(spaceBack, ' ');
+
+		if (nextSpace)
+			*nextSpace = '\0';
+
+		*spaceBack++ = '\0';
+
+		waitTime = atoi(spaceBack) * 100;
+	}
+
+	debugC(1, kDebugDemo, "Playing video \"%s\"", fileName);
+
+	// Playing the video
+	if (_vm->_vidPlayer->primaryOpen(fileName)) {
+		_vm->_vidPlayer->slotSetDoubleMode(-1, _doubleMode);
+		_vm->_vidPlayer->primaryPlay();
+		_vm->_vidPlayer->primaryClose();
+
+		if (waitTime > 0)
+			_vm->_util->longDelay(waitTime);
+	}
+}
+
+void DemoPlayer::evaluateVideoMode(const char *mode) {
+	debugC(2, kDebugDemo, "Video mode \"%s\"", mode);
+
+	if (!scumm_strnicmp(mode, "VESA", 4))
+		_doubleMode = false;
+	else if (!scumm_strnicmp(mode, "VGA", 3) && _vm->is640())
+		_doubleMode = true;
+}
+
+} // End of namespace Gob


Property changes on: scummvm/trunk/engines/gob/demoplayer.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Added: scummvm/trunk/engines/gob/demoplayer.h
===================================================================
--- scummvm/trunk/engines/gob/demoplayer.h	                        (rev 0)
+++ scummvm/trunk/engines/gob/demoplayer.h	2009-04-24 22:29:17 UTC (rev 40129)
@@ -0,0 +1,59 @@
+/* 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.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef GOB_DEMOPLAYER_H
+#define GOB_DEMOPLAYER_H
+
+#include "common/file.h"
+#include "common/str.h"
+#include "common/hashmap.h"
+
+namespace Gob {
+
+class GobEngine;
+
+class DemoPlayer {
+public:
+	DemoPlayer(GobEngine *vm);
+	virtual ~DemoPlayer();
+
+	virtual bool play(const char *fileName) = 0;
+
+protected:
+	GobEngine *_vm;
+	bool _doubleMode;
+
+	bool lineStartsWith(const Common::String &line, const char *start);
+
+	void init();
+
+	void evaluateVideoMode(const char *mode);
+	void clearScreen();
+	void playVideo(const char *fileName);
+};
+
+} // End of namespace Gob
+
+#endif // GOB_DEMOPLAYER_H


Property changes on: scummvm/trunk/engines/gob/demoplayer.h
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Modified: scummvm/trunk/engines/gob/detection.cpp
===================================================================
--- scummvm/trunk/engines/gob/detection.cpp	2009-04-24 21:30:40 UTC (rev 40128)
+++ scummvm/trunk/engines/gob/detection.cpp	2009-04-24 22:29:17 UTC (rev 40129)
@@ -2000,6 +2000,34 @@
 	},
 	{
 		{
+			"inca2",
+			"Non-Interactive Demo",
+			{
+				{"demo.bat", 0, "01a1c983c3d360cd4a96f93961a805de", 483},
+				{"cons.imd", 0, "f896ba0c4a1ac7f7260d342655980b49", 17804},
+				{"conseil.imd", 0, "aaedd5482d5b271e233e86c5a03cf62e", 33999},
+				{"int.imd", 0, "6308222fcefbcb20925f01c1aff70dee", 30871},
+				{"inter.imd", 0, "39bd6d3540f3bedcc97293f352c7f3fc", 191719},
+				{"machu.imd", 0, "c0bc8211d93b467bfd063b63fe61b85c", 34609},
+				{"post.imd", 0, "d75cad0e3fc22cb0c8b6faf597f509b2", 1047709},
+				{"posta.imd", 0, "2a5b3fe75681ddf4d21ac724db8111b4", 547250},
+				{"postb.imd", 0, "24260ce4e80a4c472352b76637265d09", 868312},
+				{"postc.imd", 0, "24accbcc8b83a9c2be4bd82849a2bd29", 415637},
+				{"tum.imd", 0, "0993d4810ec9deb3f77c5e92095320fd", 20330},
+				{"tumi.imd", 0, "bf53f229480d694de0947fe3366fbec6", 248952},
+				{NULL, 0, NULL, 0}
+			},
+			EN_ANY,
+			kPlatformPC,
+			ADGF_NO_FLAGS
+		},
+		kGameTypeInca2,
+		kFeaturesAdlib | kFeaturesBATDemo,
+		0,
+		"demo.bat"
+	},
+	{
+		{
 			"woodruff",
 			"",
 			AD_ENTRY1s("intro.stk", "dccf9d31cb720b34d75487408821b77e", 20296390),

Modified: scummvm/trunk/engines/gob/gob.cpp
===================================================================
--- scummvm/trunk/engines/gob/gob.cpp	2009-04-24 21:30:40 UTC (rev 40128)
+++ scummvm/trunk/engines/gob/gob.cpp	2009-04-24 22:29:17 UTC (rev 40129)
@@ -96,7 +96,7 @@
 	Common::addDebugChannel(kDebugGraphics, "Graphics", "Graphics debug level");
 	Common::addDebugChannel(kDebugVideo, "Video", "IMD/VMD video debug level");
 	Common::addDebugChannel(kDebugCollisions, "Collisions", "Collisions debug level");
-	Common::addDebugChannel(kDebugSCN, "SCN", "SCN demo script debug level");
+	Common::addDebugChannel(kDebugDemo, "Demo", "Demo script debug level");
 
 	syst->getEventManager()->registerRandomSource(_rnd, "gob");
 }
@@ -176,6 +176,10 @@
 	return (_features & kFeaturesSCNDemo) != 0;
 }
 
+bool GobEngine::isBATDemo() const {
+	return (_features & kFeaturesBATDemo) != 0;
+}
+
 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-04-24 21:30:40 UTC (rev 40128)
+++ scummvm/trunk/engines/gob/gob.h	2009-04-24 22:29:17 UTC (rev 40129)
@@ -109,7 +109,8 @@
 	kFeaturesEGA     = 1 << 1,
 	kFeaturesAdlib   = 1 << 2,
 	kFeatures640     = 1 << 3,
-	kFeaturesSCNDemo = 1 << 4
+	kFeaturesSCNDemo = 1 << 4,
+	kFeaturesBATDemo = 1 << 5
 };
 
 enum {
@@ -124,7 +125,7 @@
 	kDebugGraphics   = 1 <<  8,
 	kDebugVideo      = 1 <<  9,
 	kDebugCollisions = 1 << 10,
-	kDebugSCN        = 1 << 11
+	kDebugDemo       = 1 << 11
 };
 
 inline char *strncpy0(char *dest, const char *src, size_t n) {
@@ -250,6 +251,7 @@
 	bool is640() const;
 	bool hasAdlib() const;
 	bool isSCNDemo() const;
+	bool isBATDemo() const;
 
 	GobEngine(OSystem *syst);
 	virtual ~GobEngine();

Modified: scummvm/trunk/engines/gob/init.cpp
===================================================================
--- scummvm/trunk/engines/gob/init.cpp	2009-04-24 21:30:40 UTC (rev 40128)
+++ scummvm/trunk/engines/gob/init.cpp	2009-04-24 22:29:17 UTC (rev 40129)
@@ -37,6 +37,7 @@
 #include "gob/video.h"
 #include "gob/videoplayer.h"
 #include "gob/scnplayer.h"
+#include "gob/batplayer.h"
 #include "gob/sound/sound.h"
 
 namespace Gob {
@@ -101,10 +102,18 @@
 
 		SCNPlayer scnPlayer(_vm);
 
-		bool ret = scnPlayer.play(_vm->_startTot);
+		scnPlayer.play(_vm->_startTot);
 
-		warning("Played: %d", ret);
+		return;
+	}
 
+	if (_vm->isBATDemo()) {
+		// This is a non-interactive demo with a BAT script and videos
+
+		BATPlayer batPlayer(_vm);
+
+		batPlayer.play(_vm->_startTot);
+
 		return;
 	}
 

Modified: scummvm/trunk/engines/gob/module.mk
===================================================================
--- scummvm/trunk/engines/gob/module.mk	2009-04-24 21:30:40 UTC (rev 40128)
+++ scummvm/trunk/engines/gob/module.mk	2009-04-24 22:29:17 UTC (rev 40129)
@@ -55,7 +55,9 @@
 	scenery.o \
 	scenery_v1.o \
 	scenery_v2.o \
+	demoplayer.o \
 	scnplayer.o \
+	batplayer.o \
 	util.o \
 	variables.o \
 	video.o \

Modified: scummvm/trunk/engines/gob/scnplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/scnplayer.cpp	2009-04-24 21:30:40 UTC (rev 40128)
+++ scummvm/trunk/engines/gob/scnplayer.cpp	2009-04-24 22:29:17 UTC (rev 40129)
@@ -35,29 +35,18 @@
 
 namespace Gob {
 
-SCNPlayer::SCNPlayer(GobEngine *vm) : _vm(vm) {
+SCNPlayer::SCNPlayer(GobEngine *vm) : DemoPlayer(vm) {
 	_doubleMode = false;
 }
 
 SCNPlayer::~SCNPlayer() {
 }
 
-inline bool SCNPlayer::lineStartsWith(const Common::String &line, const char *start) {
-	return (strstr(line.c_str(), start) == line.c_str());
-}
-
 bool SCNPlayer::play(const char *fileName) {
-	debugC(1, kDebugSCN, "Playing SCN \"%s\"", fileName);
+	debugC(1, kDebugDemo, "Playing SCN \"%s\"", fileName);
 
-	// The video player needs some fake variables
-	_vm->_inter->allocateVars(32);
+	init();
 
-	// Init the screen
-	_vm->_draw->initScreen();
-	_vm->_draw->_cursorIndex = -1;
-
-	_vm->_util->longDelay(200); // Letting everything settle
-
 	Common::File scn;
 
 	if (!scn.open(fileName))
@@ -102,7 +91,7 @@
 }
 
 bool SCNPlayer::readLabels(Common::File &scn, LabelMap &labels) {
-	debugC(1, kDebugSCN, "Reading SCN labels");
+	debugC(1, kDebugDemo, "Reading SCN labels");
 
 	int32 startPos = scn.pos();
 
@@ -113,7 +102,7 @@
 		if (lineStartsWith(line, "LABEL ")) {
 			// Label => Add to the hashmap
 			labels.setVal(line.c_str() + 6, scn.pos());
-			debugC(2, kDebugSCN, "Found label \"%s\" (%d)", line.c_str() + 6, scn.pos());
+			debugC(2, kDebugDemo, "Found label \"%s\" (%d)", line.c_str() + 6, scn.pos());
 		}
 	}
 
@@ -128,7 +117,7 @@
 }
 
 void SCNPlayer::gotoLabel(Common::File &scn, const LabelMap &labels, const char *label) {
-	debugC(2, kDebugSCN, "Jumping to label \"%s\"", label);
+	debugC(2, kDebugDemo, "Jumping to label \"%s\"", label);
 
 	if (!labels.contains(label))
 		return;
@@ -136,33 +125,4 @@
 	scn.seek(labels.getVal(label));
 }
 
-void SCNPlayer::clearScreen() {
-	debugC(1, kDebugSCN, "Clearing the screen");
-	_vm->_video->clearScreen();
-}
-
-void SCNPlayer::playVideo(const char *fileName) {
-	// Trimming spaces
-	while (*fileName == ' ')
-		fileName++;
-
-	debugC(1, kDebugSCN, "Playing video \"%s\"", fileName);
-
-	// Playing the video
-	if (_vm->_vidPlayer->primaryOpen(fileName)) {
-		_vm->_vidPlayer->slotSetDoubleMode(-1, _doubleMode);
-		_vm->_vidPlayer->primaryPlay();
-		_vm->_vidPlayer->primaryClose();
-	}
-}
-
-void SCNPlayer::evaluateVideoMode(const char *mode) {
-	debugC(2, kDebugSCN, "Video mode \"%s\"", mode);
-
-	if (!scumm_strnicmp(mode, "VESA", 4))
-		_doubleMode = false;
-	else if (!scumm_strnicmp(mode, "VGA", 3) && _vm->is640())
-		_doubleMode = true;
-}
-
 } // End of namespace Gob

Modified: scummvm/trunk/engines/gob/scnplayer.h
===================================================================
--- scummvm/trunk/engines/gob/scnplayer.h	2009-04-24 21:30:40 UTC (rev 40128)
+++ scummvm/trunk/engines/gob/scnplayer.h	2009-04-24 22:29:17 UTC (rev 40129)
@@ -30,32 +30,24 @@
 #include "common/str.h"
 #include "common/hashmap.h"
 
+#include "demoplayer.h"
+
 namespace Gob {
 
-class GobEngine;
-
-class SCNPlayer {
+class SCNPlayer : public DemoPlayer {
 public:
 	SCNPlayer(GobEngine *vm);
-	~SCNPlayer();
+	virtual ~SCNPlayer();
 
-	bool play(const char *fileName);
+	virtual bool play(const char *fileName);
 
 private:
 	typedef Common::HashMap<Common::String, int32, Common::CaseSensitiveString_Hash, Common::CaseSensitiveString_EqualTo> LabelMap;
 
-	GobEngine *_vm;
-	bool _doubleMode;
-
 	bool play(Common::File &scn);
 	bool readLabels(Common::File &scn, LabelMap &labels);
 
-	inline bool lineStartsWith(const Common::String &line, const char *start);
-
 	void gotoLabel(Common::File &scn, const LabelMap &labels, const char *label);
-	void evaluateVideoMode(const char *mode);
-	void clearScreen();
-	void playVideo(const char *fileName);
 };
 
 } // End of namespace Gob


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