aboutsummaryrefslogtreecommitdiff
path: root/engines/lilliput
diff options
context:
space:
mode:
authorStrangerke2012-06-01 08:18:33 +0200
committerEugene Sandulenko2018-03-28 17:36:57 +0200
commit147a450834cd4a89b7dcf004eb098ef3558d6b18 (patch)
tree92fa0b9873d9e30da8789e86adbe16d681123691 /engines/lilliput
parentf625b6011700b059b5a4a0155025a7954c352cb6 (diff)
downloadscummvm-rg350-147a450834cd4a89b7dcf004eb098ef3558d6b18.tar.gz
scummvm-rg350-147a450834cd4a89b7dcf004eb098ef3558d6b18.tar.bz2
scummvm-rg350-147a450834cd4a89b7dcf004eb098ef3558d6b18.zip
LILLIPUT: Fix bug in OC_loadFile_AERIAL_GFX, implement OC_waitForEvent
Diffstat (limited to 'engines/lilliput')
-rw-r--r--engines/lilliput/lilliput.cpp33
-rw-r--r--engines/lilliput/lilliput.h5
-rw-r--r--engines/lilliput/script.cpp51
-rw-r--r--engines/lilliput/script.h2
4 files changed, 59 insertions, 32 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp
index 6f15d022b7..7a99fd683a 100644
--- a/engines/lilliput/lilliput.cpp
+++ b/engines/lilliput/lilliput.cpp
@@ -124,7 +124,7 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd)
_savedMousePosDivided = Common::Point(-1, -1);
_skipDisplayFlag1 = 1;
_skipDisplayFlag2 = 0;
- _displayMap = 0;
+ _displayMap = false;
_debugFlag = 0;
_byte14837 = 0;
@@ -470,7 +470,7 @@ void LilliputEngine::restoreSurfaceSpeech() {
void LilliputEngine::displayInterfaceHotspots() {
debugC(2, kDebugEngine, "displayInterfaceHotspots()");
- if (_displayMap == 1)
+ if (_displayMap)
return;
restoreSurfaceUnderMousePointer();
@@ -635,7 +635,7 @@ void LilliputEngine::displayIsometricBlock(byte *buf, int var1, int posX, int po
void LilliputEngine::displayGameArea() {
debugC(2, kDebugEngine, "displayGameArea()");
- if (_displayMap == 1)
+ if (_displayMap)
return;
if (_mouseDisplayPos.x > 48)
@@ -797,7 +797,7 @@ void LilliputEngine::prepareGameArea() {
void LilliputEngine::displayRefreshScreen() {
debugC(2, kDebugEngine, "displayRefreshScreen()");
- if (_displayMap == 1) {
+ if (_displayMap) {
bool forceReturnFl = false;
checkMapClosing(forceReturnFl);
if (forceReturnFl)
@@ -999,19 +999,22 @@ void LilliputEngine::checkMapClosing(bool &forceReturnFl) {
debugC(2, kDebugEngineTBC, "checkMapClosing()");
forceReturnFl = false;
- if (_displayMap != 1)
+ if (_displayMap)
return;
pollEvent();
- warning("checkMapClosing- TODO: Check keyboard");
-
- if ((_mouseButton & 1) == 0)
+ if (_keyboard_checkKeyboard()) {
+ _keyboard_getch();
return;
+ } else {
+ if ((_mouseButton & 1) == 0)
+ return;
- _mouseButton = 0;
- sub15F75();
+ _mouseButton = 0;
+ sub15F75();
+ }
- _displayMap = 0;
+ _displayMap = false;
paletteFadeOut();
_word15AC2 = 0;
unselectInterfaceHotspots();
@@ -2830,4 +2833,12 @@ Common::KeyState LilliputEngine::_keyboard_getch() {
return tmpEvent;
}
+bool LilliputEngine::_keyboard_checkKeyboard() {
+ return (_keyboard_nextIndex != _keyboard_oldIndex);
+}
+
+void LilliputEngine::_keyboard_resetKeyboardBuffer() {
+ _keyboard_nextIndex = _keyboard_oldIndex = 0;
+}
+
} // End of namespace Lilliput
diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h
index 2aa952b863..5cf577084e 100644
--- a/engines/lilliput/lilliput.h
+++ b/engines/lilliput/lilliput.h
@@ -118,7 +118,6 @@ public:
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
byte _byte14837; // Unused byte, set by an opcode
@@ -135,7 +134,7 @@ public:
bool _saveFlag;
bool _int8installed;
- byte _displayMap;
+ bool _displayMap;
int _word10800_ERULES;
byte _numCharacters;
@@ -362,6 +361,8 @@ public:
// Temporary stubs
Common::KeyState _keyboard_getch();
+ bool _keyboard_checkKeyboard();
+ void _keyboard_resetKeyboardBuffer();
protected:
Common::EventManager *_eventMan;
diff --git a/engines/lilliput/script.cpp b/engines/lilliput/script.cpp
index 71396fb170..3138779ed7 100644
--- a/engines/lilliput/script.cpp
+++ b/engines/lilliput/script.cpp
@@ -474,7 +474,7 @@ void LilliputScript::handleOpcodeType2(int curWord) {
OC_setByte14837();
break;
case 0x4D:
- OC_sub183A2();
+ OC_waitForEvent();
break;
case 0x4E:
OC_disableInterfaceHotspot();
@@ -686,7 +686,7 @@ static const OpCode opCodes2[] = {
/* 0x4a */ { "OC_sub18387", 2, kGetValue1, kImmediateValue, kNone, kNone, kNone },
/* 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 },
+/* 0x4d */ { "OC_waitForEvent", 0, kNone, kNone, kNone, kNone, kNone },
/* 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 },
@@ -1088,7 +1088,7 @@ void LilliputScript::checkSpeechAllowed(bool &forceReturnFl) {
debugC(1, kDebugScript, "checkSpeechAllowed()");
forceReturnFl = false;
- if ((_vm->_displayMap != 1) && (_vm->_characterRelativePositionX[_vm->_currentScriptCharacter] != 0xFF))
+ if ((!_vm->_displayMap) && (_vm->_characterRelativePositionX[_vm->_currentScriptCharacter] != 0xFF))
return;
forceReturnFl = true;
@@ -3041,8 +3041,23 @@ void LilliputScript::OC_setByte14837() {
_vm->_byte14837 = 1;
}
-void LilliputScript::OC_sub183A2() {
- warning("OC_sub183A2");
+void LilliputScript::OC_waitForEvent() {
+ debugC(1, kDebugScriptTBC, "OC_waitForEvent()");
+
+ _vm->_refreshScreenFlag = true;
+ while (true) {
+ if (_vm->_keyboard_checkKeyboard()) {
+ _vm->_keyboard_getch();
+ break;;
+ }
+ if (_vm->_mouseButton & 1)
+ break;
+
+ _vm->update();
+ }
+
+ _vm->_mouseButton = 0;
+ _vm->_refreshScreenFlag = false;
}
void LilliputScript::OC_disableInterfaceHotspot() {
@@ -3059,7 +3074,8 @@ void LilliputScript::OC_loadFile_AERIAL_GFX() {
debugC(1, kDebugScriptTBC, "OC_loadFile_AERIAL_GFX()");
int var1 = _currScript->readUint16LE() & 0xFF;
- _vm->_byte15EAD = var1;
+// unused variable
+// byte _byte15EAD = var1;
_vm->_refreshScreenFlag = true;
_talkingCharacter = -1;
@@ -3069,9 +3085,9 @@ void LilliputScript::OC_loadFile_AERIAL_GFX() {
OC_PaletteFadeIn();
_vm->displayCharactersOnMap();
- _vm->_byte16F08 = 1;
- _vm->_keyboard_oldIndex = 0;
- _vm->_keyboard_nextIndex = 0;
+ _vm->_displayMap = true;
+
+ _vm->_keyboard_resetKeyboardBuffer();
_vm->_refreshScreenFlag = false;
}
@@ -3105,7 +3121,7 @@ void LilliputScript::OC_displayNumericCharacterVariable() {
int posX = _currScript->readSint16LE();
int posY = _currScript->readSint16LE();
- if (_vm->_displayMap != 1) {
+ if (!_vm->_displayMap) {
_vm->restoreSurfaceUnderMousePointer();
displayNumber(displayVal, Common::Point(posX, posY));
_vm->displayMousePointer();
@@ -3151,20 +3167,19 @@ void LilliputScript::OC_displayTitleScreen() {
_vm->_byte184F4 = (_currScript->readUint16LE() & 0xFF);
_vm->_sound_byte16F06 = _vm->_byte184F4;
- // TODO: Rewrite keyboard handling (this code was in a separated function)
- _vm->_keyboard_nextIndex = 0;
- _vm->_keyboard_oldIndex = 0;
- //
+ _vm->_keyboard_resetKeyboardBuffer();
+
_vm->_mouseButton = 0;
-// _vm->_lastKeyPressed = 0;
+ _vm->_lastKeyPressed = Common::KeyState();
while (!_vm->_shouldQuit) {
_vm->displaySmallAnims();
_vm->update();
_vm->pollEvent();
- if (_vm->_keyboard_nextIndex != _vm->_keyboard_oldIndex) {
+ if (_vm->_keyboard_checkKeyboard()) {
_vm->_lastKeyPressed = _vm->_keyboard_getch();
- _vm->_keyboard_getch();
+ // Removed: why asking for 2 keystrikes?
+ // _vm->_keyboard_getch();
break;
}
@@ -3182,7 +3197,7 @@ void LilliputScript::OC_initGameAreaDisplay() {
debugC(1, kDebugScript, "OC_initGameAreaDisplay()");
OC_PaletteFadeOut();
- _vm->_displayMap = 0;
+ _vm->_displayMap = false;
_heroismLevel = 0;
_vm->unselectInterfaceHotspots();
diff --git a/engines/lilliput/script.h b/engines/lilliput/script.h
index 757ce91ab5..bc5fc972f0 100644
--- a/engines/lilliput/script.h
+++ b/engines/lilliput/script.h
@@ -271,7 +271,7 @@ private:
void OC_sub18387();
void OC_setDebugFlag();
void OC_setByte14837();
- void OC_sub183A2();
+ void OC_waitForEvent();
void OC_disableInterfaceHotspot();
void OC_loadFile_AERIAL_GFX();
void OC_sub17E22_speech1IfSoundOff();