Skip to content

Commit

Permalink
LILLIPUT: Add display heroism bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke authored and sev- committed Mar 28, 2018
1 parent ebb7f49 commit c4dc1e3
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 15 deletions.
136 changes: 126 additions & 10 deletions engines/lilliput/lilliput.cpp
Expand Up @@ -156,6 +156,7 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
_word16213 = 0;
_word16215 = 0;
_displayStringIndex = 0;
_word1289D = 0;

_saveFlag = false;
_byte16F07_menuId = 0;
Expand All @@ -171,6 +172,7 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
_array12299[i] = 0xFF;
_array109E9[i] = 0xFF;
_array10A11[i] = 0xFF;
_array16E94[i] = 0;

_array11D49[i] = 0xFFFF;
_rulesBuffer2_1[i] = 0xFFFF;
Expand All @@ -187,8 +189,12 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
_rulesBuffer2_12[i] = 0;
_rulesBuffer2_13[i] = 0;
_rulesBuffer2_14[i] = 0;
_array1289F[i] = 0xFFFF;
}

for (int i = 0; i < 30; i++)
_array12861[i] = 0xFFFF;

for (int i = 0; i < 256; i++)
_array15AC8[i] = 0;

Expand Down Expand Up @@ -667,8 +673,8 @@ void LilliputEngine::displayFunction16() {
sub16626();
sub12F37();
warning("sub_16CA0");
warning("sub_16EBC");
warning("sub_171CF");
sub16EBC();
sub171CF();
warning("sub_15EAE");
} else {
sub1638C();
Expand All @@ -678,11 +684,11 @@ void LilliputEngine::displayFunction16() {
sub16626();
sub12F37();
warning("sub_16CA0");
warning("sub_16EBC");
warning("sub_171CF");
sub16EBC();
sub171CF();
warning("sub_130EE");
warning("sub_12FE5");
warning("sub_15FFF");
sub12FE5();
displayHeroismIndicator();
}
}

Expand Down Expand Up @@ -1001,7 +1007,6 @@ void LilliputEngine::prepareGoldAmount(int param1) {
}
}


