aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2012-04-11 15:58:41 +0200
committerEugene Sandulenko2018-03-28 17:36:57 +0200
commit58dc875b2eecc2ba0482951c7c4a0df0102e7717 (patch)
treed0c4b21e07745c118c44f4b136cd2c891f307b24 /engines
parenta5271f541817506f33779bc57b76d564ab2773f4 (diff)
downloadscummvm-rg350-58dc875b2eecc2ba0482951c7c4a0df0102e7717.tar.gz
scummvm-rg350-58dc875b2eecc2ba0482951c7c4a0df0102e7717.tar.bz2
scummvm-rg350-58dc875b2eecc2ba0482951c7c4a0df0102e7717.zip
LILLIPUT: Start game scripts
Diffstat (limited to 'engines')
-rw-r--r--engines/lilliput/lilliput.cpp48
-rw-r--r--engines/lilliput/lilliput.h11
-rw-r--r--engines/lilliput/script.h3
3 files changed, 52 insertions, 10 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp
index 65ec0c940c..5465086363 100644
--- a/engines/lilliput/lilliput.cpp
+++ b/engines/lilliput/lilliput.cpp
@@ -126,6 +126,9 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
_rulesBuffer2PrevIndx = 0;
_word16EFA = 0;
_word10804 = 0;
+ _word17081_nextIndex = 0;
+ _word16EFE = 0xFFFF;
+ _word1817B = 0;
_saveFlag = false;
_byte16F07_menuId = 0;
@@ -133,6 +136,7 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
for (int i = 0; i < 40; i++) {
_byte10999[i] = 0;
_byte109C1[i] = 0;
+ _array11D49[i] = 0xFFFF;
}
}
@@ -344,15 +348,18 @@ void LilliputEngine::loadRules() {
_menuScript[i] = f.readByte();
// Chunk 7 & 8
- _rulesChunk7_size = f.readUint16LE();
- _rulesChunk7 = (int *)malloc(sizeof(int) * _rulesChunk7_size);
- for (int i = 0; i < _rulesChunk7_size; ++i)
- _rulesChunk7[i] = f.readUint16LE();
+ _gameScriptIndexSize = f.readUint16LE();
+ // Added one position to keep the total size too, as it's useful later
+ _arrayGameScriptIndex = (int *)malloc(sizeof(int) * (_gameScriptIndexSize + 1));
+ for (int i = 0; i < _gameScriptIndexSize; ++i)
+ _arrayGameScriptIndex[i] = f.readUint16LE();
curWord = f.readUint16LE();
- _rulesChunk8 = (byte *)malloc(sizeof(byte) * curWord);
+ _arrayGameScriptIndex[_gameScriptIndexSize] = curWord;
+
+ _arrayGameScripts = (byte *)malloc(sizeof(byte) * curWord);
for (int i = 0; i < curWord; ++i)
- _rulesChunk8[i] = f.readByte();
+ _arrayGameScripts[i] = f.readByte();
// Chunk 9
for (int i = 0; i < 60; i++)
@@ -496,6 +503,35 @@ void LilliputEngine::handleMenu() {
void LilliputEngine::sub17083() {
warning("sub17083");
+ int index = _word17081_nextIndex;
+ int i;
+ for (i = 0; (_scriptHandler->_array10B29[index] == 0) && (i < _word10807_ERULES); i++) {
+ ++index;
+ if (index >= _word10807_ERULES)
+ index = 0;
+ }
+
+ if (i >= _word10807_ERULES)
+ return;
+
+ _scriptHandler->_array10B29[index] = 0;
+ int tmpVal = index + 1;
+ if (tmpVal >= _word10807_ERULES)
+ tmpVal = 0;
+
+ _word17081_nextIndex = tmpVal;
+ sub170EE(index);
+
+ _word16EFE = _array11D49[index];
+ _array11D49[index] = 0xFFFF;
+ _word1817B = 0;
+
+ tmpVal = _rulesBuffer2_12[index];
+ if (tmpVal == 0xFF)
+ return;
+
+ assert(tmpVal < _gameScriptIndexSize);
+ _scriptHandler->runScript(Common::MemoryReadStream(&_arrayGameScripts[_arrayGameScriptIndex[tmpVal]], _arrayGameScriptIndex[tmpVal + 1] - _arrayGameScriptIndex[tmpVal]));
}
Common::Error LilliputEngine::run() {
diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h
index 4d88d4b6f5..0280f6762d 100644
--- a/engines/lilliput/lilliput.h
+++ b/engines/lilliput/lilliput.h
@@ -106,6 +106,11 @@ public:
int _word10800_ERULES;
int _word10807_ERULES;
int _word16EFA;
+ int _word17081_nextIndex;
+ int _word16EFE;
+ int _word1817B;
+
+ int _array11D49[40];
byte *_rulesChunk1;
int _rulesBuffer2PrevIndx;
@@ -133,9 +138,9 @@ public:
int _initScript_size;
byte *_menuScript;
int _menuScript_size;
- int *_rulesChunk7;
- int _rulesChunk7_size;
- byte *_rulesChunk8;
+ int *_arrayGameScriptIndex;
+ int _gameScriptIndexSize;
+ byte *_arrayGameScripts;
byte _rulesChunk9[60];
int _rulesChunk10_size;
int *_rulesChunk10;
diff --git a/engines/lilliput/script.h b/engines/lilliput/script.h
index 4d0f0b5ae3..d8a87768af 100644
--- a/engines/lilliput/script.h
+++ b/engines/lilliput/script.h
@@ -30,6 +30,8 @@ namespace Lilliput {
class LilliputEngine;
class LilliputScript {
public:
+ byte _array10B29[40];
+
LilliputScript(LilliputEngine *vm);
~LilliputScript();
@@ -53,7 +55,6 @@ private:
byte *_savedBuffer215Ptr;
byte _array122E9[20];
byte _array122FD[20];
- byte _array10B29[40];
byte _array128EF[40];
int16 _word1881B;