Skip to content

Commit

Permalink
LILLIPUT: Maybe fix a problem in sub12F37
Browse files Browse the repository at this point in the history
Unlocked new opcodes !
  • Loading branch information
sylvaintv authored and sev- committed Mar 28, 2018
1 parent 5ede42c commit 0be54f0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 24 deletions.
31 changes: 17 additions & 14 deletions engines/lilliput/lilliput.cpp
Expand Up @@ -1346,12 +1346,15 @@ void LilliputEngine::sub12F37() {
int index2 = 0;

for (int i = 0; i < _word10807_ERULES; i++) {
if (_rulesBuffer2_15[index1] == 1 ) {
--_rulesBuffer2_15[index1];
if (_rulesBuffer2_15[index1] == 1)
_scriptHandler->_array10B29[index2] = 1;
} else
_rulesBuffer2_15[index1] = 0;
if (_rulesBuffer2_15[index1] != 0 ) {
if (_rulesBuffer2_15[index1] == 1) {
_rulesBuffer2_15[index1] = 0;
} else {
--_rulesBuffer2_15[index1];
if (_rulesBuffer2_15[index1] == 1)
_scriptHandler->_array10B29[index2] = 1;
}
}

index1 += 32;
++index2;
Expand Down Expand Up @@ -1610,23 +1613,23 @@ void LilliputEngine::displayHeroismIndicator() {

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

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

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

_scriptHandler->_byte15FFA += var2;

int index = _scriptHandler->_word15FFB + _scriptHandler->_word15FFD * 320 ;
_scriptHandler->_heroismLevel += var2;
int index = _scriptHandler->_heroismBarX + _scriptHandler->_heroismBarBottomY * 320 ;

var2 = _scriptHandler->_byte15FFA & 0xFF;
var2 = _scriptHandler->_heroismLevel & 0xFF;
if (var2 != 0) {
// sub16064(var1, _scriptHandler->_byte15FFA);
for (int i = 0; i < (var2 << 2); i++) {
Expand All @@ -1637,9 +1640,9 @@ void LilliputEngine::displayHeroismIndicator() {
}
}

if (25 - _scriptHandler->_byte15FFA != 0) {
if (25 - _scriptHandler->_heroismLevel != 0) {
// sub16064(23, 25 - _scriptHandler->_byte15FFA);
var2 = (25 - _scriptHandler->_byte15FFA) << 2;
var2 = (25 - _scriptHandler->_heroismLevel) << 2;
for (int i = 0; i < var2; i++) {
((byte *)_mainSurface->getPixels())[index] = 23;
((byte *)_mainSurface->getPixels())[index + 1] = 23;
Expand Down
22 changes: 15 additions & 7 deletions engines/lilliput/script.cpp
Expand Up @@ -41,8 +41,8 @@ LilliputScript::LilliputScript(LilliputEngine *vm) : _vm(vm), _currScript(NULL)
_word16F00 = -1;
_viewportCharacterTarget = -1;
_word10804 = 0;
_word15FFB = 0;
_word15FFD = 0;
_heroismBarX = 0;
_heroismBarBottomY = 0;
_viewportX = 0;
_viewportY = 0;
_word18776 = 0;
Expand All @@ -63,6 +63,7 @@ LilliputScript::LilliputScript(LilliputEngine *vm) : _vm(vm), _currScript(NULL)
_array16123[i] = 0;
_array1614B[i] = 0;
_array16173[i] = 0xFF;
_array122C1[i] = 0;
}

for (int i = 0; i < 640; i++) {
Expand Down Expand Up @@ -1571,7 +1572,11 @@ void LilliputScript::OC_resetWord16EFE() {
warning("OC_resetWord16EFE");
}
void LilliputScript::OC_sub17CEF() {
warning("OC_sub17CEF");
debugC(1, kDebugScript, "OC_sub17CEF()");

int var1 = _currScript->readUint16LE();
sub1823E(_vm->_rulesBuffer2PrevIndx , var1, _vm->_ptr_rulesBuffer2_15);
sub17B6C(0);
}

void LilliputScript::OC_sub17D1B() {
Expand Down Expand Up @@ -1751,7 +1756,10 @@ void LilliputScript::OC_sub1834C() {
}

void LilliputScript::OC_sub18359() {
warning("OC_sub18359");
debugC(1, kDebugScript, "OC_sub18359()");

int var1 = _currScript->readUint16LE();
_array122C1[_vm->_rulesBuffer2PrevIndx] = var1;
}
void LilliputScript::OC_sub18367() {
warning("OC_sub18367");
Expand Down Expand Up @@ -1876,7 +1884,7 @@ void LilliputScript::OC_sub1853B() {

OC_PaletteFadeOut();
displayMap = 0;
_byte15FFA = 0;
_heroismLevel = 0;
sub130B6();

_vm->displayFunction12();
Expand Down Expand Up @@ -1907,8 +1915,8 @@ void LilliputScript::OC_initArr18560() {
void LilliputScript::OC_sub18678() {
debugC(1, kDebugScript, "OC_initArr18578()");
_savedBuffer215Ptr = getBuffer215Ptr();
_word15FFB = _currScript->readUint16LE();
_word15FFD = _currScript->readUint16LE();
_heroismBarX = _currScript->readUint16LE();
_heroismBarBottomY = _currScript->readUint16LE();
}

void LilliputScript::OC_sub18690() {
Expand Down
7 changes: 4 additions & 3 deletions engines/lilliput/script.h
Expand Up @@ -34,7 +34,7 @@ class LilliputScript {
public:
byte displayMap;
byte _byte12A04;
byte _byte15FFA;
byte _heroismLevel;

byte _array10B29[40];
byte _array122E9[20];
Expand All @@ -44,6 +44,7 @@ class LilliputScript {
byte _array12811[40];
byte _array10AB1[40];
byte _array122FD[20];
byte _array122C1[40];
short _array10B51[40 * 40];

byte *_savedBuffer215Ptr;
Expand All @@ -52,8 +53,8 @@ class LilliputScript {
int _viewportY;
int _viewportCharacterTarget;
int _word1881B;
int _word15FFB;
int _word15FFD;
int _heroismBarX;
int _heroismBarBottomY;

short _array12311[640];
byte _array128EF[40];
Expand Down

0 comments on commit 0be54f0

Please sign in to comment.