void LilliputEngine::sub16626() {
debugC(2, kDebugEngine, "sub16626()");

Expand All @@ -1020,7 +1025,7 @@ void LilliputEngine::sub16626() {
var2 = ((var1 >> 8) >> 3);
var2 &= 0xFE;

// temporary hack
// temporary hack
result = 0;

switch (var2 / 2) {
Expand Down Expand Up @@ -1073,6 +1078,24 @@ void LilliputEngine::sub16626() {
}
}

void LilliputEngine::sub16EBC() {
debugC(2, kDebugEngine, "sub16EBC()");

int index2 = 3;

for (int index1 = _word10807_ERULES - 1; index1 >= 0; index1--) {
int var2 = (_scriptHandler->_array1614B[index1] << 8) + (_scriptHandler->_array16123[index1] << 2);
int var1 = (_bufferIsoMap[index2 + var2] & 0x40);

if (var1 == _array16E94[index1])
continue;

_array16E94[index1] = var1;
if (var1 != 0)
_scriptHandler->_array10B29[index1] = 1;
}
}

void LilliputEngine::sub12F37() {
debugC(2, kDebugEngine, "sub12F37()");

Expand All @@ -1084,7 +1107,7 @@ void LilliputEngine::sub12F37() {
--_rulesBuffer2_15[index1];
if (_rulesBuffer2_15[index1] == 1)
_scriptHandler->_array10B29[index2] = 1;
} else
} else
_rulesBuffer2_15[index1] = 0;

index1 += 32;
Expand All @@ -1106,7 +1129,7 @@ int LilliputEngine::sub16675(int idx, int var1) {

warning("sub16675(%d, %d)", idx, var1);
int index = sub16685(idx, var1);

switch (index) {
case 0:
break;
Expand Down Expand Up @@ -1147,6 +1170,99 @@ int LilliputEngine::sub16675(int idx, int var1) {
return 0;
}

void LilliputEngine::sub171CF() {
debugC(2, kDebugEngine, "sub171CF()");

for (int i = 0; i < _word10807_ERULES; i++) {
if (_array1289F[i] != 0xFFFF) {
_array11D49[i] = _array1289F[i];
_array1289F[i] = 0xFFFF;
_scriptHandler->_array10B29[i] = 1;
}
}

++_word1289D;

for (int i = 0; i < 10; i++) {
if ((_array12861[(3 * i) + 1] != 0xFFFF) && (_array12861[3 * i] = _word1289D)) {
int var1 = _array12861[(3 * i) + 1];
int var4 = _array12861[(3 * i) + 2];
_array12861[(3 * i) + 1] = 0xFFFF;

warning("sub_17224");
}
}
}

void LilliputEngine::sub12FE5() {
debugC(2, kDebugEngine, "sub12FE5()");

if (_byte12A04 != 1)
return;

int index = 0;
int count = 0;
for (int i = 0; i < _word12F68_ERULES; i++) {
if (_scriptHandler->_array122FD[index] != 0) {
--_scriptHandler->_array122FD[index];
if (_scriptHandler->_array122FD[index] == 0) {
_scriptHandler->_array122E9[index] = 2;
++count;
}
}
}

if (count !=0)
displayFunction8();
}

void LilliputEngine::displayHeroismIndicator() {
debugC(2, kDebugEngine, "displayHeroismIndicator()");

if (_scriptHandler->_savedBuffer215Ptr == NULL)
return;

int var1 = (_scriptHandler->_savedBuffer215Ptr[0] * 25) >> 8;

if (var1 == _scriptHandler->_byte15FFA)
return;

displayFunction5();
int var2 = 1;
if (var1 > _scriptHandler->_byte15FFA)
var1 = 150;
else {
var2 = -1;
var1 = 40;
}

_scriptHandler->_byte15FFA += var2;

int var4 = (_scriptHandler->_word15FFD >> 8) + ((_scriptHandler->_word15FFD & 0xFF) << 8);
int index = _scriptHandler->_word15FFB + var4 + (var4 >> 2);

if ((_scriptHandler->_byte15FFA & 0xFF) == 0) {
// sub16064(var1, _scriptHandler->_byte15FFA);
for (int i = 0; i < (_scriptHandler->_byte15FFA << 2); i++) {
((byte *)_mainSurface->getPixels())[index - (i * 320)] = var1;
((byte *)_mainSurface->getPixels())[index - (i * 320) + 1] = var1;
((byte *)_mainSurface->getPixels())[index - (i * 320) + 2] = var1;
}
}

if (25 - _scriptHandler->_byte15FFA != 0) {
// sub16064(23, 25 - _scriptHandler->_byte15FFA);
var2 = (25 - _scriptHandler->_byte15FFA) << 2;
for (int i = 0; i < var2; i++) {
((byte *)_mainSurface->getPixels())[index - (i * 320)] = 23;
((byte *)_mainSurface->getPixels())[index - (i * 320) + 1] = 23;
((byte *)_mainSurface->getPixels())[index - (i * 320) + 2] = 23;
}
}

displayFunction4();
}

void LilliputEngine::pollEvent() {
debugC(2, kDebugEngine, "pollEvent()");

Expand Down
8 changes: 8 additions & 0 deletions engines/lilliput/lilliput.h
Expand Up @@ -129,8 +129,11 @@ class LilliputEngine : public Engine {
int _word15AC2;
int _word16550;
int _displayStringIndex;
int _word1289D;

int _array11D49[40];
int _array1289F[40];
int _array12861[30];

byte *_rulesChunk1;
int _rulesBuffer2PrevIndx;
Expand Down Expand Up @@ -186,6 +189,7 @@ class LilliputEngine : public Engine {
byte _array12299[40];
byte _array109E9[40];
byte _array10A11[40];
byte _array16E94[40];

byte _buffer1_45k[45056];
byte _buffer2_45k[45056];
Expand Down Expand Up @@ -232,6 +236,10 @@ class LilliputEngine : public Engine {
void sub12F37();
int sub16675(int idx, int var1);
int sub16685(int idx, int var1);
void sub16EBC();
void sub171CF();
void sub12FE5();
void displayHeroismIndicator();

void initGame(const LilliputGameDescription *gd);
byte *loadVGA(Common::String filename, bool loadPal);
Expand Down
10 changes: 5 additions & 5 deletions engines/lilliput/script.h
Expand Up @@ -34,6 +34,7 @@ class LilliputScript {
public:
byte _byte16F08;
byte _byte12A04;
byte _byte15FFA;

byte _array10B29[40];
byte _array122E9[20];
Expand All @@ -42,11 +43,15 @@ class LilliputScript {
byte _array16173[40];
byte _array12811[40];
byte _array10AB1[40];
byte _array122FD[20];
byte *_savedBuffer215Ptr;

int _word12A00;
int _word12A02;
int _word10802;
int _word1881B;
int _word15FFB;
int _word15FFD;

short _array12311[640];

Expand All @@ -64,22 +69,17 @@ class LilliputScript {
byte _byte16F05_ScriptHandler;
byte _byte12A09;
byte _byte129A0;
byte _byte15FFA;
byte _byte1855D;
byte _byte10806;
byte _byte12FE4;
byte _byte16F02;

byte *_savedBuffer215Ptr;
byte _array122FD[20];
byte _array128EF[40];
byte _array12839[40];
byte _array10B51[40 * 40];

int _word16F00;
int _word10804;
int _word15FFB;
int _word15FFD;
int _word1855E;
int _word18776;

Expand Down

0 comments on commit c4dc1e3

Please sign in to comment.