aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2012-04-06 22:45:43 +0200
committerEugene Sandulenko2018-03-28 17:36:57 +0200
commit53518bc6770e1b09211b8e2846f8655890f70a2b (patch)
tree152c0c12541caa17ad21a9d93c7b32fbe54b26c2 /engines
parent17320cadb759c996446b34813eeff13a50b6ab56 (diff)
downloadscummvm-rg350-53518bc6770e1b09211b8e2846f8655890f70a2b.tar.gz
scummvm-rg350-53518bc6770e1b09211b8e2846f8655890f70a2b.tar.bz2
scummvm-rg350-53518bc6770e1b09211b8e2846f8655890f70a2b.zip
LILLIPUT: Fix a couple of bugs in handleOpcode()
Diffstat (limited to 'engines')
-rw-r--r--engines/lilliput/lilliput.cpp3
-rw-r--r--engines/lilliput/lilliput.h7
-rw-r--r--engines/lilliput/script.cpp88
-rw-r--r--engines/lilliput/script.h13
4 files changed, 85 insertions, 26 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp
index e62e4c8535..7192628978 100644
--- a/engines/lilliput/lilliput.cpp
+++ b/engines/lilliput/lilliput.cpp
@@ -55,7 +55,8 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
_rnd = 0;
_scriptHandler = new LilliputScript(this);
- _vm_byte1714E = 0;
+ _byte1714E = 0;
+ _rulesBuffer2PrevIndx = 0;
}
LilliputEngine::~LilliputEngine() {
diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h
index 389a20da2d..23f5ae0b09 100644
--- a/engines/lilliput/lilliput.h
+++ b/engines/lilliput/lilliput.h
@@ -86,7 +86,7 @@ public:
LilliputScript *_scriptHandler;
struct18560 _arr18560[4];
- byte _vm_byte1714E;
+ byte _byte1714E;
byte _byte184F4;
byte _sound_byte16F06;
byte _byte16F09;
@@ -107,10 +107,11 @@ public:
int _word10800_ERULES;
int _word10807_ERULES;
- int _vm_word12D3D;
- int _vm_word12D3F;
+ int _word12D3D;
+ int _word12D3F;
byte *_rulesChunk1;
+ int _rulesBuffer2PrevIndx;
int _rulesBuffer2_1[40];
int _rulesBuffer2_2[40];
byte _rulesBuffer2_3[40];
diff --git a/engines/lilliput/script.cpp b/engines/lilliput/script.cpp
index 461fb9b95c..f89ca7ae60 100644
--- a/engines/lilliput/script.cpp
+++ b/engines/lilliput/script.cpp
@@ -26,6 +26,9 @@
namespace Lilliput {
LilliputScript::LilliputScript(LilliputEngine *vm) : _vm(vm), _currScript(NULL) {
+ _byte129A0 = 0xFF;
+ _word16F00 = -1;
+ _word10804 = 0;
}
LilliputScript::~LilliputScript() {
@@ -503,13 +506,13 @@ void LilliputScript::handleOpcodeType2(int curWord) {
}
}
-int LilliputScript::handleOpcode(Common::MemoryReadStream script) {
- _currScript = &script;
- uint16 curWord = script.readUint16LE();
+int LilliputScript::handleOpcode(Common::MemoryReadStream *script) {
+ _currScript = script;
+ uint16 curWord = _currScript->readUint16LE();
if (curWord == 0xFFF6)
return -1;
- while (curWord != 0xFFF8) {
+ for (; curWord != 0xFFF8; curWord = _currScript->readUint16LE()) {
byte mask = 0;
if (curWord > 1000) {
curWord -= 1000;
@@ -518,18 +521,18 @@ int LilliputScript::handleOpcode(Common::MemoryReadStream script) {
byte result = handleOpcodeType1(curWord);
if ((result ^ mask) == 0) {
do {
- curWord = script.readUint16LE();
+ curWord = _currScript->readUint16LE();
} while (curWord != 0xFFF7);
return 0;
}
}
- _vm->_vm_byte1714E = 1;
+ _vm->_byte1714E = 1;
for (;;) {
- curWord = script.readUint16LE();
+ curWord = _currScript->readUint16LE();
if (curWord == 0xFFF7)
- return _vm->_vm_byte1714E;
+ return _vm->_byte1714E;
handleOpcodeType2(curWord);
}
@@ -538,9 +541,52 @@ int LilliputScript::handleOpcode(Common::MemoryReadStream script) {
void LilliputScript::runScript(Common::MemoryReadStream script) {
_byte16F05_ScriptHandler = 1;
- while (handleOpcode(script) != 0xFF)
+ while (handleOpcode(&script) != 0xFF)
;
-
+}
+
+byte LilliputScript::compValues(byte var1, int oper, int var2) {
+ warning("compValues - %d %c %d", var1, oper & 0xFF, var2);
+ switch (oper & 0xFF) {
+ case '<':
+ return (var1 < var2);
+ case '>':
+ return (var1 > var2);
+ default:
+ return (var1 == var2);
+ break;
+ }
+}
+
+int LilliputScript::getValue1() {
+ int curWord = _currScript->readUint16LE();
+ if (curWord < 1000)
+ return curWord;
+
+ switch (curWord) {
+ case 1000:
+ return (int)_byte129A0;
+ case 1001:
+ return _vm->_rulesBuffer2PrevIndx;
+ case 1002:
+ return _word16F00;
+ case 1003:
+ return (int)_vm->_rulesBuffer2_15[6];
+ case 1004:
+ return _word10804;
+ default:
+ warning("getValue1: Unexpected large value %d", curWord);
+ return curWord;
+ }
+}
+
+byte *LilliputScript::getBuffer215Ptr() {
+ int tmpVal = getValue1();
+ tmpVal *= 32;
+ tmpVal += _currScript->readUint16LE();
+
+ assert(tmpVal < 40 * 32);
+ return &_vm->_rulesBuffer2_15[tmpVal];
}
byte LilliputScript::OC_sub173DF() {
@@ -555,14 +601,21 @@ byte LilliputScript::OC_sub1740A() {
warning("OC_sub1740A");
return 0;
}
+
byte LilliputScript::OC_sub17434() {
- warning("OC_sub17434");
- return 0;
+ byte *tmpArr = getBuffer215Ptr();
+ byte var1 = tmpArr[0];
+ uint16 oper = _currScript->readUint16LE();
+ int16 var2 = _currScript->readUint16LE();
+
+ return compValues(var1, oper, var2);
}
+
byte LilliputScript::OC_sub17468() {
warning("OC_sub17468");
return 0;
}
+
byte LilliputScript::OC_getRandom() {
warning("OC_getRandom");
return 0;
@@ -994,14 +1047,12 @@ void LilliputScript::OC_sub1847F() {
warning("OC_sub1847F");
}
void LilliputScript::OC_displayVGAFile() {
- warning("OC_displayVGAFile");
-
- _vm_byte12A09 = 1;
+ _byte12A09 = 1;
warning("TODO: unkPaletteFunction_1");
int curWord = _currScript->readUint16LE();
int index = _vm->_rulesChunk3[curWord];
Common::String fileName = Common::String((const char *)&_vm->_rulesChunk4[index]);
- _vm_word1881B = -1;
+ _word1881B = -1;
warning("TODO: guess_displayFunction_VGAFile(%s)", fileName.c_str());
warning("TODO: unkPaletteFunction_2");
}
@@ -1009,12 +1060,11 @@ void LilliputScript::OC_sub184D7() {
warning("OC_sub184D7");
}
void LilliputScript::OC_sub184F5() {
- warning("OC_sub184F5");
_vm->_byte184F4 = (_currScript->readUint16LE() & 0xFF);
_vm->_sound_byte16F06 = _vm->_byte184F4;
// TODO: use a separated function when properly identified
- _vm->_vm_word12D3D = 0;
- _vm->_vm_word12D3F = 0;
+ _vm->_word12D3D = 0;
+ _vm->_word12D3F = 0;
//
_vm->_mouse_byte1299A = 0;
_vm->_byte16F09 = 0;
diff --git a/engines/lilliput/script.h b/engines/lilliput/script.h
index b90f61e826..8a0793ec72 100644
--- a/engines/lilliput/script.h
+++ b/engines/lilliput/script.h
@@ -40,14 +40,21 @@ private:
Common::MemoryReadStream *_currScript;
byte _byte16F05_ScriptHandler;
- byte _vm_byte12A09;
+ byte _byte12A09;
+ byte _byte129A0;
- int16 _vm_word1881B;
+ int16 _word1881B;
+ int16 _word16F00;
+ int16 _word10804;
- int handleOpcode(Common::MemoryReadStream script);
+ int handleOpcode(Common::MemoryReadStream *script);
byte handleOpcodeType1(int curWord);
void handleOpcodeType2(int curWord);
+ int getValue1();
+ byte *getBuffer215Ptr();
+ byte compValues(byte var1, int oper, int var2);
+
//Opcodes Type 1
byte OC_sub173DF();
byte OC_sub173F0();