aboutsummaryrefslogtreecommitdiff
path: root/engines/lilliput
diff options
context:
space:
mode:
authorStrangerke2012-05-20 17:53:09 +0200
committerEugene Sandulenko2018-03-28 17:36:57 +0200
commitb3819ede5e91c89ff6518f66856596b03bbb15ca (patch)
tree167c9dc81428e7983ec80e0f61bdcc872d0ea702 /engines/lilliput
parent03e0d5927f57956a29b5c858d203b3272311d4db (diff)
downloadscummvm-rg350-b3819ede5e91c89ff6518f66856596b03bbb15ca.tar.gz
scummvm-rg350-b3819ede5e91c89ff6518f66856596b03bbb15ca.tar.bz2
scummvm-rg350-b3819ede5e91c89ff6518f66856596b03bbb15ca.zip
LILLIPUT: More verifications and renaming
Diffstat (limited to 'engines/lilliput')
-rw-r--r--engines/lilliput/lilliput.cpp133
-rw-r--r--engines/lilliput/lilliput.h30
-rw-r--r--engines/lilliput/script.cpp14
-rw-r--r--engines/lilliput/script.h2
4 files changed, 90 insertions, 89 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp
index dcf572fe0c..9751057f4e 100644
--- a/engines/lilliput/lilliput.cpp
+++ b/engines/lilliput/lilliput.cpp
@@ -209,7 +209,7 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
}
for (int i = 0; i < 30; i++)
- _array12861[i] = 0xFFFF;
+ _array12861[i] = -1;
for (int i = 0; i < 256; i++)
_savedSurfaceUnderMouse[i] = 0;
@@ -1374,10 +1374,10 @@ void LilliputEngine::checkSpeechClosing() {
}
}
-int LilliputEngine::getDirection(Common::Point param1, Common::Point param2) {
- debugC(2, kDebugEngineTBC, "getDirection(%d - %d, %d - %d)", param1.x, param1.y, param2.x, param2.y);
+byte LilliputEngine::getDirection(Common::Point param1, Common::Point param2) {
+ debugC(2, kDebugEngine, "getDirection(%d - %d, %d - %d)", param1.x, param1.y, param2.x, param2.y);
- static const char _directionsArray[8] = {0, 2, 0, 1, 3, 2, 3, 1};
+ static const byte _directionsArray[8] = {0, 2, 0, 1, 3, 2, 3, 1};
Common::Point var1 = param2;
Common::Point var2 = param1;
@@ -1581,21 +1581,21 @@ byte LilliputEngine::sub16A76(int indexb, int indexs) {
return 1;
}
-int LilliputEngine::findHotspot(Common::Point pos) {
- debugC(2, kDebugEngineTBC, "findHotspot(%d, %d)", pos.x, pos.y);
+int16 LilliputEngine::findHotspot(Common::Point pos) {
+ debugC(2, kDebugEngine, "findHotspot(%d, %d)", pos.x, pos.y);
- for (int i = 0; i < _rulesChunk12_size; i++) {
+ for (int i = 0; i < _rectNumb; i++) {
if ((pos.x >= (_rectXMinMax[i] >> 8)) && (pos.x <= (_rectXMinMax[i] & 0xFF)) && (pos.y >= (_rectYMinMax[i] >> 8)) && (pos.y <= (_rectYMinMax[i] & 0xFF)))
return i;
}
return -1;
}
-int LilliputEngine::reverseFindHotspot(Common::Point pos) {
- debugC(2, kDebugEngineTBC, "reverseFindHotspot(%d, %d)", pos.x, pos.y);
+int16 LilliputEngine::reverseFindHotspot(Common::Point pos) {
+ debugC(2, kDebugEngine, "reverseFindHotspot(%d, %d)", pos.x, pos.y);
- for (int i = _rulesChunk12_size - 1; i >= 0 ; i--) {
- if ((pos.x >= (_rectXMinMax[i] >> 8)) && (pos.x <= (_rectXMinMax[i] & 0xFF)) && (pos.y >= (_rectYMinMax[i] >> 8)) && (pos.y<= (_rectYMinMax[i] & 0xFF)))
+ for (int i = _rectNumb - 1; i >= 0 ; i--) {
+ if ((pos.x >= (_rectXMinMax[i] >> 8)) && (pos.x <= (_rectXMinMax[i] & 0xFF)) && (pos.y >= (_rectYMinMax[i] >> 8)) && (pos.y <= (_rectYMinMax[i] & 0xFF)))
return i;
}
return -1;
@@ -2014,13 +2014,13 @@ byte LilliputEngine::sub16675(int idx, Common::Point var1) {
case 0:
break;
case 1:
- sub166B1(index);
+ moveCharacterSpeed2(index);
break;
case 2:
- sub166B6(index);
+ moveCharacterSpeed4(index);
break;
case 3:
- sub166BB(index);
+ moveCharacterBack2(index);
break;
case 4:
sub16B63(index);
@@ -2029,19 +2029,19 @@ byte LilliputEngine::sub16675(int idx, Common::Point var1) {
sub16B76(index);
break;
case 6:
- sub166C0(index);
+ moveCharacterUp1(index);
break;
case 7:
- sub166C6(index);
+ moveCharacterUp2(index);
break;
case 8:
- sub166CC(index);
+ moveCharacterDown1(index);
break;
case 9:
- sub166D2(index);
+ moveCharacterDown2(index);
break;
case 10:
- sub166D8(index);
+ moveCharacterSpeed3(index);
break;
default:
warning("sub16675 - Unexpected value %d", var1.x);
@@ -2064,109 +2064,110 @@ void LilliputEngine::sub16B76(int index) {
_characterDirectionArray[index] = nextDirection[_characterDirectionArray[index]];
}
-void LilliputEngine::sub166C0(int index) {
- debugC(2, kDebugEngineTBC, "sub166C0(%d)", index);
+void LilliputEngine::moveCharacterUp1(int index) {
+ debugC(2, kDebugEngine, "moveCharacterUp1(%d)", index);
_characterPositionAltitude[index] += 1;
}
-void LilliputEngine::sub166C6(int index) {
- debugC(2, kDebugEngineTBC, "sub166C6(%d)", index);
+void LilliputEngine::moveCharacterUp2(int index) {
+ debugC(2, kDebugEngine, "moveCharacterUp2(%d)", index);
_characterPositionAltitude[index] += 2;
}
-void LilliputEngine::sub166CC(int index) {
- debugC(2, kDebugEngineTBC, "sub166CC(%d)", index);
+void LilliputEngine::moveCharacterDown1(int index) {
+ debugC(2, kDebugEngine, "moveCharacterDown1(%d)", index);
_characterPositionAltitude[index] -= 1;
}
-void LilliputEngine::sub166D2(int index) {
- debugC(2, kDebugEngineTBC, "sub166D2(%d)", index);
+void LilliputEngine::moveCharacterDown2(int index) {
+ debugC(2, kDebugEngine, "moveCharacterDown2(%d)", index);
_characterPositionAltitude[index] -= 2;
}
-void LilliputEngine::sub166B1(int index) {
- debugC(2, kDebugEngineTBC, "sub166B1(%d)", index);
+void LilliputEngine::moveCharacterSpeed2(int index) {
+ debugC(2, kDebugEngine, "moveCharacterSpeed2(%d)", index);
- sub16B31(index, 2);
+ sub16B31_moveCharacter(index, 2);
}
-void LilliputEngine::sub166B6(int index) {
- debugC(2, kDebugEngineTBC, "sub166B6(%d)", index);
+void LilliputEngine::moveCharacterSpeed4(int index) {
+ debugC(2, kDebugEngine, "moveCharacterSpeed4(%d)", index);
- sub16B31(index, 4);
+ sub16B31_moveCharacter(index, 4);
}
-void LilliputEngine::sub166BB(int index) {
- debugC(2, kDebugEngineTBC, "sub166BB(%d)", index);
+void LilliputEngine::moveCharacterBack2(int index) {
+ debugC(2, kDebugEngine, "moveCharacterBack2(%d)", index);
- sub16B31(index, -2);
+ sub16B31_moveCharacter(index, -2);
}
-void LilliputEngine::sub166D8(int index) {
- debugC(2, kDebugEngineTBC, "sub166D8(%d)", index);
+void LilliputEngine::moveCharacterSpeed3(int index) {
+ debugC(2, kDebugEngine, "moveCharacterSpeed3(%d)", index);
- sub16B31(index, 3);
+ sub16B31_moveCharacter(index, 3);
}
-void LilliputEngine::sub16B31(int index, int val) {
- debugC(2, kDebugEngineTBC, "sub16B31(%d, %d)", index, val);
+void LilliputEngine::sub16B31_moveCharacter(int index, int16 speed) {
+ debugC(2, kDebugEngine, "sub16B31_moveCharacter(%d, %d)", index, speed);
- int newX = _characterPositionX[index];
- int newY = _characterPositionY[index];
+ int16 newX = _characterPositionX[index];
+ int16 newY = _characterPositionY[index];
switch (_characterDirectionArray[index]) {
case 0:
- newX += val;
+ newX += speed;
break;
case 1:
- newY -= val;
+ newY -= speed;
break;
case 2:
- newY += val;
+ newY += speed;
break;
default:
- newX -= val;
+ newX -= speed;
break;
}
- sub16B8F(index, newX, newY, _characterDirectionArray[index]);
+ sub16B8F_moveCharacter(index, Common::Point(newX, newY), _characterDirectionArray[index]);
}
-void LilliputEngine::sub16B8F(int index, int x, int y, int flag) {
- debugC(2, kDebugEngineTBC, "sub16B8F(%d, %d, %d)", index, x, y);
+void LilliputEngine::sub16B8F_moveCharacter(int index, Common::Point pos, int direction) {
+ debugC(2, kDebugEngine, "sub16B8F_moveCharacter(%d, %d - %d, %d)", index, pos.x, pos.y, direction);
- int diffX = x >> 3;
- if (((diffX & 0xFF) == _scriptHandler->_array16123PosX[index]) && ((y >> 3) == _scriptHandler->_array1614BPosY[index])) {
- _characterPositionX[index] = x;
- _characterPositionY[index] = y;
+ int16 diffX = pos.x >> 3;
+ if (((diffX & 0xFF) == _scriptHandler->_array16123PosX[index]) && ((pos.y >> 3) == _scriptHandler->_array1614BPosY[index])) {
+ _characterPositionX[index] = pos.x;
+ _characterPositionY[index] = pos.y;
+ return;
}
- if ((x < 0) || (x >= 512) || (y < 0) || (y >= 512))
+ if ((pos.x < 0) || (pos.x >= 512) || (pos.y < 0) || (pos.y >= 512))
return;
int mapIndex = (_scriptHandler->_array1614BPosY[index] << 6) + _scriptHandler->_array16123PosX[index];
mapIndex <<= 2;
- if ((_bufferIsoMap[mapIndex + 3] & _array16C58[flag]) == 0)
+ if ((_bufferIsoMap[mapIndex + 3] & _array16C58[direction]) == 0)
return;
- mapIndex = ((y & 0xFFF8) << 3) + diffX;
+ mapIndex = ((pos.y & 0xFFF8) << 3) + diffX;
mapIndex <<= 2;
- if ((_bufferIsoMap[mapIndex + 3] & _array16C54[flag]) == 0)
+ if ((_bufferIsoMap[mapIndex + 3] & _array16C54[direction]) == 0)
return;
- int var1 = _rulesBuffer2_10[index];
+ byte var1 = _rulesBuffer2_10[index];
var1 &= 7;
var1 ^= 7;
if ((var1 & _rulesChunk9[_bufferIsoMap[mapIndex]]) != 0)
return;
- _characterPositionX[index] = x;
- _characterPositionY[index] = y;
+ _characterPositionX[index] = pos.x;
+ _characterPositionY[index] = pos.y;
}
void LilliputEngine::sub17224(int var1, int var4) {
@@ -2217,10 +2218,10 @@ void LilliputEngine::sub171CF() {
++_word1289D;
for (int i = 0; i < 10; i++) {
- if ((_array12861[(3 * i) + 1] != 0xFFFF) && (_array12861[3 * i] == _word1289D)) {
+ if ((_array12861[(3 * i) + 1] != -1) && (_array12861[3 * i] == _word1289D)) {
int var1 = _array12861[(3 * i) + 1];
int var4 = _array12861[(3 * i) + 2];
- _array12861[(3 * i) + 1] = 0xFFFF;
+ _array12861[(3 * i) + 1] = -1;
sub17224(var1, var4);
}
@@ -2528,11 +2529,11 @@ void LilliputEngine::loadRules() {
}
// Chunk 12
- _rulesChunk12_size = f.readUint16LE();
- assert(_rulesChunk12_size <= 40);
+ _rectNumb = f.readUint16LE();
+ assert(_rectNumb <= 40);
uint16 tmpVal;
- for (int i = 0; i < _rulesChunk12_size; i++) {
+ for (int i = 0; i < _rectNumb; i++) {
_rectXMinMax[i] = f.readUint16LE();
_rectYMinMax[i] = f.readUint16LE();
tmpVal = f.readUint16LE();
diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h
index b980333646..a13dc41af1 100644
--- a/engines/lilliput/lilliput.h
+++ b/engines/lilliput/lilliput.h
@@ -152,7 +152,7 @@ public:
byte _byte15E35[40];
int _array11D49[40];
int _array1289F[40];
- int _array12861[30];
+ int16 _array12861[30];
byte *_rulesChunk1;
int16 _currentScriptCharacter;
@@ -187,7 +187,7 @@ public:
byte _rulesChunk10_size;
int16 *_rulesChunk10;
byte *_rulesChunk11;
- int16 _rulesChunk12_size;
+ int16 _rectNumb;
int16 _rectXMinMax[40];
int16 _rectYMinMax[40];
Common::Point _rulesBuffer12Pos3[40];
@@ -263,8 +263,8 @@ public:
byte sub16A76(int indexb, int indexs);
void sub17224(int var1, int var4);
void sub17264(int index, int var4);
- int findHotspot(Common::Point pos);
- int reverseFindHotspot(Common::Point pos);
+ int16 findHotspot(Common::Point pos);
+ int16 reverseFindHotspot(Common::Point pos);
byte sub16722(int index, Common::Point var1);
byte sub166EA(int index);
void sub167EF(int index);
@@ -272,7 +272,7 @@ public:
void renderCharacters(byte *buf, Common::Point pos);
byte sub16799(int index, Common::Point param1);
- int getDirection(Common::Point param1, Common::Point param2);
+ byte getDirection(Common::Point param1, Common::Point param2);
void addCharToBuf(byte character);
void numberToString(int param1);
void sub12F37();
@@ -299,16 +299,16 @@ public:
void checkMapClosing(bool &forceReturnFl);
void sub16B63(int index);
void sub16B76(int index);
- void sub166C0(int index);
- void sub166C6(int index);
- void sub166CC(int index);
- void sub166D2(int index);
- void sub166B1(int index);
- void sub166B6(int index);
- void sub166BB(int index);
- void sub166D8(int index);
- void sub16B31(int index, int val);
- void sub16B8F(int index, int x, int y, int flag);
+ void moveCharacterUp1(int index);
+ void moveCharacterUp2(int index);
+ void moveCharacterDown1(int index);
+ void moveCharacterDown2(int index);
+ void moveCharacterSpeed2(int index);
+ void moveCharacterSpeed4(int index);
+ void moveCharacterBack2(int index);
+ void moveCharacterSpeed3(int index);
+ void sub16B31_moveCharacter(int index, int16 speed);
+ void sub16B8F_moveCharacter(int index, Common::Point pos, int direction);
byte sub1675D(int index, Common::Point var1);
byte sub16729(int index, Common::Point var1);
byte sub166F7(int index, Common::Point var1, int tmpVal);
diff --git a/engines/lilliput/script.cpp b/engines/lilliput/script.cpp
index 04b83117d4..d18abd7824 100644
--- a/engines/lilliput/script.cpp
+++ b/engines/lilliput/script.cpp
@@ -2456,12 +2456,12 @@ void LilliputScript::OC_setCurrentCharacter() {
_vm->setCurrentCharacter(var1);
}
-void LilliputScript::sub171AF(int var1, int var2, int var4) {
- debugC(2, kDebugScriptTBC, "sub171AF()");
+void LilliputScript::sub171AF(int16 var1, int16 var2, int16 var4) {
+ debugC(2, kDebugScript, "sub171AF()");
int index = 0;
for (int i = 0; i < 10; i++) {
- if (_vm->_array12861[index + 1] == 0xFFFF) {
+ if (_vm->_array12861[index + 1] == -1) {
_vm->_array12861[index + 1] = var1;
_vm->_array12861[index + 2] = var2;
_vm->_array12861[index + 0] = _vm->_word1289D + var4;
@@ -2493,11 +2493,11 @@ void LilliputScript::OC_sub17CA2() {
}
void LilliputScript::OC_sub17CB9() {
- debugC(1, kDebugScriptTBC, "OC_sub17CB9()");
+ debugC(1, kDebugScript, "OC_sub17CB9()");
- int var4 = _currScript->readUint16LE();
- int var1 = getValue1();
- int var2 = _currScript->readUint16LE();
+ int16 var4 = _currScript->readSint16LE();
+ int16 var1 = getValue1();
+ int16 var2 = _currScript->readSint16LE();
var2 = ((var2 & 0xFF) << 8) + _vm->_currentScriptCharacter;
sub171AF(var1, var2, var4);
diff --git a/engines/lilliput/script.h b/engines/lilliput/script.h
index de15fe102d..580049bdcf 100644
--- a/engines/lilliput/script.h
+++ b/engines/lilliput/script.h
@@ -128,7 +128,7 @@ private:
void displayNumber(byte var1, Common::Point pos);
byte *getMapPtr(Common::Point val);
byte *getCurrentCharacterVarFromScript();
- void sub171AF(int var1, int var2, int var4);
+ void sub171AF(int16 var1, int16 var2, int16 var4);
void sub18B7C(int var1, int var3);
void sub189B8();
void sub189F5();