diff options
author | Sven Hesse | 2009-04-24 22:29:17 +0000 |
---|---|---|
committer | Sven Hesse | 2009-04-24 22:29:17 +0000 |
commit | 383a2b332226acdd8eb69535837965bb723bfc68 (patch) | |
tree | 67bf660d5963f9c0130f31832d656b333bc0045e | |
parent | d8972c3f2cc9a28e750dcaee38d6cf84380d95eb (diff) | |
download | scummvm-rg350-383a2b332226acdd8eb69535837965bb723bfc68.tar.gz scummvm-rg350-383a2b332226acdd8eb69535837965bb723bfc68.tar.bz2 scummvm-rg350-383a2b332226acdd8eb69535837965bb723bfc68.zip |
Added supported for BAT-based non-interactive demos, namely the Inca2 one
svn-id: r40129
-rw-r--r-- | engines/gob/batplayer.cpp | 81 | ||||
-rw-r--r-- | engines/gob/batplayer.h | 48 | ||||
-rw-r--r-- | engines/gob/demoplayer.cpp | 107 | ||||
-rw-r--r-- | engines/gob/demoplayer.h | 59 | ||||
-rw-r--r-- | engines/gob/detection.cpp | 28 | ||||
-rw-r--r-- | engines/gob/gob.cpp | 6 | ||||
-rw-r--r-- | engines/gob/gob.h | 6 | ||||
-rw-r--r-- | engines/gob/init.cpp | 13 | ||||
-rw-r--r-- | engines/gob/module.mk | 2 | ||||
-rw-r--r-- | engines/gob/scnplayer.cpp | 52 | ||||
-rw-r--r-- | engines/gob/scnplayer.h | 18 |
11 files changed, 356 insertions, 64 deletions
diff --git a/engines/gob/batplayer.cpp b/engines/gob/batplayer.cpp new file mode 100644 index 0000000000..4cce68302f --- /dev/null +++ b/engines/gob/batplayer.cpp @@ -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 diff --git a/engines/gob/batplayer.h b/engines/gob/batplayer.h new file mode 100644 index 0000000000..bbce238f06 --- /dev/null +++ b/engines/gob/batplayer.h @@ -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 diff --git a/engines/gob/demoplayer.cpp b/engines/gob/demoplayer.cpp new file mode 100644 index 0000000000..16eebd53bf --- /dev/null +++ b/engines/gob/demoplayer.cpp @@ -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 diff --git a/engines/gob/demoplayer.h b/engines/gob/demoplayer.h new file mode 100644 index 0000000000..8663426649 --- /dev/null +++ b/engines/gob/demoplayer.h @@ -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 diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index 1fbefe9297..4a5e012812 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -2000,6 +2000,34 @@ static const GOBGameDescription gameDescriptions[] = { }, { { + "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), diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index 42e8654a5b..05db4ffee6 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -96,7 +96,7 @@ GobEngine::GobEngine(OSystem *syst) : Engine(syst) { 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 @@ bool GobEngine::isSCNDemo() const { 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"); diff --git a/engines/gob/gob.h b/engines/gob/gob.h index 36a328946d..f8f3605426 100644 --- a/engines/gob/gob.h +++ b/engines/gob/gob.h @@ -109,7 +109,8 @@ enum Features { kFeaturesEGA = 1 << 1, kFeaturesAdlib = 1 << 2, kFeatures640 = 1 << 3, - kFeaturesSCNDemo = 1 << 4 + kFeaturesSCNDemo = 1 << 4, + kFeaturesBATDemo = 1 << 5 }; enum { @@ -124,7 +125,7 @@ enum { 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 @@ public: bool is640() const; bool hasAdlib() const; bool isSCNDemo() const; + bool isBATDemo() const; GobEngine(OSystem *syst); virtual ~GobEngine(); diff --git a/engines/gob/init.cpp b/engines/gob/init.cpp index 93b141b1ce..fcc24875cd 100644 --- a/engines/gob/init.cpp +++ b/engines/gob/init.cpp @@ -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,9 +102,17 @@ void Init::initGame() { 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; } diff --git a/engines/gob/module.mk b/engines/gob/module.mk index ec8e99ad00..ca54248a66 100644 --- a/engines/gob/module.mk +++ b/engines/gob/module.mk @@ -55,7 +55,9 @@ MODULE_OBJS := \ scenery.o \ scenery_v1.o \ scenery_v2.o \ + demoplayer.o \ scnplayer.o \ + batplayer.o \ util.o \ variables.o \ video.o \ diff --git a/engines/gob/scnplayer.cpp b/engines/gob/scnplayer.cpp index b37f8f6fe5..573243c768 100644 --- a/engines/gob/scnplayer.cpp +++ b/engines/gob/scnplayer.cpp @@ -35,28 +35,17 @@ 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); - - // The video player needs some fake variables - _vm->_inter->allocateVars(32); - - // Init the screen - _vm->_draw->initScreen(); - _vm->_draw->_cursorIndex = -1; + debugC(1, kDebugDemo, "Playing SCN \"%s\"", fileName); - _vm->_util->longDelay(200); // Letting everything settle + init(); Common::File scn; @@ -102,7 +91,7 @@ bool SCNPlayer::play(Common::File &scn) { } 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 @@ bool SCNPlayer::readLabels(Common::File &scn, LabelMap &labels) { 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 @@ bool SCNPlayer::readLabels(Common::File &scn, LabelMap &labels) { } 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 @@ void SCNPlayer::gotoLabel(Common::File &scn, const LabelMap &labels, const char 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 diff --git a/engines/gob/scnplayer.h b/engines/gob/scnplayer.h index 4a7ac99447..a9973e7b20 100644 --- a/engines/gob/scnplayer.h +++ b/engines/gob/scnplayer.h @@ -30,32 +30,24 @@ #include "common/str.h" #include "common/hashmap.h" -namespace Gob { +#include "demoplayer.h" -class GobEngine; +namespace Gob { -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 |