2009-06-22 10:13:37 +00:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/util.h"
|
|
|
|
#include "common/endian.h"
|
|
|
|
|
|
|
|
#include "gob/gob.h"
|
|
|
|
#include "gob/script.h"
|
|
|
|
#include "gob/dataio.h"
|
2009-06-22 16:30:35 +00:00
|
|
|
#include "gob/expression.h"
|
2009-06-22 10:15:14 +00:00
|
|
|
#include "gob/videoplayer.h"
|
2009-06-22 10:13:37 +00:00
|
|
|
|
|
|
|
namespace Gob {
|
|
|
|
|
|
|
|
Script::Script(GobEngine *vm) : _vm(vm) {
|
2009-06-22 16:30:06 +00:00
|
|
|
_expression = new Expression(vm);
|
2009-06-22 10:13:37 +00:00
|
|
|
|
|
|
|
_finished = true;
|
|
|
|
|
|
|
|
_totData = 0;
|
|
|
|
_totPtr = 0;
|
2009-06-22 16:29:16 +00:00
|
|
|
_totSize = 0;
|
2009-06-22 10:13:37 +00:00
|
|
|
|
2010-10-31 20:07:14 +00:00
|
|
|
_lom = 0;
|
2009-06-23 23:55:19 +00:00
|
|
|
|
|
|
|
memset(&_totProperties, 0, sizeof(TOTFile::Properties));
|
2009-06-22 10:13:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Script::~Script() {
|
|
|
|
unload();
|
|
|
|
|
2009-06-22 16:30:06 +00:00
|
|
|
delete _expression;
|
2009-06-22 10:13:37 +00:00
|
|
|
}
|
|
|
|
|
2009-06-22 16:29:45 +00:00
|
|
|
uint32 Script::read(byte *data, int32 size) {
|
|
|
|
int32 toRead = MIN<int32>(size, _totSize - (_totPtr - _totData));
|
|
|
|
|
|
|
|
if (toRead < 1)
|
|
|
|
return 0;
|
2009-06-22 10:13:37 +00:00
|
|
|
|
|
|
|
memcpy(data, _totPtr, toRead);
|
|
|
|
_totPtr += toRead;
|
|
|
|
|
|
|
|
return toRead;
|
|
|
|
}
|
|
|
|
|
2009-06-22 16:29:45 +00:00
|
|
|
uint32 Script::peek(byte *data, int32 size, int32 offset) const {
|
2009-06-22 10:13:37 +00:00
|
|
|
int32 totOffset = ((_totPtr + offset) - _totData);
|
|
|
|
|
2009-06-22 16:29:45 +00:00
|
|
|
if (totOffset < 1)
|
2009-06-22 10:13:37 +00:00
|
|
|
return 0;
|
|
|
|
if (((uint32) totOffset) >= _totSize)
|
|
|
|
return 0;
|
|
|
|
|
2009-06-22 16:29:45 +00:00
|
|
|
int32 toPeek = MIN<int32>(size, _totSize - totOffset);
|
|
|
|
if (toPeek < 1)
|
|
|
|
return 0;
|
2009-06-22 10:13:37 +00:00
|
|
|
|
|
|
|
memcpy(data, _totPtr + offset, toPeek);
|
|
|
|
|
|
|
|
return toPeek;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32 Script::pos() const {
|
|
|
|
if (!_totData)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return _totPtr - _totData;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32 Script::getSize() const {
|
|
|
|
if (!_totData)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return _totSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Script::seek(int32 offset, int whence) {
|
|
|
|
if (!_totData)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (whence == SEEK_CUR)
|
|
|
|
offset += pos();
|
|
|
|
else if (whence == SEEK_END)
|
|
|
|
offset += _totSize;
|
|
|
|
|
|
|
|
if ((offset < 0) || (((uint32) offset) >= _totSize))
|
|
|
|
return false;
|
|
|
|
|
2009-06-23 01:23:31 +00:00
|
|
|
// Cannot seek into the header
|
|
|
|
if (offset < 128) {
|
|
|
|
_finished = true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-06-22 16:29:16 +00:00
|
|
|
// A successful seek means the script file continues to be executed
|
2009-06-22 10:13:37 +00:00
|
|
|
_finished = false;
|
|
|
|
|
|
|
|
_totPtr = _totData + offset;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-06-22 16:29:45 +00:00
|
|
|
bool Script::skip(int32 offset) {
|
2009-06-22 10:13:37 +00:00
|
|
|
return seek(offset, SEEK_CUR);
|
|
|
|
}
|
|
|
|
|
2009-07-05 11:27:26 +00:00
|
|
|
bool Script::skipBlock() {
|
|
|
|
return seek(peekUint16(2) + 2, SEEK_CUR);
|
|
|
|
}
|
|
|
|
|
2009-06-23 01:19:37 +00:00
|
|
|
int32 Script::getOffset(byte *ptr) const {
|
2009-06-22 10:13:37 +00:00
|
|
|
if (!_totData)
|
2009-06-22 16:29:45 +00:00
|
|
|
return -1;
|
2009-06-22 10:13:37 +00:00
|
|
|
|
2009-06-22 20:51:34 +00:00
|
|
|
if ((ptr < _totData) || (ptr >= (_totData + _totSize)))
|
|
|
|
return -1;
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
return ptr - _totData;
|
|
|
|
}
|
|
|
|
|
2009-06-23 01:19:37 +00:00
|
|
|
byte *Script::getData(int32 offset) const {
|
2009-06-22 20:51:34 +00:00
|
|
|
if (!_totData)
|
|
|
|
return 0;
|
|
|
|
if ((offset < 0) || (((uint32) offset) >= _totSize))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return _totData + offset;
|
|
|
|
}
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
byte *Script::getData() {
|
|
|
|
return _totData;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte Script::readByte() {
|
2009-12-31 00:06:28 +00:00
|
|
|
byte v = 0;
|
|
|
|
uint32 n;
|
2009-06-22 10:13:37 +00:00
|
|
|
|
2009-12-31 00:06:28 +00:00
|
|
|
n = read(&v, 1);
|
|
|
|
assert(n == 1);
|
2009-06-22 10:13:37 +00:00
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
char Script::readChar() {
|
|
|
|
return (char) readByte();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8 Script::readUint8() {
|
|
|
|
return (uint8) readByte();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16 Script::readUint16() {
|
2009-12-31 00:06:28 +00:00
|
|
|
byte v[2] = {0, 0};
|
|
|
|
uint32 n;
|
2009-06-22 10:13:37 +00:00
|
|
|
|
2009-12-31 00:06:28 +00:00
|
|
|
n = read(v, 2);
|
|
|
|
assert(n == 2);
|
2009-06-22 10:13:37 +00:00
|
|
|
|
|
|
|
return READ_LE_UINT16(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 Script::readUint32() {
|
2009-12-31 00:06:28 +00:00
|
|
|
byte v[4] = {0, 0, 0, 0};
|
|
|
|
uint32 n;
|
2009-06-22 10:13:37 +00:00
|
|
|
|
2009-12-31 00:06:28 +00:00
|
|
|
n = read(v, 4);
|
|
|
|
assert(n == 4);
|
2009-06-22 10:13:37 +00:00
|
|
|
|
|
|
|
return READ_LE_UINT32(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
int8 Script::readInt8() {
|
|
|
|
return (int8) readByte();
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 Script::readInt16() {
|
|
|
|
return (int16) readUint16();
|
|
|
|
}
|
|
|
|
|
|
|
|
int32 Script::readInt32() {
|
|
|
|
return (int32) readUint32();
|
|
|
|
}
|
|
|
|
|
|
|
|
char *Script::readString(int32 length) {
|
|
|
|
if (length < 0) {
|
|
|
|
length = 0;
|
2009-07-28 15:05:44 +00:00
|
|
|
while (_totPtr[length++] != '\0') { }
|
2009-06-22 10:13:37 +00:00
|
|
|
}
|
|
|
|
|
2010-05-17 22:46:53 +00:00
|
|
|
char *string = (char *)_totPtr;
|
2009-06-22 10:13:37 +00:00
|
|
|
|
|
|
|
_totPtr += length;
|
|
|
|
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte Script::peekByte(int32 offset) {
|
|
|
|
byte v;
|
|
|
|
|
|
|
|
peek(&v, 1, offset);
|
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
char Script::peekChar(int32 offset) {
|
|
|
|
return (char) peekByte(offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8 Script::peekUint8(int32 offset) {
|
|
|
|
return (uint8) peekByte(offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16 Script::peekUint16(int32 offset) {
|
|
|
|
byte v[2];
|
|
|
|
|
|
|
|
peek(v, 2, offset);
|
|
|
|
|
|
|
|
return READ_LE_UINT16(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 Script::peekUint32(int32 offset) {
|
|
|
|
byte v[4];
|
|
|
|
|
|
|
|
peek(v, 4, offset);
|
|
|
|
|
|
|
|
return READ_LE_UINT32(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
int8 Script::peekInt8(int32 offset) {
|
|
|
|
return (int8) peekByte(offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 Script::peekInt16(int32 offset) {
|
|
|
|
return (int16) peekUint16(offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32 Script::peekInt32(int32 offset) {
|
|
|
|
return (int32) peekUint32(offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *Script::peekString(int32 offset) {
|
2010-05-17 22:46:53 +00:00
|
|
|
return (char *)(_totPtr + offset);
|
2009-06-22 10:13:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int16 Script::readVarIndex(uint16 *size, uint16 *type) {
|
2009-06-22 16:30:06 +00:00
|
|
|
return _expression->parseVarIndex(size, type);
|
2009-06-22 10:13:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int16 Script::readValExpr(byte stopToken) {
|
2009-06-22 16:30:06 +00:00
|
|
|
return _expression->parseValExpr(stopToken);
|
2009-06-22 10:13:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int16 Script::readExpr(byte stopToken, byte *type) {
|
2009-06-22 16:30:06 +00:00
|
|
|
return _expression->parseExpr(stopToken, type);
|
2009-06-22 10:13:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Script::skipExpr(char stopToken) {
|
2009-06-22 16:30:06 +00:00
|
|
|
_expression->skipExpr(stopToken);
|
2009-06-22 10:13:37 +00:00
|
|
|
}
|
|
|
|
|
2009-06-22 10:29:32 +00:00
|
|
|
char Script::evalExpr(int16 *pRes) {
|
|
|
|
byte type;
|
|
|
|
|
2009-06-22 16:30:06 +00:00
|
|
|
_expression->printExpr(99);
|
2009-06-22 10:29:32 +00:00
|
|
|
|
2009-06-22 16:30:06 +00:00
|
|
|
_expression->parseExpr(99, &type);
|
2009-06-22 10:29:32 +00:00
|
|
|
if (!pRes)
|
|
|
|
return type;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case TYPE_IMM_INT16:
|
2009-06-22 16:30:06 +00:00
|
|
|
*pRes = _expression->getResultInt();
|
2009-06-22 10:29:32 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TYPE_IMM_STR:
|
|
|
|
case GOB_FALSE:
|
|
|
|
*pRes = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GOB_TRUE:
|
|
|
|
*pRes = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:47:14 +00:00
|
|
|
bool Script::evalBool() {
|
2009-06-22 10:29:32 +00:00
|
|
|
byte type;
|
|
|
|
|
2009-06-22 16:30:06 +00:00
|
|
|
_expression->printExpr(99);
|
2009-06-22 10:29:32 +00:00
|
|
|
|
2009-06-22 16:30:06 +00:00
|
|
|
_expression->parseExpr(99, &type);
|
2009-06-22 10:29:32 +00:00
|
|
|
if ( (type == GOB_TRUE) ||
|
2009-06-22 16:30:06 +00:00
|
|
|
((type == TYPE_IMM_INT16) && _expression->getResultInt()))
|
2009-06-22 10:29:32 +00:00
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:47:53 +00:00
|
|
|
int32 Script::evalInt() {
|
|
|
|
evalExpr(0);
|
|
|
|
return getResultInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *Script::evalString() {
|
|
|
|
evalExpr(0);
|
|
|
|
return getResultStr();
|
|
|
|
}
|
|
|
|
|
2009-06-23 01:19:37 +00:00
|
|
|
int32 Script::getResultInt() const {
|
2009-06-22 16:30:06 +00:00
|
|
|
return _expression->getResultInt();
|
2009-06-22 10:13:37 +00:00
|
|
|
}
|
|
|
|
|
2009-06-23 01:19:37 +00:00
|
|
|
char *Script::getResultStr() const {
|
2009-06-22 16:30:06 +00:00
|
|
|
return _expression->getResultStr();
|
2009-06-22 10:13:37 +00:00
|
|
|
}
|
|
|
|
|
2009-06-23 23:55:35 +00:00
|
|
|
bool Script::load(const Common::String &fileName) {
|
2009-06-22 10:13:37 +00:00
|
|
|
unload();
|
|
|
|
|
|
|
|
_finished = false;
|
|
|
|
|
2009-06-23 23:55:35 +00:00
|
|
|
bool isLOM;
|
2009-06-22 10:13:37 +00:00
|
|
|
|
2009-06-23 23:55:35 +00:00
|
|
|
_totFile = TOTFile::createFileName(fileName, isLOM);
|
2009-06-22 10:13:37 +00:00
|
|
|
|
2009-06-23 23:55:35 +00:00
|
|
|
if (isLOM) {
|
2009-06-22 10:15:14 +00:00
|
|
|
if (!loadLOM(_totFile)) {
|
|
|
|
unload();
|
|
|
|
return false;
|
2009-06-22 10:13:37 +00:00
|
|
|
}
|
2009-06-22 10:15:14 +00:00
|
|
|
} else {
|
|
|
|
if (!loadTOT(_totFile)) {
|
|
|
|
unload();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2009-06-22 10:13:37 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Script::loadTOT(const Common::String &fileName) {
|
2009-06-23 23:55:19 +00:00
|
|
|
TOTFile totFile(_vm);
|
2009-06-22 16:29:16 +00:00
|
|
|
|
2009-06-23 23:55:19 +00:00
|
|
|
if (!totFile.load(fileName))
|
|
|
|
return false;
|
2009-06-22 10:15:14 +00:00
|
|
|
|
2009-06-23 23:55:19 +00:00
|
|
|
Common::SeekableReadStream *stream = totFile.getStream();
|
|
|
|
if (!stream)
|
|
|
|
return false;
|
2009-06-22 10:15:14 +00:00
|
|
|
|
2009-06-24 21:49:37 +00:00
|
|
|
if (!totFile.getProperties(_totProperties))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
_totSize = _totProperties.scriptEnd;
|
2009-06-23 23:55:19 +00:00
|
|
|
if (_totSize <= 0)
|
|
|
|
return false;
|
2009-06-22 10:15:14 +00:00
|
|
|
|
2009-06-23 23:55:19 +00:00
|
|
|
_totData = new byte[_totSize];
|
|
|
|
if (stream->read(_totData, _totSize) != _totSize)
|
|
|
|
return false;
|
2009-06-22 10:13:37 +00:00
|
|
|
|
2009-06-23 23:55:19 +00:00
|
|
|
return true;
|
2009-06-22 10:13:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Script::loadLOM(const Common::String &fileName) {
|
2009-06-24 21:47:54 +00:00
|
|
|
warning("Stub: Script::loadLOM(%s)", _totFile.c_str());
|
2009-06-22 10:13:37 +00:00
|
|
|
|
2010-10-31 20:07:14 +00:00
|
|
|
_lom = _vm->_dataIO->getFile(_totFile);
|
|
|
|
if (!_lom)
|
2009-06-22 10:15:14 +00:00
|
|
|
return false;
|
2009-06-22 10:13:37 +00:00
|
|
|
|
2010-10-31 20:07:14 +00:00
|
|
|
_lom->seek(48);
|
|
|
|
_totSize = _lom->readUint32LE();
|
|
|
|
_lom->seek(0);
|
2009-06-22 10:13:37 +00:00
|
|
|
|
|
|
|
_totData = new byte[_totSize];
|
2010-10-31 20:07:14 +00:00
|
|
|
_lom->read(_totData, _totSize);
|
2009-06-22 10:13:37 +00:00
|
|
|
|
2009-06-23 23:55:19 +00:00
|
|
|
return false;
|
2009-06-23 01:19:03 +00:00
|
|
|
}
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
void Script::unload() {
|
|
|
|
unloadTOT();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::unloadTOT() {
|
2010-10-31 20:07:14 +00:00
|
|
|
delete _lom;
|
|
|
|
_lom = 0;
|
2009-06-22 10:13:37 +00:00
|
|
|
|
2009-06-22 16:29:16 +00:00
|
|
|
// Unwind the call stack
|
2009-06-22 10:16:45 +00:00
|
|
|
while (!_callStack.empty())
|
|
|
|
pop();
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
delete[] _totData;
|
|
|
|
|
|
|
|
_totData = 0;
|
|
|
|
_totSize = 0;
|
|
|
|
_totPtr = 0;
|
|
|
|
_totFile.clear();
|
|
|
|
|
|
|
|
_finished = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Script::isLoaded() const {
|
|
|
|
return _totData != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::setFinished(bool finished) {
|
|
|
|
_finished = finished;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Script::isFinished() const {
|
|
|
|
return _finished;
|
|
|
|
}
|
|
|
|
|
2009-06-22 10:14:18 +00:00
|
|
|
void Script::push() {
|
2009-06-22 16:29:31 +00:00
|
|
|
if (!isLoaded())
|
|
|
|
// Nothing to do
|
|
|
|
return;
|
|
|
|
|
2009-06-22 10:14:18 +00:00
|
|
|
CallEntry currentCall;
|
|
|
|
|
|
|
|
currentCall.totPtr = _totPtr;
|
|
|
|
currentCall.finished = _finished;
|
|
|
|
|
|
|
|
_callStack.push(currentCall);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::pop(bool ret) {
|
2009-06-22 16:29:31 +00:00
|
|
|
if (!isLoaded())
|
|
|
|
// Nothing to do
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Unmatched pop?
|
2009-06-22 10:14:18 +00:00
|
|
|
assert(!_callStack.empty());
|
|
|
|
|
|
|
|
CallEntry lastCall = _callStack.pop();
|
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
_totPtr = lastCall.totPtr;
|
|
|
|
_finished = lastCall.finished;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Script::call(uint32 offset) {
|
2009-06-22 16:29:31 +00:00
|
|
|
if (!isLoaded())
|
|
|
|
// Nothing to do
|
|
|
|
return;
|
|
|
|
|
2009-06-22 10:14:18 +00:00
|
|
|
push();
|
|
|
|
seek(offset);
|
|
|
|
}
|
|
|
|
|
2009-06-23 01:19:03 +00:00
|
|
|
uint8 Script::getVersionMajor() const {
|
2009-06-23 23:55:19 +00:00
|
|
|
return _totProperties.versionMajor;
|
2009-06-23 01:19:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8 Script::getVersionMinor() const {
|
2009-06-23 23:55:19 +00:00
|
|
|
return _totProperties.versionMinor;
|
2009-06-23 01:19:03 +00:00
|
|
|
}
|
|
|
|
|
2009-06-23 01:20:05 +00:00
|
|
|
uint32 Script::getVariablesCount() const {
|
2009-06-23 23:55:19 +00:00
|
|
|
return _totProperties.variablesCount;
|
2009-06-23 01:20:05 +00:00
|
|
|
}
|
|
|
|
|
2009-06-23 01:20:21 +00:00
|
|
|
uint32 Script::getTextsOffset() const {
|
2009-06-23 23:55:19 +00:00
|
|
|
return _totProperties.textsOffset;
|
2009-06-23 01:20:21 +00:00
|
|
|
}
|
|
|
|
|
2009-06-23 01:21:06 +00:00
|
|
|
uint32 Script::getResourcesOffset() const {
|
2009-06-23 23:55:19 +00:00
|
|
|
return _totProperties.resourcesOffset;
|
2009-06-23 01:21:06 +00:00
|
|
|
}
|
|
|
|
|
2009-06-23 01:21:51 +00:00
|
|
|
uint16 Script::getAnimDataSize() const {
|
2009-06-23 23:55:19 +00:00
|
|
|
return _totProperties.animDataSize;
|
2009-06-23 01:21:51 +00:00
|
|
|
}
|
|
|
|
|
2009-06-23 01:19:21 +00:00
|
|
|
uint8 Script::getImFileNumber() const {
|
2009-06-23 23:55:19 +00:00
|
|
|
return _totProperties.imFileNumber;
|
2009-06-23 01:19:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8 Script::getExFileNumber() const {
|
2009-06-23 23:55:19 +00:00
|
|
|
return _totProperties.exFileNumber;
|
2009-06-23 01:19:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8 Script::getCommunHandling() const {
|
2009-06-23 23:55:19 +00:00
|
|
|
return _totProperties.communHandling;
|
2009-06-23 01:19:21 +00:00
|
|
|
}
|
|
|
|
|
2009-06-23 01:23:14 +00:00
|
|
|
uint16 Script::getFunctionOffset(uint8 function) const {
|
|
|
|
if (!_totData)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// Offsets 100-128, 2 bytes per function
|
|
|
|
assert(function <= 13);
|
2009-06-23 01:22:30 +00:00
|
|
|
|
2009-06-23 23:55:19 +00:00
|
|
|
return _totProperties.functions[function];
|
2009-06-23 01:22:51 +00:00
|
|
|
}
|
|
|
|
|
2009-06-23 01:20:05 +00:00
|
|
|
uint32 Script::getVariablesCount(const char *fileName, GobEngine *vm) {
|
2010-10-31 20:07:14 +00:00
|
|
|
Common::SeekableReadStream *stream = vm->_dataIO->getFile(fileName);
|
2009-06-24 21:48:13 +00:00
|
|
|
if (!stream)
|
|
|
|
return 0;
|
2009-06-23 01:20:05 +00:00
|
|
|
|
|
|
|
stream->seek(0x2C);
|
|
|
|
uint32 variablesCount = stream->readUint32LE();
|
|
|
|
delete stream;
|
|
|
|
|
|
|
|
return variablesCount;
|
|
|
|
}
|
|
|
|
|
2009-06-22 10:13:37 +00:00
|
|
|
} // End of namespace Gob
|