[Scummvm-cvs-logs] SF.net SVN: scummvm:[41753] scummvm/trunk/engines/gob
drmccoy at users.sourceforge.net
drmccoy at users.sourceforge.net
Mon Jun 22 12:13:37 CEST 2009
Revision: 41753
http://scummvm.svn.sourceforge.net/scummvm/?rev=41753&view=rev
Author: drmccoy
Date: 2009-06-22 10:13:37 +0000 (Mon, 22 Jun 2009)
Log Message:
-----------
Encapsulating script file access
Modified Paths:
--------------
scummvm/trunk/engines/gob/draw.cpp
scummvm/trunk/engines/gob/draw_v2.cpp
scummvm/trunk/engines/gob/game.cpp
scummvm/trunk/engines/gob/game.h
scummvm/trunk/engines/gob/game_fascin.cpp
scummvm/trunk/engines/gob/game_v1.cpp
scummvm/trunk/engines/gob/game_v2.cpp
scummvm/trunk/engines/gob/game_v6.cpp
scummvm/trunk/engines/gob/init.cpp
scummvm/trunk/engines/gob/inter.cpp
scummvm/trunk/engines/gob/inter.h
scummvm/trunk/engines/gob/inter_fascin.cpp
scummvm/trunk/engines/gob/inter_v1.cpp
scummvm/trunk/engines/gob/inter_v2.cpp
scummvm/trunk/engines/gob/inter_v3.cpp
scummvm/trunk/engines/gob/inter_v4.cpp
scummvm/trunk/engines/gob/inter_v5.cpp
scummvm/trunk/engines/gob/inter_v6.cpp
scummvm/trunk/engines/gob/map_v2.cpp
scummvm/trunk/engines/gob/map_v4.cpp
scummvm/trunk/engines/gob/module.mk
scummvm/trunk/engines/gob/mult.cpp
scummvm/trunk/engines/gob/mult_v1.cpp
scummvm/trunk/engines/gob/mult_v2.cpp
scummvm/trunk/engines/gob/parse.cpp
scummvm/trunk/engines/gob/scenery.cpp
Added Paths:
-----------
scummvm/trunk/engines/gob/script.cpp
scummvm/trunk/engines/gob/script.h
Modified: scummvm/trunk/engines/gob/draw.cpp
===================================================================
--- scummvm/trunk/engines/gob/draw.cpp 2009-06-22 10:12:33 UTC (rev 41752)
+++ scummvm/trunk/engines/gob/draw.cpp 2009-06-22 10:13:37 UTC (rev 41753)
@@ -30,6 +30,7 @@
#include "gob/global.h"
#include "gob/util.h"
#include "gob/game.h"
+#include "gob/script.h"
#include "gob/inter.h"
#include "gob/video.h"
#include "gob/palanim.h"
@@ -389,11 +390,10 @@
adjustCoords(1, &left, &top);
adjustCoords(1, &right, &bottom);
- if (READ_LE_UINT16(_vm->_game->_totFileData + 0x7E) != 0) {
- byte *storedIP = _vm->_global->_inter_execPtr;
+ if (READ_LE_UINT16(_vm->_game->_script->getData() + 0x7E) != 0) {
+ uint32 startPos = _vm->_game->_script->pos();
- _vm->_global->_inter_execPtr = _vm->_game->_totFileData +
- READ_LE_UINT16(_vm->_game->_totFileData + 0x7E);
+ _vm->_game->_script->seek(READ_LE_UINT16(_vm->_game->_script->getData() + 0x7E));
WRITE_VAR(17, (uint32) id);
WRITE_VAR(18, (uint32) left);
WRITE_VAR(19, (uint32) top);
@@ -401,7 +401,7 @@
WRITE_VAR(21, (uint32) (bottom - top + 1));
_vm->_inter->funcBlock(0);
- _vm->_global->_inter_execPtr = storedIP;
+ _vm->_game->_script->seek(startPos);
}
if (str[0] == '\0')
Modified: scummvm/trunk/engines/gob/draw_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/draw_v2.cpp 2009-06-22 10:12:33 UTC (rev 41752)
+++ scummvm/trunk/engines/gob/draw_v2.cpp 2009-06-22 10:13:37 UTC (rev 41753)
@@ -32,6 +32,7 @@
#include "gob/global.h"
#include "gob/util.h"
#include "gob/game.h"
+#include "gob/script.h"
#include "gob/scenery.h"
#include "gob/inter.h"
#include "gob/video.h"
@@ -328,7 +329,7 @@
ptrEnd = ptr;
while (((ptrEnd - dataPtr) < size) && (*ptrEnd != 1)) {
// Converting to unknown commands/characters to spaces
- if ((_vm->_game->_totFileData[0x29] < 0x32) && (*ptrEnd > 3) && (*ptrEnd < 32))
+ if ((_vm->_game->_script->getData()[0x29] < 0x32) && (*ptrEnd > 3) && (*ptrEnd < 32))
*ptrEnd = 32;
switch (*ptrEnd) {
Modified: scummvm/trunk/engines/gob/game.cpp
===================================================================
--- scummvm/trunk/engines/gob/game.cpp 2009-06-22 10:12:33 UTC (rev 41752)
+++ scummvm/trunk/engines/gob/game.cpp 2009-06-22 10:13:37 UTC (rev 41753)
@@ -31,8 +31,8 @@
#include "gob/global.h"
#include "gob/util.h"
#include "gob/dataio.h"
+#include "gob/script.h"
#include "gob/inter.h"
-#include "gob/parse.h"
#include "gob/draw.h"
#include "gob/mult.h"
#include "gob/videoplayer.h"
@@ -42,7 +42,6 @@
Game::Game(GobEngine *vm) : _vm(vm) {
_extTable = 0;
- _totFileData = 0;
_totResourceTable = 0;
_imFileData = 0;
_extHandle = 0;
@@ -95,7 +94,6 @@
_cursorHotspotXArray[i] = 0;
_cursorHotspotYArray[i] = 0;
_totTextDataArray[i] = 0;
- _totFileDataArray[i] = 0;
_totResourceTableArray[i] = 0;
_extTableArray[i] = 0;
_extHandleArray[i] = 0;
@@ -103,19 +101,22 @@
_variablesArray[i] = 0;
_curTotFileArray[i][0] = 0;
}
+
+ _script = new Script(_vm);
}
Game::~Game() {
- delete[] _vm->_game->_totFileData;
- if (_vm->_game->_totTextData) {
- if (_vm->_game->_totTextData->items)
- delete[] _vm->_game->_totTextData->items;
- delete _vm->_game->_totTextData;
+ if (_totTextData) {
+ if (_totTextData->items)
+ delete[] _totTextData->items;
+ delete _totTextData;
}
- if (_vm->_game->_totResourceTable) {
- delete[] _vm->_game->_totResourceTable->items;
- delete _vm->_game->_totResourceTable;
+ if (_totResourceTable) {
+ delete[] _totResourceTable->items;
+ delete _totResourceTable;
}
+
+ delete _script;
}
byte *Game::loadExtData(int16 itemId, int16 *pResWidth,
@@ -175,7 +176,7 @@
tableSize = 0;
_vm->_dataIO->closeData(_extHandle);
strcpy(path, "commun.ex1");
- path[strlen(path) - 1] = *(_totFileData + 0x3C) + '0';
+ path[strlen(path) - 1] = *(_script->getData() + 0x3C) + '0';
commonHandle = _vm->_dataIO->openData(path);
handle = commonHandle;
} else
@@ -287,7 +288,7 @@
TotResItem *itemPtr;
int32 offset;
- if (id >= _vm->_game->_totResourceTable->itemsCount) {
+ if (id >= _totResourceTable->itemsCount) {
warning("Trying to load non-existent TOT resource (%s, %d/%d)",
_curTotFile, id, _totResourceTable->itemsCount - 1);
return 0;
@@ -313,7 +314,7 @@
void Game::freeSoundSlot(int16 slot) {
if (slot == -1)
- slot = _vm->_parse->parseValExpr();
+ slot = _script->readValExpr();
_vm->_sound->sampleFree(_vm->_sound->sampleGetBySlot(slot));
}
@@ -416,50 +417,6 @@
return key - 0x20;
}
-int32 Game::loadTotFile(const char *path) {
- int32 size;
-
- _lomHandle = -1;
-
- size = -1;
- if (_vm->_dataIO->existData(path)) {
- if (!scumm_stricmp(path + strlen(path) - 3, "LOM")) {
- warning("Urban Stub: loadTotFile %s", path);
-
- _lomHandle = _vm->_dataIO->openData(path);
-
- DataStream *stream = _vm->_dataIO->openAsStream(_lomHandle);
-
- stream->seek(48);
- size = stream->readUint32LE();
- stream->seek(0);
-
- _totFileData = new byte[size];
- stream->read(_totFileData, size);
-
- delete stream;
- } else {
- size = _vm->_dataIO->getDataSize(path);
- _totFileData = _vm->_dataIO->getData(path);
- }
-
- } else {
- Common::MemoryReadStream *videoExtraData = _vm->_vidPlayer->getExtraData(path);
-
- if (videoExtraData) {
- warning("Found \"%s\" in video file", path);
-
- size = videoExtraData->size();
- _totFileData = new byte[size];
- videoExtraData->read(_totFileData, size);
- delete videoExtraData;
- } else
- _totFileData = 0;
- }
-
- return size;
-}
-
void Game::loadExtTable(void) {
int16 count;
@@ -494,12 +451,12 @@
void Game::loadImFile(void) {
char path[20];
- if ((_totFileData[0x3D] != 0) && (_totFileData[0x3B] == 0))
+ if ((_script->getData()[0x3D] != 0) && (_script->getData()[0x3B] == 0))
return;
strcpy(path, "commun.im1");
- if (_totFileData[0x3B] != 0)
- path[strlen(path) - 1] = '0' + _totFileData[0x3B];
+ if (_script->getData()[0x3B] != 0)
+ path[strlen(path) - 1] = '0' + _script->getData()[0x3B];
if (!_vm->_dataIO->existData(path))
return;
@@ -524,6 +481,8 @@
// flagbits: 0 = freeInterVariables, 1 = skipPlay
void Game::totSub(int8 flags, const char *newTotFile) {
+ warning("totSub");
+
int8 curBackupPos;
if (_backupedCount >= 5)
@@ -531,8 +490,8 @@
_cursorHotspotXArray[_backupedCount] = _vm->_draw->_cursorHotspotXVar;
_cursorHotspotYArray[_backupedCount] = _vm->_draw->_cursorHotspotYVar;
+ _scriptArray[_backupedCount] = _script;
_totTextDataArray[_backupedCount] = _totTextData;
- _totFileDataArray[_backupedCount] = _totFileData;
_totResourceTableArray[_backupedCount] = _totResourceTable;
_extTableArray[_backupedCount] = _extTable;
_extHandleArray[_backupedCount] = _extHandle;
@@ -545,7 +504,7 @@
_curBackupPos = _backupedCount;
_totTextData = 0;
- _totFileData = 0;
+ _script = new Script(_vm);
_totResourceTable = 0;
if (flags & 1)
_vm->_inter->_variables = 0;
@@ -581,7 +540,7 @@
_vm->_draw->_cursorHotspotXVar = _cursorHotspotXArray[_backupedCount];
_vm->_draw->_cursorHotspotYVar = _cursorHotspotYArray[_backupedCount];
_totTextData = _totTextDataArray[_backupedCount];
- _totFileData = _totFileDataArray[_backupedCount];
+ _script = _scriptArray[_backupedCount];
_totResourceTable = _totResourceTableArray[_backupedCount];
_extTable = _extTableArray[_backupedCount];
_extHandle = _extHandleArray[_backupedCount];
@@ -594,6 +553,8 @@
}
void Game::switchTotSub(int16 index, int16 skipPlay) {
+ warning("switchTotSub");
+
int16 backupedCount;
int16 curBackupPos;
@@ -613,7 +574,7 @@
_cursorHotspotXArray[_backupedCount] = _vm->_draw->_cursorHotspotXVar;
_cursorHotspotYArray[_backupedCount] = _vm->_draw->_cursorHotspotYVar;
_totTextDataArray[_backupedCount] = _totTextData;
- _totFileDataArray[_backupedCount] = _totFileData;
+ _scriptArray[_backupedCount] = _script;
_totResourceTableArray[_backupedCount] = _totResourceTable;
_extTableArray[_backupedCount] = _extTable;
_extHandleArray[_backupedCount] = _extHandle;
@@ -629,7 +590,7 @@
_vm->_draw->_cursorHotspotXVar = _cursorHotspotXArray[_curBackupPos];
_vm->_draw->_cursorHotspotYVar = _cursorHotspotYArray[_curBackupPos];
_totTextData = _totTextDataArray[_curBackupPos];
- _totFileData = _totFileDataArray[_curBackupPos];
+ _script = _scriptArray[_curBackupPos];
_totResourceTable = _totResourceTableArray[_curBackupPos];
_imFileData = _imFileDataArray[_curBackupPos];
_extTable = _extTableArray[_curBackupPos];
@@ -643,20 +604,20 @@
if (_vm->_inter->_terminate != 0)
return;
- _vm->_game->pushCollisions(0);
- _vm->_game->playTot(skipPlay);
+ pushCollisions(0);
+ playTot(skipPlay);
if (_vm->_inter->_terminate != 2)
_vm->_inter->_terminate = 0;
- _vm->_game->popCollisions();
+ popCollisions();
_curBackupPos = curBackupPos;
_backupedCount = backupedCount;
_vm->_draw->_cursorHotspotXVar = _cursorHotspotXArray[_curBackupPos];
_vm->_draw->_cursorHotspotYVar = _cursorHotspotYArray[_curBackupPos];
_totTextData = _totTextDataArray[_curBackupPos];
- _totFileData = _totFileDataArray[_curBackupPos];
+ _script = _scriptArray[_curBackupPos];
_totResourceTable = _totResourceTableArray[_curBackupPos];
_extTable = _extTableArray[_curBackupPos];
_extHandle = _extHandleArray[_curBackupPos];
@@ -761,7 +722,6 @@
}
void Game::setCollisions(byte arg_0) {
- byte *savedIP;
uint16 left;
uint16 top;
uint16 width;
@@ -772,12 +732,14 @@
if (((collArea->id & 0xC000) != 0x8000) || (collArea->funcSub == 0))
continue;
- savedIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr = _totFileData + collArea->funcSub;
- left = _vm->_parse->parseValExpr();
- top = _vm->_parse->parseValExpr();
- width = _vm->_parse->parseValExpr();
- height = _vm->_parse->parseValExpr();
+ uint32 startPos = _script->pos();
+
+ _script->seek(collArea->funcSub);
+
+ left = _script->readValExpr();
+ top = _script->readValExpr();
+ width = _script->readValExpr();
+ height = _script->readValExpr();
if ((_vm->_draw->_renderFlags & RENDERFLAG_CAPTUREPOP) &&
(left != 0xFFFF)) {
left += _vm->_draw->_backDeltaX;
@@ -796,17 +758,18 @@
collArea->top = top;
collArea->right = left + width - 1;
collArea->bottom = top + height - 1;
- _vm->_global->_inter_execPtr = savedIP;
+
+ _script->seek(startPos);
}
}
void Game::collSub(uint16 offset) {
- byte *savedIP;
int16 collStackSize;
- savedIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr = _totFileData + offset;
+ uint32 startPos = _script->pos();
+ _script->seek(offset);
+
_shouldPushColls = 1;
collStackSize = _collStackSize;
@@ -816,7 +779,8 @@
popCollisions();
_shouldPushColls = 0;
- _vm->_global->_inter_execPtr = savedIP;
+
+ _script->seek(startPos);
setCollisions();
}
Modified: scummvm/trunk/engines/gob/game.h
===================================================================
--- scummvm/trunk/engines/gob/game.h 2009-06-22 10:12:33 UTC (rev 41752)
+++ scummvm/trunk/engines/gob/game.h 2009-06-22 10:13:37 UTC (rev 41753)
@@ -30,6 +30,8 @@
namespace Gob {
+class Script;
+
class Game {
public:
@@ -47,6 +49,7 @@
uint16 funcLeave;
uint16 funcSub;
byte *totFileData;
+ uint32 totSize;
} PACKED_STRUCT;
#define szGame_TotTextItem (2 + 2)
@@ -77,11 +80,12 @@
bool _foundTotLoc;
TotTextTable *_totTextData;
+ Script *_script;
+
char _curTotFile[14];
char _curExtFile[14];
byte *_imFileData;
- byte *_totFileData;
int16 _extHandle;
int16 _lomHandle;
@@ -211,20 +215,19 @@
int16 _cursorHotspotXArray[5];
int16 _cursorHotspotYArray[5];
TotTextTable *_totTextDataArray[5];
- byte *_totFileDataArray[5];
TotResTable *_totResourceTableArray[5];
ExtTable *_extTableArray[5];
int16 _extHandleArray[5];
byte *_imFileDataArray[5];
Variables *_variablesArray[5];
char _curTotFileArray[5][14];
+ Script *_scriptArray[5];
GobEngine *_vm;
virtual int16 adjustKey(int16 key);
byte *loadLocTexts(int32 *dataSize = 0);
- int32 loadTotFile(const char *path);
void loadExtTable(void);
void loadImFile(void);
Modified: scummvm/trunk/engines/gob/game_fascin.cpp
===================================================================
--- scummvm/trunk/engines/gob/game_fascin.cpp 2009-06-22 10:12:33 UTC (rev 41752)
+++ scummvm/trunk/engines/gob/game_fascin.cpp 2009-06-22 10:13:37 UTC (rev 41753)
@@ -35,7 +35,6 @@
#include "gob/goblin.h"
#include "gob/inter.h"
#include "gob/mult.h"
-#include "gob/parse.h"
#include "gob/scenery.h"
#include "gob/video.h"
#include "gob/videoplayer.h"
Modified: scummvm/trunk/engines/gob/game_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/game_v1.cpp 2009-06-22 10:12:33 UTC (rev 41752)
+++ scummvm/trunk/engines/gob/game_v1.cpp 2009-06-22 10:13:37 UTC (rev 41753)
@@ -32,11 +32,11 @@
#include "gob/global.h"
#include "gob/util.h"
#include "gob/dataio.h"
+#include "gob/script.h"
#include "gob/draw.h"
#include "gob/inter.h"
#include "gob/mult.h"
#include "gob/video.h"
-#include "gob/parse.h"
#include "gob/scenery.h"
#include "gob/sound/sound.h"
@@ -54,8 +54,9 @@
int16 *oldNestLevel = _vm->_inter->_nestLevel;
int16 *oldBreakFrom = _vm->_inter->_breakFromLevel;
int16 *oldCaptureCounter = _vm->_scenery->_pCaptureCounter;
- byte *savedIP = _vm->_global->_inter_execPtr;
+ uint32 startPos = _script->pos();
+
_vm->_inter->_nestLevel = &nestLevel;
_vm->_inter->_breakFromLevel = &breakFrom;
_vm->_scenery->_pCaptureCounter = &_captureCounter;
@@ -101,11 +102,10 @@
_totToLoad[0] = 0;
- if ((_curTotFile[0] == 0) && (_totFileData == 0))
+ if ((_curTotFile[0] == 0) && !_script->isLoaded())
break;
- loadTotFile(_curTotFile);
- if (_totFileData == 0) {
+ if (!_script->load(_curTotFile)) {
_vm->_draw->blitCursor();
break;
}
@@ -122,13 +122,13 @@
debugC(4, kDebugFileIO, "IMA: %s", _curImaFile);
debugC(4, kDebugFileIO, "EXT: %s", _curExtFile);
- byte *filePtr = _totFileData + 0x30;
+ byte *filePtr = _script->getData() + 0x30;
_totTextData = 0;
if (READ_LE_UINT32(filePtr) != (uint32) -1) {
_totTextData = new TotTextTable;
_totTextData->dataPtr =
- (_totFileData + READ_LE_UINT32(_totFileData + 0x30));
+ (_script->getData() + READ_LE_UINT32(_script->getData() + 0x30));
Common::MemoryReadStream totTextData(_totTextData->dataPtr,
4294967295U);
@@ -141,12 +141,12 @@
}
}
- filePtr = _totFileData + 0x34;
+ filePtr = _script->getData() + 0x34;
_totResourceTable = 0;
if (READ_LE_UINT32(filePtr) != (uint32) -1) {
_totResourceTable = new TotResTable;
_totResourceTable->dataPtr =
- _totFileData + READ_LE_UINT32( _totFileData + 0x34);
+ _script->getData() + READ_LE_UINT32(_script->getData() + 0x34);
Common::MemoryReadStream totResTable(_totResourceTable->dataPtr,
4294967295U);
@@ -167,12 +167,11 @@
loadExtTable();
_vm->_global->_inter_animDataSize =
- READ_LE_UINT16(_totFileData + 0x38);
+ READ_LE_UINT16(_script->getData() + 0x38);
if (!_vm->_inter->_variables)
- _vm->_inter->allocateVars(READ_LE_UINT16(_totFileData + 0x2C));
+ _vm->_inter->allocateVars(READ_LE_UINT16(_script->getData() + 0x2C));
- _vm->_global->_inter_execPtr = _totFileData;
- _vm->_global->_inter_execPtr += READ_LE_UINT32(_totFileData + 0x64);
+ _script->seek(READ_LE_UINT32(_script->getData() + 0x64));
_vm->_inter->renewTimeInVars();
@@ -182,15 +181,16 @@
WRITE_VAR(16, _vm->_global->_language);
_vm->_inter->callSub(2);
+ _script->setFinished(false);
if (_totToLoad[0] != 0)
_vm->_inter->_terminate = 0;
- variablesCount = READ_LE_UINT32(_totFileData + 0x2C);
+ variablesCount = READ_LE_UINT32(_script->getData() + 0x2C);
_vm->_draw->blitInvalidated();
- delete[] _totFileData;
- _totFileData = 0;
+ _script->unload();
+
if (_totTextData) {
delete[] _totTextData->items;
delete _totTextData;
@@ -241,7 +241,8 @@
_vm->_inter->_nestLevel = oldNestLevel;
_vm->_inter->_breakFromLevel = oldBreakFrom;
_vm->_scenery->_pCaptureCounter = oldCaptureCounter;
- _vm->_global->_inter_execPtr = savedIP;
+
+ _script->seek(startPos);
}
void Game_v1::clearCollisions() {
@@ -280,6 +281,7 @@
ptr->funcLeave = funcLeave;
ptr->funcSub = funcSub;
ptr->totFileData = 0;
+ ptr->totSize = 0;
return i;
}
@@ -331,7 +333,6 @@
int16 Game_v1::checkCollisions(byte handleMouse, int16 deltaTime,
int16 *pResId, int16 *pResIndex) {
- byte *savedIP;
int16 resIndex;
int16 key;
int16 oldIndex;
@@ -357,12 +358,13 @@
_lastCollKey = checkMousePoint(1, &_lastCollId, &_lastCollAreaIndex);
if ((_lastCollKey != 0) && ((_lastCollId & 0x8000) != 0)) {
- savedIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr = _totFileData +
- _collisionAreas[_lastCollAreaIndex].funcEnter;
+ uint32 startPos = _script->pos();
+ _script->seek(_collisionAreas[_lastCollAreaIndex].funcEnter);
+
_vm->_inter->funcBlock(0);
- _vm->_global->_inter_execPtr = savedIP;
+
+ _script->seek(startPos);
}
}
@@ -423,12 +425,14 @@
if ((_lastCollKey != 0) &&
(_collisionAreas[_lastCollAreaIndex].funcLeave != 0)) {
- savedIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr = _totFileData +
- _collisionAreas[_lastCollAreaIndex].funcLeave;
+ uint32 startPos = _script->pos();
+
+ _script->seek(_collisionAreas[_lastCollAreaIndex].funcLeave);
+
_vm->_inter->funcBlock(0);
- _vm->_global->_inter_execPtr = savedIP;
+
+ _script->seek(startPos);
}
_lastCollKey = 0;
@@ -463,12 +467,13 @@
if ((_lastCollKey != 0) &&
(_collisionAreas[_lastCollAreaIndex].funcLeave != 0)) {
- savedIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr = _totFileData +
- _collisionAreas[_lastCollAreaIndex].funcLeave;
+ uint32 startPos = _script->pos();
+ _script->seek(_collisionAreas[_lastCollAreaIndex].funcLeave);
+
_vm->_inter->funcBlock(0);
- _vm->_global->_inter_execPtr = savedIP;
+
+ _script->seek(startPos);
}
_lastCollKey = 0;
return key;
@@ -476,24 +481,26 @@
if ((_lastCollKey != 0) &&
(_collisionAreas[_lastCollAreaIndex].funcLeave != 0)) {
- savedIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr = _totFileData +
- _collisionAreas[_lastCollAreaIndex].funcLeave;
+ uint32 startPos = _script->pos();
+ _script->seek(_collisionAreas[_lastCollAreaIndex].funcLeave);
+
_vm->_inter->funcBlock(0);
- _vm->_global->_inter_execPtr = savedIP;
+
+ _script->seek(startPos);
}
_lastCollKey =
checkMousePoint(1, &_lastCollId, &_lastCollAreaIndex);
if ((_lastCollKey != 0) && ((_lastCollId & 0x8000) != 0)) {
- savedIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr = _totFileData +
- _collisionAreas[_lastCollAreaIndex].funcEnter;
+ uint32 startPos = _script->pos();
+ _script->seek(_collisionAreas[_lastCollAreaIndex].funcEnter);
+
_vm->_inter->funcBlock(0);
- _vm->_global->_inter_execPtr = savedIP;
+
+ _script->seek(startPos);
}
} else {
@@ -507,23 +514,26 @@
if (key != _lastCollKey) {
if ((_lastCollKey != 0) && ((oldId & 0x8000) != 0)) {
- savedIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr = _totFileData +
- _collisionAreas[oldIndex].funcLeave;
+ uint32 startPos = _script->pos();
+ _script->seek(_collisionAreas[oldIndex].funcLeave);
+
_vm->_inter->funcBlock(0);
- _vm->_global->_inter_execPtr = savedIP;
+
+ _script->seek(startPos);
}
_lastCollKey = key;
if ((_lastCollKey != 0) && ((_lastCollId & 0x8000) != 0)) {
- savedIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr = _totFileData +
- _collisionAreas[_lastCollAreaIndex].funcEnter;
+ uint32 startPos = _script->pos();
+ _script->seek(_collisionAreas[_lastCollAreaIndex].funcEnter);
+
_vm->_inter->funcBlock(0);
- _vm->_global->_inter_execPtr = savedIP;
+
+ _script->seek(startPos);
}
+
}
}
}
@@ -588,7 +598,6 @@
int16 array[250];
byte count;
int16 collResId;
- byte *startIP;
int16 curCmd;
int16 cmd;
int16 cmdHigh;
@@ -615,27 +624,27 @@
int16 collStackPos;
Collision *collPtr;
uint32 timeKey;
- byte *savedIP;
if (_shouldPushColls)
pushCollisions(1);
collResId = -1;
- _vm->_global->_inter_execPtr++;
- count = *_vm->_global->_inter_execPtr++;
- _handleMouse = _vm->_global->_inter_execPtr[0];
- deltaTime = 1000 * _vm->_global->_inter_execPtr[1];
- descIndex2 = _vm->_global->_inter_execPtr[2];
- stackPos2 = _vm->_global->_inter_execPtr[3];
- descIndex = _vm->_global->_inter_execPtr[4];
+ _script->skip(1);
+ count = _script->readByte();
+ _handleMouse = _script->readByte();
+ deltaTime = 1000 * _script->readByte();
+ descIndex2 = _script->readByte();
+ stackPos2 = _script->readByte();
+ descIndex = _script->readByte();
if ((stackPos2 != 0) || (descIndex != 0))
deltaTime /= 100;
timeVal = deltaTime;
- _vm->_global->_inter_execPtr += 6;
+ _script->skip(1);
- startIP = _vm->_global->_inter_execPtr;
+ uint32 startPos = _script->pos();
+
WRITE_VAR(16, 0);
var_22 = 0;
index = 0;
@@ -643,26 +652,25 @@
for (curCmd = 0; curCmd < count; curCmd++) {
array[curCmd] = 0;
- cmd = *_vm->_global->_inter_execPtr++;
+ cmd = _script->readByte();
if ((cmd & 0x40) != 0) {
cmd -= 0x40;
- cmdHigh = *_vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr++;
+ cmdHigh = _script->readByte();
cmdHigh <<= 8;
} else
cmdHigh = 0;
if ((cmd & 0x80) != 0) {
- left = _vm->_parse->parseValExpr();
- top = _vm->_parse->parseValExpr();
- width = _vm->_parse->parseValExpr();
- height = _vm->_parse->parseValExpr();
+ left = _script->readValExpr();
+ top = _script->readValExpr();
+ width = _script->readValExpr();
+ height = _script->readValExpr();
} else {
- left = _vm->_inter->load16();
- top = _vm->_inter->load16();
- width = _vm->_inter->load16();
- height = _vm->_inter->load16();
+ left = _script->readUint16();
+ top = _script->readUint16();
+ width = _script->readUint16();
+ height = _script->readUint16();
}
cmd &= 0x7F;
@@ -680,16 +688,16 @@
_vm->_util->clearKeyBuf();
var_22 = 1;
- key = _vm->_parse->parseVarIndex();
- descArray[index].fontIndex = _vm->_inter->load16();
- descArray[index].backColor = *_vm->_global->_inter_execPtr++;
- descArray[index].frontColor = *_vm->_global->_inter_execPtr++;
+ key = _script->readVarIndex();
+ descArray[index].fontIndex = _script->readInt16();
+ descArray[index].backColor = _script->readByte();
+ descArray[index].frontColor = _script->readByte();
if ((cmd < 5) || (cmd > 8)) {
descArray[index].ptr = 0;
} else {
- descArray[index].ptr = _vm->_global->_inter_execPtr + 2;
- _vm->_global->_inter_execPtr += _vm->_inter->load16();
+ descArray[index].ptr = _script->getData() + _script->pos() + 2;
+ _script->skip(_script->readInt16());
}
if (left == 0xFFFF)
@@ -698,12 +706,9 @@
if ((cmd & 1) == 0) {
addNewCollision(curCmd + 0x8000, left, top, left + width *
_vm->_draw->_fonts[descArray[index].fontIndex]->itemWidth - 1,
- top + height - 1, cmd, key, 0,
- _vm->_global->_inter_execPtr - _totFileData);
+ top + height - 1, cmd, key, 0, _script->pos());
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
} else {
addNewCollision(curCmd + 0x8000, left, top, left + width *
_vm->_draw->_fonts[descArray[index].fontIndex]->itemWidth - 1,
@@ -713,18 +718,15 @@
break;
case 21:
- key = _vm->_inter->load16();
- array[curCmd] = _vm->_inter->load16();
- flags = _vm->_inter->load16() & 3;
+ key = _script->readInt16();
+ array[curCmd] = _script->readInt16();
+ flags = _script->readInt16() & 3;
addNewCollision(curCmd + 0x8000, left, top,
left + width - 1, top + height - 1,
- (flags << 4) + cmdHigh + 2, key,
- _vm->_global->_inter_execPtr - _totFileData, 0);
+ (flags << 4) + cmdHigh + 2, key, _script->pos(), 0);
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
break;
case 20:
@@ -732,61 +734,48 @@
// Fall through to case 2
case 2:
- key = _vm->_inter->load16();
- array[curCmd] = _vm->_inter->load16();
- flags = _vm->_inter->load16() & 3;
+ key = _script->readInt16();
+ array[curCmd] = _script->readInt16();
+ flags = _script->readInt16() & 3;
addNewCollision(curCmd + 0x8000, left, top,
left + width - 1,
top + height - 1,
- (flags << 4) + cmdHigh + 2, key, 0,
- _vm->_global->_inter_execPtr - _totFileData);
+ (flags << 4) + cmdHigh + 2, key, 0, _script->pos());
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
break;
case 0:
- _vm->_global->_inter_execPtr += 6;
- startIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(6);
+ startPos = _script->pos();
+ _script->skip(_script->peekUint16(2) + 2);
key = curCmd + 0xA000;
addNewCollision(curCmd + 0x8000, left, top,
left + width - 1, top + height - 1,
cmd + cmdHigh, key,
- startIP - _totFileData,
- _vm->_global->_inter_execPtr - _totFileData);
+ startPos, _script->pos());
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
break;
case 1:
- key = _vm->_inter->load16();
- array[curCmd] = _vm->_inter->load16();
- flags = _vm->_inter->load16() & 3;
+ key = _script->readInt16();
+ array[curCmd] = _script->readInt16();
+ flags = _script->readInt16() & 3;
- startIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ startPos = _script->pos();
+ _script->skip(_script->peekUint16(2) + 2);
if (key == 0)
key = curCmd + 0xA000;
addNewCollision(curCmd + 0x8000, left, top,
left + width - 1, top + height - 1,
(flags << 4) + cmd + cmdHigh, key,
- startIP - _totFileData,
- _vm->_global->_inter_execPtr - _totFileData);
+ startPos, _script->pos());
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
break;
}
}
@@ -895,9 +884,11 @@
if (collPtr->funcLeave != 0) {
timeKey = _vm->_util->getTimeKey();
- savedIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr =
- _totFileData + collPtr->funcLeave;
+
+ uint32 savedPos = _script->pos();
+
+ _script->seek(collPtr->funcLeave);
+
_shouldPushColls = 1;
savedCollStackSize = _collStackSize;
_vm->_inter->funcBlock(0);
@@ -906,8 +897,9 @@
popCollisions();
_shouldPushColls = 0;
- _vm->_global->_inter_execPtr = savedIP;
+ _script->seek(savedPos);
+
deltaTime = timeVal -
(_vm->_util->getTimeKey() - timeKey);
@@ -986,10 +978,10 @@
WRITE_VAR(16, array[(uint16) _activeCollResId & ~0x8000]);
if (_collisionAreas[_activeCollIndex].funcEnter != 0) {
- savedIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr = _totFileData +
- _collisionAreas[_activeCollIndex].funcEnter;
+ uint32 savedPos = _script->pos();
+ _script->seek(_collisionAreas[_activeCollIndex].funcEnter);
+
_shouldPushColls = 1;
collStackPos = _collStackSize;
@@ -997,7 +989,8 @@
if (collStackPos != _collStackSize)
popCollisions();
_shouldPushColls = 0;
- _vm->_global->_inter_execPtr = savedIP;
+
+ _script->seek(savedPos);
}
WRITE_VAR(16, 0);
@@ -1071,10 +1064,8 @@
WRITE_VAR(17, 1);
}
- savedIP = 0;
if (!_vm->_inter->_terminate) {
- savedIP = _totFileData +
- _collisionAreas[_activeCollIndex].funcLeave;
+ _script->seek(_collisionAreas[_activeCollIndex].funcLeave);
WRITE_VAR(2, _vm->_global->_inter_mouseX);
WRITE_VAR(3, _vm->_global->_inter_mouseY);
@@ -1082,12 +1073,11 @@
if (VAR(16) == 0)
WRITE_VAR(16, array[(uint16) _activeCollResId & ~0x8000]);
- }
+ } else
+ _script->setFinished(true);
for (curCmd = 0; curCmd < count; curCmd++)
freeCollision(curCmd + 0x8000);
-
- _vm->_global->_inter_execPtr = savedIP;
}
int16 Game_v1::multiEdit(int16 time, int16 index, int16 *pCurPos,
Modified: scummvm/trunk/engines/gob/game_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/game_v2.cpp 2009-06-22 10:12:33 UTC (rev 41752)
+++ scummvm/trunk/engines/gob/game_v2.cpp 2009-06-22 10:13:37 UTC (rev 41753)
@@ -32,11 +32,11 @@
#include "gob/global.h"
#include "gob/util.h"
#include "gob/dataio.h"
+#include "gob/script.h"
#include "gob/draw.h"
#include "gob/goblin.h"
#include "gob/inter.h"
#include "gob/mult.h"
-#include "gob/parse.h"
#include "gob/scenery.h"
#include "gob/video.h"
#include "gob/videoplayer.h"
@@ -55,16 +55,15 @@
int16 _captureCounter;
int16 breakFrom;
int16 nestLevel;
- int32 totSize;
byte *filePtr;
- byte *savedIP;
bool totTextLoc;
oldNestLevel = _vm->_inter->_nestLevel;
oldBreakFrom = _vm->_inter->_breakFromLevel;
oldCaptureCounter = _vm->_scenery->_pCaptureCounter;
- savedIP = _vm->_global->_inter_execPtr;
+ uint32 startPos = _script->pos();
+
_vm->_inter->_nestLevel = &nestLevel;
_vm->_inter->_breakFromLevel = &breakFrom;
_vm->_scenery->_pCaptureCounter = &_captureCounter;
@@ -103,17 +102,15 @@
_vm->_draw->_cursorHotspotXVar = -1;
_totToLoad[0] = 0;
- if ((_curTotFile[0] == 0) && (_totFileData == 0))
+ if ((_curTotFile[0] == 0) && (!_script->isLoaded()))
break;
- totSize = loadTotFile(_curTotFile);
-
if (skipPlay == -2) {
_vm->_vidPlayer->primaryClose();
skipPlay = 0;
}
- if (_totFileData == 0) {
+ if (!_script->load(_curTotFile)) {
_vm->_draw->blitCursor();
_vm->_inter->_terminate = 2;
break;
@@ -131,7 +128,7 @@
debugC(4, kDebugFileIO, "IMA: %s", _curImaFile);
debugC(4, kDebugFileIO, "EXT: %s", _curExtFile);
- filePtr = _totFileData + 0x30;
+ filePtr = _script->getData() + 0x30;
_totTextData = 0;
totTextLoc = false;
@@ -145,8 +142,8 @@
totTextLoc = true;
} else {
_totTextData->dataPtr =
- (_totFileData + READ_LE_UINT32(_totFileData + 0x30));
- size = totSize;
+ (_script->getData() + READ_LE_UINT32(_script->getData() + 0x30));
+ size = _script->getSize();
_vm->_global->_language = _vm->_global->_languageWanted;
}
@@ -164,19 +161,19 @@
}
}
- filePtr = _totFileData + 0x34;
+ filePtr = _script->getData() + 0x34;
_totResourceTable = 0;
int32 resSize;
if (READ_LE_UINT32(filePtr) != (uint32) -1) {
_totResourceTable = new TotResTable;
_totResourceTable->dataPtr =
- _totFileData + READ_LE_UINT32(_totFileData + 0x34);
+ _script->getData() + READ_LE_UINT32(_script->getData() + 0x34);
Common::MemoryReadStream totResTable(_totResourceTable->dataPtr,
4294967295U);
_totResourceTable->itemsCount = totResTable.readSint16LE();
resSize = _totResourceTable->itemsCount * szGame_TotResItem + szGame_TotResTable;
- if (totSize > (resSize + 0x34)) {
+ if (_script->getSize() > (resSize + 0x34)) {
_totResourceTable->unknown = totResTable.readByte();
_totResourceTable->items =
@@ -196,7 +193,7 @@
// pointer with the real one.
debugC(1, kDebugFileIO,
"Attempted to load invalid resource table (size = %d, totSize = %d)",
- resSize, totSize);
+ resSize, _script->getSize());
delete _totResourceTable;
_totResourceTable = 0;
}
@@ -206,13 +203,11 @@
loadExtTable();
_vm->_global->_inter_animDataSize =
- READ_LE_UINT16(_totFileData + 0x38);
+ READ_LE_UINT16(_script->getData() + 0x38);
if (!_vm->_inter->_variables)
- _vm->_inter->allocateVars(READ_LE_UINT16(_totFileData + 0x2C));
+ _vm->_inter->allocateVars(READ_LE_UINT16(_script->getData() + 0x2C));
- _vm->_global->_inter_execPtr = _totFileData;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_totFileData + 0x64);
+ _script->seek(READ_LE_UINT16(_script->getData() + 0x64));
_vm->_inter->renewTimeInVars();
@@ -227,9 +222,9 @@
_vm->_inter->_terminate = 0;
_vm->_draw->blitInvalidated();
- delete[] _totFileData;
- _totFileData = 0;
+ _script->unload();
+
if (_totTextData) {
delete[] _totTextData->items;
if (totTextLoc)
@@ -282,9 +277,7 @@
} else {
_vm->_inter->initControlVars(0);
_vm->_scenery->_pCaptureCounter = oldCaptureCounter;
- _vm->_global->_inter_execPtr = _totFileData;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_totFileData + (skipPlay << 1) + 0x66);
+ _script->seek(READ_LE_UINT16(_script->getData() + (skipPlay << 1) + 0x66));
_menuLevel++;
_vm->_inter->callSub(2);
@@ -299,7 +292,8 @@
_vm->_inter->_nestLevel = oldNestLevel;
_vm->_inter->_breakFromLevel = oldBreakFrom;
_vm->_scenery->_pCaptureCounter = oldCaptureCounter;
- _vm->_global->_inter_execPtr = savedIP;
+
+ _script->seek(startPos);
}
void Game_v2::clearCollisions() {
@@ -338,6 +332,7 @@
ptr->funcLeave = funcLeave;
ptr->funcSub = funcSub;
ptr->totFileData = 0;
+ ptr->totSize = 0;
return i;
}
@@ -604,7 +599,6 @@
int16 array[250];
byte count;
int16 collResId;
- byte *startIP;
int16 curCmd;
int16 cmd;
int16 cmdHigh;
@@ -621,7 +615,6 @@
int16 stackPos2;
int16 descIndex;
int16 timeVal;
- int16 offsetIP;
char *str;
int16 i;
int16 counter;
@@ -631,8 +624,9 @@
Collision *collPtr;
Collision *collArea;
int16 timeKey;
- byte *savedIP;
byte collAreaStart;
+ uint32 startPos;
+ uint32 offsetPos;
if (_shouldPushColls)
pushCollisions(0);
@@ -645,21 +639,22 @@
_shouldPushColls = 0;
collResId = -1;
- _vm->_global->_inter_execPtr++;
- count = *_vm->_global->_inter_execPtr++;
+ _script->skip(1);
+ count = _script->readByte();
- _handleMouse = _vm->_global->_inter_execPtr[0];
- deltaTime = 1000 * _vm->_global->_inter_execPtr[1];
- stackPos2 = _vm->_global->_inter_execPtr[3];
- descIndex = _vm->_global->_inter_execPtr[4];
+ _handleMouse = _script->readByte();
+ deltaTime = 1000 * _script->readByte();
+ _script->skip(1);
+ stackPos2 = _script->readByte();
+ descIndex = _script->readByte();
if ((stackPos2 != 0) || (descIndex != 0))
deltaTime /= 100;
timeVal = deltaTime;
- _vm->_global->_inter_execPtr += 6;
+ _script->skip(1);
- startIP = _vm->_global->_inter_execPtr;
+ startPos = _script->pos();
WRITE_VAR(16, 0);
var_1C = 0;
@@ -668,28 +663,27 @@
for (curCmd = 0; curCmd < count; curCmd++) {
array[curCmd] = 0;
- cmd = *_vm->_global->_inter_execPtr++;
+ cmd = _script->readByte();
if ((cmd & 0x40) != 0) {
cmd -= 0x40;
- cmdHigh = *_vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr++;
+ cmdHigh = _script->readByte();
cmdHigh <<= 8;
} else
cmdHigh = 0;
if ((cmd & 0x80) != 0) {
- offsetIP = _vm->_global->_inter_execPtr - _totFileData;
- left = _vm->_parse->parseValExpr();
- top = _vm->_parse->parseValExpr();
- width = _vm->_parse->parseValExpr();
- height = _vm->_parse->parseValExpr();
+ offsetPos = _script->pos();
+ left = _script->readValExpr();
+ top = _script->readValExpr();
+ width = _script->readValExpr();
+ height = _script->readValExpr();
} else {
- offsetIP = 0;
- left = _vm->_inter->load16();
- top = _vm->_inter->load16();
- width = _vm->_inter->load16();
- height = _vm->_inter->load16();
+ offsetPos = 0;
+ left = _script->readUint16();
+ top = _script->readUint16();
+ width = _script->readUint16();
+ height = _script->readUint16();
}
if ((_vm->_draw->_renderFlags & RENDERFLAG_CAPTUREPOP) && (left != 0xFFFF)) {
@@ -712,46 +706,37 @@
switch (cmd) {
case 0:
- _vm->_global->_inter_execPtr += 6;
- startIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(6);
+ startPos = _script->pos();
+ _script->skip(_script->peekUint16(2) + 2);
key = curCmd + 0xA000;
addNewCollision(curCmd + 0x8000, left, top,
left + width - 1, top + height - 1,
- cmd + cmdHigh, key, startIP - _totFileData,
- _vm->_global->_inter_execPtr - _totFileData, offsetIP);
+ cmd + cmdHigh, key, startPos,
+ _script->pos(), offsetPos);
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
break;
case 1:
- key = _vm->_inter->load16();
- array[curCmd] = _vm->_inter->load16();
- flags = _vm->_inter->load16();
+ key = _script->readInt16();
+ array[curCmd] = _script->readInt16();
+ flags = _script->readInt16();
- startIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ startPos = _script->pos();
+ _script->skip(_script->peekUint16(2) + 2);
if (key == 0)
key = curCmd + 0xA000;
addNewCollision(curCmd + 0x8000, left, top,
left + width - 1, top + height - 1,
- (flags << 4) + cmd + cmdHigh, key, startIP - _totFileData,
- _vm->_global->_inter_execPtr - _totFileData, offsetIP);
+ (flags << 4) + cmd + cmdHigh, key, startPos,
+ _script->pos(), offsetPos);
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
-
+ _script->skip(_script->peekUint16(2) + 2);
break;
case 3:
@@ -764,23 +749,20 @@
case 10:
_vm->_util->clearKeyBuf();
var_1C = 1;
- key = _vm->_parse->parseVarIndex();
- descArray[index].fontIndex = _vm->_inter->load16();
- descArray[index].backColor = *_vm->_global->_inter_execPtr++;
- descArray[index].frontColor = *_vm->_global->_inter_execPtr++;
+ key = _script->readVarIndex();
+ descArray[index].fontIndex = _script->readInt16();
+ descArray[index].backColor = _script->readByte();
+ descArray[index].frontColor = _script->readByte();
if ((cmd >= 5) && (cmd <= 8)) {
- descArray[index].ptr = _vm->_global->_inter_execPtr + 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr) + 2;
+ descArray[index].ptr = _script->getData() + _script->pos() + 2;
+ _script->skip(_script->peekUint16() + 2);
} else
descArray[index].ptr = 0;
if (left == 0xFFFF) {
if ((cmd & 1) == 0) {
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
}
break;
}
@@ -789,11 +771,9 @@
addNewCollision(curCmd + 0x8000, left, top, left + width *
_vm->_draw->_fonts[descArray[index].fontIndex]-> itemWidth - 1,
top + height - 1, cmd, key, 0,
- _vm->_global->_inter_execPtr - _totFileData);
+ _script->pos());
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
} else
addNewCollision(curCmd + 0x8000, left, top, left + width *
_vm->_draw->_fonts[descArray[index].fontIndex]-> itemWidth - 1,
@@ -803,35 +783,31 @@
break;
case 11:
- _vm->_global->_inter_execPtr += 6;
+ _script->skip(6);
for (i = 0; i < 150; i++) {
if ((_collisionAreas[i].id & 0xF000) == 0xE000) {
_collisionAreas[i].id &= 0xBFFF;
_collisionAreas[i].funcEnter =
- _vm->_global->_inter_execPtr - _totFileData;
+ _script->pos();
_collisionAreas[i].funcLeave =
- _vm->_global->_inter_execPtr - _totFileData;
+ _script->pos();
}
}
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
break;
case 12:
- _vm->_global->_inter_execPtr += 6;
+ _script->skip(6);
for (i = 0; i < 150; i++) {
if ((_collisionAreas[i].id & 0xF000) == 0xD000) {
_collisionAreas[i].id &= 0xBFFF;
_collisionAreas[i].funcEnter =
- _vm->_global->_inter_execPtr - _totFileData;
+ _script->pos();
_collisionAreas[i].funcLeave =
- _vm->_global->_inter_execPtr - _totFileData;
+ _script->pos();
}
}
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
break;
case 20:
@@ -839,34 +815,30 @@
// Fall through to case 2
case 2:
- key = _vm->_inter->load16();
- array[curCmd] = _vm->_inter->load16();
- flags = _vm->_inter->load16();
+ key = _script->readInt16();
+ array[curCmd] = _script->readInt16();
+ flags = _script->readInt16();
addNewCollision(curCmd + 0x8000, left, top,
left + width - 1, top + height - 1,
(flags << 4) + cmdHigh + 2, key, 0,
- _vm->_global->_inter_execPtr - _totFileData, offsetIP);
+ _script->pos(), offsetPos);
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
break;
case 21:
- key = _vm->_inter->load16();
- array[curCmd] = _vm->_inter->load16();
- flags = _vm->_inter->load16() & 3;
+ key = _script->readInt16();
+ array[curCmd] = _script->readInt16();
+ flags = _script->readInt16() & 3;
addNewCollision(curCmd + 0x8000, left, top,
left + width - 1, top + height - 1,
(flags << 4) + cmdHigh + 2, key,
- _vm->_global->_inter_execPtr - _totFileData, 0, offsetIP);
+ _script->pos(), 0, offsetPos);
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
break;
}
@@ -1116,10 +1088,8 @@
if (_handleMouse == 1)
_vm->_draw->blitCursor();
- savedIP = 0;
if (!_vm->_inter->_terminate) {
- savedIP = _totFileData +
- _collisionAreas[_activeCollIndex].funcLeave;
+ _script->seek(_collisionAreas[_activeCollIndex].funcLeave);
_vm->_inter->storeMouse();
if (VAR(16) == 0) {
@@ -1128,7 +1098,8 @@
else
WRITE_VAR(16, _activeCollResId & 0xFFF);
}
- }
+ } else
+ _script->setFinished(true);
for (curCmd = 0; curCmd < count; curCmd++)
freeCollision(curCmd + 0x8000);
@@ -1138,8 +1109,6 @@
((_collisionAreas[i].id & 0xF000) == 0x9000))
_collisionAreas[i].id |= 0x4000;
}
-
- _vm->_global->_inter_execPtr = savedIP;
}
int16 Game_v2::multiEdit(int16 time, int16 index, int16 *pCurPos,
Modified: scummvm/trunk/engines/gob/game_v6.cpp
===================================================================
--- scummvm/trunk/engines/gob/game_v6.cpp 2009-06-22 10:12:33 UTC (rev 41752)
+++ scummvm/trunk/engines/gob/game_v6.cpp 2009-06-22 10:13:37 UTC (rev 41753)
@@ -31,9 +31,9 @@
#include "gob/game.h"
#include "gob/helper.h"
#include "gob/global.h"
+#include "gob/script.h"
#include "gob/inter.h"
#include "gob/draw.h"
-#include "gob/parse.h"
namespace Gob {
@@ -54,7 +54,7 @@
_cursorHotspotXArray[_backupedCount] = _vm->_draw->_cursorHotspotXVar;
_cursorHotspotYArray[_backupedCount] = _vm->_draw->_cursorHotspotYVar;
_totTextDataArray[_backupedCount] = _totTextData;
- _totFileDataArray[_backupedCount] = _totFileData;
+ _scriptArray[_backupedCount] = _script;
_totResourceTableArray[_backupedCount] = _totResourceTable;
_extTableArray[_backupedCount] = _extTable;
_extHandleArray[_backupedCount] = _extHandle;
@@ -66,8 +66,8 @@
_backupedCount++;
_curBackupPos = _backupedCount;
+ _script = new Script(_vm);
_totTextData = 0;
- _totFileData = 0;
_totResourceTable = 0;
if (flags & 0x80)
@@ -105,7 +105,7 @@
_vm->_draw->_cursorHotspotXVar = _cursorHotspotXArray[_backupedCount];
_vm->_draw->_cursorHotspotYVar = _cursorHotspotYArray[_backupedCount];
_totTextData = _totTextDataArray[_backupedCount];
- _totFileData = _totFileDataArray[_backupedCount];
+ _script = _scriptArray[_backupedCount];
_totResourceTable = _totResourceTableArray[_backupedCount];
_extTable = _extTableArray[_backupedCount];
_extHandle = _extHandleArray[_backupedCount];
@@ -148,7 +148,8 @@
ptr->funcEnter = funcEnter;
ptr->funcLeave = funcLeave;
ptr->funcSub = funcSub;
- ptr->totFileData = _totFileData;
+ ptr->totFileData = _script->getData();
+ ptr->totSize = _script->getSize();
return i;
}
@@ -383,7 +384,6 @@
int16 array[300];
byte count;
int16 collResId;
- byte *startIP;
int16 curCmd;
int16 cmd;
int16 cmdHigh;
@@ -397,7 +397,6 @@
int16 stackPos2;
int16 descIndex;
int16 timeVal;
- int16 offsetIP;
char *str;
int16 i;
int16 counter;
@@ -406,10 +405,11 @@
int16 collStackPos;
Collision *collPtr;
Collision *collArea;
- byte *savedIP;
byte collAreaStart;
int16 activeCollResId = 0;
int16 activeCollIndex = 0;
+ uint32 startPos;
+ uint32 offsetPos;
if (_shouldPushColls)
pushCollisions(0);
@@ -422,25 +422,25 @@
_shouldPushColls = 0;
collResId = -1;
- _vm->_global->_inter_execPtr++;
- count = *_vm->_global->_inter_execPtr++;
+ _script->skip(1);
+ count = _script->readByte();
- _handleMouse = _vm->_global->_inter_execPtr[0];
- deltaTime = 1000 * _vm->_global->_inter_execPtr[1];
- stackPos2 = _vm->_global->_inter_execPtr[3];
- descIndex = _vm->_global->_inter_execPtr[4];
- byte var_42 = _vm->_global->_inter_execPtr[5];
+ _handleMouse = _script->peekByte(0);
+ deltaTime = 1000 * _script->peekByte(1);
+ stackPos2 = _script->peekByte(3);
+ descIndex = _script->peekByte(4);
+ byte var_42 = _script->peekByte(5);
if ((stackPos2 != 0) || (descIndex != 0)) {
deltaTime /= 100;
- if (_vm->_global->_inter_execPtr[1] == 100)
+ if (_script->peekByte(1) == 100)
deltaTime = 2;
}
timeVal = deltaTime;
- _vm->_global->_inter_execPtr += 6;
+ _script->skip(6);
- startIP = _vm->_global->_inter_execPtr;
+ startPos = _script->pos();
WRITE_VAR(16, 0);
byte var_41 = 0;
@@ -452,28 +452,27 @@
for (curCmd = 0; curCmd < count; curCmd++) {
array[curCmd] = 0;
- cmd = *_vm->_global->_inter_execPtr++;
+ cmd = _script->readByte();
if ((cmd & 0x40) != 0) {
cmd -= 0x40;
- cmdHigh = *_vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr++;
+ cmdHigh = _script->readByte();
cmdHigh <<= 8;
} else
cmdHigh = 0;
if ((cmd & 0x80) != 0) {
- offsetIP = _vm->_global->_inter_execPtr - _totFileData;
- left = _vm->_parse->parseValExpr();
- top = _vm->_parse->parseValExpr();
- width = _vm->_parse->parseValExpr();
- height = _vm->_parse->parseValExpr();
+ offsetPos = _script->pos();
+ left = _script->readValExpr();
+ top = _script->readValExpr();
+ width = _script->readValExpr();
+ height = _script->readValExpr();
} else {
- offsetIP = 0;
- left = _vm->_inter->load16();
- top = _vm->_inter->load16();
- width = _vm->_inter->load16();
- height = _vm->_inter->load16();
+ offsetPos = 0;
+ left = _script->readUint16();
+ top = _script->readUint16();
+ width = _script->readUint16();
+ height = _script->readUint16();
}
if ((_vm->_draw->_renderFlags & RENDERFLAG_CAPTUREPOP) && (left != 0xFFFF)) {
@@ -496,45 +495,37 @@
switch (cmd) {
case 0:
- _vm->_global->_inter_execPtr += 6;
- startIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(6);
+ startPos = _script->pos();
+ _script->skip(_script->peekUint16(2) + 2);
key = curCmd + 0xA000;
addNewCollision(curCmd + 0x8000, left, top,
left + width - 1, top + height - 1,
- cmd + cmdHigh, key, startIP - _totFileData,
- _vm->_global->_inter_execPtr - _totFileData, offsetIP);
+ cmd + cmdHigh, key, startPos,
+ _script->pos(), offsetPos);
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
break;
case 1:
- key = _vm->_inter->load16();
- array[curCmd] = _vm->_inter->load16();
- flags = _vm->_inter->load16();
+ key = _script->readInt16();
+ array[curCmd] = _script->readInt16();
+ flags = _script->readInt16();
- startIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ startPos = _script->pos();
+ _script->skip(_script->peekUint16(2) + 2);
if (key == 0)
key = curCmd + 0xA000;
addNewCollision(curCmd + 0x8000, left, top,
left + width - 1, top + height - 1,
- (flags << 4) + cmd + cmdHigh, key, startIP - _totFileData,
- _vm->_global->_inter_execPtr - _totFileData, offsetIP);
+ (flags << 4) + cmd + cmdHigh, key, startPos,
+ _script->pos(), offsetPos);
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
break;
@@ -548,23 +539,20 @@
case 10:
_vm->_util->clearKeyBuf();
var_1C = 1;
- key = _vm->_parse->parseVarIndex();
- descArray[index].fontIndex = _vm->_inter->load16();
- descArray[index].backColor = *_vm->_global->_inter_execPtr++;
- descArray[index].frontColor = *_vm->_global->_inter_execPtr++;
+ key = _script->readVarIndex();
+ descArray[index].fontIndex = _script->readInt16();
+ descArray[index].backColor = _script->readByte();
+ descArray[index].frontColor = _script->readByte();
if ((cmd >= 5) && (cmd <= 8)) {
- descArray[index].ptr = _vm->_global->_inter_execPtr + 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr) + 2;
+ descArray[index].ptr = _script->getData() + _script->pos() + 2;
+ _script->skip(_script->peekUint16() + 2);
} else
descArray[index].ptr = 0;
if (left == 0xFFFF) {
if ((cmd & 1) == 0) {
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
}
break;
}
@@ -575,50 +563,44 @@
funcLeave = 0;
if (!(cmd & 1))
- funcLeave = _vm->_global->_inter_execPtr - _totFileData;
+ funcLeave = _script->pos();
addNewCollision(curCmd + 0x8000, left, top, right,
top + height - 1, cmd, key, 0, funcLeave, 0);
if (!(cmd & 1)) {
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
}
index++;
break;
case 11:
- _vm->_global->_inter_execPtr += 6;
+ _script->skip(6);
for (i = 0; i < 150; i++) {
if ((_collisionAreas[i].id & 0xF000) == 0xE000) {
_collisionAreas[i].id &= 0xBFFF;
_collisionAreas[i].funcEnter =
- _vm->_global->_inter_execPtr - _totFileData;
+ _script->pos();
_collisionAreas[i].funcLeave =
- _vm->_global->_inter_execPtr - _totFileData;
+ _script->pos();
}
}
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
break;
case 12:
- _vm->_global->_inter_execPtr += 6;
+ _script->skip(6);
for (i = 0; i < 150; i++) {
if ((_collisionAreas[i].id & 0xF000) == 0xD000) {
_collisionAreas[i].id &= 0xBFFF;
_collisionAreas[i].funcEnter =
- _vm->_global->_inter_execPtr - _totFileData;
+ _script->pos();
_collisionAreas[i].funcLeave =
- _vm->_global->_inter_execPtr - _totFileData;
+ _script->pos();
}
}
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
break;
case 20:
@@ -626,34 +608,30 @@
// Fall through to case 2
case 2:
- key = _vm->_inter->load16();
- array[curCmd] = _vm->_inter->load16();
- flags = _vm->_inter->load16();
+ key = _script->readInt16();
+ array[curCmd] = _script->readInt16();
+ flags = _script->readInt16();
addNewCollision(curCmd + 0x8000, left, top,
left + width - 1, top + height - 1,
(flags << 4) + cmdHigh + 2, key, 0,
- _vm->_global->_inter_execPtr - _totFileData, offsetIP);
+ _script->pos(), offsetPos);
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
break;
case 21:
- key = _vm->_inter->load16();
- array[curCmd] = _vm->_inter->load16();
- flags = _vm->_inter->load16() & 3;
+ key = _script->readInt16();
+ array[curCmd] = _script->readInt16();
+ flags = _script->readInt16() & 3;
addNewCollision(curCmd + 0x8000, left, top,
left + width - 1, top + height - 1,
(flags << 4) + cmdHigh + 2, key,
- _vm->_global->_inter_execPtr - _totFileData, 0, offsetIP);
+ _script->pos(), 0, offsetPos);
- _vm->_global->_inter_execPtr += 2;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr);
+ _script->skip(_script->peekUint16(2) + 2);
break;
}
@@ -915,10 +893,8 @@
if (_handleMouse == 1)
_vm->_draw->blitCursor();
- savedIP = 0;
if (!_vm->_inter->_terminate && (var_41 == 0)) {
- savedIP = _totFileData +
- _collisionAreas[activeCollIndex].funcLeave;
+ _script->seek(_collisionAreas[activeCollIndex].funcLeave);
_vm->_inter->storeMouse();
if (VAR(16) == 0) {
@@ -927,7 +903,8 @@
else
WRITE_VAR(16, activeCollResId & 0xFFF);
}
- }
+ } else
+ _script->setFinished(true);
for (curCmd = 0; curCmd < count; curCmd++)
freeCollision(curCmd + 0x8000);
@@ -937,8 +914,6 @@
((_collisionAreas[i].id & 0xF000) == 0x9000))
_collisionAreas[i].id |= 0x4000;
}
-
- _vm->_global->_inter_execPtr = savedIP;
}
void Game_v6::setCollisions(byte arg_0) {
@@ -951,22 +926,28 @@
continue;
byte *totFileData = collArea->totFileData;
+ uint32 totSize = collArea->totSize;
- if (!totFileData)
- totFileData = _totFileData;
+ if (!totFileData || (totSize == 0)) {
+ totFileData = _script->getData();
+ totSize = _script->getSize();
+ }
- byte *savedIP = _vm->_global->_inter_execPtr;
+ uint32 savedPos = _script->pos();
+ byte *savedData = _script->getData();
+ uint32 savedSize = _script->getSize();
- _vm->_global->_inter_execPtr = totFileData + collArea->funcSub;
+ _script->cuckoo(totFileData, totSize);
+ _script->seek(collArea->funcSub);
- int16 left = _vm->_parse->parseValExpr();
- int16 top = _vm->_parse->parseValExpr();
- int16 width = _vm->_parse->parseValExpr();
- int16 height = _vm->_parse->parseValExpr();
+ int16 left = _script->readValExpr();
+ int16 top = _script->readValExpr();
+ int16 width = _script->readValExpr();
+ int16 height = _script->readValExpr();
uint16 flags = 0;
if ((collArea->id & 0xF000) == 0xA000)
- flags = _vm->_parse->parseValExpr();
+ flags = _script->readValExpr();
if ((_vm->_draw->_renderFlags & RENDERFLAG_CAPTUREPOP) &&
(left != -1)) {
@@ -1001,17 +982,18 @@
if ((collArea->id & 0xF000) == 0xA000)
collArea->flags = flags;
- _vm->_global->_inter_execPtr = savedIP;
+ _script->cuckoo(savedData, savedSize);
+ _script->seek(savedPos);
}
}
void Game_v6::collSub(uint16 offset) {
- byte *savedIP;
int16 collStackSize;
- savedIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr = _totFileData + offset;
+ uint32 savedPos = _script->pos();
+ _script->seek(offset);
+
_shouldPushColls = 1;
collStackSize = _collStackSize;
@@ -1021,8 +1003,9 @@
popCollisions();
_shouldPushColls = 0;
- _vm->_global->_inter_execPtr = savedIP;
+ _script->seek(savedPos);
+
if ((_vm->_util->getTimeKey() - _someTimeDly) > 500)
setCollisions(0);
}
Modified: scummvm/trunk/engines/gob/init.cpp
===================================================================
--- scummvm/trunk/engines/gob/init.cpp 2009-06-22 10:12:33 UTC (rev 41752)
+++ scummvm/trunk/engines/gob/init.cpp 2009-06-22 10:13:37 UTC (rev 41753)
@@ -99,7 +99,6 @@
_vm->_global->_mouseYShift = 1;
_vm->_game->_totTextData = 0;
- _vm->_game->_totFileData = 0;
_palDesc = new Video::PalDesc;
_vm->validateVideoMode(_vm->_global->_videoMode);
Modified: scummvm/trunk/engines/gob/inter.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter.cpp 2009-06-22 10:12:33 UTC (rev 41752)
+++ scummvm/trunk/engines/gob/inter.cpp 2009-06-22 10:13:37 UTC (rev 41753)
@@ -33,9 +33,10 @@
#include "gob/util.h"
#include "gob/draw.h"
#include "gob/game.h"
-#include "gob/parse.h"
+#include "gob/script.h"
#include "gob/scenery.h"
#include "gob/sound/sound.h"
+#include "gob/parse.h"
namespace Gob {
@@ -114,7 +115,7 @@
return;
}
- _vm->_global->_inter_execPtr += params.paramCount << 1;
+ _vm->_game->_script->skip(params.paramCount << 1);
warning("unimplemented opcodeGob: %d [0x%X]", i, i);
}
@@ -156,24 +157,18 @@
}
}
-int16 Inter::load16() {
- int16 tmp = (int16) READ_LE_UINT16(_vm->_global->_inter_execPtr);
- _vm->_global->_inter_execPtr += 2;
- return tmp;
-}
-
char Inter::evalExpr(int16 *pRes) {
byte type;
_vm->_parse->printExpr(99);
- _vm->_parse->parseExpr(99, &type);
+ _vm->_game->_script->readExpr(99, &type);
if (!pRes)
return type;
switch (type) {
case TYPE_IMM_INT16:
- *pRes = _vm->_parse->getResultInt();
+ *pRes = _vm->_game->_script->getResultInt();
break;
case TYPE_IMM_STR:
@@ -194,9 +189,9 @@
_vm->_parse->printExpr(99);
- _vm->_parse->parseExpr(99, &type);
+ _vm->_game->_script->readExpr(99, &type);
if ( (type == GOB_TRUE) ||
- ((type == TYPE_IMM_INT16) && _vm->_parse->getResultInt()))
+ ((type == TYPE_IMM_INT16) && _vm->_game->_script->getResultInt()))
return true;
else
return false;
@@ -283,20 +278,20 @@
params.retFlag = retFlag;
- if (!_vm->_global->_inter_execPtr)
+ if (_vm->_game->_script->isFinished())
return;
_break = false;
- _vm->_global->_inter_execPtr++;
- params.cmdCount = *_vm->_global->_inter_execPtr++;
- _vm->_global->_inter_execPtr += 2;
+ _vm->_game->_script->skip(1);
+ params.cmdCount = _vm->_game->_script->readByte();
+ _vm->_game->_script->skip(2);
if (params.cmdCount == 0) {
- _vm->_global->_inter_execPtr = 0;
+ _vm->_game->_script->setFinished(true);
return;
}
- int startaddr = _vm->_global->_inter_execPtr - _vm->_game->_totFileData;
+ int startaddr = _vm->_game->_script->pos();
params.counter = 0;
do {
@@ -311,7 +306,7 @@
(_vm->getPlatform() == Common::kPlatformMacintosh) ||
(_vm->getPlatform() == Common::kPlatformWindows))) {
- int addr = _vm->_global->_inter_execPtr-_vm->_game->_totFileData;
+ int addr = _vm->_game->_script->pos();
if ((startaddr == 0x18B4 && addr == 0x1A7F && // Zombie, EGA
!strncmp(_vm->_game->_curTotFile, "avt005.tot", 10)) ||
@@ -337,14 +332,13 @@
} // End of workaround
- cmd = *_vm->_global->_inter_execPtr;
+ cmd = _vm->_game->_script->readByte();
if ((cmd >> 4) >= 12) {
cmd2 = 16 - (cmd >> 4);
cmd &= 0xF;
} else
cmd2 = 0;
- _vm->_global->_inter_execPtr++;
params.counter++;
if (cmd2 == 0)
@@ -366,17 +360,17 @@
}
} while (params.counter != params.cmdCount);
- _vm->_global->_inter_execPtr = 0;
+ _vm->_game->_script->setFinished(true);
return;
}
void Inter::callSub(int16 retFlag) {
byte block;
- while (!_vm->shouldQuit() && _vm->_global->_inter_execPtr &&
- (_vm->_global->_inter_execPtr != _vm->_game->_totFileData)) {
+ while (!_vm->shouldQuit() && !_vm->_game->_script->isFinished() &&
+ (_vm->_game->_script->pos() != 0)) {
- block = *_vm->_global->_inter_execPtr;
+ block = _vm->_game->_script->peekByte();
if (block == 1)
funcBlock(retFlag);
else if (block == 2)
@@ -385,7 +379,7 @@
error("Unknown block type %d in Inter::callSub()", block);
}
- if (_vm->_global->_inter_execPtr == _vm->_game->_totFileData)
+ if (!_vm->_game->_script->isFinished() && (_vm->_game->_script->pos() == 0))
_terminate = 1;
}
Modified: scummvm/trunk/engines/gob/inter.h
===================================================================
--- scummvm/trunk/engines/gob/inter.h 2009-06-22 10:12:33 UTC (rev 41752)
+++ scummvm/trunk/engines/gob/inter.h 2009-06-22 10:13:37 UTC (rev 41753)
@@ -100,7 +100,6 @@
void setupOpcodes();
void initControlVars(char full);
- int16 load16();
char evalExpr(int16 *pRes);
bool evalBoolResult();
void renewTimeInVars();
@@ -152,7 +151,7 @@
virtual void setupOpcodesFunc() = 0;
virtual void setupOpcodesGob() = 0;
- virtual void checkSwitchTable(byte **ppExec) = 0;
+ virtual void checkSwitchTable(uint32 &offset) = 0;
void o_drawNOP() {}
bool o_funcNOP(OpFuncParams ¶ms) { return false; }
@@ -172,7 +171,7 @@
virtual void setupOpcodesFunc();
virtual void setupOpcodesGob();
- virtual void checkSwitchTable(byte **ppExec);
+ virtual void checkSwitchTable(uint32 &offset);
void o1_loadMult();
void o1_playMult();
@@ -343,7 +342,7 @@
virtual void setupOpcodesFunc();
virtual void setupOpcodesGob();
- virtual void checkSwitchTable(byte **ppExec);
+ virtual void checkSwitchTable(uint32 &offset);
void o2_playMult();
void o2_freeMultKeys();
Modified: scummvm/trunk/engines/gob/inter_fascin.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_fascin.cpp 2009-06-22 10:12:33 UTC (rev 41752)
+++ scummvm/trunk/engines/gob/inter_fascin.cpp 2009-06-22 10:13:37 UTC (rev 41753)
@@ -31,8 +31,8 @@
#include "gob/util.h"
#include "gob/dataio.h"
#include "gob/draw.h"
-#include "gob/parse.h"
#include "gob/game.h"
+#include "gob/script.h"
#include "gob/palanim.h"
#include "gob/video.h"
#include "gob/videoplayer.h"
@@ -205,15 +205,15 @@
warning("Fascination oFascin_cdUnknown3 - Variables initialisations");
- resVar = (uint16) load16();
- resVar2 = (uint16) load16();
- retVal1 = _vm->_parse->parseVarIndex();
- retVal2 = _vm->_parse->parseVarIndex();
- retVal3 = _vm->_parse->parseVarIndex();
- retVal4 = _vm->_parse->parseVarIndex();
- retVal5 = _vm->_parse->parseVarIndex();
- retVal6 = _vm->_parse->parseVarIndex();
- retVal7 = _vm->_parse->parseVarIndex();
+ resVar = _vm->_game->_script->readUint16();
+ resVar2 = _vm->_game->_script->readUint16();
+ retVal1 = _vm->_game->_script->readVarIndex();
+ retVal2 = _vm->_game->_script->readVarIndex();
+ retVal3 = _vm->_game->_script->readVarIndex();
+ retVal4 = _vm->_game->_script->readVarIndex();
+ retVal5 = _vm->_game->_script->readVarIndex();
+ retVal6 = _vm->_game->_script->readVarIndex();
+ retVal7 = _vm->_game->_script->readVarIndex();
warning ("Width? :%d Height? :%d",resVar, resVar2);
warning ("Fetched variables 1:%d 2:%d 3:%d 4:%d 5:%d 6:%d 7:%d", retVal1, retVal2, retVal3, retVal4, retVal5, retVal6, retVal7);
}
@@ -229,7 +229,7 @@
int16 retVal1,expr;
warning("Fascination oFascin_cdUnknown5");
evalExpr(&expr);
- retVal1 = _vm->_parse->parseVarIndex();
+ retVal1 = _vm->_game->_script->readVarIndex();
warning ("evalExpr: %d Variable index %d, the rest is not yet implemented",expr, retVal1);
}
@@ -237,7 +237,7 @@
int16 retVal1,expr;
warning("Fascination oFascin_cdUnknown6");
evalExpr(&expr);
- retVal1 = _vm->_parse->parseVarIndex();
+ retVal1 = _vm->_game->_script->readVarIndex();
warning ("evalExpr: %d Variable index %d, the rest is not yet implemented",expr, retVal1);
}
Modified: scummvm/trunk/engines/gob/inter_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v1.cpp 2009-06-22 10:12:33 UTC (rev 41752)
+++ scummvm/trunk/engines/gob/inter_v1.cpp 2009-06-22 10:13:37 UTC (rev 41753)
@@ -34,12 +34,13 @@
#include "gob/dataio.h"
#include "gob/draw.h"
#include "gob/game.h"
+#include "gob/script.h"
+#include "gob/parse.h"
#include "gob/goblin.h"
#include "gob/inter.h"
#include "gob/map.h"
#include "gob/mult.h"
#include "gob/palanim.h"
-#include "gob/parse.h"
#include "gob/scenery.h"
#include "gob/video.h"
#include "gob/sound/sound.h"
@@ -239,7 +240,7 @@
OPCODEGOB(2005, o1_initGoblin);
}
-void Inter_v1::checkSwitchTable(byte **ppExec) {
+void Inter_v1::checkSwitchTable(uint32 &offset) {
int16 len;
int32 value;
bool found;
@@ -247,10 +248,10 @@
found = false;
notFound = true;
- *ppExec = 0;
- value = VAR_OFFSET(_vm->_parse->parseVarIndex());
+ offset = 0;
+ value = VAR_OFFSET(_vm->_game->_script->readVarIndex());
- len = (int8) *_vm->_global->_inter_execPtr++;
+ len = _vm->_game->_script->readInt8();
while (len != -5) {
for (int i = 0; i < len; i++) {
evalExpr(0);
@@ -258,45 +259,43 @@
if (_terminate)
return;
- if (_vm->_parse->getResultInt() == value) {
+ if (_vm->_game->_script->getResultInt() == value) {
found = true;
notFound = false;
}
}
if (found)
- *ppExec = _vm->_global->_inter_execPtr;
+ offset = _vm->_game->_script->pos();
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr + 2) + 2;
+ _vm->_game->_script->skip(_vm->_game->_script->peekUint16(2) + 2);
found = false;
- len = (int8) *_vm->_global->_inter_execPtr++;
+ len = _vm->_game->_script->readInt8();
}
- if ((*_vm->_global->_inter_execPtr >> 4) != 4)
+ if ((_vm->_game->_script->peekByte() >> 4) != 4)
return;
- _vm->_global->_inter_execPtr++;
+ _vm->_game->_script->skip(1);
if (notFound)
- *ppExec = _vm->_global->_inter_execPtr;
+ offset = _vm->_game->_script->pos();
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr + 2) + 2;
+ _vm->_game->_script->skip(_vm->_game->_script->peekUint16(2) + 2);
}
void Inter_v1::o1_loadMult() {
- _vm->_mult->loadMult(load16());
+ _vm->_mult->loadMult(_vm->_game->_script->readInt16());
}
void Inter_v1::o1_playMult() {
int16 checkEscape;
- checkEscape = load16();
+ checkEscape = _vm->_game->_script->readInt16();
_vm->_mult->playMult(VAR(57), -1, checkEscape, 0);
}
void Inter_v1::o1_freeMultKeys() {
- load16();
+ _vm->_game->_script->readInt16();
_vm->_mult->freeMultKeys();
}
@@ -305,20 +304,20 @@
int16 height;
int16 count;
- _vm->_draw->_cursorHotspotXVar = _vm->_parse->parseVarIndex() / 4;
- _vm->_draw->_cursorHotspotYVar = _vm->_parse->parseVarIndex() / 4;
+ _vm->_draw->_cursorHotspotXVar = _vm->_game->_script->readVarIndex() / 4;
+ _vm->_draw->_cursorHotspotYVar = _vm->_game->_script->readVarIndex() / 4;
- width = load16();
+ width = _vm->_game->_script->readInt16();
if (width < 16)
width = 16;
- height = load16();
+ height = _vm->_game->_script->readInt16();
if (height < 16)
height = 16;
_vm->_draw->adjustCoords(0, &width, &height);
- count = load16();
+ count = _vm->_game->_script->readInt16();
if (count < 2)
count = 2;
@@ -366,24 +365,24 @@
int16 ind;
_vm->_draw->_showCursor = 3;
- ind = _vm->_parse->parseValExpr();
- _vm->_draw->_cursorAnimLow[ind] = load16();
- _vm->_draw->_cursorAnimHigh[ind] = load16();
- _vm->_draw->_cursorAnimDelays[ind] = load16();
+ ind = _vm->_game->_script->readValExpr();
+ _vm->_draw->_cursorAnimLow[ind] = _vm->_game->_script->readInt16();
+ _vm->_draw->_cursorAnimHigh[ind] = _vm->_game->_script->readInt16();
+ _vm->_draw->_cursorAnimDelays[ind] = _vm->_game->_script->readInt16();
}
void Inter_v1::o1_clearCursorAnim() {
int16 ind;
_vm->_draw->_showCursor = 0;
- ind = _vm->_parse->parseValExpr();
+ ind = _vm->_game->_script->readValExpr();
_vm->_draw->_cursorAnimLow[ind] = -1;
_vm->_draw->_cursorAnimHigh[ind] = 0;
_vm->_draw->_cursorAnimDelays[ind] = 0;
}
void Inter_v1::o1_setRenderFlags() {
- _vm->_draw->_renderFlags = _vm->_parse->parseValExpr();
+ _vm->_draw->_renderFlags = _vm->_game->_script->readValExpr();
}
void Inter_v1::o1_loadAnim() {
@@ -407,7 +406,7 @@
evalExpr(&animation);
evalExpr(&layer);
evalExpr(&frame);
- flags = load16();
+ flags = _vm->_game->_script->readInt16();
_vm->_scenery->updateAnim(layer, frame, animation, flags,
deltaX, deltaY, 1);
}
@@ -424,14 +423,14 @@
oldAnimHeight = _vm->_mult->_animHeight;
oldObjCount = _vm->_mult->_objCount;
- _vm->_mult->_animLeft = load16();
- _vm->_mult->_animTop = load16();
- _vm->_mult->_animWidth = load16();
- _vm->_mult->_animHeight = load16();
- _vm->_mult->_objCount = load16();
- posXVar = _vm->_parse->parseVarIndex();
- posYVar = _vm->_parse->parseVarIndex();
- animDataVar = _vm->_parse->parseVarIndex();
+ _vm->_mult->_animLeft = _vm->_game->_script->readInt16();
+ _vm->_mult->_animTop = _vm->_game->_script->readInt16();
+ _vm->_mult->_animWidth = _vm->_game->_script->readInt16();
+ _vm->_mult->_animHeight = _vm->_game->_script->readInt16();
+ _vm->_mult->_objCount = _vm->_game->_script->readInt16();
+ posXVar = _vm->_game->_script->readVarIndex();
+ posYVar = _vm->_game->_script->readVarIndex();
+ animDataVar = _vm->_game->_script->readVarIndex();
if (_vm->_mult->_objects && (oldObjCount != _vm->_mult->_objCount)) {
@@ -464,8 +463,8 @@
uint32 offPosY = i * 4 + (posYVar / 4) * 4;
uint32 offAnim = animDataVar + i * 4 * _vm->_global->_inter_animDataSize;
- _vm->_mult->_objects[i].pPosX = new VariableReference(*_vm->_inter->_variables, offPosX);
- _vm->_mult->_objects[i].pPosY = new VariableReference(*_vm->_inter->_variables, offPosY);
+ _vm->_mult->_objects[i].pPosX = new VariableReference(*_variables, offPosX);
+ _vm->_mult->_objects[i].pPosY = new VariableReference(*_variables, offPosY);
_vm->_mult->_objects[i].pAnimData =
(Mult::Mult_AnimData *) _variables->getAddressOff8(offAnim);
@@ -528,11 +527,11 @@
multData = (byte *) _vm->_mult->_objects[objIndex].pAnimData;
for (int i = 0; i < 11; i++) {
- if (READ_LE_UINT16(_vm->_global->_inter_execPtr) != 99) {
+ if (_vm->_game->_script->peekUint16() != 99) {
evalExpr(&val);
multData[i] = val;
} else
- _vm->_global->_inter_execPtr++;
+ _vm->_game->_script->skip(1);
}
}
@@ -546,10 +545,10 @@
evalExpr(&anim);
evalExpr(&layer);
- varDX = _vm->_parse->parseVarIndex();
- varDY = _vm->_parse->parseVarIndex();
- varUnk0 = _vm->_parse->parseVarIndex();
- varFrames = _vm->_parse->parseVarIndex();
+ varDX = _vm->_game->_script->readVarIndex();
+ varDY = _vm->_game->_script->readVarIndex();
+ varUnk0 = _vm->_game->_script->readVarIndex();
+ varFrames = _vm->_game->_script->readVarIndex();
_vm->_scenery->writeAnimLayerInfo(anim, layer,
varDX, varDY, varUnk0, varFrames);
@@ -568,10 +567,10 @@
_vm->_scenery->_toRedrawLeft = MAX(_vm->_scenery->_toRedrawLeft, (int16) 0);
_vm->_scenery->_toRedrawTop = MAX(_vm->_scenery->_toRedrawTop, (int16) 0);
- WRITE_VAR_OFFSET(_vm->_parse->parseVarIndex(), _vm->_scenery->_toRedrawLeft);
- WRITE_VAR_OFFSET(_vm->_parse->parseVarIndex(), _vm->_scenery->_toRedrawTop);
- WRITE_VAR_OFFSET(_vm->_parse->parseVarIndex(), _vm->_scenery->_toRedrawRight);
- WRITE_VAR_OFFSET(_vm->_parse->parseVarIndex(), _vm->_scenery->_toRedrawBottom);
+ WRITE_VAR_OFFSET(_vm->_game->_script->readVarIndex(), _vm->_scenery->_toRedrawLeft);
+ WRITE_VAR_OFFSET(_vm->_game->_script->readVarIndex(), _vm->_scenery->_toRedrawTop);
+ WRITE_VAR_OFFSET(_vm->_game->_script->readVarIndex(), _vm->_scenery->_toRedrawRight);
+ WRITE_VAR_OFFSET(_vm->_game->_script->readVarIndex(), _vm->_scenery->_toRedrawBottom);
}
void Inter_v1::o1_loadStatic() {
@@ -586,8 +585,8 @@
int16 layer;
int16 index;
- _vm->_inter->evalExpr(&index);
- _vm->_inter->evalExpr(&layer);
+ evalExpr(&index);
+ evalExpr(&layer);
_vm->_scenery->renderStatic(index, layer);
}
@@ -599,7 +598,7 @@
void Inter_v1::o1_playCDTrack() {
evalExpr(0);
_vm->_sound->adlibPlayBgMusic(); // Mac version
- _vm->_sound->cdPlay(_vm->_parse->getResultStr()); // PC CD version
+ _vm->_sound->cdPlay(_vm->_game->_script->getResultStr()); // PC CD version
}
void Inter_v1::o1_getCDTrackPos() {
@@ -623,15 +622,15 @@
}
void Inter_v1::o1_loadFontToSprite() {
- int16 i = load16();
- _vm->_draw->_fontToSprite[i].sprite = load16();
- _vm->_draw->_fontToSprite[i].base = load16();
- _vm->_draw->_fontToSprite[i].width = load16();
- _vm->_draw->_fontToSprite[i].height = load16();
+ int16 i = _vm->_game->_script->readInt16();
+ _vm->_draw->_fontToSprite[i].sprite = _vm->_game->_script->readInt16();
+ _vm->_draw->_fontToSprite[i].base = _vm->_game->_script->readInt16();
+ _vm->_draw->_fontToSprite[i].width = _vm->_game->_script->readInt16();
+ _vm->_draw->_fontToSprite[i].height = _vm->_game->_script->readInt16();
}
void Inter_v1::o1_freeFontToSprite() {
- int16 i = load16();
+ int16 i = _vm->_game->_script->readInt16();
_vm->_draw->_fontToSprite[i].sprite = -1;
_vm->_draw->_fontToSprite[i].base = -1;
_vm->_draw->_fontToSprite[i].width = -1;
@@ -639,12 +638,12 @@
}
bool Inter_v1::o1_callSub(OpFuncParams ¶ms) {
- byte *storedIP;
uint16 offset;
- offset = load16();
- storedIP = _vm->_global->_inter_execPtr;
+ offset = _vm->_game->_script->readUint16();
+ uint32 startPos = _vm->_game->_script->pos();
+
debugC(5, kDebugGameFlow, "tot = \"%s\", offset = %d",
_vm->_game->_curTotFile, offset);
@@ -667,19 +666,20 @@
return false;
}
- _vm->_global->_inter_execPtr = _vm->_game->_totFileData + offset;
+ _vm->_game->_script->seek(offset);
if ((params.counter == params.cmdCount) && (params.retFlag == 2))
return true;
callSub(2);
- _vm->_global->_inter_execPtr = storedIP;
+ _vm->_game->_script->seek(startPos);
+
return false;
}
bool Inter_v1::o1_printTotText(OpFuncParams ¶ms) {
- _vm->_draw->printTotText(load16());
+ _vm->_draw->printTotText(_vm->_game->_script->readInt16());
return false;
}
@@ -689,8 +689,8 @@
int16 id;
int8 index;
- id = load16();
- index = (int8) *_vm->_global->_inter_execPtr++;
+ id = _vm->_game->_script->readInt16();
+ index = _vm->_game->_script->readInt8();
if ((index * _vm->_draw->_cursorWidth) >= _vm->_draw->_cursorSprites->getWidth())
return false;
@@ -710,35 +710,41 @@
}
bool Inter_v1::o1_switch(OpFuncParams ¶ms) {
- byte *callAddr;
+ uint32 offset;
- checkSwitchTable(&callAddr);
- byte *storedIP = _vm->_global->_inter_execPtr;
- _vm->_global->_inter_execPtr = callAddr;
+ checkSwitchTable(offset);
+ uint32 startPos = _vm->_game->_script->pos();
+
+ _vm->_game->_script->seek(offset);
+ if (offset == 0)
+ _vm->_game->_script->setFinished(true);
+
if ((params.counter == params.cmdCount) && (params.retFlag == 2))
return true;
funcBlock(0);
- _vm->_global->_inter_execPtr = storedIP;
+ _vm->_game->_script->seek(startPos);
return false;
}
bool Inter_v1::o1_repeatUntil(OpFuncParams ¶ms) {
- byte *blockPtr;
int16 size;
bool flag;
_nestLevel[0]++;
- blockPtr = _vm->_global->_inter_execPtr;
+ uint32 blockPos = _vm->_game->_script->pos();
+
do {
- _vm->_global->_inter_execPtr = blockPtr;
- size = READ_LE_UINT16(_vm->_global->_inter_execPtr + 2) + 2;
+ _vm->_game->_script->seek(blockPos);
+ size = _vm->_game->_script->peekUint16(2) + 2;
funcBlock(1);
- _vm->_global->_inter_execPtr = blockPtr + size + 1;
+
+ _vm->_game->_script->seek(blockPos + size + 1);
+
flag = evalBoolResult();
} while (!flag && !_break && !_terminate && !_vm->shouldQuit());
@@ -752,32 +758,31 @@
}
bool Inter_v1::o1_whileDo(OpFuncParams ¶ms) {
- byte *blockPtr;
- byte *savedIP;
bool flag;
int16 size;
_nestLevel[0]++;
do {
- savedIP = _vm->_global->_inter_execPtr;
+ uint32 startPos = _vm->_game->_script->pos();
+
flag = evalBoolResult();
if (_terminate)
return false;
- blockPtr = _vm->_global->_inter_execPtr;
+ uint32 blockPos = _vm->_game->_script->pos();
- size = READ_LE_UINT16(_vm->_global->_inter_execPtr + 2) + 2;
+ size = _vm->_game->_script->peekUint16(2) + 2;
if (flag) {
funcBlock(1);
- _vm->_global->_inter_execPtr = savedIP;
+ _vm->_game->_script->seek(startPos);
} else
- _vm->_global->_inter_execPtr += size;
+ _vm->_game->_script->skip(size);
if (_break || _terminate || _vm->shouldQuit()) {
- _vm->_global->_inter_execPtr = blockPtr;
- _vm->_global->_inter_execPtr += size;
+ _vm->_game->_script->seek(blockPos);
+ _vm->_game->_script->skip(size);
break;
}
} while (flag);
@@ -793,58 +798,52 @@
bool Inter_v1::o1_if(OpFuncParams ¶ms) {
byte cmd;
bool boolRes;
- byte *storedIP;
boolRes = evalBoolResult();
if (boolRes) {
if ((params.counter == params.cmdCount) && (params.retFlag == 2))
return true;
- storedIP = _vm->_global->_inter_execPtr;
+ uint32 startPos = _vm->_game->_script->pos();
funcBlock(0);
- _vm->_global->_inter_execPtr = storedIP;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr + 2) + 2;
+ _vm->_game->_script->seek(startPos);
- debugC(5, kDebugGameFlow, "cmd = %d",
- (int16) *_vm->_global->_inter_execPtr);
+ _vm->_game->_script->skip(_vm->_game->_script->peekUint16(2) + 2);
- cmd = *_vm->_global->_inter_execPtr >> 4;
- _vm->_global->_inter_execPtr++;
+ debugC(5, kDebugGameFlow, "cmd = %d", (int16) _vm->_game->_script->peekByte());
+
+ cmd = _vm->_game->_script->readByte() >> 4;
if (cmd != 12)
return false;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr + 2) + 2;
+ _vm->_game->_script->skip(_vm->_game->_script->peekUint16(2) + 2);
} else {
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr + 2) + 2;
+ _vm->_game->_script->skip(_vm->_game->_script->peekUint16(2) + 2);
- debugC(5, kDebugGameFlow, "cmd = %d",
- (int16) *_vm->_global->_inter_execPtr);
+ debugC(5, kDebugGameFlow, "cmd = %d", (int16) _vm->_game->_script->peekByte());
- cmd = *_vm->_global->_inter_execPtr >> 4;
- _vm->_global->_inter_execPtr++;
+ cmd = _vm->_game->_script->readByte() >> 4;
if (cmd != 12)
return false;
if ((params.counter == params.cmdCount) && (params.retFlag == 2))
return true;
- storedIP = _vm->_global->_inter_execPtr;
+ uint32 startPos = _vm->_game->_script->pos();
+
funcBlock(0);
- _vm->_global->_inter_execPtr = storedIP;
- _vm->_global->_inter_execPtr +=
- READ_LE_UINT16(_vm->_global->_inter_execPtr + 2) + 2;
+ _vm->_game->_script->seek(startPos);
+
+ _vm->_game->_script->skip(_vm->_game->_script->peekUint16(2) + 2);
}
return false;
}
bool Inter_v1::o1_assign(OpFuncParams ¶ms) {
- byte destType = *_vm->_global->_inter_execPtr;
- int16 dest = _vm->_parse->parseVarIndex();
+ byte destType = _vm->_game->_script->peekByte();
+ int16 dest = _vm->_game->_script->readVarIndex();
int16 result;
int16 srcType = evalExpr(&result);
@@ -852,7 +851,7 @@
switch (destType) {
case TYPE_VAR_INT32:
case TYPE_ARRAY_INT32:
- WRITE_VAR_OFFSET(dest, _vm->_parse->getResultInt());
+ WRITE_VAR_OFFSET(dest, _vm->_game->_script->getResultInt());
break;
case TYPE_VAR_STR:
@@ -860,7 +859,7 @@
if (srcType == TYPE_IMM_INT16)
WRITE_VARO_UINT8(dest, result);
else
- WRITE_VARO_STR(dest, _vm->_parse->getResultStr());
+ WRITE_VARO_STR(dest, _vm->_game->_script->getResultStr());
break;
}
@@ -868,17 +867,17 @@
}
bool Inter_v1::o1_loadSpriteToPos(OpFuncParams ¶ms) {
- _vm->_draw->_spriteLeft = load16();
+ _vm->_draw->_spriteLeft = _vm->_game->_script->readInt16();
- _vm->_draw->_destSpriteX = _vm->_parse->parseValExpr();
- _vm->_draw->_destSpriteY = _vm->_parse->parseValExpr();
+ _vm->_draw->_destSpriteX = _vm->_game->_script->readValExpr();
+ _vm->_draw->_destSpriteY = _vm->_game->_script->readValExpr();
- _vm->_draw->_transparency = *_vm->_global->_inter_execPtr & 1;
- _vm->_draw->_destSurface = ((int16) (*_vm->_global->_inter_execPtr >> 1)) - 1;
+ _vm->_draw->_transparency = _vm->_game->_script->peekByte() & 1;
+ _vm->_draw->_destSurface = ((int16) (_vm->_game->_script->peekByte() >> 1)) - 1;
if (_vm->_draw->_destSurface < 0)
_vm->_draw->_destSurface = 101;
- _vm->_global->_inter_execPtr += 2;
+ _vm->_game->_script->skip(2);
_vm->_draw->spriteOperation(DRAW_LOADSPRITE);
@@ -889,12 +888,12 @@
char buf[60];
int i;
- _vm->_draw->_destSpriteX = _vm->_parse->parseValExpr();
- _vm->_draw->_destSpriteY = _vm->_parse->parseValExpr();
+ _vm->_draw->_destSpriteX = _vm->_game->_script->readValExpr();
+ _vm->_draw->_destSpriteY = _vm->_game->_script->readValExpr();
- _vm->_draw->_backColor = _vm->_parse->parseValExpr();
- _vm->_draw->_frontColor = _vm->_parse->parseValExpr();
- _vm->_draw->_fontIndex = _vm->_parse->parseValExpr();
+ _vm->_draw->_backColor = _vm->_game->_script->readValExpr();
+ _vm->_draw->_frontColor = _vm->_game->_script->readValExpr();
+ _vm->_draw->_fontIndex = _vm->_game->_script->readValExpr();
_vm->_draw->_destSurface = 21;
_vm->_draw->_textToPrint = buf;
_vm->_draw->_transparency = 0;
@@ -905,35 +904,35 @@
}
do {
- for (i = 0; (((char) *_vm->_global->_inter_execPtr) != '.') &&
- (*_vm->_global->_inter_execPtr != 200);
- i++, _vm->_global->_inter_execPtr++) {
- buf[i] = (char) *_vm->_global->_inter_execPtr;
+ for (i = 0; ((_vm->_game->_script->peekChar()) != '.') &&
+ (_vm->_game->_script->peekByte() != 200);
+ i++, _vm->_game->_script->skip(1)) {
+ buf[i] = _vm->_game->_script->peekChar();
}
- if (*_vm->_global->_inter_execPtr != 200) {
- _vm->_global->_inter_execPtr++;
- switch (*_vm->_global->_inter_execPtr) {
+ if (_vm->_game->_script->peekByte() != 200) {
+ _vm->_game->_script->skip(1);
+ switch (_vm->_game->_script->peekByte()) {
case TYPE_VAR_INT32:
case TYPE_ARRAY_INT32:
sprintf(buf + i, "%d",
- VAR_OFFSET(_vm->_parse->parseVarIndex()));
+ VAR_OFFSET(_vm->_game->_script->readVarIndex()));
break;
case TYPE_VAR_STR:
case TYPE_ARRAY_STR:
sprintf(buf + i, "%s",
- GET_VARO_STR(_vm->_parse->parseVarIndex()));
+ GET_VARO_STR(_vm->_game->_script->readVarIndex()));
break;
}
- _vm->_global->_inter_execPtr++;
+ _vm->_game->_script->skip(1);
} else
buf[i] = 0;
_vm->_draw->spriteOperation(DRAW_PRINTTEXT);
- } while (*_vm->_global->_inter_execPtr != 200);
+ } while (_vm->_game->_script->peekByte() != 200);
- _vm->_global->_inter_execPtr++;
+ _vm->_game->_script->skip(1);
return false;
}
@@ -942,16 +941,14 @@
char buf[20];
int8 size;
- if ((*_vm->_global->_inter_execPtr & 0x80) != 0) {
- _vm->_global->_inter_execPtr++;
+ if ((_vm->_game->_script->peekByte() & 0x80) != 0) {
+ _vm->_game->_script->skip(1);
evalExpr(0);
- strncpy0(buf, _vm->_parse->getResultStr(), 15);
+ strncpy0(buf, _vm->_game->_script->getResultStr(), 15);
} else {
- size = (int8) *_vm->_global->_inter_execPtr++;
- for (int i = 0; i < size; i++)
- buf[i] = *_vm->_global->_inter_execPtr++;
-
- buf[size] = 0;
+ size = _vm->_game->_script->readInt8();
+ memcpy(buf, _vm->_game->_script->readString(size), size);
+ buf[size] = '\0';
}
// if (_vm->getGameType() == kGameTypeGeisha)
@@ -971,12 +968,12 @@
byte *palPtr;
byte cmd;
- cmd = *_vm->_global->_inter_execPtr++;
+ cmd = _vm->_game->_script->readByte();
switch (cmd & 0x7F) {
case 48:
if ((_vm->_global->_fakeVideoMode < 0x32) ||
(_vm->_global->_fakeVideoMode > 0x63)) {
- _vm->_global->_inter_execPtr += 48;
+ _vm->_game->_script->skip(48);
return false;
}
break;
@@ -984,35 +981,35 @@
case 49:
if ((_vm->_global->_fakeVideoMode != 5) &&
(_vm->_global->_fakeVideoMode != 7)) {
- _vm->_global->_inter_execPtr += 18;
+ _vm->_game->_script->skip(18);
return false;
}
break;
case 50:
if (_vm->_global->_colorCount == 256) {
- _vm->_global->_inter_execPtr += 16;
+ _vm->_game->_script->skip(16);
return false;
}
break;
case 51:
if (_vm->_global->_fakeVideoMode < 0x64) {
- _vm->_global->_inter_execPtr += 2;
+ _vm->_game->_script->skip(2);
return false;
}
break;
case 52:
if (_vm->_global->_colorCount == 256) {
- _vm->_global->_inter_execPtr += 48;
+ _vm->_game->_script->skip(48);
return false;
}
break;
case 53:
if (_vm->_global->_colorCount != 256) {
- _vm->_global->_inter_execPtr += 2;
+ _vm->_game->_script->skip(2);
return false;
}
break;
@@ -1025,14 +1022,14 @@
case 61:
if (_vm->_global->_fakeVideoMode < 0x13) {
- _vm->_global->_inter_execPtr += 4;
+ _vm->_game->_script->skip(4);
return false;
}
break;
}
if ((cmd & 0x7F) == 0x30) {
- _vm->_global->_inter_execPtr += 48;
+ _vm->_game->_script->skip(48);
return false;
}
@@ -1043,7 +1040,7 @@
bool allZero = true;
for (int i = 2; i < 18; i++) {
- if (_vm->_global->_inter_execPtr[i] != 0) {
+ if (_vm->_game->_script->peekByte(i) != 0) {
allZero = false;
break;
}
@@ -1051,28 +1048,30 @@
if (!allZero) {
_vm->_video->clearSurf(*_vm->_draw->_frontSurface);
_vm->_draw->_noInvalidated57 = true;
- _vm->_global->_inter_execPtr += 18;
+ _vm->_game->_script->skip(48);
return false;
}
_vm->_draw->_noInvalidated57 = false;
- for (int i = 0; i < 18; i++, _vm->_global->_inter_execPtr++) {
+ for (int i = 0; i < 18; i++) {
if (i < 2) {
if (!_vm->_draw->_applyPal)
continue;
- _vm->_draw->_unusedPalette1[i] = *_vm->_global->_inter_execPtr;
+ _vm->_draw->_unusedPalette1[i] = _vm->_game->_script->peekByte();
continue;
}
- index1 = *_vm->_global->_inter_execPtr >> 4;
- index2 = (*_vm->_global->_inter_execPtr & 0xF);
+ index1 = _vm->_game->_script->peekByte() >> 4;
+ index2 = _vm->_game->_script->peekByte() & 0xF;
_vm->_draw->_unusedPalette1[i] =
((_vm->_draw->_palLoadData1[index1] +
_vm->_draw->_palLoadData2[index2]) << 8) +
(_vm->_draw->_palLoadData2[index1] +
_vm->_draw->_palLoadData1[index2]);
+
+ _vm->_game->_script->skip(1);
}
_vm->_global->_pPaletteDesc->unused1 = _vm->_draw->_unusedPalette1;
@@ -1082,20 +1081,20 @@
switch (cmd) {
case 50:
- for (int i = 0; i < 16; i++, _vm->_global->_inter_execPtr++)
- _vm->_draw->_unusedPalette2[i] = *_vm->_global->_inter_execPtr;
+ for (int i = 0; i < 16; i++)
+ _vm->_draw->_unusedPalette2[i] = _vm->_game->_script->readByte();
break;
case 52:
- for (int i = 0; i < 16; i++, _vm->_global->_inter_execPtr += 3) {
- _vm->_draw->_vgaPalette[i].red = _vm->_global->_inter_execPtr[0];
- _vm->_draw->_vgaPalette[i].green = _vm->_global->_inter_execPtr[1];
- _vm->_draw->_vgaPalette[i].blue = _vm->_global->_inter_execPtr[2];
+ for (int i = 0; i < 16; i++) {
+ _vm->_draw->_vgaPalette[i].red = _vm->_game->_script->readByte();
+ _vm->_draw->_vgaPalette[i].green = _vm->_game->_script->readByte();
+ _vm->_draw->_vgaPalette[i].blue = _vm->_game->_script->readByte();
}
break;
case 53:
- palPtr = _vm->_game->loadTotResource(_vm->_inter->load16());
+ palPtr = _vm->_game->loadTotResource(_vm->_game->_script->readInt16());
memcpy((char *) _vm->_draw->_vgaPalette, palPtr, 768);
break;
@@ -1104,9 +1103,9 @@
break;
case 61:
- index1 = *_vm->_global->_inter_execPtr++;
- index2 = (*_vm->_global->_inter_execPtr++ - index1 + 1) * 3;
- palPtr = _vm->_game->loadTotResource(_vm->_inter->load16());
+ index1 = _vm->_game->_script->readByte();
+ index2 = (_vm->_game->_script->readByte() - index1 + 1) * 3;
+ palPtr = _vm->_game->loadTotResource(_vm->_game->_script->readInt16());
memcpy((char *) _vm->_draw->_vgaPalette + index1 * 3,
palPtr + index1 * 3, index2);
@@ -1146,7 +1145,7 @@
int16 key;
uint32 now;
- cmd = load16();
+ cmd = _vm->_game->_script->readInt16();
animPalette();
_vm->_draw->blitInvalidated();
@@ -1161,7 +1160,7 @@
// to become 5000. We deliberately slow down busy-waiting, so we shorten
// the counting, too.
if ((_vm->getGameType() == kGameTypeWeen) && (VAR(59) < 4000) &&
- ((_vm->_global->_inter_execPtr - _vm->_game->_totFileData) == 729) &&
+ (_vm->_game->_script->pos() == 729) &&
!scumm_stricmp(_vm->_game->_curTotFile, "intro5.tot"))
WRITE_VAR(59, 4000);
@@ -1207,10 +1206,10 @@
int16 left, top;
int16 width, height;
- left = _vm->_parse->parseValExpr();
- top = _vm->_parse->parseValExpr();
- width = _vm->_parse->parseValExpr();
- height = _vm->_parse->parseValExpr();
+ left = _vm->_game->_script->readValExpr();
+ top = _vm->_game->_script->readValExpr();
+ width = _vm->_game->_script->readValExpr();
+ height = _vm->_game->_script->readValExpr();
if ((width < 0) || (height < 0))
return false;
@@ -1229,16 +1228,16 @@
}
bool Inter_v1::o1_animPalInit(OpFuncParams ¶ms) {
- _animPalDir[0] = load16();
- _animPalLowIndex[0] = _vm->_parse->parseValExpr();
- _animPalHighIndex[0] = _vm->_parse->parseValExpr();
+ _animPalDir[0] = _vm->_game->_script->readInt16();
+ _animPalLowIndex[0] = _vm->_game->_script->readValExpr();
+ _animPalHighIndex[0] = _vm->_game->_script->readValExpr();
return false;
}
bool Inter_v1::o1_drawOperations(OpFuncParams ¶ms) {
byte cmd;
- cmd = *_vm->_global->_inter_execPtr++;
+ cmd = _vm->_game->_script->readByte();
executeOpcodeDraw(cmd);
@@ -1246,7 +1245,7 @@
}
bool Inter_v1::o1_setcmdCount(OpFuncParams ¶ms) {
- params.cmdCount = *_vm->_global->_inter_execPtr++;
+ params.cmdCount = _vm->_game->_script->readByte();
params.counter = 0;
return false;
}
@@ -1255,7 +1254,7 @@
if (params.retFlag != 2)
_break = true;
- _vm->_global->_inter_execPtr = 0;
+ _vm->_game->_script->setFinished(true);
return true;
}
@@ -1265,7 +1264,7 @@
}
bool Inter_v1::o1_speakerOn(OpFuncParams ¶ms) {
- _vm->_sound->speakerOn(_vm->_parse->parseValExpr(), -1);
+ _vm->_sound->speakerOn(_vm->_game->_script->readValExpr(), -1);
return false;
}
@@ -1275,11 +1274,11 @@
}
bool Inter_v1::o1_putPixel(OpFuncParams ¶ms) {
- _vm->_draw->_destSurface = load16();
+ _vm->_draw->_destSurface = _vm->_game->_script->readInt16();
- _vm->_draw->_destSpriteX = _vm->_parse->parseValExpr();
- _vm->_draw->_destSpriteY = _vm->_parse->parseValExpr();
- _vm->_draw->_frontColor = _vm->_parse->parseValExpr();
+ _vm->_draw->_destSpriteX = _vm->_game->_script->readValExpr();
+ _vm->_draw->_destSpriteY = _vm->_game->_script->readValExpr();
+ _vm->_draw->_frontColor = _vm->_game->_script->readValExpr();
_vm->_draw->spriteOperation(DRAW_PUTPIXEL);
return false;
}
@@ -1291,33 +1290,33 @@
gobParams.extraData = 0;
gobParams.objDesc = 0;
- gobParams.retVarPtr.set(*_vm->_inter->_variables, 236);
+ gobParams.retVarPtr.set(*_variables, 236);
- cmd = load16();
- _vm->_global->_inter_execPtr += 2;
+ cmd = _vm->_game->_script->readInt16();
+ _vm->_game->_script->skip(2);
if ((cmd > 0) && (cmd < 17)) {
objDescSet = true;
- gobParams.extraData = load16();
+ gobParams.extraData = _vm->_game->_script->readInt16();
gobParams.objDesc = _vm->_goblin->_objects[gobParams.extraData];
- gobParams.extraData = load16();
+ gobParams.extraData = _vm->_game->_script->readInt16();
}
if ((cmd > 90) && (cmd < 107)) {
objDescSet = true;
- gobParams.extraData = load16();
+ gobParams.extraData = _vm->_game->_script->readInt16();
gobParams.objDesc = _vm->_goblin->_goblins[gobParams.extraData];
- gobParams.extraData = load16();
+ gobParams.extraData = _vm->_game->_script->readInt16();
cmd -= 90;
}
if ((cmd > 110) && (cmd < 128)) {
objDescSet = true;
- gobParams.extraData = load16();
+ gobParams.extraData = _vm->_game->_script->readInt16();
gobParams.objDesc = _vm->_goblin->_goblins[gobParams.extraData];
cmd -= 90;
} else if ((cmd > 20) && (cmd < 38)) {
objDescSet = true;
- gobParams.extraData = load16();
+ gobParams.extraData = _vm->_game->_script->readInt16();
gobParams.objDesc = _vm->_goblin->_objects[gobParams.extraData];
}
@@ -1343,31 +1342,31 @@
int16 width, height;
int16 flag;
- if (_vm->_global->_inter_execPtr[1] == 0) {
- index = load16();
- width = load16();
- height = load16();
+ if (_vm->_game->_script->peekByte(1) == 0) {
+ index = _vm->_game->_script->readInt16();
+ width = _vm->_game->_script->readInt16();
+ height = _vm->_game->_script->readInt16();
} else {
- index = _vm->_parse->parseValExpr();
- width = _vm->_parse->parseValExpr();
- height = _vm->_parse->parseValExpr();
+ index = _vm->_game->_script->readValExpr();
+ width = _vm->_game->_script->readValExpr();
+ height = _vm->_game->_script->readValExpr();
}
- flag = load16();
+ flag = _vm->_game->_script->readInt16();
_vm->_draw->initSpriteSurf(index, width, height, flag ? 2 : 0);
return false;
}
bool Inter_v1::o1_freeSprite(OpFuncParams ¶ms) {
- _vm->_draw->freeSprite(load16());
+ _vm->_draw->freeSprite(_vm->_game->_script->readInt16());
return false;
}
bool Inter_v1::o1_returnTo(OpFuncParams ¶ms) {
if (params.retFlag == 1) {
_break = true;
- _vm->_global->_inter_execPtr = 0;
+ _vm->_game->_script->setFinished(true);
return true;
}
@@ -1376,14 +1375,14 @@
*_breakFromLevel = *_nestLevel;
_break = true;
- _vm->_global->_inter_execPtr = 0;
+ _vm->_game->_script->setFinished(true);
return true;
}
bool Inter_v1::o1_loadSpriteContent(OpFuncParams ¶ms) {
- _vm->_draw->_spriteLeft = load16();
- _vm->_draw->_destSurface = load16();
- _vm->_draw->_transparency = load16();
+ _vm->_draw->_spriteLeft = _vm->_game->_script->readInt16();
+ _vm->_draw->_destSurface = _vm->_game->_script->readInt16();
+ _vm->_draw->_transparency = _vm->_game->_script->readInt16();
_vm->_draw->_destSpriteX = 0;
_vm->_draw->_destSpriteY = 0;
@@ -1392,25 +1391,25 @@
}
bool Inter_v1::o1_copySprite(OpFuncParams ¶ms) {
- if (_vm->_global->_inter_execPtr[1] == 0)
- _vm->_draw->_sourceSurface = load16();
+ if (_vm->_game->_script->peekByte(1) == 0)
+ _vm->_draw->_sourceSurface = _vm->_game->_script->readInt16();
else
- _vm->_draw->_sourceSurface = _vm->_parse->parseValExpr();
+ _vm->_draw->_sourceSurface = _vm->_game->_script->readValExpr();
- if (_vm->_global->_inter_execPtr[1] == 0)
- _vm->_draw->_destSurface = load16();
+ if (_vm->_game->_script->peekByte(1) == 0)
+ _vm->_draw->_destSurface = _vm->_game->_script->readInt16();
else
- _vm->_draw->_destSurface = _vm->_parse->parseValExpr();
+ _vm->_draw->_destSurface = _vm->_game->_script->readValExpr();
- _vm->_draw->_spriteLeft = _vm->_parse->parseValExpr();
- _vm->_draw->_spriteTop = _vm->_parse->parseValExpr();
- _vm->_draw->_spriteRight = _vm->_parse->parseValExpr();
- _vm->_draw->_spriteBottom = _vm->_parse->parseValExpr();
+ _vm->_draw->_spriteLeft = _vm->_game->_script->readValExpr();
+ _vm->_draw->_spriteTop = _vm->_game->_script->readValExpr();
+ _vm->_draw->_spriteRight = _vm->_game->_script->readValExpr();
+ _vm->_draw->_spriteBottom = _vm->_game->_script->readValExpr();
- _vm->_draw->_destSpriteX = _vm->_parse->parseValExpr();
- _vm->_draw->_destSpriteY = _vm->_parse->parseValExpr();
+ _vm->_draw->_destSpriteX = _vm->_game->_script->readValExpr();
+ _vm->_draw->_destSpriteY = _vm->_game->_script->readValExpr();
- _vm->_draw->_transparency = load16();
+ _vm->_draw->_transparency = _vm->_game->_script->readInt16();
_vm->_draw->spriteOperation(DRAW_BLITSURF);
return false;
@@ -1419,14 +1418,14 @@
bool Inter_v1::o1_fillRect(OpFuncParams ¶ms) {
int16 destSurf;
- _vm->_draw->_destSurface = destSurf = load16();
+ _vm->_draw->_destSurface = destSurf = _vm->_game->_script->readInt16();
- _vm->_draw->_destSpriteX = _vm->_parse->parseValExpr();
- _vm->_draw->_destSpriteY = _vm->_parse->parseValExpr();
- _vm->_draw->_spriteRight = _vm->_parse->parseValExpr();
- _vm->_draw->_spriteBottom = _vm->_parse->parseValExpr();
+ _vm->_draw->_destSpriteX = _vm->_game->_script->readValExpr();
+ _vm->_draw->_destSpriteY = _vm->_game->_script->readValExpr();
+ _vm->_draw->_spriteRight = _vm->_game->_script->readValExpr();
+ _vm->_draw->_spriteBottom = _vm->_game->_script->readValExpr();
- _vm->_draw->_backColor = _vm->_parse->parseValExpr();
+ _vm->_draw->_backColor = _vm->_game->_script->readValExpr();
if (!_vm->_draw->_spritesArray[(destSurf >= 100) ? (destSurf - 80) : destSurf])
return false;
@@ -1445,14 +1444,14 @@
}
bool Inter_v1::o1_drawLine(OpFuncParams ¶ms) {
- _vm->_draw->_destSurface = load16();
+ _vm->_draw->_destSurface = _vm->_game->_script->readInt16();
- _vm->_draw->_destSpriteX = _vm->_parse->parseValExpr();
- _vm->_draw->_destSpriteY = _vm->_parse->parseValExpr();
- _vm->_draw->_spriteRight = _vm->_parse->parseValExpr();
- _vm->_draw->_spriteBottom = _vm->_parse->parseValExpr();
+ _vm->_draw->_destSpriteX = _vm->_game->_script->readValExpr();
+ _vm->_draw->_destSpriteY = _vm->_game->_script->readValExpr();
+ _vm->_draw->_spriteRight = _vm->_game->_script->readValExpr();
+ _vm->_draw->_spriteBottom = _vm->_game->_script->readValExpr();
- _vm->_draw->_frontColor = _vm->_parse->parseValExpr();
+ _vm->_draw->_frontColor = _vm->_game->_script->readValExpr();
_vm->_draw->spriteOperation(DRAW_DRAWLINE);
return false;
}
@@ -1463,28 +1462,28 @@
int16 destVar;
int32 res;
- strVar = _vm->_parse->parseVarIndex();
+ strVar = _vm->_game->_script->readVarIndex();
strncpy0(str, GET_VARO_STR(strVar), 19);
res = atoi(str);
- destVar = _vm->_parse->parseVarIndex();
+ destVar = _vm->_game->_script->readVarIndex();
WRITE_VAR_OFFSET(destVar, res);
return false;
}
bool Inter_v1::o1_invalidate(OpFuncParams ¶ms) {
- _vm->_draw->_destSurface = load16();
- _vm->_draw->_destSpriteX = _vm->_parse->parseValExpr();
- _vm->_draw->_destSpriteY = _vm->_parse->parseValExpr();
- _vm->_draw->_spriteRight = _vm->_parse->parseValExpr();
- _vm->_draw->_frontColor = _vm->_parse->parseValExpr();
+ _vm->_draw->_destSurface = _vm->_game->_script->readInt16();
+ _vm->_draw->_destSpriteX = _vm->_game->_script->readValExpr();
+ _vm->_draw->_destSpriteY = _vm->_game->_script->readValExpr();
+ _vm->_draw->_spriteRight = _vm->_game->_script->readValExpr();
+ _vm->_draw->_frontColor = _vm->_game->_script->readValExpr();
_vm->_draw->spriteOperation(DRAW_INVALIDATE);
return false;
}
bool Inter_v1::o1_setBackDelta(OpFuncParams ¶ms) {
- _vm->_draw->_backDeltaX = _vm->_parse->parseValExpr();
- _vm->_draw->_backDeltaY = _vm->_parse->parseValExpr();
+ _vm->_draw->_backDeltaX = _vm->_game->_script->readValExpr();
+ _vm->_draw->_backDeltaY = _vm->_game->_script->readValExpr();
return false;
}
@@ -1495,9 +1494,9 @@
int16 index;
int16 endRep;
- index = _vm->_parse->parseValExpr();
- repCount = _vm->_parse->parseValExpr();
- frequency = _vm->_parse->parseValExpr();
+ index = _vm->_game->_script->readValExpr();
+ repCount = _vm->_game->_script->readValExpr();
+ frequency = _vm->_game->_script->readValExpr();
SoundDesc *sample = _vm->_sound->sampleGetBySlot(index);
@@ -1533,7 +1532,7 @@
bool Inter_v1::o1_stopSound(OpFuncParams ¶ms) {
_vm->_sound->adlibStop();
- _vm->_sound->blasterStop(_vm->_parse->parseValExpr());
+ _vm->_sound->blasterStop(_vm->_game->_script->readValExpr());
_soundEndTimeKey = 0;
return false;
@@ -1559,8 +1558,8 @@
int16 dataVar;
int16 freqVal;
- dataVar = _vm->_parse->parseVarIndex();
- freqVal = _vm->_parse->parseValExpr();
+ dataVar = _vm->_game->_script->readVarIndex();
+ freqVal = _vm->_game->_script->readValExpr();
for (int i = 0; i < 50; i++)
composition[i] = (int16) VAR_OFFSET(dataVar + i * 4);
@@ -1572,8 +1571,8 @@
int16 freeVar;
int16 maxFreeVar;
- freeVar = _vm->_parse->parseVarIndex();
- maxFreeVar = _vm->_parse->parseVarIndex();
+ freeVar = _vm->_game->_script->readVarIndex();
+ maxFreeVar = _vm->_game->_script->readVarIndex();
// HACK
WRITE_VAR_OFFSET(freeVar, 1000000);
@@ -1586,21 +1585,21 @@
int16 varOff;
evalExpr(0);
- varOff = _vm->_parse->parseVarIndex();
- handle = _vm->_dataIO->openData(_vm->_parse->getResultStr());
+ varOff = _vm->_game->_script->readVarIndex();
+ handle = _vm->_dataIO->openData(_vm->_game->_script->getResultStr());
WRITE_VAR_OFFSET(varOff, handle);
if (handle >= 0)
_vm->_dataIO->closeData(handle);
else
- warning("File \"%s\" not found", _vm->_parse->getResultStr());
+ warning("File \"%s\" not found", _vm->_game->_script->getResultStr());
return false;
}
bool Inter_v1::o1_prepareStr(OpFuncParams ¶ms) {
int16 strVar;
- strVar = _vm->_parse->parseVarIndex();
+ strVar = _vm->_game->_script->readVarIndex();
_vm->_util->prepareStr(GET_VARO_FSTR(strVar));
return false;
}
@@ -1609,12 +1608,12 @@
int16 pos;
int16 strVar;
- strVar = _vm->_parse->parseVarIndex();
+ strVar = _vm->_game->_script->readVarIndex();
evalExpr(0);
- pos = _vm->_parse->parseValExpr();
+ pos = _vm->_game->_script->readValExpr();
char *str = GET_VARO_FSTR(strVar);
- _vm->_util->insertStr(_vm->_parse->getResultStr(), str, pos);
+ _vm->_util->insertStr(_vm->_game->_script->getResultStr(), str, pos);
return false;
}
@@ -1623,9 +1622,9 @@
int16 pos;
int16 size;
- strVar = _vm->_parse->parseVarIndex();
- pos = _vm->_parse->parseValExpr();
- size = _vm->_parse->parseValExpr();
+ strVar = _vm->_game->_script->readVarIndex();
+ pos = _vm->_game->_script->readValExpr();
+ size = _vm->_game->_script->readValExpr();
_vm->_util->cutFromStr(GET_VARO_STR(strVar), pos, size);
return false;
}
@@ -1635,11 +1634,11 @@
int16 resVar;
int16 pos;
- strVar = _vm->_parse->parseVarIndex();
+ strVar = _vm->_game->_script->readVarIndex();
evalExpr(0);
- resVar = _vm->_parse->parseVarIndex();
+ resVar = _vm->_game->_script->readVarIndex();
- char *res = strstr(GET_VARO_STR(strVar), _vm->_parse->getResultStr());
+ char *res = strstr(GET_VARO_STR(strVar), _vm->_game->_script->getResultStr());
pos = res ? (res - (GET_VARO_STR(strVar))) : -1;
WRITE_VAR_OFFSET(resVar, pos);
return false;
@@ -1649,17 +1648,17 @@
int16 len;
int16 strVar;
@@ Diff output truncated at 100000 characters. @@
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