LILLIPUT: Renaming, fix interface hotspots: it's now possible to skip the intro

This commit is contained in:
Strangerke 2012-05-18 19:24:03 +02:00 committed by Eugene Sandulenko
parent 9ecbc0e327
commit e6983de0d0
4 changed files with 88 additions and 96 deletions

View file

@ -144,8 +144,8 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
_byte12A08 = 0;
_byte12A09 = 0;
_byte16552 = 0;
_byte12FE4 = 0xFF;
_byte12FE3 = 0;
_lastInterfaceHotspotIndex = -1;
_lastInterfaceHotspotButton = 0;
_byte16F08 = 0;
_byte16C9F = 0;
_lastAnimationTick = 0;
@ -340,7 +340,7 @@ void LilliputEngine::displayCharacter(int index, Common::Point pos, int flags) {
}
void LilliputEngine::display16x16IndexedBuf(byte *buf, int index, Common::Point pos) {
debugC(2, kDebugEngine, "display16x16IndexedBuf(buf, %d, %d, %d)", index, pos.x, pos.y);
debugC(2, kDebugEngine, "display16x16IndexedBuf(buf, %d, %d - %d)", index, pos.x, pos.y);
int index1 = index * 16 * 16;
byte *newBuf = &buf[index1];
@ -471,8 +471,8 @@ void LilliputEngine::displayInterfaceHotspots() {
restoreSurfaceUnderMousePointer();
int tmpVal;
for (int index = 0; index < _word12F68_ERULES; index++) {
tmpVal = _scriptHandler->_array122E9[index] * 20;
for (int index = 0; index < _interfaceHotspotNumb; index++) {
tmpVal = _scriptHandler->_interfaceHotspotStatus[index] * 20;
display16x16IndexedBuf(_bufferIdeogram, tmpVal + index, Common::Point(_interfaceHotspotsX[index], _interfaceHotspotsY[index]));
}
@ -975,12 +975,12 @@ void LilliputEngine::sub15F75() {
_byte16F07_menuId = 5;
}
void LilliputEngine::sub130B6() {
debugC(2, kDebugEngineTBC, "sub130B6()");
void LilliputEngine::unselectInterfaceHotspots() {
debugC(2, kDebugEngine, "unselectInterfaceHotspots()");
for (int index = 0; index < _word12F68_ERULES; index++) {
if (_scriptHandler->_array122E9[index] == 3)
_scriptHandler->_array122E9[index] = 2;
for (int index = 0; index < _interfaceHotspotNumb; index++) {
if (_scriptHandler->_interfaceHotspotStatus[index] == kHotspotSelected)
_scriptHandler->_interfaceHotspotStatus[index] = kHotspotEnabled;
}
}
@ -1003,7 +1003,7 @@ void LilliputEngine::checkMapClosing(bool &forceReturnFl) {
_displayMap = 0;
paletteFadeOut();
_word15AC2 = 0;
sub130B6();
unselectInterfaceHotspots();
initGameAreaDisplay();
_scriptHandler->_heroismLevel = 0;
moveCharacters();
@ -1871,8 +1871,8 @@ void LilliputEngine::sub130EE() {
_mouseButton = 0;
if (button & 2) {
if (_byte12FE4 != 0xFF)
sub1305C(_byte12FE4, button);
if (_lastInterfaceHotspotIndex != -1)
sub1305C(_lastInterfaceHotspotIndex, button);
return;
}
@ -1937,7 +1937,7 @@ void LilliputEngine::checkInterfaceHotspots(bool &forceReturnFl) {
debugC(2, kDebugEngineTBC, "checkInterfaceHotspots()");
forceReturnFl = false;
for (int index = _word12F68_ERULES - 1; index >= 0; index--) {
for (int index = _interfaceHotspotNumb - 1; index >= 0; index--) {
if (sub13240(_mousePos, _interfaceHotspotsX[index], _interfaceHotspotsY[index]) == 0) {
sub1305C(index, 1);
forceReturnFl = true;
@ -1964,15 +1964,15 @@ int LilliputEngine::sub13240(Common::Point mousePos, int var3, int var4) {
void LilliputEngine::sub1305C(byte index, byte button) {
debugC(2, kDebugEngineTBC, "sub1305C(%d, %d)", index, button);
if (_scriptHandler->_array122E9[index] < 2)
if (_scriptHandler->_interfaceHotspotStatus[index] < kHotspotEnabled)
return;
_byte12FE4 = index;
_byte12FE3 = button;
_lastInterfaceHotspotIndex = index;
_lastInterfaceHotspotButton = button;
if (button == 2) {
if (button &= 2) {
if (_byte12FCE != 1) {
_scriptHandler->_array122E9[index] = 2;
_scriptHandler->_interfaceHotspotStatus[index] = kHotspotEnabled;
_byte16F07_menuId = 2;
displayInterfaceHotspots();
}
@ -1984,8 +1984,8 @@ void LilliputEngine::sub1305C(byte index, byte button) {
return;
}
_scriptHandler->sub130B6();
_scriptHandler->_array122E9[index] = 3;
unselectInterfaceHotspots();
_scriptHandler->_interfaceHotspotStatus[index] = kHotspotSelected;
if (_rulesBuffer13_1[index] == 1) {
_byte12FCE = 1;
_word15AC2 = 1;
@ -2234,11 +2234,11 @@ void LilliputEngine::sub12FE5() {
int index = 0;
int count = 0;
for (int i = 0; i < _word12F68_ERULES; i++) {
for (int i = 0; i < _interfaceHotspotNumb; i++) {
if (_scriptHandler->_array122FD[index] != 0) {
--_scriptHandler->_array122FD[index];
if (_scriptHandler->_array122FD[index] == 0) {
_scriptHandler->_array122E9[index] = 2;
_scriptHandler->_interfaceHotspotStatus[index] = kHotspotEnabled;
++count;
}
}
@ -2513,7 +2513,7 @@ void LilliputEngine::loadRules() {
assert(_rulesChunk10_size <= 20);
if (_rulesChunk10_size != 0) {
_rulesChunk10 = (int *)malloc(sizeof(int) * _rulesChunk10_size);
_rulesChunk10 = (int16 *)malloc(sizeof(int16) * _rulesChunk10_size);
int totalSize = 0;
for (int i = 0; i < _rulesChunk10_size; ++i) {
_rulesChunk10[i] = totalSize;
@ -2541,7 +2541,7 @@ void LilliputEngine::loadRules() {
}
// Chunk 13
_word12F68_ERULES = f.readUint16LE();
_interfaceHotspotNumb = f.readUint16LE();
for (int i = 0 ; i < 20; i++)
_rulesBuffer13_1[i] = f.readByte();

View file

@ -66,6 +66,13 @@ enum LilliputDebugChannels {
kDebugScriptTBC = 1 << 4
};
enum InterfaceHotspotStatus {
kHotspotOff = 0,
kHotspotDisabled = 1,
kHotspotEnabled = 2,
kHotspotSelected = 3
};
struct LilliputGameDescription;
struct SmallAnim {
@ -106,8 +113,8 @@ public:
byte _byte12A08;
byte _byte12A09;
byte _byte16552;
byte _byte12FE4;
byte _byte12FE3;
int8 _lastInterfaceHotspotIndex;
byte _lastInterfaceHotspotButton; // Unused: set by 2 functions, but never used elsewhere
byte _byte16F08;
byte _byte15EAD;
byte _debugFlag; // Mostly useless, as the associated functions are empty
@ -177,15 +184,15 @@ public:
int _gameScriptIndexSize;
byte *_arrayGameScripts;
byte _rulesChunk9[60];
int _rulesChunk10_size;
int *_rulesChunk10;
byte _rulesChunk10_size;
int16 *_rulesChunk10;
byte *_rulesChunk11;
int _rulesChunk12_size;
int16 _rulesChunk12_size;
int16 _rectXMinMax[40];
int16 _rectYMinMax[40];
Common::Point _rulesBuffer12Pos3[40];
Common::Point _rulesBuffer12Pos4[40];
int _word12F68_ERULES;
int _interfaceHotspotNumb;
byte _rulesBuffer13_1[20];
int16 _interfaceHotspotsX[20];
int16 _interfaceHotspotsY[20];
@ -241,7 +248,7 @@ public:
void displaySmallAnims();
void displaySmallIndexedAnim(byte index, byte subIndex);
void sub130B6();
void unselectInterfaceHotspots();
void sub15F75();
void resetSmallAnims();
void paletteFadeOut();
@ -341,7 +348,6 @@ public:
int16 _word10804;
bool _shouldQuit;
void pollEvent();
void setCurrentCharacter(int index);
void sub130DD();

View file

@ -31,7 +31,6 @@ namespace Lilliput {
LilliputScript::LilliputScript(LilliputEngine *vm) : _vm(vm), _currScript(NULL) {
_byte129A0 = 0xFF;
_byte10806 = 0;
_byte12FE4 = 0xFF;
_byte16F02 = 0;
_byte16F04 = 0;
_byte1881A = 0;
@ -53,7 +52,7 @@ LilliputScript::LilliputScript(LilliputEngine *vm) : _vm(vm), _currScript(NULL)
_savedBuffer215Ptr = NULL;
for (int i = 0; i < 20; i++) {
_array122E9[i] = 0;
_interfaceHotspotStatus[i] = kHotspotOff;
_array122FD[i] = 0;
}
@ -170,10 +169,10 @@ byte LilliputScript::handleOpcodeType1(int curWord) {
return OC_CurrentCharacterVar0Equals();
break;
case 0x1C:
return OC_sub17825();
return OC_checkLastInterfaceHotspotIndexMenu13();
break;
case 0x1D:
return OC_sub17844();
return OC_checkLastInterfaceHotspotIndexMenu2();
break;
case 0x1E:
return OC_CompareNumberOfCharacterWithVar0Equals();
@ -215,7 +214,7 @@ byte LilliputScript::handleOpcodeType1(int curWord) {
return OC_checkCharacterDirection();
break;
case 0x2B:
return OC_sub17984();
return OC_checkLastInterfaceHotspotIndex();
break;
case 0x2C:
return OC_checkSavedMousePos();
@ -416,7 +415,7 @@ void LilliputScript::handleOpcodeType2(int curWord) {
OC_setCurrentCharacterDirection();
break;
case 0x39:
OC_sub18099();
OC_setInterfaceHotspot();
break;
case 0x3A:
OC_sub180C3();
@ -479,7 +478,7 @@ void LilliputScript::handleOpcodeType2(int curWord) {
OC_sub183A2();
break;
case 0x4E:
OC_sub183C6();
OC_disableInterfaceHotspot();
break;
case 0x4F:
OC_loadFile_AERIAL_GFX();
@ -585,8 +584,8 @@ static const OpCode opCodes1[] = {
{ "OC_compWord16EFE", 1, kImmediateValue, kNone, kNone, kNone, kNone },
{ "OC_AreCurrentCharacterVar0AndVar1EqualsTo", 2, kImmediateValue, kImmediateValue, kNone, kNone, kNone },
{ "OC_CurrentCharacterVar0Equals", 1, kImmediateValue, kNone, kNone, kNone, kNone },
{ "OC_sub17825", 1, kImmediateValue, kNone, kNone, kNone, kNone },
{ "OC_sub17844", 1, kImmediateValue, kNone, kNone, kNone, kNone },
{ "OC_checkLastInterfaceHotspotIndexMenu13", 1, kImmediateValue, kNone, kNone, kNone, kNone },
{ "OC_checkLastInterfaceHotspotIndexMenu2", 1, kImmediateValue, kNone, kNone, kNone, kNone },
{ "OC_CompareNumberOfCharacterWithVar0Equals", 3, kImmediateValue, kCompareOperation, kImmediateValue, kNone, kNone },
{ "OC_IsPositionInViewport", 1, kgetPosFromScript, kNone, kNone, kNone, kNone },
{ "OC_CompareGameVariables", 2, kGetValue1, kGetValue1, kNone, kNone, kNone },
@ -600,7 +599,7 @@ static const OpCode opCodes1[] = {
{ "OC_sub1793E", 0, kNone, kNone, kNone, kNone, kNone },
{ "OC_CurrentCharacterVar3Equals1", 0, kNone, kNone, kNone, kNone, kNone },
{ "OC_sub1796E", 2, kGetValue1, kImmediateValue, kNone, kNone, kNone },
{ "OC_sub17984", 2, kImmediateValue, kImmediateValue, kNone, kNone, kNone },
{ "OC_checkLastInterfaceHotspotIndex", 2, kImmediateValue, kImmediateValue, kNone, kNone, kNone },
{ "OC_checkSavedMousePos", 0, kNone, kNone, kNone, kNone, kNone },
{ "OC_sub179AE", 0, kNone, kNone, kNone, kNone, kNone },
{ "OC_sub179C2", 1, kgetPosFromScript, kNone, kNone, kNone, kNone },
@ -668,7 +667,7 @@ static const OpCode opCodes2[] = {
/* 0x36 */ { "OC_sub1805D", 5, kGetValue1, kImmediateValue, kImmediateValue, kImmediateValue, kImmediateValue },
/* 0x37 */ { "OC_sub18074", 2, kImmediateValue, kImmediateValue, kNone, kNone, kNone },
/* 0x38 */ { "OC_setCurrentCharacterDirection", 1, kImmediateValue, kNone, kNone, kNone, kNone },
/* 0x39 */ { "OC_sub18099", 2, kImmediateValue, kImmediateValue, kNone, kNone, kNone },
/* 0x39 */ { "OC_setInterfaceHotspot", 2, kImmediateValue, kImmediateValue, kNone, kNone, kNone },
/* 0x3a */ { "OC_sub180C3", 1, kImmediateValue, kNone, kNone, kNone, kNone },
/* 0x3b */ { "OC_setViewPortPos", 1, kgetPosFromScript, kNone, kNone, kNone, kNone },
/* 0x3c */ { "OC_setCurrentCharacterAltitude", 1, kImmediateValue, kNone, kNone, kNone, kNone },
@ -689,7 +688,7 @@ static const OpCode opCodes2[] = {
/* 0x4b */ { "OC_setDebugFlag", 0, kNone, kNone, kNone, kNone, kNone },
/* 0x4c */ { "OC_setByte14837", 0, kNone, kNone, kNone, kNone, kNone },
/* 0x4d */ { "OC_sub183A2", 0, kNone, kNone, kNone, kNone, kNone },
/* 0x4e */ { "OC_sub183C6", 2, kImmediateValue, kImmediateValue, kNone, kNone, kNone }, // TODO
/* 0x4e */ { "OC_disableInterfaceHotspot", 2, kImmediateValue, kImmediateValue, kNone, kNone, kNone }, // TODO
/* 0x4f */ { "OC_loadFile_AERIAL_GFX", 1, kImmediateValue, kNone, kNone, kNone, kNone },
/* 0x50 */ { "OC_sub17E22_speech1IfSoundOff", 1, kImmediateValue, kNone, kNone, kNone, kNone },
/* 0x51 */ { "OC_sub1844A", 2, kGetValue1, kImmediateValue, kNone, kNone, kNone },
@ -1357,16 +1356,6 @@ Common::Point LilliputScript::getPosFromScript() {
}
}
void LilliputScript::sub130B6() {
debugC(1, kDebugScript, "sub130B6()");
assert(_vm->_word12F68_ERULES <= 20);
for (int i = 0; i < _vm->_word12F68_ERULES; i++) {
if (_array122E9[i] == 3)
_array122E9[i] = 2;
}
}
byte *LilliputScript::getCharacterVariablePtr() {
debugC(2, kDebugScript, "getCharacterVariablePtr()");
@ -1843,29 +1832,29 @@ byte LilliputScript::OC_CurrentCharacterVar0Equals() {
return 0;
}
byte LilliputScript::OC_sub17825() {
debugC(1, kDebugScriptTBC, "OC_sub17825()");
byte LilliputScript::OC_checkLastInterfaceHotspotIndexMenu13() {
debugC(1, kDebugScript, "OC_checkLastInterfaceHotspotIndexMenu13()");
byte tmpVal = (_currScript->readUint16LE() & 0xFF);
if ((_vm->_byte16F07_menuId != 1) && (_vm->_byte16F07_menuId != 3))
return 0;
if (tmpVal == _byte12FE4)
if (tmpVal == _vm->_lastInterfaceHotspotIndex)
return 1;
return 0;
}
byte LilliputScript::OC_sub17844() {
debugC(1, kDebugScriptTBC, "OC_sub17844()");
byte LilliputScript::OC_checkLastInterfaceHotspotIndexMenu2() {
debugC(1, kDebugScriptTBC, "OC_checkLastInterfaceHotspotIndexMenu2()");
int tmpVal = _currScript->readUint16LE();
if ((_vm->_byte16F07_menuId == 2) || ((tmpVal & 0xFF) != _byte12FE4))
return 0;
int8 hotspotIndex = (_currScript->readUint16LE() & 0xFF);
if ((_vm->_byte16F07_menuId == 2) || (hotspotIndex == _vm->_lastInterfaceHotspotIndex))
return 1;
return 0;
}
byte LilliputScript::OC_CompareNumberOfCharacterWithVar0Equals() {
@ -2020,15 +2009,15 @@ byte LilliputScript::OC_checkCharacterDirection() {
return 0;
}
byte LilliputScript::OC_sub17984() {
debugC(1, kDebugScriptTBC, "OC_sub17984()");
byte LilliputScript::OC_checkLastInterfaceHotspotIndex() {
debugC(1, kDebugScriptTBC, "OC_checkLastInterfaceHotspotIndex()");
int index = _currScript->readUint16LE();
int var2 = _currScript->readUint16LE();
int8 var2 = (_currScript->readUint16LE() & 0xFF);
assert(index < 20);
if (_array122E9[index] == (var2 & 0xFF))
if (_interfaceHotspotStatus[index] == var2)
return 1;
return 0;
@ -2573,21 +2562,21 @@ void LilliputScript::OC_changeCurrentCharacterSprite() {
}
byte *LilliputScript::sub173D2() {
debugC(2, kDebugScriptTBC, "sub173D2()");
byte *LilliputScript::getCurrentCharacterVarFromScript() {
debugC(2, kDebugScript, "getCurrentCharacterVarFromScript()");
int index = _currScript->readUint16LE();
return &_vm->_currentCharacterVariables[index];
}
void LilliputScript::OC_sub17E99() {
debugC(1, kDebugScriptTBC, "OC_sub17E99()");
debugC(1, kDebugScript, "OC_sub17E99()");
byte *compBuf = sub173D2();
byte *compBuf = getCurrentCharacterVarFromScript();
int oper = _currScript->readUint16LE();
int index = _currScript->readUint16LE();
byte *buf = sub173D2();
byte *buf = getCurrentCharacterVarFromScript();
byte var1 = buf[0];
byte var3 = _vm->_rulesChunk11[var1 + _vm->_rulesChunk10[index]];
@ -2599,12 +2588,12 @@ void LilliputScript::OC_sub17EC5() {
int indexChunk10 = _currScript->readUint16LE();
byte *compBuf = sub173D2();
byte *compBuf = getCurrentCharacterVarFromScript();
int indexChunk11 = _vm->_rulesChunk10[indexChunk10] + compBuf[0];
int oper = _currScript->readUint16LE();
byte *tmpBuf = sub173D2();
byte *tmpBuf = getCurrentCharacterVarFromScript();
int var3 = tmpBuf[0];
computeOperation(&_vm->_rulesChunk11[indexChunk11], oper, var3);
@ -2781,14 +2770,14 @@ void LilliputScript::OC_setCurrentCharacterDirection() {
_vm->_characterDirectionArray[_vm->_currentScriptCharacter] = (_currScript->readUint16LE() & 0xFF);
}
void LilliputScript::OC_sub18099() {
debugC(1, kDebugScriptTBC, "OC_sub18099()");
void LilliputScript::OC_setInterfaceHotspot() {
debugC(1, kDebugScript, "OC_setInterfaceHotspot()");
int16 index = _currScript->readSint16LE();
uint16 curWord = _currScript->readUint16LE();
int index = _currScript->readUint16LE();
assert((index >= 0) && (index < 20));
int curWord = _currScript->readUint16LE();
_array122E9[index] = (curWord & 0xFF);
_interfaceHotspotStatus[index] = (curWord & 0xFF);
_array122FD[index] = (curWord >> 8);
_vm->displayInterfaceHotspots();
@ -3033,12 +3022,12 @@ void LilliputScript::OC_sub183A2() {
warning("OC_sub183A2");
}
void LilliputScript::OC_sub183C6() {
debugC(1, kDebugScriptTBC, "OC_sub183C6()");
void LilliputScript::OC_disableInterfaceHotspot() {
debugC(1, kDebugScriptTBC, "OC_disableInterfaceHotspot()");
int index = _currScript->readUint16LE();
_array122FD[index] = (_currScript->readUint16LE() & 0xff);
_array122E9[index] = 1;
_interfaceHotspotStatus[index] = kHotspotDisabled;
_vm->displayInterfaceHotspots();
}
@ -3168,7 +3157,7 @@ void LilliputScript::OC_initGameAreaDisplay() {
OC_PaletteFadeOut();
_vm->_displayMap = 0;
_heroismLevel = 0;
sub130B6();
_vm->unselectInterfaceHotspots();
_vm->initGameAreaDisplay();

View file

@ -60,7 +60,7 @@ public:
byte _speechTimer;
byte _characterScriptEnabled[40];
byte _array122E9[20];
int8 _interfaceHotspotStatus[20];
char _array16123PosX[40];
char _array1614BPosY[40];
byte _array12811[40];
@ -83,8 +83,6 @@ public:
byte _array12839[40];
Common::Point _array1813BPos[32];
void sub130B6();
LilliputScript(LilliputEngine *vm);
~LilliputScript();
@ -103,7 +101,6 @@ private:
byte _byte12A09;
byte _byte129A0;
byte _byte10806;
byte _byte12FE4;
byte _byte16F02;
byte _byte16F04;
byte _byte1881A;
@ -130,7 +127,7 @@ private:
void sub18B3C(int var);
void displayNumber(byte var1, Common::Point pos);
byte *getMapPtr(Common::Point val);
byte *sub173D2();
byte *getCurrentCharacterVarFromScript();
void sub171AF(int var1, int var2, int var4);
void sub18B7C(int var1, int var3);
void sub189B8();
@ -174,8 +171,8 @@ private:
byte OC_compWord16EFE();
byte OC_AreCurrentCharacterVar0AndVar1EqualsTo();
byte OC_CurrentCharacterVar0Equals();
byte OC_sub17825();
byte OC_sub17844();
byte OC_checkLastInterfaceHotspotIndexMenu13();
byte OC_checkLastInterfaceHotspotIndexMenu2();
byte OC_CompareNumberOfCharacterWithVar0Equals();
byte OC_IsPositionInViewport();
byte OC_CompareGameVariables();
@ -189,7 +186,7 @@ private:
byte OC_sub1793E();
byte OC_CurrentCharacterVar3Equals1();
byte OC_checkCharacterDirection();
byte OC_sub17984();
byte OC_checkLastInterfaceHotspotIndex();
byte OC_checkSavedMousePos();
byte OC_sub179AE();
byte OC_sub179C2();
@ -255,7 +252,7 @@ private:
void OC_sub1805D();
void OC_sub18074();
void OC_setCurrentCharacterDirection();
void OC_sub18099();
void OC_setInterfaceHotspot();
void OC_sub180C3();
void OC_setViewPortPos();
void OC_setCurrentCharacterAltitude();
@ -277,7 +274,7 @@ private:
void OC_setDebugFlag();
void OC_setByte14837();
void OC_sub183A2();
void OC_sub183C6();
void OC_disableInterfaceHotspot();
void OC_loadFile_AERIAL_GFX();
void OC_sub17E22_speech1IfSoundOff();
void OC_sub1844A();