aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/lilliput/lilliput.cpp87
-rw-r--r--engines/lilliput/lilliput.h15
-rw-r--r--engines/lilliput/script.cpp69
-rw-r--r--engines/lilliput/script.h10
4 files changed, 96 insertions, 85 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp
index 8904b867f4..2d4db24952 100644
--- a/engines/lilliput/lilliput.cpp
+++ b/engines/lilliput/lilliput.cpp
@@ -134,7 +134,7 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
_soundHandler = new LilliputSound(this);
_byte1714E = 0;
- _byte12FCE = false;
+ _bool12FCE = false;
_selectedCharacterId = -1;
_numCharactersToDisplay = 0;
_nextDisplayCharacterPos = Common::Point(0, 0);
@@ -154,17 +154,17 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
_currentScriptCharacterPos = Common::Point(0, 0);
_word10804 = 0;
_nextCharacterIndex = 0;
- _word16EFE = -1;
+ _word16EFEh = -1;
+ _word16EFEl_characterId = -1;
_word1817B = 0;
_savedSurfaceUnderMousePos = Common::Point(0, 0);
- _word15AC2 = 0;
- _word15AC2 = 0;
+ _bool15AC2 = false;
_displayStringIndex = 0;
_word1289D = 0;
_numCharacters = 0;
_saveFlag = true;
- _byte16F07_menuId = 0;
+ _actionType = kActionNone;
_array16C54[0] = _array16C58[3] = 1;
_array16C54[1] = _array16C58[2] = 2;
@@ -172,7 +172,7 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
_array16C54[3] = _array16C58[0] = 8;
for (int i = 0; i < 3; i++)
- _array147D1[i] = 0;
+ _codeEntered[i] = 0;
for (int i = 0; i < 4; i++)
_array1692B[i] = 0;
@@ -404,7 +404,7 @@ void LilliputEngine::displayMousePointer() {
_savedSurfaceUnderMousePos = _mouseDisplayPos;
SaveSurfaceUnderMouseCursor(_savedSurfaceUnderMouse, _mouseDisplayPos);
- display16x16IndexedBuf(_bufferIdeogram, _word15AC2 + 80, _mouseDisplayPos);
+ display16x16IndexedBuf(_bufferIdeogram, _bool15AC2 ? 81 : 80, _mouseDisplayPos);
_skipDisplayFlag1 = 1;
_skipDisplayFlag2 = 0;
@@ -821,7 +821,7 @@ void LilliputEngine::displayRefreshScreen() {
sub16CA0();
sub16EBC();
sub171CF();
- sub130EE();
+ handleGameMouseClick();
sub12FE5();
displayHeroismIndicator();
}
@@ -984,7 +984,7 @@ void LilliputEngine::sub15F75() {
return;
_savedMousePosDivided = Common::Point(newX, newY);
- _byte16F07_menuId = 5;
+ _actionType = kActionGoto;
}
void LilliputEngine::unselectInterfaceHotspots() {
@@ -1016,7 +1016,7 @@ void LilliputEngine::checkMapClosing(bool &forceReturnFl) {
_displayMap = false;
paletteFadeOut();
- _word15AC2 = 0;
+ _bool15AC2 = false;
unselectInterfaceHotspots();
initGameAreaDisplay();
_scriptHandler->_heroismLevel = 0;
@@ -1933,7 +1933,7 @@ void LilliputEngine::sub147D7() {
} else if (oldEvent.type == Common::EVENT_KEYUP) {
altKeyFl = false;
if (keyCount == 3)
- _byte16F07_menuId = 6;
+ _actionType = kCodeEntered;
return;
}
}
@@ -1963,7 +1963,7 @@ void LilliputEngine::sub147D7() {
case Common::KEYCODE_7:
case Common::KEYCODE_8:
case Common::KEYCODE_9:
- _array147D1[keyCount] = oldEvent.kbd.keycode - Common::KEYCODE_0;
+ _codeEntered[keyCount] = oldEvent.kbd.keycode - Common::KEYCODE_0;
++keyCount;
break;
default:
@@ -1972,8 +1972,8 @@ void LilliputEngine::sub147D7() {
}
}
-void LilliputEngine::sub130EE() {
- debugC(2, kDebugEngine, "sub130EE()");
+void LilliputEngine::handleGameMouseClick() {
+ debugC(2, kDebugEngine, "handleGameMouseClick()");
sub147D7();
@@ -2013,26 +2013,27 @@ void LilliputEngine::sub130EE() {
if (forceReturnFl)
return;
- sub131FC(pos);
+ checkClickOnGameArea(pos);
}
-void LilliputEngine::sub131FC(Common::Point pos) {
- debugC(2, kDebugEngine, "sub131FC(%d, %d)", pos.x, pos.y);
+void LilliputEngine::checkClickOnGameArea(Common::Point pos) {
+ debugC(2, kDebugEngine, "checkClickOnGameArea(%d, %d)", pos.x, pos.y);
int x = pos.x - 8;
int y = pos.y - 4;
- x = (x >> 4) - 7;
- y = (y >> 3) - 4;
+ x = (x / 16) - 7;
+ y = (y / 8) - 4;
- int diff = (y - x) >> 1;
- y = y - diff;
+ int arrowY = (y - x) >> 1;
+ int arrowX = y - arrowY;
- if ((y >= 0) && (diff >= 0) && (y < 8) && (diff < 8)) {
- y += _scriptHandler->_viewportPos.x;
- diff += _scriptHandler->_viewportPos.y;
- _savedMousePosDivided = Common::Point(y, diff);
- _byte16F07_menuId = 5;
+ // Set the arrow coordinates
+ if ((arrowX >= 0) && (arrowY >= 0) && (arrowX < 8) && (arrowY < 8)) {
+ arrowX += _scriptHandler->_viewportPos.x;
+ arrowY += _scriptHandler->_viewportPos.y;
+ _savedMousePosDivided = Common::Point(arrowX, arrowY);
+ _actionType = kActionGoto;
}
}
@@ -2042,11 +2043,12 @@ void LilliputEngine::checkClickOnCharacter(Common::Point pos, bool &forceReturnF
forceReturnFl = false;
for (int8 i = 0; i < _numCharacters; i++) {
+ // check if position is over a character
if ((pos.x >= _characterDisplayX[i]) && (pos.x <= _characterDisplayX[i] + 17) && (pos.y >= _characterDisplayY[i]) && (pos.y <= _characterDisplayY[i] + 17) && (i != _word10804)) {
_selectedCharacterId = i;
- _byte16F07_menuId = 4;
- if (_byte12FCE)
- _byte16F07_menuId = 3;
+ _actionType = 4;
+ if (_bool12FCE)
+ _actionType = 3;
forceReturnFl = true;
return;
@@ -2086,15 +2088,15 @@ void LilliputEngine::sub1305C(byte index, byte button) {
_lastInterfaceHotspotButton = button;
if (button == 2) {
- if (!_byte12FCE) {
+ if (!_bool12FCE) {
_scriptHandler->_interfaceHotspotStatus[index] = kHotspotEnabled;
- _byte16F07_menuId = 2;
+ _actionType = 2;
displayInterfaceHotspots();
}
return;
}
- if (_byte12FCE) {
+ if (_bool12FCE) {
unselectInterfaceButton();
return;
}
@@ -2102,10 +2104,10 @@ void LilliputEngine::sub1305C(byte index, byte button) {
unselectInterfaceHotspots();
_scriptHandler->_interfaceHotspotStatus[index] = kHotspotSelected;
if (_rulesBuffer13_1[index] == 1) {
- _byte12FCE = true;
- _word15AC2 = 1;
+ _bool12FCE = true;
+ _bool15AC2 = true;
} else {
- _byte16F07_menuId = 1;
+ _actionType = 1;
}
displayInterfaceHotspots();
@@ -2794,8 +2796,8 @@ void LilliputEngine::setCurrentCharacter(int index) {
void LilliputEngine::unselectInterfaceButton() {
debugC(1, kDebugEngine, "unselectInterfaceButton()");
- _byte12FCE = false;
- _word15AC2 = 0;
+ _bool12FCE = false;
+ _bool15AC2 = false;
_lastInterfaceHotspotButton = 0;
unselectInterfaceHotspots();
displayInterfaceHotspots();
@@ -2804,10 +2806,10 @@ void LilliputEngine::unselectInterfaceButton() {
void LilliputEngine::handleMenu() {
debugC(1, kDebugEngine, "handleMenu()");
- if (_byte16F07_menuId == 0)
+ if (_actionType == kActionNone)
return;
- if (_byte12FCE && (_byte16F07_menuId != 3))
+ if (_bool12FCE && (_actionType != 3))
return;
setCurrentCharacter(_word10804);
@@ -2817,10 +2819,10 @@ void LilliputEngine::handleMenu() {
_savedMousePosDivided = Common::Point(-1, -1);
_selectedCharacterId = -1;
- if (_byte16F07_menuId == 3)
+ if (_actionType == 3)
unselectInterfaceButton();
- _byte16F07_menuId = 0;
+ _actionType = kActionNone;
}
void LilliputEngine::handleGameScripts() {
@@ -2844,7 +2846,8 @@ void LilliputEngine::handleGameScripts() {
setCurrentCharacter(index);
- _word16EFE = _array11D49[index];
+ _word16EFEh = _array11D49[index] >> 8;
+ _word16EFEl_characterId = _array11D49[index] & 0xFF;
_array11D49[index] = -1;
_word1817B = 0;
diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h
index 43ac74b674..27f123c7c8 100644
--- a/engines/lilliput/lilliput.h
+++ b/engines/lilliput/lilliput.h
@@ -122,7 +122,7 @@ public:
byte _debugFlag; // Mostly useless, as the associated functions are empty
byte _byte14837; // Unused byte, set by an opcode
- byte _array147D1[3];
+ byte _codeEntered[3];
char _array1692B[4];
byte *_bufferIsoMap;
byte *_bufferCubegfx;
@@ -141,10 +141,11 @@ public:
byte _numCharacters;
Common::Point _currentScriptCharacterPos;
int _nextCharacterIndex;
- int16 _word16EFE;
+ int8 _word16EFEh;
+ int8 _word16EFEl_characterId;
uint16 _word1817B;
Common::Point _savedSurfaceUnderMousePos;
- int _word15AC2;
+ bool _bool15AC2;
int _currentDisplayCharacter;
int _displayStringIndex;
int _word1289D;
@@ -291,12 +292,12 @@ public:
void displayCharactersOnMap();
void restoreMapPoints();
void displayHeroismIndicator();
- void sub130EE();
+ void handleGameMouseClick();
void sub1305C(byte index, byte var2);
void checkInterfaceHotspots(bool &forceReturnFl);
bool isMouseOverHotspot(Common::Point mousePos, Common::Point hotspotPos);
void checkClickOnCharacter(Common::Point pos, bool &forceReturnFl);
- void sub131FC(Common::Point pos);
+ void checkClickOnGameArea(Common::Point pos);
void displaySpeechBubbleTail(Common::Point displayPos);
void displaySpeechBubbleTailLine(Common::Point pos, int var2);
void displaySpeechLine(int vgaIndex, byte *srcBuf, int &bufIndex);
@@ -346,8 +347,8 @@ public:
int _skipDisplayFlag1;
int _skipDisplayFlag2;
- byte _byte16F07_menuId;
- bool _byte12FCE;
+ byte _actionType;
+ bool _bool12FCE;
int8 _selectedCharacterId;
byte _numCharactersToDisplay;
int16 _word10804;
diff --git a/engines/lilliput/script.cpp b/engines/lilliput/script.cpp
index fd30b96952..a4eae7f326 100644
--- a/engines/lilliput/script.cpp
+++ b/engines/lilliput/script.cpp
@@ -36,7 +36,7 @@ LilliputScript::LilliputScript(LilliputEngine *vm) : _vm(vm), _currScript(NULL)
_byte18823 = 0;
_speechDisplaySpeed = 3;
_speechTimer = 0;
- _word16F00 = -1;
+ _word16F00_characterId = -1;
_word129A3 = 0;
_viewportCharacterTarget = -1;
_heroismBarX = 0;
@@ -229,7 +229,7 @@ byte LilliputScript::handleOpcodeType1(int curWord) {
return OC_checkFunctionKeyPressed();
break;
case 0x30:
- return OC_sub17A07();
+ return OC_checkCodeEntered();
break;
case 0x31:
return OC_checkViewPortCharacterTarget();
@@ -604,7 +604,7 @@ static const OpCode opCodes1[] = {
{ "OC_sub179AE", 0, kNone, kNone, kNone, kNone, kNone },
{ "OC_sub179C2", 1, kgetPosFromScript, kNone, kNone, kNone, kNone },
{ "OC_checkFunctionKeyPressed", 1, kImmediateValue, kNone, kNone, kNone, kNone },
- { "OC_sub17A07", 3, kImmediateValue, kImmediateValue, kImmediateValue, kNone, kNone },
+ { "OC_checkCodeEntered", 3, kImmediateValue, kImmediateValue, kImmediateValue, kNone, kNone },
{ "OC_checkViewPortCharacterTarget", 1, kGetValue1, kNone, kNone, kNone, kNone },
};
@@ -730,7 +730,7 @@ Common::String LilliputScript::getArgumentString(KValueType type, ScriptStream&
} else if (val == 1001) {
str = Common::String("characterIndex");
} else if (val == 1002) {
- str = Common::String("_word16F00");
+ str = Common::String("_word16F00_characterId");
} else if (val == 1003) {
str = Common::String("_currentCharacterVariables[6]");
} else if (val == 1004) {
@@ -759,7 +759,7 @@ Common::String LilliputScript::getArgumentString(KValueType type, ScriptStream&
break;
}
case 0xFB: {
- str = "(characterPositionTileX[_word16F00], characterPositionTileY[_word16F00])";
+ str = "(characterPositionTileX[_word16F00_characterId], characterPositionTileY[_word16F00_characterId])";
break;
}
case 0xFA:
@@ -1289,7 +1289,7 @@ int16 LilliputScript::getValue1() {
case 1001:
return _vm->_currentScriptCharacter;
case 1002:
- return _word16F00;
+ return _word16F00_characterId;
case 1003:
return (int16)_vm->_currentCharacterVariables[6];
case 1004:
@@ -1325,7 +1325,7 @@ Common::Point LilliputScript::getPosFromScript() {
return Common::Point(x, y);
}
case 0xFB: {
- int index = _word16F00;
+ int index = _word16F00_characterId;
assert((index >= 0) && (index < 40));
int16 x = _vm->_characterPositionX[index] >> 3;
int16 y = _vm->_characterPositionY[index] >> 3;
@@ -1499,7 +1499,7 @@ byte LilliputScript::OC_sub174D8() {
if (curWord == 3000) {
for (int index = 0; index < _vm->_numCharacters; index++) {
if (_vm->_rulesBuffer2_5[index] == tmpVal) {
- _word16F00 = index;
+ _word16F00_characterId = index;
return 1;
}
}
@@ -1508,7 +1508,7 @@ byte LilliputScript::OC_sub174D8() {
int index = getValue1();
assert(index < 40);
if (_vm->_rulesBuffer2_5[index] == tmpVal) {
- _word16F00 = index;
+ _word16F00_characterId = index;
return 1;
}
}
@@ -1617,7 +1617,7 @@ byte LilliputScript::OC_sub175C8() {
if ((var1 & 0xFF) < var4)
return 0;
- _word16F00 = index;
+ _word16F00_characterId = index;
return 1;
}
@@ -1625,7 +1625,7 @@ byte LilliputScript::OC_sub175C8() {
for (int i = 0; i < _vm->_numCharacters; i++) {
int var1 = _array10B51[(_vm->_currentScriptCharacter * 40) + i];
if ((var1 & 0xFF) >= var4) {
- _word16F00 = i;
+ _word16F00_characterId = i;
return 1;
}
}
@@ -1637,7 +1637,7 @@ byte LilliputScript::OC_sub175C8() {
for (int i = 0; i < _vm->_numCharacters; i++) {
int var1 = _array10B51[(_vm->_currentScriptCharacter * 40) + i];
if (((var1 & 0xFF) >= var4) && (_vm->_rulesBuffer2_12[i] == var4b)) {
- _word16F00 = i;
+ _word16F00_characterId = i;
return 1;
}
}
@@ -1660,7 +1660,7 @@ byte LilliputScript::OC_sub17640() {
byte v2 = tmpVal >> 8;
if ((v1 < (var4 & 0xFF)) || (v2 >= (var4 & 0xFF)))
return 0;
- _word16F00 = subIndex;
+ _word16F00_characterId = subIndex;
return 1;
}
@@ -1671,7 +1671,7 @@ byte LilliputScript::OC_sub17640() {
byte v1 = tmpVal & 0xFF;
byte v2 = tmpVal >> 8;
if ((v1 >= (var4 & 0xFF)) && (v2 < (var4 & 0xFF))) {
- _word16F00 = i;
+ _word16F00_characterId = i;
return 1;
}
}
@@ -1685,7 +1685,7 @@ byte LilliputScript::OC_sub17640() {
byte v1 = tmpVal & 0xFF;
byte v2 = tmpVal >> 8;
if ((v1 >= (var4 & 0xFF)) && (v2 < (var4 & 0xFF)) && (_vm->_rulesBuffer2_12[i] == (var4 >> 8))) {
- _word16F00 = i;
+ _word16F00_characterId = i;
return 1;
}
}
@@ -1706,7 +1706,7 @@ byte LilliputScript::OC_sub176C4() {
if (((var1 & 0xFF) >= var4) || ((var1 >> 8) < var4))
return 0;
- _word16F00 = index;
+ _word16F00_characterId = index;
return 1;
}
@@ -1714,7 +1714,7 @@ byte LilliputScript::OC_sub176C4() {
for (int i = 0; i < _vm->_numCharacters; i++) {
int var1 = _array10B51[(_vm->_currentScriptCharacter * 40) + i];
if (((var1 & 0xFF) < var4) && ((var1 >> 8) >= var4)) {
- _word16F00 = i;
+ _word16F00_characterId = i;
return 1;
}
}
@@ -1727,7 +1727,7 @@ byte LilliputScript::OC_sub176C4() {
int var1 = _array10B51[(_vm->_currentScriptCharacter * 40) + i];
if (((var1 & 0xFF) < var4) && ((var1 >> 8) >= var4)) {
if (_vm->_rulesBuffer2_12[i] == var4b) {
- _word16F00 = i;
+ _word16F00_characterId = i;
return 1;
}
}
@@ -1804,12 +1804,12 @@ byte LilliputScript::OC_compWord16EFE() {
debugC(1, kDebugScript, "OC_compWord16EFE()");
byte curByte = _currScript->readUint16LE() & 0xFF;
- byte tmpVal = _vm->_word16EFE >> 8;
+ byte tmpVal = _vm->_word16EFEh;
if (curByte != tmpVal)
return 0;
- _word16F00 = (_vm->_word16EFE & 0xFF);
+ _word16F00_characterId = _vm->_word16EFEl_characterId;
return 1;
}
@@ -1842,7 +1842,7 @@ byte LilliputScript::OC_checkLastInterfaceHotspotIndexMenu13() {
byte tmpVal = (_currScript->readUint16LE() & 0xFF);
- if ((_vm->_byte16F07_menuId != 1) && (_vm->_byte16F07_menuId != 3))
+ if ((_vm->_actionType != 1) && (_vm->_actionType != 3))
return 0;
if (tmpVal == _vm->_lastInterfaceHotspotIndex)
@@ -1856,7 +1856,7 @@ byte LilliputScript::OC_checkLastInterfaceHotspotIndexMenu2() {
int8 hotspotIndex = (_currScript->readUint16LE() & 0xFF);
- if ((_vm->_byte16F07_menuId == 2) || (hotspotIndex == _vm->_lastInterfaceHotspotIndex))
+ if ((_vm->_actionType == 2) && (hotspotIndex == _vm->_lastInterfaceHotspotIndex))
return 1;
return 0;
@@ -1963,7 +1963,7 @@ byte LilliputScript::OC_sub1790F() {
if (_vm->_rulesBuffer2_5[index] == -1)
return 0;
- _word16F00 = _vm->_rulesBuffer2_5[index];
+ _word16F00_characterId = _vm->_rulesBuffer2_5[index];
return 1;
}
@@ -2039,7 +2039,7 @@ byte LilliputScript::OC_checkSelectedCharacter() {
byte LilliputScript::OC_sub179AE() {
debugC(1, kDebugScript, "OC_sub179AE()");
- if (_vm->_byte12FCE || (_vm->_selectedCharacterId == -1))
+ if (_vm->_bool12FCE || (_vm->_selectedCharacterId == -1))
return 0;
return 1;
@@ -2070,18 +2070,18 @@ byte LilliputScript::OC_checkFunctionKeyPressed() {
return 0;
}
-byte LilliputScript::OC_sub17A07() {
- debugC(1, kDebugScript, "OC_sub17A07()");
+byte LilliputScript::OC_checkCodeEntered() {
+ debugC(1, kDebugScript, "OC_checkCodeEntered()");
- static const byte array179FD[10] = {11, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ static const byte solutionArr[10] = {11, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- if (_vm->_byte16F07_menuId == 6) {
+ if (_vm->_actionType == kCodeEntered) {
uint16 index = _currScript->readUint16LE();
- if (array179FD[index] == _vm->_array147D1[0]) {
+ if (solutionArr[index] == _vm->_codeEntered[0]) {
index = _currScript->readUint16LE();
- if (array179FD[index] == _vm->_array147D1[1]) {
+ if (solutionArr[index] == _vm->_codeEntered[1]) {
index = _currScript->readUint16LE();
- if (array179FD[index] == _vm->_array147D1[2]) {
+ if (solutionArr[index] == _vm->_codeEntered[2]) {
return 1;
}
} else
@@ -2537,9 +2537,10 @@ void LilliputScript::OC_sub17CD1() {
}
void LilliputScript::OC_resetWord16EFE() {
- debugC(1, kDebugScriptTBC, "OC_resetWord16EFE()");
+ debugC(1, kDebugScript, "OC_resetWord16EFE()");
- _vm->_word16EFE = -1;
+ _vm->_word16EFEh = -1;
+ _vm->_word16EFEl_characterId = -1;
}
void LilliputScript::OC_enableCurrentCharacterScript() {
@@ -3110,7 +3111,7 @@ void LilliputScript::OC_loadFileAerial() {
_vm->_refreshScreenFlag = true;
_talkingCharacter = -1;
OC_PaletteFadeOut();
- _vm->_word15AC2 = 1;
+ _vm->_bool15AC2 = true;
_vm->displayVGAFile("AERIAL.GFX");
OC_PaletteFadeIn();
diff --git a/engines/lilliput/script.h b/engines/lilliput/script.h
index 9500531385..1c02021f06 100644
--- a/engines/lilliput/script.h
+++ b/engines/lilliput/script.h
@@ -34,6 +34,12 @@ namespace Lilliput {
class LilliputEngine;
+enum kActionType {
+ kActionNone = 0,
+ kActionGoto = 5,
+ kCodeEntered = 6
+};
+
enum KValueType {
kNone,
kImmediateValue,
@@ -105,7 +111,7 @@ private:
byte _byte18823;
byte _speechDisplaySpeed;
- int16 _word16F00;
+ int16 _word16F00_characterId;
int _currentSpeechId;
int _word18821;
int _word129A3;
@@ -190,7 +196,7 @@ private:
byte OC_sub179AE();
byte OC_sub179C2();
byte OC_checkFunctionKeyPressed();
- byte OC_sub17A07();
+ byte OC_checkCodeEntered();
byte OC_checkViewPortCharacterTarget();
// Opcodes Type 2