mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-18 16:03:05 +00:00
- 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
This commit is contained in:
parent
8e4b31f522
commit
c9ff1d7492
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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)) {
|
||||
|
@ -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
|
||||
|
@ -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))
|
||||
|
@ -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
|
||||
|
@ -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");
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -44,7 +44,8 @@ protected:
|
||||
static const char *_fontNames[4];
|
||||
GobEngine *_vm;
|
||||
|
||||
void cleanup(void);
|
||||
void cleanup();
|
||||
void doDemo();
|
||||
};
|
||||
|
||||
class Init_v1 : public Init {
|
||||
|
Loading…
x
Reference in New Issue
Block a user