aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/lilliput/lilliput.cpp98
-rw-r--r--engines/lilliput/lilliput.h6
-rw-r--r--engines/lilliput/script.h4
3 files changed, 105 insertions, 3 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp
index 6725a66c60..35261f35d8 100644
--- a/engines/lilliput/lilliput.cpp
+++ b/engines/lilliput/lilliput.cpp
@@ -143,6 +143,8 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
_byte12A09 = 0;
_byte1881D = 0;
_byte16552 = 0;
+ _byte12FE4 = 0xFF;
+ _byte12FE3 = 0;
_rulesBuffer2PrevIndx = 0;
_word16EFA = 0;
@@ -686,7 +688,7 @@ void LilliputEngine::displayFunction16() {
sub16CA0();
sub16EBC();
sub171CF();
- warning("sub_130EE");
+ sub130EE();
sub12FE5();
displayHeroismIndicator();
}
@@ -1278,6 +1280,100 @@ void LilliputEngine::sub12F37() {
}
}
+void LilliputEngine::sub130EE() {
+ debugC(2, kDebugEngine, "sub130EE()");
+
+ warning("sub147D7");
+ warning("sub13156");
+
+ if (_mouseButton == 0)
+ // TODO: check _mouse_byte1299F
+ return;
+
+ int button = _mouseButton;
+ _mouseButton = 0;
+
+ if (button & 2) {
+ if (_byte12FE4 != 0xFF)
+ sub1305C(_byte12FE4, button);
+ return;
+ }
+
+ sub13184();
+ int posX = _mouseX - 64;
+ int posY = _mouseY - 16;
+
+ if ((posX < 0) || (posX > 255))
+ return;
+
+ if ((posY < 0) || (posY > 176))
+ return;
+
+ warning("sub131B2");
+ warning("sub131FC");
+}
+
+void LilliputEngine::sub13184() {
+ debugC(2, kDebugEngine, "sub13184()");
+
+ for (int index = _word12F68_ERULES - 1; index >= 0; index--) {
+ if (sub13240(_mouseX, _mouseY, _rulesBuffer13_2[index], _rulesBuffer13_3[index]) == 0) {
+ sub1305C(index, 1);
+ warning("TODO: sub13184 - add parameter to force return in calling function");
+ }
+ }
+}
+
+int LilliputEngine::sub13240(int posX, int posY, int var3, int var4) {
+ debugC(2, kDebugEngine, "sub13240(%d, %d, %d, %d)", posX, posY, var3, var4);
+
+ if ((posX < var3) || (posY < var4))
+ return -1;
+
+ var3 += 16;
+ var4 += 16;
+
+ if ((posX > var3) || (posY > var4))
+ return -1;
+
+ return 0;
+}
+
+void LilliputEngine::sub1305C(byte index, byte button) {
+ debugC(2, kDebugEngine, "sub1305C(%d, %d)", index, button);
+
+ if (_scriptHandler->_array122E9[index] < 2)
+ return;
+
+ _byte12FE4 = index;
+ _byte12FE3 = button;
+
+ if (button == 2) {
+ if (_byte12FCE != 1) {
+ _scriptHandler->_array122E9[index] = 2;
+ _byte16F07_menuId = 2;
+ displayFunction8();
+ }
+ return;
+ }
+
+ if (_byte12FCE == 1) {
+ sub130DD();
+ return;
+ }
+
+ _scriptHandler->sub130B6();
+ _scriptHandler->_array122E9[index] = 3;
+ if (_rulesBuffer13_1[index] == 1) {
+ _byte12FCE = 1;
+ _word15AC2 = 1;
+ } else {
+ _byte16F07_menuId = 1;
+ }
+
+ displayFunction8();
+}
+
int LilliputEngine::sub16685(int idx, int var1) {
debugC(2, kDebugEngine, "sub16685(%d, %d)", idx, var1);
diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h
index 49a1a04080..6ddfb07481 100644
--- a/engines/lilliput/lilliput.h
+++ b/engines/lilliput/lilliput.h
@@ -101,6 +101,8 @@ public:
byte _byte12A09;
byte _byte1881D;
byte _byte16552;
+ byte _byte12FE4;
+ byte _byte12FE3;
byte _buffer1[45056];
byte _buffer2[45056];
@@ -244,6 +246,10 @@ public:
void sub12FE5();
int sub16DD5(int x1, int y1, int x2, int y2);
void displayHeroismIndicator();
+ void sub130EE();
+ void sub1305C(byte index, byte var2);
+ void sub13184();
+ int sub13240(int posX, int posY, int var3, int var4);
void initGame(const LilliputGameDescription *gd);
byte *loadVGA(Common::String filename, bool loadPal);
diff --git a/engines/lilliput/script.h b/engines/lilliput/script.h
index 3ea50791db..63a9aab805 100644
--- a/engines/lilliput/script.h
+++ b/engines/lilliput/script.h
@@ -57,6 +57,8 @@ public:
short _array12311[640];
+ void sub130B6();
+
LilliputScript(LilliputEngine *vm);
~LilliputScript();
@@ -103,8 +105,6 @@ private:
int getValue1();
int getValue2();
- void sub130B6();
-
byte *getBuffer215Ptr();
byte compareValues(byte var1, int oper, int var2);
void computeOperation(byte *bufPtr, int oper, int var2);