aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/lilliput/lilliput.cpp109
-rw-r--r--engines/lilliput/lilliput.h5
-rw-r--r--engines/lilliput/script.cpp20
-rw-r--r--engines/lilliput/script.h6
4 files changed, 136 insertions, 4 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp
index 0014ec37ef..3bb410a8c4 100644
--- a/engines/lilliput/lilliput.cpp
+++ b/engines/lilliput/lilliput.cpp
@@ -168,6 +168,8 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
_array161C3[i] = 0;
_array161EB[i] = 0;
_array12299[i] = 0xFF;
+ _array109E9[i] = 0xFF;
+ _array10A11[i] = 0xFF;
_array11D49[i] = 0xFFFF;
_rulesBuffer2_1[i] = 0xFFFF;
@@ -601,8 +603,7 @@ void LilliputEngine::sub16217() {
}
}
- warning("sub_161323");
-
+ sub16323();
}
void LilliputEngine::sub1652B(int var1) {
@@ -693,6 +694,49 @@ void LilliputEngine::displayFunction17() {
displayFunction4();
}
+void LilliputEngine::sub16323() {
+ debugC(2, kDebugEngine, "sub16323()");
+
+ if (_byte160FA <= 1)
+ return;
+
+ int var3;
+ for (int var4 = _byte160FA - 1; var4 != 0; var4--) {
+ var3 = 0;
+
+ for (int var2 = 0; var2 < var4; var2++) {
+ int index1 = _array160FB[var2];
+ int index2 = _array160FB[var2 + 1];
+
+ if (_array1619B[index1] < _array1619B[index2])
+ continue;
+
+ if (_array1619B[index1] == _array1619B[index2]) {
+ if (_array16173[index1] < _array16173[index2])
+ continue;
+
+ if (_array16173[index1] == _array16173[index2]) {
+ if (_rulesBuffer2_3[index1] < _rulesBuffer2_3[index2])
+ continue;
+
+ if (_rulesBuffer2_3[index1] == _rulesBuffer2_3[index2]) {
+ if (_array161EB[index1] < _array161EB[index2])
+ continue;
+ }
+ }
+ }
+
+ byte tmpVal = _array160FB[var2];
+ _array160FB[var2] = _array160FB[var2 + 1];
+ _array160FB[var2 + 1] = tmpVal;
+ ++var3;
+ }
+
+ if (var3 == 0)
+ return;
+ }
+}
+
// Move view port to x/y
void LilliputEngine::sub1638C() {
debugC(2, kDebugEngine, "sub1638C()");
@@ -829,6 +873,64 @@ void LilliputEngine::sub189DE() {
}
}
+int LilliputEngine::sub16B0C(int param1, int param2) {
+ debugC(2, kDebugEngine, "sub16B0C(%d, %d)", param1, param2);
+
+ static const byte _array16B04[8] = {0, 2, 0, 1, 3, 2, 3, 1};
+
+ int var1 = param2;
+ int var2 = param1;
+
+ int8 var1h = (var1 >>8) - (var2 >>8);
+ int8 var1l = (var1 & 0xFF) - (var2 & 0xFF);
+ int8 var2h = 0;
+ int8 var2l = 0;
+
+ if (var1h < var2h) {
+ var2l |= 4;
+ var1h = -var1h;
+ }
+
+ if (var1l < var2h) {
+ var2l |= 2;
+ var1l = -var1l;
+ }
+
+ if (var1h < var1l)
+ var2l |= 1;
+
+ return _array16B04[var2l];
+}
+
+int LilliputEngine::sub16799(int param1, int index) {
+ debugC(2, kDebugEngine, "sub16799(%d, %d)", param1, index);
+
+ byte var3h = _array109E9[index];
+ byte var3l = _array10A11[index];
+
+ if (var3h != 0xFF) {
+ if ((var3h != _scriptHandler->_array16123[index]) || (var3l != _scriptHandler->_array1614B[index])) {
+ warning("sub_1693A");
+ _scriptHandler->_array12811[index] -= (param1 >> 8) & 0x0F;
+ return 3;
+ }
+
+ if ((var3h == _scriptHandler->_array12811[index]) && (var3l == _array109C1[index]))
+ return 2;
+ }
+
+ warning("sub_167EF");
+ int var1 = (_scriptHandler->_array16123[index] << 8) + _scriptHandler->_array1614B[index];
+ int var2 = (_array109E9[index] << 8) + _array10A11[index];
+
+ _rulesBuffer2_9[index] = sub16B0C(var1, var2);
+
+ warning("sub_1693A");
+ _scriptHandler->_array12811[index] -= (param1 >> 8) & 0x0F;
+ return 3;
+
+}
+
void LilliputEngine::sub16626() {
debugC(2, kDebugEngine, "sub16626()");
@@ -872,7 +974,7 @@ void LilliputEngine::sub16626() {
warning("result = sub_16729");
break;
case 12:
- warning("result = sub_16799");
+ result = sub16799(var1, index);
break;
case 13:
warning("result = sub_16722");
@@ -887,6 +989,7 @@ void LilliputEngine::sub16626() {
error("sub16626 - unexpected value %d", var2 / 2);
break;
}
+
if (result == 1) {
++_scriptHandler->_array12811[index];
if (_scriptHandler->_array12811[index] == 16)
diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h
index 298a367d3d..bdbda3fde8 100644
--- a/engines/lilliput/lilliput.h
+++ b/engines/lilliput/lilliput.h
@@ -182,6 +182,8 @@ public:
byte _array161C3[40];
byte _array161EB[40];
byte _array12299[40];
+ byte _array109E9[40];
+ byte _array10A11[40];
byte _buffer1_45k[45056];
byte _buffer2_45k[45056];
@@ -213,11 +215,14 @@ public:
void displayFunction16();
void displayFunction17();
+ void sub16323();
void sub1638C();
void sub163F0(int var1, int var3);
void sub189DE();
void sub16626();
void sub16553(byte *buf);
+ int sub16799(int param1, int index);
+ int sub16B0C(int param1, int param2);
void initGame(const LilliputGameDescription *gd);
byte *loadVGA(Common::String filename, bool loadPal);
diff --git a/engines/lilliput/script.cpp b/engines/lilliput/script.cpp
index a6a10e5e23..caa9d52d0f 100644
--- a/engines/lilliput/script.cpp
+++ b/engines/lilliput/script.cpp
@@ -36,7 +36,12 @@ LilliputScript::LilliputScript(LilliputEngine *vm) : _vm(vm), _currScript(NULL)
_byte10806 = 0;
_byte12FE4 = 0xFF;
_byte16F02 = 0;
+ _byte18778 = 0;
+ _byte18779 = 0;
+ _byte1877A = 0;
+ _byte1877B = 0;
+ _word18818 = 0;
_word1855E = 0;
_word16F00 = -1;
_word10802 = -1;
@@ -1764,11 +1769,24 @@ void LilliputScript::OC_sub1847F() {
if (_byte16F08 != 1) {
_vm->displayFunction5();
- warning("TODO: OC_sub1847F - sub_18BE6");
+ sub18BE6();
_vm->displayFunction4();
}
}
+void LilliputScript::sub18BE6() {
+ debugC(1, kDebugScript, "sub18BE6()");
+
+ _word18818 = 0;
+ _byte18778 = 32;
+ _byte18779 = 32;
+ _byte1877A = 32;
+ _byte1877B = 0;
+
+ warning("sub_18AEE");
+ warning("sub_15A8B(_vm_byte18778);");
+}
+
void LilliputScript::OC_displayVGAFile() {
debugC(1, kDebugScript, "OC_displayVGAFile()");
diff --git a/engines/lilliput/script.h b/engines/lilliput/script.h
index 662538a3d0..4b5bc3df00 100644
--- a/engines/lilliput/script.h
+++ b/engines/lilliput/script.h
@@ -69,6 +69,10 @@ private:
byte _byte10806;
byte _byte12FE4;
byte _byte16F02;
+ byte _byte18778;
+ byte _byte18779;
+ byte _byte1877A;
+ byte _byte1877B;
byte *_savedBuffer215Ptr;
byte _array122FD[20];
@@ -76,6 +80,7 @@ private:
byte _array12839[40];
byte _array10B51[40 * 40];
+ int _word18818;
int _word16F00;
int _word10804;
int _word15FFB;
@@ -97,6 +102,7 @@ private:
int sub17D40(int var);
void sub18A56(byte *buf);
void sub18B3C(int var);
+ void sub18BE6();
int getValue1();
int getValue2();