Skip to content

Commit

Permalink
LILLIPUT: Implement some more core functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke authored and sev- committed Mar 28, 2018
1 parent a8699a8 commit 1864f1e
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 3 deletions.
98 changes: 97 additions & 1 deletion engines/lilliput/lilliput.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -686,7 +688,7 @@ void LilliputEngine::displayFunction16() {
sub16CA0();
sub16EBC();
sub171CF();
warning("sub_130EE");
sub130EE();
sub12FE5();
displayHeroismIndicator();
}
Expand Down Expand Up @@ -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);

Expand Down
6 changes: 6 additions & 0 deletions engines/lilliput/lilliput.h
Expand Up @@ -101,6 +101,8 @@ class LilliputEngine : public Engine {
byte _byte12A09;
byte _byte1881D;
byte _byte16552;
byte _byte12FE4;
byte _byte12FE3;

byte _buffer1[45056];
byte _buffer2[45056];
Expand Down Expand Up @@ -244,6 +246,10 @@ class LilliputEngine : public Engine {
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);
Expand Down
4 changes: 2 additions & 2 deletions engines/lilliput/script.h
Expand Up @@ -57,6 +57,8 @@ class LilliputScript {

short _array12311[640];

void sub130B6();

LilliputScript(LilliputEngine *vm);
~LilliputScript();

Expand Down Expand Up @@ -103,8 +105,6 @@ class LilliputScript {
int getValue1();
int getValue2();

void sub130B6();

byte *getBuffer215Ptr();
byte compareValues(byte var1, int oper, int var2);
void computeOperation(byte *bufPtr, int oper, int var2);
Expand Down

0 comments on commit 1864f1e

Please sign in to comment.